@drincs/pixi-vn 1.8.12 → 1.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- 'use strict';var core=require('./core.cjs');var se=Object.defineProperty;var kt=c=>{throw TypeError(c)};var ae=(c,t,i)=>t in c?se(c,t,{enumerable:true,configurable:true,writable:true,value:i}):c[t]=i;var N=(c,t,i)=>ae(c,typeof t!="symbol"?t+"":t,i),Yt=(c,t,i)=>t.has(c)||kt("Cannot "+i);var e=(c,t,i)=>(Yt(c,t,"read from private field"),i?i.call(c):t.get(c)),_=(c,t,i)=>t.has(c)?kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,i),f=(c,t,i,r)=>(Yt(c,t,"write to private field"),t.set(c,i),i),l=(c,t,i)=>(Yt(c,t,"access private method"),i);var Mt=(c,t,i,r)=>({set _(a){f(c,t,a);},get _(){return e(c,t,r)}});var st="storage",ut="temp",Ft="flags",U={CHARACTER_CATEGORY_KEY:"character"};var oe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Kt=typeof process=="object"&&process?process:{},Qt=(c,t,i,r)=>{typeof Kt.emitWarning=="function"?Kt.emitWarning(c,t,i,r):console.error(`[${i}] ${t}: ${c}`);},Pt=globalThis.AbortController,Bt=globalThis.AbortSignal;if(typeof Pt>"u"){Bt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,r){this._onabort.push(r);}},Pt=class{constructor(){t();}signal=new Bt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i);}}};let c=Kt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{c&&(c=false,Qt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var ne=c=>!qt.has(c);var at=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),Zt=c=>at(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Gt:null:null,Gt=class extends Array{constructor(c){super(c),this.fill(0);}},et,St,he=(et=class{heap;length;static create(t){let i=Zt(t);if(!i)return [];f(et,St,true);let r=new et(t,i);return f(et,St,false),r}constructor(t,i){if(!e(et,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},St=new WeakMap,_(et,St,false),et),Xt,Jt,j,z,k,ft,B,Et,Tt,X,R,J,x,O,d,V,Y,M,I,q,D,Q,Z,K,W,tt,lt,L,yt,n,Wt,dt,rt,Ct,H,ee,gt,bt,It,ot,nt,Ht,Vt,Lt,v,$t,Rt,ht,jt,At,te=(At=class{constructor(t){_(this,n);_(this,j);_(this,z);_(this,k);_(this,ft);_(this,B);_(this,Et);_(this,Tt);_(this,X);N(this,"ttl");N(this,"ttlResolution");N(this,"ttlAutopurge");N(this,"updateAgeOnGet");N(this,"updateAgeOnHas");N(this,"allowStale");N(this,"noDisposeOnSet");N(this,"noUpdateTTL");N(this,"maxEntrySize");N(this,"sizeCalculation");N(this,"noDeleteOnFetchRejection");N(this,"noDeleteOnStaleGet");N(this,"allowStaleOnFetchAbort");N(this,"allowStaleOnFetchRejection");N(this,"ignoreFetchAbort");_(this,R);_(this,J);_(this,x);_(this,O);_(this,d);_(this,V);_(this,Y);_(this,M);_(this,I);_(this,q);_(this,D);_(this,Q);_(this,Z);_(this,K);_(this,W);_(this,tt);_(this,lt);_(this,L);_(this,yt);_(this,dt,()=>{});_(this,rt,()=>{});_(this,Ct,()=>{});_(this,H,()=>false);_(this,gt,t=>{});_(this,bt,(t,i,r)=>{});_(this,It,(t,i,r,a)=>{if(r||a)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});N(this,Xt,"LRUCache");let{max:i=0,ttl:r,ttlResolution:a=1,ttlAutopurge:o,updateAgeOnGet:s,updateAgeOnHas:h,allowStale:u,dispose:S,onInsert:C,disposeAfter:g,noDisposeOnSet:y,noUpdateTTL:T,maxSize:E=0,maxEntrySize:b=0,sizeCalculation:A,fetchMethod:p,memoMethod:F,noDeleteOnFetchRejection:P,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:xt,ignoreFetchAbort:pt,perf:_t}=t;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,_t??oe),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let mt=i?Zt(i):Array;if(!mt)throw new Error("invalid max value: "+i);if(f(this,j,i),f(this,z,E),this.maxEntrySize=b||e(this,z),this.sizeCalculation=A,this.sizeCalculation){if(!e(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(F!==void 0&&typeof F!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,Tt,F),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Et,p),f(this,lt,!!p),f(this,x,new Map),f(this,O,new Array(i).fill(void 0)),f(this,d,new Array(i).fill(void 0)),f(this,V,new mt(i)),f(this,Y,new mt(i)),f(this,M,0),f(this,I,0),f(this,q,he.create(i)),f(this,R,0),f(this,J,0),typeof S=="function"&&f(this,k,S),typeof C=="function"&&f(this,ft,C),typeof g=="function"?(f(this,B,g),f(this,D,[])):(f(this,B,void 0),f(this,D,void 0)),f(this,tt,!!e(this,k)),f(this,yt,!!e(this,ft)),f(this,L,!!e(this,B)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!P,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(e(this,z)!==0&&!at(e(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");l(this,n,ee).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!h,this.ttlResolution=at(a)||a===0?a:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");l(this,n,Wt).call(this);}if(e(this,j)===0&&this.ttl===0&&e(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,j)&&!e(this,z)){let zt="LRU_CACHE_UNBOUNDED";ne(zt)&&(qt.add(zt),Qt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",zt,At));}}get perf(){return e(this,X)}static unsafeExposeInternals(t){return {starts:e(t,Z),ttls:e(t,K),autopurgeTimers:e(t,W),sizes:e(t,Q),keyMap:e(t,x),keyList:e(t,O),valList:e(t,d),next:e(t,V),prev:e(t,Y),get head(){return e(t,M)},get tail(){return e(t,I)},free:e(t,q),isBackgroundFetch:i=>{var r;return l(r=t,n,v).call(r,i)},backgroundFetch:(i,r,a,o)=>{var s;return l(s=t,n,Lt).call(s,i,r,a,o)},moveToTail:i=>{var r;return l(r=t,n,Rt).call(r,i)},indexes:i=>{var r;return l(r=t,n,ot).call(r,i)},rindexes:i=>{var r;return l(r=t,n,nt).call(r,i)},isStale:i=>{var r;return e(r=t,H).call(r,i)}}}get max(){return e(this,j)}get maxSize(){return e(this,z)}get calculatedSize(){return e(this,J)}get size(){return e(this,R)}get fetchMethod(){return e(this,Et)}get memoMethod(){return e(this,Tt)}get dispose(){return e(this,k)}get onInsert(){return e(this,ft)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,x).has(t)?1/0:0}*entries(){for(let t of l(this,n,ot).call(this))e(this,d)[t]!==void 0&&e(this,O)[t]!==void 0&&!l(this,n,v).call(this,e(this,d)[t])&&(yield [e(this,O)[t],e(this,d)[t]]);}*rentries(){for(let t of l(this,n,nt).call(this))e(this,d)[t]!==void 0&&e(this,O)[t]!==void 0&&!l(this,n,v).call(this,e(this,d)[t])&&(yield [e(this,O)[t],e(this,d)[t]]);}*keys(){for(let t of l(this,n,ot).call(this)){let i=e(this,O)[t];i!==void 0&&!l(this,n,v).call(this,e(this,d)[t])&&(yield i);}}*rkeys(){for(let t of l(this,n,nt).call(this)){let i=e(this,O)[t];i!==void 0&&!l(this,n,v).call(this,e(this,d)[t])&&(yield i);}}*values(){for(let t of l(this,n,ot).call(this))e(this,d)[t]!==void 0&&!l(this,n,v).call(this,e(this,d)[t])&&(yield e(this,d)[t]);}*rvalues(){for(let t of l(this,n,nt).call(this))e(this,d)[t]!==void 0&&!l(this,n,v).call(this,e(this,d)[t])&&(yield e(this,d)[t]);}[(Jt=Symbol.iterator,Xt=Symbol.toStringTag,Jt)](){return this.entries()}find(t,i={}){for(let r of l(this,n,ot).call(this)){let a=e(this,d)[r],o=l(this,n,v).call(this,a)?a.__staleWhileFetching:a;if(o!==void 0&&t(o,e(this,O)[r],this))return this.get(e(this,O)[r],i)}}forEach(t,i=this){for(let r of l(this,n,ot).call(this)){let a=e(this,d)[r],o=l(this,n,v).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&t.call(i,o,e(this,O)[r],this);}}rforEach(t,i=this){for(let r of l(this,n,nt).call(this)){let a=e(this,d)[r],o=l(this,n,v).call(this,a)?a.__staleWhileFetching:a;o!==void 0&&t.call(i,o,e(this,O)[r],this);}}purgeStale(){let t=false;for(let i of l(this,n,nt).call(this,{allowStale:true}))e(this,H).call(this,i)&&(l(this,n,ht).call(this,e(this,O)[i],"expire"),t=true);return t}info(t){let i=e(this,x).get(t);if(i===void 0)return;let r=e(this,d)[i],a=l(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(a===void 0)return;let o={value:a};if(e(this,K)&&e(this,Z)){let s=e(this,K)[i],h=e(this,Z)[i];if(s&&h){let u=s-(e(this,X).now()-h);o.ttl=u,o.start=Date.now();}}return e(this,Q)&&(o.size=e(this,Q)[i]),o}dump(){let t=[];for(let i of l(this,n,ot).call(this,{allowStale:true})){let r=e(this,O)[i],a=e(this,d)[i],o=l(this,n,v).call(this,a)?a.__staleWhileFetching:a;if(o===void 0||r===void 0)continue;let s={value:o};if(e(this,K)&&e(this,Z)){s.ttl=e(this,K)[i];let h=e(this,X).now()-e(this,Z)[i];s.start=Math.floor(Date.now()-h);}e(this,Q)&&(s.size=e(this,Q)[i]),t.unshift([r,s]);}return t}load(t){this.clear();for(let[i,r]of t){if(r.start){let a=Date.now()-r.start;r.start=e(this,X).now()-a;}this.set(i,r.value,r);}}set(t,i,r={}){var y,T,E,b;if(i===void 0)return this.delete(t),this;let{ttl:a=this.ttl,start:o,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:u}=r,{noUpdateTTL:S=this.noUpdateTTL}=r,C=e(this,It).call(this,t,i,r.size||0,h);if(this.maxEntrySize&&C>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),l(this,n,ht).call(this,t,"set"),this;let g=e(this,R)===0?void 0:e(this,x).get(t);if(g===void 0)g=e(this,R)===0?e(this,I):e(this,q).length!==0?e(this,q).pop():e(this,R)===e(this,j)?l(this,n,Vt).call(this,false):e(this,R),e(this,O)[g]=t,e(this,d)[g]=i,e(this,x).set(t,g),e(this,V)[e(this,I)]=g,e(this,Y)[g]=e(this,I),f(this,I,g),Mt(this,R)._++,e(this,bt).call(this,g,C,u),u&&(u.set="add"),S=false,e(this,yt)&&((y=e(this,ft))==null||y.call(this,i,t,"add"));else {l(this,n,Rt).call(this,g);let A=e(this,d)[g];if(i!==A){if(e(this,lt)&&l(this,n,v).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=A;p!==void 0&&!s&&(e(this,tt)&&((T=e(this,k))==null||T.call(this,p,t,"set")),e(this,L)&&e(this,D)?.push([p,t,"set"]));}else s||(e(this,tt)&&((E=e(this,k))==null||E.call(this,A,t,"set")),e(this,L)&&e(this,D)?.push([A,t,"set"]));if(e(this,gt).call(this,g),e(this,bt).call(this,g,C,u),e(this,d)[g]=i,u){u.set="replace";let p=A&&l(this,n,v).call(this,A)?A.__staleWhileFetching:A;p!==void 0&&(u.oldValue=p);}}else u&&(u.set="update");e(this,yt)&&this.onInsert?.(i,t,i===A?"update":"replace");}if(a!==0&&!e(this,K)&&l(this,n,Wt).call(this),e(this,K)&&(S||e(this,Ct).call(this,g,a,o),u&&e(this,rt).call(this,u,g)),!s&&e(this,L)&&e(this,D)){let A=e(this,D),p;for(;p=A?.shift();)(b=e(this,B))==null||b.call(this,...p);}return this}pop(){var t;try{for(;e(this,R);){let i=e(this,d)[e(this,M)];if(l(this,n,Vt).call(this,!0),l(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,L)&&e(this,D)){let i=e(this,D),r;for(;r=i?.shift();)(t=e(this,B))==null||t.call(this,...r);}}}has(t,i={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:a}=i,o=e(this,x).get(t);if(o!==void 0){let s=e(this,d)[o];if(l(this,n,v).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(e(this,H).call(this,o))a&&(a.has="stale",e(this,rt).call(this,a,o));else return r&&e(this,dt).call(this,o),a&&(a.has="hit",e(this,rt).call(this,a,o)),true}else a&&(a.has="miss");return false}peek(t,i={}){let{allowStale:r=this.allowStale}=i,a=e(this,x).get(t);if(a===void 0||!r&&e(this,H).call(this,a))return;let o=e(this,d)[a];return l(this,n,v).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:u=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:C=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:b,forceRefresh:A=false,status:p,signal:F}=i;if(!e(this,lt))return p&&(p.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:o,status:p});let P={allowStale:r,updateAgeOnGet:a,noDeleteOnStaleGet:o,ttl:s,noDisposeOnSet:h,size:u,sizeCalculation:S,noUpdateTTL:C,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:p,signal:F},G=e(this,x).get(t);if(G===void 0){p&&(p.fetch="miss");let w=l(this,n,Lt).call(this,t,G,P,b);return w.__returned=w}else {let w=e(this,d)[G];if(l(this,n,v).call(this,w)){let mt=r&&w.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",mt&&(p.returnedStale=true)),mt?w.__staleWhileFetching:w.__returned=w}let xt=e(this,H).call(this,G);if(!A&&!xt)return p&&(p.fetch="hit"),l(this,n,Rt).call(this,G),a&&e(this,dt).call(this,G),p&&e(this,rt).call(this,p,G),w;let pt=l(this,n,Lt).call(this,t,G,P,b),_t=pt.__staleWhileFetching!==void 0&&r;return p&&(p.fetch=xt?"stale":"refresh",_t&&xt&&(p.returnedStale=true)),_t?pt.__staleWhileFetching:pt.__returned=pt}}async forceFetch(t,i={}){let r=await this.fetch(t,i);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,i={}){let r=e(this,Tt);if(!r)throw new Error("no memoMethod provided to constructor");let{context:a,forceRefresh:o,...s}=i,h=this.get(t,s);if(!o&&h!==void 0)return h;let u=r(t,h,{options:s,context:a});return this.set(t,u,s),u}get(t,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:a=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:s}=i,h=e(this,x).get(t);if(h!==void 0){let u=e(this,d)[h],S=l(this,n,v).call(this,u);return s&&e(this,rt).call(this,s,h),e(this,H).call(this,h)?(s&&(s.get="stale"),S?(s&&r&&u.__staleWhileFetching!==void 0&&(s.returnedStale=true),r?u.__staleWhileFetching:void 0):(o||l(this,n,ht).call(this,t,"expire"),s&&r&&(s.returnedStale=true),r?u:void 0)):(s&&(s.get="hit"),S?u.__staleWhileFetching:(l(this,n,Rt).call(this,h),a&&e(this,dt).call(this,h),u))}else s&&(s.get="miss");}delete(t){return l(this,n,ht).call(this,t,"delete")}clear(){return l(this,n,jt).call(this,"delete")}},j=new WeakMap,z=new WeakMap,k=new WeakMap,ft=new WeakMap,B=new WeakMap,Et=new WeakMap,Tt=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,O=new WeakMap,d=new WeakMap,V=new WeakMap,Y=new WeakMap,M=new WeakMap,I=new WeakMap,q=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,K=new WeakMap,W=new WeakMap,tt=new WeakMap,lt=new WeakMap,L=new WeakMap,yt=new WeakMap,n=new WeakSet,Wt=function(){let t=new Gt(e(this,j)),i=new Gt(e(this,j));f(this,K,t),f(this,Z,i);let r=this.ttlAutopurge?new Array(e(this,j)):void 0;f(this,W,r),f(this,Ct,(h,u,S=e(this,X).now())=>{i[h]=u!==0?S:0,t[h]=u,a(h,u);}),f(this,dt,h=>{i[h]=t[h]!==0?e(this,X).now():0,a(h,t[h]);});let a=this.ttlAutopurge?(h,u)=>{if(r?.[h]&&(clearTimeout(r[h]),r[h]=void 0),u&&u!==0&&r){let S=setTimeout(()=>{e(this,H).call(this,h)&&l(this,n,ht).call(this,e(this,O)[h],"expire");},u+1);S.unref&&S.unref(),r[h]=S;}}:()=>{};f(this,rt,(h,u)=>{if(t[u]){let S=t[u],C=i[u];if(!S||!C)return;h.ttl=S,h.start=C,h.now=o||s();let g=h.now-C;h.remainingTTL=S-g;}});let o=0,s=()=>{let h=e(this,X).now();if(this.ttlResolution>0){o=h;let u=setTimeout(()=>o=0,this.ttlResolution);u.unref&&u.unref();}return h};this.getRemainingTTL=h=>{let u=e(this,x).get(h);if(u===void 0)return 0;let S=t[u],C=i[u];if(!S||!C)return 1/0;let g=(o||s())-C;return S-g},f(this,H,h=>{let u=i[h],S=t[h];return !!S&&!!u&&(o||s())-u>S});},dt=new WeakMap,rt=new WeakMap,Ct=new WeakMap,H=new WeakMap,ee=function(){let t=new Gt(e(this,j));f(this,J,0),f(this,Q,t),f(this,gt,i=>{f(this,J,e(this,J)-t[i]),t[i]=0;}),f(this,It,(i,r,a,o)=>{if(l(this,n,v).call(this,r))return 0;if(!at(a))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(a=o(r,i),!at(a))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return a}),f(this,bt,(i,r,a)=>{if(t[i]=r,e(this,z)){let o=e(this,z)-t[i];for(;e(this,J)>o;)l(this,n,Vt).call(this,true);}f(this,J,e(this,J)+t[i]),a&&(a.entrySize=r,a.totalCalculatedSize=e(this,J));});},gt=new WeakMap,bt=new WeakMap,It=new WeakMap,ot=function*({allowStale:t=this.allowStale}={}){if(e(this,R))for(let i=e(this,I);!(!l(this,n,Ht).call(this,i)||((t||!e(this,H).call(this,i))&&(yield i),i===e(this,M)));)i=e(this,Y)[i];},nt=function*({allowStale:t=this.allowStale}={}){if(e(this,R))for(let i=e(this,M);!(!l(this,n,Ht).call(this,i)||((t||!e(this,H).call(this,i))&&(yield i),i===e(this,I)));)i=e(this,V)[i];},Ht=function(t){return t!==void 0&&e(this,x).get(e(this,O)[t])===t},Vt=function(t){var o;let i=e(this,M),r=e(this,O)[i],a=e(this,d)[i];return e(this,lt)&&l(this,n,v).call(this,a)?a.__abortController.abort(new Error("evicted")):(e(this,tt)||e(this,L))&&(e(this,tt)&&((o=e(this,k))==null||o.call(this,a,r,"evict")),e(this,L)&&e(this,D)?.push([a,r,"evict"])),e(this,gt).call(this,i),e(this,W)?.[i]&&(clearTimeout(e(this,W)[i]),e(this,W)[i]=void 0),t&&(e(this,O)[i]=void 0,e(this,d)[i]=void 0,e(this,q).push(i)),e(this,R)===1?(f(this,M,f(this,I,0)),e(this,q).length=0):f(this,M,e(this,V)[i]),e(this,x).delete(r),Mt(this,R)._--,i},Lt=function(t,i,r,a){let o=i===void 0?void 0:e(this,d)[i];if(l(this,n,v).call(this,o))return o;let s=new Pt,{signal:h}=r;h?.addEventListener("abort",()=>s.abort(h.reason),{signal:s.signal});let u={signal:s.signal,options:r,context:a},S=(b,A=false)=>{let{aborted:p}=s.signal,F=r.ignoreFetchAbort&&b!==void 0,P=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&b!==void 0);if(r.status&&(p&&!A?(r.status.fetchAborted=true,r.status.fetchError=s.signal.reason,F&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),p&&!F&&!A)return g(s.signal.reason,P);let G=T,w=e(this,d)[i];return (w===T||F&&A&&w===void 0)&&(b===void 0?G.__staleWhileFetching!==void 0?e(this,d)[i]=G.__staleWhileFetching:l(this,n,ht).call(this,t,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(t,b,u.options))),b},C=b=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=b),g(b,false)),g=(b,A)=>{let{aborted:p}=s.signal,F=p&&r.allowStaleOnFetchAbort,P=F||r.allowStaleOnFetchRejection,G=P||r.noDeleteOnFetchRejection,w=T;if(e(this,d)[i]===T&&(!G||!A&&w.__staleWhileFetching===void 0?l(this,n,ht).call(this,t,"fetch"):F||(e(this,d)[i]=w.__staleWhileFetching)),P)return r.status&&w.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw b},y=(b,A)=>{var F;let p=(F=e(this,Et))==null?void 0:F.call(this,t,o,u);p&&p instanceof Promise&&p.then(P=>b(P===void 0?void 0:P),A),s.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(b(void 0),r.allowStaleOnFetchAbort&&(b=P=>S(P,true)));});};r.status&&(r.status.fetchDispatched=true);let T=new Promise(y).then(S,C),E=Object.assign(T,{__abortController:s,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,E,{...u.options,status:void 0}),i=e(this,x).get(t)):e(this,d)[i]=E,E},v=function(t){if(!e(this,lt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Pt},$t=function(t,i){e(this,Y)[i]=t,e(this,V)[t]=i;},Rt=function(t){t!==e(this,I)&&(t===e(this,M)?f(this,M,e(this,V)[t]):l(this,n,$t).call(this,e(this,Y)[t],e(this,V)[t]),l(this,n,$t).call(this,e(this,I),t),f(this,I,t));},ht=function(t,i){var a,o;let r=false;if(e(this,R)!==0){let s=e(this,x).get(t);if(s!==void 0)if(e(this,W)?.[s]&&(clearTimeout(e(this,W)?.[s]),e(this,W)[s]=void 0),r=true,e(this,R)===1)l(this,n,jt).call(this,i);else {e(this,gt).call(this,s);let h=e(this,d)[s];if(l(this,n,v).call(this,h)?h.__abortController.abort(new Error("deleted")):(e(this,tt)||e(this,L))&&(e(this,tt)&&((a=e(this,k))==null||a.call(this,h,t,i)),e(this,L)&&e(this,D)?.push([h,t,i])),e(this,x).delete(t),e(this,O)[s]=void 0,e(this,d)[s]=void 0,s===e(this,I))f(this,I,e(this,Y)[s]);else if(s===e(this,M))f(this,M,e(this,V)[s]);else {let u=e(this,Y)[s];e(this,V)[u]=e(this,V)[s];let S=e(this,V)[s];e(this,Y)[S]=e(this,Y)[s];}Mt(this,R)._--,e(this,q).push(s);}}if(e(this,L)&&e(this,D)?.length){let s=e(this,D),h;for(;h=s?.shift();)(o=e(this,B))==null||o.call(this,...h);}return r},jt=function(t){var i,r;for(let a of l(this,n,nt).call(this,{allowStale:true})){let o=e(this,d)[a];if(l(this,n,v).call(this,o))o.__abortController.abort(new Error("deleted"));else {let s=e(this,O)[a];e(this,tt)&&((i=e(this,k))==null||i.call(this,o,s,t)),e(this,L)&&e(this,D)?.push([o,s,t]);}}if(e(this,x).clear(),e(this,d).fill(void 0),e(this,O).fill(void 0),e(this,K)&&e(this,Z)){e(this,K).fill(0),e(this,Z).fill(0);for(let a of e(this,W)??[])a!==void 0&&clearTimeout(a);e(this,W)?.fill(void 0);}if(e(this,Q)&&e(this,Q).fill(0),f(this,M,0),f(this,I,0),e(this,q).length=0,f(this,J,0),f(this,R,0),e(this,L)&&e(this,D)){let a=e(this,D),o;for(;o=a?.shift();)(r=e(this,B))==null||r.call(this,...o);}},At);var ct=class{cache;map=new Map;constructor(t){this.cache=new te({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var it;(a=>(a.log=(o,...s)=>console.log(`[Pixi\u2019VN] ${o}`,...s),a.warn=(o,...s)=>console.warn(`[Pixi\u2019VN] ${o}`,...s),a.error=(o,...s)=>console.error(`[Pixi\u2019VN] ${o}`,...s),a.info=(o,...s)=>console.info(`[Pixi\u2019VN] ${o}`,...s)))(it||={});function Dt(c){try{if(typeof c>"u")return c;let t=JSON.stringify(c);return JSON.parse(t)}catch(t){throw it.error("Error creating exportable element",c,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ie;(g=>{g.storage=new ct({cacheSize:50}),g.defaultStorage=new ct({cacheSize:10}),g.tempStorageDeadlines=new Map;let r;function a(y){g.tempStorageDeadlines.forEach((T,E)=>{T>y&&(g.storage.delete(`${ut}:${E}`),r?.onClearOldTempVariable?.(E),g.tempStorageDeadlines.delete(E));});}g.clearOldTempVariables=a;function o(y){r=y;}g.setExternalStoreHandler=o;function s(y,T,E){E==null?g.storage.delete(`${y}:${T}`):g.storage.set(`${y}:${T}`,E),r?.onSetVariable?.(T,E);}g.setVariable=s;function h(y,T){let E=g.storage.get(`${y}:${T}`);return Dt(E)}g.getVariable=h;function u(y,T){g.storage.delete(`${y}:${T}`),r?.onRemoveVariable?.(T);}g.removeVariable=u;function S(y,T){let E=g.storage.get(Ft)||[];if(T)E.includes(y)||E.push(y);else {let b=E.indexOf(y);b>-1&&E.splice(b,1);}g.storage.set(Ft,E);}g.setFlag=S;function C(y){return (g.storage.get(Ft)||[]).includes(y)}g.getFlag=C;})(ie||={});var m=ie;var vt=class{constructor(t,i){this.categoryId=t,this.id=i,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let i=m.getVariable(st,t);i&&(Object.entries(i).forEach(([r,a])=>{typeof a=="object"&&a!==null&&Object.entries(a).forEach(([o,s])=>{m.setVariable(this.categoryId,`${r}:${o}`,s);});}),m.removeVariable(st,t));}id;categoryId;setStorageProperty(t,i){m.setVariable(this.categoryId,`${this.id}:${t}`,i);}getStorageProperty(t,i=this.id){return m.getVariable(this.categoryId,`${i}:${t}`)}};var ue="@",Ot=class extends vt{sourceId;constructor(t,i=""){super(U.CHARACTER_CATEGORY_KEY,t+(i?ue+i:"")),this.sourceId=t,this.migrateOldStorage("___character___");}getStorageProperty(t){let i=super.getStorageProperty(t);return i===void 0&&(i=super.getStorageProperty(t,this.sourceId)),i}};var Ut=class extends Ot{constructor(t,i){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion),this.defaultName=i.name,this.defaultSurname=i.surname,this.defaultAge=i.age,this.icon=i.icon,this.color=i.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}icon;color};var wt=new ct({cacheSize:10}),re;(o=>{function c(s){try{let h=wt.get(s);if(!h){it.warn(`Character "${s}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return h}catch(h){it.error(`Error while getting Character "${s}"`,h);return}}o.get=c;function t(s){if(Array.isArray(s)){s.forEach(h=>{t(h);});return}wt.get(s.id)&&it.info(`Character id "${s.id}" already exists, it will be overwritten`),wt.set(s.id,s);}o.add=t;function i(){return Array.from(wt.values())}o.values=i;function r(s){return wt.has(s)}o.has=r;function a(){return Array.from(wt.keys())}o.keys=a;})(re||={});var fe=re;exports.CharacterBaseModel=Ut;exports.CharacterStoredClass=Ot;exports.RegisteredCharacters=fe;
1
+ 'use strict';var core=require('./core.cjs');var se=Object.defineProperty;var kt=u=>{throw TypeError(u)};var ae=(u,t,i)=>t in u?se(u,t,{enumerable:true,configurable:true,writable:true,value:i}):u[t]=i;var N=(u,t,i)=>ae(u,typeof t!="symbol"?t+"":t,i),Yt=(u,t,i)=>t.has(u)||kt("Cannot "+i);var e=(u,t,i)=>(Yt(u,t,"read from private field"),i?i.call(u):t.get(u)),_=(u,t,i)=>t.has(u)?kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(u):t.set(u,i),f=(u,t,i,r)=>(Yt(u,t,"write to private field"),t.set(u,i),i),c=(u,t,i)=>(Yt(u,t,"access private method"),i);var Mt=(u,t,i,r)=>({set _(s){f(u,t,s);},get _(){return e(u,t,r)}});var st="storage",ut="temp",Ft="flags",U={CHARACTER_CATEGORY_KEY:"character"};var oe=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Kt=typeof process=="object"&&process?process:{},Qt=(u,t,i,r)=>{typeof Kt.emitWarning=="function"?Kt.emitWarning(u,t,i,r):console.error(`[${i}] ${t}: ${u}`);},Pt=globalThis.AbortController,Bt=globalThis.AbortSignal;if(typeof Pt>"u"){Bt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,r){this._onabort.push(r);}},Pt=class{constructor(){t();}signal=new Bt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let r of this.signal._onabort)r(i);this.signal.onabort?.(i);}}};let u=Kt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{u&&(u=false,Qt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",t));};}var ne=u=>!qt.has(u);var at=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),Zt=u=>at(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Gt:null:null,Gt=class extends Array{constructor(u){super(u),this.fill(0);}},et,Et,he=(et=class{heap;length;static create(t){let i=Zt(t);if(!i)return [];f(et,Et,true);let r=new et(t,i);return f(et,Et,false),r}constructor(t,i){if(!e(et,Et))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}},Et=new WeakMap,_(et,Et,false),et),Xt,Jt,j,z,k,ft,B,Tt,yt,X,R,J,x,O,d,V,Y,M,I,q,D,Q,Z,K,W,tt,lt,L,bt,n,Wt,dt,rt,Ct,H,ee,gt,At,It,ot,nt,Ht,Vt,Lt,v,$t,Rt,ht,jt,vt,te=(vt=class{constructor(t){_(this,n);_(this,j);_(this,z);_(this,k);_(this,ft);_(this,B);_(this,Tt);_(this,yt);_(this,X);N(this,"ttl");N(this,"ttlResolution");N(this,"ttlAutopurge");N(this,"updateAgeOnGet");N(this,"updateAgeOnHas");N(this,"allowStale");N(this,"noDisposeOnSet");N(this,"noUpdateTTL");N(this,"maxEntrySize");N(this,"sizeCalculation");N(this,"noDeleteOnFetchRejection");N(this,"noDeleteOnStaleGet");N(this,"allowStaleOnFetchAbort");N(this,"allowStaleOnFetchRejection");N(this,"ignoreFetchAbort");_(this,R);_(this,J);_(this,x);_(this,O);_(this,d);_(this,V);_(this,Y);_(this,M);_(this,I);_(this,q);_(this,D);_(this,Q);_(this,Z);_(this,K);_(this,W);_(this,tt);_(this,lt);_(this,L);_(this,bt);_(this,dt,()=>{});_(this,rt,()=>{});_(this,Ct,()=>{});_(this,H,()=>false);_(this,gt,t=>{});_(this,At,(t,i,r)=>{});_(this,It,(t,i,r,s)=>{if(r||s)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});N(this,Xt,"LRUCache");let{max:i=0,ttl:r,ttlResolution:s=1,ttlAutopurge:o,updateAgeOnGet:a,updateAgeOnHas:h,allowStale:l,dispose:S,onInsert:C,disposeAfter:g,noDisposeOnSet:y,noUpdateTTL:T,maxSize:E=0,maxEntrySize:b=0,sizeCalculation:A,fetchMethod:p,memoMethod:F,noDeleteOnFetchRejection:P,noDeleteOnStaleGet:G,allowStaleOnFetchRejection:w,allowStaleOnFetchAbort:xt,ignoreFetchAbort:_t,perf:mt}=t;if(mt!==void 0&&typeof mt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,mt??oe),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let St=i?Zt(i):Array;if(!St)throw new Error("invalid max value: "+i);if(f(this,j,i),f(this,z,E),this.maxEntrySize=b||e(this,z),this.sizeCalculation=A,this.sizeCalculation){if(!e(this,z)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(F!==void 0&&typeof F!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,yt,F),p!==void 0&&typeof p!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,Tt,p),f(this,lt,!!p),f(this,x,new Map),f(this,O,new Array(i).fill(void 0)),f(this,d,new Array(i).fill(void 0)),f(this,V,new St(i)),f(this,Y,new St(i)),f(this,M,0),f(this,I,0),f(this,q,he.create(i)),f(this,R,0),f(this,J,0),typeof S=="function"&&f(this,k,S),typeof C=="function"&&f(this,ft,C),typeof g=="function"?(f(this,B,g),f(this,D,[])):(f(this,B,void 0),f(this,D,void 0)),f(this,tt,!!e(this,k)),f(this,bt,!!e(this,ft)),f(this,L,!!e(this,B)),this.noDisposeOnSet=!!y,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!P,this.allowStaleOnFetchRejection=!!w,this.allowStaleOnFetchAbort=!!xt,this.ignoreFetchAbort=!!_t,this.maxEntrySize!==0){if(e(this,z)!==0&&!at(e(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,n,ee).call(this);}if(this.allowStale=!!l,this.noDeleteOnStaleGet=!!G,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!h,this.ttlResolution=at(s)||s===0?s:1,this.ttlAutopurge=!!o,this.ttl=r||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,n,Wt).call(this);}if(e(this,j)===0&&this.ttl===0&&e(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,j)&&!e(this,z)){let zt="LRU_CACHE_UNBOUNDED";ne(zt)&&(qt.add(zt),Qt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",zt,vt));}}get perf(){return e(this,X)}static unsafeExposeInternals(t){return {starts:e(t,Z),ttls:e(t,K),autopurgeTimers:e(t,W),sizes:e(t,Q),keyMap:e(t,x),keyList:e(t,O),valList:e(t,d),next:e(t,V),prev:e(t,Y),get head(){return e(t,M)},get tail(){return e(t,I)},free:e(t,q),isBackgroundFetch:i=>{var r;return c(r=t,n,v).call(r,i)},backgroundFetch:(i,r,s,o)=>{var a;return c(a=t,n,Lt).call(a,i,r,s,o)},moveToTail:i=>{var r;return c(r=t,n,Rt).call(r,i)},indexes:i=>{var r;return c(r=t,n,ot).call(r,i)},rindexes:i=>{var r;return c(r=t,n,nt).call(r,i)},isStale:i=>{var r;return e(r=t,H).call(r,i)}}}get max(){return e(this,j)}get maxSize(){return e(this,z)}get calculatedSize(){return e(this,J)}get size(){return e(this,R)}get fetchMethod(){return e(this,Tt)}get memoMethod(){return e(this,yt)}get dispose(){return e(this,k)}get onInsert(){return e(this,ft)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,x).has(t)?1/0:0}*entries(){for(let t of c(this,n,ot).call(this))e(this,d)[t]!==void 0&&e(this,O)[t]!==void 0&&!c(this,n,v).call(this,e(this,d)[t])&&(yield [e(this,O)[t],e(this,d)[t]]);}*rentries(){for(let t of c(this,n,nt).call(this))e(this,d)[t]!==void 0&&e(this,O)[t]!==void 0&&!c(this,n,v).call(this,e(this,d)[t])&&(yield [e(this,O)[t],e(this,d)[t]]);}*keys(){for(let t of c(this,n,ot).call(this)){let i=e(this,O)[t];i!==void 0&&!c(this,n,v).call(this,e(this,d)[t])&&(yield i);}}*rkeys(){for(let t of c(this,n,nt).call(this)){let i=e(this,O)[t];i!==void 0&&!c(this,n,v).call(this,e(this,d)[t])&&(yield i);}}*values(){for(let t of c(this,n,ot).call(this))e(this,d)[t]!==void 0&&!c(this,n,v).call(this,e(this,d)[t])&&(yield e(this,d)[t]);}*rvalues(){for(let t of c(this,n,nt).call(this))e(this,d)[t]!==void 0&&!c(this,n,v).call(this,e(this,d)[t])&&(yield e(this,d)[t]);}[(Jt=Symbol.iterator,Xt=Symbol.toStringTag,Jt)](){return this.entries()}find(t,i={}){for(let r of c(this,n,ot).call(this)){let s=e(this,d)[r],o=c(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(o!==void 0&&t(o,e(this,O)[r],this))return this.get(e(this,O)[r],i)}}forEach(t,i=this){for(let r of c(this,n,ot).call(this)){let s=e(this,d)[r],o=c(this,n,v).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(i,o,e(this,O)[r],this);}}rforEach(t,i=this){for(let r of c(this,n,nt).call(this)){let s=e(this,d)[r],o=c(this,n,v).call(this,s)?s.__staleWhileFetching:s;o!==void 0&&t.call(i,o,e(this,O)[r],this);}}purgeStale(){let t=false;for(let i of c(this,n,nt).call(this,{allowStale:true}))e(this,H).call(this,i)&&(c(this,n,ht).call(this,e(this,O)[i],"expire"),t=true);return t}info(t){let i=e(this,x).get(t);if(i===void 0)return;let r=e(this,d)[i],s=c(this,n,v).call(this,r)?r.__staleWhileFetching:r;if(s===void 0)return;let o={value:s};if(e(this,K)&&e(this,Z)){let a=e(this,K)[i],h=e(this,Z)[i];if(a&&h){let l=a-(e(this,X).now()-h);o.ttl=l,o.start=Date.now();}}return e(this,Q)&&(o.size=e(this,Q)[i]),o}dump(){let t=[];for(let i of c(this,n,ot).call(this,{allowStale:true})){let r=e(this,O)[i],s=e(this,d)[i],o=c(this,n,v).call(this,s)?s.__staleWhileFetching:s;if(o===void 0||r===void 0)continue;let a={value:o};if(e(this,K)&&e(this,Z)){a.ttl=e(this,K)[i];let h=e(this,X).now()-e(this,Z)[i];a.start=Math.floor(Date.now()-h);}e(this,Q)&&(a.size=e(this,Q)[i]),t.unshift([r,a]);}return t}load(t){this.clear();for(let[i,r]of t){if(r.start){let s=Date.now()-r.start;r.start=e(this,X).now()-s;}this.set(i,r.value,r);}}set(t,i,r={}){var y,T,E,b;if(i===void 0)return this.delete(t),this;let{ttl:s=this.ttl,start:o,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:l}=r,{noUpdateTTL:S=this.noUpdateTTL}=r,C=e(this,It).call(this,t,i,r.size||0,h);if(this.maxEntrySize&&C>this.maxEntrySize)return l&&(l.set="miss",l.maxEntrySizeExceeded=true),c(this,n,ht).call(this,t,"set"),this;let g=e(this,R)===0?void 0:e(this,x).get(t);if(g===void 0)g=e(this,R)===0?e(this,I):e(this,q).length!==0?e(this,q).pop():e(this,R)===e(this,j)?c(this,n,Vt).call(this,false):e(this,R),e(this,O)[g]=t,e(this,d)[g]=i,e(this,x).set(t,g),e(this,V)[e(this,I)]=g,e(this,Y)[g]=e(this,I),f(this,I,g),Mt(this,R)._++,e(this,At).call(this,g,C,l),l&&(l.set="add"),S=false,e(this,bt)&&((y=e(this,ft))==null||y.call(this,i,t,"add"));else {c(this,n,Rt).call(this,g);let A=e(this,d)[g];if(i!==A){if(e(this,lt)&&c(this,n,v).call(this,A)){A.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:p}=A;p!==void 0&&!a&&(e(this,tt)&&((T=e(this,k))==null||T.call(this,p,t,"set")),e(this,L)&&e(this,D)?.push([p,t,"set"]));}else a||(e(this,tt)&&((E=e(this,k))==null||E.call(this,A,t,"set")),e(this,L)&&e(this,D)?.push([A,t,"set"]));if(e(this,gt).call(this,g),e(this,At).call(this,g,C,l),e(this,d)[g]=i,l){l.set="replace";let p=A&&c(this,n,v).call(this,A)?A.__staleWhileFetching:A;p!==void 0&&(l.oldValue=p);}}else l&&(l.set="update");e(this,bt)&&this.onInsert?.(i,t,i===A?"update":"replace");}if(s!==0&&!e(this,K)&&c(this,n,Wt).call(this),e(this,K)&&(S||e(this,Ct).call(this,g,s,o),l&&e(this,rt).call(this,l,g)),!a&&e(this,L)&&e(this,D)){let A=e(this,D),p;for(;p=A?.shift();)(b=e(this,B))==null||b.call(this,...p);}return this}pop(){var t;try{for(;e(this,R);){let i=e(this,d)[e(this,M)];if(c(this,n,Vt).call(this,!0),c(this,n,v).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,L)&&e(this,D)){let i=e(this,D),r;for(;r=i?.shift();)(t=e(this,B))==null||t.call(this,...r);}}}has(t,i={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:s}=i,o=e(this,x).get(t);if(o!==void 0){let a=e(this,d)[o];if(c(this,n,v).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(e(this,H).call(this,o))s&&(s.has="stale",e(this,rt).call(this,s,o));else return r&&e(this,dt).call(this,o),s&&(s.has="hit",e(this,rt).call(this,s,o)),true}else s&&(s.has="miss");return false}peek(t,i={}){let{allowStale:r=this.allowStale}=i,s=e(this,x).get(t);if(s===void 0||!r&&e(this,H).call(this,s))return;let o=e(this,d)[s];return c(this,n,v).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:l=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:C=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:y=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:E=this.allowStaleOnFetchAbort,context:b,forceRefresh:A=false,status:p,signal:F}=i;if(!e(this,lt))return p&&(p.fetch="get"),this.get(t,{allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:o,status:p});let P={allowStale:r,updateAgeOnGet:s,noDeleteOnStaleGet:o,ttl:a,noDisposeOnSet:h,size:l,sizeCalculation:S,noUpdateTTL:C,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:y,allowStaleOnFetchAbort:E,ignoreFetchAbort:T,status:p,signal:F},G=e(this,x).get(t);if(G===void 0){p&&(p.fetch="miss");let w=c(this,n,Lt).call(this,t,G,P,b);return w.__returned=w}else {let w=e(this,d)[G];if(c(this,n,v).call(this,w)){let St=r&&w.__staleWhileFetching!==void 0;return p&&(p.fetch="inflight",St&&(p.returnedStale=true)),St?w.__staleWhileFetching:w.__returned=w}let xt=e(this,H).call(this,G);if(!A&&!xt)return p&&(p.fetch="hit"),c(this,n,Rt).call(this,G),s&&e(this,dt).call(this,G),p&&e(this,rt).call(this,p,G),w;let _t=c(this,n,Lt).call(this,t,G,P,b),mt=_t.__staleWhileFetching!==void 0&&r;return p&&(p.fetch=xt?"stale":"refresh",mt&&xt&&(p.returnedStale=true)),mt?_t.__staleWhileFetching:_t.__returned=_t}}async forceFetch(t,i={}){let r=await this.fetch(t,i);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(t,i={}){let r=e(this,yt);if(!r)throw new Error("no memoMethod provided to constructor");let{context:s,forceRefresh:o,...a}=i,h=this.get(t,a);if(!o&&h!==void 0)return h;let l=r(t,h,{options:a,context:s});return this.set(t,l,a),l}get(t,i={}){let{allowStale:r=this.allowStale,updateAgeOnGet:s=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:a}=i,h=e(this,x).get(t);if(h!==void 0){let l=e(this,d)[h],S=c(this,n,v).call(this,l);return a&&e(this,rt).call(this,a,h),e(this,H).call(this,h)?(a&&(a.get="stale"),S?(a&&r&&l.__staleWhileFetching!==void 0&&(a.returnedStale=true),r?l.__staleWhileFetching:void 0):(o||c(this,n,ht).call(this,t,"expire"),a&&r&&(a.returnedStale=true),r?l:void 0)):(a&&(a.get="hit"),S?l.__staleWhileFetching:(c(this,n,Rt).call(this,h),s&&e(this,dt).call(this,h),l))}else a&&(a.get="miss");}delete(t){return c(this,n,ht).call(this,t,"delete")}clear(){return c(this,n,jt).call(this,"delete")}},j=new WeakMap,z=new WeakMap,k=new WeakMap,ft=new WeakMap,B=new WeakMap,Tt=new WeakMap,yt=new WeakMap,X=new WeakMap,R=new WeakMap,J=new WeakMap,x=new WeakMap,O=new WeakMap,d=new WeakMap,V=new WeakMap,Y=new WeakMap,M=new WeakMap,I=new WeakMap,q=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,K=new WeakMap,W=new WeakMap,tt=new WeakMap,lt=new WeakMap,L=new WeakMap,bt=new WeakMap,n=new WeakSet,Wt=function(){let t=new Gt(e(this,j)),i=new Gt(e(this,j));f(this,K,t),f(this,Z,i);let r=this.ttlAutopurge?new Array(e(this,j)):void 0;f(this,W,r),f(this,Ct,(h,l,S=e(this,X).now())=>{i[h]=l!==0?S:0,t[h]=l,s(h,l);}),f(this,dt,h=>{i[h]=t[h]!==0?e(this,X).now():0,s(h,t[h]);});let s=this.ttlAutopurge?(h,l)=>{if(r?.[h]&&(clearTimeout(r[h]),r[h]=void 0),l&&l!==0&&r){let S=setTimeout(()=>{e(this,H).call(this,h)&&c(this,n,ht).call(this,e(this,O)[h],"expire");},l+1);S.unref&&S.unref(),r[h]=S;}}:()=>{};f(this,rt,(h,l)=>{if(t[l]){let S=t[l],C=i[l];if(!S||!C)return;h.ttl=S,h.start=C,h.now=o||a();let g=h.now-C;h.remainingTTL=S-g;}});let o=0,a=()=>{let h=e(this,X).now();if(this.ttlResolution>0){o=h;let l=setTimeout(()=>o=0,this.ttlResolution);l.unref&&l.unref();}return h};this.getRemainingTTL=h=>{let l=e(this,x).get(h);if(l===void 0)return 0;let S=t[l],C=i[l];if(!S||!C)return 1/0;let g=(o||a())-C;return S-g},f(this,H,h=>{let l=i[h],S=t[h];return !!S&&!!l&&(o||a())-l>S});},dt=new WeakMap,rt=new WeakMap,Ct=new WeakMap,H=new WeakMap,ee=function(){let t=new Gt(e(this,j));f(this,J,0),f(this,Q,t),f(this,gt,i=>{f(this,J,e(this,J)-t[i]),t[i]=0;}),f(this,It,(i,r,s,o)=>{if(c(this,n,v).call(this,r))return 0;if(!at(s))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(s=o(r,i),!at(s))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return s}),f(this,At,(i,r,s)=>{if(t[i]=r,e(this,z)){let o=e(this,z)-t[i];for(;e(this,J)>o;)c(this,n,Vt).call(this,true);}f(this,J,e(this,J)+t[i]),s&&(s.entrySize=r,s.totalCalculatedSize=e(this,J));});},gt=new WeakMap,At=new WeakMap,It=new WeakMap,ot=function*({allowStale:t=this.allowStale}={}){if(e(this,R))for(let i=e(this,I);!(!c(this,n,Ht).call(this,i)||((t||!e(this,H).call(this,i))&&(yield i),i===e(this,M)));)i=e(this,Y)[i];},nt=function*({allowStale:t=this.allowStale}={}){if(e(this,R))for(let i=e(this,M);!(!c(this,n,Ht).call(this,i)||((t||!e(this,H).call(this,i))&&(yield i),i===e(this,I)));)i=e(this,V)[i];},Ht=function(t){return t!==void 0&&e(this,x).get(e(this,O)[t])===t},Vt=function(t){var o;let i=e(this,M),r=e(this,O)[i],s=e(this,d)[i];return e(this,lt)&&c(this,n,v).call(this,s)?s.__abortController.abort(new Error("evicted")):(e(this,tt)||e(this,L))&&(e(this,tt)&&((o=e(this,k))==null||o.call(this,s,r,"evict")),e(this,L)&&e(this,D)?.push([s,r,"evict"])),e(this,gt).call(this,i),e(this,W)?.[i]&&(clearTimeout(e(this,W)[i]),e(this,W)[i]=void 0),t&&(e(this,O)[i]=void 0,e(this,d)[i]=void 0,e(this,q).push(i)),e(this,R)===1?(f(this,M,f(this,I,0)),e(this,q).length=0):f(this,M,e(this,V)[i]),e(this,x).delete(r),Mt(this,R)._--,i},Lt=function(t,i,r,s){let o=i===void 0?void 0:e(this,d)[i];if(c(this,n,v).call(this,o))return o;let a=new Pt,{signal:h}=r;h?.addEventListener("abort",()=>a.abort(h.reason),{signal:a.signal});let l={signal:a.signal,options:r,context:s},S=(b,A=false)=>{let{aborted:p}=a.signal,F=r.ignoreFetchAbort&&b!==void 0,P=r.ignoreFetchAbort||!!(r.allowStaleOnFetchAbort&&b!==void 0);if(r.status&&(p&&!A?(r.status.fetchAborted=true,r.status.fetchError=a.signal.reason,F&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),p&&!F&&!A)return g(a.signal.reason,P);let G=T,w=e(this,d)[i];return (w===T||F&&A&&w===void 0)&&(b===void 0?G.__staleWhileFetching!==void 0?e(this,d)[i]=G.__staleWhileFetching:c(this,n,ht).call(this,t,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(t,b,l.options))),b},C=b=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=b),g(b,false)),g=(b,A)=>{let{aborted:p}=a.signal,F=p&&r.allowStaleOnFetchAbort,P=F||r.allowStaleOnFetchRejection,G=P||r.noDeleteOnFetchRejection,w=T;if(e(this,d)[i]===T&&(!G||!A&&w.__staleWhileFetching===void 0?c(this,n,ht).call(this,t,"fetch"):F||(e(this,d)[i]=w.__staleWhileFetching)),P)return r.status&&w.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),w.__staleWhileFetching;if(w.__returned===w)throw b},y=(b,A)=>{var F;let p=(F=e(this,Tt))==null?void 0:F.call(this,t,o,l);p&&p instanceof Promise&&p.then(P=>b(P===void 0?void 0:P),A),a.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(b(void 0),r.allowStaleOnFetchAbort&&(b=P=>S(P,true)));});};r.status&&(r.status.fetchDispatched=true);let T=new Promise(y).then(S,C),E=Object.assign(T,{__abortController:a,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,E,{...l.options,status:void 0}),i=e(this,x).get(t)):e(this,d)[i]=E,E},v=function(t){if(!e(this,lt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Pt},$t=function(t,i){e(this,Y)[i]=t,e(this,V)[t]=i;},Rt=function(t){t!==e(this,I)&&(t===e(this,M)?f(this,M,e(this,V)[t]):c(this,n,$t).call(this,e(this,Y)[t],e(this,V)[t]),c(this,n,$t).call(this,e(this,I),t),f(this,I,t));},ht=function(t,i){var s,o;let r=false;if(e(this,R)!==0){let a=e(this,x).get(t);if(a!==void 0)if(e(this,W)?.[a]&&(clearTimeout(e(this,W)?.[a]),e(this,W)[a]=void 0),r=true,e(this,R)===1)c(this,n,jt).call(this,i);else {e(this,gt).call(this,a);let h=e(this,d)[a];if(c(this,n,v).call(this,h)?h.__abortController.abort(new Error("deleted")):(e(this,tt)||e(this,L))&&(e(this,tt)&&((s=e(this,k))==null||s.call(this,h,t,i)),e(this,L)&&e(this,D)?.push([h,t,i])),e(this,x).delete(t),e(this,O)[a]=void 0,e(this,d)[a]=void 0,a===e(this,I))f(this,I,e(this,Y)[a]);else if(a===e(this,M))f(this,M,e(this,V)[a]);else {let l=e(this,Y)[a];e(this,V)[l]=e(this,V)[a];let S=e(this,V)[a];e(this,Y)[S]=e(this,Y)[a];}Mt(this,R)._--,e(this,q).push(a);}}if(e(this,L)&&e(this,D)?.length){let a=e(this,D),h;for(;h=a?.shift();)(o=e(this,B))==null||o.call(this,...h);}return r},jt=function(t){var i,r;for(let s of c(this,n,nt).call(this,{allowStale:true})){let o=e(this,d)[s];if(c(this,n,v).call(this,o))o.__abortController.abort(new Error("deleted"));else {let a=e(this,O)[s];e(this,tt)&&((i=e(this,k))==null||i.call(this,o,a,t)),e(this,L)&&e(this,D)?.push([o,a,t]);}}if(e(this,x).clear(),e(this,d).fill(void 0),e(this,O).fill(void 0),e(this,K)&&e(this,Z)){e(this,K).fill(0),e(this,Z).fill(0);for(let s of e(this,W)??[])s!==void 0&&clearTimeout(s);e(this,W)?.fill(void 0);}if(e(this,Q)&&e(this,Q).fill(0),f(this,M,0),f(this,I,0),e(this,q).length=0,f(this,J,0),f(this,R,0),e(this,L)&&e(this,D)){let s=e(this,D),o;for(;o=s?.shift();)(r=e(this,B))==null||r.call(this,...o);}},vt);var ct=class{cache;map=new Map;constructor(t){this.cache=new te({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(t){let i=this.map.delete(t);return i&&this.cache.delete(t),i}get forEach(){return this.map.forEach}get(t){let i=this.cache.get(t);return i||this.map.get(t)}has(t){return this.map.has(t)}set(t,i){return this.map.set(t,i),this.cache.set(t,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var it;(s=>(s.log=(o,...a)=>console.log(`[Pixi\u2019VN] ${o}`,...a),s.warn=(o,...a)=>console.warn(`[Pixi\u2019VN] ${o}`,...a),s.error=(o,...a)=>console.error(`[Pixi\u2019VN] ${o}`,...a),s.info=(o,...a)=>console.info(`[Pixi\u2019VN] ${o}`,...a)))(it||={});function Dt(u){try{if(typeof u>"u")return u;let t=JSON.stringify(u);return JSON.parse(t)}catch(t){throw it.error("Error creating exportable element",u,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ie;(g=>{g.storage=new ct({cacheSize:50}),g.defaultStorage=new ct({cacheSize:10}),g.tempStorageDeadlines=new Map;let r;function s(y){g.tempStorageDeadlines.forEach((T,E)=>{T>y&&(g.storage.delete(`${ut}:${E}`),r?.onClearOldTempVariable?.(E),g.tempStorageDeadlines.delete(E));});}g.clearOldTempVariables=s;function o(y){r=y;}g.setExternalStoreHandler=o;function a(y,T,E){E==null?g.storage.delete(`${y}:${T}`):g.storage.set(`${y}:${T}`,E),r?.onSetVariable?.(T,E);}g.setVariable=a;function h(y,T){let E=g.storage.get(`${y}:${T}`);return Dt(E)}g.getVariable=h;function l(y,T){g.storage.delete(`${y}:${T}`),r?.onRemoveVariable?.(T);}g.removeVariable=l;function S(y,T){let E=g.storage.get(Ft)||[];if(T)E.includes(y)||E.push(y);else {let b=E.indexOf(y);b>-1&&E.splice(b,1);}g.storage.set(Ft,E);}g.setFlag=S;function C(y){return (g.storage.get(Ft)||[]).includes(y)}g.getFlag=C;})(ie||={});var m=ie;var Ot=class{constructor(t,i){this.categoryId=t,this.id=i,this.migrateOldStorage();}migrateOldStorage(t=this.categoryId){let i=m.getVariable(st,t);i&&(Object.entries(i).forEach(([r,s])=>{typeof s=="object"&&s!==null&&Object.entries(s).forEach(([o,a])=>{m.setVariable(this.categoryId,`${r}:${o}`,a);});}),m.removeVariable(st,t));}id;categoryId;setStorageProperty(t,i){m.setVariable(this.categoryId,`${this.id}:${t}`,i);}getStorageProperty(t,i=this.id){return m.getVariable(this.categoryId,`${i}:${t}`)}};var ue="@",wt=class extends Ot{sourceId;constructor(t,i=""){super(U.CHARACTER_CATEGORY_KEY,t+(i?ue+i:"")),this.sourceId=t,this.migrateOldStorage("___character___");}getStorageProperty(t){let i=super.getStorageProperty(t);return i===void 0&&(i=super.getStorageProperty(t,this.sourceId)),i}};var Ut=class extends wt{constructor(t,i){super(typeof t=="string"?t:t.id,typeof t=="string"?"":t.emotion),this.defaultName=i.name,this.defaultSurname=i.surname,this.defaultAge=i.age,this.icon=i.icon,this.color=i.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(t){this.setStorageProperty("name",t);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(t){this.setStorageProperty("surname",t);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(t){this.setStorageProperty("age",t);}icon;color};var pt=new ct({cacheSize:10}),re;(a=>{function u(h){try{let l=pt.get(h);if(!l){it.warn(`Character "${h}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return l}catch(l){it.error(`Error while getting Character "${h}"`,l);return}}a.get=u;function t(h){if(Array.isArray(h)){h.forEach(l=>{t(l);});return}pt.get(h.id)&&it.info(`Character id "${h.id}" already exists, it will be overwritten`),pt.set(h.id,h);}a.add=t;function i(){return Array.from(pt.values())}a.values=i;function r(h){return pt.has(h)}a.has=r;function s(){return Array.from(pt.keys())}a.keys=s;function o(){pt.clear();}a.clear=o;})(re||={});var fe=re;exports.CharacterBaseModel=Ut;exports.CharacterStoredClass=wt;exports.RegisteredCharacters=fe;
@@ -187,6 +187,10 @@ declare namespace RegisteredCharacters {
187
187
  * @returns An array of character ids.
188
188
  */
189
189
  function keys(): CharacterIdType[];
190
+ /**
191
+ * Removes all registered characters.
192
+ */
193
+ function clear(): void;
190
194
  }
191
195
 
192
196
  /**
@@ -187,6 +187,10 @@ declare namespace RegisteredCharacters {
187
187
  * @returns An array of character ids.
188
188
  */
189
189
  function keys(): CharacterIdType[];
190
+ /**
191
+ * Removes all registered characters.
192
+ */
193
+ function clear(): void;
190
194
  }
191
195
 
192
196
  /**
@@ -1 +1 @@
1
- import {b}from'./chunk-GIYMPXBT.mjs';import {n as n$1}from'./chunk-IWAXXFXE.mjs';import {d,e}from'./chunk-HQQ5WH6C.mjs';var g="@",n=class extends b{sourceId;constructor(e,r=""){super(n$1.CHARACTER_CATEGORY_KEY,e+(r?g+r:"")),this.sourceId=e,this.migrateOldStorage("___character___");}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var i=class extends n{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion),this.defaultName=r.name,this.defaultSurname=r.surname,this.defaultAge=r.age,this.icon=r.icon,this.color=r.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(e){this.setStorageProperty("name",e);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(e){this.setStorageProperty("surname",e);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(e){this.setStorageProperty("age",e);}icon;color};var o=new d({cacheSize:10}),h;(y=>{function d(t){try{let a=o.get(t);if(!a){e.warn(`Character "${t}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return a}catch(a){e.error(`Error while getting Character "${t}"`,a);return}}y.get=d;function e$1(t){if(Array.isArray(t)){t.forEach(a=>{e$1(a);});return}o.get(t.id)&&e.info(`Character id "${t.id}" already exists, it will be overwritten`),o.set(t.id,t);}y.add=e$1;function r(){return Array.from(o.values())}y.values=r;function m(t){return o.has(t)}y.has=m;function l(){return Array.from(o.keys())}y.keys=l;})(h||={});var p=h;export{i as CharacterBaseModel,n as CharacterStoredClass,p as RegisteredCharacters};
1
+ import {b}from'./chunk-GIYMPXBT.mjs';import {n as n$1}from'./chunk-IWAXXFXE.mjs';import {d,e}from'./chunk-HQQ5WH6C.mjs';var g="@",n=class extends b{sourceId;constructor(e,r=""){super(n$1.CHARACTER_CATEGORY_KEY,e+(r?g+r:"")),this.sourceId=e,this.migrateOldStorage("___character___");}getStorageProperty(e){let r=super.getStorageProperty(e);return r===void 0&&(r=super.getStorageProperty(e,this.sourceId)),r}};var i=class extends n{constructor(e,r){super(typeof e=="string"?e:e.id,typeof e=="string"?"":e.emotion),this.defaultName=r.name,this.defaultSurname=r.surname,this.defaultAge=r.age,this.icon=r.icon,this.color=r.color;}defaultName;get name(){return this.getStorageProperty("name")||this.defaultName||this.id}set name(e){this.setStorageProperty("name",e);}defaultSurname;get surname(){return this.getStorageProperty("surname")||this.defaultSurname}set surname(e){this.setStorageProperty("surname",e);}defaultAge;get age(){return this.getStorageProperty("age")||this.defaultAge}set age(e){this.setStorageProperty("age",e);}icon;color};var a=new d({cacheSize:10}),h;(C=>{function d(t){try{let o=a.get(t);if(!o){e.warn(`Character "${t}" not found, did you forget to register it with the RegisteredCharacters.add?`);return}return o}catch(o){e.error(`Error while getting Character "${t}"`,o);return}}C.get=d;function e$1(t){if(Array.isArray(t)){t.forEach(o=>{e$1(o);});return}a.get(t.id)&&e.info(`Character id "${t.id}" already exists, it will be overwritten`),a.set(t.id,t);}C.add=e$1;function r(){return Array.from(a.values())}C.values=r;function m(t){return a.has(t)}C.has=m;function l(){return Array.from(a.keys())}C.keys=l;function y(){a.clear();}C.clear=y;})(h||={});var p=h;export{i as CharacterBaseModel,n as CharacterStoredClass,p as RegisteredCharacters};
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var nt=require('./canvas.cjs'),Bt=require('./characters.cjs'),core=require('./core.cjs'),et=require('./history.cjs'),L=require('./narration.cjs'),pt=require('./sound.cjs'),G=require('./storage.cjs'),motion=require('./motion.cjs');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var nt__namespace=/*#__PURE__*/_interopNamespace(nt);var Bt__namespace=/*#__PURE__*/_interopNamespace(Bt);var et__namespace=/*#__PURE__*/_interopNamespace(et);var L__namespace=/*#__PURE__*/_interopNamespace(L);var pt__namespace=/*#__PURE__*/_interopNamespace(pt);var G__namespace=/*#__PURE__*/_interopNamespace(G);var Xt=Object.defineProperty;var Jt=h=>{throw TypeError(h)};var ue=(h,e,i)=>e in h?Xt(h,e,{enumerable:true,configurable:true,writable:true,value:i}):h[e]=i;var fe=(h,e)=>{for(var i in e)Xt(h,i,{get:e[i],enumerable:true});};var C=(h,e,i)=>ue(h,typeof e!="symbol"?e+"":e,i),jt=(h,e,i)=>e.has(h)||Jt("Cannot "+i);var t=(h,e,i)=>(jt(h,e,"read from private field"),i?i.call(h):e.get(h)),_=(h,e,i)=>e.has(h)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,i),u=(h,e,i,s)=>(jt(h,e,"write to private field"),e.set(h,i),i),d=(h,e,i)=>(jt(h,e,"access private method"),i);var Rt=(h,e,i,s)=>({set _(r){u(h,e,r);},get _(){return t(h,e,s)}});var me=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ee=new Set,Gt=typeof process=="object"&&process?process:{},ie=(h,e,i,s)=>{typeof Gt.emitWarning=="function"?Gt.emitWarning(h,e,i,s):console.error(`[${i}] ${e}: ${h}`);},Nt=globalThis.AbortController,Qt=globalThis.AbortSignal;if(typeof Nt>"u"){Qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new Qt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let h=Gt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{h&&(h=false,ie("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var ge=h=>!ee.has(h);var at=h=>h&&h===Math.floor(h)&&h>0&&isFinite(h),se=h=>at(h)?h<=Math.pow(2,8)?Uint8Array:h<=Math.pow(2,16)?Uint16Array:h<=Math.pow(2,32)?Uint32Array:h<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(h){super(h),this.fill(0);}},it,St,_e=(it=class{heap;length;static create(e){let i=se(e);if(!i)return [];u(it,St,true);let s=new it(e,i);return u(it,St,false),s}constructor(e,i){if(!t(it,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,_(it,St,false),it),Zt,te,K,M,q,ut,$,yt,xt,B,O,X,T,b,m,P,z,N,R,J,D,Q,Z,V,W,tt,dt,j,Et,l,It,ft,ot,Tt,Y,oe,mt,bt,Ot,lt,ht,Mt,Lt,Ct,E,zt,At,ct,Vt,wt,re=(wt=class{constructor(e){_(this,l);_(this,K);_(this,M);_(this,q);_(this,ut);_(this,$);_(this,yt);_(this,xt);_(this,B);C(this,"ttl");C(this,"ttlResolution");C(this,"ttlAutopurge");C(this,"updateAgeOnGet");C(this,"updateAgeOnHas");C(this,"allowStale");C(this,"noDisposeOnSet");C(this,"noUpdateTTL");C(this,"maxEntrySize");C(this,"sizeCalculation");C(this,"noDeleteOnFetchRejection");C(this,"noDeleteOnStaleGet");C(this,"allowStaleOnFetchAbort");C(this,"allowStaleOnFetchRejection");C(this,"ignoreFetchAbort");_(this,O);_(this,X);_(this,T);_(this,b);_(this,m);_(this,P);_(this,z);_(this,N);_(this,R);_(this,J);_(this,D);_(this,Q);_(this,Z);_(this,V);_(this,W);_(this,tt);_(this,dt);_(this,j);_(this,Et);_(this,ft,()=>{});_(this,ot,()=>{});_(this,Tt,()=>{});_(this,Y,()=>false);_(this,mt,e=>{});_(this,bt,(e,i,s)=>{});_(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});C(this,Zt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:p,dispose:v,onInsert:U,disposeAfter:S,noDisposeOnSet:rt,noUpdateTTL:I,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:y,fetchMethod:a,memoMethod:x,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:f,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:F,ignoreFetchAbort:H,perf:_t}=e;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,B,_t??me),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let vt=i?se(i):Array;if(!vt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,M,k),this.maxEntrySize=w||t(this,M),this.sizeCalculation=y,this.sizeCalculation){if(!t(this,M)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,xt,x),a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,yt,a),u(this,dt,!!a),u(this,T,new Map),u(this,b,new Array(i).fill(void 0)),u(this,m,new Array(i).fill(void 0)),u(this,P,new vt(i)),u(this,z,new vt(i)),u(this,N,0),u(this,R,0),u(this,J,_e.create(i)),u(this,O,0),u(this,X,0),typeof v=="function"&&u(this,q,v),typeof U=="function"&&u(this,ut,U),typeof S=="function"?(u(this,$,S),u(this,D,[])):(u(this,$,void 0),u(this,D,void 0)),u(this,tt,!!t(this,q)),u(this,Et,!!t(this,ut)),u(this,j,!!t(this,$)),this.noDisposeOnSet=!!rt,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!g,this.allowStaleOnFetchAbort=!!F,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(t(this,M)!==0&&!at(t(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,l,oe).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!f,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,l,It).call(this);}if(t(this,K)===0&&this.ttl===0&&t(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,K)&&!t(this,M)){let Pt="LRU_CACHE_UNBOUNDED";ge(Pt)&&(ee.add(Pt),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Pt,wt));}}get perf(){return t(this,B)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,V),autopurgeTimers:t(e,W),sizes:t(e,Q),keyMap:t(e,T),keyList:t(e,b),valList:t(e,m),next:t(e,P),prev:t(e,z),get head(){return t(e,N)},get tail(){return t(e,R)},free:t(e,J),isBackgroundFetch:i=>{var s;return d(s=e,l,E).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return d(o=e,l,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return d(s=e,l,At).call(s,i)},indexes:i=>{var s;return d(s=e,l,lt).call(s,i)},rindexes:i=>{var s;return d(s=e,l,ht).call(s,i)},isStale:i=>{var s;return t(s=e,Y).call(s,i)}}}get max(){return t(this,K)}get maxSize(){return t(this,M)}get calculatedSize(){return t(this,X)}get size(){return t(this,O)}get fetchMethod(){return t(this,yt)}get memoMethod(){return t(this,xt)}get dispose(){return t(this,q)}get onInsert(){return t(this,ut)}get disposeAfter(){return t(this,$)}getRemainingTTL(e){return t(this,T).has(e)?1/0:0}*entries(){for(let e of d(this,l,lt).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*rentries(){for(let e of d(this,l,ht).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*keys(){for(let e of d(this,l,lt).call(this)){let i=t(this,b)[e];i!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield i);}}*rkeys(){for(let e of d(this,l,ht).call(this)){let i=t(this,b)[e];i!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield i);}}*values(){for(let e of d(this,l,lt).call(this))t(this,m)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}*rvalues(){for(let e of d(this,l,ht).call(this))t(this,m)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}[(te=Symbol.iterator,Zt=Symbol.toStringTag,te)](){return this.entries()}find(e,i={}){for(let s of d(this,l,lt).call(this)){let r=t(this,m)[s],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,b)[s],this))return this.get(t(this,b)[s],i)}}forEach(e,i=this){for(let s of d(this,l,lt).call(this)){let r=t(this,m)[s],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,b)[s],this);}}rforEach(e,i=this){for(let s of d(this,l,ht).call(this)){let r=t(this,m)[s],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,b)[s],this);}}purgeStale(){let e=false;for(let i of d(this,l,ht).call(this,{allowStale:true}))t(this,Y).call(this,i)&&(d(this,l,ct).call(this,t(this,b)[i],"expire"),e=true);return e}info(e){let i=t(this,T).get(e);if(i===void 0)return;let s=t(this,m)[i],r=d(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,V)&&t(this,Z)){let o=t(this,V)[i],c=t(this,Z)[i];if(o&&c){let p=o-(t(this,B).now()-c);n.ttl=p,n.start=Date.now();}}return t(this,Q)&&(n.size=t(this,Q)[i]),n}dump(){let e=[];for(let i of d(this,l,lt).call(this,{allowStale:true})){let s=t(this,b)[i],r=t(this,m)[i],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,V)&&t(this,Z)){o.ttl=t(this,V)[i];let c=t(this,B).now()-t(this,Z)[i];o.start=Math.floor(Date.now()-c);}t(this,Q)&&(o.size=t(this,Q)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,B).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var rt,I,k,w;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:p}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,U=t(this,Ot).call(this,e,i,s.size||0,c);if(this.maxEntrySize&&U>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),d(this,l,ct).call(this,e,"set"),this;let S=t(this,O)===0?void 0:t(this,T).get(e);if(S===void 0)S=t(this,O)===0?t(this,R):t(this,J).length!==0?t(this,J).pop():t(this,O)===t(this,K)?d(this,l,Lt).call(this,false):t(this,O),t(this,b)[S]=e,t(this,m)[S]=i,t(this,T).set(e,S),t(this,P)[t(this,R)]=S,t(this,z)[S]=t(this,R),u(this,R,S),Rt(this,O)._++,t(this,bt).call(this,S,U,p),p&&(p.set="add"),v=false,t(this,Et)&&((rt=t(this,ut))==null||rt.call(this,i,e,"add"));else {d(this,l,At).call(this,S);let y=t(this,m)[S];if(i!==y){if(t(this,dt)&&d(this,l,E).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:a}=y;a!==void 0&&!o&&(t(this,tt)&&((I=t(this,q))==null||I.call(this,a,e,"set")),t(this,j)&&t(this,D)?.push([a,e,"set"]));}else o||(t(this,tt)&&((k=t(this,q))==null||k.call(this,y,e,"set")),t(this,j)&&t(this,D)?.push([y,e,"set"]));if(t(this,mt).call(this,S),t(this,bt).call(this,S,U,p),t(this,m)[S]=i,p){p.set="replace";let a=y&&d(this,l,E).call(this,y)?y.__staleWhileFetching:y;a!==void 0&&(p.oldValue=a);}}else p&&(p.set="update");t(this,Et)&&this.onInsert?.(i,e,i===y?"update":"replace");}if(r!==0&&!t(this,V)&&d(this,l,It).call(this),t(this,V)&&(v||t(this,Tt).call(this,S,r,n),p&&t(this,ot).call(this,p,S)),!o&&t(this,j)&&t(this,D)){let y=t(this,D),a;for(;a=y?.shift();)(w=t(this,$))==null||w.call(this,...a);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,m)[t(this,N)];if(d(this,l,Lt).call(this,!0),d(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,j)&&t(this,D)){let i=t(this,D),s;for(;s=i?.shift();)(e=t(this,$))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,T).get(e);if(n!==void 0){let o=t(this,m)[n];if(d(this,l,E).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,Y).call(this,n))r&&(r.has="stale",t(this,ot).call(this,r,n));else return s&&t(this,ft).call(this,n),r&&(r.has="hit",t(this,ot).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,T).get(e);if(r===void 0||!s&&t(this,Y).call(this,r))return;let n=t(this,m)[r];return d(this,l,E).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:p=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:U=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:rt=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:y=false,status:a,signal:x}=i;if(!t(this,dt))return a&&(a.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:a});let A={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:c,size:p,sizeCalculation:v,noUpdateTTL:U,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:rt,allowStaleOnFetchAbort:k,ignoreFetchAbort:I,status:a,signal:x},f=t(this,T).get(e);if(f===void 0){a&&(a.fetch="miss");let g=d(this,l,Ct).call(this,e,f,A,w);return g.__returned=g}else {let g=t(this,m)[f];if(d(this,l,E).call(this,g)){let vt=s&&g.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",vt&&(a.returnedStale=true)),vt?g.__staleWhileFetching:g.__returned=g}let F=t(this,Y).call(this,f);if(!y&&!F)return a&&(a.fetch="hit"),d(this,l,At).call(this,f),r&&t(this,ft).call(this,f),a&&t(this,ot).call(this,a,f),g;let H=d(this,l,Ct).call(this,e,f,A,w),_t=H.__staleWhileFetching!==void 0&&s;return a&&(a.fetch=F?"stale":"refresh",_t&&F&&(a.returnedStale=true)),_t?H.__staleWhileFetching:H.__returned=H}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,xt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,c=this.get(e,o);if(!n&&c!==void 0)return c;let p=s(e,c,{options:o,context:r});return this.set(e,p,o),p}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,c=t(this,T).get(e);if(c!==void 0){let p=t(this,m)[c],v=d(this,l,E).call(this,p);return o&&t(this,ot).call(this,o,c),t(this,Y).call(this,c)?(o&&(o.get="stale"),v?(o&&s&&p.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?p.__staleWhileFetching:void 0):(n||d(this,l,ct).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?p:void 0)):(o&&(o.get="hit"),v?p.__staleWhileFetching:(d(this,l,At).call(this,c),r&&t(this,ft).call(this,c),p))}else o&&(o.get="miss");}delete(e){return d(this,l,ct).call(this,e,"delete")}clear(){return d(this,l,Vt).call(this,"delete")}},K=new WeakMap,M=new WeakMap,q=new WeakMap,ut=new WeakMap,$=new WeakMap,yt=new WeakMap,xt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,T=new WeakMap,b=new WeakMap,m=new WeakMap,P=new WeakMap,z=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,V=new WeakMap,W=new WeakMap,tt=new WeakMap,dt=new WeakMap,j=new WeakMap,Et=new WeakMap,l=new WeakSet,It=function(){let e=new Dt(t(this,K)),i=new Dt(t(this,K));u(this,V,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,K)):void 0;u(this,W,s),u(this,Tt,(c,p,v=t(this,B).now())=>{i[c]=p!==0?v:0,e[c]=p,r(c,p);}),u(this,ft,c=>{i[c]=e[c]!==0?t(this,B).now():0,r(c,e[c]);});let r=this.ttlAutopurge?(c,p)=>{if(s?.[c]&&(clearTimeout(s[c]),s[c]=void 0),p&&p!==0&&s){let v=setTimeout(()=>{t(this,Y).call(this,c)&&d(this,l,ct).call(this,t(this,b)[c],"expire");},p+1);v.unref&&v.unref(),s[c]=v;}}:()=>{};u(this,ot,(c,p)=>{if(e[p]){let v=e[p],U=i[p];if(!v||!U)return;c.ttl=v,c.start=U,c.now=n||o();let S=c.now-U;c.remainingTTL=v-S;}});let n=0,o=()=>{let c=t(this,B).now();if(this.ttlResolution>0){n=c;let p=setTimeout(()=>n=0,this.ttlResolution);p.unref&&p.unref();}return c};this.getRemainingTTL=c=>{let p=t(this,T).get(c);if(p===void 0)return 0;let v=e[p],U=i[p];if(!v||!U)return 1/0;let S=(n||o())-U;return v-S},u(this,Y,c=>{let p=i[c],v=e[c];return !!v&&!!p&&(n||o())-p>v});},ft=new WeakMap,ot=new WeakMap,Tt=new WeakMap,Y=new WeakMap,oe=function(){let e=new Dt(t(this,K));u(this,X,0),u(this,Q,e),u(this,mt,i=>{u(this,X,t(this,X)-e[i]),e[i]=0;}),u(this,Ot,(i,s,r,n)=>{if(d(this,l,E).call(this,s))return 0;if(!at(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!at(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),u(this,bt,(i,s,r)=>{if(e[i]=s,t(this,M)){let n=t(this,M)-e[i];for(;t(this,X)>n;)d(this,l,Lt).call(this,true);}u(this,X,t(this,X)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,X));});},mt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,lt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,R);!(!d(this,l,Mt).call(this,i)||((e||!t(this,Y).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,z)[i];},ht=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,N);!(!d(this,l,Mt).call(this,i)||((e||!t(this,Y).call(this,i))&&(yield i),i===t(this,R)));)i=t(this,P)[i];},Mt=function(e){return e!==void 0&&t(this,T).get(t(this,b)[e])===e},Lt=function(e){var n;let i=t(this,N),s=t(this,b)[i],r=t(this,m)[i];return t(this,dt)&&d(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,j))&&(t(this,tt)&&((n=t(this,q))==null||n.call(this,r,s,"evict")),t(this,j)&&t(this,D)?.push([r,s,"evict"])),t(this,mt).call(this,i),t(this,W)?.[i]&&(clearTimeout(t(this,W)[i]),t(this,W)[i]=void 0),e&&(t(this,b)[i]=void 0,t(this,m)[i]=void 0,t(this,J).push(i)),t(this,O)===1?(u(this,N,u(this,R,0)),t(this,J).length=0):u(this,N,t(this,P)[i]),t(this,T).delete(s),Rt(this,O)._--,i},Ct=function(e,i,s,r){let n=i===void 0?void 0:t(this,m)[i];if(d(this,l,E).call(this,n))return n;let o=new Nt,{signal:c}=s;c?.addEventListener("abort",()=>o.abort(c.reason),{signal:o.signal});let p={signal:o.signal,options:s,context:r},v=(w,y=false)=>{let{aborted:a}=o.signal,x=s.ignoreFetchAbort&&w!==void 0,A=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(a&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,x&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),a&&!x&&!y)return S(o.signal.reason,A);let f=I,g=t(this,m)[i];return (g===I||x&&y&&g===void 0)&&(w===void 0?f.__staleWhileFetching!==void 0?t(this,m)[i]=f.__staleWhileFetching:d(this,l,ct).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,w,p.options))),w},U=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),S(w,false)),S=(w,y)=>{let{aborted:a}=o.signal,x=a&&s.allowStaleOnFetchAbort,A=x||s.allowStaleOnFetchRejection,f=A||s.noDeleteOnFetchRejection,g=I;if(t(this,m)[i]===I&&(!f||!y&&g.__staleWhileFetching===void 0?d(this,l,ct).call(this,e,"fetch"):x||(t(this,m)[i]=g.__staleWhileFetching)),A)return s.status&&g.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),g.__staleWhileFetching;if(g.__returned===g)throw w},rt=(w,y)=>{var x;let a=(x=t(this,yt))==null?void 0:x.call(this,e,n,p);a&&a instanceof Promise&&a.then(A=>w(A===void 0?void 0:A),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=A=>v(A,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(rt).then(v,U),k=Object.assign(I,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,k,{...p.options,status:void 0}),i=t(this,T).get(e)):t(this,m)[i]=k,k},E=function(e){if(!t(this,dt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},zt=function(e,i){t(this,z)[i]=e,t(this,P)[e]=i;},At=function(e){e!==t(this,R)&&(e===t(this,N)?u(this,N,t(this,P)[e]):d(this,l,zt).call(this,t(this,z)[e],t(this,P)[e]),d(this,l,zt).call(this,t(this,R),e),u(this,R,e));},ct=function(e,i){var r,n;let s=false;if(t(this,O)!==0){let o=t(this,T).get(e);if(o!==void 0)if(t(this,W)?.[o]&&(clearTimeout(t(this,W)?.[o]),t(this,W)[o]=void 0),s=true,t(this,O)===1)d(this,l,Vt).call(this,i);else {t(this,mt).call(this,o);let c=t(this,m)[o];if(d(this,l,E).call(this,c)?c.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,j))&&(t(this,tt)&&((r=t(this,q))==null||r.call(this,c,e,i)),t(this,j)&&t(this,D)?.push([c,e,i])),t(this,T).delete(e),t(this,b)[o]=void 0,t(this,m)[o]=void 0,o===t(this,R))u(this,R,t(this,z)[o]);else if(o===t(this,N))u(this,N,t(this,P)[o]);else {let p=t(this,z)[o];t(this,P)[p]=t(this,P)[o];let v=t(this,P)[o];t(this,z)[v]=t(this,z)[o];}Rt(this,O)._--,t(this,J).push(o);}}if(t(this,j)&&t(this,D)?.length){let o=t(this,D),c;for(;c=o?.shift();)(n=t(this,$))==null||n.call(this,...c);}return s},Vt=function(e){var i,s;for(let r of d(this,l,ht).call(this,{allowStale:true})){let n=t(this,m)[r];if(d(this,l,E).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,b)[r];t(this,tt)&&((i=t(this,q))==null||i.call(this,n,o,e)),t(this,j)&&t(this,D)?.push([n,o,e]);}}if(t(this,T).clear(),t(this,m).fill(void 0),t(this,b).fill(void 0),t(this,V)&&t(this,Z)){t(this,V).fill(0),t(this,Z).fill(0);for(let r of t(this,W)??[])r!==void 0&&clearTimeout(r);t(this,W)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,N,0),u(this,R,0),t(this,J).length=0,u(this,X,0),u(this,O,0),t(this,j)&&t(this,D)){let r=t(this,D),n;for(;n=r?.shift();)(s=t(this,$))==null||s.call(this,...n);}},wt);var Ft=class{cache;map=new Map;constructor(e){this.cache=new re({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ut="1.8.12";var Wt={version:Ut};var Yt="repeat";function Ht(h){return {type:"pause",duration:h}}var Kt="__game_layer__";var ve={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ae={};var kt={};fe(kt,{createExportableElement:()=>le});var gt;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(gt||={});function le(h){try{if(typeof h>"u")return h;let e=JSON.stringify(h);return JSON.parse(e)}catch(e){throw gt.error("Error creating exportable element",h,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ye=typeof window<"u"&&typeof document<"u",he=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Wt.version}`],ce=31,xe="background:#2f90da;color:#fff;font-weight:bold;",Ee="background:#c832bb;color:#fff;font-weight:bold;",be="background:transparent;font-weight:bold;",qt=` v${Wt.version}`;function de(){if(!ye)return;let h=[],e=[];for(let i=0;i<he.length;i++){let s=he[i],r=s.endsWith(qt),n=r?s.slice(0,-qt.length):s,o=n.slice(0,ce),c=n.slice(ce),p=r?"%c%s%c%s%c%s":"%c%s%c%s";h.push(p),e.push(xe,o,Ee,c),r&&e.push(be,qt);}console.info(h.join(`
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var nt=require('./canvas.cjs'),Bt=require('./characters.cjs'),core=require('./core.cjs'),et=require('./history.cjs'),L=require('./narration.cjs'),pt=require('./sound.cjs'),G=require('./storage.cjs'),motion=require('./motion.cjs');function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var nt__namespace=/*#__PURE__*/_interopNamespace(nt);var Bt__namespace=/*#__PURE__*/_interopNamespace(Bt);var et__namespace=/*#__PURE__*/_interopNamespace(et);var L__namespace=/*#__PURE__*/_interopNamespace(L);var pt__namespace=/*#__PURE__*/_interopNamespace(pt);var G__namespace=/*#__PURE__*/_interopNamespace(G);var Xt=Object.defineProperty;var Jt=h=>{throw TypeError(h)};var ue=(h,e,i)=>e in h?Xt(h,e,{enumerable:true,configurable:true,writable:true,value:i}):h[e]=i;var fe=(h,e)=>{for(var i in e)Xt(h,i,{get:e[i],enumerable:true});};var C=(h,e,i)=>ue(h,typeof e!="symbol"?e+"":e,i),jt=(h,e,i)=>e.has(h)||Jt("Cannot "+i);var t=(h,e,i)=>(jt(h,e,"read from private field"),i?i.call(h):e.get(h)),_=(h,e,i)=>e.has(h)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(h):e.set(h,i),u=(h,e,i,s)=>(jt(h,e,"write to private field"),e.set(h,i),i),d=(h,e,i)=>(jt(h,e,"access private method"),i);var Rt=(h,e,i,s)=>({set _(r){u(h,e,r);},get _(){return t(h,e,s)}});var me=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ee=new Set,Gt=typeof process=="object"&&process?process:{},ie=(h,e,i,s)=>{typeof Gt.emitWarning=="function"?Gt.emitWarning(h,e,i,s):console.error(`[${i}] ${e}: ${h}`);},Nt=globalThis.AbortController,Qt=globalThis.AbortSignal;if(typeof Nt>"u"){Qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new Qt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let h=Gt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{h&&(h=false,ie("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var ge=h=>!ee.has(h);var at=h=>h&&h===Math.floor(h)&&h>0&&isFinite(h),se=h=>at(h)?h<=Math.pow(2,8)?Uint8Array:h<=Math.pow(2,16)?Uint16Array:h<=Math.pow(2,32)?Uint32Array:h<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(h){super(h),this.fill(0);}},it,St,_e=(it=class{heap;length;static create(e){let i=se(e);if(!i)return [];u(it,St,true);let s=new it(e,i);return u(it,St,false),s}constructor(e,i){if(!t(it,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,_(it,St,false),it),Zt,te,K,M,q,ut,$,yt,xt,B,O,X,T,b,m,P,z,N,R,J,D,Q,Z,V,W,tt,dt,j,Et,l,It,ft,ot,Tt,Y,oe,mt,bt,Ot,lt,ht,Mt,Lt,Ct,E,zt,At,ct,Vt,wt,re=(wt=class{constructor(e){_(this,l);_(this,K);_(this,M);_(this,q);_(this,ut);_(this,$);_(this,yt);_(this,xt);_(this,B);C(this,"ttl");C(this,"ttlResolution");C(this,"ttlAutopurge");C(this,"updateAgeOnGet");C(this,"updateAgeOnHas");C(this,"allowStale");C(this,"noDisposeOnSet");C(this,"noUpdateTTL");C(this,"maxEntrySize");C(this,"sizeCalculation");C(this,"noDeleteOnFetchRejection");C(this,"noDeleteOnStaleGet");C(this,"allowStaleOnFetchAbort");C(this,"allowStaleOnFetchRejection");C(this,"ignoreFetchAbort");_(this,O);_(this,X);_(this,T);_(this,b);_(this,m);_(this,P);_(this,z);_(this,N);_(this,R);_(this,J);_(this,D);_(this,Q);_(this,Z);_(this,V);_(this,W);_(this,tt);_(this,dt);_(this,j);_(this,Et);_(this,ft,()=>{});_(this,ot,()=>{});_(this,Tt,()=>{});_(this,Y,()=>false);_(this,mt,e=>{});_(this,bt,(e,i,s)=>{});_(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});C(this,Zt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:c,allowStale:p,dispose:v,onInsert:U,disposeAfter:S,noDisposeOnSet:rt,noUpdateTTL:I,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:y,fetchMethod:a,memoMethod:x,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:f,allowStaleOnFetchRejection:g,allowStaleOnFetchAbort:F,ignoreFetchAbort:H,perf:_t}=e;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,B,_t??me),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let vt=i?se(i):Array;if(!vt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,M,k),this.maxEntrySize=w||t(this,M),this.sizeCalculation=y,this.sizeCalculation){if(!t(this,M)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,xt,x),a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,yt,a),u(this,dt,!!a),u(this,T,new Map),u(this,b,new Array(i).fill(void 0)),u(this,m,new Array(i).fill(void 0)),u(this,P,new vt(i)),u(this,z,new vt(i)),u(this,N,0),u(this,R,0),u(this,J,_e.create(i)),u(this,O,0),u(this,X,0),typeof v=="function"&&u(this,q,v),typeof U=="function"&&u(this,ut,U),typeof S=="function"?(u(this,$,S),u(this,D,[])):(u(this,$,void 0),u(this,D,void 0)),u(this,tt,!!t(this,q)),u(this,Et,!!t(this,ut)),u(this,j,!!t(this,$)),this.noDisposeOnSet=!!rt,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!g,this.allowStaleOnFetchAbort=!!F,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(t(this,M)!==0&&!at(t(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");d(this,l,oe).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!f,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!c,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");d(this,l,It).call(this);}if(t(this,K)===0&&this.ttl===0&&t(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,K)&&!t(this,M)){let Pt="LRU_CACHE_UNBOUNDED";ge(Pt)&&(ee.add(Pt),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Pt,wt));}}get perf(){return t(this,B)}static unsafeExposeInternals(e){return {starts:t(e,Z),ttls:t(e,V),autopurgeTimers:t(e,W),sizes:t(e,Q),keyMap:t(e,T),keyList:t(e,b),valList:t(e,m),next:t(e,P),prev:t(e,z),get head(){return t(e,N)},get tail(){return t(e,R)},free:t(e,J),isBackgroundFetch:i=>{var s;return d(s=e,l,E).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return d(o=e,l,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return d(s=e,l,At).call(s,i)},indexes:i=>{var s;return d(s=e,l,lt).call(s,i)},rindexes:i=>{var s;return d(s=e,l,ht).call(s,i)},isStale:i=>{var s;return t(s=e,Y).call(s,i)}}}get max(){return t(this,K)}get maxSize(){return t(this,M)}get calculatedSize(){return t(this,X)}get size(){return t(this,O)}get fetchMethod(){return t(this,yt)}get memoMethod(){return t(this,xt)}get dispose(){return t(this,q)}get onInsert(){return t(this,ut)}get disposeAfter(){return t(this,$)}getRemainingTTL(e){return t(this,T).has(e)?1/0:0}*entries(){for(let e of d(this,l,lt).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*rentries(){for(let e of d(this,l,ht).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*keys(){for(let e of d(this,l,lt).call(this)){let i=t(this,b)[e];i!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield i);}}*rkeys(){for(let e of d(this,l,ht).call(this)){let i=t(this,b)[e];i!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield i);}}*values(){for(let e of d(this,l,lt).call(this))t(this,m)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}*rvalues(){for(let e of d(this,l,ht).call(this))t(this,m)[e]!==void 0&&!d(this,l,E).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}[(te=Symbol.iterator,Zt=Symbol.toStringTag,te)](){return this.entries()}find(e,i={}){for(let s of d(this,l,lt).call(this)){let r=t(this,m)[s],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,b)[s],this))return this.get(t(this,b)[s],i)}}forEach(e,i=this){for(let s of d(this,l,lt).call(this)){let r=t(this,m)[s],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,b)[s],this);}}rforEach(e,i=this){for(let s of d(this,l,ht).call(this)){let r=t(this,m)[s],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,b)[s],this);}}purgeStale(){let e=false;for(let i of d(this,l,ht).call(this,{allowStale:true}))t(this,Y).call(this,i)&&(d(this,l,ct).call(this,t(this,b)[i],"expire"),e=true);return e}info(e){let i=t(this,T).get(e);if(i===void 0)return;let s=t(this,m)[i],r=d(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,V)&&t(this,Z)){let o=t(this,V)[i],c=t(this,Z)[i];if(o&&c){let p=o-(t(this,B).now()-c);n.ttl=p,n.start=Date.now();}}return t(this,Q)&&(n.size=t(this,Q)[i]),n}dump(){let e=[];for(let i of d(this,l,lt).call(this,{allowStale:true})){let s=t(this,b)[i],r=t(this,m)[i],n=d(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,V)&&t(this,Z)){o.ttl=t(this,V)[i];let c=t(this,B).now()-t(this,Z)[i];o.start=Math.floor(Date.now()-c);}t(this,Q)&&(o.size=t(this,Q)[i]),e.unshift([s,o]);}return e}load(e){this.clear();for(let[i,s]of e){if(s.start){let r=Date.now()-s.start;s.start=t(this,B).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var rt,I,k,w;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:p}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,U=t(this,Ot).call(this,e,i,s.size||0,c);if(this.maxEntrySize&&U>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),d(this,l,ct).call(this,e,"set"),this;let S=t(this,O)===0?void 0:t(this,T).get(e);if(S===void 0)S=t(this,O)===0?t(this,R):t(this,J).length!==0?t(this,J).pop():t(this,O)===t(this,K)?d(this,l,Lt).call(this,false):t(this,O),t(this,b)[S]=e,t(this,m)[S]=i,t(this,T).set(e,S),t(this,P)[t(this,R)]=S,t(this,z)[S]=t(this,R),u(this,R,S),Rt(this,O)._++,t(this,bt).call(this,S,U,p),p&&(p.set="add"),v=false,t(this,Et)&&((rt=t(this,ut))==null||rt.call(this,i,e,"add"));else {d(this,l,At).call(this,S);let y=t(this,m)[S];if(i!==y){if(t(this,dt)&&d(this,l,E).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:a}=y;a!==void 0&&!o&&(t(this,tt)&&((I=t(this,q))==null||I.call(this,a,e,"set")),t(this,j)&&t(this,D)?.push([a,e,"set"]));}else o||(t(this,tt)&&((k=t(this,q))==null||k.call(this,y,e,"set")),t(this,j)&&t(this,D)?.push([y,e,"set"]));if(t(this,mt).call(this,S),t(this,bt).call(this,S,U,p),t(this,m)[S]=i,p){p.set="replace";let a=y&&d(this,l,E).call(this,y)?y.__staleWhileFetching:y;a!==void 0&&(p.oldValue=a);}}else p&&(p.set="update");t(this,Et)&&this.onInsert?.(i,e,i===y?"update":"replace");}if(r!==0&&!t(this,V)&&d(this,l,It).call(this),t(this,V)&&(v||t(this,Tt).call(this,S,r,n),p&&t(this,ot).call(this,p,S)),!o&&t(this,j)&&t(this,D)){let y=t(this,D),a;for(;a=y?.shift();)(w=t(this,$))==null||w.call(this,...a);}return this}pop(){var e;try{for(;t(this,O);){let i=t(this,m)[t(this,N)];if(d(this,l,Lt).call(this,!0),d(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,j)&&t(this,D)){let i=t(this,D),s;for(;s=i?.shift();)(e=t(this,$))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,T).get(e);if(n!==void 0){let o=t(this,m)[n];if(d(this,l,E).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,Y).call(this,n))r&&(r.has="stale",t(this,ot).call(this,r,n));else return s&&t(this,ft).call(this,n),r&&(r.has="hit",t(this,ot).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,T).get(e);if(r===void 0||!s&&t(this,Y).call(this,r))return;let n=t(this,m)[r];return d(this,l,E).call(this,n)?n.__staleWhileFetching:n}async fetch(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:p=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:U=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:rt=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:y=false,status:a,signal:x}=i;if(!t(this,dt))return a&&(a.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:a});let A={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:c,size:p,sizeCalculation:v,noUpdateTTL:U,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:rt,allowStaleOnFetchAbort:k,ignoreFetchAbort:I,status:a,signal:x},f=t(this,T).get(e);if(f===void 0){a&&(a.fetch="miss");let g=d(this,l,Ct).call(this,e,f,A,w);return g.__returned=g}else {let g=t(this,m)[f];if(d(this,l,E).call(this,g)){let vt=s&&g.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",vt&&(a.returnedStale=true)),vt?g.__staleWhileFetching:g.__returned=g}let F=t(this,Y).call(this,f);if(!y&&!F)return a&&(a.fetch="hit"),d(this,l,At).call(this,f),r&&t(this,ft).call(this,f),a&&t(this,ot).call(this,a,f),g;let H=d(this,l,Ct).call(this,e,f,A,w),_t=H.__staleWhileFetching!==void 0&&s;return a&&(a.fetch=F?"stale":"refresh",_t&&F&&(a.returnedStale=true)),_t?H.__staleWhileFetching:H.__returned=H}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e,i={}){let s=t(this,xt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,c=this.get(e,o);if(!n&&c!==void 0)return c;let p=s(e,c,{options:o,context:r});return this.set(e,p,o),p}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,c=t(this,T).get(e);if(c!==void 0){let p=t(this,m)[c],v=d(this,l,E).call(this,p);return o&&t(this,ot).call(this,o,c),t(this,Y).call(this,c)?(o&&(o.get="stale"),v?(o&&s&&p.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?p.__staleWhileFetching:void 0):(n||d(this,l,ct).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?p:void 0)):(o&&(o.get="hit"),v?p.__staleWhileFetching:(d(this,l,At).call(this,c),r&&t(this,ft).call(this,c),p))}else o&&(o.get="miss");}delete(e){return d(this,l,ct).call(this,e,"delete")}clear(){return d(this,l,Vt).call(this,"delete")}},K=new WeakMap,M=new WeakMap,q=new WeakMap,ut=new WeakMap,$=new WeakMap,yt=new WeakMap,xt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,T=new WeakMap,b=new WeakMap,m=new WeakMap,P=new WeakMap,z=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,V=new WeakMap,W=new WeakMap,tt=new WeakMap,dt=new WeakMap,j=new WeakMap,Et=new WeakMap,l=new WeakSet,It=function(){let e=new Dt(t(this,K)),i=new Dt(t(this,K));u(this,V,e),u(this,Z,i);let s=this.ttlAutopurge?new Array(t(this,K)):void 0;u(this,W,s),u(this,Tt,(c,p,v=t(this,B).now())=>{i[c]=p!==0?v:0,e[c]=p,r(c,p);}),u(this,ft,c=>{i[c]=e[c]!==0?t(this,B).now():0,r(c,e[c]);});let r=this.ttlAutopurge?(c,p)=>{if(s?.[c]&&(clearTimeout(s[c]),s[c]=void 0),p&&p!==0&&s){let v=setTimeout(()=>{t(this,Y).call(this,c)&&d(this,l,ct).call(this,t(this,b)[c],"expire");},p+1);v.unref&&v.unref(),s[c]=v;}}:()=>{};u(this,ot,(c,p)=>{if(e[p]){let v=e[p],U=i[p];if(!v||!U)return;c.ttl=v,c.start=U,c.now=n||o();let S=c.now-U;c.remainingTTL=v-S;}});let n=0,o=()=>{let c=t(this,B).now();if(this.ttlResolution>0){n=c;let p=setTimeout(()=>n=0,this.ttlResolution);p.unref&&p.unref();}return c};this.getRemainingTTL=c=>{let p=t(this,T).get(c);if(p===void 0)return 0;let v=e[p],U=i[p];if(!v||!U)return 1/0;let S=(n||o())-U;return v-S},u(this,Y,c=>{let p=i[c],v=e[c];return !!v&&!!p&&(n||o())-p>v});},ft=new WeakMap,ot=new WeakMap,Tt=new WeakMap,Y=new WeakMap,oe=function(){let e=new Dt(t(this,K));u(this,X,0),u(this,Q,e),u(this,mt,i=>{u(this,X,t(this,X)-e[i]),e[i]=0;}),u(this,Ot,(i,s,r,n)=>{if(d(this,l,E).call(this,s))return 0;if(!at(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!at(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),u(this,bt,(i,s,r)=>{if(e[i]=s,t(this,M)){let n=t(this,M)-e[i];for(;t(this,X)>n;)d(this,l,Lt).call(this,true);}u(this,X,t(this,X)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,X));});},mt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,lt=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,R);!(!d(this,l,Mt).call(this,i)||((e||!t(this,Y).call(this,i))&&(yield i),i===t(this,N)));)i=t(this,z)[i];},ht=function*({allowStale:e=this.allowStale}={}){if(t(this,O))for(let i=t(this,N);!(!d(this,l,Mt).call(this,i)||((e||!t(this,Y).call(this,i))&&(yield i),i===t(this,R)));)i=t(this,P)[i];},Mt=function(e){return e!==void 0&&t(this,T).get(t(this,b)[e])===e},Lt=function(e){var n;let i=t(this,N),s=t(this,b)[i],r=t(this,m)[i];return t(this,dt)&&d(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,tt)||t(this,j))&&(t(this,tt)&&((n=t(this,q))==null||n.call(this,r,s,"evict")),t(this,j)&&t(this,D)?.push([r,s,"evict"])),t(this,mt).call(this,i),t(this,W)?.[i]&&(clearTimeout(t(this,W)[i]),t(this,W)[i]=void 0),e&&(t(this,b)[i]=void 0,t(this,m)[i]=void 0,t(this,J).push(i)),t(this,O)===1?(u(this,N,u(this,R,0)),t(this,J).length=0):u(this,N,t(this,P)[i]),t(this,T).delete(s),Rt(this,O)._--,i},Ct=function(e,i,s,r){let n=i===void 0?void 0:t(this,m)[i];if(d(this,l,E).call(this,n))return n;let o=new Nt,{signal:c}=s;c?.addEventListener("abort",()=>o.abort(c.reason),{signal:o.signal});let p={signal:o.signal,options:s,context:r},v=(w,y=false)=>{let{aborted:a}=o.signal,x=s.ignoreFetchAbort&&w!==void 0,A=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(a&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,x&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),a&&!x&&!y)return S(o.signal.reason,A);let f=I,g=t(this,m)[i];return (g===I||x&&y&&g===void 0)&&(w===void 0?f.__staleWhileFetching!==void 0?t(this,m)[i]=f.__staleWhileFetching:d(this,l,ct).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,w,p.options))),w},U=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),S(w,false)),S=(w,y)=>{let{aborted:a}=o.signal,x=a&&s.allowStaleOnFetchAbort,A=x||s.allowStaleOnFetchRejection,f=A||s.noDeleteOnFetchRejection,g=I;if(t(this,m)[i]===I&&(!f||!y&&g.__staleWhileFetching===void 0?d(this,l,ct).call(this,e,"fetch"):x||(t(this,m)[i]=g.__staleWhileFetching)),A)return s.status&&g.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),g.__staleWhileFetching;if(g.__returned===g)throw w},rt=(w,y)=>{var x;let a=(x=t(this,yt))==null?void 0:x.call(this,e,n,p);a&&a instanceof Promise&&a.then(A=>w(A===void 0?void 0:A),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=A=>v(A,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(rt).then(v,U),k=Object.assign(I,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,k,{...p.options,status:void 0}),i=t(this,T).get(e)):t(this,m)[i]=k,k},E=function(e){if(!t(this,dt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},zt=function(e,i){t(this,z)[i]=e,t(this,P)[e]=i;},At=function(e){e!==t(this,R)&&(e===t(this,N)?u(this,N,t(this,P)[e]):d(this,l,zt).call(this,t(this,z)[e],t(this,P)[e]),d(this,l,zt).call(this,t(this,R),e),u(this,R,e));},ct=function(e,i){var r,n;let s=false;if(t(this,O)!==0){let o=t(this,T).get(e);if(o!==void 0)if(t(this,W)?.[o]&&(clearTimeout(t(this,W)?.[o]),t(this,W)[o]=void 0),s=true,t(this,O)===1)d(this,l,Vt).call(this,i);else {t(this,mt).call(this,o);let c=t(this,m)[o];if(d(this,l,E).call(this,c)?c.__abortController.abort(new Error("deleted")):(t(this,tt)||t(this,j))&&(t(this,tt)&&((r=t(this,q))==null||r.call(this,c,e,i)),t(this,j)&&t(this,D)?.push([c,e,i])),t(this,T).delete(e),t(this,b)[o]=void 0,t(this,m)[o]=void 0,o===t(this,R))u(this,R,t(this,z)[o]);else if(o===t(this,N))u(this,N,t(this,P)[o]);else {let p=t(this,z)[o];t(this,P)[p]=t(this,P)[o];let v=t(this,P)[o];t(this,z)[v]=t(this,z)[o];}Rt(this,O)._--,t(this,J).push(o);}}if(t(this,j)&&t(this,D)?.length){let o=t(this,D),c;for(;c=o?.shift();)(n=t(this,$))==null||n.call(this,...c);}return s},Vt=function(e){var i,s;for(let r of d(this,l,ht).call(this,{allowStale:true})){let n=t(this,m)[r];if(d(this,l,E).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,b)[r];t(this,tt)&&((i=t(this,q))==null||i.call(this,n,o,e)),t(this,j)&&t(this,D)?.push([n,o,e]);}}if(t(this,T).clear(),t(this,m).fill(void 0),t(this,b).fill(void 0),t(this,V)&&t(this,Z)){t(this,V).fill(0),t(this,Z).fill(0);for(let r of t(this,W)??[])r!==void 0&&clearTimeout(r);t(this,W)?.fill(void 0);}if(t(this,Q)&&t(this,Q).fill(0),u(this,N,0),u(this,R,0),t(this,J).length=0,u(this,X,0),u(this,O,0),t(this,j)&&t(this,D)){let r=t(this,D),n;for(;n=r?.shift();)(s=t(this,$))==null||s.call(this,...n);}},wt);var Ft=class{cache;map=new Map;constructor(e){this.cache=new re({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ut="1.8.13";var Wt={version:Ut};var Yt="repeat";function Ht(h){return {type:"pause",duration:h}}var Kt="__game_layer__";var ve={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var ae={};var kt={};fe(kt,{createExportableElement:()=>le});var gt;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(gt||={});function le(h){try{if(typeof h>"u")return h;let e=JSON.stringify(h);return JSON.parse(e)}catch(e){throw gt.error("Error creating exportable element",h,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ye=typeof window<"u"&&typeof document<"u",he=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Wt.version}`],ce=31,xe="background:#2f90da;color:#fff;font-weight:bold;",Ee="background:#c832bb;color:#fff;font-weight:bold;",be="background:transparent;font-weight:bold;",qt=` v${Wt.version}`;function de(){if(!ye)return;let h=[],e=[];for(let i=0;i<he.length;i++){let s=he[i],r=s.endsWith(qt),n=r?s.slice(0,-qt.length):s,o=n.slice(0,ce),c=n.slice(ce),p=r?"%c%s%c%s%c%s":"%c%s%c%s";h.push(p),e.push(xe,o,Ee,c),r&&e.push(be,qt);}console.info(h.join(`
2
2
  `),...e);}function $t(){let h=window.location.pathname+window.location.hash;return h.includes("#")&&(h=h.split("#")[1]),h}de();exports.Game=void 0;(y=>{async function h(a,x,A){if(core.GameUnifier.init({navigate:x?.navigate,getCurrentGameStepState:()=>{let f={};try{f=nt__namespace.canvas.export();}catch{}return {path:$t(),storage:G__namespace.storage.export(),canvas:f,sound:pt__namespace.sound.export(),labelIndex:L__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:L__namespace.narration.openedLabels}},restoreGameStepState:async(f,g)=>{et__namespace.HistoryManagerStatic._originalStepData=f,L__namespace.NarrationManagerStatic.openedLabels=f.openedLabels,G__namespace.storage.restore(f.storage);try{await nt__namespace.canvas.restore(f.canvas),await pt__namespace.sound.restore(f.sound);}catch(F){gt.error("Error restoring game step state:",F);}await g(f.path);},getStepCounter:()=>L__namespace.narration.stepCounter,setStepCounter:f=>{L__namespace.NarrationManagerStatic._stepCounter=f;},getOpenedLabels:()=>L__namespace.narration.openedLabels.length,addHistoryItem:(f,g)=>et__namespace.stepHistory.add(f,g),getCharacter:f=>Bt__namespace.RegisteredCharacters.get(f),processNavigationRequests:(f,g)=>{let F=f,H=Promise.resolve();return f>0?(F--,H=L__namespace.narration.continue(g)):f<0&&(F=0,H=et__namespace.stepHistory.back(g,{steps:f*-1})),{newValue:F,result:H}},animate:(f,g,F,H)=>motion.motion.animate(f,g,F,H),getVariable:(f,g)=>G__namespace.StorageRegistry.getVariable(f,g),setVariable:(f,g,F)=>G__namespace.StorageRegistry.setVariable(f,g,F),removeVariable:(f,g)=>G__namespace.StorageRegistry.removeVariable(f,g),getFlag:f=>G__namespace.storage.getFlag(f),setFlag:(f,g)=>G__namespace.storage.setFlag(f,g),onLabelClosing:f=>G__namespace.StorageRegistry.clearOldTempVariables(f)}),!a||!x){gt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await nt__namespace.canvas.init(a,x,A)}y.init=h;function e(){G__namespace.storage.clear();try{nt__namespace.canvas.clear();}catch{}pt__namespace.sound.clear(),L__namespace.narration.clear(),et__namespace.stepHistory.clear();}y.clear=e;function i(){let a={};try{a=nt__namespace.canvas.export();}catch{}return {pixivn_version:Ut,stepData:L__namespace.narration.export(),storageData:G__namespace.storage.export(),canvasData:a,soundData:pt__namespace.sound.export(),historyData:et__namespace.stepHistory.export(),path:$t()}}y.exportGameState=i;async function s(a,x){et__namespace.stepHistory.restore(a.historyData);let A=et__namespace.stepHistory.lastKey;if(typeof A=="number"){let f=et__namespace.stepHistory.stepsInfoMap.get(A)||null;await L__namespace.narration.restore(a.stepData,f);}G__namespace.storage.restore(a.storageData);try{await nt__namespace.canvas.restore(a.canvasData),await pt__namespace.sound.restore(a.soundData);}catch{}x?await x(a.path):await core.GameUnifier.navigate(a.path);}y.restoreGameState=s;async function r(a,x){return y.clear(),await L__namespace.narration.call(a,x)}y.start=r;function n(a){return JSON.parse(a)}y.jsonToGameState=n;function o(a){core.GameUnifier.onEnd=a;}y.onEnd=o;function c(a){return gt.warn("Game.onError is deprecated. Use Game.addOnError / Game.removeOnError to register multiple handlers."),core.GameUnifier.addOnError((x,A)=>a("step",x,A))}y.onError=c;function p(a){return core.GameUnifier.addOnError(a)}y.addOnError=p;function v(a){return core.GameUnifier.removeOnError(a)}y.removeOnError=v;function U(a){L__namespace.NarrationManagerStatic.onStepStart=a;}y.onStepStart=U;function S(a){L__namespace.NarrationManagerStatic.onLoadingLabel=a;}y.onLoadingLabel=S;function rt(a){L__namespace.NarrationManagerStatic.onStepEnd=a;}y.onStepEnd=rt;function I(a){core.GameUnifier.navigate=a;}y.onNavigate=I;function k(a){return core.GameUnifier.addOnPreContinue(a)}y.addOnPreContinue=k;function w(a){return core.GameUnifier.removeOnPreContinue(a)}y.removeOnPreContinue=w;})(exports.Game||={});var Ze={characterUtils:Bt__namespace,canvasUtils:nt__namespace,narrationUtils:L__namespace,soundUtils:pt__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Kt,Pause:Ht,Repeat:Yt,PIXIVN_VERSION:Ut,...kt,...ae,canvas:nt__namespace.canvas,narration:L__namespace.narration,sound:pt__namespace.sound,storage:G__namespace.storage,history:et__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Kt;exports.CachedMap=Ft;exports.PIXIVN_VERSION=Ut;exports.Pause=Ht;exports.Repeat=Yt;exports.SYSTEM_RESERVED_STORAGE_KEYS=ve;exports.createExportableElement=le;exports.default=Ze;Object.keys(nt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return nt[k]}})});Object.keys(Bt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return Bt[k]}})});Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(et).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return et[k]}})});Object.keys(L).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return L[k]}})});Object.keys(pt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return pt[k]}})});Object.keys(G).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return G[k]}})});
package/dist/index.d.cts CHANGED
@@ -29,7 +29,7 @@ import './HistoryStep-G9dUn0Lf.cjs';
29
29
  import 'microdiff';
30
30
  import './StorageElementType-C7ETezlL.cjs';
31
31
 
32
- var version = "1.8.12";
32
+ var version = "1.8.13";
33
33
 
34
34
  /**
35
35
  * @deprecated
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ import './HistoryStep-G9dUn0Lf.js';
29
29
  import 'microdiff';
30
30
  import './StorageElementType-C7ETezlL.js';
31
31
 
32
- var version = "1.8.12";
32
+ var version = "1.8.13";
33
33
 
34
34
  /**
35
35
  * @deprecated
package/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {f as f$1,b as b$1,g,e,d,h,i}from'./chunk-K7JIC2F2.mjs';import*as nt from'./canvas.mjs';export*from'./canvas.mjs';import*as $t from'./characters.mjs';export*from'./characters.mjs';import {PixiError,GameUnifier}from'./core.mjs';export*from'./core.mjs';import*as et from'./history.mjs';export*from'./history.mjs';import*as L from'./narration.mjs';export*from'./narration.mjs';import*as pt from'./sound.mjs';export*from'./sound.mjs';import*as G from'./storage.mjs';export*from'./storage.mjs';import {motion}from'./motion.mjs';var de=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Qt=new Set,jt=typeof process=="object"&&process?process:{},Zt=(m,e,i,s)=>{typeof jt.emitWarning=="function"?jt.emitWarning(m,e,i,s):console.error(`[${i}] ${e}: ${m}`);},Nt=globalThis.AbortController,Bt=globalThis.AbortSignal;if(typeof Nt>"u"){Bt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new Bt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let m=jt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{m&&(m=false,Zt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var pe=m=>!Qt.has(m);var at=m=>m&&m===Math.floor(m)&&m>0&&isFinite(m),te=m=>at(m)?m<=Math.pow(2,8)?Uint8Array:m<=Math.pow(2,16)?Uint16Array:m<=Math.pow(2,32)?Uint32Array:m<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(m){super(m),this.fill(0);}},it,St,ue=(it=class{heap;length;static create(e){let i=te(e);if(!i)return [];g(it,St,true);let s=new it(e,i);return g(it,St,false),s}constructor(e$1,i){if(!e(it,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,f$1(it,St,false),it),Xt,Jt,K,M,q,ut,$,yt,xt,B,O,X,T,b,f,P,z,N,R,J,D,Q,Z,V,W,tt,dt,j,Et,l,Gt,ft,ot,Tt,Y,ie,mt,bt,Ot,lt,ht,It,Lt,Ct,E,Mt,At,ct,zt,wt,ee=(wt=class{constructor(e$1){f$1(this,l);f$1(this,K);f$1(this,M);f$1(this,q);f$1(this,ut);f$1(this,$);f$1(this,yt);f$1(this,xt);f$1(this,B);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f$1(this,O);f$1(this,X);f$1(this,T);f$1(this,b);f$1(this,f);f$1(this,P);f$1(this,z);f$1(this,N);f$1(this,R);f$1(this,J);f$1(this,D);f$1(this,Q);f$1(this,Z);f$1(this,V);f$1(this,W);f$1(this,tt);f$1(this,dt);f$1(this,j);f$1(this,Et);f$1(this,ft,()=>{});f$1(this,ot,()=>{});f$1(this,Tt,()=>{});f$1(this,Y,()=>false);f$1(this,mt,e=>{});f$1(this,bt,(e,i,s)=>{});f$1(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Xt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:h$1,allowStale:d$1,dispose:v,onInsert:U,disposeAfter:S,noDisposeOnSet:rt,noUpdateTTL:I,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:y,fetchMethod:a,memoMethod:x,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:u,allowStaleOnFetchRejection:g$1,allowStaleOnFetchAbort:F,ignoreFetchAbort:H,perf:_t}=e$1;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,B,_t??de),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let vt=i?te(i):Array;if(!vt)throw new Error("invalid max value: "+i);if(g(this,K,i),g(this,M,k),this.maxEntrySize=w||e(this,M),this.sizeCalculation=y,this.sizeCalculation){if(!e(this,M)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,xt,x),a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,yt,a),g(this,dt,!!a),g(this,T,new Map),g(this,b,new Array(i).fill(void 0)),g(this,f,new Array(i).fill(void 0)),g(this,P,new vt(i)),g(this,z,new vt(i)),g(this,N,0),g(this,R,0),g(this,J,ue.create(i)),g(this,O,0),g(this,X,0),typeof v=="function"&&g(this,q,v),typeof U=="function"&&g(this,ut,U),typeof S=="function"?(g(this,$,S),g(this,D,[])):(g(this,$,void 0),g(this,D,void 0)),g(this,tt,!!e(this,q)),g(this,Et,!!e(this,ut)),g(this,j,!!e(this,$)),this.noDisposeOnSet=!!rt,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!g$1,this.allowStaleOnFetchAbort=!!F,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(e(this,M)!==0&&!at(e(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,l,ie).call(this);}if(this.allowStale=!!d$1,this.noDeleteOnStaleGet=!!u,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h$1,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,l,Gt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,M)){let Pt="LRU_CACHE_UNBOUNDED";pe(Pt)&&(Qt.add(Pt),Zt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Pt,wt));}}get perf(){return e(this,B)}static unsafeExposeInternals(e$1){return {starts:e(e$1,Z),ttls:e(e$1,V),autopurgeTimers:e(e$1,W),sizes:e(e$1,Q),keyMap:e(e$1,T),keyList:e(e$1,b),valList:e(e$1,f),next:e(e$1,P),prev:e(e$1,z),get head(){return e(e$1,N)},get tail(){return e(e$1,R)},free:e(e$1,J),isBackgroundFetch:i=>{var s;return h(s=e$1,l,E).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return h(o=e$1,l,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return h(s=e$1,l,At).call(s,i)},indexes:i=>{var s;return h(s=e$1,l,lt).call(s,i)},rindexes:i=>{var s;return h(s=e$1,l,ht).call(s,i)},isStale:i=>{var s;return e(s=e$1,Y).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,M)}get calculatedSize(){return e(this,X)}get size(){return e(this,O)}get fetchMethod(){return e(this,yt)}get memoMethod(){return e(this,xt)}get dispose(){return e(this,q)}get onInsert(){return e(this,ut)}get disposeAfter(){return e(this,$)}getRemainingTTL(e$1){return e(this,T).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,l,lt).call(this))e(this,f)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield [e(this,b)[e$1],e(this,f)[e$1]]);}*rentries(){for(let e$1 of h(this,l,ht).call(this))e(this,f)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield [e(this,b)[e$1],e(this,f)[e$1]]);}*keys(){for(let e$1 of h(this,l,lt).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,l,ht).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,l,lt).call(this))e(this,f)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield e(this,f)[e$1]);}*rvalues(){for(let e$1 of h(this,l,ht).call(this))e(this,f)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield e(this,f)[e$1]);}[(Jt=Symbol.iterator,Xt=Symbol.toStringTag,Jt)](){return this.entries()}find(e$1,i={}){for(let s of h(this,l,lt).call(this)){let r=e(this,f)[s],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e$1(n,e(this,b)[s],this))return this.get(e(this,b)[s],i)}}forEach(e$1,i=this){for(let s of h(this,l,lt).call(this)){let r=e(this,f)[s],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,l,ht).call(this)){let r=e(this,f)[s],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,l,ht).call(this,{allowStale:true}))e(this,Y).call(this,i)&&(h(this,l,ct).call(this,e(this,b)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,T).get(e$1);if(i===void 0)return;let s=e(this,f)[i],r=h(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(e(this,V)&&e(this,Z)){let o=e(this,V)[i],h=e(this,Z)[i];if(o&&h){let d=o-(e(this,B).now()-h);n.ttl=d,n.start=Date.now();}}return e(this,Q)&&(n.size=e(this,Q)[i]),n}dump(){let e$1=[];for(let i of h(this,l,lt).call(this,{allowStale:true})){let s=e(this,b)[i],r=e(this,f)[i],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(e(this,V)&&e(this,Z)){o.ttl=e(this,V)[i];let h=e(this,B).now()-e(this,Z)[i];o.start=Math.floor(Date.now()-h);}e(this,Q)&&(o.size=e(this,Q)[i]),e$1.unshift([s,o]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let r=Date.now()-s.start;s.start=e(this,B).now()-r;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var rt,I,k,w;if(i$1===void 0)return this.delete(e$1),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h$1=this.sizeCalculation,status:d}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,U=e(this,Ot).call(this,e$1,i$1,s.size||0,h$1);if(this.maxEntrySize&&U>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),h(this,l,ct).call(this,e$1,"set"),this;let S=e(this,O)===0?void 0:e(this,T).get(e$1);if(S===void 0)S=e(this,O)===0?e(this,R):e(this,J).length!==0?e(this,J).pop():e(this,O)===e(this,K)?h(this,l,Lt).call(this,false):e(this,O),e(this,b)[S]=e$1,e(this,f)[S]=i$1,e(this,T).set(e$1,S),e(this,P)[e(this,R)]=S,e(this,z)[S]=e(this,R),g(this,R,S),i(this,O)._++,e(this,bt).call(this,S,U,d),d&&(d.set="add"),v=false,e(this,Et)&&((rt=e(this,ut))==null||rt.call(this,i$1,e$1,"add"));else {h(this,l,At).call(this,S);let y=e(this,f)[S];if(i$1!==y){if(e(this,dt)&&h(this,l,E).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:a}=y;a!==void 0&&!o&&(e(this,tt)&&((I=e(this,q))==null||I.call(this,a,e$1,"set")),e(this,j)&&e(this,D)?.push([a,e$1,"set"]));}else o||(e(this,tt)&&((k=e(this,q))==null||k.call(this,y,e$1,"set")),e(this,j)&&e(this,D)?.push([y,e$1,"set"]));if(e(this,mt).call(this,S),e(this,bt).call(this,S,U,d),e(this,f)[S]=i$1,d){d.set="replace";let a=y&&h(this,l,E).call(this,y)?y.__staleWhileFetching:y;a!==void 0&&(d.oldValue=a);}}else d&&(d.set="update");e(this,Et)&&this.onInsert?.(i$1,e$1,i$1===y?"update":"replace");}if(r!==0&&!e(this,V)&&h(this,l,Gt).call(this),e(this,V)&&(v||e(this,Tt).call(this,S,r,n),d&&e(this,ot).call(this,d,S)),!o&&e(this,j)&&e(this,D)){let y=e(this,D),a;for(;a=y?.shift();)(w=e(this,$))==null||w.call(this,...a);}return this}pop(){var e$1;try{for(;e(this,O);){let i=e(this,f)[e(this,N)];if(h(this,l,Lt).call(this,!0),h(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,j)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(e$1=e(this,$))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=e(this,T).get(e$1);if(n!==void 0){let o=e(this,f)[n];if(h(this,l,E).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(e(this,Y).call(this,n))r&&(r.has="stale",e(this,ot).call(this,r,n));else return s&&e(this,ft).call(this,n),r&&(r.has="hit",e(this,ot).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,T).get(e$1);if(r===void 0||!s&&e(this,Y).call(this,r))return;let n=e(this,f)[r];return h(this,l,E).call(this,n)?n.__staleWhileFetching:n}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h$1=this.noDisposeOnSet,size:d=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:U=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:rt=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:y=false,status:a,signal:x}=i;if(!e(this,dt))return a&&(a.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:a});let A={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:h$1,size:d,sizeCalculation:v,noUpdateTTL:U,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:rt,allowStaleOnFetchAbort:k,ignoreFetchAbort:I,status:a,signal:x},u=e(this,T).get(e$1);if(u===void 0){a&&(a.fetch="miss");let g=h(this,l,Ct).call(this,e$1,u,A,w);return g.__returned=g}else {let g=e(this,f)[u];if(h(this,l,E).call(this,g)){let vt=s&&g.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",vt&&(a.returnedStale=true)),vt?g.__staleWhileFetching:g.__returned=g}let F=e(this,Y).call(this,u);if(!y&&!F)return a&&(a.fetch="hit"),h(this,l,At).call(this,u),r&&e(this,ft).call(this,u),a&&e(this,ot).call(this,a,u),g;let H=h(this,l,Ct).call(this,e$1,u,A,w),_t=H.__staleWhileFetching!==void 0&&s;return a&&(a.fetch=F?"stale":"refresh",_t&&F&&(a.returnedStale=true)),_t?H.__staleWhileFetching:H.__returned=H}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,xt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,h=this.get(e$1,o);if(!n&&h!==void 0)return h;let d=s(e$1,h,{options:o,context:r});return this.set(e$1,d,o),d}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,h$1=e(this,T).get(e$1);if(h$1!==void 0){let d=e(this,f)[h$1],v=h(this,l,E).call(this,d);return o&&e(this,ot).call(this,o,h$1),e(this,Y).call(this,h$1)?(o&&(o.get="stale"),v?(o&&s&&d.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?d.__staleWhileFetching:void 0):(n||h(this,l,ct).call(this,e$1,"expire"),o&&s&&(o.returnedStale=true),s?d:void 0)):(o&&(o.get="hit"),v?d.__staleWhileFetching:(h(this,l,At).call(this,h$1),r&&e(this,ft).call(this,h$1),d))}else o&&(o.get="miss");}delete(e){return h(this,l,ct).call(this,e,"delete")}clear(){return h(this,l,zt).call(this,"delete")}},K=new WeakMap,M=new WeakMap,q=new WeakMap,ut=new WeakMap,$=new WeakMap,yt=new WeakMap,xt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,T=new WeakMap,b=new WeakMap,f=new WeakMap,P=new WeakMap,z=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,V=new WeakMap,W=new WeakMap,tt=new WeakMap,dt=new WeakMap,j=new WeakMap,Et=new WeakMap,l=new WeakSet,Gt=function(){let e$1=new Dt(e(this,K)),i=new Dt(e(this,K));g(this,V,e$1),g(this,Z,i);let s=this.ttlAutopurge?new Array(e(this,K)):void 0;g(this,W,s),g(this,Tt,(h,d,v=e(this,B).now())=>{i[h]=d!==0?v:0,e$1[h]=d,r(h,d);}),g(this,ft,h=>{i[h]=e$1[h]!==0?e(this,B).now():0,r(h,e$1[h]);});let r=this.ttlAutopurge?(h$1,d)=>{if(s?.[h$1]&&(clearTimeout(s[h$1]),s[h$1]=void 0),d&&d!==0&&s){let v=setTimeout(()=>{e(this,Y).call(this,h$1)&&h(this,l,ct).call(this,e(this,b)[h$1],"expire");},d+1);v.unref&&v.unref(),s[h$1]=v;}}:()=>{};g(this,ot,(h,d)=>{if(e$1[d]){let v=e$1[d],U=i[d];if(!v||!U)return;h.ttl=v,h.start=U,h.now=n||o();let S=h.now-U;h.remainingTTL=v-S;}});let n=0,o=()=>{let h=e(this,B).now();if(this.ttlResolution>0){n=h;let d=setTimeout(()=>n=0,this.ttlResolution);d.unref&&d.unref();}return h};this.getRemainingTTL=h=>{let d=e(this,T).get(h);if(d===void 0)return 0;let v=e$1[d],U=i[d];if(!v||!U)return 1/0;let S=(n||o())-U;return v-S},g(this,Y,h=>{let d=i[h],v=e$1[h];return !!v&&!!d&&(n||o())-d>v});},ft=new WeakMap,ot=new WeakMap,Tt=new WeakMap,Y=new WeakMap,ie=function(){let e$1=new Dt(e(this,K));g(this,X,0),g(this,Q,e$1),g(this,mt,i=>{g(this,X,e(this,X)-e$1[i]),e$1[i]=0;}),g(this,Ot,(i,s,r,n)=>{if(h(this,l,E).call(this,s))return 0;if(!at(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!at(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),g(this,bt,(i,s,r)=>{if(e$1[i]=s,e(this,M)){let n=e(this,M)-e$1[i];for(;e(this,X)>n;)h(this,l,Lt).call(this,true);}g(this,X,e(this,X)+e$1[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,X));});},mt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,lt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,O))for(let i=e(this,R);!(!h(this,l,It).call(this,i)||((e$1||!e(this,Y).call(this,i))&&(yield i),i===e(this,N)));)i=e(this,z)[i];},ht=function*({allowStale:e$1=this.allowStale}={}){if(e(this,O))for(let i=e(this,N);!(!h(this,l,It).call(this,i)||((e$1||!e(this,Y).call(this,i))&&(yield i),i===e(this,R)));)i=e(this,P)[i];},It=function(e$1){return e$1!==void 0&&e(this,T).get(e(this,b)[e$1])===e$1},Lt=function(e$1){var n;let i$1=e(this,N),s=e(this,b)[i$1],r=e(this,f)[i$1];return e(this,dt)&&h(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,tt)||e(this,j))&&(e(this,tt)&&((n=e(this,q))==null||n.call(this,r,s,"evict")),e(this,j)&&e(this,D)?.push([r,s,"evict"])),e(this,mt).call(this,i$1),e(this,W)?.[i$1]&&(clearTimeout(e(this,W)[i$1]),e(this,W)[i$1]=void 0),e$1&&(e(this,b)[i$1]=void 0,e(this,f)[i$1]=void 0,e(this,J).push(i$1)),e(this,O)===1?(g(this,N,g(this,R,0)),e(this,J).length=0):g(this,N,e(this,P)[i$1]),e(this,T).delete(s),i(this,O)._--,i$1},Ct=function(e$1,i,s,r){let n=i===void 0?void 0:e(this,f)[i];if(h(this,l,E).call(this,n))return n;let o=new Nt,{signal:h$1}=s;h$1?.addEventListener("abort",()=>o.abort(h$1.reason),{signal:o.signal});let d={signal:o.signal,options:s,context:r},v=(w,y=false)=>{let{aborted:a}=o.signal,x=s.ignoreFetchAbort&&w!==void 0,A=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(a&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,x&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),a&&!x&&!y)return S(o.signal.reason,A);let u=I,g=e(this,f)[i];return (g===I||x&&y&&g===void 0)&&(w===void 0?u.__staleWhileFetching!==void 0?e(this,f)[i]=u.__staleWhileFetching:h(this,l,ct).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,w,d.options))),w},U=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),S(w,false)),S=(w,y)=>{let{aborted:a}=o.signal,x=a&&s.allowStaleOnFetchAbort,A=x||s.allowStaleOnFetchRejection,u=A||s.noDeleteOnFetchRejection,g=I;if(e(this,f)[i]===I&&(!u||!y&&g.__staleWhileFetching===void 0?h(this,l,ct).call(this,e$1,"fetch"):x||(e(this,f)[i]=g.__staleWhileFetching)),A)return s.status&&g.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),g.__staleWhileFetching;if(g.__returned===g)throw w},rt=(w,y)=>{var x;let a=(x=e(this,yt))==null?void 0:x.call(this,e$1,n,d);a&&a instanceof Promise&&a.then(A=>w(A===void 0?void 0:A),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=A=>v(A,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(rt).then(v,U),k=Object.assign(I,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e$1,k,{...d.options,status:void 0}),i=e(this,T).get(e$1)):e(this,f)[i]=k,k},E=function(e$1){if(!e(this,dt))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},Mt=function(e$1,i){e(this,z)[i]=e$1,e(this,P)[e$1]=i;},At=function(e$1){e$1!==e(this,R)&&(e$1===e(this,N)?g(this,N,e(this,P)[e$1]):h(this,l,Mt).call(this,e(this,z)[e$1],e(this,P)[e$1]),h(this,l,Mt).call(this,e(this,R),e$1),g(this,R,e$1));},ct=function(e$1,i$1){var r,n;let s=false;if(e(this,O)!==0){let o=e(this,T).get(e$1);if(o!==void 0)if(e(this,W)?.[o]&&(clearTimeout(e(this,W)?.[o]),e(this,W)[o]=void 0),s=true,e(this,O)===1)h(this,l,zt).call(this,i$1);else {e(this,mt).call(this,o);let h$1=e(this,f)[o];if(h(this,l,E).call(this,h$1)?h$1.__abortController.abort(new Error("deleted")):(e(this,tt)||e(this,j))&&(e(this,tt)&&((r=e(this,q))==null||r.call(this,h$1,e$1,i$1)),e(this,j)&&e(this,D)?.push([h$1,e$1,i$1])),e(this,T).delete(e$1),e(this,b)[o]=void 0,e(this,f)[o]=void 0,o===e(this,R))g(this,R,e(this,z)[o]);else if(o===e(this,N))g(this,N,e(this,P)[o]);else {let d=e(this,z)[o];e(this,P)[d]=e(this,P)[o];let v=e(this,P)[o];e(this,z)[v]=e(this,z)[o];}i(this,O)._--,e(this,J).push(o);}}if(e(this,j)&&e(this,D)?.length){let o=e(this,D),h;for(;h=o?.shift();)(n=e(this,$))==null||n.call(this,...h);}return s},zt=function(e$1){var i,s;for(let r of h(this,l,ht).call(this,{allowStale:true})){let n=e(this,f)[r];if(h(this,l,E).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=e(this,b)[r];e(this,tt)&&((i=e(this,q))==null||i.call(this,n,o,e$1)),e(this,j)&&e(this,D)?.push([n,o,e$1]);}}if(e(this,T).clear(),e(this,f).fill(void 0),e(this,b).fill(void 0),e(this,V)&&e(this,Z)){e(this,V).fill(0),e(this,Z).fill(0);for(let r of e(this,W)??[])r!==void 0&&clearTimeout(r);e(this,W)?.fill(void 0);}if(e(this,Q)&&e(this,Q).fill(0),g(this,N,0),g(this,R,0),e(this,J).length=0,g(this,X,0),g(this,O,0),e(this,j)&&e(this,D)){let r=e(this,D),n;for(;n=r?.shift();)(s=e(this,$))==null||s.call(this,...n);}},wt);var Ft=class{cache;map=new Map;constructor(e){this.cache=new ee({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ut="1.8.12";var Vt={version:Ut};var Wt="repeat";function Yt(m){return {type:"pause",duration:m}}var Ht="__game_layer__";var fe={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var re={};var Kt={};b$1(Kt,{createExportableElement:()=>oe});var gt;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(gt||={});function oe(m){try{if(typeof m>"u")return m;let e=JSON.stringify(m);return JSON.parse(e)}catch(e){throw gt.error("Error creating exportable element",m,e),new PixiError("not_json_serializable","Error creating exportable element")}}var ge=typeof window<"u"&&typeof document<"u",ne=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Vt.version}`],ae=31,_e="background:#2f90da;color:#fff;font-weight:bold;",ve="background:#c832bb;color:#fff;font-weight:bold;",Se="background:transparent;font-weight:bold;",kt=` v${Vt.version}`;function le(){if(!ge)return;let m=[],e=[];for(let i=0;i<ne.length;i++){let s=ne[i],r=s.endsWith(kt),n=r?s.slice(0,-kt.length):s,o=n.slice(0,ae),h=n.slice(ae),d=r?"%c%s%c%s%c%s":"%c%s%c%s";m.push(d),e.push(_e,o,ve,h),r&&e.push(Se,kt);}console.info(m.join(`
1
+ import {f as f$1,b as b$1,g,e,d,h,i}from'./chunk-K7JIC2F2.mjs';import*as nt from'./canvas.mjs';export*from'./canvas.mjs';import*as $t from'./characters.mjs';export*from'./characters.mjs';import {PixiError,GameUnifier}from'./core.mjs';export*from'./core.mjs';import*as et from'./history.mjs';export*from'./history.mjs';import*as L from'./narration.mjs';export*from'./narration.mjs';import*as pt from'./sound.mjs';export*from'./sound.mjs';import*as G from'./storage.mjs';export*from'./storage.mjs';import {motion}from'./motion.mjs';var de=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Qt=new Set,jt=typeof process=="object"&&process?process:{},Zt=(m,e,i,s)=>{typeof jt.emitWarning=="function"?jt.emitWarning(m,e,i,s):console.error(`[${i}] ${e}: ${m}`);},Nt=globalThis.AbortController,Bt=globalThis.AbortSignal;if(typeof Nt>"u"){Bt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new Bt;abort(i){if(!this.signal.aborted){this.signal.reason=i,this.signal.aborted=true;for(let s of this.signal._onabort)s(i);this.signal.onabort?.(i);}}};let m=jt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{m&&(m=false,Zt("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var pe=m=>!Qt.has(m);var at=m=>m&&m===Math.floor(m)&&m>0&&isFinite(m),te=m=>at(m)?m<=Math.pow(2,8)?Uint8Array:m<=Math.pow(2,16)?Uint16Array:m<=Math.pow(2,32)?Uint32Array:m<=Number.MAX_SAFE_INTEGER?Dt:null:null,Dt=class extends Array{constructor(m){super(m),this.fill(0);}},it,St,ue=(it=class{heap;length;static create(e){let i=te(e);if(!i)return [];g(it,St,true);let s=new it(e,i);return g(it,St,false),s}constructor(e$1,i){if(!e(it,St))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(e$1),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},St=new WeakMap,f$1(it,St,false),it),Xt,Jt,K,M,q,ut,$,yt,xt,B,O,X,T,b,f,P,z,N,R,J,D,Q,Z,V,W,tt,dt,j,Et,l,Gt,ft,ot,Tt,Y,ie,mt,bt,Ot,lt,ht,It,Lt,Ct,E,Mt,At,ct,zt,wt,ee=(wt=class{constructor(e$1){f$1(this,l);f$1(this,K);f$1(this,M);f$1(this,q);f$1(this,ut);f$1(this,$);f$1(this,yt);f$1(this,xt);f$1(this,B);d(this,"ttl");d(this,"ttlResolution");d(this,"ttlAutopurge");d(this,"updateAgeOnGet");d(this,"updateAgeOnHas");d(this,"allowStale");d(this,"noDisposeOnSet");d(this,"noUpdateTTL");d(this,"maxEntrySize");d(this,"sizeCalculation");d(this,"noDeleteOnFetchRejection");d(this,"noDeleteOnStaleGet");d(this,"allowStaleOnFetchAbort");d(this,"allowStaleOnFetchRejection");d(this,"ignoreFetchAbort");f$1(this,O);f$1(this,X);f$1(this,T);f$1(this,b);f$1(this,f);f$1(this,P);f$1(this,z);f$1(this,N);f$1(this,R);f$1(this,J);f$1(this,D);f$1(this,Q);f$1(this,Z);f$1(this,V);f$1(this,W);f$1(this,tt);f$1(this,dt);f$1(this,j);f$1(this,Et);f$1(this,ft,()=>{});f$1(this,ot,()=>{});f$1(this,Tt,()=>{});f$1(this,Y,()=>false);f$1(this,mt,e=>{});f$1(this,bt,(e,i,s)=>{});f$1(this,Ot,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});d(this,Xt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:h$1,allowStale:d$1,dispose:v,onInsert:U,disposeAfter:S,noDisposeOnSet:rt,noUpdateTTL:I,maxSize:k=0,maxEntrySize:w=0,sizeCalculation:y,fetchMethod:a,memoMethod:x,noDeleteOnFetchRejection:A,noDeleteOnStaleGet:u,allowStaleOnFetchRejection:g$1,allowStaleOnFetchAbort:F,ignoreFetchAbort:H,perf:_t}=e$1;if(_t!==void 0&&typeof _t?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(g(this,B,_t??de),i!==0&&!at(i))throw new TypeError("max option must be a nonnegative integer");let vt=i?te(i):Array;if(!vt)throw new Error("invalid max value: "+i);if(g(this,K,i),g(this,M,k),this.maxEntrySize=w||e(this,M),this.sizeCalculation=y,this.sizeCalculation){if(!e(this,M)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(x!==void 0&&typeof x!="function")throw new TypeError("memoMethod must be a function if defined");if(g(this,xt,x),a!==void 0&&typeof a!="function")throw new TypeError("fetchMethod must be a function if specified");if(g(this,yt,a),g(this,dt,!!a),g(this,T,new Map),g(this,b,new Array(i).fill(void 0)),g(this,f,new Array(i).fill(void 0)),g(this,P,new vt(i)),g(this,z,new vt(i)),g(this,N,0),g(this,R,0),g(this,J,ue.create(i)),g(this,O,0),g(this,X,0),typeof v=="function"&&g(this,q,v),typeof U=="function"&&g(this,ut,U),typeof S=="function"?(g(this,$,S),g(this,D,[])):(g(this,$,void 0),g(this,D,void 0)),g(this,tt,!!e(this,q)),g(this,Et,!!e(this,ut)),g(this,j,!!e(this,$)),this.noDisposeOnSet=!!rt,this.noUpdateTTL=!!I,this.noDeleteOnFetchRejection=!!A,this.allowStaleOnFetchRejection=!!g$1,this.allowStaleOnFetchAbort=!!F,this.ignoreFetchAbort=!!H,this.maxEntrySize!==0){if(e(this,M)!==0&&!at(e(this,M)))throw new TypeError("maxSize must be a positive integer if specified");if(!at(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,l,ie).call(this);}if(this.allowStale=!!d$1,this.noDeleteOnStaleGet=!!u,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h$1,this.ttlResolution=at(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!at(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,l,Gt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,M)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,M)){let Pt="LRU_CACHE_UNBOUNDED";pe(Pt)&&(Qt.add(Pt),Zt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Pt,wt));}}get perf(){return e(this,B)}static unsafeExposeInternals(e$1){return {starts:e(e$1,Z),ttls:e(e$1,V),autopurgeTimers:e(e$1,W),sizes:e(e$1,Q),keyMap:e(e$1,T),keyList:e(e$1,b),valList:e(e$1,f),next:e(e$1,P),prev:e(e$1,z),get head(){return e(e$1,N)},get tail(){return e(e$1,R)},free:e(e$1,J),isBackgroundFetch:i=>{var s;return h(s=e$1,l,E).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return h(o=e$1,l,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return h(s=e$1,l,At).call(s,i)},indexes:i=>{var s;return h(s=e$1,l,lt).call(s,i)},rindexes:i=>{var s;return h(s=e$1,l,ht).call(s,i)},isStale:i=>{var s;return e(s=e$1,Y).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,M)}get calculatedSize(){return e(this,X)}get size(){return e(this,O)}get fetchMethod(){return e(this,yt)}get memoMethod(){return e(this,xt)}get dispose(){return e(this,q)}get onInsert(){return e(this,ut)}get disposeAfter(){return e(this,$)}getRemainingTTL(e$1){return e(this,T).has(e$1)?1/0:0}*entries(){for(let e$1 of h(this,l,lt).call(this))e(this,f)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield [e(this,b)[e$1],e(this,f)[e$1]]);}*rentries(){for(let e$1 of h(this,l,ht).call(this))e(this,f)[e$1]!==void 0&&e(this,b)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield [e(this,b)[e$1],e(this,f)[e$1]]);}*keys(){for(let e$1 of h(this,l,lt).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield i);}}*rkeys(){for(let e$1 of h(this,l,ht).call(this)){let i=e(this,b)[e$1];i!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield i);}}*values(){for(let e$1 of h(this,l,lt).call(this))e(this,f)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield e(this,f)[e$1]);}*rvalues(){for(let e$1 of h(this,l,ht).call(this))e(this,f)[e$1]!==void 0&&!h(this,l,E).call(this,e(this,f)[e$1])&&(yield e(this,f)[e$1]);}[(Jt=Symbol.iterator,Xt=Symbol.toStringTag,Jt)](){return this.entries()}find(e$1,i={}){for(let s of h(this,l,lt).call(this)){let r=e(this,f)[s],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e$1(n,e(this,b)[s],this))return this.get(e(this,b)[s],i)}}forEach(e$1,i=this){for(let s of h(this,l,lt).call(this)){let r=e(this,f)[s],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}rforEach(e$1,i=this){for(let s of h(this,l,ht).call(this)){let r=e(this,f)[s],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e$1.call(i,n,e(this,b)[s],this);}}purgeStale(){let e$1=false;for(let i of h(this,l,ht).call(this,{allowStale:true}))e(this,Y).call(this,i)&&(h(this,l,ct).call(this,e(this,b)[i],"expire"),e$1=true);return e$1}info(e$1){let i=e(this,T).get(e$1);if(i===void 0)return;let s=e(this,f)[i],r=h(this,l,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(e(this,V)&&e(this,Z)){let o=e(this,V)[i],h=e(this,Z)[i];if(o&&h){let d=o-(e(this,B).now()-h);n.ttl=d,n.start=Date.now();}}return e(this,Q)&&(n.size=e(this,Q)[i]),n}dump(){let e$1=[];for(let i of h(this,l,lt).call(this,{allowStale:true})){let s=e(this,b)[i],r=e(this,f)[i],n=h(this,l,E).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(e(this,V)&&e(this,Z)){o.ttl=e(this,V)[i];let h=e(this,B).now()-e(this,Z)[i];o.start=Math.floor(Date.now()-h);}e(this,Q)&&(o.size=e(this,Q)[i]),e$1.unshift([s,o]);}return e$1}load(e$1){this.clear();for(let[i,s]of e$1){if(s.start){let r=Date.now()-s.start;s.start=e(this,B).now()-r;}this.set(i,s.value,s);}}set(e$1,i$1,s={}){var rt,I,k,w;if(i$1===void 0)return this.delete(e$1),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h$1=this.sizeCalculation,status:d}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,U=e(this,Ot).call(this,e$1,i$1,s.size||0,h$1);if(this.maxEntrySize&&U>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),h(this,l,ct).call(this,e$1,"set"),this;let S=e(this,O)===0?void 0:e(this,T).get(e$1);if(S===void 0)S=e(this,O)===0?e(this,R):e(this,J).length!==0?e(this,J).pop():e(this,O)===e(this,K)?h(this,l,Lt).call(this,false):e(this,O),e(this,b)[S]=e$1,e(this,f)[S]=i$1,e(this,T).set(e$1,S),e(this,P)[e(this,R)]=S,e(this,z)[S]=e(this,R),g(this,R,S),i(this,O)._++,e(this,bt).call(this,S,U,d),d&&(d.set="add"),v=false,e(this,Et)&&((rt=e(this,ut))==null||rt.call(this,i$1,e$1,"add"));else {h(this,l,At).call(this,S);let y=e(this,f)[S];if(i$1!==y){if(e(this,dt)&&h(this,l,E).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:a}=y;a!==void 0&&!o&&(e(this,tt)&&((I=e(this,q))==null||I.call(this,a,e$1,"set")),e(this,j)&&e(this,D)?.push([a,e$1,"set"]));}else o||(e(this,tt)&&((k=e(this,q))==null||k.call(this,y,e$1,"set")),e(this,j)&&e(this,D)?.push([y,e$1,"set"]));if(e(this,mt).call(this,S),e(this,bt).call(this,S,U,d),e(this,f)[S]=i$1,d){d.set="replace";let a=y&&h(this,l,E).call(this,y)?y.__staleWhileFetching:y;a!==void 0&&(d.oldValue=a);}}else d&&(d.set="update");e(this,Et)&&this.onInsert?.(i$1,e$1,i$1===y?"update":"replace");}if(r!==0&&!e(this,V)&&h(this,l,Gt).call(this),e(this,V)&&(v||e(this,Tt).call(this,S,r,n),d&&e(this,ot).call(this,d,S)),!o&&e(this,j)&&e(this,D)){let y=e(this,D),a;for(;a=y?.shift();)(w=e(this,$))==null||w.call(this,...a);}return this}pop(){var e$1;try{for(;e(this,O);){let i=e(this,f)[e(this,N)];if(h(this,l,Lt).call(this,!0),h(this,l,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,j)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(e$1=e(this,$))==null||e$1.call(this,...s);}}}has(e$1,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=e(this,T).get(e$1);if(n!==void 0){let o=e(this,f)[n];if(h(this,l,E).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(e(this,Y).call(this,n))r&&(r.has="stale",e(this,ot).call(this,r,n));else return s&&e(this,ft).call(this,n),r&&(r.has="hit",e(this,ot).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e$1,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,T).get(e$1);if(r===void 0||!s&&e(this,Y).call(this,r))return;let n=e(this,f)[r];return h(this,l,E).call(this,n)?n.__staleWhileFetching:n}async fetch(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:h$1=this.noDisposeOnSet,size:d=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:U=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:rt=this.allowStaleOnFetchRejection,ignoreFetchAbort:I=this.ignoreFetchAbort,allowStaleOnFetchAbort:k=this.allowStaleOnFetchAbort,context:w,forceRefresh:y=false,status:a,signal:x}=i;if(!e(this,dt))return a&&(a.fetch="get"),this.get(e$1,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:a});let A={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:h$1,size:d,sizeCalculation:v,noUpdateTTL:U,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:rt,allowStaleOnFetchAbort:k,ignoreFetchAbort:I,status:a,signal:x},u=e(this,T).get(e$1);if(u===void 0){a&&(a.fetch="miss");let g=h(this,l,Ct).call(this,e$1,u,A,w);return g.__returned=g}else {let g=e(this,f)[u];if(h(this,l,E).call(this,g)){let vt=s&&g.__staleWhileFetching!==void 0;return a&&(a.fetch="inflight",vt&&(a.returnedStale=true)),vt?g.__staleWhileFetching:g.__returned=g}let F=e(this,Y).call(this,u);if(!y&&!F)return a&&(a.fetch="hit"),h(this,l,At).call(this,u),r&&e(this,ft).call(this,u),a&&e(this,ot).call(this,a,u),g;let H=h(this,l,Ct).call(this,e$1,u,A,w),_t=H.__staleWhileFetching!==void 0&&s;return a&&(a.fetch=F?"stale":"refresh",_t&&F&&(a.returnedStale=true)),_t?H.__staleWhileFetching:H.__returned=H}}async forceFetch(e,i={}){let s=await this.fetch(e,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(e$1,i={}){let s=e(this,xt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,h=this.get(e$1,o);if(!n&&h!==void 0)return h;let d=s(e$1,h,{options:o,context:r});return this.set(e$1,d,o),d}get(e$1,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,h$1=e(this,T).get(e$1);if(h$1!==void 0){let d=e(this,f)[h$1],v=h(this,l,E).call(this,d);return o&&e(this,ot).call(this,o,h$1),e(this,Y).call(this,h$1)?(o&&(o.get="stale"),v?(o&&s&&d.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?d.__staleWhileFetching:void 0):(n||h(this,l,ct).call(this,e$1,"expire"),o&&s&&(o.returnedStale=true),s?d:void 0)):(o&&(o.get="hit"),v?d.__staleWhileFetching:(h(this,l,At).call(this,h$1),r&&e(this,ft).call(this,h$1),d))}else o&&(o.get="miss");}delete(e){return h(this,l,ct).call(this,e,"delete")}clear(){return h(this,l,zt).call(this,"delete")}},K=new WeakMap,M=new WeakMap,q=new WeakMap,ut=new WeakMap,$=new WeakMap,yt=new WeakMap,xt=new WeakMap,B=new WeakMap,O=new WeakMap,X=new WeakMap,T=new WeakMap,b=new WeakMap,f=new WeakMap,P=new WeakMap,z=new WeakMap,N=new WeakMap,R=new WeakMap,J=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,V=new WeakMap,W=new WeakMap,tt=new WeakMap,dt=new WeakMap,j=new WeakMap,Et=new WeakMap,l=new WeakSet,Gt=function(){let e$1=new Dt(e(this,K)),i=new Dt(e(this,K));g(this,V,e$1),g(this,Z,i);let s=this.ttlAutopurge?new Array(e(this,K)):void 0;g(this,W,s),g(this,Tt,(h,d,v=e(this,B).now())=>{i[h]=d!==0?v:0,e$1[h]=d,r(h,d);}),g(this,ft,h=>{i[h]=e$1[h]!==0?e(this,B).now():0,r(h,e$1[h]);});let r=this.ttlAutopurge?(h$1,d)=>{if(s?.[h$1]&&(clearTimeout(s[h$1]),s[h$1]=void 0),d&&d!==0&&s){let v=setTimeout(()=>{e(this,Y).call(this,h$1)&&h(this,l,ct).call(this,e(this,b)[h$1],"expire");},d+1);v.unref&&v.unref(),s[h$1]=v;}}:()=>{};g(this,ot,(h,d)=>{if(e$1[d]){let v=e$1[d],U=i[d];if(!v||!U)return;h.ttl=v,h.start=U,h.now=n||o();let S=h.now-U;h.remainingTTL=v-S;}});let n=0,o=()=>{let h=e(this,B).now();if(this.ttlResolution>0){n=h;let d=setTimeout(()=>n=0,this.ttlResolution);d.unref&&d.unref();}return h};this.getRemainingTTL=h=>{let d=e(this,T).get(h);if(d===void 0)return 0;let v=e$1[d],U=i[d];if(!v||!U)return 1/0;let S=(n||o())-U;return v-S},g(this,Y,h=>{let d=i[h],v=e$1[h];return !!v&&!!d&&(n||o())-d>v});},ft=new WeakMap,ot=new WeakMap,Tt=new WeakMap,Y=new WeakMap,ie=function(){let e$1=new Dt(e(this,K));g(this,X,0),g(this,Q,e$1),g(this,mt,i=>{g(this,X,e(this,X)-e$1[i]),e$1[i]=0;}),g(this,Ot,(i,s,r,n)=>{if(h(this,l,E).call(this,s))return 0;if(!at(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!at(r))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return r}),g(this,bt,(i,s,r)=>{if(e$1[i]=s,e(this,M)){let n=e(this,M)-e$1[i];for(;e(this,X)>n;)h(this,l,Lt).call(this,true);}g(this,X,e(this,X)+e$1[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,X));});},mt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,lt=function*({allowStale:e$1=this.allowStale}={}){if(e(this,O))for(let i=e(this,R);!(!h(this,l,It).call(this,i)||((e$1||!e(this,Y).call(this,i))&&(yield i),i===e(this,N)));)i=e(this,z)[i];},ht=function*({allowStale:e$1=this.allowStale}={}){if(e(this,O))for(let i=e(this,N);!(!h(this,l,It).call(this,i)||((e$1||!e(this,Y).call(this,i))&&(yield i),i===e(this,R)));)i=e(this,P)[i];},It=function(e$1){return e$1!==void 0&&e(this,T).get(e(this,b)[e$1])===e$1},Lt=function(e$1){var n;let i$1=e(this,N),s=e(this,b)[i$1],r=e(this,f)[i$1];return e(this,dt)&&h(this,l,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,tt)||e(this,j))&&(e(this,tt)&&((n=e(this,q))==null||n.call(this,r,s,"evict")),e(this,j)&&e(this,D)?.push([r,s,"evict"])),e(this,mt).call(this,i$1),e(this,W)?.[i$1]&&(clearTimeout(e(this,W)[i$1]),e(this,W)[i$1]=void 0),e$1&&(e(this,b)[i$1]=void 0,e(this,f)[i$1]=void 0,e(this,J).push(i$1)),e(this,O)===1?(g(this,N,g(this,R,0)),e(this,J).length=0):g(this,N,e(this,P)[i$1]),e(this,T).delete(s),i(this,O)._--,i$1},Ct=function(e$1,i,s,r){let n=i===void 0?void 0:e(this,f)[i];if(h(this,l,E).call(this,n))return n;let o=new Nt,{signal:h$1}=s;h$1?.addEventListener("abort",()=>o.abort(h$1.reason),{signal:o.signal});let d={signal:o.signal,options:s,context:r},v=(w,y=false)=>{let{aborted:a}=o.signal,x=s.ignoreFetchAbort&&w!==void 0,A=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(a&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,x&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),a&&!x&&!y)return S(o.signal.reason,A);let u=I,g=e(this,f)[i];return (g===I||x&&y&&g===void 0)&&(w===void 0?u.__staleWhileFetching!==void 0?e(this,f)[i]=u.__staleWhileFetching:h(this,l,ct).call(this,e$1,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e$1,w,d.options))),w},U=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),S(w,false)),S=(w,y)=>{let{aborted:a}=o.signal,x=a&&s.allowStaleOnFetchAbort,A=x||s.allowStaleOnFetchRejection,u=A||s.noDeleteOnFetchRejection,g=I;if(e(this,f)[i]===I&&(!u||!y&&g.__staleWhileFetching===void 0?h(this,l,ct).call(this,e$1,"fetch"):x||(e(this,f)[i]=g.__staleWhileFetching)),A)return s.status&&g.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),g.__staleWhileFetching;if(g.__returned===g)throw w},rt=(w,y)=>{var x;let a=(x=e(this,yt))==null?void 0:x.call(this,e$1,n,d);a&&a instanceof Promise&&a.then(A=>w(A===void 0?void 0:A),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=A=>v(A,true)));});};s.status&&(s.status.fetchDispatched=true);let I=new Promise(rt).then(v,U),k=Object.assign(I,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e$1,k,{...d.options,status:void 0}),i=e(this,T).get(e$1)):e(this,f)[i]=k,k},E=function(e$1){if(!e(this,dt))return false;let i=e$1;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},Mt=function(e$1,i){e(this,z)[i]=e$1,e(this,P)[e$1]=i;},At=function(e$1){e$1!==e(this,R)&&(e$1===e(this,N)?g(this,N,e(this,P)[e$1]):h(this,l,Mt).call(this,e(this,z)[e$1],e(this,P)[e$1]),h(this,l,Mt).call(this,e(this,R),e$1),g(this,R,e$1));},ct=function(e$1,i$1){var r,n;let s=false;if(e(this,O)!==0){let o=e(this,T).get(e$1);if(o!==void 0)if(e(this,W)?.[o]&&(clearTimeout(e(this,W)?.[o]),e(this,W)[o]=void 0),s=true,e(this,O)===1)h(this,l,zt).call(this,i$1);else {e(this,mt).call(this,o);let h$1=e(this,f)[o];if(h(this,l,E).call(this,h$1)?h$1.__abortController.abort(new Error("deleted")):(e(this,tt)||e(this,j))&&(e(this,tt)&&((r=e(this,q))==null||r.call(this,h$1,e$1,i$1)),e(this,j)&&e(this,D)?.push([h$1,e$1,i$1])),e(this,T).delete(e$1),e(this,b)[o]=void 0,e(this,f)[o]=void 0,o===e(this,R))g(this,R,e(this,z)[o]);else if(o===e(this,N))g(this,N,e(this,P)[o]);else {let d=e(this,z)[o];e(this,P)[d]=e(this,P)[o];let v=e(this,P)[o];e(this,z)[v]=e(this,z)[o];}i(this,O)._--,e(this,J).push(o);}}if(e(this,j)&&e(this,D)?.length){let o=e(this,D),h;for(;h=o?.shift();)(n=e(this,$))==null||n.call(this,...h);}return s},zt=function(e$1){var i,s;for(let r of h(this,l,ht).call(this,{allowStale:true})){let n=e(this,f)[r];if(h(this,l,E).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=e(this,b)[r];e(this,tt)&&((i=e(this,q))==null||i.call(this,n,o,e$1)),e(this,j)&&e(this,D)?.push([n,o,e$1]);}}if(e(this,T).clear(),e(this,f).fill(void 0),e(this,b).fill(void 0),e(this,V)&&e(this,Z)){e(this,V).fill(0),e(this,Z).fill(0);for(let r of e(this,W)??[])r!==void 0&&clearTimeout(r);e(this,W)?.fill(void 0);}if(e(this,Q)&&e(this,Q).fill(0),g(this,N,0),g(this,R,0),e(this,J).length=0,g(this,X,0),g(this,O,0),e(this,j)&&e(this,D)){let r=e(this,D),n;for(;n=r?.shift();)(s=e(this,$))==null||s.call(this,...n);}},wt);var Ft=class{cache;map=new Map;constructor(e){this.cache=new ee({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let i=this.map.delete(e);return i&&this.cache.delete(e),i}get forEach(){return this.map.forEach}get(e){let i=this.cache.get(e);return i||this.map.get(e)}has(e){return this.map.has(e)}set(e,i){return this.map.set(e,i),this.cache.set(e,i),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var Ut="1.8.13";var Vt={version:Ut};var Wt="repeat";function Yt(m){return {type:"pause",duration:m}}var Ht="__game_layer__";var fe={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var re={};var Kt={};b$1(Kt,{createExportableElement:()=>oe});var gt;(r=>(r.log=(n,...o)=>console.log(`[Pixi\u2019VN] ${n}`,...o),r.warn=(n,...o)=>console.warn(`[Pixi\u2019VN] ${n}`,...o),r.error=(n,...o)=>console.error(`[Pixi\u2019VN] ${n}`,...o),r.info=(n,...o)=>console.info(`[Pixi\u2019VN] ${n}`,...o)))(gt||={});function oe(m){try{if(typeof m>"u")return m;let e=JSON.stringify(m);return JSON.parse(e)}catch(e){throw gt.error("Error creating exportable element",m,e),new PixiError("not_json_serializable","Error creating exportable element")}}var ge=typeof window<"u"&&typeof document<"u",ne=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Vt.version}`],ae=31,_e="background:#2f90da;color:#fff;font-weight:bold;",ve="background:#c832bb;color:#fff;font-weight:bold;",Se="background:transparent;font-weight:bold;",kt=` v${Vt.version}`;function le(){if(!ge)return;let m=[],e=[];for(let i=0;i<ne.length;i++){let s=ne[i],r=s.endsWith(kt),n=r?s.slice(0,-kt.length):s,o=n.slice(0,ae),h=n.slice(ae),d=r?"%c%s%c%s%c%s":"%c%s%c%s";m.push(d),e.push(_e,o,ve,h),r&&e.push(Se,kt);}console.info(m.join(`
2
2
  `),...e);}function qt(){let m=window.location.pathname+window.location.hash;return m.includes("#")&&(m=m.split("#")[1]),m}le();var he;(y=>{async function m(a,x,A){if(GameUnifier.init({navigate:x?.navigate,getCurrentGameStepState:()=>{let u={};try{u=nt.canvas.export();}catch{}return {path:qt(),storage:G.storage.export(),canvas:u,sound:pt.sound.export(),labelIndex:L.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:L.narration.openedLabels}},restoreGameStepState:async(u,g)=>{et.HistoryManagerStatic._originalStepData=u,L.NarrationManagerStatic.openedLabels=u.openedLabels,G.storage.restore(u.storage);try{await nt.canvas.restore(u.canvas),await pt.sound.restore(u.sound);}catch(F){gt.error("Error restoring game step state:",F);}await g(u.path);},getStepCounter:()=>L.narration.stepCounter,setStepCounter:u=>{L.NarrationManagerStatic._stepCounter=u;},getOpenedLabels:()=>L.narration.openedLabels.length,addHistoryItem:(u,g)=>et.stepHistory.add(u,g),getCharacter:u=>$t.RegisteredCharacters.get(u),processNavigationRequests:(u,g)=>{let F=u,H=Promise.resolve();return u>0?(F--,H=L.narration.continue(g)):u<0&&(F=0,H=et.stepHistory.back(g,{steps:u*-1})),{newValue:F,result:H}},animate:(u,g,F,H)=>motion.animate(u,g,F,H),getVariable:(u,g)=>G.StorageRegistry.getVariable(u,g),setVariable:(u,g,F)=>G.StorageRegistry.setVariable(u,g,F),removeVariable:(u,g)=>G.StorageRegistry.removeVariable(u,g),getFlag:u=>G.storage.getFlag(u),setFlag:(u,g)=>G.storage.setFlag(u,g),onLabelClosing:u=>G.StorageRegistry.clearOldTempVariables(u)}),!a||!x){gt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await nt.canvas.init(a,x,A)}y.init=m;function e(){G.storage.clear();try{nt.canvas.clear();}catch{}pt.sound.clear(),L.narration.clear(),et.stepHistory.clear();}y.clear=e;function i(){let a={};try{a=nt.canvas.export();}catch{}return {pixivn_version:Ut,stepData:L.narration.export(),storageData:G.storage.export(),canvasData:a,soundData:pt.sound.export(),historyData:et.stepHistory.export(),path:qt()}}y.exportGameState=i;async function s(a,x){et.stepHistory.restore(a.historyData);let A=et.stepHistory.lastKey;if(typeof A=="number"){let u=et.stepHistory.stepsInfoMap.get(A)||null;await L.narration.restore(a.stepData,u);}G.storage.restore(a.storageData);try{await nt.canvas.restore(a.canvasData),await pt.sound.restore(a.soundData);}catch{}x?await x(a.path):await GameUnifier.navigate(a.path);}y.restoreGameState=s;async function r(a,x){return y.clear(),await L.narration.call(a,x)}y.start=r;function n(a){return JSON.parse(a)}y.jsonToGameState=n;function o(a){GameUnifier.onEnd=a;}y.onEnd=o;function h(a){return gt.warn("Game.onError is deprecated. Use Game.addOnError / Game.removeOnError to register multiple handlers."),GameUnifier.addOnError((x,A)=>a("step",x,A))}y.onError=h;function d(a){return GameUnifier.addOnError(a)}y.addOnError=d;function v(a){return GameUnifier.removeOnError(a)}y.removeOnError=v;function U(a){L.NarrationManagerStatic.onStepStart=a;}y.onStepStart=U;function S(a){L.NarrationManagerStatic.onLoadingLabel=a;}y.onLoadingLabel=S;function rt(a){L.NarrationManagerStatic.onStepEnd=a;}y.onStepEnd=rt;function I(a){GameUnifier.navigate=a;}y.onNavigate=I;function k(a){return GameUnifier.addOnPreContinue(a)}y.addOnPreContinue=k;function w(a){return GameUnifier.removeOnPreContinue(a)}y.removeOnPreContinue=w;})(he||={});var $e={characterUtils:$t,canvasUtils:nt,narrationUtils:L,soundUtils:pt,CANVAS_APP_GAME_LAYER_ALIAS:Ht,Pause:Yt,Repeat:Wt,PIXIVN_VERSION:Ut,...Kt,...re,canvas:nt.canvas,narration:L.narration,sound:pt.sound,storage:G.storage,history:et.stepHistory,Game:he,GameUnifier:GameUnifier};export{Ht as CANVAS_APP_GAME_LAYER_ALIAS,Ft as CachedMap,he as Game,Ut as PIXIVN_VERSION,Yt as Pause,Wt as Repeat,fe as SYSTEM_RESERVED_STORAGE_KEYS,oe as createExportableElement,$e as default};
@@ -1,2 +1,2 @@
1
- 'use strict';var core=require('./core.cjs');var St=Object.create;var We=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Qe=o=>{throw TypeError(o)};var _t=(o,e,t)=>e in o?We(o,e,{enumerable:true,configurable:true,writable:true,value:t}):o[e]=t;var Be=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Ze=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var Tt=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(o,i)&&i!==t&&We(o,i,{get:()=>e[i],enumerable:!(n=yt(e,i))||n.enumerable});return o};var Et=(o,e,t)=>(t=o!=null?St(gt(o)):{},Tt(We(t,"default",{value:o,enumerable:true}),o));var z=(o,e,t)=>_t(o,typeof e!="symbol"?e+"":e,t),je=(o,e,t)=>e.has(o)||Qe("Cannot "+t);var r=(o,e,t)=>(je(o,e,"read from private field"),t?t.call(o):e.get(o)),v=(o,e,t)=>e.has(o)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,t),y=(o,e,t,n)=>(je(o,e,"write to private field"),e.set(o,t),t),f=(o,e,t)=>(je(o,e,"access private method"),t);var Ue=(o,e,t,n)=>({set _(i){y(o,e,i);},get _(){return r(o,e,n)}});var ct=Ze((ze,pt)=>{(function(o,e){typeof ze=="object"?pt.exports=ze=e():typeof define=="function"&&define.amd?define([],e):o.CryptoJS=e();})(ze,function(){var o=o||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function l(){}return function(d){var C;return l.prototype=d,C=new l,l.prototype=null,C}})(),s={},h=s.lib={},p=h.Base=(function(){return {extend:function(l){var d=a(this);return l&&d.mixIn(l),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),S=h.WordArray=p.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||L).stringify(this)},concat:function(l){var d=this.words,C=l.words,E=this.sigBytes,O=l.sigBytes;if(this.clamp(),E%4)for(var P=0;P<O;P++){var oe=C[P>>>2]>>>24-P%4*8&255;d[E+P>>>2]|=oe<<24-(E+P)%4*8;}else for(var G=0;G<O;G+=4)d[E+G>>>2]=C[G>>>2];return this.sigBytes+=O,this},clamp:function(){var l=this.words,d=this.sigBytes;l[d>>>2]&=4294967295<<32-d%4*8,l.length=e.ceil(d/4);},clone:function(){var l=p.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],C=0;C<l;C+=4)d.push(i());return new S.init(d,l)}}),u=s.enc={},L=u.Hex={stringify:function(l){for(var d=l.words,C=l.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push((P>>>4).toString(16)),E.push((P&15).toString(16));}return E.join("")},parse:function(l){for(var d=l.length,C=[],E=0;E<d;E+=2)C[E>>>3]|=parseInt(l.substr(E,2),16)<<24-E%8*4;return new S.init(C,d/2)}},M=u.Latin1={stringify:function(l){for(var d=l.words,C=l.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push(String.fromCharCode(P));}return E.join("")},parse:function(l){for(var d=l.length,C=[],E=0;E<d;E++)C[E>>>2]|=(l.charCodeAt(E)&255)<<24-E%4*8;return new S.init(C,d)}},N=u.Utf8={stringify:function(l){try{return decodeURIComponent(escape(M.stringify(l)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(l){return M.parse(unescape(encodeURIComponent(l)))}},D=h.BufferedBlockAlgorithm=p.extend({reset:function(){this._data=new S.init,this._nDataBytes=0;},_append:function(l){typeof l=="string"&&(l=N.parse(l)),this._data.concat(l),this._nDataBytes+=l.sigBytes;},_process:function(l){var d,C=this._data,E=C.words,O=C.sigBytes,P=this.blockSize,oe=P*4,G=O/oe;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var J=G*P,Le=e.min(J*4,O);if(J){for(var Ke=0;Ke<J;Ke+=P)this._doProcessBlock(E,Ke);d=E.splice(0,J),C.sigBytes-=Le;}return new S.init(d,Le)},clone:function(){var l=p.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});h.Hasher=D.extend({cfg:p.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){D.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(l){return function(d,C){return new l.init(C).finalize(d)}},_createHmacHelper:function(l){return function(d,C){return new T.HMAC.init(l,C).finalize(d)}}});var T=s.algo={};return s})(Math);return o});});var dt=Ze((He,ut)=>{(function(o,e){typeof He=="object"?ut.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(o.CryptoJS);})(He,function(o){return (function(){var e=o,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,s=[],h=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(p,S){for(var u=this._hash.words,L=u[0],M=u[1],N=u[2],D=u[3],w=u[4],T=0;T<80;T++){if(T<16)s[T]=p[S+T]|0;else {var l=s[T-3]^s[T-8]^s[T-14]^s[T-16];s[T]=l<<1|l>>>31;}var d=(L<<5|L>>>27)+w+s[T];T<20?d+=(M&N|~M&D)+1518500249:T<40?d+=(M^N^D)+1859775393:T<60?d+=(M&N|M&D|N&D)-1894007588:d+=(M^N^D)-899497514,w=D,D=N,N=M<<30|M>>>2,M=L,L=d;}u[0]=u[0]+L|0,u[1]=u[1]+M|0,u[2]=u[2]+N|0,u[3]=u[3]+D|0,u[4]=u[4]+w|0;},_doFinalize:function(){var p=this._data,S=p.words,u=this._nDataBytes*8,L=p.sigBytes*8;return S[L>>>5]|=128<<24-L%32,S[(L+64>>>9<<4)+14]=Math.floor(u/4294967296),S[(L+64>>>9<<4)+15]=u,p.sigBytes=S.length*4,this._process(),this._hash},clone:function(){var p=i.clone.call(this);return p._hash=this._hash.clone(),p}});e.SHA1=i._createHelper(h),e.HmacSHA1=i._createHmacHelper(h);})(),o.SHA1});});var R="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(o,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(o,e,t,n):console.error(`[${t}] ${e}: ${o}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let o=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{o&&(o=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=o=>!nt.has(o);var ue=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),at=o=>ue(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(o){super(o),this.fill(0);}},le,_e,Ot=(le=class{heap;length;static create(e){let t=at(e);if(!t)return [];y(le,_e,true);let n=new le(e,t);return y(le,_e,false),n}constructor(e,t){if(!r(le,_e))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},_e=new WeakMap,v(le,_e,false),le),tt,rt,X,B,Q,ye,Z,Te,Ee,ee,Y,te,U,A,_,K,j,H,F,re,V,ne,ie,k,$,ae,Se,W,Ce,c,$e,me,he,Me,q,ot,ge,Ie,Ne,de,fe,qe,Fe,Ve,x,Xe,Ae,be,Je,Oe,st=(Oe=class{constructor(e){v(this,c);v(this,X);v(this,B);v(this,Q);v(this,ye);v(this,Z);v(this,Te);v(this,Ee);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,_);v(this,K);v(this,j);v(this,H);v(this,F);v(this,re);v(this,V);v(this,ne);v(this,ie);v(this,k);v(this,$);v(this,ae);v(this,Se);v(this,W);v(this,Ce);v(this,me,()=>{});v(this,he,()=>{});v(this,Me,()=>{});v(this,q,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Ne,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:s,updateAgeOnHas:h,allowStale:p,dispose:S,onInsert:u,disposeAfter:L,noDisposeOnSet:M,noUpdateTTL:N,maxSize:D=0,maxEntrySize:w=0,sizeCalculation:T,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:P,ignoreFetchAbort:oe,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(y(this,ee,G??Ct),t!==0&&!ue(t))throw new TypeError("max option must be a nonnegative integer");let J=t?at(t):Array;if(!J)throw new Error("invalid max value: "+t);if(y(this,X,t),y(this,B,D),this.maxEntrySize=w||r(this,B),this.sizeCalculation=T,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(y(this,Ee,d),l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(y(this,Te,l),y(this,Se,!!l),y(this,U,new Map),y(this,A,new Array(t).fill(void 0)),y(this,_,new Array(t).fill(void 0)),y(this,K,new J(t)),y(this,j,new J(t)),y(this,H,0),y(this,F,0),y(this,re,Ot.create(t)),y(this,Y,0),y(this,te,0),typeof S=="function"&&y(this,Q,S),typeof u=="function"&&y(this,ye,u),typeof L=="function"?(y(this,Z,L),y(this,V,[])):(y(this,Z,void 0),y(this,V,void 0)),y(this,ae,!!r(this,Q)),y(this,Ce,!!r(this,ye)),y(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!oe,this.maxEntrySize!==0){if(r(this,B)!==0&&!ue(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!ue(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,c,ot).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!h,this.ttlResolution=ue(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!ue(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,c,$e).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let Le="LRU_CACHE_UNBOUNDED";It(Le)&&(nt.add(Le),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,Oe));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,$),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,_),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,F)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,c,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var s;return f(s=e,c,Ve).call(s,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,c,Ae).call(n,t)},indexes:t=>{var n;return f(n=e,c,de).call(n,t)},rindexes:t=>{var n;return f(n=e,c,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,Te)}get memoMethod(){return r(this,Ee)}get dispose(){return r(this,Q)}get onInsert(){return r(this,ye)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,c,de).call(this))r(this,_)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield [r(this,A)[e],r(this,_)[e]]);}*rentries(){for(let e of f(this,c,fe).call(this))r(this,_)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield [r(this,A)[e],r(this,_)[e]]);}*keys(){for(let e of f(this,c,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield t);}}*rkeys(){for(let e of f(this,c,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield t);}}*values(){for(let e of f(this,c,de).call(this))r(this,_)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield r(this,_)[e]);}*rvalues(){for(let e of f(this,c,fe).call(this))r(this,_)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield r(this,_)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,c,de).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,c,de).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,c,fe).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,c,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,c,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,_)[t],i=f(this,c,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let s=r(this,k)[t],h=r(this,ie)[t];if(s&&h){let p=s-(r(this,ee).now()-h);a.ttl=p,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,c,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,_)[t],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let s={value:a};if(r(this,k)&&r(this,ie)){s.ttl=r(this,k)[t];let h=r(this,ee).now()-r(this,ie)[t];s.start=Math.floor(Date.now()-h);}r(this,ne)&&(s.size=r(this,ne)[t]),e.unshift([n,s]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,D,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:p}=n,{noUpdateTTL:S=this.noUpdateTTL}=n,u=r(this,Ne).call(this,e,t,n.size||0,h);if(this.maxEntrySize&&u>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),f(this,c,be).call(this,e,"set"),this;let L=r(this,Y)===0?void 0:r(this,U).get(e);if(L===void 0)L=r(this,Y)===0?r(this,F):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,c,Fe).call(this,false):r(this,Y),r(this,A)[L]=e,r(this,_)[L]=t,r(this,U).set(e,L),r(this,K)[r(this,F)]=L,r(this,j)[L]=r(this,F),y(this,F,L),Ue(this,Y)._++,r(this,Ie).call(this,L,u,p),p&&(p.set="add"),S=false,r(this,Ce)&&((M=r(this,ye))==null||M.call(this,t,e,"add"));else {f(this,c,Ae).call(this,L);let T=r(this,_)[L];if(t!==T){if(r(this,Se)&&f(this,c,x).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=T;l!==void 0&&!s&&(r(this,ae)&&((N=r(this,Q))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,V)?.push([l,e,"set"]));}else s||(r(this,ae)&&((D=r(this,Q))==null||D.call(this,T,e,"set")),r(this,W)&&r(this,V)?.push([T,e,"set"]));if(r(this,ge).call(this,L),r(this,Ie).call(this,L,u,p),r(this,_)[L]=t,p){p.set="replace";let l=T&&f(this,c,x).call(this,T)?T.__staleWhileFetching:T;l!==void 0&&(p.oldValue=l);}}else p&&(p.set="update");r(this,Ce)&&this.onInsert?.(t,e,t===T?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,c,$e).call(this),r(this,k)&&(S||r(this,Me).call(this,L,i,a),p&&r(this,he).call(this,p,L)),!s&&r(this,W)&&r(this,V)){let T=r(this,V),l;for(;l=T?.shift();)(w=r(this,Z))==null||w.call(this,...l);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,_)[r(this,H)];if(f(this,c,Fe).call(this,!0),f(this,c,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,V)){let t=r(this,V),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let s=r(this,_)[a];if(f(this,c,x).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,he).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,he).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,_)[i];return f(this,c,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:p=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:L=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:w,forceRefresh:T=false,status:l,signal:d}=t;if(!r(this,Se))return l&&(l.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let C={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:s,noDisposeOnSet:h,size:p,sizeCalculation:S,noUpdateTTL:u,noDeleteOnFetchRejection:L,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:N,status:l,signal:d},E=r(this,U).get(e);if(E===void 0){l&&(l.fetch="miss");let O=f(this,c,Ve).call(this,e,E,C,w);return O.__returned=O}else {let O=r(this,_)[E];if(f(this,c,x).call(this,O)){let J=n&&O.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",J&&(l.returnedStale=true)),J?O.__staleWhileFetching:O.__returned=O}let P=r(this,q).call(this,E);if(!T&&!P)return l&&(l.fetch="hit"),f(this,c,Ae).call(this,E),i&&r(this,me).call(this,E),l&&r(this,he).call(this,l,E),O;let oe=f(this,c,Ve).call(this,e,E,C,w),G=oe.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=P?"stale":"refresh",G&&P&&(l.returnedStale=true)),G?oe.__staleWhileFetching:oe.__returned=oe}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ee);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...s}=t,h=this.get(e,s);if(!a&&h!==void 0)return h;let p=n(e,h,{options:s,context:i});return this.set(e,p,s),p}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:s}=t,h=r(this,U).get(e);if(h!==void 0){let p=r(this,_)[h],S=f(this,c,x).call(this,p);return s&&r(this,he).call(this,s,h),r(this,q).call(this,h)?(s&&(s.get="stale"),S?(s&&n&&p.__staleWhileFetching!==void 0&&(s.returnedStale=true),n?p.__staleWhileFetching:void 0):(a||f(this,c,be).call(this,e,"expire"),s&&n&&(s.returnedStale=true),n?p:void 0)):(s&&(s.get="hit"),S?p.__staleWhileFetching:(f(this,c,Ae).call(this,h),i&&r(this,me).call(this,h),p))}else s&&(s.get="miss");}delete(e){return f(this,c,be).call(this,e,"delete")}clear(){return f(this,c,Je).call(this,"delete")}},X=new WeakMap,B=new WeakMap,Q=new WeakMap,ye=new WeakMap,Z=new WeakMap,Te=new WeakMap,Ee=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,_=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,F=new WeakMap,re=new WeakMap,V=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,$=new WeakMap,ae=new WeakMap,Se=new WeakMap,W=new WeakMap,Ce=new WeakMap,c=new WeakSet,$e=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));y(this,k,e),y(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;y(this,$,n),y(this,Me,(h,p,S=r(this,ee).now())=>{t[h]=p!==0?S:0,e[h]=p,i(h,p);}),y(this,me,h=>{t[h]=e[h]!==0?r(this,ee).now():0,i(h,e[h]);});let i=this.ttlAutopurge?(h,p)=>{if(n?.[h]&&(clearTimeout(n[h]),n[h]=void 0),p&&p!==0&&n){let S=setTimeout(()=>{r(this,q).call(this,h)&&f(this,c,be).call(this,r(this,A)[h],"expire");},p+1);S.unref&&S.unref(),n[h]=S;}}:()=>{};y(this,he,(h,p)=>{if(e[p]){let S=e[p],u=t[p];if(!S||!u)return;h.ttl=S,h.start=u,h.now=a||s();let L=h.now-u;h.remainingTTL=S-L;}});let a=0,s=()=>{let h=r(this,ee).now();if(this.ttlResolution>0){a=h;let p=setTimeout(()=>a=0,this.ttlResolution);p.unref&&p.unref();}return h};this.getRemainingTTL=h=>{let p=r(this,U).get(h);if(p===void 0)return 0;let S=e[p],u=t[p];if(!S||!u)return 1/0;let L=(a||s())-u;return S-L},y(this,q,h=>{let p=t[h],S=e[h];return !!S&&!!p&&(a||s())-p>S});},me=new WeakMap,he=new WeakMap,Me=new WeakMap,q=new WeakMap,ot=function(){let e=new Ye(r(this,X));y(this,te,0),y(this,ne,e),y(this,ge,t=>{y(this,te,r(this,te)-e[t]),e[t]=0;}),y(this,Ne,(t,n,i,a)=>{if(f(this,c,x).call(this,n))return 0;if(!ue(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!ue(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),y(this,Ie,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,c,Fe).call(this,true);}y(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,F);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,F)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Fe=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,_)[t];return r(this,Se)&&f(this,c,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,V)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,$)?.[t]&&(clearTimeout(r(this,$)[t]),r(this,$)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,_)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(y(this,H,y(this,F,0)),r(this,re).length=0):y(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Ve=function(e,t,n,i){let a=t===void 0?void 0:r(this,_)[t];if(f(this,c,x).call(this,a))return a;let s=new Ge,{signal:h}=n;h?.addEventListener("abort",()=>s.abort(h.reason),{signal:s.signal});let p={signal:s.signal,options:n,context:i},S=(w,T=false)=>{let{aborted:l}=s.signal,d=n.ignoreFetchAbort&&w!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!T?(n.status.fetchAborted=true,n.status.fetchError=s.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!T)return L(s.signal.reason,C);let E=N,O=r(this,_)[t];return (O===N||d&&T&&O===void 0)&&(w===void 0?E.__staleWhileFetching!==void 0?r(this,_)[t]=E.__staleWhileFetching:f(this,c,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,p.options))),w},u=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),L(w,false)),L=(w,T)=>{let{aborted:l}=s.signal,d=l&&n.allowStaleOnFetchAbort,C=d||n.allowStaleOnFetchRejection,E=C||n.noDeleteOnFetchRejection,O=N;if(r(this,_)[t]===N&&(!E||!T&&O.__staleWhileFetching===void 0?f(this,c,be).call(this,e,"fetch"):d||(r(this,_)[t]=O.__staleWhileFetching)),C)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw w},M=(w,T)=>{var d;let l=(d=r(this,Te))==null?void 0:d.call(this,e,a,p);l&&l instanceof Promise&&l.then(C=>w(C===void 0?void 0:C),T),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=C=>S(C,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(S,u),D=Object.assign(N,{__abortController:s,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,D,{...p.options,status:void 0}),t=r(this,U).get(e)):r(this,_)[t]=D,D},x=function(e){if(!r(this,Se))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},Ae=function(e){e!==r(this,F)&&(e===r(this,H)?y(this,H,r(this,K)[e]):f(this,c,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,c,Xe).call(this,r(this,F),e),y(this,F,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let s=r(this,U).get(e);if(s!==void 0)if(r(this,$)?.[s]&&(clearTimeout(r(this,$)?.[s]),r(this,$)[s]=void 0),n=true,r(this,Y)===1)f(this,c,Je).call(this,t);else {r(this,ge).call(this,s);let h=r(this,_)[s];if(f(this,c,x).call(this,h)?h.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,Q))==null||i.call(this,h,e,t)),r(this,W)&&r(this,V)?.push([h,e,t])),r(this,U).delete(e),r(this,A)[s]=void 0,r(this,_)[s]=void 0,s===r(this,F))y(this,F,r(this,j)[s]);else if(s===r(this,H))y(this,H,r(this,K)[s]);else {let p=r(this,j)[s];r(this,K)[p]=r(this,K)[s];let S=r(this,K)[s];r(this,j)[S]=r(this,j)[s];}Ue(this,Y)._--,r(this,re).push(s);}}if(r(this,W)&&r(this,V)?.length){let s=r(this,V),h;for(;h=s?.shift();)(a=r(this,Z))==null||a.call(this,...h);}return n},Je=function(e){var t,n;for(let i of f(this,c,fe).call(this,{allowStale:true})){let a=r(this,_)[i];if(f(this,c,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let s=r(this,A)[i];r(this,ae)&&((t=r(this,Q))==null||t.call(this,a,s,e)),r(this,W)&&r(this,V)?.push([a,s,e]);}}if(r(this,U).clear(),r(this,_).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,$)??[])i!==void 0&&clearTimeout(i);r(this,$)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),y(this,H,0),y(this,F,0),r(this,re).length=0,y(this,te,0),y(this,Y,0),r(this,W)&&r(this,V)){let i=r(this,V),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Oe);var De=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var g;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN] ${a}`,...s)))(g||={});var Re=new De({cacheSize:10}),lt;(a=>{function o(s){let h=Re.get(s);if(!h){g.error(`Label "${s}" not found`);return}return h}a.get=o;function e(s){if(Array.isArray(s)){s.forEach(h=>{e(h);});return}Re.has(s.id)&&g.info(`Label "${s.id}" already exists, it will be overwritten`),Re.set(s.id,s);}a.add=e;function t(){return Array.from(Re.values())}a.values=t;function n(s){return Re.has(s)}a.has=n;function i(){return Array.from(Re.keys())}a.keys=i;})(lt||={});var se=lt;function pe(o){try{if(typeof o>"u")return o;let e=JSON.stringify(o);return JSON.parse(e)}catch(e){throw g.error("Error creating exportable element",o,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class o{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(R,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(R,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=o.currentLabelStepIndex;if(t===null)return g.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=o.currentLabelId,a=o._currentLabel;if(!i||t===null||!a)return g.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let s=a.getStepSha(t)||"error",h=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return h[i]||(h[i]={}),(!h[i][n]||h[i][n].stepSha1!==s)&&(h[i][n]={stepSha1:s}),h[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=o.currentLabelStepIndex,i=n+e,a=o.currentLabelId;if(!a||n===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let s=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[a]||(s[a]={}),s[a][i]=t,core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static getCurrentStepTimesCounter(e=""){let t=o._stepCounter,n=o.getCurrentStepTimesCounterData(e);if(!n)return g.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(s=>s===t)||(i.push(t),n.stepCounters=i,o.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let s=o.getCurrentStepTimesCounterData(i);if(!s)return;let h=s.usedRandomNumbers||{},p=Array.from({length:t-e+1},(L,M)=>M+e).filter(L=>!h[`${e}-${t}`]?.includes(L));if(p.length===0)return;let S=Math.floor(Math.random()*p.length),u=p[S];return h[`${e}-${t}`]||(h[`${e}-${t}`]=[]),h[`${e}-${t}`].push(u),s.usedRandomNumbers=h,o.setCurrentStepTimesCounterData(i,s),u}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=o.currentLabelStepIndex,n=t+e,i=o.currentLabelId;if(!i||t===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(R,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(R,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){o._stepCounter++;}static _openedLabels=[];static get openedLabels(){return pe(o._openedLabels)}static set openedLabels(e){o._openedLabels=pe(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return pe(o._originalOpenedLabels)}static set originalOpenedLabels(e){o._originalOpenedLabels=pe(e);}static get _currentLabel(){if(o.currentLabelId)return se.get(o.currentLabelId)}static get currentLabelId(){if(o._openedLabels.length>0)return o._openedLabels[o._openedLabels.length-1].label}static get currentLabelStepIndex(){return o._openedLabels.length>0?o._openedLabels[o._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=o.allOpenedLabels,i=o.allOpenedLabels[e]?.biggestStep||0,a=o.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},o.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=o.allChoicesMade,s=a.findIndex(h=>h.labelId===e&&h.stepIndex===t&&h.choiceIndex===i&&h.stepSha1===n);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[s].madeTimes++,o.allChoicesMade=a;}static pushNewLabel(e){if(!se.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);o._openedLabels.push({label:e,currentStepIndex:0});let n=o.allOpenedLabels,i=o.allOpenedLabels[e]?.biggestStep||0,a=o.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},o.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(o._openedLabels.length>0){let e=o._openedLabels[o._openedLabels.length-1];o._openedLabels[o._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){o._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return o.onLoadingLabel&&e===0&&n.push(o.onLoadingLabel(e,t)),o._onStepStart&&n.push(o._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd};var Pe=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,s,h,p=core.GameUnifier.getVariable(R,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(h=core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let S=b.openedLabels,u={currentLabel:b.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:h,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:p,openedLabels:S};b.originalOpenedLabels=S,core.GameUnifier.addHistoryItem(u,{ignoreSameStep:i}),b.lastHistoryStep=u,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){g.warn("No label to close");return}if(!this.currentLabel){g.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=se.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(g.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&g.warn("The player must make a choice"),false):this.isRequiredInput?(t&&g.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){g.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){g.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(s){throw g.error("Error continuing",s),s}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});g.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){g.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){g.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(u){g.error("Error running onStepStart",u),this.onStepError&&await this.onStepError(u,e);return}let s=a.getStepById(i);if(!s){g.error("step not found");return}let h=a.getStepSha(i);h||(g.warn("stepSha not found, setting to ERROR"),h="error");let p,S;try{p=await s(e,{labelId:a.id});}catch(u){g.error("Error running step",u),S=u;}try{let u=this.choices;if(u?.length===1&&u[0].autoSelect){let L=u[0];p=await this.selectChoice(L,e);}}catch(u){g.error("Error auto-selecting choice",u),S||(S=u);}try{let u=b.lastHistoryStep;n!==void 0&&u&&(h=u.stepSha1,h||(g.warn("stepSha not found, setting to ERROR"),h="error"),b.addChoicesMade(u.currentLabel||"error",typeof u.labelStepIndex=="number"?u.labelStepIndex:-1,u.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(u){g.warn("Error adding choice made to history",u);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(h,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(u){g.warn("Error adding step to history",u);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(u){g.warn("Error running onStepEnd",u);}return S&&this.onStepError&&await this.onStepError(S,e),p}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){b.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;g.error("currentLabelId not found");}}async call(e,t,n){let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let s;try{let h=se.get(a);if(!h)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(h.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(h){throw g.error("Error calling label",h),h}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||s}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let s;try{let h=se.get(a);if(!h)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(h.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(h){throw g.error("Error jumping to label",h),h}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||s}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw g.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw g.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){g.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(R,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,pe({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,s)=>({...a,choiceIndex:s})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,s)=>a.oneTime&&i?.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,pe(e)),core.GameUnifier.setVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,core.GameUnifier.setVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:pe(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=se.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):g.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:g.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){g.error("Error running onLoadingLabel",n);}}catch(n){g.error("Error importing data",n);}}};function xt(o,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:o,type:n?.type||"call"}}var ht="close";function At(o,e){return {...e,type:ht,text:o}}var ft=Et(dt());var we=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var xe=class extends we{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){if(e<0||e>=this.steps.length)return g.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e];return (0,ft.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return g.warn("stepSha not found, setting to ERROR",t),"error"}}};function bt(o,e,t){let n=new xe(o,e,t);return se.add(n),n}var Er=new Pe;
1
+ 'use strict';var core=require('./core.cjs');var St=Object.create;var We=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Qe=s=>{throw TypeError(s)};var _t=(s,e,t)=>e in s?We(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var Be=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ze=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Tt=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(s,i)&&i!==t&&We(s,i,{get:()=>e[i],enumerable:!(n=yt(e,i))||n.enumerable});return s};var Et=(s,e,t)=>(t=s!=null?St(gt(s)):{},Tt(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>_t(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Qe("Cannot "+t);var r=(s,e,t)=>(je(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),y=(s,e,t,n)=>(je(s,e,"write to private field"),e.set(s,t),t),f=(s,e,t)=>(je(s,e,"access private method"),t);var Ue=(s,e,t,n)=>({set _(i){y(s,e,i);},get _(){return r(s,e,n)}});var ct=Ze((ze,pt)=>{(function(s,e){typeof ze=="object"?pt.exports=ze=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(ze,function(){var s=s||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function h(){}return function(d){var C;return h.prototype=d,C=new h,h.prototype=null,C}})(),o={},l=o.lib={},p=l.Base=(function(){return {extend:function(h){var d=a(this);return h&&d.mixIn(h),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var h=this.extend();return h.init.apply(h,arguments),h},init:function(){},mixIn:function(h){for(var d in h)h.hasOwnProperty(d)&&(this[d]=h[d]);h.hasOwnProperty("toString")&&(this.toString=h.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),S=l.WordArray=p.extend({init:function(h,d){h=this.words=h||[],d!=t?this.sigBytes=d:this.sigBytes=h.length*4;},toString:function(h){return (h||L).stringify(this)},concat:function(h){var d=this.words,C=h.words,E=this.sigBytes,O=h.sigBytes;if(this.clamp(),E%4)for(var P=0;P<O;P++){var oe=C[P>>>2]>>>24-P%4*8&255;d[E+P>>>2]|=oe<<24-(E+P)%4*8;}else for(var G=0;G<O;G+=4)d[E+G>>>2]=C[G>>>2];return this.sigBytes+=O,this},clamp:function(){var h=this.words,d=this.sigBytes;h[d>>>2]&=4294967295<<32-d%4*8,h.length=e.ceil(d/4);},clone:function(){var h=p.clone.call(this);return h.words=this.words.slice(0),h},random:function(h){for(var d=[],C=0;C<h;C+=4)d.push(i());return new S.init(d,h)}}),u=o.enc={},L=u.Hex={stringify:function(h){for(var d=h.words,C=h.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push((P>>>4).toString(16)),E.push((P&15).toString(16));}return E.join("")},parse:function(h){for(var d=h.length,C=[],E=0;E<d;E+=2)C[E>>>3]|=parseInt(h.substr(E,2),16)<<24-E%8*4;return new S.init(C,d/2)}},M=u.Latin1={stringify:function(h){for(var d=h.words,C=h.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push(String.fromCharCode(P));}return E.join("")},parse:function(h){for(var d=h.length,C=[],E=0;E<d;E++)C[E>>>2]|=(h.charCodeAt(E)&255)<<24-E%4*8;return new S.init(C,d)}},N=u.Utf8={stringify:function(h){try{return decodeURIComponent(escape(M.stringify(h)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(h){return M.parse(unescape(encodeURIComponent(h)))}},D=l.BufferedBlockAlgorithm=p.extend({reset:function(){this._data=new S.init,this._nDataBytes=0;},_append:function(h){typeof h=="string"&&(h=N.parse(h)),this._data.concat(h),this._nDataBytes+=h.sigBytes;},_process:function(h){var d,C=this._data,E=C.words,O=C.sigBytes,P=this.blockSize,oe=P*4,G=O/oe;h?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var J=G*P,_e=e.min(J*4,O);if(J){for(var Ke=0;Ke<J;Ke+=P)this._doProcessBlock(E,Ke);d=E.splice(0,J),C.sigBytes-=_e;}return new S.init(d,_e)},clone:function(){var h=p.clone.call(this);return h._data=this._data.clone(),h},_minBufferSize:0});l.Hasher=D.extend({cfg:p.extend(),init:function(h){this.cfg=this.cfg.extend(h),this.reset();},reset:function(){D.reset.call(this),this._doReset();},update:function(h){return this._append(h),this._process(),this},finalize:function(h){h&&this._append(h);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(h){return function(d,C){return new h.init(C).finalize(d)}},_createHmacHelper:function(h){return function(d,C){return new T.HMAC.init(h,C).finalize(d)}}});var T=o.algo={};return o})(Math);return s});});var dt=Ze((He,ut)=>{(function(s,e){typeof He=="object"?ut.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(He,function(s){return (function(){var e=s,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,o=[],l=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(p,S){for(var u=this._hash.words,L=u[0],M=u[1],N=u[2],D=u[3],w=u[4],T=0;T<80;T++){if(T<16)o[T]=p[S+T]|0;else {var h=o[T-3]^o[T-8]^o[T-14]^o[T-16];o[T]=h<<1|h>>>31;}var d=(L<<5|L>>>27)+w+o[T];T<20?d+=(M&N|~M&D)+1518500249:T<40?d+=(M^N^D)+1859775393:T<60?d+=(M&N|M&D|N&D)-1894007588:d+=(M^N^D)-899497514,w=D,D=N,N=M<<30|M>>>2,M=L,L=d;}u[0]=u[0]+L|0,u[1]=u[1]+M|0,u[2]=u[2]+N|0,u[3]=u[3]+D|0,u[4]=u[4]+w|0;},_doFinalize:function(){var p=this._data,S=p.words,u=this._nDataBytes*8,L=p.sigBytes*8;return S[L>>>5]|=128<<24-L%32,S[(L+64>>>9<<4)+14]=Math.floor(u/4294967296),S[(L+64>>>9<<4)+15]=u,p.sigBytes=S.length*4,this._process(),this._hash},clone:function(){var p=i.clone.call(this);return p._hash=this._hash.clone(),p}});e.SHA1=i._createHelper(l),e.HmacSHA1=i._createHmacHelper(l);})(),s.SHA1});});var R="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(s,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let s=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=s=>!nt.has(s);var ue=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>ue(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(s){super(s),this.fill(0);}},le,Te,Ot=(le=class{heap;length;static create(e){let t=at(e);if(!t)return [];y(le,Te,true);let n=new le(e,t);return y(le,Te,false),n}constructor(e,t){if(!r(le,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(le,Te,false),le),tt,rt,X,B,Q,ye,Z,Ee,Ce,ee,Y,te,U,A,_,K,j,H,F,re,V,ne,ie,k,$,ae,Se,W,Ie,c,$e,me,he,Me,q,ot,ge,Oe,Ne,de,fe,qe,Fe,Ve,x,Xe,Ae,be,Je,Re,st=(Re=class{constructor(e){v(this,c);v(this,X);v(this,B);v(this,Q);v(this,ye);v(this,Z);v(this,Ee);v(this,Ce);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,_);v(this,K);v(this,j);v(this,H);v(this,F);v(this,re);v(this,V);v(this,ne);v(this,ie);v(this,k);v(this,$);v(this,ae);v(this,Se);v(this,W);v(this,Ie);v(this,me,()=>{});v(this,he,()=>{});v(this,Me,()=>{});v(this,q,()=>false);v(this,ge,e=>{});v(this,Oe,(e,t,n)=>{});v(this,Ne,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:p,dispose:S,onInsert:u,disposeAfter:L,noDisposeOnSet:M,noUpdateTTL:N,maxSize:D=0,maxEntrySize:w=0,sizeCalculation:T,fetchMethod:h,memoMethod:d,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:P,ignoreFetchAbort:oe,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(y(this,ee,G??Ct),t!==0&&!ue(t))throw new TypeError("max option must be a nonnegative integer");let J=t?at(t):Array;if(!J)throw new Error("invalid max value: "+t);if(y(this,X,t),y(this,B,D),this.maxEntrySize=w||r(this,B),this.sizeCalculation=T,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(y(this,Ce,d),h!==void 0&&typeof h!="function")throw new TypeError("fetchMethod must be a function if specified");if(y(this,Ee,h),y(this,Se,!!h),y(this,U,new Map),y(this,A,new Array(t).fill(void 0)),y(this,_,new Array(t).fill(void 0)),y(this,K,new J(t)),y(this,j,new J(t)),y(this,H,0),y(this,F,0),y(this,re,Ot.create(t)),y(this,Y,0),y(this,te,0),typeof S=="function"&&y(this,Q,S),typeof u=="function"&&y(this,ye,u),typeof L=="function"?(y(this,Z,L),y(this,V,[])):(y(this,Z,void 0),y(this,V,void 0)),y(this,ae,!!r(this,Q)),y(this,Ie,!!r(this,ye)),y(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!oe,this.maxEntrySize!==0){if(r(this,B)!==0&&!ue(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!ue(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,c,ot).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=ue(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!ue(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,c,$e).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let _e="LRU_CACHE_UNBOUNDED";It(_e)&&(nt.add(_e),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_e,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,$),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,_),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,F)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,c,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,c,Ve).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,c,Ae).call(n,t)},indexes:t=>{var n;return f(n=e,c,de).call(n,t)},rindexes:t=>{var n;return f(n=e,c,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,Ee)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,Q)}get onInsert(){return r(this,ye)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,c,de).call(this))r(this,_)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield [r(this,A)[e],r(this,_)[e]]);}*rentries(){for(let e of f(this,c,fe).call(this))r(this,_)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield [r(this,A)[e],r(this,_)[e]]);}*keys(){for(let e of f(this,c,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield t);}}*rkeys(){for(let e of f(this,c,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield t);}}*values(){for(let e of f(this,c,de).call(this))r(this,_)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield r(this,_)[e]);}*rvalues(){for(let e of f(this,c,fe).call(this))r(this,_)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield r(this,_)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,c,de).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,c,de).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,c,fe).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,c,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,c,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,_)[t],i=f(this,c,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let o=r(this,k)[t],l=r(this,ie)[t];if(o&&l){let p=o-(r(this,ee).now()-l);a.ttl=p,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,c,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,_)[t],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(r(this,k)&&r(this,ie)){o.ttl=r(this,k)[t];let l=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-l);}r(this,ne)&&(o.size=r(this,ne)[t]),e.unshift([n,o]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,D,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:p}=n,{noUpdateTTL:S=this.noUpdateTTL}=n,u=r(this,Ne).call(this,e,t,n.size||0,l);if(this.maxEntrySize&&u>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),f(this,c,be).call(this,e,"set"),this;let L=r(this,Y)===0?void 0:r(this,U).get(e);if(L===void 0)L=r(this,Y)===0?r(this,F):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,c,Fe).call(this,false):r(this,Y),r(this,A)[L]=e,r(this,_)[L]=t,r(this,U).set(e,L),r(this,K)[r(this,F)]=L,r(this,j)[L]=r(this,F),y(this,F,L),Ue(this,Y)._++,r(this,Oe).call(this,L,u,p),p&&(p.set="add"),S=false,r(this,Ie)&&((M=r(this,ye))==null||M.call(this,t,e,"add"));else {f(this,c,Ae).call(this,L);let T=r(this,_)[L];if(t!==T){if(r(this,Se)&&f(this,c,x).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:h}=T;h!==void 0&&!o&&(r(this,ae)&&((N=r(this,Q))==null||N.call(this,h,e,"set")),r(this,W)&&r(this,V)?.push([h,e,"set"]));}else o||(r(this,ae)&&((D=r(this,Q))==null||D.call(this,T,e,"set")),r(this,W)&&r(this,V)?.push([T,e,"set"]));if(r(this,ge).call(this,L),r(this,Oe).call(this,L,u,p),r(this,_)[L]=t,p){p.set="replace";let h=T&&f(this,c,x).call(this,T)?T.__staleWhileFetching:T;h!==void 0&&(p.oldValue=h);}}else p&&(p.set="update");r(this,Ie)&&this.onInsert?.(t,e,t===T?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,c,$e).call(this),r(this,k)&&(S||r(this,Me).call(this,L,i,a),p&&r(this,he).call(this,p,L)),!o&&r(this,W)&&r(this,V)){let T=r(this,V),h;for(;h=T?.shift();)(w=r(this,Z))==null||w.call(this,...h);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,_)[r(this,H)];if(f(this,c,Fe).call(this,!0),f(this,c,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,V)){let t=r(this,V),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let o=r(this,_)[a];if(f(this,c,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,he).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,he).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,_)[i];return f(this,c,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:p=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:L=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:w,forceRefresh:T=false,status:h,signal:d}=t;if(!r(this,Se))return h&&(h.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:h});let C={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:l,size:p,sizeCalculation:S,noUpdateTTL:u,noDeleteOnFetchRejection:L,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:N,status:h,signal:d},E=r(this,U).get(e);if(E===void 0){h&&(h.fetch="miss");let O=f(this,c,Ve).call(this,e,E,C,w);return O.__returned=O}else {let O=r(this,_)[E];if(f(this,c,x).call(this,O)){let J=n&&O.__staleWhileFetching!==void 0;return h&&(h.fetch="inflight",J&&(h.returnedStale=true)),J?O.__staleWhileFetching:O.__returned=O}let P=r(this,q).call(this,E);if(!T&&!P)return h&&(h.fetch="hit"),f(this,c,Ae).call(this,E),i&&r(this,me).call(this,E),h&&r(this,he).call(this,h,E),O;let oe=f(this,c,Ve).call(this,e,E,C,w),G=oe.__staleWhileFetching!==void 0&&n;return h&&(h.fetch=P?"stale":"refresh",G&&P&&(h.returnedStale=true)),G?oe.__staleWhileFetching:oe.__returned=oe}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...o}=t,l=this.get(e,o);if(!a&&l!==void 0)return l;let p=n(e,l,{options:o,context:i});return this.set(e,p,o),p}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,l=r(this,U).get(e);if(l!==void 0){let p=r(this,_)[l],S=f(this,c,x).call(this,p);return o&&r(this,he).call(this,o,l),r(this,q).call(this,l)?(o&&(o.get="stale"),S?(o&&n&&p.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?p.__staleWhileFetching:void 0):(a||f(this,c,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?p:void 0)):(o&&(o.get="hit"),S?p.__staleWhileFetching:(f(this,c,Ae).call(this,l),i&&r(this,me).call(this,l),p))}else o&&(o.get="miss");}delete(e){return f(this,c,be).call(this,e,"delete")}clear(){return f(this,c,Je).call(this,"delete")}},X=new WeakMap,B=new WeakMap,Q=new WeakMap,ye=new WeakMap,Z=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,_=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,F=new WeakMap,re=new WeakMap,V=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,$=new WeakMap,ae=new WeakMap,Se=new WeakMap,W=new WeakMap,Ie=new WeakMap,c=new WeakSet,$e=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));y(this,k,e),y(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;y(this,$,n),y(this,Me,(l,p,S=r(this,ee).now())=>{t[l]=p!==0?S:0,e[l]=p,i(l,p);}),y(this,me,l=>{t[l]=e[l]!==0?r(this,ee).now():0,i(l,e[l]);});let i=this.ttlAutopurge?(l,p)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),p&&p!==0&&n){let S=setTimeout(()=>{r(this,q).call(this,l)&&f(this,c,be).call(this,r(this,A)[l],"expire");},p+1);S.unref&&S.unref(),n[l]=S;}}:()=>{};y(this,he,(l,p)=>{if(e[p]){let S=e[p],u=t[p];if(!S||!u)return;l.ttl=S,l.start=u,l.now=a||o();let L=l.now-u;l.remainingTTL=S-L;}});let a=0,o=()=>{let l=r(this,ee).now();if(this.ttlResolution>0){a=l;let p=setTimeout(()=>a=0,this.ttlResolution);p.unref&&p.unref();}return l};this.getRemainingTTL=l=>{let p=r(this,U).get(l);if(p===void 0)return 0;let S=e[p],u=t[p];if(!S||!u)return 1/0;let L=(a||o())-u;return S-L},y(this,q,l=>{let p=t[l],S=e[l];return !!S&&!!p&&(a||o())-p>S});},me=new WeakMap,he=new WeakMap,Me=new WeakMap,q=new WeakMap,ot=function(){let e=new Ye(r(this,X));y(this,te,0),y(this,ne,e),y(this,ge,t=>{y(this,te,r(this,te)-e[t]),e[t]=0;}),y(this,Ne,(t,n,i,a)=>{if(f(this,c,x).call(this,n))return 0;if(!ue(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!ue(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),y(this,Oe,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,c,Fe).call(this,true);}y(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Oe=new WeakMap,Ne=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,F);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,F)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Fe=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,_)[t];return r(this,Se)&&f(this,c,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,V)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,$)?.[t]&&(clearTimeout(r(this,$)[t]),r(this,$)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,_)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(y(this,H,y(this,F,0)),r(this,re).length=0):y(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Ve=function(e,t,n,i){let a=t===void 0?void 0:r(this,_)[t];if(f(this,c,x).call(this,a))return a;let o=new Ge,{signal:l}=n;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let p={signal:o.signal,options:n,context:i},S=(w,T=false)=>{let{aborted:h}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(h&&!T?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),h&&!d&&!T)return L(o.signal.reason,C);let E=N,O=r(this,_)[t];return (O===N||d&&T&&O===void 0)&&(w===void 0?E.__staleWhileFetching!==void 0?r(this,_)[t]=E.__staleWhileFetching:f(this,c,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,p.options))),w},u=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),L(w,false)),L=(w,T)=>{let{aborted:h}=o.signal,d=h&&n.allowStaleOnFetchAbort,C=d||n.allowStaleOnFetchRejection,E=C||n.noDeleteOnFetchRejection,O=N;if(r(this,_)[t]===N&&(!E||!T&&O.__staleWhileFetching===void 0?f(this,c,be).call(this,e,"fetch"):d||(r(this,_)[t]=O.__staleWhileFetching)),C)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw w},M=(w,T)=>{var d;let h=(d=r(this,Ee))==null?void 0:d.call(this,e,a,p);h&&h instanceof Promise&&h.then(C=>w(C===void 0?void 0:C),T),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=C=>S(C,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(S,u),D=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,D,{...p.options,status:void 0}),t=r(this,U).get(e)):r(this,_)[t]=D,D},x=function(e){if(!r(this,Se))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},Ae=function(e){e!==r(this,F)&&(e===r(this,H)?y(this,H,r(this,K)[e]):f(this,c,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,c,Xe).call(this,r(this,F),e),y(this,F,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let o=r(this,U).get(e);if(o!==void 0)if(r(this,$)?.[o]&&(clearTimeout(r(this,$)?.[o]),r(this,$)[o]=void 0),n=true,r(this,Y)===1)f(this,c,Je).call(this,t);else {r(this,ge).call(this,o);let l=r(this,_)[o];if(f(this,c,x).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,Q))==null||i.call(this,l,e,t)),r(this,W)&&r(this,V)?.push([l,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,_)[o]=void 0,o===r(this,F))y(this,F,r(this,j)[o]);else if(o===r(this,H))y(this,H,r(this,K)[o]);else {let p=r(this,j)[o];r(this,K)[p]=r(this,K)[o];let S=r(this,K)[o];r(this,j)[S]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,V)?.length){let o=r(this,V),l;for(;l=o?.shift();)(a=r(this,Z))==null||a.call(this,...l);}return n},Je=function(e){var t,n;for(let i of f(this,c,fe).call(this,{allowStale:true})){let a=r(this,_)[i];if(f(this,c,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,Q))==null||t.call(this,a,o,e)),r(this,W)&&r(this,V)?.push([a,o,e]);}}if(r(this,U).clear(),r(this,_).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,$)??[])i!==void 0&&clearTimeout(i);r(this,$)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),y(this,H,0),y(this,F,0),r(this,re).length=0,y(this,te,0),y(this,Y,0),r(this,W)&&r(this,V)){let i=r(this,V),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var De=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var g;(i=>(i.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),i.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),i.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(g||={});var Le=new De({cacheSize:10}),lt;(o=>{function s(l){let p=Le.get(l);if(!p){g.error(`Label "${l}" not found`);return}return p}o.get=s;function e(l){if(Array.isArray(l)){l.forEach(p=>{e(p);});return}Le.has(l.id)&&g.info(`Label "${l.id}" already exists, it will be overwritten`),Le.set(l.id,l);}o.add=e;function t(){return Array.from(Le.values())}o.values=t;function n(l){return Le.has(l)}o.has=n;function i(){return Array.from(Le.keys())}o.keys=i;function a(){Le.clear();}o.clear=a;})(lt||={});var se=lt;function pe(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw g.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class s{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(R,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(R,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return g.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return g.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",l=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return l[i]||(l[i]={}),(!l[i][n]||l[i][n].stepSha1!==o)&&(l[i][n]={stepSha1:o}),l[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return g.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(o=>o===t)||(i.push(t),n.stepCounters=i,s.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let o=s.getCurrentStepTimesCounterData(i);if(!o)return;let l=o.usedRandomNumbers||{},p=Array.from({length:t-e+1},(L,M)=>M+e).filter(L=>!l[`${e}-${t}`]?.includes(L));if(p.length===0)return;let S=Math.floor(Math.random()*p.length),u=p[S];return l[`${e}-${t}`]||(l[`${e}-${t}`]=[]),l[`${e}-${t}`].push(u),o.usedRandomNumbers=l,s.setCurrentStepTimesCounterData(i,o),u}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=s.currentLabelStepIndex,n=t+e,i=s.currentLabelId;if(!i||t===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(R,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(R,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return pe(s._openedLabels)}static set openedLabels(e){s._openedLabels=pe(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return pe(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=pe(e);}static get _currentLabel(){if(s.currentLabelId)return se.get(s.currentLabelId)}static get currentLabelId(){if(s._openedLabels.length>0)return s._openedLabels[s._openedLabels.length-1].label}static get currentLabelStepIndex(){return s._openedLabels.length>0?s._openedLabels[s._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},s.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=s.allChoicesMade,o=a.findIndex(l=>l.labelId===e&&l.stepIndex===t&&l.choiceIndex===i&&l.stepSha1===n);o<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[o].madeTimes++,s.allChoicesMade=a;}static pushNewLabel(e){if(!se.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);s._openedLabels.push({label:e,currentStepIndex:0});let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},s.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(s._openedLabels.length>0){let e=s._openedLabels[s._openedLabels.length-1];s._openedLabels[s._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){s._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return s.onLoadingLabel&&e===0&&n.push(s.onLoadingLabel(e,t)),s._onStepStart&&n.push(s._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd};var Pe=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,l,p=core.GameUnifier.getVariable(R,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l=core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let S=b.openedLabels,u={currentLabel:b.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:l,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:p,openedLabels:S};b.originalOpenedLabels=S,core.GameUnifier.addHistoryItem(u,{ignoreSameStep:i}),b.lastHistoryStep=u,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){g.warn("No label to close");return}if(!this.currentLabel){g.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=se.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(g.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&g.warn("The player must make a choice"),false):this.isRequiredInput?(t&&g.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){g.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){g.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(o){throw g.error("Error continuing",o),o}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});g.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){g.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){g.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(u){g.error("Error running onStepStart",u),this.onStepError&&await this.onStepError(u,e);return}let o=a.getStepById(i);if(!o){g.error("step not found");return}let l=a.getStepSha(i);l||(g.warn("stepSha not found, setting to ERROR"),l="error");let p,S;try{p=await o(e,{labelId:a.id});}catch(u){g.error("Error running step",u),S=u;}try{let u=this.choices;if(u?.length===1&&u[0].autoSelect){let L=u[0];p=await this.selectChoice(L,e);}}catch(u){g.error("Error auto-selecting choice",u),S||(S=u);}try{let u=b.lastHistoryStep;n!==void 0&&u&&(l=u.stepSha1,l||(g.warn("stepSha not found, setting to ERROR"),l="error"),b.addChoicesMade(u.currentLabel||"error",typeof u.labelStepIndex=="number"?u.labelStepIndex:-1,u.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(u){g.warn("Error adding choice made to history",u);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(l,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(u){g.warn("Error adding step to history",u);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(u){g.warn("Error running onStepEnd",u);}return S&&this.onStepError&&await this.onStepError(S,e),p}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){b.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;g.error("currentLabelId not found");}}async call(e,t,n){let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let o;try{let l=se.get(a);if(!l)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(l.id),o=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw g.error("Error calling label",l),l}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||o}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let o;try{let l=se.get(a);if(!l)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(l.id),o=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw g.error("Error jumping to label",l),l}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||o}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw g.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw g.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){g.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(R,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,pe({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,o)=>({...a,choiceIndex:o})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,o)=>a.oneTime&&i?.includes(o)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,pe(e)),core.GameUnifier.setVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,core.GameUnifier.setVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:pe(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=se.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):g.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:g.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){g.error("Error running onLoadingLabel",n);}}catch(n){g.error("Error importing data",n);}}};function xt(s,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:s,type:n?.type||"call"}}var ht="close";function At(s,e){return {...e,type:ht,text:s}}var ft=Et(dt());var we=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var xe=class extends we{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){if(e<0||e>=this.steps.length)return g.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e];return (0,ft.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return g.warn("stepSha not found, setting to ERROR",t),"error"}}};function bt(s,e,t){let n=new xe(s,e,t);return se.add(n),n}var Er=new Pe;
2
2
  exports.Label=xe;exports.LabelAbstract=we;exports.NarrationManagerStatic=b;exports.RegisteredLabels=se;exports.narration=Er;exports.newChoiceOption=xt;exports.newCloseChoiceOption=At;exports.newLabel=bt;
@@ -518,6 +518,10 @@ declare namespace RegisteredLabels {
518
518
  * @returns An array of label ids.
519
519
  */
520
520
  function keys(): LabelIdType[];
521
+ /**
522
+ * Removes all registered labels.
523
+ */
524
+ function clear(): void;
521
525
  }
522
526
 
523
527
  interface ChoiceInterface {
@@ -518,6 +518,10 @@ declare namespace RegisteredLabels {
518
518
  * @returns An array of label ids.
519
519
  */
520
520
  function keys(): LabelIdType[];
521
+ /**
522
+ * Removes all registered labels.
523
+ */
524
+ function clear(): void;
521
525
  }
522
526
 
523
527
  interface ChoiceInterface {
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-6GLWL3NH.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {d,c,e,f as f$1}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'./core.mjs';var h=new d({cacheSize:10}),R;(a=>{function i(p){let u=h.get(p);if(!u){e.error(`Label "${p}" not found`);return}return u}a.get=i;function e$1(p){if(Array.isArray(p)){p.forEach(u=>{e$1(u);});return}h.has(p.id)&&e.info(`Label "${p.id}" already exists, it will be overwritten`),h.set(p.id,p);}a.add=e$1;function t(){return Array.from(h.values())}a.values=t;function r(p){return h.has(p)}a.has=r;function n(){return Array.from(h.keys())}a.keys=n;})(R||={});var f=R;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e$1=""){let t=i.currentLabelStepIndex;if(t===null)return e.error("currentLabelStepIndex is null"),null;let r=`${t}${e$1}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let p=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!==p)&&(u[n$1][r]={stepSha1:p}),u[n$1][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n$1=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};p[a]||(p[a]={}),p[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,p);}static getCurrentStepTimesCounter(e$1=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e$1);if(!r)return e.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(p=>p===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e$1,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let p=i.getCurrentStepTimesCounterData(n);if(!p)return;let u=p.usedRandomNumbers||{},S=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!u[`${e}-${t}`]?.includes(E));if(S.length===0)return;let L=Math.floor(Math.random()*S.length),b=S[L];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),p.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,p),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e$1=""){let t=i.currentLabelStepIndex,r=t+e$1,n$1=i.currentLabelId;if(!n$1||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return f$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=f$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return f$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=f$1(e);}static get _currentLabel(){if(i.currentLabelId)return f.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,p=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);p<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[p].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!f.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd};var C=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,p,u,S=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:p,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:L};o.originalOpenedLabels=L,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){e.warn("No label to close");return}if(!this.currentLabel){e.error("currentLabel not found");return}let e$1=o.openedLabels;e$1.pop(),o.openedLabels=e$1,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=f.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e$1=o.currentLabelStepIndex,t=this.currentLabel;if(e$1===null||!t)return;let r=t.getStepSha(e$1);return r||(e.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e$1&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&e.warn("The player must make a choice"),false):this.isRequiredInput?(t&&e.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e$1,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){e.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){e.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e$1,t);}catch(p){throw e.error("Error continuing",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e$1)||a}async afterRunCurrentStep(e$1){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e$1,{labelId:"end"});e.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e$1,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){e.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){e.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){e.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e$1);return}let p=a.getStepById(n);if(!p){e.error("step not found");return}let u=a.getStepSha(n);u||(e.warn("stepSha not found, setting to ERROR"),u="error");let S,L;try{S=await p(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),L=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let E=b[0];S=await this.selectChoice(E,e$1);}}catch(b){e.error("Error auto-selecting choice",b),L||(L=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(e.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){e.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){e.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){e.warn("Error running onStepEnd",b);}return L&&this.onStepError&&await this.onStepError(L,e$1),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e$1,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async call(e$1,t,r){let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let p;try{let u=f.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw e.error("Error calling label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async jump(e$1,t,r){if(this.stepCounter===0)return await this.call(e$1,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let p;try{let u=f.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw e.error("Error jumping to label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async selectChoice(e$1,t){this.choices=void 0;let r=e$1.type;switch(r){case "call":return await this.call(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "jump":return await this.jump(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "close":return await this.closeChoiceMenu(e$1,{...e$1.props,...t});default:throw e.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e$1,t){if(e$1.type!=="close")throw e.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e$1.choiceIndex=="number"&&(r=e$1.choiceIndex),e$1.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e$1,t)=>{try{await GameUnifier.runOnError(e$1,t);}catch(r){e.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e$1){if(e$1===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e$1=="string"||Array.isArray(e$1))&&(e$1={text:e$1}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e$1.text)?r=[...r,...e$1.text]:r=[...r,e$1.text],e$1.text=r,e$1.character=e$1.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,f$1({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,p)=>({...a,choiceIndex:p})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,p)=>a.oneTime&&n?.includes(p)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,f$1(e$1)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:f$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=f.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e$1,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e$1,"openedLabels")?(o.openedLabels=e$1.openedLabels,o.originalOpenedLabels=o.openedLabels):e.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e$1,"stepCounter")?o._stepCounter=e$1.stepCounter:e.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){e.error("Error running onLoadingLabel",r);}}catch(r){e.error("Error importing data",r);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var g=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var I=class extends g{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e$1){if(e$1<0||e$1>=this.steps.length)return e.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e$1];return (0,M.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return e.warn("stepSha not found, setting to ERROR",t),"error"}}};function x(i,e,t){let r=new I(i,e,t);return f.add(r),r}var fe=new C;
2
- export{I as Label,g as LabelAbstract,o as NarrationManagerStatic,f as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
1
+ import {a}from'./chunk-6GLWL3NH.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {d,c,e,f}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'./core.mjs';var h=new d({cacheSize:10}),R;(d=>{function i(p){let f=h.get(p);if(!f){e.error(`Label "${p}" not found`);return}return f}d.get=i;function e$1(p){if(Array.isArray(p)){p.forEach(f=>{e$1(f);});return}h.has(p.id)&&e.info(`Label "${p.id}" already exists, it will be overwritten`),h.set(p.id,p);}d.add=e$1;function t(){return Array.from(h.values())}d.values=t;function r(p){return h.has(p)}d.has=r;function n(){return Array.from(h.keys())}d.keys=n;function a(){h.clear();}d.clear=a;})(R||={});var L=R;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e$1=""){let t=i.currentLabelStepIndex;if(t===null)return e.error("currentLabelStepIndex is null"),null;let r=`${t}${e$1}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let d=a.getStepSha(t)||"error",p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[n$1]||(p[n$1]={}),(!p[n$1][r]||p[n$1][r].stepSha1!==d)&&(p[n$1][r]={stepSha1:d}),p[n$1][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n$1=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let d=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};d[a]||(d[a]={}),d[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,d);}static getCurrentStepTimesCounter(e$1=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e$1);if(!r)return e.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(d=>d===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e$1,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let d=i.getCurrentStepTimesCounterData(n);if(!d)return;let p=d.usedRandomNumbers||{},f=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!p[`${e}-${t}`]?.includes(E));if(f.length===0)return;let S=Math.floor(Math.random()*f.length),b=f[S];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(b),d.usedRandomNumbers=p,i.setCurrentStepTimesCounterData(n,d),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e$1=""){let t=i.currentLabelStepIndex,r=t+e$1,n$1=i.currentLabelId;if(!n$1||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return f(i._openedLabels)}static set openedLabels(e){i._openedLabels=f(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return f(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=f(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,d=a.findIndex(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===n&&p.stepSha1===r);d<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[d].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd};var C=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,d,p,f=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(d=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let S=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:d,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:p,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:f,openedLabels:S};o.originalOpenedLabels=S,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){e.warn("No label to close");return}if(!this.currentLabel){e.error("currentLabel not found");return}let e$1=o.openedLabels;e$1.pop(),o.openedLabels=e$1,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e$1=o.currentLabelStepIndex,t=this.currentLabel;if(e$1===null||!t)return;let r=t.getStepSha(e$1);return r||(e.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e$1&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&e.warn("The player must make a choice"),false):this.isRequiredInput?(t&&e.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e$1,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){e.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){e.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e$1,t);}catch(d){throw e.error("Error continuing",d),d}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e$1)||a}async afterRunCurrentStep(e$1){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e$1,{labelId:"end"});e.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e$1,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){e.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){e.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){e.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e$1);return}let d=a.getStepById(n);if(!d){e.error("step not found");return}let p=a.getStepSha(n);p||(e.warn("stepSha not found, setting to ERROR"),p="error");let f,S;try{f=await d(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),S=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let E=b[0];f=await this.selectChoice(E,e$1);}}catch(b){e.error("Error auto-selecting choice",b),S||(S=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(p=b.stepSha1,p||(e.warn("stepSha not found, setting to ERROR"),p="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){e.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(p,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){e.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){e.warn("Error running onStepEnd",b);}return S&&this.onStepError&&await this.onStepError(S,e$1),f}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e$1,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async call(e$1,t,r){let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let d;try{let p=L.get(a);if(!p)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(p.id),d=await this.runCurrentStep(t,{choiceMade:n});}catch(p){throw e.error("Error calling label",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||d}async jump(e$1,t,r){if(this.stepCounter===0)return await this.call(e$1,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let d;try{let p=L.get(a);if(!p)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(p.id),d=await this.runCurrentStep(t,{choiceMade:n});}catch(p){throw e.error("Error jumping to label",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||d}async selectChoice(e$1,t){this.choices=void 0;let r=e$1.type;switch(r){case "call":return await this.call(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "jump":return await this.jump(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "close":return await this.closeChoiceMenu(e$1,{...e$1.props,...t});default:throw e.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e$1,t){if(e$1.type!=="close")throw e.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e$1.choiceIndex=="number"&&(r=e$1.choiceIndex),e$1.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e$1,t)=>{try{await GameUnifier.runOnError(e$1,t);}catch(r){e.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e$1){if(e$1===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e$1=="string"||Array.isArray(e$1))&&(e$1={text:e$1}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e$1.text)?r=[...r,...e$1.text]:r=[...r,e$1.text],e$1.text=r,e$1.character=e$1.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,f({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,d)=>({...a,choiceIndex:d})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,d)=>a.oneTime&&n?.includes(d)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,f(e$1)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:f(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e$1,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e$1,"openedLabels")?(o.openedLabels=e$1.openedLabels,o.originalOpenedLabels=o.openedLabels):e.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e$1,"stepCounter")?o._stepCounter=e$1.stepCounter:e.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){e.error("Error running onLoadingLabel",r);}}catch(r){e.error("Error importing data",r);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var g=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var I=class extends g{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e$1){if(e$1<0||e$1>=this.steps.length)return e.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e$1];return (0,M.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return e.warn("stepSha not found, setting to ERROR",t),"error"}}};function x(i,e,t){let r=new I(i,e,t);return L.add(r),r}var fe=new C;
2
+ export{I as Label,g as LabelAbstract,o as NarrationManagerStatic,L as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
package/dist/vite.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var J=Object.create;var L=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var U=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Y=(n,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!z.call(n,s)&&s!==o&&L(n,s,{get:()=>e[s],enumerable:!(m=G(e,s))||m.enumerable});return n};var W=(n,e,o)=>(o=n!=null?J(j(n)):{},Y(L(o,"default",{value:n,enumerable:true}),n));var F=U((ce,_)=>{var f=process||{},B=f.argv||[],p=f.env||{},K=!(p.NO_COLOR||B.includes("--no-color"))&&(!!p.FORCE_COLOR||B.includes("--color")||f.platform==="win32"||(f.stdout||{}).isTTY&&p.TERM!=="dumb"||!!p.CI),Q=(n,e,o=n)=>m=>{let s=""+m,l=s.indexOf(e,n.length);return ~l?n+Z(s,e,o,l)+e:n+s+e},Z=(n,e,o,m)=>{let s="",l=0;do s+=n.substring(l,m)+o,l=m+e.length,m=n.indexOf(e,l);while(~m);return s+n.substring(l)},T=(n=K)=>{let e=n?Q:()=>String;return {isColorSupported:n,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};_.exports=T();_.exports.createColors=T;});var y="/__pixi-vn/characters",I="/__pixi-vn/labels",S="/__pixi-vn/assets/manifest",P="/__pixi-vn/canvas-options";var C=W(F());var w=C.default.cyan("(pixi-vn)");function A(n){return n?Array.isArray(n)?n:[n]:[]}function se(n){let e=[],o=[];for(let m of n)try{let s=fs.readFileSync(m,"utf-8"),l=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=l.exec(s))!==null;)o.push(d[1]);let b=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=b.exec(s))!==null;)e.push(d[1]);}catch{}return {charIds:e,labelIds:o}}function ae(n){let e,o,m=new Promise(t=>{o=t;}),s=[...A(n?.content),...A(n?.characters),...A(n?.labels)],l=[],d=[],b=new Set,E=[],h=new Map;function V(){if(!n?.typeFilePath||!e)return null;let t=n.typeFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function M(){let t=[...d,...Array.from(h.values()).flat()];return Array.from(new Set(t))}function k(t,i,a){fs.mkdirSync(path.dirname(t),{recursive:true});let r=["// @ts-nocheck","/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(i.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let c of i)r.push(` ${JSON.stringify(c)}: never;`);r.push(" }"),r.push("}");}if(a.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let c of a)r.push(` ${JSON.stringify(c)}: never;`);r.push(" }"),r.push("}");}r.push("export {};"),r.push(""),fs.writeFileSync(t,r.join(`
2
- `),"utf-8");}function u(){let t=V();if(t)try{k(t,l.map(i=>i.id),M());}catch(i){e?.logger.error(`${w} Failed to write type file "${t}".`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}async function O(t,i=[]){try{l=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{l=[];}try{d=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{d=[];}if(i.length>0){let{charIds:r,labelIds:c}=se(i),v=new Set(l.map(g=>g.id)),$=new Set(d);for(let g of r)v.has(g)||l.push({id:g});for(let g of c)$.has(g)||d.push(g);}let a=l.map(r=>r.id).join(", ")||"none";e?.logger.info(`${w} ${C.default.dim(`${l.length} character(s): [${a}], ${d.length} label(s)`)}`,{timestamp:true});}async function N(t,i){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let a=await tinyglobby.glob(s,{cwd:i,absolute:true,onlyFiles:true}),r=[];for(let c of a){b.add(c);try{await t(c);}catch{r.push(c);}}await O(t,r),u(),o();}async function X(t){for(let r of b)for(let c of t.moduleGraph.getModulesByFile(r)??[])t.moduleGraph.invalidateModule(c);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).registeredCharacters?.clear?.();}catch{}let i=await tinyglobby.glob(s,{cwd:e.root,absolute:true,onlyFiles:true}),a=[];for(let r of i){b.add(r);try{await t.ssrLoadModule(r);}catch{a.push(r);}}await O(r=>t.ssrLoadModule(r),a),u();for(let r of E)r();}let R={characters:null,labels:null,manifest:null,canvasOptions:null};function x(t,i){return (a,r)=>{if(r.setHeader("Content-Type","application/json"),a.method==="GET"){let c=R[t];if(c===null){r.statusCode=404,r.end(JSON.stringify({error:`${i} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(c));return}if(a.method==="POST"){let c="";a.on("data",v=>{c+=v.toString();}),a.on("end",()=>{try{R[t]=JSON.parse(c),r.statusCode=201,r.end(JSON.stringify({message:`${i} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${i}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return l},onReload(t){E.push(t);},setExternalLabels(t,i){h.set(t,i),u();},clearExternalLabels(t){h.delete(t),u();}},config(t,i){if(i.command==="serve"&&s.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,s.length===0&&o();},async buildStart(){if(e?.command!=="build"||s.length===0)return;let{createServer:t}=await import('vite'),i=await t({root:e.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await N(a=>i.ssrLoadModule(a),e.root);}catch{o();}finally{await i.close();}},configureServer(t){s.length>0&&N(i=>t.ssrLoadModule(i),e.root).catch(()=>{o();}),t.middlewares.use(y,x("characters","Characters")),t.middlewares.use(I,x("labels","Labels")),t.middlewares.use(S,x("manifest","Manifest")),t.middlewares.use(P,x("canvasOptions","Canvas options"));},hotUpdate({file:t,server:i}){let a=V();if(a&&t===a)return [];if(s.length>0&&b.has(t))return X(i).catch(r=>{e?.logger.error(`${w} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=S;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=P;exports.PIXIVN_DEV_API_CHARACTERS=y;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=ae;
1
+ 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var J=Object.create;var N=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var U=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Y=(n,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!z.call(n,s)&&s!==o&&N(n,s,{get:()=>e[s],enumerable:!(m=G(e,s))||m.enumerable});return n};var W=(n,e,o)=>(o=n!=null?J(j(n)):{},Y(N(o,"default",{value:n,enumerable:true}),n));var F=U((ce,_)=>{var f=process||{},B=f.argv||[],p=f.env||{},K=!(p.NO_COLOR||B.includes("--no-color"))&&(!!p.FORCE_COLOR||B.includes("--color")||f.platform==="win32"||(f.stdout||{}).isTTY&&p.TERM!=="dumb"||!!p.CI),Q=(n,e,o=n)=>m=>{let s=""+m,l=s.indexOf(e,n.length);return ~l?n+Z(s,e,o,l)+e:n+s+e},Z=(n,e,o,m)=>{let s="",l=0;do s+=n.substring(l,m)+o,l=m+e.length,m=n.indexOf(e,l);while(~m);return s+n.substring(l)},T=(n=K)=>{let e=n?Q:()=>String;return {isColorSupported:n,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};_.exports=T();_.exports.createColors=T;});var y="/__pixi-vn/characters",I="/__pixi-vn/labels",S="/__pixi-vn/assets/manifest",P="/__pixi-vn/canvas-options";var C=W(F());var w=C.default.cyan("(pixi-vn)");function A(n){return n?Array.isArray(n)?n:[n]:[]}function se(n){let e=[],o=[];for(let m of n)try{let s=fs.readFileSync(m,"utf-8"),l=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=l.exec(s))!==null;)o.push(d[1]);let b=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=b.exec(s))!==null;)e.push(d[1]);}catch{}return {charIds:e,labelIds:o}}function ae(n){let e,o,m=new Promise(t=>{o=t;}),s=[...A(n?.content),...A(n?.characters),...A(n?.labels)],l=[],d=[],b=new Set,E=[],h=new Map;function R(){if(!n?.typeFilePath||!e)return null;let t=n.typeFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function D(){let t=[...d,...Array.from(h.values()).flat()];return Array.from(new Set(t))}function k(t,i,a){fs.mkdirSync(path.dirname(t),{recursive:true});let r=["// @ts-nocheck","/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(i.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let c of i)r.push(` ${JSON.stringify(c)}: never;`);r.push(" }"),r.push("}");}if(a.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let c of a)r.push(` ${JSON.stringify(c)}: never;`);r.push(" }"),r.push("}");}r.push("export {};"),r.push(""),fs.writeFileSync(t,r.join(`
2
+ `),"utf-8");}function u(){let t=R();if(t)try{k(t,l.map(i=>i.id),D());}catch(i){e?.logger.error(`${w} Failed to write type file "${t}".`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}async function V(t,i=[]){try{l=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{l=[];}try{d=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{d=[];}if(i.length>0){let{charIds:r,labelIds:c}=se(i),v=new Set(l.map(g=>g.id)),$=new Set(d);for(let g of r)v.has(g)||l.push({id:g});for(let g of c)$.has(g)||d.push(g);}let a=l.map(r=>r.id).join(", ")||"none";e?.logger.info(`${w} ${C.default.dim(`${l.length} character(s): [${a}], ${d.length} label(s)`)}`,{timestamp:true});}async function O(t,i){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let a=await tinyglobby.glob(s,{cwd:i,absolute:true,onlyFiles:true}),r=[];for(let c of a){b.add(c);try{await t(c);}catch{r.push(c);}}await V(t,r),u(),o();}async function X(t){for(let r of b)for(let c of t.moduleGraph.getModulesByFile(r)??[])t.moduleGraph.invalidateModule(c);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let i=await tinyglobby.glob(s,{cwd:e.root,absolute:true,onlyFiles:true}),a=[];for(let r of i){b.add(r);try{await t.ssrLoadModule(r);}catch{a.push(r);}}await V(r=>t.ssrLoadModule(r),a),u();for(let r of E)r();}let L={characters:null,labels:null,manifest:null,canvasOptions:null};function x(t,i){return (a,r)=>{if(r.setHeader("Content-Type","application/json"),a.method==="GET"){let c=L[t];if(c===null){r.statusCode=404,r.end(JSON.stringify({error:`${i} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(c));return}if(a.method==="POST"){let c="";a.on("data",v=>{c+=v.toString();}),a.on("end",()=>{try{L[t]=JSON.parse(c),r.statusCode=201,r.end(JSON.stringify({message:`${i} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${i}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return l},onReload(t){E.push(t);},setExternalLabels(t,i){h.set(t,i),u();},clearExternalLabels(t){h.delete(t),u();}},config(t,i){if(i.command==="serve"&&s.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,s.length===0&&o();},async buildStart(){if(e?.command!=="build"||s.length===0)return;let{createServer:t}=await import('vite'),i=await t({root:e.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await O(a=>i.ssrLoadModule(a),e.root);}catch{o();}finally{await i.close();}},configureServer(t){s.length>0&&O(i=>t.ssrLoadModule(i),e.root).catch(()=>{o();}),t.middlewares.use(y,x("characters","Characters")),t.middlewares.use(I,x("labels","Labels")),t.middlewares.use(S,x("manifest","Manifest")),t.middlewares.use(P,x("canvasOptions","Canvas options"));},hotUpdate({file:t,server:i}){let a=R();if(a&&t===a)return [];if(s.length>0&&b.has(t))return X(i).catch(r=>{e?.logger.error(`${w} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=S;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=P;exports.PIXIVN_DEV_API_CHARACTERS=y;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=ae;
package/dist/vite.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import {a as a$1,b,c as c$1,d}from'./chunk-3BBZHKU4.mjs';export{c as PIXIVN_DEV_API_ASSETS_MANIFEST,d as PIXIVN_DEV_API_CANVAS_OPTIONS,a as PIXIVN_DEV_API_CHARACTERS,b as PIXIVN_DEV_API_LABELS}from'./chunk-3BBZHKU4.mjs';import {a,c}from'./chunk-K7JIC2F2.mjs';import {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var F=a((ee,P)=>{var h=process||{},V=h.argv||[],f=h.env||{},G=!(f.NO_COLOR||V.includes("--no-color"))&&(!!f.FORCE_COLOR||V.includes("--color")||h.platform==="win32"||(h.stdout||{}).isTTY&&f.TERM!=="dumb"||!!f.CI),j=(i,e,c=i)=>d=>{let o=""+d,a=o.indexOf(e,i.length);return ~a?i+H(o,e,c,a)+e:i+o+e},H=(i,e,c,d)=>{let o="",a=0;do o+=i.substring(a,d)+c,a=d+e.length,d=i.indexOf(e,a);while(~d);return o+i.substring(a)},N=(i=G)=>{let e=i?j:()=>String;return {isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};P.exports=N();P.exports.createColors=N;});var _=c(F(),1);var C=_.default.cyan("(pixi-vn)");function A(i){return i?Array.isArray(i)?i:[i]:[]}function Z(i){let e=[],c=[];for(let d of i)try{let o=readFileSync(d,"utf-8"),a=/newLabel\(\s*["']([^"']+)["']/g,m;for(;(m=a.exec(o))!==null;)c.push(m[1]);let b=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(m=b.exec(o))!==null;)e.push(m[1]);}catch{}return {charIds:e,labelIds:c}}function q(i){let e,c,d$1=new Promise(t=>{c=t;}),o=[...A(i?.content),...A(i?.characters),...A(i?.labels)],a=[],m=[],b$1=new Set,E=[],p=new Map;function O(){if(!i?.typeFilePath||!e)return null;let t=i.typeFilePath;return isAbsolute(t)?t:resolve(e.root,t)}function M(){let t=[...m,...Array.from(p.values()).flat()];return Array.from(new Set(t))}function k(t,n,s){mkdirSync(dirname(t),{recursive:true});let r=["// @ts-nocheck","/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(n.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let l of n)r.push(` ${JSON.stringify(l)}: never;`);r.push(" }"),r.push("}");}if(s.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let l of s)r.push(` ${JSON.stringify(l)}: never;`);r.push(" }"),r.push("}");}r.push("export {};"),r.push(""),writeFileSync(t,r.join(`
2
- `),"utf-8");}function u(){let t=O();if(t)try{k(t,a.map(n=>n.id),M());}catch(n){e?.logger.error(`${C} Failed to write type file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function R(t,n=[]){try{a=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{a=[];}try{m=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{m=[];}if(n.length>0){let{charIds:r,labelIds:l}=Z(n),y=new Set(a.map(g=>g.id)),$=new Set(m);for(let g of r)y.has(g)||a.push({id:g});for(let g of l)$.has(g)||m.push(g);}let s=a.map(r=>r.id).join(", ")||"none";e?.logger.info(`${C} ${_.default.dim(`${a.length} character(s): [${s}], ${m.length} label(s)`)}`,{timestamp:true});}async function B(t,n){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let s=await glob(o,{cwd:n,absolute:true,onlyFiles:true}),r=[];for(let l of s){b$1.add(l);try{await t(l);}catch{r.push(l);}}await R(t,r),u(),c();}async function D(t){for(let r of b$1)for(let l of t.moduleGraph.getModulesByFile(r)??[])t.moduleGraph.invalidateModule(l);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).registeredCharacters?.clear?.();}catch{}let n=await glob(o,{cwd:e.root,absolute:true,onlyFiles:true}),s=[];for(let r of n){b$1.add(r);try{await t.ssrLoadModule(r);}catch{s.push(r);}}await R(r=>t.ssrLoadModule(r),s),u();for(let r of E)r();}let L={characters:null,labels:null,manifest:null,canvasOptions:null};function x(t,n){return (s,r)=>{if(r.setHeader("Content-Type","application/json"),s.method==="GET"){let l=L[t];if(l===null){r.statusCode=404,r.end(JSON.stringify({error:`${n} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(l));return}if(s.method==="POST"){let l="";s.on("data",y=>{l+=y.toString();}),s.on("end",()=>{try{L[t]=JSON.parse(l),r.statusCode=201,r.end(JSON.stringify({message:`${n} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${n}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:d$1,get characters(){return a},onReload(t){E.push(t);},setExternalLabels(t,n){p.set(t,n),u();},clearExternalLabels(t){p.delete(t),u();}},config(t,n){if(n.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,o.length===0&&c();},async buildStart(){if(e?.command!=="build"||o.length===0)return;let{createServer:t}=await import('vite'),n=await t({root:e.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await B(s=>n.ssrLoadModule(s),e.root);}catch{c();}finally{await n.close();}},configureServer(t){o.length>0&&B(n=>t.ssrLoadModule(n),e.root).catch(()=>{c();}),t.middlewares.use(a$1,x("characters","Characters")),t.middlewares.use(b,x("labels","Labels")),t.middlewares.use(c$1,x("manifest","Manifest")),t.middlewares.use(d,x("canvasOptions","Canvas options"));},hotUpdate({file:t,server:n}){let s=O();if(s&&t===s)return [];if(o.length>0&&b$1.has(t))return D(n).catch(r=>{e?.logger.error(`${C} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}export{q as vitePluginPixivn};
1
+ import {a as a$1,b,c as c$1,d}from'./chunk-3BBZHKU4.mjs';export{c as PIXIVN_DEV_API_ASSETS_MANIFEST,d as PIXIVN_DEV_API_CANVAS_OPTIONS,a as PIXIVN_DEV_API_CHARACTERS,b as PIXIVN_DEV_API_LABELS}from'./chunk-3BBZHKU4.mjs';import {a,c}from'./chunk-K7JIC2F2.mjs';import {mkdirSync,writeFileSync,readFileSync}from'fs';import {isAbsolute,resolve,dirname}from'path';import {glob}from'tinyglobby';var F=a((ee,P)=>{var h=process||{},V=h.argv||[],f=h.env||{},G=!(f.NO_COLOR||V.includes("--no-color"))&&(!!f.FORCE_COLOR||V.includes("--color")||h.platform==="win32"||(h.stdout||{}).isTTY&&f.TERM!=="dumb"||!!f.CI),j=(i,e,c=i)=>d=>{let o=""+d,a=o.indexOf(e,i.length);return ~a?i+H(o,e,c,a)+e:i+o+e},H=(i,e,c,d)=>{let o="",a=0;do o+=i.substring(a,d)+c,a=d+e.length,d=i.indexOf(e,a);while(~d);return o+i.substring(a)},N=(i=G)=>{let e=i?j:()=>String;return {isColorSupported:i,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};P.exports=N();P.exports.createColors=N;});var _=c(F(),1);var C=_.default.cyan("(pixi-vn)");function A(i){return i?Array.isArray(i)?i:[i]:[]}function Z(i){let e=[],c=[];for(let d of i)try{let o=readFileSync(d,"utf-8"),a=/newLabel\(\s*["']([^"']+)["']/g,m;for(;(m=a.exec(o))!==null;)c.push(m[1]);let b=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(m=b.exec(o))!==null;)e.push(m[1]);}catch{}return {charIds:e,labelIds:c}}function q(i){let e,c,d$1=new Promise(t=>{c=t;}),o=[...A(i?.content),...A(i?.characters),...A(i?.labels)],a=[],m=[],b$1=new Set,E=[],p=new Map;function R(){if(!i?.typeFilePath||!e)return null;let t=i.typeFilePath;return isAbsolute(t)?t:resolve(e.root,t)}function M(){let t=[...m,...Array.from(p.values()).flat()];return Array.from(new Set(t))}function k(t,n,s){mkdirSync(dirname(t),{recursive:true});let r=["// @ts-nocheck","/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(n.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let l of n)r.push(` ${JSON.stringify(l)}: never;`);r.push(" }"),r.push("}");}if(s.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let l of s)r.push(` ${JSON.stringify(l)}: never;`);r.push(" }"),r.push("}");}r.push("export {};"),r.push(""),writeFileSync(t,r.join(`
2
+ `),"utf-8");}function u(){let t=R();if(t)try{k(t,a.map(n=>n.id),M());}catch(n){e?.logger.error(`${C} Failed to write type file "${t}".`,{error:n instanceof Error?n:new Error(String(n)),timestamp:true});}}async function O(t,n=[]){try{a=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{a=[];}try{m=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{m=[];}if(n.length>0){let{charIds:r,labelIds:l}=Z(n),y=new Set(a.map(g=>g.id)),$=new Set(m);for(let g of r)y.has(g)||a.push({id:g});for(let g of l)$.has(g)||m.push(g);}let s=a.map(r=>r.id).join(", ")||"none";e?.logger.info(`${C} ${_.default.dim(`${a.length} character(s): [${s}], ${m.length} label(s)`)}`,{timestamp:true});}async function L(t,n){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let s=await glob(o,{cwd:n,absolute:true,onlyFiles:true}),r=[];for(let l of s){b$1.add(l);try{await t(l);}catch{r.push(l);}}await O(t,r),u(),c();}async function D(t){for(let r of b$1)for(let l of t.moduleGraph.getModulesByFile(r)??[])t.moduleGraph.invalidateModule(l);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let n=await glob(o,{cwd:e.root,absolute:true,onlyFiles:true}),s=[];for(let r of n){b$1.add(r);try{await t.ssrLoadModule(r);}catch{s.push(r);}}await O(r=>t.ssrLoadModule(r),s),u();for(let r of E)r();}let B={characters:null,labels:null,manifest:null,canvasOptions:null};function x(t,n){return (s,r)=>{if(r.setHeader("Content-Type","application/json"),s.method==="GET"){let l=B[t];if(l===null){r.statusCode=404,r.end(JSON.stringify({error:`${n} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(l));return}if(s.method==="POST"){let l="";s.on("data",y=>{l+=y.toString();}),s.on("end",()=>{try{B[t]=JSON.parse(l),r.statusCode=201,r.end(JSON.stringify({message:`${n} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${n}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:d$1,get characters(){return a},onReload(t){E.push(t);},setExternalLabels(t,n){p.set(t,n),u();},clearExternalLabels(t){p.delete(t),u();}},config(t,n){if(n.command==="serve"&&o.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,o.length===0&&c();},async buildStart(){if(e?.command!=="build"||o.length===0)return;let{createServer:t}=await import('vite'),n=await t({root:e.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await L(s=>n.ssrLoadModule(s),e.root);}catch{c();}finally{await n.close();}},configureServer(t){o.length>0&&L(n=>t.ssrLoadModule(n),e.root).catch(()=>{c();}),t.middlewares.use(a$1,x("characters","Characters")),t.middlewares.use(b,x("labels","Labels")),t.middlewares.use(c$1,x("manifest","Manifest")),t.middlewares.use(d,x("canvasOptions","Canvas options"));},hotUpdate({file:t,server:n}){let s=R();if(s&&t===s)return [];if(o.length>0&&b$1.has(t))return D(n).catch(r=>{e?.logger.error(`${C} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}export{q as vitePluginPixivn};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn",
3
- "version": "1.8.12",
3
+ "version": "1.8.13",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN is a npm package that provides various features for creating visual novels.",
6
6
  "main": "./dist/index.cjs",