UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

1 lines 30.2 kB
'use strict';var Qt=Object.defineProperty;var Kt=l=>{throw TypeError(l)};var Zt=(l,t,i)=>t in l?Qt(l,t,{enumerable:true,configurable:true,writable:true,value:i}):l[t]=i;var c=(l,t,i)=>Zt(l,typeof t!="symbol"?t+"":t,i),Lt=(l,t,i)=>t.has(l)||Kt("Cannot "+i);var e=(l,t,i)=>(Lt(l,t,"read from private field"),i?i.call(l):t.get(l)),b=(l,t,i)=>t.has(l)?Kt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(l):t.set(l,i),u=(l,t,i,s)=>(Lt(l,t,"write to private field"),t.set(l,i),i),h=(l,t,i)=>(Lt(l,t,"access private method"),i);var Ct=(l,t,i,s)=>({set _(r){u(l,t,r);},get _(){return e(l,t,s)}});var T;(r=>(r.log=(n,...a)=>console.log(`[Pixi\u2019VN] ${n}`,...a),r.warn=(n,...a)=>console.warn(`[Pixi\u2019VN] ${n}`,...a),r.error=(n,...a)=>console.error(`[Pixi\u2019VN] ${n}`,...a),r.info=(n,...a)=>console.info(`[Pixi\u2019VN] ${n}`,...a)))(T||(T={}));var f=class f{static init(t){f._getStepCounter=t.getStepCounter,f._setStepCounter=t.setStepCounter,f._getCurrentGameStepState=t.getCurrentGameStepState,f._restoreGameStepState=t.restoreGameStepState,f._getOpenedLabels=t.getOpenedLabels,t.onGoNextEnd&&(f._onGoNextEnd=t.onGoNextEnd),f._getVariable=t.getVariable,f._setVariable=t.setVariable,f._removeVariable=t.removeVariable,f._getFlag=t.getFlag,f._setFlag=t.setFlag,t.onLabelClosing&&(f._onLabelClosing=t.onLabelClosing),f._addHistoryItem=t.addHistoryItem,f._getCurrentStepsRunningNumber=t.getCurrentStepsRunningNumber,f._getCharacter=t.getCharacter;}static get stepCounter(){return f._getStepCounter()}static set stepCounter(t){f._setStepCounter(t);}static get currentGameStepState(){return f._getCurrentGameStepState()}static get restoreGameStepState(){return f._restoreGameStepState}static get openedLabels(){return f._getOpenedLabels()}static get onGoNextEnd(){return f._onGoNextEnd}static get getVariable(){return f._getVariable}static get setVariable(){return f._setVariable}static get removeVariable(){return f._removeVariable}static get getFlag(){return f._getFlag}static get setFlag(){return f._setFlag}static get onLabelClosing(){return f._onLabelClosing}static get addHistoryItem(){return f._addHistoryItem}static get currentStepsRunningNumber(){return f._getCurrentStepsRunningNumber()}static get getCharacter(){return f._getCharacter}};c(f,"_getStepCounter",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_setStepCounter",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_getCurrentGameStepState",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_restoreGameStepState",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_getOpenedLabels",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_onGoNextEnd",async()=>{}),c(f,"_getVariable",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_setVariable",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_removeVariable",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_getFlag",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_setFlag",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_onLabelClosing",()=>{}),c(f,"_addHistoryItem",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_getCurrentStepsRunningNumber",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented, you should initialize the Game: Game.init()")}),c(f,"_getCharacter",()=>{throw T.error("Method not implemented, you should initialize the Game: Game.init()"),new Error("Method not implemented.")}),c(f,"onEnd"),c(f,"onError");var ft=f;function Ft(l){try{if(typeof l>"u")return l;let t=JSON.stringify(l);return JSON.parse(t)}catch(t){throw T.error("Error creating exportable element",l,t),new Error("[Pixi\u2019VN] Error creating exportable element")}}var dt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,qt=new Set,Rt=typeof process=="object"&&process?process:{},Jt=(l,t,i,s)=>{typeof Rt.emitWarning=="function"?Rt.emitWarning(l,t,i,s):console.error(`[${i}] ${t}: ${l}`);},xt=globalThis.AbortController,$t=globalThis.AbortSignal;if(typeof xt>"u"){$t=class{constructor(){c(this,"onabort");c(this,"_onabort",[]);c(this,"reason");c(this,"aborted",false);}addEventListener(s,r){this._onabort.push(r);}},xt=class{constructor(){c(this,"signal",new $t);t();}abort(s){if(!this.signal.aborted){this.signal.reason=s,this.signal.aborted=true;for(let r of this.signal._onabort)r(s);this.signal.onabort?.(s);}}};let l=Rt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{l&&(l=false,Jt("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 kt=l=>!qt.has(l),et=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),Yt=l=>et(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?gt:null:null,gt=class extends Array{constructor(t){super(t),this.fill(0);}},mt,at=class at{constructor(t,i){c(this,"heap");c(this,"length");if(!e(at,mt))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new i(t),this.length=0;}static create(t){let i=Yt(t);if(!i)return [];u(at,mt,true);let s=new at(t,i);return u(at,mt,false),s}push(t){this.heap[this.length++]=t;}pop(){return this.heap[--this.length]}};mt=new WeakMap,b(at,mt,false);var Dt=at,Bt,Ut,K,D,$,ot,B,pt,St,F,U,G,w,p,M,N,I,A,q,O,J,Y,W,X,nt,V,bt,o,Nt,ht,k,vt,P,Xt,lt,yt,Tt,it,st,Wt,At,Ot,y,Pt,_t,rt,jt,Ht=class Ht{constructor(t){b(this,o);b(this,K);b(this,D);b(this,$);b(this,ot);b(this,B);b(this,pt);b(this,St);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");b(this,F);b(this,U);b(this,G);b(this,w);b(this,p);b(this,M);b(this,N);b(this,I);b(this,A);b(this,q);b(this,O);b(this,J);b(this,Y);b(this,W);b(this,X);b(this,nt);b(this,V);b(this,bt);b(this,ht,()=>{});b(this,k,()=>{});b(this,vt,()=>{});b(this,P,()=>false);b(this,lt,t=>{});b(this,yt,(t,i,s)=>{});b(this,Tt,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});c(this,Bt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:a,updateAgeOnHas:m,allowStale:d,dispose:C,onInsert:Q,disposeAfter:E,noDisposeOnSet:tt,noUpdateTTL:j,maxSize:Z=0,maxEntrySize:v=0,sizeCalculation:_,fetchMethod:S,memoMethod:L,noDeleteOnFetchRejection:R,noDeleteOnStaleGet:x,allowStaleOnFetchRejection:H,allowStaleOnFetchAbort:Et,ignoreFetchAbort:ct}=t;if(i!==0&&!et(i))throw new TypeError("max option must be a nonnegative integer");let zt=i?Yt(i):Array;if(!zt)throw new Error("invalid max value: "+i);if(u(this,K,i),u(this,D,Z),this.maxEntrySize=v||e(this,D),this.sizeCalculation=_,this.sizeCalculation){if(!e(this,D)&&!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(L!==void 0&&typeof L!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,St,L),S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,pt,S),u(this,nt,!!S),u(this,G,new Map),u(this,w,new Array(i).fill(void 0)),u(this,p,new Array(i).fill(void 0)),u(this,M,new zt(i)),u(this,N,new zt(i)),u(this,I,0),u(this,A,0),u(this,q,Dt.create(i)),u(this,F,0),u(this,U,0),typeof C=="function"&&u(this,$,C),typeof Q=="function"&&u(this,ot,Q),typeof E=="function"?(u(this,B,E),u(this,O,[])):(u(this,B,void 0),u(this,O,void 0)),u(this,X,!!e(this,$)),u(this,bt,!!e(this,ot)),u(this,V,!!e(this,B)),this.noDisposeOnSet=!!tt,this.noUpdateTTL=!!j,this.noDeleteOnFetchRejection=!!R,this.allowStaleOnFetchRejection=!!H,this.allowStaleOnFetchAbort=!!Et,this.ignoreFetchAbort=!!ct,this.maxEntrySize!==0){if(e(this,D)!==0&&!et(e(this,D)))throw new TypeError("maxSize must be a positive integer if specified");if(!et(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");h(this,o,Xt).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!x,this.updateAgeOnGet=!!a,this.updateAgeOnHas=!!m,this.ttlResolution=et(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!et(this.ttl))throw new TypeError("ttl must be a positive integer if specified");h(this,o,Nt).call(this);}if(e(this,K)===0&&this.ttl===0&&e(this,D)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,K)&&!e(this,D)){let ut="LRU_CACHE_UNBOUNDED";kt(ut)&&(qt.add(ut),Jt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ut,Ht));}}static unsafeExposeInternals(t){return {starts:e(t,Y),ttls:e(t,W),sizes:e(t,J),keyMap:e(t,G),keyList:e(t,w),valList:e(t,p),next:e(t,M),prev:e(t,N),get head(){return e(t,I)},get tail(){return e(t,A)},free:e(t,q),isBackgroundFetch:i=>{var s;return h(s=t,o,y).call(s,i)},backgroundFetch:(i,s,r,n)=>{var a;return h(a=t,o,Ot).call(a,i,s,r,n)},moveToTail:i=>{var s;return h(s=t,o,_t).call(s,i)},indexes:i=>{var s;return h(s=t,o,it).call(s,i)},rindexes:i=>{var s;return h(s=t,o,st).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,K)}get maxSize(){return e(this,D)}get calculatedSize(){return e(this,U)}get size(){return e(this,F)}get fetchMethod(){return e(this,pt)}get memoMethod(){return e(this,St)}get dispose(){return e(this,$)}get onInsert(){return e(this,ot)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,G).has(t)?1/0:0}*entries(){for(let t of h(this,o,it).call(this))e(this,p)[t]!==void 0&&e(this,w)[t]!==void 0&&!h(this,o,y).call(this,e(this,p)[t])&&(yield [e(this,w)[t],e(this,p)[t]]);}*rentries(){for(let t of h(this,o,st).call(this))e(this,p)[t]!==void 0&&e(this,w)[t]!==void 0&&!h(this,o,y).call(this,e(this,p)[t])&&(yield [e(this,w)[t],e(this,p)[t]]);}*keys(){for(let t of h(this,o,it).call(this)){let i=e(this,w)[t];i!==void 0&&!h(this,o,y).call(this,e(this,p)[t])&&(yield i);}}*rkeys(){for(let t of h(this,o,st).call(this)){let i=e(this,w)[t];i!==void 0&&!h(this,o,y).call(this,e(this,p)[t])&&(yield i);}}*values(){for(let t of h(this,o,it).call(this))e(this,p)[t]!==void 0&&!h(this,o,y).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}*rvalues(){for(let t of h(this,o,st).call(this))e(this,p)[t]!==void 0&&!h(this,o,y).call(this,e(this,p)[t])&&(yield e(this,p)[t]);}[(Ut=Symbol.iterator,Bt=Symbol.toStringTag,Ut)](){return this.entries()}find(t,i={}){for(let s of h(this,o,it).call(this)){let r=e(this,p)[s],n=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&t(n,e(this,w)[s],this))return this.get(e(this,w)[s],i)}}forEach(t,i=this){for(let s of h(this,o,it).call(this)){let r=e(this,p)[s],n=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&t.call(i,n,e(this,w)[s],this);}}rforEach(t,i=this){for(let s of h(this,o,st).call(this)){let r=e(this,p)[s],n=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&t.call(i,n,e(this,w)[s],this);}}purgeStale(){let t=false;for(let i of h(this,o,st).call(this,{allowStale:true}))e(this,P).call(this,i)&&(h(this,o,rt).call(this,e(this,w)[i],"expire"),t=true);return t}info(t){let i=e(this,G).get(t);if(i===void 0)return;let s=e(this,p)[i],r=h(this,o,y).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(e(this,W)&&e(this,Y)){let a=e(this,W)[i],m=e(this,Y)[i];if(a&&m){let d=a-(dt.now()-m);n.ttl=d,n.start=Date.now();}}return e(this,J)&&(n.size=e(this,J)[i]),n}dump(){let t=[];for(let i of h(this,o,it).call(this,{allowStale:true})){let s=e(this,w)[i],r=e(this,p)[i],n=h(this,o,y).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let a={value:n};if(e(this,W)&&e(this,Y)){a.ttl=e(this,W)[i];let m=dt.now()-e(this,Y)[i];a.start=Math.floor(Date.now()-m);}e(this,J)&&(a.size=e(this,J)[i]),t.unshift([s,a]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=dt.now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var tt,j,Z,v;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:a=this.noDisposeOnSet,sizeCalculation:m=this.sizeCalculation,status:d}=s,{noUpdateTTL:C=this.noUpdateTTL}=s,Q=e(this,Tt).call(this,t,i,s.size||0,m);if(this.maxEntrySize&&Q>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),h(this,o,rt).call(this,t,"set"),this;let E=e(this,F)===0?void 0:e(this,G).get(t);if(E===void 0)E=e(this,F)===0?e(this,A):e(this,q).length!==0?e(this,q).pop():e(this,F)===e(this,K)?h(this,o,At).call(this,false):e(this,F),e(this,w)[E]=t,e(this,p)[E]=i,e(this,G).set(t,E),e(this,M)[e(this,A)]=E,e(this,N)[E]=e(this,A),u(this,A,E),Ct(this,F)._++,e(this,yt).call(this,E,Q,d),d&&(d.set="add"),C=false,e(this,bt)&&((tt=e(this,ot))==null||tt.call(this,i,t,"add"));else {h(this,o,_t).call(this,E);let _=e(this,p)[E];if(i!==_){if(e(this,nt)&&h(this,o,y).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:S}=_;S!==void 0&&!a&&(e(this,X)&&((j=e(this,$))==null||j.call(this,S,t,"set")),e(this,V)&&e(this,O)?.push([S,t,"set"]));}else a||(e(this,X)&&((Z=e(this,$))==null||Z.call(this,_,t,"set")),e(this,V)&&e(this,O)?.push([_,t,"set"]));if(e(this,lt).call(this,E),e(this,yt).call(this,E,Q,d),e(this,p)[E]=i,d){d.set="replace";let S=_&&h(this,o,y).call(this,_)?_.__staleWhileFetching:_;S!==void 0&&(d.oldValue=S);}}else d&&(d.set="update");e(this,bt)&&this.onInsert?.(i,t,i===_?"update":"replace");}if(r!==0&&!e(this,W)&&h(this,o,Nt).call(this),e(this,W)&&(C||e(this,vt).call(this,E,r,n),d&&e(this,k).call(this,d,E)),!a&&e(this,V)&&e(this,O)){let _=e(this,O),S;for(;S=_?.shift();)(v=e(this,B))==null||v.call(this,...S);}return this}pop(){var t;try{for(;e(this,F);){let i=e(this,p)[e(this,I)];if(h(this,o,At).call(this,!0),h(this,o,y).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,V)&&e(this,O)){let i=e(this,O),s;for(;s=i?.shift();)(t=e(this,B))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=e(this,G).get(t);if(n!==void 0){let a=e(this,p)[n];if(h(this,o,y).call(this,a)&&a.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,n))r&&(r.has="stale",e(this,k).call(this,r,n));else return s&&e(this,ht).call(this,n),r&&(r.has="hit",e(this,k).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,G).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let n=e(this,p)[r];return h(this,o,y).call(this,n)?n.__staleWhileFetching:n}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,ttl:a=this.ttl,noDisposeOnSet:m=this.noDisposeOnSet,size:d=0,sizeCalculation:C=this.sizeCalculation,noUpdateTTL:Q=this.noUpdateTTL,noDeleteOnFetchRejection:E=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:tt=this.allowStaleOnFetchRejection,ignoreFetchAbort:j=this.ignoreFetchAbort,allowStaleOnFetchAbort:Z=this.allowStaleOnFetchAbort,context:v,forceRefresh:_=false,status:S,signal:L}=i;if(!e(this,nt))return S&&(S.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:S});let R={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:a,noDisposeOnSet:m,size:d,sizeCalculation:C,noUpdateTTL:Q,noDeleteOnFetchRejection:E,allowStaleOnFetchRejection:tt,allowStaleOnFetchAbort:Z,ignoreFetchAbort:j,status:S,signal:L},x=e(this,G).get(t);if(x===void 0){S&&(S.fetch="miss");let H=h(this,o,Ot).call(this,t,x,R,v);return H.__returned=H}else {let H=e(this,p)[x];if(h(this,o,y).call(this,H)){let Vt=s&&H.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",Vt&&(S.returnedStale=true)),Vt?H.__staleWhileFetching:H.__returned=H}let Et=e(this,P).call(this,x);if(!_&&!Et)return S&&(S.fetch="hit"),h(this,o,_t).call(this,x),r&&e(this,ht).call(this,x),S&&e(this,k).call(this,S,x),H;let ct=h(this,o,Ot).call(this,t,x,R,v),ut=ct.__staleWhileFetching!==void 0&&s;return S&&(S.fetch=Et?"stale":"refresh",ut&&Et&&(S.returnedStale=true)),ut?ct.__staleWhileFetching:ct.__returned=ct}}async forceFetch(t,i={}){let s=await this.fetch(t,i);if(s===void 0)throw new Error("fetch() returned undefined");return s}memo(t,i={}){let s=e(this,St);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...a}=i,m=this.get(t,a);if(!n&&m!==void 0)return m;let d=s(t,m,{options:a,context:r});return this.set(t,d,a),d}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:a}=i,m=e(this,G).get(t);if(m!==void 0){let d=e(this,p)[m],C=h(this,o,y).call(this,d);return a&&e(this,k).call(this,a,m),e(this,P).call(this,m)?(a&&(a.get="stale"),C?(a&&s&&d.__staleWhileFetching!==void 0&&(a.returnedStale=true),s?d.__staleWhileFetching:void 0):(n||h(this,o,rt).call(this,t,"expire"),a&&s&&(a.returnedStale=true),s?d:void 0)):(a&&(a.get="hit"),C?d.__staleWhileFetching:(h(this,o,_t).call(this,m),r&&e(this,ht).call(this,m),d))}else a&&(a.get="miss");}delete(t){return h(this,o,rt).call(this,t,"delete")}clear(){return h(this,o,jt).call(this,"delete")}};K=new WeakMap,D=new WeakMap,$=new WeakMap,ot=new WeakMap,B=new WeakMap,pt=new WeakMap,St=new WeakMap,F=new WeakMap,U=new WeakMap,G=new WeakMap,w=new WeakMap,p=new WeakMap,M=new WeakMap,N=new WeakMap,I=new WeakMap,A=new WeakMap,q=new WeakMap,O=new WeakMap,J=new WeakMap,Y=new WeakMap,W=new WeakMap,X=new WeakMap,nt=new WeakMap,V=new WeakMap,bt=new WeakMap,o=new WeakSet,Nt=function(){let t=new gt(e(this,K)),i=new gt(e(this,K));u(this,W,t),u(this,Y,i),u(this,vt,(n,a,m=dt.now())=>{if(i[n]=a!==0?m:0,t[n]=a,a!==0&&this.ttlAutopurge){let d=setTimeout(()=>{e(this,P).call(this,n)&&h(this,o,rt).call(this,e(this,w)[n],"expire");},a+1);d.unref&&d.unref();}}),u(this,ht,n=>{i[n]=t[n]!==0?dt.now():0;}),u(this,k,(n,a)=>{if(t[a]){let m=t[a],d=i[a];if(!m||!d)return;n.ttl=m,n.start=d,n.now=s||r();let C=n.now-d;n.remainingTTL=m-C;}});let s=0,r=()=>{let n=dt.now();if(this.ttlResolution>0){s=n;let a=setTimeout(()=>s=0,this.ttlResolution);a.unref&&a.unref();}return n};this.getRemainingTTL=n=>{let a=e(this,G).get(n);if(a===void 0)return 0;let m=t[a],d=i[a];if(!m||!d)return 1/0;let C=(s||r())-d;return m-C},u(this,P,n=>{let a=i[n],m=t[n];return !!m&&!!a&&(s||r())-a>m});},ht=new WeakMap,k=new WeakMap,vt=new WeakMap,P=new WeakMap,Xt=function(){let t=new gt(e(this,K));u(this,U,0),u(this,J,t),u(this,lt,i=>{u(this,U,e(this,U)-t[i]),t[i]=0;}),u(this,Tt,(i,s,r,n)=>{if(h(this,o,y).call(this,s))return 0;if(!et(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!et(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,yt,(i,s,r)=>{if(t[i]=s,e(this,D)){let n=e(this,D)-t[i];for(;e(this,U)>n;)h(this,o,At).call(this,true);}u(this,U,e(this,U)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,U));});},lt=new WeakMap,yt=new WeakMap,Tt=new WeakMap,it=function*({allowStale:t=this.allowStale}={}){if(e(this,F))for(let i=e(this,A);!(!h(this,o,Wt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,I)));)i=e(this,N)[i];},st=function*({allowStale:t=this.allowStale}={}){if(e(this,F))for(let i=e(this,I);!(!h(this,o,Wt).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,A)));)i=e(this,M)[i];},Wt=function(t){return t!==void 0&&e(this,G).get(e(this,w)[t])===t},At=function(t){var n;let i=e(this,I),s=e(this,w)[i],r=e(this,p)[i];return e(this,nt)&&h(this,o,y).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,X)||e(this,V))&&(e(this,X)&&((n=e(this,$))==null||n.call(this,r,s,"evict")),e(this,V)&&e(this,O)?.push([r,s,"evict"])),e(this,lt).call(this,i),t&&(e(this,w)[i]=void 0,e(this,p)[i]=void 0,e(this,q).push(i)),e(this,F)===1?(u(this,I,u(this,A,0)),e(this,q).length=0):u(this,I,e(this,M)[i]),e(this,G).delete(s),Ct(this,F)._--,i},Ot=function(t,i,s,r){let n=i===void 0?void 0:e(this,p)[i];if(h(this,o,y).call(this,n))return n;let a=new xt,{signal:m}=s;m?.addEventListener("abort",()=>a.abort(m.reason),{signal:a.signal});let d={signal:a.signal,options:s,context:r},C=(v,_=false)=>{let{aborted:S}=a.signal,L=s.ignoreFetchAbort&&v!==void 0;if(s.status&&(S&&!_?(s.status.fetchAborted=true,s.status.fetchError=a.signal.reason,L&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),S&&!L&&!_)return E(a.signal.reason);let R=j;return e(this,p)[i]===j&&(v===void 0?R.__staleWhileFetching?e(this,p)[i]=R.__staleWhileFetching:h(this,o,rt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,v,d.options))),v},Q=v=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=v),E(v)),E=v=>{let{aborted:_}=a.signal,S=_&&s.allowStaleOnFetchAbort,L=S||s.allowStaleOnFetchRejection,R=L||s.noDeleteOnFetchRejection,x=j;if(e(this,p)[i]===j&&(!R||x.__staleWhileFetching===void 0?h(this,o,rt).call(this,t,"fetch"):S||(e(this,p)[i]=x.__staleWhileFetching)),L)return s.status&&x.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),x.__staleWhileFetching;if(x.__returned===x)throw v},tt=(v,_)=>{var L;let S=(L=e(this,pt))==null?void 0:L.call(this,t,n,d);S&&S instanceof Promise&&S.then(R=>v(R===void 0?void 0:R),_),a.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(v(void 0),s.allowStaleOnFetchAbort&&(v=R=>C(R,true)));});};s.status&&(s.status.fetchDispatched=true);let j=new Promise(tt).then(C,Q),Z=Object.assign(j,{__abortController:a,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(t,Z,{...d.options,status:void 0}),i=e(this,G).get(t)):e(this,p)[i]=Z,Z},y=function(t){if(!e(this,nt))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof xt},Pt=function(t,i){e(this,N)[i]=t,e(this,M)[t]=i;},_t=function(t){t!==e(this,A)&&(t===e(this,I)?u(this,I,e(this,M)[t]):h(this,o,Pt).call(this,e(this,N)[t],e(this,M)[t]),h(this,o,Pt).call(this,e(this,A),t),u(this,A,t));},rt=function(t,i){var r,n;let s=false;if(e(this,F)!==0){let a=e(this,G).get(t);if(a!==void 0)if(s=true,e(this,F)===1)h(this,o,jt).call(this,i);else {e(this,lt).call(this,a);let m=e(this,p)[a];if(h(this,o,y).call(this,m)?m.__abortController.abort(new Error("deleted")):(e(this,X)||e(this,V))&&(e(this,X)&&((r=e(this,$))==null||r.call(this,m,t,i)),e(this,V)&&e(this,O)?.push([m,t,i])),e(this,G).delete(t),e(this,w)[a]=void 0,e(this,p)[a]=void 0,a===e(this,A))u(this,A,e(this,N)[a]);else if(a===e(this,I))u(this,I,e(this,M)[a]);else {let d=e(this,N)[a];e(this,M)[d]=e(this,M)[a];let C=e(this,M)[a];e(this,N)[C]=e(this,N)[a];}Ct(this,F)._--,e(this,q).push(a);}}if(e(this,V)&&e(this,O)?.length){let a=e(this,O),m;for(;m=a?.shift();)(n=e(this,B))==null||n.call(this,...m);}return s},jt=function(t){var i,s;for(let r of h(this,o,st).call(this,{allowStale:true})){let n=e(this,p)[r];if(h(this,o,y).call(this,n))n.__abortController.abort(new Error("deleted"));else {let a=e(this,w)[r];e(this,X)&&((i=e(this,$))==null||i.call(this,n,a,t)),e(this,V)&&e(this,O)?.push([n,a,t]);}}if(e(this,G).clear(),e(this,p).fill(void 0),e(this,w).fill(void 0),e(this,W)&&e(this,Y)&&(e(this,W).fill(0),e(this,Y).fill(0)),e(this,J)&&e(this,J).fill(0),u(this,I,0),u(this,A,0),e(this,q).length=0,u(this,U,0),u(this,F,0),e(this,V)&&e(this,O)){let r=e(this,O),n;for(;n=r?.shift();)(s=e(this,B))==null||s.call(this,...n);}};var It=Ht;var wt=class{constructor(t){c(this,"cache");c(this,"map",new Map);this.cache=new It({max:t.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return 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 z=class z{constructor(){}static clearOldTempVariables(t){z.tempStorageDeadlines.forEach((i,s)=>{i>t&&(z.tempStorage.delete(s),z.tempStorageDeadlines.delete(s),z.storage.cache.delete(s));});}static setVariable(t,i){let s=z.tempStorage.has(t);i==null?(z.storage.map.delete(t),!s&&z.storage.cache.delete(t)):(z.storage.map.set(t,i),!s&&z.storage.cache.set(t,i));}static getVariable(t){let i=z.storage.cache.get(t);return i===void 0&&(i=z.tempStorage.get(t)),i===void 0&&(i=z.storage.map.get(t)),Ft(i)}static removeVariable(t){z.storage.delete(t);}static setFlag(t,i){if(i)this.flags.includes(t)||this.flags.push(t);else {let s=this.flags.indexOf(t);s>-1&&this.flags.splice(s,1);}}static getFlag(t){return this.flags.includes(t)}};c(z,"storage",new wt({cacheSize:20})),c(z,"startingStorage",[]),c(z,"flags",Array()),c(z,"tempStorage",new Map),c(z,"tempStorageDeadlines",new Map);var g=z;var Gt=class{get storage(){return g.storage.map}get cache(){return g.storage.cache}get flags(){return g.flags}get tempStorage(){return g.tempStorage}get tempStorageDeadlines(){return g.tempStorageDeadlines}set startingStorage(t){let i=[],s=ft.stepCounter===0;Object.entries(t).forEach(([r,n])=>{i.push({key:r,value:n}),s&&g.storage.set(r,n);}),g.startingStorage=i;}setVariable(t,i){return g.setVariable(t,i)}getVariable(t){return g.getVariable(t)}removeVariable(t){return g.removeVariable(t)}setTempVariable(t,i){if(i==null){this.removeTempVariable(t);return}else g.tempStorage.set(t,i),g.storage.cache.set(t,i),g.tempStorageDeadlines.has(t)||g.tempStorageDeadlines.set(t,ft.openedLabels);}removeTempVariable(t){g.tempStorage.has(t)&&(g.tempStorage.delete(t),g.tempStorageDeadlines.delete(t),g.storage.cache.delete(t));}setFlag(t,i){return g.setFlag(t,i)}getFlag(t){return g.getFlag(t)}clear(){this.storage.clear(),this.cache.clear(),g.flags=[],g.tempStorage.clear(),g.tempStorageDeadlines.clear(),g.startingStorage.forEach(({key:t,value:i})=>{this.storage.set(t,i);});}export(){let t=[];[...this.storage.keys()].forEach(r=>{t.push({key:r,value:this.storage.get(r)});});let i=[];[...g.tempStorage.keys()].forEach(r=>{i.push({key:r,value:g.tempStorage.get(r)});});let s=[];return [...g.tempStorageDeadlines.keys()].forEach(r=>{s.push({key:r,value:g.tempStorageDeadlines.get(r)});}),Ft({base:t,temp:i,tempDeadlines:s,flags:g.flags})}restore(t){this.clear();try{t?(Array.isArray(t)&&t.forEach(i=>{if(i.key==="___temp_storage___"){let s=i.value;Object.entries(s).forEach(([r,n])=>{g.tempStorage.set(r,n);});}else if(i.key==="___temp_storage_deadlines___"){let s=i.value;Object.entries(s).forEach(([r,n])=>{g.tempStorageDeadlines.set(r,n);});}else i.key==="___flags___"?i.value.forEach(r=>{g.flags.push(r);}):this.storage.set(i.key,i.value);}),"base"in t&&"temp"in t&&"tempDeadlines"in t?(t.base?.forEach(i=>{this.storage.set(i.key,i.value);}),t.temp?.forEach(i=>{g.tempStorage.set(i.key,i.value);}),t.tempDeadlines?.forEach(i=>{g.tempStorageDeadlines.set(i.key,i.value);})):Object.entries(t).forEach(([i,s])=>{i==="___temp_storage___"?Object.entries(s).forEach(([r,n])=>{g.tempStorage.set(r,n);}):i==="___temp_storage_deadlines___"?Object.entries(s).forEach(([r,n])=>{g.tempStorageDeadlines.set(r,n);}):i==="___flags___"?s.forEach(r=>{g.flags.push(r);}):this.storage.set(i,s);})):T.warn("No storage data found");}catch(i){T.error("Error importing data",i);}}};var Mt=class{constructor(t,i){c(this,"_id");c(this,"categoryId");this.categoryId=t,this._id=i;}get id(){return this._id}setStorageProperty(t,i){let s=g.getVariable(this.categoryId);s||(s={}),s.hasOwnProperty(this.id)||(s[this.id]={}),i==null?s[this.id].hasOwnProperty(t)&&delete s[this.id][t]:s[this.id]={...s[this.id],[t]:i},Object.keys(s[this.id]).length===0&&delete s[this.id],g.setVariable(this.categoryId,s);}getStorageProperty(t,i=this.id){let s=g.getVariable(this.categoryId);if(s&&s.hasOwnProperty(i)&&s[i].hasOwnProperty(t))return s[i][t]}};var Oe=new Gt;exports.StorageManagerStatic=g;exports.StoredClassModel=Mt;exports.storage=Oe;