UNPKG

@zxxxy/koishi-plugin-tarotpro

Version:

抽取文字加强

13 lines 522 kB
var Td=Object.create;var qn=Object.defineProperty;var Ad=Object.getOwnPropertyDescriptor;var Cd=Object.getOwnPropertyNames;var $d=Object.getPrototypeOf,Pd=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Os=(e,t)=>{for(var i in t)qn(e,i,{get:t[i],enumerable:!0})},Fn=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Cd(t))!Pd.call(e,r)&&r!==i&&qn(e,r,{get:()=>t[r],enumerable:!(n=Ad(t,r))||n.enumerable});return e},le=(e,t,i)=>(Fn(e,t,"default"),i&&Fn(i,t,"default")),st=(e,t,i)=>(i=e!=null?Td($d(e)):{},Fn(t||!e||!e.__esModule?qn(i,"default",{value:e,enumerable:!0}):i,e)),Nd=e=>Fn(qn({},"__esModule",{value:!0}),e);var oc=S(($w,Id)=>{Id.exports={name:"@koishijs/core",description:"Core Features for Koishi",version:"4.18.7",main:"lib/index.cjs",module:"lib/index.mjs",typings:"lib/index.d.ts",files:["lib","src"],author:"Shigma <shigma10826@gmail.com>",license:"MIT",repository:{type:"git",url:"git+https://github.com/koishijs/koishi.git",directory:"packages/core"},bugs:{url:"https://github.com/koishijs/koishi/issues"},homepage:"https://koishi.chat",keywords:["bot","chatbot","koishi"],devDependencies:{"@minatojs/driver-memory":"^3.6.0","@types/chai":"^4.3.16","@types/chai-as-promised":"^7.1.8",chai:"^5.1.1","chai-as-promised":"^7.1.1","chai-shape":"^1.1.0"},dependencies:{"@koishijs/i18n-utils":"^1.0.1","@koishijs/utils":"^7.2.1","@satorijs/core":"^4.5.0",cordis:"^3.18.1",cosmokit:"^1.6.3","fastest-levenshtein":"^1.0.16",minato:"^3.6.1"}}});var uc=S((Pw,pc)=>{var Fd=Object.defineProperty,qd=(e,t)=>Fd(e,"name",{value:t,configurable:!0}),lc=class{constructor(e=Math.random){this.get=e}id(e=8,t=16){let i="";for(let n=0;n<e;++n)i+=lc.chars[Math.floor(Math.random()*t)];return i}bool(e){return e>=1?!0:e<=0?!1:this.get()<e}real(...e){let t=e.length>1?e[0]:0,i=e[e.length-1];return this.get()*(i-t)+t}int(...e){return Math.floor(this.real(...e))}splice(e){return e.splice(Math.floor(this.get()*e.length),1)[0]}pick(e,t){if(t===void 0)return this.pick(e,1)[0];let i=e.slice(),n=[];t=Math.min(i.length,t);for(let r=0;r<t;r+=1)n.push(this.splice(i));return n}shuffle(e){return this.pick(e,e.length)}weightedPick(e){let t=Object.entries(e).reduce((r,[,s])=>r+s,0),i=this.get()*t,n=0;for(let r in e)if(n+=e[r],i<n)return r}},Li=lc;qd(Li,"Random");Li.chars="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";var cc=new Li;for(let e of["id","bool","int","real","splice","pick","shuffle","weightedPick"])Li[e]=cc[e].bind(cc);pc.exports=Li});var R=S((Iw,Nc)=>{"use strict";var Ln=Object.defineProperty,Rd=Object.getOwnPropertyDescriptor,Dd=Object.getOwnPropertyNames,Ld=Object.prototype.hasOwnProperty,M=(e,t)=>Ln(e,"name",{value:t,configurable:!0}),Md=(e,t)=>{for(var i in t)Ln(e,i,{get:t[i],enumerable:!0})},Bd=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Dd(t))!Ld.call(e,r)&&r!==i&&Ln(e,r,{get:()=>t[r],enumerable:!(n=Rd(t,r))||n.enumerable});return e},Ud=e=>Bd(Ln({},"__esModule",{value:!0}),e),fc={};Md(fc,{Binary:()=>qt,Time:()=>Ts,arrayBufferToBase64:()=>Wd,arrayBufferToHex:()=>Hd,base64ToArrayBuffer:()=>zd,camelCase:()=>As,camelize:()=>Gd,capitalize:()=>Tc,clone:()=>Rn,contain:()=>yc,deduplicate:()=>Ec,deepEqual:()=>Dn,defineProperty:()=>bc,difference:()=>wc,filterKeys:()=>xc,formatProperty:()=>$c,hexToArrayBuffer:()=>Vd,hyphenate:()=>Kd,intersection:()=>_c,is:()=>at,isNonNullable:()=>dc,isNullable:()=>ti,isPlainObject:()=>hc,makeArray:()=>Oc,mapValues:()=>js,noop:()=>mc,omit:()=>gc,paramCase:()=>$s,pick:()=>vc,remove:()=>Sc,sanitize:()=>Pc,snakeCase:()=>Cc,trimSlash:()=>Ps,uncapitalize:()=>Ac,union:()=>kc,valueMap:()=>js});Nc.exports=Ud(fc);function mc(){}M(mc,"noop");function ti(e){return e==null}M(ti,"isNullable");function dc(e){return!ti(e)}M(dc,"isNonNullable");function hc(e){return e&&typeof e=="object"&&!Array.isArray(e)}M(hc,"isPlainObject");function xc(e,t){return Object.fromEntries(Object.entries(e).filter(([i,n])=>t(i,n)))}M(xc,"filterKeys");function js(e,t){return Object.fromEntries(Object.entries(e).map(([i,n])=>[i,t(n,i)]))}M(js,"mapValues");function vc(e,t,i){if(!t)return{...e};let n={};for(let r of t)(i||e[r]!==void 0)&&(n[r]=e[r]);return n}M(vc,"pick");function gc(e,t){if(!t)return{...e};let i={...e};for(let n of t)Reflect.deleteProperty(i,n);return i}M(gc,"omit");function bc(e,t,i){return Object.defineProperty(e,t,{writable:!0,value:i,enumerable:!1})}M(bc,"defineProperty");function yc(e,t){return t.every(i=>e.includes(i))}M(yc,"contain");function _c(e,t){return e.filter(i=>t.includes(i))}M(_c,"intersection");function wc(e,t){return e.filter(i=>!t.includes(i))}M(wc,"difference");function kc(e,t){return Array.from(new Set([...e,...t]))}M(kc,"union");function Ec(e){return[...new Set(e)]}M(Ec,"deduplicate");function Sc(e,t){let i=e?.indexOf(t);return i>=0?(e.splice(i,1),!0):!1}M(Sc,"remove");function Oc(e){return Array.isArray(e)?e:ti(e)?[]:[e]}M(Oc,"makeArray");function at(e,t){return arguments.length===1?i=>at(e,i):e in globalThis&&t instanceof globalThis[e]||Object.prototype.toString.call(t).slice(8,-1)===e}M(at,"is");function Mi(e){return at("ArrayBuffer",e)||at("SharedArrayBuffer",e)}M(Mi,"isArrayBufferLike");function jc(e){return Mi(e)||ArrayBuffer.isView(e)}M(jc,"isArrayBufferSource");var qt;(e=>{e.is=Mi,e.isSource=jc;function t(a){return ArrayBuffer.isView(a)?a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength):a}e.fromSource=t,M(t,"fromSource");function i(a){if(typeof Buffer<"u")return Buffer.from(a).toString("base64");let o="",c=new Uint8Array(a);for(let l=0;l<c.byteLength;l++)o+=String.fromCharCode(c[l]);return btoa(o)}e.toBase64=i,M(i,"toBase64");function n(a){return typeof Buffer<"u"?t(Buffer.from(a,"base64")):Uint8Array.from(atob(a),o=>o.charCodeAt(0))}e.fromBase64=n,M(n,"fromBase64");function r(a){return typeof Buffer<"u"?Buffer.from(a).toString("hex"):Array.from(new Uint8Array(a),o=>o.toString(16).padStart(2,"0")).join("")}e.toHex=r,M(r,"toHex");function s(a){if(typeof Buffer<"u")return t(Buffer.from(a,"hex"));let o=a.length%2===0?a:a.slice(0,a.length-1),c=[];for(let l=0;l<o.length;l+=2)c.push(parseInt(`${o[l]}${o[l+1]}`,16));return Uint8Array.from(c).buffer}e.fromHex=s,M(s,"fromHex")})(qt||(qt={}));var zd=qt.fromBase64,Wd=qt.toBase64,Vd=qt.fromHex,Hd=qt.toHex;function Rn(e,t=new Map){if(!e||typeof e!="object")return e;if(at("Date",e))return new Date(e.valueOf());if(at("RegExp",e))return new RegExp(e.source,e.flags);if(Mi(e))return e.slice(0);if(ArrayBuffer.isView(e))return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let i=t.get(e);if(i)return i;if(Array.isArray(e)){let r=[];return t.set(e,r),e.forEach((s,a)=>{r[a]=Reflect.apply(Rn,null,[s,t])}),r}let n=Object.create(Object.getPrototypeOf(e));t.set(e,n);for(let r of Reflect.ownKeys(e)){let s={...Reflect.getOwnPropertyDescriptor(e,r)};"value"in s&&(s.value=Reflect.apply(Rn,null,[s.value,t])),Reflect.defineProperty(n,r,s)}return n}M(Rn,"clone");function Dn(e,t,i){if(e===t||!i&&ti(e)&&ti(t))return!0;if(typeof e!=typeof t||typeof e!="object"||!e||!t)return!1;function n(r,s){return r(e)?r(t)?s(e,t):!1:r(t)?!1:void 0}return M(n,"check"),n(Array.isArray,(r,s)=>r.length===s.length&&r.every((a,o)=>Dn(a,s[o])))??n(at("Date"),(r,s)=>r.valueOf()===s.valueOf())??n(at("RegExp"),(r,s)=>r.source===s.source&&r.flags===s.flags)??n(Mi,(r,s)=>{if(r.byteLength!==s.byteLength)return!1;let a=new Uint8Array(r),o=new Uint8Array(s);for(let c=0;c<a.length;c++)if(a[c]!==o[c])return!1;return!0})??Object.keys({...e,...t}).every(r=>Dn(e[r],t[r],i))}M(Dn,"deepEqual");function Tc(e){return e.charAt(0).toUpperCase()+e.slice(1)}M(Tc,"capitalize");function Ac(e){return e.charAt(0).toLowerCase()+e.slice(1)}M(Ac,"uncapitalize");function As(e){return e.replace(/[_-][a-z]/g,t=>t.slice(1).toUpperCase())}M(As,"camelCase");function Cs(e,t,i){let n=[],r=0;for(let s=0;s<e.length;s++){let a=e.charCodeAt(s);if(a>=65&&a<=90){if(r===1){let o=e.charCodeAt(s+1);o>=97&&o<=122&&n.push(i),n.push(a+32)}else r!==0&&n.push(i),n.push(a+32);r=1}else a>=97&&a<=122?(n.push(a),r=2):t.includes(a)?(r!==0&&n.push(i),r=0):n.push(a)}return String.fromCharCode(...n)}M(Cs,"tokenize");function $s(e){return Cs(e,[45,95],45)}M($s,"paramCase");function Cc(e){return Cs(e,[45,95],95)}M(Cc,"snakeCase");var Gd=As,Kd=$s;function $c(e){return typeof e!="string"?`[${e.toString()}]`:/^[a-z_$][\w$]*$/i.test(e)?`.${e}`:`[${JSON.stringify(e)}]`}M($c,"formatProperty");function Ps(e){return e.replace(/\/$/,"")}M(Ps,"trimSlash");function Pc(e){return e.startsWith("/")||(e="/"+e),Ps(e)}M(Pc,"sanitize");var Ts;(e=>{e.millisecond=1,e.second=1e3,e.minute=e.second*60,e.hour=e.minute*60,e.day=e.hour*24,e.week=e.day*7;let t=new Date().getTimezoneOffset();function i(d){t=d}e.setTimezoneOffset=i,M(i,"setTimezoneOffset");function n(){return t}e.getTimezoneOffset=n,M(n,"getTimezoneOffset");function r(d=new Date,u){return typeof d=="number"&&(d=new Date(d)),u===void 0&&(u=t),Math.floor((d.valueOf()/e.minute-u)/1440)}e.getDateNumber=r,M(r,"getDateNumber");function s(d,u){let x=new Date(d*e.day);return u===void 0&&(u=t),new Date(+x+u*e.minute)}e.fromDateNumber=s,M(s,"fromDateNumber");let a=/\d+(?:\.\d+)?/.source,o=new RegExp(`^${["w(?:eek(?:s)?)?","d(?:ay(?:s)?)?","h(?:our(?:s)?)?","m(?:in(?:ute)?(?:s)?)?","s(?:ec(?:ond)?(?:s)?)?"].map(d=>`(${a}${d})?`).join("")}$`);function c(d){let u=o.exec(d);return u?(parseFloat(u[1])*e.week||0)+(parseFloat(u[2])*e.day||0)+(parseFloat(u[3])*e.hour||0)+(parseFloat(u[4])*e.minute||0)+(parseFloat(u[5])*e.second||0):0}e.parseTime=c,M(c,"parseTime");function l(d){let u=c(d);return u?d=Date.now()+u:/^\d{1,2}(:\d{1,2}){1,2}$/.test(d)?d=`${new Date().toLocaleDateString()}-${d}`:/^\d{1,2}-\d{1,2}-\d{1,2}(:\d{1,2}){1,2}$/.test(d)&&(d=`${new Date().getFullYear()}-${d}`),d?new Date(d):new Date}e.parseDate=l,M(l,"parseDate");function p(d){let u=Math.abs(d);return u>=e.day-e.hour/2?Math.round(d/e.day)+"d":u>=e.hour-e.minute/2?Math.round(d/e.hour)+"h":u>=e.minute-e.second/2?Math.round(d/e.minute)+"m":u>=e.second?Math.round(d/e.second)+"s":d+"ms"}e.format=p,M(p,"format");function f(d,u=2){return d.toString().padStart(u,"0")}e.toDigits=f,M(f,"toDigits");function m(d,u=new Date){return d.replace("yyyy",u.getFullYear().toString()).replace("yy",u.getFullYear().toString().slice(2)).replace("MM",f(u.getMonth()+1)).replace("dd",f(u.getDate())).replace("hh",f(u.getHours())).replace("mm",f(u.getMinutes())).replace("ss",f(u.getSeconds())).replace("SSS",f(u.getMilliseconds(),3))}e.template=m,M(m,"template")})(Ts||(Ts={}))});var Dt=S((Fw,Ls)=>{var Yd=Object.create,Bi=Object.defineProperty,Jd=Object.getOwnPropertyDescriptor,Qd=Object.getOwnPropertyNames,Xd=Object.getPrototypeOf,Zd=Object.prototype.hasOwnProperty,de=(e,t)=>Bi(e,"name",{value:t,configurable:!0}),eh=(e,t)=>{for(var i in t)Bi(e,i,{get:t[i],enumerable:!0})},Mn=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Qd(t))!Zd.call(e,r)&&r!==i&&Bi(e,r,{get:()=>t[r],enumerable:!(n=Jd(t,r))||n.enumerable});return e},th=(e,t,i)=>(Mn(e,t,"default"),i&&Mn(i,t,"default")),ih=(e,t,i)=>(i=e!=null?Yd(Xd(e)):{},Mn(t||!e||!e.__esModule?Bi(i,"default",{value:e,enumerable:!0}):i,e)),nh=e=>Mn(Bi({},"__esModule",{value:!0}),e),Is={};eh(Is,{Random:()=>rh.default,assertProperty:()=>Lc,coerce:()=>Mc,defineEnumProperty:()=>Dc,enumKeys:()=>Rc,escapeRegExp:()=>Gc,extend:()=>Uc,interpolate:()=>Hc,isInteger:()=>Fc,isType:()=>sh.is,merge:()=>Fs,observe:()=>Vc,renameProperty:()=>Bc,sleep:()=>qc});Ls.exports=nh(Is);var rh=ih(uc()),sh=R();th(Is,R(),Ls.exports);function Fc(e){return typeof e=="number"&&Math.floor(e)===e}de(Fc,"isInteger");async function qc(e){return new Promise(t=>setTimeout(t,e))}de(qc,"sleep");function Rc(e){return Object.values(e).filter(t=>typeof t=="string")}de(Rc,"enumKeys");function Dc(e,t,i){e[t]=i,e[i]=t}de(Dc,"defineEnumProperty");function Fs(e,t){return Object.entries(t).forEach(([i,n])=>{if(typeof e[i]>"u")return e[i]=n;Object.hasOwn(e,i)&&(typeof n=="object"&&typeof e[i]=="object"?e[i]=Fs(e[i],n):e[i]=n)}),e}de(Fs,"merge");function Lc(e,t){if(!e[t])throw new Error(`missing configuration "${t}"`);return e[t]}de(Lc,"assertProperty");function Mc(e){let{message:t,stack:i}=e instanceof Error&&e.stack?e:new Error(e),n=i.split(` `),r=n.findIndex(s=>s.endsWith(t));return n.slice(r).join(` `)}de(Mc,"coerce");function Bc(e,t,i){e[t]=Reflect.get(e,i),Reflect.deleteProperty(e,i)}de(Bc,"renameProperty");function Uc(e,t){Object.defineProperties(e,Object.getOwnPropertyDescriptors(t))}de(Uc,"extend");var Rt=R(),qs=["number","string","bigint","boolean","symbol","function"],ah=["Date","RegExp","Set","Map","WeakSet","WeakMap","Array"];function Rs(e,t){return(0,Rt.is)("Date",e)?Wc(e,t):Array.isArray(e)?zc(e,t):Ds(e,t)}de(Rs,"observeProperty");function Ns(e){return typeof e=="symbol"||e.startsWith("$")}de(Ns,"untracked");function Ds(e,t){let i=t;if(!t){let r=Object.create(null);(0,Rt.defineProperty)(e,"$diff",r),t=de(s=>{Ns(s)||(r[s]=e[s])},"notify")}return new Proxy(e,{get(r,s){let a=Reflect.get(r,s);return!a||qs.includes(typeof a)||Ns(s)?a:Rs(a,i||(()=>t(s)))},set(r,s,a){let o=r[s]===a,c=Reflect.set(r,s,a);return o||!c?c:(t(s),!0)},deleteProperty(r,s){let a=!(s in r),o=Reflect.deleteProperty(r,s);return a||!o?o:(t(s),!0)}})}de(Ds,"observeObject");var oh=["pop","shift","splice","sort"];function zc(e,t){let i={};for(let n of oh)(0,Rt.defineProperty)(e,n,function(...r){return t(),Array.prototype[n].apply(this,r)});return new Proxy(e,{get(n,r){if(r in i)return i[r];let s=n[r];return!s||qs.includes(typeof s)||typeof r=="symbol"||isNaN(r)?s:Rs(s,t)},set(n,r,s){return typeof r!="symbol"&&!isNaN(r)&&n[r]!==s&&t(),Reflect.set(n,r,s)}})}de(zc,"observeArray");function Wc(e,t){for(let i of Object.getOwnPropertyNames(Date.prototype))i!=="valueOf"&&(0,Rt.defineProperty)(e,i,function(...n){let r=e.valueOf(),s=Date.prototype[i].apply(this,n);return e.valueOf()!==r&&t(),s});return e}de(Wc,"observeDate");function Vc(e,...t){if(qs.includes(typeof e))throw new Error(`cannot observe immutable type "${typeof e}"`);if(!e)throw new Error("cannot observe null or undefined");let i=Object.prototype.toString.call(e).slice(8,-1);if(ah.includes(i))throw new Error(`cannot observe instance of type "${i}"`);let n=Rt.noop;typeof t[0]=="function"&&(n=t.shift());let r=Ds(e,null);return(0,Rt.defineProperty)(r,"$update",de(function(){let a={...this.$diff};if(Object.keys(a).length){for(let c in this.$diff)delete this.$diff[c];return n(a)}},"$update")),(0,Rt.defineProperty)(r,"$merge",de(function(a){for(let o in a){if(o in this.$diff)throw new Error(`unresolved diff key "${o}"`);e[o]=a[o]}return this},"$merge")),r}de(Vc,"observe");var Ic=new Function("context","expr",` try { with (context) { return eval(expr) } } catch {} `);function Hc(e,t,i=/\{\{([\s\S]+?)\}\}/g){let n,r="",s=0;for(;n=i.exec(e);){if(n[0]===e)return Ic(t,n[1]);r+=e.slice(s,n.index),r+=Ic(t,n[1])??"",s=n.index+n[0].length}return r+e.slice(s)}de(Hc,"interpolate");function Gc(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}de(Gc,"escapeRegExp")});var ai=S((qw,rl)=>{"use strict";var Hn=Object.defineProperty,ch=Object.getOwnPropertyDescriptor,lh=Object.getOwnPropertyNames,ph=Object.prototype.hasOwnProperty,D=(e,t)=>Hn(e,"name",{value:t,configurable:!0}),uh=(e,t)=>{for(var i in t)Hn(e,i,{get:t[i],enumerable:!0})},fh=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of lh(t))!ph.call(e,r)&&r!==i&&Hn(e,r,{get:()=>t[r],enumerable:!(n=ch(t,r))||n.enumerable});return e},mh=e=>fh(Hn({},"__esModule",{value:!0}),e),Yc={};uh(Yc,{Context:()=>Ie,CordisError:()=>Vn,EffectScope:()=>Ws,ForkScope:()=>el,Inject:()=>zi,Lifecycle:()=>Qc,MainScope:()=>Bs,ReflectService:()=>zn,Registry:()=>il,ScopeStatus:()=>Xc,Service:()=>wh,createCallable:()=>Un,getTraceable:()=>He,isBailed:()=>Wn,isConstructor:()=>Gn,isObject:()=>Yn,isUnproxyable:()=>Us,joinPrototype:()=>Kn,resolveConfig:()=>si,symbols:()=>j,withProps:()=>ri});rl.exports=mh(Yc);var dh=R(),ot=R(),ii=R(),hh=R(),j={shadow:Symbol.for("cordis.shadow"),receiver:Symbol.for("cordis.receiver"),original:Symbol.for("cordis.original"),store:Symbol.for("cordis.store"),events:Symbol.for("cordis.events"),static:Symbol.for("cordis.static"),filter:Symbol.for("cordis.filter"),expose:Symbol.for("cordis.expose"),isolate:Symbol.for("cordis.isolate"),internal:Symbol.for("cordis.internal"),intercept:Symbol.for("cordis.intercept"),setup:Symbol.for("cordis.setup"),invoke:Symbol.for("cordis.invoke"),extend:Symbol.for("cordis.extend"),tracker:Symbol.for("cordis.tracker"),provide:Symbol.for("cordis.provide"),immediate:Symbol.for("cordis.immediate")},xh=function*(){}.constructor,Kc=async function*(){}.constructor;function Gn(e){return!(!e.prototype||e instanceof xh||Kc!==Function&&e instanceof Kc)}D(Gn,"isConstructor");function si(e,t){let i=e.Config||e.schema;return i&&e.schema!==!1&&(t=i(t)),t??{}}D(si,"resolveConfig");function Us(e){return[Map,Set,Date,Promise].some(t=>e instanceof t)}D(Us,"isUnproxyable");function Kn(e,t){if(e===Object.prototype)return t;let i=Object.create(Kn(Object.getPrototypeOf(e),t));for(let n of Reflect.ownKeys(e))Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(e,n));return i}D(Kn,"joinPrototype");function Yn(e){return e&&(typeof e=="object"||typeof e=="function")}D(Yn,"isObject");function He(e,t,i){if(!Yn(t))return t;if(Object.hasOwn(t,j.shadow))return Object.getPrototypeOf(t);let n=t[j.tracker];return n?Jn(e,t,n,i):t}D(He,"getTraceable");function ri(e,t){return t?new Proxy(e,{get:D((i,n,r)=>n in t&&n!=="constructor"?Reflect.get(t,n,r):Reflect.get(i,n,r),"get"),set:D((i,n,r,s)=>n in t&&n!=="constructor"?Reflect.set(t,n,r,s):Reflect.set(i,n,r,s),"set")}):e}D(ri,"withProps");function Bn(e,t,i){return ri(e,Object.defineProperty(Object.create(null),t,{value:i,writable:!1}))}D(Bn,"withProp");function Ms(e,t,i,n){if(!i)return n;let r=Reflect.getOwnPropertyDescriptor(t,i)?.value;return r?Bn(n,i,e.extend({[j.shadow]:r})):n}D(Ms,"createShadow");function Jc(e,t,i,n){return new Proxy(t,{apply:D((r,s,a)=>(s===i&&(s=n),a=a.map(o=>typeof o!="function"||o[j.original]?o:new Proxy(o,{get:D((c,l,p)=>{if(l===j.original)return c;let f=Reflect.get(c,l,p);return l==="toString"&&f===Function.prototype.toString?function(...m){return Reflect.apply(f,this===p?c:this,m)}:f},"get"),apply:D((c,l,p)=>Reflect.apply(c,He(e,l),p.map(f=>He(e,f))),"apply"),construct:D((c,l,p)=>Reflect.construct(c,l.map(f=>He(e,f)),p),"construct")})),He(e,Reflect.apply(r,s,a))),"apply")})}D(Jc,"createShadowMethod");function Jn(e,t,i,n){e[j.shadow]&&(e=Object.getPrototypeOf(e));let r=new Proxy(t,{get:D((s,a,o)=>{if(a===j.original)return s;if(a===i.property)return e;if(typeof a=="symbol")return Reflect.get(s,a,o);if(i.associate&&e[j.internal][`${i.associate}.${a}`])return Reflect.get(e,`${i.associate}.${a}`,Bn(e,j.receiver,o));let c=Ms(e,s,i.property,o),l=Reflect.get(s,a,c),p=l?.[j.tracker];return p?Jn(e,l,p):!n&&typeof l=="function"?Jc(e,l,o,c):l},"get"),set:D((s,a,o,c)=>{if(a===j.original||a===i.property)return!1;if(typeof a=="symbol")return Reflect.set(s,a,o,c);if(i.associate&&e[j.internal][`${i.associate}.${a}`])return Reflect.set(e,`${i.associate}.${a}`,o,Bn(e,j.receiver,c));let l=Ms(e,s,i.property,c);return Reflect.set(s,a,o,l)},"set"),apply:D((s,a,o)=>zs(r,s,a,o),"apply")});return r}D(Jn,"createTraceable");function zs(e,t,i,n){return t[j.invoke]?t[j.invoke].apply(e,n):Reflect.apply(t,i,n)}D(zs,"applyTraceable");function Un(e,t,i){let n=D(function(...r){let s=Jn(n.ctx,n,i);return zs(s,n,this,r)},"self");return(0,hh.defineProperty)(n,"name",e),Object.setPrototypeOf(n,t)}D(Un,"createCallable");var vh=class ni{constructor(t){this.ctx=t,(0,ii.defineProperty)(this,j.tracker,{associate:"reflect",property:"ctx"}),this._mixin("reflect",["get","set","provide","accessor","mixin","alias"]),this._mixin("scope",["config","runtime","effect","collect","accept","decline"]),this._mixin("registry",["using","inject","plugin"]),this._mixin("lifecycle",["on","once","parallel","emit","serial","bail","start","stop"])}static{D(this,"ReflectService")}static resolveInject(t,i){let n=t[j.internal][i];for(;n?.type==="alias";)i=n.name,n=t[j.internal][i];return[i,n]}static checkInject(t,i,n){if(t=t[j.shadow]??t,["prototype","then","registry","lifecycle"].includes(i)||i[0]==="$"||i[0]==="_"||!t.runtime.plugin||t.bail(t,"internal/inject",i))return;let r=n.stack.split(` `);r.splice(1,1),n.stack=r.join(` `),t.emit(t,"internal/warning",n)}static handler={get:D((t,i,n)=>{if(typeof i!="string")return Reflect.get(t,i,n);if(Reflect.has(t,i))return He(n,Reflect.get(t,i,n),!0);let[r,s]=ni.resolveInject(t,i),a=new Error(`property ${r} is not registered, declare it as \`inject\` to suppress this warning`);return s?s.type==="accessor"?s.get.call(n,n[j.receiver]):(s.builtin||ni.checkInject(n,r,a),n.reflect.get(r)):(ni.checkInject(n,r,a),Reflect.get(t,r,n))},"get"),set:D((t,i,n,r)=>{if(typeof i!="string")return Reflect.set(t,i,n,r);let[s,a]=ni.resolveInject(t,i);return a?a.type==="accessor"?a.set?a.set.call(r,n,r[j.receiver]):!1:(r.reflect.set(s,n),!0):Reflect.set(t,s,n,r)},"set"),has:D((t,i)=>{if(typeof i!="string")return Reflect.has(t,i);if(Reflect.has(t,i))return!0;let[,n]=ni.resolveInject(t,i);return!!n},"has")};get(t){if(this.ctx[j.internal][t]?.type!=="service")return;let n=this.ctx[j.isolate][t],r=this.ctx[j.store][n]?.value;return He(this.ctx,r)}set(t,i){this.provide(t);let n=this.ctx[j.isolate][t],r=this.ctx[j.store][n]?.value;i??=void 0;let s=D(()=>{},"dispose");if(r===i)return s;if(!(0,ii.isNullable)(i)&&!(0,ii.isNullable)(r))throw new Error(`service ${t} has been registered`);let a=this.ctx;(0,ii.isNullable)(i)||(s=a.effect(()=>()=>{a.set(t,void 0)})),Us(i)&&a.emit(a,"internal/warning",new Error(`service ${t} is an unproxyable object, which may lead to unexpected behavior`));let o=Object.create(a);return o[j.filter]=c=>a[j.isolate][t]===c[j.isolate][t],a.emit(o,"internal/before-service",t,i),a[j.store][n]={value:i,source:a},a.emit(o,"internal/service",t,r),s}provide(t,i,n){let r=this.ctx.root[j.internal];if(t in r)return;let s=Symbol(t);r[t]={type:"service",builtin:n},this.ctx.root[j.isolate][t]=s,Yn(i)&&(this.ctx[j.store][s]={value:i,source:null},(0,ii.defineProperty)(i,j.tracker,{associate:t,property:"ctx"}))}_accessor(t,i){let n=this.ctx.root[j.internal];return t in n?()=>{}:(n[t]={type:"accessor",...i},()=>delete this.ctx.root[j.isolate][t])}accessor(t,i){this.ctx.scope.effect(()=>this._accessor(t,i))}alias(t,i){let n=this.ctx.root[j.internal];if(!(t in n))for(let r of i)n[r]||={type:"alias",name:t}}_mixin(t,i){let n=Array.isArray(i)?i.map(a=>[a,a]):Object.entries(i),r=typeof t=="string"?a=>a[t]:()=>t,s=n.map(([a,o])=>this._accessor(o,{get(c){let l=r(this);if((0,ii.isNullable)(l))return l;let p=c?ri(c,l):l,f=Reflect.get(l,a,p);return typeof f!="function"?f:f.bind(p??l)},set(c,l){let p=r(this),f=l?ri(l,p):p;return Reflect.set(p,a,c,f)}}));return()=>s.forEach(a=>a())}mixin(t,i){this.ctx.scope.effect(()=>this._mixin(t,i))}trace(t){return He(this.ctx,t)}bind(t){return new Proxy(t,{apply:D((i,n,r)=>i.apply(this.trace(n),r.map(s=>this.trace(s))),"apply")})}},zn=vh;function Wn(e){return e!==null&&e!==!1&&e!==void 0}D(Wn,"isBailed");var gh=class{constructor(e){this.ctx=e,(0,ot.defineProperty)(this,j.tracker,{associate:"lifecycle",property:"ctx"}),(0,ot.defineProperty)(this.on("internal/listener",function(i,n,r){let s=r.prepend?"unshift":"push";if(i==="ready")return this.lifecycle.isActive?(this.scope.ensure(async()=>n()),()=>!1):void 0;if(i==="dispose")return this.scope.disposables[s](n),(0,ot.defineProperty)(n,"name","event <dispose>"),()=>(0,ot.remove)(this.scope.disposables,n);if(i==="fork")return this.scope.runtime.forkables[s](n),this.scope.collect("event <fork>",()=>(0,ot.remove)(this.scope.runtime.forkables,n))}),Ie.static,e.scope);for(let i of["info","error","warning"])(0,ot.defineProperty)(this.on(`internal/${i}`,(n,...r)=>{this._hooks[`internal/${i}`].length>1||console.info(n,...r)}),Ie.static,e.scope);(0,ot.defineProperty)(this.on("internal/before-service",function(i){for(let n of this.registry.values()){if(!n.inject[i]?.required)continue;let r=n.isReusable?n.children:[n];for(let s of r)this[j.filter](s.ctx)&&(s.updateStatus(),s.reset())}},{global:!0}),Ie.static,e.scope),(0,ot.defineProperty)(this.on("internal/service",function(i){for(let n of this.registry.values()){if(!n.inject[i]?.required)continue;let r=n.isReusable?n.children:[n];for(let s of r)this[j.filter](s.ctx)&&s.start()}},{global:!0}),Ie.static,e.scope);let t=D((i,n)=>{if(!i.runtime.plugin)return!1;for(let r in i.runtime.inject)if(n===zn.resolveInject(i.ctx,r)[0])return!0;return t(i.parent.scope,n)},"checkInject");(0,ot.defineProperty)(this.on("internal/inject",function(i){return t(this.scope,i)},{global:!0}),Ie.static,e.scope)}static{D(this,"Lifecycle")}isActive=!1;_tasks=new Set;_hooks={};async flush(){for(;this._tasks.size;)await Promise.all(Array.from(this._tasks))}filterHooks(e,t){return t=He(this.ctx,t),e.slice().filter(i=>{let n=t?.[Ie.filter];return i.global||!n||n.call(t,i.ctx)})}*dispatch(e,t){let i=typeof t[0]=="object"||typeof t[0]=="function"?t.shift():null,n=t.shift();n!=="internal/event"&&this.emit("internal/event",e,n,t,i);for(let r of this.filterHooks(this._hooks[n]||[],i))yield r.callback.apply(i,t)}async parallel(...e){await Promise.all(this.dispatch("emit",e))}emit(...e){Array.from(this.dispatch("emit",e))}async serial(...e){for await(let t of this.dispatch("serial",e))if(Wn(t))return t}bail(...e){for(let t of this.dispatch("bail",e))if(Wn(t))return t}register(e,t,i,n){let r=n.prepend?"unshift":"push";return t[r]({ctx:this.ctx,callback:i,...n}),this.ctx.state.collect(e,()=>this.unregister(t,i))}unregister(e,t){let i=e.findIndex(n=>n.callback===t);if(i>=0)return e.splice(i,1),!0}on(e,t,i){typeof i!="object"&&(i={prepend:i}),this.ctx.scope.assertActive(),t=this.ctx.reflect.bind(t);let n=this.bail(this.ctx,"internal/listener",e,t,i);if(n)return n;let r=this._hooks[e]||=[],s=typeof e=="string"?`event <${e}>`:"event (Symbol)";return this.register(s,r,t,i)}once(e,t,i){let n=this.on(e,function(...r){return n(),t.apply(this,r)},i);return n}async start(){this.isActive=!0;let e=this._hooks.ready||[];for(;e.length;){let{ctx:t,callback:i}=e.shift();t.scope.ensure(async()=>i())}await this.flush()}async stop(){this.isActive=!1,this.ctx.scope.reset()}},Qc=gh,bh=R(),ct=R(),Xc=(e=>(e[e.PENDING=0]="PENDING",e[e.LOADING=1]="LOADING",e[e.ACTIVE=2]="ACTIVE",e[e.FAILED=3]="FAILED",e[e.DISPOSED=4]="DISPOSED",e))(Xc||{}),Vn=class Zc extends Error{constructor(t,i){super(i??Zc.Code[t]),this.code=t}static{D(this,"CordisError")}};(e=>{e.Code={INACTIVE_EFFECT:"cannot create effect on inactive context"}})(Vn||(Vn={}));var Ws=class{constructor(e,t){this.parent=e,this.config=t,this.uid=e.registry?e.registry.counter:0,this.ctx=this.context=e.extend({scope:this}),this.proxy=new Proxy({},{get:D((i,n)=>Reflect.get(this.config,n),"get")})}static{D(this,"EffectScope")}uid;ctx;disposables=[];error;status=0;isActive=!1;context;proxy;acceptors=[];tasks=new Set;hasError=!1;get _config(){return this.runtime.isReactive?this.proxy:this.config}assertActive(){if(!(this.uid!==null||this.isActive))throw new Vn("INACTIVE_EFFECT")}effect(e,t){this.assertActive();let i=Gn(e)?new e(this.ctx,t):e(this.ctx,t),n=!1,r=typeof i=="function"?i:i.dispose.bind(i),s=D((...a)=>{if(!n)return n=!0,(0,ct.remove)(this.disposables,s),r(...a)},"wrapped");return this.disposables.push(s),typeof i=="function"?s:(i.dispose=s,i)}collect(e,t){let i=(0,ct.defineProperty)(()=>((0,ct.remove)(this.disposables,i),t()),"name",e);return this.disposables.push(i),i}restart(){this.reset(),this.error=null,this.hasError=!1,this.status=0,this.start()}_getStatus(){return this.uid===null?4:this.hasError?3:this.tasks.size?1:this.ready?2:0}updateStatus(e){let t=this.status;e?.(),this.status=this._getStatus(),t!==this.status&&this.context.emit("internal/status",this,t)}ensure(e){let t=e().catch(i=>{this.context.emit(this.ctx,"internal/error",i),this.cancel(i)}).finally(()=>{this.updateStatus(()=>this.tasks.delete(t)),this.context.events._tasks.delete(t)});this.updateStatus(()=>this.tasks.add(t)),this.context.events._tasks.add(t)}cancel(e){this.error=e,this.updateStatus(()=>this.hasError=!0),this.reset()}get ready(){return Object.entries(this.runtime.inject).every(([e,t])=>!t.required||!(0,ct.isNullable)(this.ctx.get(e)))}reset(){this.isActive=!1,this.disposables=this.disposables.splice(0).filter(e=>{if(this.uid!==null&&e[Ie.static]===this)return!0;(async()=>e())().catch(t=>{this.context.emit(this.ctx,"internal/error",t)})})}init(e){this.config?this.start():this.cancel(e)}start(){if(!this.ready||this.isActive||this.uid===null)return!0;this.isActive=!0,this.updateStatus(()=>this.hasError=!1)}accept(...e){let i={keys:Array.isArray(e[0])?e.shift():null,callback:e[0],...e[1]};return this.effect(()=>(this.acceptors.push(i),i.immediate&&i.callback?.(this.config),()=>(0,ct.remove)(this.acceptors,i)))}decline(e){return this.accept(e,()=>!0)}checkUpdate(e,t){if(t||!this.config)return[!0,!0];if(t===!1)return[!1,!1];let i=Object.create(null),n=D(c=>{let l=i[c]??=!(0,ct.deepEqual)(this.config[c],e[c]);return s||=l,l},"checkPropertyUpdate"),r=new Set,s=!1,a=!1,o=this.runtime.isReactive||null;for(let{keys:c,callback:l,passive:p}of this.acceptors){if(!c)o||=!p;else if(p)c?.forEach(m=>r.add(m));else{let m=!1;for(let d of c)m||=n(d);if(!m)continue}l?.(e)&&(a=!0)}for(let c in{...this.config,...e})if(o!==!1&&!(c in i)&&!r.has(c)){let l=n(c);o===null&&(a||=l)}return[s,a]}},el=class extends Ws{constructor(e,t,i,n){super(e,i),this.runtime=t,this.dispose=(0,ct.defineProperty)(e.scope.collect(`fork <${e.runtime.name}>`,()=>{this.uid=null,this.reset(),this.context.emit("internal/fork",this);let r=(0,ct.remove)(t.disposables,this.dispose);return(0,ct.remove)(t.children,this)&&!t.children.length&&e.registry.delete(t.plugin),r}),Ie.static,t),t.children.push(this),t.disposables.push(this.dispose),this.context.emit("internal/fork",this),this.init(n)}static{D(this,"ForkScope")}dispose;start(){if(super.start())return!0;for(let e of this.runtime.forkables)this.ensure(async()=>e(this.context,this._config))}update(e,t){let i=this.config,n=this.runtime.isForkable?this:this.runtime;if(n.config!==i)return;let r;try{r=si(this.runtime.plugin,e)}catch(o){return this.context.emit("internal/error",o),this.cancel(o)}let[s,a]=n.checkUpdate(r,t);this.context.emit("internal/before-update",this,e),this.config=r,n.config=r,s&&this.context.emit("internal/update",this,i),a&&n.restart()}},Bs=class extends Ws{constructor(e,t,i,n){super(e,i),this.plugin=t,t?(this.setup(),this.init(n)):(this.name="root",this.isActive=!0)}static{D(this,"MainScope")}value;runtime=this;schema;name;inject=Object.create(null);forkables=[];children=[];isReusable=!1;isReactive=!1;get isForkable(){return this.forkables.length>0}fork(e,t,i){return new el(e,this,t,i)}dispose(){return this.uid=null,this.reset(),this.context.emit("internal/runtime",this),!0}setup(){let{name:e}=this.plugin;e&&e!=="apply"&&(this.name=e),this.schema=this.plugin.Config||this.plugin.schema,this.inject=zi.resolve(this.plugin.using||this.plugin.inject),this.isReusable=this.plugin.reusable,this.isReactive=this.plugin.reactive,this.context.emit("internal/runtime",this),this.isReusable&&this.forkables.push(this.apply)}apply=D((e,t)=>{if(typeof this.plugin!="function")return this.plugin.apply(e,t);if(Gn(this.plugin)){let i=new this.plugin(e,t),n=i[Ie.expose];return n&&e.set(n,i),i.fork&&this.forkables.push(i.fork.bind(i)),i}else return this.plugin(e,t)},"apply");reset(){super.reset();for(let e of this.children)e.reset()}start(){if(super.start())return!0;!this.isReusable&&this.plugin&&this.ensure(async()=>this.value=this.apply(this.ctx,this._config));for(let e of this.children)e.start()}update(e,t){if(this.isForkable){let o=new Error(`attempting to update forkable plugin "${this.plugin.name}", which may lead to unexpected behavior`);this.context.emit(this.ctx,"internal/warning",o)}let i=this.config,n;try{n=si(this.runtime.plugin||this.context.constructor,e)}catch(o){return this.context.emit("internal/error",o),this.cancel(o)}let[r,s]=this.checkUpdate(n,t),a=this.children.find(o=>o.config===i);this.config=n,a&&(this.context.emit("internal/before-update",a,e),a.config=n,r&&this.context.emit("internal/update",a,i)),s&&this.restart()}};function tl(e){return e&&typeof e=="object"&&typeof e.apply=="function"}D(tl,"isApplicable");function zi(e){return function(t,i){if(i.kind==="class")t.inject=e;else if(i.kind==="method")i.addInitializer(function(){let n=this[j.tracker]?.property;if(!n)throw new Error("missing context tracker");this[n].inject(e,r=>{t.call(ri(this,{[n]:r}))})});else throw new Error("@Inject can only be used on class or class methods")}}D(zi,"Inject");(e=>{function t(i){if(!i)return{};if(Array.isArray(i))return Object.fromEntries(i.map(a=>[a,{required:!0}]));let{required:n,optional:r,...s}=i;return Array.isArray(n)&&Object.assign(s,Object.fromEntries(n.map(a=>[a,{required:!0}]))),Array.isArray(r)&&Object.assign(s,Object.fromEntries(r.map(a=>[a,{required:!1}]))),s}e.resolve=t,D(t,"resolve")})(zi||(zi={}));var yh=class{constructor(e,t){this.ctx=e,(0,bh.defineProperty)(this,j.tracker,{associate:"registry",property:"ctx"}),this.context=e;let i=new Bs(e,null,t);e.scope=i,i.ctx=e,this.set(null,i)}static{D(this,"Registry")}_counter=0;_internal=new Map;context;get counter(){return++this._counter}get size(){return this._internal.size}resolve(e,t=!1){if(e===null||typeof e=="function")return e;if(tl(e))return e.apply;if(t)throw new Error('invalid plugin, expect function or object with an "apply" method, received '+typeof e)}get(e){let t=this.resolve(e);return t&&this._internal.get(t)}has(e){let t=this.resolve(e);return!!t&&this._internal.has(t)}set(e,t){let i=this.resolve(e);this._internal.set(i,t)}delete(e){let t=this.resolve(e),i=t&&this._internal.get(t);if(i)return this._internal.delete(t),i.dispose(),i}keys(){return this._internal.keys()}values(){return this._internal.values()}entries(){return this._internal.entries()}forEach(e){return this._internal.forEach(e)}using(e,t){return this.inject(e,t)}inject(e,t){return this.plugin({inject:e,apply:t,name:t.name})}plugin(e,t,i){if(this.resolve(e,!0),this.ctx.scope.assertActive(),!i)try{t=si(e,t)}catch(r){this.context.emit(this.ctx,"internal/error",r),i=r,t=null}let n=this.get(e);return n?(n.isForkable||this.context.emit(this.ctx,"internal/warning",new Error(`duplicate plugin detected: ${e.name}`)),n.fork(this.ctx,t,i)):(n=new Bs(this.ctx,e,t,i),this.set(e,n),n.fork(this.ctx,t,i))}},il=yh,Ie=class Ui{static{D(this,"Context")}static store=j.store;static events=j.events;static static=j.static;static filter=j.filter;static expose=j.expose;static isolate=j.isolate;static internal=j.internal;static intercept=j.intercept;static origin="ctx";static current="ctx";static is(t){return!!t?.[Ui.is]}static{Ui.is[Symbol.toPrimitive]=()=>Symbol.for("cordis.is"),Ui.prototype[Ui.is]=!0}static associate(t,i){return t}constructor(t){t=si(this.constructor,t),this[j.store]=Object.create(null),this[j.isolate]=Object.create(null),this[j.internal]=Object.create(null),this[j.intercept]=Object.create(null);let i=new Proxy(this,zn.handler);i.root=i,i.reflect=new zn(i),i.registry=new il(i,t),i.lifecycle=new Qc(i);let n=D(r=>{if(r){n(Object.getPrototypeOf(r));for(let s of Object.getOwnPropertyNames(r)){let a=r[s].prototype?.constructor;a&&(i[r[s].key]=new a(i,t),(0,dh.defineProperty)(i[r[s].key],"ctx",i))}}},"attach");return n(this[j.internal]),i}[Symbol.for("nodejs.util.inspect.custom")](){return`Context <${this.name}>`}get name(){let t=this.runtime;for(;t&&!t.name;)t=t.parent.runtime;return t?.name}get events(){return this.lifecycle}get state(){return this.scope}extend(t={}){let i=Reflect.getOwnPropertyDescriptor(this,j.shadow)?.value,n=Object.assign(Object.create(He(this,this)),t);return i?Object.assign(Object.create(n),{[j.shadow]:i}):n}isolate(t,i){let n=Object.create(this[j.isolate]);return n[t]=i??Symbol(t),this.extend({[j.isolate]:n})}intercept(t,i){let n=Object.create(this[j.intercept]);return n[t]=i,this.extend({[j.intercept]:n})}};Ie.prototype[Ie.internal]=Object.create(null);var _h=R(),wh=class nl{static{D(this,"Service")}static setup=j.setup;static invoke=j.invoke;static extend=j.extend;static tracker=j.tracker;static provide=j.provide;static immediate=j.immediate;start(){}stop(){}ctx;name;config;constructor(...t){let i,n,r,s;Ie.is(t[0])?(i=t[0],typeof t[1]=="string"?(n=t[1],r=t[2]):s=t[1]):s=t[0],n??=this.constructor[j.provide],r??=this.constructor[j.immediate];let a=this,o={associate:n,property:"ctx"};return a[j.invoke]&&(a=Un(n,Kn(Object.getPrototypeOf(this),Function.prototype),o)),i?a.ctx=i:a[j.setup](),a.name=n,a.config=s,(0,_h.defineProperty)(a,j.tracker,o),a.ctx.provide(n),a.ctx.runtime.name=n,r&&(i?a[j.expose]=n:a.ctx.set(n,a)),a.ctx.on("ready",async()=>{await Promise.resolve(),await a.start(),r||a.ctx.set(n,a)}),a.ctx.on("dispose",()=>a.stop()),a}[j.filter](t){return t[j.isolate][this.name]===this.ctx[j.isolate][this.name]}[j.setup](){this.ctx=new Ie}[j.extend](t){let i;return this[nl.invoke]?i=Un(this.name,this,this[j.tracker]):i=Object.create(this),Object.assign(i,t)}static[Symbol.hasInstance](t){let i=t.constructor;for(;i;){if(i=i.prototype?.constructor,i===this)return!0;i=Object.getPrototypeOf(i)}return!1}}});var al=S((Uw,sl)=>{"use strict";sl.exports=(e,t=process.argv)=>{let i=e.startsWith("-")?"":e.length===1?"-":"--",n=t.indexOf(i+e),r=t.indexOf("--");return n!==-1&&(r===-1||n<r)}});var ll=S((zw,cl)=>{"use strict";var kh=require("os"),ol=require("tty"),Be=al(),{env:ye}=process,Qn;Be("no-color")||Be("no-colors")||Be("color=false")||Be("color=never")?Qn=0:(Be("color")||Be("colors")||Be("color=true")||Be("color=always"))&&(Qn=1);function Eh(){if("FORCE_COLOR"in ye)return ye.FORCE_COLOR==="true"?1:ye.FORCE_COLOR==="false"?0:ye.FORCE_COLOR.length===0?1:Math.min(Number.parseInt(ye.FORCE_COLOR,10),3)}function Sh(e){return e===0?!1:{level:e,hasBasic:!0,has256:e>=2,has16m:e>=3}}function Oh(e,{streamIsTTY:t,sniffFlags:i=!0}={}){let n=Eh();n!==void 0&&(Qn=n);let r=i?Qn:n;if(r===0)return 0;if(i){if(Be("color=16m")||Be("color=full")||Be("color=truecolor"))return 3;if(Be("color=256"))return 2}if(e&&!t&&r===void 0)return 0;let s=r||0;if(ye.TERM==="dumb")return s;if(process.platform==="win32"){let a=kh.release().split(".");return Number(a[0])>=10&&Number(a[2])>=10586?Number(a[2])>=14931?3:2:1}if("CI"in ye)return["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(a=>a in ye)||ye.CI_NAME==="codeship"?1:s;if("TEAMCITY_VERSION"in ye)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(ye.TEAMCITY_VERSION)?1:0;if(ye.COLORTERM==="truecolor")return 3;if("TERM_PROGRAM"in ye){let a=Number.parseInt((ye.TERM_PROGRAM_VERSION||"").split(".")[0],10);switch(ye.TERM_PROGRAM){case"iTerm.app":return a>=3?3:2;case"Apple_Terminal":return 2}}return/-256(color)?$/i.test(ye.TERM)?2:/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(ye.TERM)||"COLORTERM"in ye?1:s}function Vs(e,t={}){let i=Oh(e,{streamIsTTY:e&&e.isTTY,...t});return Sh(i)}cl.exports={supportsColor:Vs,stdout:Vs({isTTY:ol.isatty(1)}),stderr:Vs({isTTY:ol.isatty(2)})}});var dl=S((Ww,ml)=>{"use strict";var jh=Object.defineProperty,Xn=(e,t)=>jh(e,"name",{value:t,configurable:!0}),pl=ll(),ul=R(),Th=[6,2,3,4,5,1],Ah=[20,21,26,27,32,33,38,39,40,41,42,43,44,45,56,57,62,63,68,69,74,75,76,77,78,79,80,81,92,93,98,99,112,113,129,134,135,148,149,160,161,162,163,164,165,166,167,168,169,170,171,172,173,178,179,184,185,196,197,198,199,200,201,202,203,204,205,206,207,208,209,214,215,220,221];function fl(e){return e instanceof Error&&Array.isArray(e.errors)}Xn(fl,"isAggregateError");var lt=class _e{constructor(t,i){this.name=t,this.meta=i,this.createMethod("success",_e.SUCCESS),this.createMethod("error",_e.ERROR),this.createMethod("info",_e.INFO),this.createMethod("warn",_e.WARN),this.createMethod("debug",_e.DEBUG)}static{Xn(this,"Logger")}static SILENT=0;static SUCCESS=1;static ERROR=1;static INFO=2;static WARN=2;static DEBUG=3;static id=0;static targets=[{colors:pl.stdout&&pl.stdout.level,print(t){console.log(t)}}];static formatters=Object.create(null);static format(t,i){this.formatters[t]=i}static levels={base:2};static color(t,i,n,r=""){return t.colors?`\x1B[3${i<8?i:"8;5;"+i}${t.colors>=2?r:""}m${n}\x1B[0m`:""+n}static code(t,i){let n=0;for(let s=0;s<t.length;s++)n=(n<<3)-n+t.charCodeAt(s)+13,n|=0;let r=i.colors?i.colors>=2?Ah:Th:[];return r[Math.abs(n)%r.length]}static render(t,i){let n=`[${i.type[0].toUpperCase()}]`,r=" ".repeat(t.label?.margin??1),s=3+r.length,a="";t.showTime&&(s+=t.showTime.length+r.length,a+=_e.color(t,8,ul.Time.template(t.showTime))+r);let o=_e.code(i.name,t),c=_e.color(t,o,i.name,";1"),l=(t.label?.width??0)+c.length-i.name.length;if(t.label?.align==="right"?(a+=c.padStart(l)+r+n+r,s+=(t.label.width??0)+r.length):a+=n+r+c.padEnd(l)+r,a+=i.content.replace(/\n/g,` `+" ".repeat(s)),t.showDiff&&t.timestamp){let p=i.timestamp-t.timestamp;a+=_e.color(t,o," +"+ul.Time.format(p))}return a}extend=Xn(t=>new _e(`${this.name}:${t}`,this.meta),"extend");warning=Xn((t,...i)=>{this.warn(t,...i)},"warning");createMethod(t,i){this[t]=(...n)=>{if(n.length===1&&n[0]instanceof Error){if(n[0].cause)this[t](n[0].cause);else if(fl(n[0])){n[0].errors.forEach(a=>this[t](a));return}}let r=++_e.id,s=Date.now();for(let a of _e.targets){if(this.getLevel(a)<i)continue;let o=this.format(a,...n),c={id:r,type:t,level:i,name:this.name,meta:this.meta,content:o,timestamp:s};if(a.record)a.record(c);else{let{print:l=console.log}=a;l(_e.render(a,c))}a.timestamp=s}}}format(t,...i){i[0]instanceof Error?(i[0]=i[0].stack||i[0].message,i.unshift("%s")):typeof i[0]!="string"&&i.unshift("%o");let n=i.shift();n=n.replace(/%([a-zA-Z%])/g,(s,a)=>{if(s==="%%")return"%";let o=_e.formatters[a];if(typeof o=="function"){let c=i.shift();return o(c,t,this)}return s});for(let s of i)typeof s=="object"&&s&&(s=_e.formatters.o(s,t,this)),n+=" "+s;let{maxLength:r=10240}=t;return n.split(/\r?\n/g).map(s=>s.slice(0,r)+(s.length>r?"...":"")).join(` `)}getLevel(t){let i=this.name.split(":"),n=t?.levels||_e.levels;do n=n[i.shift()]??n.base;while(i.length&&typeof n=="object");return n}get level(){return this.getLevel()}set level(t){let i=this.name.split(":"),n=_e.levels;for(;i.length>1;){let r=i.shift(),s=n[r];typeof s=="object"?n=s:n=n[r]={base:s??n.base}}n[i[0]]=t}};lt.format("s",e=>e);lt.format("d",e=>+e);lt.format("j",e=>JSON.stringify(e));lt.format("c",(e,t,i)=>lt.color(t,lt.code(i.name,t),e));lt.format("C",(e,t)=>lt.color(t,15,e,";1"));ml.exports=lt});var gl=S((Vw,vl)=>{"use strict";var Ch=Object.create,hl=Object.defineProperty,$h=Object.getOwnPropertyDescriptor,Ph=Object.getOwnPropertyNames,Nh=Object.getPrototypeOf,Ih=Object.prototype.hasOwnProperty,Fh=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ph(t))!Ih.call(e,r)&&r!==i&&hl(e,r,{get:()=>t[r],enumerable:!(n=$h(t,r))||n.enumerable});return e},qh=(e,t,i)=>(i=e!=null?Ch(Nh(e)):{},Fh(t||!e||!e.__esModule?hl(i,"default",{value:e,enumerable:!0}):i,e)),Rh=require("util"),xl=qh(dl());xl.default.format("o",(e,t)=>(0,Rh.inspect)(e,{colors:!!t.colors,depth:1/0}).replace(/\s*\n\s*/g," "));vl.exports=xl.default});var Hs=S((Hw,Sl)=>{"use strict";var Dh=Object.create,Wi=Object.defineProperty,Lh=Object.getOwnPropertyDescriptor,Mh=Object.getOwnPropertyNames,Bh=Object.getPrototypeOf,Uh=Object.prototype.hasOwnProperty,zh=(e,t)=>Wi(e,"name",{value:t,configurable:!0}),Wh=(e,t)=>{for(var i in t)Wi(e,i,{get:t[i],enumerable:!0})},yl=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Mh(t))!Uh.call(e,r)&&r!==i&&Wi(e,r,{get:()=>t[r],enumerable:!(n=Lh(t,r))||n.enumerable});return e},Vh=(e,t,i)=>(i=e!=null?Dh(Bh(e)):{},yl(t||!e||!e.__esModule?Wi(i,"default",{value:e,enumerable:!0}):i,e)),Hh=e=>yl(Wi({},"__esModule",{value:!0}),e),_l={};Wh(_l,{Logger:()=>wl.default,LoggerService:()=>kl,default:()=>Kh});Sl.exports=Hh(_l);var bl=ai(),Gh=R(),wl=Vh(gl(),1),kl=class El extends bl.Service{static{zh(this,"LoggerService")}constructor(t){super(t,"logger",!0),t.on("internal/info",function(i,...n){this.logger("app").info(i,...n)}),t.on("internal/error",function(i,...n){this.logger("app").error(i,...n)}),t.on("internal/warning",function(i,...n){this.logger("app").warn(i,...n)})}[bl.Service.invoke](t){return new wl.default(t,(0,Gh.defineProperty)({},"ctx",this.ctx))}static{for(let t of["success","error","info","warn","debug","extend"])El.prototype[t]=function(...i){return this(this.ctx.name)[t](...i)}}},Kh=kl});var Ks=S((Gw,$l)=>{"use strict";var Yh=Object.defineProperty,K=(e,t)=>Yh(e,"name",{value:t,configurable:!0}),Q=R(),tr=Symbol.for("schemastery"),Ol=Symbol.for("ValidationError");globalThis.__schemastery_index__??=0;var Z=class extends TypeError{constructor(e,t){let i="$";for(let n of t.path||[])typeof n=="string"?i+="."+n:typeof n=="number"?i+="["+n+"]":typeof n=="symbol"&&(i+=`[Symbol(${n.toString()})]`);i.startsWith(".")&&(i=i.slice(1)),super((i==="$"?"":`${i} `)+e),this.options=t}static{K(this,"ValidationError")}name="ValidationError";static is(e){return!!e?.[Ol]}};Object.defineProperty(Z.prototype,Ol,{value:!0});var k=K(function(e){let t=K(function(i,n={}){return k.resolve(i,t,n)[0]},"schema");if(e.refs){let i=(0,Q.valueMap)(e.refs,r=>new k(r)),n=K(r=>i[r],"getRef");for(let r in i){let s=i[r];s.sKey=n(s.sKey),s.inner=n(s.inner),s.list=s.list&&s.list.map(n),s.dict=s.dict&&(0,Q.valueMap)(s.dict,n)}return i[e.uid]}if(Object.assign(t,e),typeof t.callback=="string")try{t.callback=new Function("return "+t.callback)()}catch{}return Object.defineProperty(t,"uid",{value:globalThis.__schemastery_index__++}),Object.setPrototypeOf(t,k.prototype),t.meta||={},t.toString=t.toString.bind(t),t},"Schema");k.prototype=Object.create(Function.prototype);k.prototype[tr]=!0;k.ValidationError=Z;var oi;k.prototype.toJSON=K(function(){if(oi)return oi[this.uid]??=JSON.parse(JSON.stringify({...this})),this.uid;oi={[this.uid]:{...this}},oi[this.uid]=JSON.parse(JSON.stringify({...this}));let t={uid:this.uid,refs:oi};return oi=void 0,t},"toJSON");k.prototype.set=K(function(t,i){return this.dict[t]=i,this},"set");k.prototype.push=K(function(t){return this.list.push(t),this},"push");function jl(e,t){let i=typeof e=="string"?{"":e}:{...e};for(let n in t){let r=t[n];r?.$description||r?.$desc?i[n]=r.$description||r.$desc:typeof r=="string"&&(i[n]=r)}return i}K(jl,"mergeDesc");function ci(e){return e?.$value??e?.$inner}K(ci,"getInner");function Gs(e){return(0,Q.filterKeys)(e??{},t=>!t.startsWith("$"))}K(Gs,"extractKeys");k.prototype.i18n=K(function(t){let i=k(this),n=jl(i.meta.description,t);return Object.keys(n).length&&(i.meta.description=n),i.dict&&(i.dict=(0,Q.valueMap)(i.dict,(r,s)=>r.i18n((0,Q.valueMap)(t,a=>ci(a)?.[s]??a?.[s])))),i.list&&(i.list=i.list.map((r,s)=>r.i18n((0,Q.valueMap)(t,(a={})=>Array.isArray(ci(a))?ci(a)[s]:Array.isArray(a)?a[s]:Gs(a))))),i.inner&&(i.inner=i.inner.i18n((0,Q.valueMap)(t,r=>ci(r)?ci(r):Gs(r)))),i.sKey&&(i.sKey=i.sKey.i18n((0,Q.valueMap)(t,r=>r?.$key))),i},"i18n");k.prototype.extra=K(function(t,i){let n=k(this);return n.meta={...n.meta,[t]:i},n},"extra");for(let e of["required","disabled","collapse","hidden","loose"])Object.assign(k.prototype,{[e](t=!0){let i=k(this);return i.meta={...i.meta,[e]:t},i}});k.prototype.deprecated=K(function(){let t=k(this);return t.meta.badges||=[],t.meta.badges.push({text:"deprecated",type:"danger"}),t},"deprecated");k.prototype.experimental=K(function(){let t=k(this);return t.meta.badges||=[],t.meta.badges.push({text:"experimental",type:"warning"}),t},"experimental");k.prototype.pattern=K(function(t){let i=k(this),n=(0,Q.pick)(t,["source","flags"]);return i.meta={...i.meta,pattern:n},i},"pattern");k.prototype.simplify=K(function(t){if((0,Q.deepEqual)(t,this.meta.default,this.type==="dict"))return null;if((0,Q.isNullable)(t))return t;if(this.type==="object"||this.type==="dict"){let i={};for(let n in t){let s=(this.type==="object"?this.dict[n]:this.inner)?.simplify(t[n]);(this.type==="dict"||!(0,Q.isNullable)(s))&&(i[n]=s)}return(0,Q.deepEqual)(i,this.meta.default,this.type==="dict")?null:i}else if(this.type==="array"||this.type==="tuple"){let i=[];return t.forEach((n,r)=>{let s=this.type==="array"?this.inner:this.list[r],a=s?s.simplify(n):n;i.push(a)}),i}else if(this.type==="intersect"){let i={};for(let n of this.list)Object.assign(i,n.simplify(t));return i}else if(this.type==="union")for(let i of this.list)try{return k.resolve(t,i,{}),i.simplify(t)}catch{}return t},"simplify");k.prototype.toString=K(function(t){return Cl[this.type]?.(this,t)??`Schema<${this.type}>`},"toString");k.prototype.role=K(function(e,t){let i=k(this);return i.meta={...i.meta,role:e,extra:t},i},"role");for(let e of["default","link","comment","description","max","min","step"])Object.assign(k.prototype,{[e](t){let i=k(this);return i.meta={...i.meta,[e]:t},i}});var Tl={};k.extend=K(function(t,i){Tl[t]=i},"extend");k.resolve=K(function(t,i,n={},r=!1){if(!i)return[t];if(n.ignore?.(t,i))return[t];if((0,Q.isNullable)(t)&&i.type!=="lazy"){if(i.meta.required)throw new Z("missing required value",n);let a=i,o=i.meta.default;for(;a?.type==="intersect"&&(0,Q.isNullable)(o);)a=a.list[0],o=a?.meta.default;if((0,Q.isNullable)(o))return[t];t=(0,Q.clone)(o)}let s=Tl[i.type];if(!s)throw new Z(`unsupported type "${i.type}"`,n);try{return s(t,i,n,r)}catch(a){if(!i.meta.loose)throw a;return[i.meta.default]}},"resolve");k.from=K(function(t){if((0,Q.isNullable)(t))return k.any();if(["string","number","boolean"].includes(typeof t))return k.const(t).required();if(t[tr])return t;if(typeof t=="function")switch(t){case String:return k.string().required();case Number:return k.number().required();case Boolean:return k.boolean().required();case Function:return k.function().required();default:return k.is(t).required()}else throw new TypeError(`cannot infer schema from ${t}`)},"from");k.lazy=K(function(t){let i=K(()=>(n.inner[tr]||(n.inner=n.builder(),n.inner.meta={...n.meta,..