@drincs/pixi-vn 1.8.25 → 1.9.0

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.
Files changed (53) hide show
  1. package/README.md +23 -1
  2. package/dist/{ContainerMemory-D2HtgX7w.d.cts → ContainerMemory-BpDgacyr.d.cts} +2 -15
  3. package/dist/{ContainerMemory-D2HtgX7w.d.ts → ContainerMemory-BpDgacyr.d.ts} +2 -15
  4. package/dist/{HistoryChoiceMenuOption-DVMD78W7.d.cts → HistoryChoiceMenuOption-BxMSXnyI.d.cts} +1 -1
  5. package/dist/{HistoryChoiceMenuOption-B8RfQz5H.d.ts → HistoryChoiceMenuOption-hSI4SHV-.d.ts} +1 -1
  6. package/dist/{HistoryGameState-CmjUtlkV.d.ts → HistoryGameState-C8ATx9K6.d.ts} +1 -1
  7. package/dist/{HistoryGameState-C28NcKKl.d.cts → HistoryGameState-CGfvq5iL.d.cts} +1 -1
  8. package/dist/{HistoryStep-G9dUn0Lf.d.cts → HistoryStep-WGB6nA4N.d.cts} +5 -0
  9. package/dist/{HistoryStep-G9dUn0Lf.d.ts → HistoryStep-WGB6nA4N.d.ts} +5 -0
  10. package/dist/{OpenedLabel-DLfFuZgk.d.ts → OpenedLabel-CmRdzTXP.d.ts} +1 -1
  11. package/dist/{OpenedLabel-BxfL31aQ.d.cts → OpenedLabel-Cmd675NI.d.cts} +1 -1
  12. package/dist/SoundGameState-C_6ZsQX6.d.cts +186 -0
  13. package/dist/SoundGameState-C_6ZsQX6.d.ts +186 -0
  14. package/dist/{StorageGameState-CtjNJpvE.d.cts → StorageGameState-C3PGrFPr.d.cts} +2 -2
  15. package/dist/{StorageGameState-BJy57o6K.d.ts → StorageGameState-jAexrJLj.d.ts} +2 -2
  16. package/dist/canvas.cjs +2 -2
  17. package/dist/canvas.d.cts +265 -24
  18. package/dist/canvas.d.ts +265 -24
  19. package/dist/canvas.mjs +2 -2
  20. package/dist/characters.cjs +1 -1
  21. package/dist/characters.mjs +1 -1
  22. package/dist/chunk-HD353M4B.mjs +1 -0
  23. package/dist/chunk-I7DOUH5V.mjs +1 -0
  24. package/dist/history.cjs +1 -1
  25. package/dist/history.d.cts +38 -15
  26. package/dist/history.d.ts +38 -15
  27. package/dist/history.mjs +1 -1
  28. package/dist/index.cjs +2 -2
  29. package/dist/index.d.cts +32 -34
  30. package/dist/index.d.ts +32 -34
  31. package/dist/index.mjs +2 -2
  32. package/dist/motion.cjs +1 -1
  33. package/dist/motion.mjs +1 -1
  34. package/dist/narration.cjs +2 -2
  35. package/dist/narration.d.cts +196 -52
  36. package/dist/narration.d.ts +196 -52
  37. package/dist/narration.mjs +2 -2
  38. package/dist/pixi/browser.js +115 -115
  39. package/dist/sound.cjs +1 -1
  40. package/dist/sound.d.cts +313 -6
  41. package/dist/sound.d.ts +313 -6
  42. package/dist/sound.mjs +1 -1
  43. package/dist/storage.cjs +1 -1
  44. package/dist/storage.d.cts +50 -3
  45. package/dist/storage.d.ts +50 -3
  46. package/dist/storage.mjs +1 -1
  47. package/dist/vite.cjs +2 -2
  48. package/dist/vite.mjs +2 -2
  49. package/package.json +2 -1
  50. package/dist/SoundManagerInterface-Dd0b88_N.d.cts +0 -436
  51. package/dist/SoundManagerInterface-Dd0b88_N.d.ts +0 -436
  52. package/dist/chunk-GIYMPXBT.mjs +0 -1
  53. package/dist/chunk-IWAXXFXE.mjs +0 -1
package/dist/history.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var core=require('@drincs/pixi-vn/core');var Yt=Object.defineProperty;var Wt=c=>{throw TypeError(c)};var Xt=(c,t,i)=>t in c?Yt(c,t,{enumerable:true,configurable:true,writable:true,value:i}):c[t]=i;var D=(c,t,i)=>Xt(c,typeof t!="symbol"?t+"":t,i),It=(c,t,i)=>t.has(c)||Wt("Cannot "+i);var e=(c,t,i)=>(It(c,t,"read from private field"),i?i.call(c):t.get(c)),b=(c,t,i)=>t.has(c)?Wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,i),u=(c,t,i,s)=>(It(c,t,"write to private field"),t.set(c,i),i),f=(c,t,i)=>(It(c,t,"access private method"),i);var Ot=(c,t,i,s)=>({set _(r){u(c,t,r);},get _(){return e(c,t,s)}});var Qt=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Kt=new Set,Lt=typeof process=="object"&&process?process:{},Pt=(c,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(c,t,i,s):console.error(`[${i}] ${t}: ${c}`);},Dt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Dt>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Dt=class{constructor(){t();}signal=new jt;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 c=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{c&&(c=false,Pt("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 Zt=c=>!Kt.has(c);var rt=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),$t=c=>rt(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(c){super(c),this.fill(0);}},et,gt,te=(et=class{heap;length;static create(t){let i=$t(t);if(!i)return [];u(et,gt,true);let s=new et(t,i);return u(et,gt,false),s}constructor(t,i){if(!e(et,gt))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]}},gt=new WeakMap,b(et,gt,false),et),Vt,Ut,P,k,$,ct,B,mt,St,q,T,J,E,x,y,L,W,z,F,Y,C,X,Q,j,V,Z,ht,M,bt,l,Mt,ft,st,Ht,U,qt,ut,vt,At,ot,nt,Gt,Ft,Ct,_,Rt,xt,at,kt,wt,Bt=(wt=class{constructor(t){b(this,l);b(this,P);b(this,k);b(this,$);b(this,ct);b(this,B);b(this,mt);b(this,St);b(this,q);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");b(this,T);b(this,J);b(this,E);b(this,x);b(this,y);b(this,L);b(this,W);b(this,z);b(this,F);b(this,Y);b(this,C);b(this,X);b(this,Q);b(this,j);b(this,V);b(this,Z);b(this,ht);b(this,M);b(this,bt);b(this,ft,()=>{});b(this,st,()=>{});b(this,Ht,()=>{});b(this,U,()=>false);b(this,ut,t=>{});b(this,vt,(t,i,s)=>{});b(this,At,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});D(this,Vt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:d,onInsert:g,disposeAfter:m,noDisposeOnSet:v,noUpdateTTL:K,maxSize:tt=0,maxEntrySize:H=0,sizeCalculation:w,fetchMethod:S,memoMethod:N,noDeleteOnFetchRejection:G,noDeleteOnStaleGet:I,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:_t,ignoreFetchAbort:pt,perf:dt}=t;if(dt!==void 0&&typeof dt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,q,dt??Qt),i!==0&&!rt(i))throw new TypeError("max option must be a nonnegative integer");let yt=i?$t(i):Array;if(!yt)throw new Error("invalid max value: "+i);if(u(this,P,i),u(this,k,tt),this.maxEntrySize=H||e(this,k),this.sizeCalculation=w,this.sizeCalculation){if(!e(this,k)&&!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(N!==void 0&&typeof N!="function")throw new TypeError("memoMethod must be a function if defined");if(u(this,St,N),S!==void 0&&typeof S!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,mt,S),u(this,ht,!!S),u(this,E,new Map),u(this,x,new Array(i).fill(void 0)),u(this,y,new Array(i).fill(void 0)),u(this,L,new yt(i)),u(this,W,new yt(i)),u(this,z,0),u(this,F,0),u(this,Y,te.create(i)),u(this,T,0),u(this,J,0),typeof d=="function"&&u(this,$,d),typeof g=="function"&&u(this,ct,g),typeof m=="function"?(u(this,B,m),u(this,C,[])):(u(this,B,void 0),u(this,C,void 0)),u(this,Z,!!e(this,$)),u(this,bt,!!e(this,ct)),u(this,M,!!e(this,B)),this.noDisposeOnSet=!!v,this.noUpdateTTL=!!K,this.noDeleteOnFetchRejection=!!G,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!_t,this.ignoreFetchAbort=!!pt,this.maxEntrySize!==0){if(e(this,k)!==0&&!rt(e(this,k)))throw new TypeError("maxSize must be a positive integer if specified");if(!rt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,l,qt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!I,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=rt(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!rt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,l,Mt).call(this);}if(e(this,P)===0&&this.ttl===0&&e(this,k)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,P)&&!e(this,k)){let Nt="LRU_CACHE_UNBOUNDED";Zt(Nt)&&(Kt.add(Nt),Pt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Nt,wt));}}get perf(){return e(this,q)}static unsafeExposeInternals(t){return {starts:e(t,Q),ttls:e(t,j),autopurgeTimers:e(t,V),sizes:e(t,X),keyMap:e(t,E),keyList:e(t,x),valList:e(t,y),next:e(t,L),prev:e(t,W),get head(){return e(t,z)},get tail(){return e(t,F)},free:e(t,Y),isBackgroundFetch:i=>{var s;return f(s=t,l,_).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return f(n=t,l,Ct).call(n,i,s,r,o)},moveToTail:i=>{var s;return f(s=t,l,xt).call(s,i)},indexes:i=>{var s;return f(s=t,l,ot).call(s,i)},rindexes:i=>{var s;return f(s=t,l,nt).call(s,i)},isStale:i=>{var s;return e(s=t,U).call(s,i)}}}get max(){return e(this,P)}get maxSize(){return e(this,k)}get calculatedSize(){return e(this,J)}get size(){return e(this,T)}get fetchMethod(){return e(this,mt)}get memoMethod(){return e(this,St)}get dispose(){return e(this,$)}get onInsert(){return e(this,ct)}get disposeAfter(){return e(this,B)}getRemainingTTL(t){return e(this,E).has(t)?1/0:0}*entries(){for(let t of f(this,l,ot).call(this))e(this,y)[t]!==void 0&&e(this,x)[t]!==void 0&&!f(this,l,_).call(this,e(this,y)[t])&&(yield [e(this,x)[t],e(this,y)[t]]);}*rentries(){for(let t of f(this,l,nt).call(this))e(this,y)[t]!==void 0&&e(this,x)[t]!==void 0&&!f(this,l,_).call(this,e(this,y)[t])&&(yield [e(this,x)[t],e(this,y)[t]]);}*keys(){for(let t of f(this,l,ot).call(this)){let i=e(this,x)[t];i!==void 0&&!f(this,l,_).call(this,e(this,y)[t])&&(yield i);}}*rkeys(){for(let t of f(this,l,nt).call(this)){let i=e(this,x)[t];i!==void 0&&!f(this,l,_).call(this,e(this,y)[t])&&(yield i);}}*values(){for(let t of f(this,l,ot).call(this))e(this,y)[t]!==void 0&&!f(this,l,_).call(this,e(this,y)[t])&&(yield e(this,y)[t]);}*rvalues(){for(let t of f(this,l,nt).call(this))e(this,y)[t]!==void 0&&!f(this,l,_).call(this,e(this,y)[t])&&(yield e(this,y)[t]);}[(Ut=Symbol.iterator,Vt=Symbol.toStringTag,Ut)](){return this.entries()}find(t,i={}){for(let s of f(this,l,ot).call(this)){let r=e(this,y)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,x)[s],this))return this.get(e(this,x)[s],i)}}forEach(t,i=this){for(let s of f(this,l,ot).call(this)){let r=e(this,y)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,x)[s],this);}}rforEach(t,i=this){for(let s of f(this,l,nt).call(this)){let r=e(this,y)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,x)[s],this);}}purgeStale(){let t=false;for(let i of f(this,l,nt).call(this,{allowStale:true}))e(this,U).call(this,i)&&(f(this,l,at).call(this,e(this,x)[i],"expire"),t=true);return t}info(t){let i=e(this,E).get(t);if(i===void 0)return;let s=e(this,y)[i],r=f(this,l,_).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,j)&&e(this,Q)){let n=e(this,j)[i],a=e(this,Q)[i];if(n&&a){let h=n-(e(this,q).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,X)&&(o.size=e(this,X)[i]),o}dump(){let t=[];for(let i of f(this,l,ot).call(this,{allowStale:true})){let s=e(this,x)[i],r=e(this,y)[i],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,j)&&e(this,Q)){n.ttl=e(this,j)[i];let a=e(this,q).now()-e(this,Q)[i];n.start=Math.floor(Date.now()-a);}e(this,X)&&(n.size=e(this,X)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,q).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var v,K,tt,H;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,g=e(this,At).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&g>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),f(this,l,at).call(this,t,"set"),this;let m=e(this,T)===0?void 0:e(this,E).get(t);if(m===void 0)m=e(this,T)===0?e(this,F):e(this,Y).length!==0?e(this,Y).pop():e(this,T)===e(this,P)?f(this,l,Ft).call(this,false):e(this,T),e(this,x)[m]=t,e(this,y)[m]=i,e(this,E).set(t,m),e(this,L)[e(this,F)]=m,e(this,W)[m]=e(this,F),u(this,F,m),Ot(this,T)._++,e(this,vt).call(this,m,g,h),h&&(h.set="add"),d=false,e(this,bt)&&((v=e(this,ct))==null||v.call(this,i,t,"add"));else {f(this,l,xt).call(this,m);let w=e(this,y)[m];if(i!==w){if(e(this,ht)&&f(this,l,_).call(this,w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:S}=w;S!==void 0&&!n&&(e(this,Z)&&((K=e(this,$))==null||K.call(this,S,t,"set")),e(this,M)&&e(this,C)?.push([S,t,"set"]));}else n||(e(this,Z)&&((tt=e(this,$))==null||tt.call(this,w,t,"set")),e(this,M)&&e(this,C)?.push([w,t,"set"]));if(e(this,ut).call(this,m),e(this,vt).call(this,m,g,h),e(this,y)[m]=i,h){h.set="replace";let S=w&&f(this,l,_).call(this,w)?w.__staleWhileFetching:w;S!==void 0&&(h.oldValue=S);}}else h&&(h.set="update");e(this,bt)&&this.onInsert?.(i,t,i===w?"update":"replace");}if(r!==0&&!e(this,j)&&f(this,l,Mt).call(this),e(this,j)&&(d||e(this,Ht).call(this,m,r,o),h&&e(this,st).call(this,h,m)),!n&&e(this,M)&&e(this,C)){let w=e(this,C),S;for(;S=w?.shift();)(H=e(this,B))==null||H.call(this,...S);}return this}pop(){var t;try{for(;e(this,T);){let i=e(this,y)[e(this,z)];if(f(this,l,Ft).call(this,!0),f(this,l,_).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,M)&&e(this,C)){let i=e(this,C),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,o=e(this,E).get(t);if(o!==void 0){let n=e(this,y)[o];if(f(this,l,_).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,U).call(this,o))r&&(r.has="stale",e(this,st).call(this,r,o));else return s&&e(this,ft).call(this,o),r&&(r.has="hit",e(this,st).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,E).get(t);if(r===void 0||!s&&e(this,U).call(this,r))return;let o=e(this,y)[r];return f(this,l,_).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:g=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:v=this.allowStaleOnFetchRejection,ignoreFetchAbort:K=this.ignoreFetchAbort,allowStaleOnFetchAbort:tt=this.allowStaleOnFetchAbort,context:H,forceRefresh:w=false,status:S,signal:N}=i;if(!e(this,ht))return S&&(S.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:S});let G={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:d,noUpdateTTL:g,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:tt,ignoreFetchAbort:K,status:S,signal:N},I=e(this,E).get(t);if(I===void 0){S&&(S.fetch="miss");let A=f(this,l,Ct).call(this,t,I,G,H);return A.__returned=A}else {let A=e(this,y)[I];if(f(this,l,_).call(this,A)){let yt=s&&A.__staleWhileFetching!==void 0;return S&&(S.fetch="inflight",yt&&(S.returnedStale=true)),yt?A.__staleWhileFetching:A.__returned=A}let _t=e(this,U).call(this,I);if(!w&&!_t)return S&&(S.fetch="hit"),f(this,l,xt).call(this,I),r&&e(this,ft).call(this,I),S&&e(this,st).call(this,S,I),A;let pt=f(this,l,Ct).call(this,t,I,G,H),dt=pt.__staleWhileFetching!==void 0&&s;return S&&(S.fetch=_t?"stale":"refresh",dt&&_t&&(S.returnedStale=true)),dt?pt.__staleWhileFetching:pt.__returned=pt}}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:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,E).get(t);if(a!==void 0){let h=e(this,y)[a],d=f(this,l,_).call(this,h);return n&&e(this,st).call(this,n,a),e(this,U).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||f(this,l,at).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),d?h.__staleWhileFetching:(f(this,l,xt).call(this,a),r&&e(this,ft).call(this,a),h))}else n&&(n.get="miss");}delete(t){return f(this,l,at).call(this,t,"delete")}clear(){return f(this,l,kt).call(this,"delete")}},P=new WeakMap,k=new WeakMap,$=new WeakMap,ct=new WeakMap,B=new WeakMap,mt=new WeakMap,St=new WeakMap,q=new WeakMap,T=new WeakMap,J=new WeakMap,E=new WeakMap,x=new WeakMap,y=new WeakMap,L=new WeakMap,W=new WeakMap,z=new WeakMap,F=new WeakMap,Y=new WeakMap,C=new WeakMap,X=new WeakMap,Q=new WeakMap,j=new WeakMap,V=new WeakMap,Z=new WeakMap,ht=new WeakMap,M=new WeakMap,bt=new WeakMap,l=new WeakSet,Mt=function(){let t=new Tt(e(this,P)),i=new Tt(e(this,P));u(this,j,t),u(this,Q,i);let s=this.ttlAutopurge?new Array(e(this,P)):void 0;u(this,V,s),u(this,Ht,(a,h,d=e(this,q).now())=>{i[a]=h!==0?d:0,t[a]=h,r(a,h);}),u(this,ft,a=>{i[a]=t[a]!==0?e(this,q).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,h)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h&&h!==0&&s){let d=setTimeout(()=>{e(this,U).call(this,a)&&f(this,l,at).call(this,e(this,x)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};u(this,st,(a,h)=>{if(t[h]){let d=t[h],g=i[h];if(!d||!g)return;a.ttl=d,a.start=g,a.now=o||n();let m=a.now-g;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,q).now();if(this.ttlResolution>0){o=a;let h=setTimeout(()=>o=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=e(this,E).get(a);if(h===void 0)return 0;let d=t[h],g=i[h];if(!d||!g)return 1/0;let m=(o||n())-g;return d-m},u(this,U,a=>{let h=i[a],d=t[a];return !!d&&!!h&&(o||n())-h>d});},ft=new WeakMap,st=new WeakMap,Ht=new WeakMap,U=new WeakMap,qt=function(){let t=new Tt(e(this,P));u(this,J,0),u(this,X,t),u(this,ut,i=>{u(this,J,e(this,J)-t[i]),t[i]=0;}),u(this,At,(i,s,r,o)=>{if(f(this,l,_).call(this,s))return 0;if(!rt(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!rt(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,vt,(i,s,r)=>{if(t[i]=s,e(this,k)){let o=e(this,k)-t[i];for(;e(this,J)>o;)f(this,l,Ft).call(this,true);}u(this,J,e(this,J)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,J));});},ut=new WeakMap,vt=new WeakMap,At=new WeakMap,ot=function*({allowStale:t=this.allowStale}={}){if(e(this,T))for(let i=e(this,F);!(!f(this,l,Gt).call(this,i)||((t||!e(this,U).call(this,i))&&(yield i),i===e(this,z)));)i=e(this,W)[i];},nt=function*({allowStale:t=this.allowStale}={}){if(e(this,T))for(let i=e(this,z);!(!f(this,l,Gt).call(this,i)||((t||!e(this,U).call(this,i))&&(yield i),i===e(this,F)));)i=e(this,L)[i];},Gt=function(t){return t!==void 0&&e(this,E).get(e(this,x)[t])===t},Ft=function(t){var o;let i=e(this,z),s=e(this,x)[i],r=e(this,y)[i];return e(this,ht)&&f(this,l,_).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,Z)||e(this,M))&&(e(this,Z)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,M)&&e(this,C)?.push([r,s,"evict"])),e(this,ut).call(this,i),e(this,V)?.[i]&&(clearTimeout(e(this,V)[i]),e(this,V)[i]=void 0),t&&(e(this,x)[i]=void 0,e(this,y)[i]=void 0,e(this,Y).push(i)),e(this,T)===1?(u(this,z,u(this,F,0)),e(this,Y).length=0):u(this,z,e(this,L)[i]),e(this,E).delete(s),Ot(this,T)._--,i},Ct=function(t,i,s,r){let o=i===void 0?void 0:e(this,y)[i];if(f(this,l,_).call(this,o))return o;let n=new Dt,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},d=(H,w=false)=>{let{aborted:S}=n.signal,N=s.ignoreFetchAbort&&H!==void 0,G=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&H!==void 0);if(s.status&&(S&&!w?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,N&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),S&&!N&&!w)return m(n.signal.reason,G);let I=K,A=e(this,y)[i];return (A===K||N&&w&&A===void 0)&&(H===void 0?I.__staleWhileFetching!==void 0?e(this,y)[i]=I.__staleWhileFetching:f(this,l,at).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,H,h.options))),H},g=H=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=H),m(H,false)),m=(H,w)=>{let{aborted:S}=n.signal,N=S&&s.allowStaleOnFetchAbort,G=N||s.allowStaleOnFetchRejection,I=G||s.noDeleteOnFetchRejection,A=K;if(e(this,y)[i]===K&&(!I||!w&&A.__staleWhileFetching===void 0?f(this,l,at).call(this,t,"fetch"):N||(e(this,y)[i]=A.__staleWhileFetching)),G)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw H},v=(H,w)=>{var N;let S=(N=e(this,mt))==null?void 0:N.call(this,t,o,h);S&&S instanceof Promise&&S.then(G=>H(G===void 0?void 0:G),w),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(H(void 0),s.allowStaleOnFetchAbort&&(H=G=>d(G,true)));});};s.status&&(s.status.fetchDispatched=true);let K=new Promise(v).then(d,g),tt=Object.assign(K,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,tt,{...h.options,status:void 0}),i=e(this,E).get(t)):e(this,y)[i]=tt,tt},_=function(t){if(!e(this,ht))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Dt},Rt=function(t,i){e(this,W)[i]=t,e(this,L)[t]=i;},xt=function(t){t!==e(this,F)&&(t===e(this,z)?u(this,z,e(this,L)[t]):f(this,l,Rt).call(this,e(this,W)[t],e(this,L)[t]),f(this,l,Rt).call(this,e(this,F),t),u(this,F,t));},at=function(t,i){var r,o;let s=false;if(e(this,T)!==0){let n=e(this,E).get(t);if(n!==void 0)if(e(this,V)?.[n]&&(clearTimeout(e(this,V)?.[n]),e(this,V)[n]=void 0),s=true,e(this,T)===1)f(this,l,kt).call(this,i);else {e(this,ut).call(this,n);let a=e(this,y)[n];if(f(this,l,_).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,Z)||e(this,M))&&(e(this,Z)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,M)&&e(this,C)?.push([a,t,i])),e(this,E).delete(t),e(this,x)[n]=void 0,e(this,y)[n]=void 0,n===e(this,F))u(this,F,e(this,W)[n]);else if(n===e(this,z))u(this,z,e(this,L)[n]);else {let h=e(this,W)[n];e(this,L)[h]=e(this,L)[n];let d=e(this,L)[n];e(this,W)[d]=e(this,W)[n];}Ot(this,T)._--,e(this,Y).push(n);}}if(e(this,M)&&e(this,C)?.length){let n=e(this,C),a;for(;a=n?.shift();)(o=e(this,B))==null||o.call(this,...a);}return s},kt=function(t){var i,s;for(let r of f(this,l,nt).call(this,{allowStale:true})){let o=e(this,y)[r];if(f(this,l,_).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,x)[r];e(this,Z)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,M)&&e(this,C)?.push([o,n,t]);}}if(e(this,E).clear(),e(this,y).fill(void 0),e(this,x).fill(void 0),e(this,j)&&e(this,Q)){e(this,j).fill(0),e(this,Q).fill(0);for(let r of e(this,V)??[])r!==void 0&&clearTimeout(r);e(this,V)?.fill(void 0);}if(e(this,X)&&e(this,X).fill(0),u(this,z,0),u(this,F,0),e(this,Y).length=0,u(this,J,0),u(this,T,0),e(this,M)&&e(this,C)){let r=e(this,C),o;for(;o=r?.shift();)(s=e(this,B))==null||s.call(this,...o);}},wt);var lt=class{cache;map=new Map;constructor(t){this.cache=new Bt({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 O;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(O||={});function it(c){try{if(typeof c>"u")return c;let t=JSON.stringify(c);return JSON.parse(t)}catch(t){throw O.error("Error creating exportable element",c,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var p=class c{static _diffHistory=new lt({cacheSize:5});static _stepsInfoHistory=new lt({cacheSize:5});static _narrationHistory=new lt({cacheSize:50});static stepLimitSaved=20;static _originalStepData=void 0;static get originalStepData(){return c._originalStepData?it(c._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){c._originalStepData=it(t);}};function Jt(c,t){let i=it(c);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(s=>{ie(i,s);}),i}function ie(c,t){let i=c;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):O.warn("No path found, skipping diff",t);}var se={Date:true,RegExp:true,String:true,Number:true};function zt(c,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(c);for(let a in c){let h=c[a],d=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[d],oldValue:c[a]});continue}let g=t[a],m=typeof h=="object"&&typeof g=="object"&&Array.isArray(h)===Array.isArray(g);h&&g&&m&&!se[Object.getPrototypeOf(h)?.constructor?.name]&&(!i.cyclesFix||!s.includes(h))?r.push.apply(r,zt(h,g,i,i.cyclesFix?s.concat([h]):[]).map(v=>(v.path.unshift(d),v))):h!==g&&!(Number.isNaN(h)&&Number.isNaN(g))&&!(m&&(isNaN(h)?h+""==g+"":+h==+g))&&r.push({path:[d],type:"CHANGE",value:g,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in c||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var Et=class{get stepsInfoMap(){return p._stepsInfoHistory}get diffMap(){return p._diffHistory}get narrationMap(){return p._narrationHistory}get size(){return p._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return p._stepsInfoHistory.keys()}get(t){let i=p._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){p._stepsInfoHistory.delete(t),p._diffHistory.delete(t),p._narrationHistory.delete(t);}getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastKey;if(typeof s!="number")return O.warn("You can't go back, there is no step to go back"),i;let r=p._diffHistory.get(s);if(r)try{let o=Jt(i,r);return core.GameUnifier.stepCounter=s,this.delete(s),this.getOldGameState(t-1,o)}catch(o){return O.error("Error applying diff",o),i}else return O.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){O.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){O.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(p._diffHistory.size<1){O.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{let r=it(this.getOldGameState(s,p.originalStepData));if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate);let o=core.GameUnifier.stepCounter-1,n=p._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=p._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});p._narrationHistory.set(a.index,h);}}}else O.error("Error going back");p.originalStepData=r;}catch(r){O.error("Error going back",r);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}add(t,i={}){let s=p.originalStepData,{ignoreSameStep:r}=i,o=core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey;(async()=>{try{let h,d;if(typeof n=="number"&&(h=p._stepsInfoHistory.get(n),d=p._narrationHistory.get(n)),p._stepsInfoHistory.set(t.index,t),t.index!==0){let v=zt(s,o);v?p._diffHistory.set(t.index,v):O.warn("It was not possible to create the difference between the two steps");}let g={},m=this.itemMapper({step:t},g);if(p._narrationHistory.set(t.index,m),h&&d&&typeof n=="number"){let v=this.itemMapper({...g,step:h},{});p._narrationHistory.set(n,v);}}catch(h){O.error("Error adding history step",h);}})(),p.originalStepData=o;}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let d=h?.map((g,m)=>{let v=false;return g.oneTime&&s.alreadyMadeChoices?.includes(m)&&(v=true),{text:g.text,type:g.type,isResponse:false,hidden:v}});if(d){if(d.every(g=>g.hidden)){let g=d.find(m=>m.hidden===false);g&&(g.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o,openedLabelsNumber:s.openedLabels?.length}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((h,d)=>d-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=p._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,d)=>{let g=this.get(h);if(g){if(d===0)return t.push(g),true;let m=p._stepsInfoHistory.get(h);if(!m)return true;let v=m.openedLabels;if(!v||!Array.isArray(v)||v.length===0||v[0].label!==a||v[0].currentStepIndex>n)return false;n=v[0].currentStepIndex,t.push(g);}return true}),t.reverse()}get currentPageParagraphs(){let t=[],i;return this.currentLabelHistory.forEach(s=>{t.length===0||s.openedLabelsNumber!==i?t.push([s]):t[t.length-1].push(s),i=s.openedLabelsNumber;}),t}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{p._narrationHistory.delete(s),p._stepsInfoHistory.delete(s),p._diffHistory.delete(s);});}else p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear();}get canGoBack(){let t=this.lastKey;return typeof t!="number"?false:p._diffHistory.has(t)}blockGoBack(){core.GameUnifier.runningStepsCount===0&&p._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return O.error("Error comparing opened labels",s),true}return false}clear(){p._stepsInfoHistory.clear(),p._diffHistory.clear(),p._narrationHistory.clear(),p._originalStepData=void 0;}get stepLimitSaved(){return p.stepLimitSaved}set stepLimitSaved(t){p.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];return t.forEach(s=>{let r=p._stepsInfoHistory.get(s);if(r){let o=p._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:it(i),originalStepData:it(p._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=p._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&p._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{Object.hasOwn(t,"stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&p._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};p._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):O.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?p._originalStepData=t.originalStepData:O.warn("Could not import originalStepData data, so will be ignored");}catch(i){O.error("Error importing data",i);}}};var Le=new Et;exports.HistoryManagerStatic=p;exports.stepHistory=Le;
1
+ 'use strict';var core=require('@drincs/pixi-vn/core');var Qt=Object.defineProperty;var Wt=c=>{throw TypeError(c)};var Zt=(c,t,i)=>t in c?Qt(c,t,{enumerable:true,configurable:true,writable:true,value:i}):c[t]=i;var M=(c,t,i)=>Zt(c,typeof t!="symbol"?t+"":t,i),zt=(c,t,i)=>t.has(c)||Wt("Cannot "+i);var e=(c,t,i)=>(zt(c,t,"read from private field"),i?i.call(c):t.get(c)),S=(c,t,i)=>t.has(c)?Wt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(c):t.set(c,i),p=(c,t,i,s)=>(zt(c,t,"write to private field"),t.set(c,i),i),f=(c,t,i)=>(zt(c,t,"access private method"),i);var Ot=(c,t,i,s)=>({set _(r){p(c,t,r);},get _(){return e(c,t,s)}});var te=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Kt=new Set,Lt=typeof process=="object"&&process?process:{},Pt=(c,t,i,s)=>{typeof Lt.emitWarning=="function"?Lt.emitWarning(c,t,i,s):console.error(`[${i}] ${t}: ${c}`);},Dt=globalThis.AbortController,jt=globalThis.AbortSignal;if(typeof Dt>"u"){jt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Dt=class{constructor(){t();}signal=new jt;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 c=Lt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",t=()=>{c&&(c=false,Pt("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 ee=c=>!Kt.has(c);var st=c=>c&&c===Math.floor(c)&&c>0&&isFinite(c),Bt=c=>st(c)?c<=Math.pow(2,8)?Uint8Array:c<=Math.pow(2,16)?Uint16Array:c<=Math.pow(2,32)?Uint32Array:c<=Number.MAX_SAFE_INTEGER?Tt:null:null,Tt=class extends Array{constructor(c){super(c),this.fill(0);}},et,yt,ie=(et=class{heap;length;static create(t){let i=Bt(t);if(!i)return [];p(et,yt,true);let s=new et(t,i);return p(et,yt,false),s}constructor(t,i){if(!e(et,yt))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]}},yt=new WeakMap,S(et,yt,false),et),Vt,Ut,B,j,$,lt,q,gt,mt,J,C,Y,E,x,g,G,V,k,F,X,D,Q,Z,U,K,tt,at,I,bt,l,Gt,ct,it,Ht,P,qt,ft,St,At,rt,ot,It,Ct,Ft,_,Rt,xt,nt,Nt,vt,$t=(vt=class{constructor(t){S(this,l);S(this,B);S(this,j);S(this,$);S(this,lt);S(this,q);S(this,gt);S(this,mt);S(this,J);M(this,"ttl");M(this,"ttlResolution");M(this,"ttlAutopurge");M(this,"updateAgeOnGet");M(this,"updateAgeOnHas");M(this,"allowStale");M(this,"noDisposeOnSet");M(this,"noUpdateTTL");M(this,"maxEntrySize");M(this,"sizeCalculation");M(this,"noDeleteOnFetchRejection");M(this,"noDeleteOnStaleGet");M(this,"allowStaleOnFetchAbort");M(this,"allowStaleOnFetchRejection");M(this,"ignoreFetchAbort");S(this,C);S(this,Y);S(this,E);S(this,x);S(this,g);S(this,G);S(this,V);S(this,k);S(this,F);S(this,X);S(this,D);S(this,Q);S(this,Z);S(this,U);S(this,K);S(this,tt);S(this,at);S(this,I);S(this,bt);S(this,ct,()=>{});S(this,it,()=>{});S(this,Ht,()=>{});S(this,P,()=>false);S(this,ft,t=>{});S(this,St,(t,i,s)=>{});S(this,At,(t,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});M(this,Vt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:o,updateAgeOnGet:n,updateAgeOnHas:a,allowStale:h,dispose:d,onInsert:y,disposeAfter:m,noDisposeOnSet:v,noUpdateTTL:T,maxSize:W=0,maxEntrySize:H=0,sizeCalculation:w,fetchMethod:b,memoMethod:z,noDeleteOnFetchRejection:R,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:A,allowStaleOnFetchAbort:_t,ignoreFetchAbort:ut,perf:pt}=t;if(pt!==void 0&&typeof pt?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(p(this,J,pt??te),i!==0&&!st(i))throw new TypeError("max option must be a nonnegative integer");let dt=i?Bt(i):Array;if(!dt)throw new Error("invalid max value: "+i);if(p(this,B,i),p(this,j,W),this.maxEntrySize=H||e(this,j),this.sizeCalculation=w,this.sizeCalculation){if(!e(this,j)&&!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(z!==void 0&&typeof z!="function")throw new TypeError("memoMethod must be a function if defined");if(p(this,mt,z),b!==void 0&&typeof b!="function")throw new TypeError("fetchMethod must be a function if specified");if(p(this,gt,b),p(this,at,!!b),p(this,E,new Map),p(this,x,new Array(i).fill(void 0)),p(this,g,new Array(i).fill(void 0)),p(this,G,new dt(i)),p(this,V,new dt(i)),p(this,k,0),p(this,F,0),p(this,X,ie.create(i)),p(this,C,0),p(this,Y,0),typeof d=="function"&&p(this,$,d),typeof y=="function"&&p(this,lt,y),typeof m=="function"?(p(this,q,m),p(this,D,[])):(p(this,q,void 0),p(this,D,void 0)),p(this,tt,!!e(this,$)),p(this,bt,!!e(this,lt)),p(this,I,!!e(this,q)),this.noDisposeOnSet=!!v,this.noUpdateTTL=!!T,this.noDeleteOnFetchRejection=!!R,this.allowStaleOnFetchRejection=!!A,this.allowStaleOnFetchAbort=!!_t,this.ignoreFetchAbort=!!ut,this.maxEntrySize!==0){if(e(this,j)!==0&&!st(e(this,j)))throw new TypeError("maxSize must be a positive integer if specified");if(!st(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,l,qt).call(this);}if(this.allowStale=!!h,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!n,this.updateAgeOnHas=!!a,this.ttlResolution=st(r)||r===0?r:1,this.ttlAutopurge=!!o,this.ttl=s||0,this.ttl){if(!st(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,l,Gt).call(this);}if(e(this,B)===0&&this.ttl===0&&e(this,j)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!e(this,B)&&!e(this,j)){let kt="LRU_CACHE_UNBOUNDED";ee(kt)&&(Kt.add(kt),Pt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",kt,vt));}}get perf(){return e(this,J)}static unsafeExposeInternals(t){return {starts:e(t,Z),ttls:e(t,U),autopurgeTimers:e(t,K),sizes:e(t,Q),keyMap:e(t,E),keyList:e(t,x),valList:e(t,g),next:e(t,G),prev:e(t,V),get head(){return e(t,k)},get tail(){return e(t,F)},free:e(t,X),isBackgroundFetch:i=>{var s;return f(s=t,l,_).call(s,i)},backgroundFetch:(i,s,r,o)=>{var n;return f(n=t,l,Ft).call(n,i,s,r,o)},moveToTail:i=>{var s;return f(s=t,l,xt).call(s,i)},indexes:i=>{var s;return f(s=t,l,rt).call(s,i)},rindexes:i=>{var s;return f(s=t,l,ot).call(s,i)},isStale:i=>{var s;return e(s=t,P).call(s,i)}}}get max(){return e(this,B)}get maxSize(){return e(this,j)}get calculatedSize(){return e(this,Y)}get size(){return e(this,C)}get fetchMethod(){return e(this,gt)}get memoMethod(){return e(this,mt)}get dispose(){return e(this,$)}get onInsert(){return e(this,lt)}get disposeAfter(){return e(this,q)}getRemainingTTL(t){return e(this,E).has(t)?1/0:0}*entries(){for(let t of f(this,l,rt).call(this))e(this,g)[t]!==void 0&&e(this,x)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield [e(this,x)[t],e(this,g)[t]]);}*rentries(){for(let t of f(this,l,ot).call(this))e(this,g)[t]!==void 0&&e(this,x)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield [e(this,x)[t],e(this,g)[t]]);}*keys(){for(let t of f(this,l,rt).call(this)){let i=e(this,x)[t];i!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield i);}}*rkeys(){for(let t of f(this,l,ot).call(this)){let i=e(this,x)[t];i!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield i);}}*values(){for(let t of f(this,l,rt).call(this))e(this,g)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}*rvalues(){for(let t of f(this,l,ot).call(this))e(this,g)[t]!==void 0&&!f(this,l,_).call(this,e(this,g)[t])&&(yield e(this,g)[t]);}[(Ut=Symbol.iterator,Vt=Symbol.toStringTag,Ut)](){return this.entries()}find(t,i={}){for(let s of f(this,l,rt).call(this)){let r=e(this,g)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;if(o!==void 0&&t(o,e(this,x)[s],this))return this.get(e(this,x)[s],i)}}forEach(t,i=this){for(let s of f(this,l,rt).call(this)){let r=e(this,g)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,x)[s],this);}}rforEach(t,i=this){for(let s of f(this,l,ot).call(this)){let r=e(this,g)[s],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;o!==void 0&&t.call(i,o,e(this,x)[s],this);}}purgeStale(){let t=false;for(let i of f(this,l,ot).call(this,{allowStale:true}))e(this,P).call(this,i)&&(f(this,l,nt).call(this,e(this,x)[i],"expire"),t=true);return t}info(t){let i=e(this,E).get(t);if(i===void 0)return;let s=e(this,g)[i],r=f(this,l,_).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let o={value:r};if(e(this,U)&&e(this,Z)){let n=e(this,U)[i],a=e(this,Z)[i];if(n&&a){let h=n-(e(this,J).now()-a);o.ttl=h,o.start=Date.now();}}return e(this,Q)&&(o.size=e(this,Q)[i]),o}dump(){let t=[];for(let i of f(this,l,rt).call(this,{allowStale:true})){let s=e(this,x)[i],r=e(this,g)[i],o=f(this,l,_).call(this,r)?r.__staleWhileFetching:r;if(o===void 0||s===void 0)continue;let n={value:o};if(e(this,U)&&e(this,Z)){n.ttl=e(this,U)[i];let a=e(this,J).now()-e(this,Z)[i];n.start=Math.floor(Date.now()-a);}e(this,Q)&&(n.size=e(this,Q)[i]),t.unshift([s,n]);}return t}load(t){this.clear();for(let[i,s]of t){if(s.start){let r=Date.now()-s.start;s.start=e(this,J).now()-r;}this.set(i,s.value,s);}}set(t,i,s={}){var v,T,W,H;if(i===void 0)return this.delete(t),this;let{ttl:r=this.ttl,start:o,noDisposeOnSet:n=this.noDisposeOnSet,sizeCalculation:a=this.sizeCalculation,status:h}=s,{noUpdateTTL:d=this.noUpdateTTL}=s,y=e(this,At).call(this,t,i,s.size||0,a);if(this.maxEntrySize&&y>this.maxEntrySize)return h&&(h.set="miss",h.maxEntrySizeExceeded=true),f(this,l,nt).call(this,t,"set"),this;let m=e(this,C)===0?void 0:e(this,E).get(t);if(m===void 0)m=e(this,C)===0?e(this,F):e(this,X).length!==0?e(this,X).pop():e(this,C)===e(this,B)?f(this,l,Ct).call(this,false):e(this,C),e(this,x)[m]=t,e(this,g)[m]=i,e(this,E).set(t,m),e(this,G)[e(this,F)]=m,e(this,V)[m]=e(this,F),p(this,F,m),Ot(this,C)._++,e(this,St).call(this,m,y,h),h&&(h.set="add"),d=false,e(this,bt)&&((v=e(this,lt))==null||v.call(this,i,t,"add"));else {f(this,l,xt).call(this,m);let w=e(this,g)[m];if(i!==w){if(e(this,at)&&f(this,l,_).call(this,w)){w.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:b}=w;b!==void 0&&!n&&(e(this,tt)&&((T=e(this,$))==null||T.call(this,b,t,"set")),e(this,I)&&e(this,D)?.push([b,t,"set"]));}else n||(e(this,tt)&&((W=e(this,$))==null||W.call(this,w,t,"set")),e(this,I)&&e(this,D)?.push([w,t,"set"]));if(e(this,ft).call(this,m),e(this,St).call(this,m,y,h),e(this,g)[m]=i,h){h.set="replace";let b=w&&f(this,l,_).call(this,w)?w.__staleWhileFetching:w;b!==void 0&&(h.oldValue=b);}}else h&&(h.set="update");e(this,bt)&&this.onInsert?.(i,t,i===w?"update":"replace");}if(r!==0&&!e(this,U)&&f(this,l,Gt).call(this),e(this,U)&&(d||e(this,Ht).call(this,m,r,o),h&&e(this,it).call(this,h,m)),!n&&e(this,I)&&e(this,D)){let w=e(this,D),b;for(;b=w?.shift();)(H=e(this,q))==null||H.call(this,...b);}return this}pop(){var t;try{for(;e(this,C);){let i=e(this,g)[e(this,k)];if(f(this,l,Ct).call(this,!0),f(this,l,_).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(e(this,I)&&e(this,D)){let i=e(this,D),s;for(;s=i?.shift();)(t=e(this,q))==null||t.call(this,...s);}}}has(t,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,o=e(this,E).get(t);if(o!==void 0){let n=e(this,g)[o];if(f(this,l,_).call(this,n)&&n.__staleWhileFetching===void 0)return false;if(e(this,P).call(this,o))r&&(r.has="stale",e(this,it).call(this,r,o));else return s&&e(this,ct).call(this,o),r&&(r.has="hit",e(this,it).call(this,r,o)),true}else r&&(r.has="miss");return false}peek(t,i={}){let{allowStale:s=this.allowStale}=i,r=e(this,E).get(t);if(r===void 0||!s&&e(this,P).call(this,r))return;let o=e(this,g)[r];return f(this,l,_).call(this,o)?o.__staleWhileFetching:o}async fetch(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,ttl:n=this.ttl,noDisposeOnSet:a=this.noDisposeOnSet,size:h=0,sizeCalculation:d=this.sizeCalculation,noUpdateTTL:y=this.noUpdateTTL,noDeleteOnFetchRejection:m=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:v=this.allowStaleOnFetchRejection,ignoreFetchAbort:T=this.ignoreFetchAbort,allowStaleOnFetchAbort:W=this.allowStaleOnFetchAbort,context:H,forceRefresh:w=false,status:b,signal:z}=i;if(!e(this,at))return b&&(b.fetch="get"),this.get(t,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,status:b});let R={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:o,ttl:n,noDisposeOnSet:a,size:h,sizeCalculation:d,noUpdateTTL:y,noDeleteOnFetchRejection:m,allowStaleOnFetchRejection:v,allowStaleOnFetchAbort:W,ignoreFetchAbort:T,status:b,signal:z},L=e(this,E).get(t);if(L===void 0){b&&(b.fetch="miss");let A=f(this,l,Ft).call(this,t,L,R,H);return A.__returned=A}else {let A=e(this,g)[L];if(f(this,l,_).call(this,A)){let dt=s&&A.__staleWhileFetching!==void 0;return b&&(b.fetch="inflight",dt&&(b.returnedStale=true)),dt?A.__staleWhileFetching:A.__returned=A}let _t=e(this,P).call(this,L);if(!w&&!_t)return b&&(b.fetch="hit"),f(this,l,xt).call(this,L),r&&e(this,ct).call(this,L),b&&e(this,it).call(this,b,L),A;let ut=f(this,l,Ft).call(this,t,L,R,H),pt=ut.__staleWhileFetching!==void 0&&s;return b&&(b.fetch=_t?"stale":"refresh",pt&&_t&&(b.returnedStale=true)),pt?ut.__staleWhileFetching:ut.__returned=ut}}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,mt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:o,...n}=i,a=this.get(t,n);if(!o&&a!==void 0)return a;let h=s(t,a,{options:n,context:r});return this.set(t,h,n),h}get(t,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:o=this.noDeleteOnStaleGet,status:n}=i,a=e(this,E).get(t);if(a!==void 0){let h=e(this,g)[a],d=f(this,l,_).call(this,h);return n&&e(this,it).call(this,n,a),e(this,P).call(this,a)?(n&&(n.get="stale"),d?(n&&s&&h.__staleWhileFetching!==void 0&&(n.returnedStale=true),s?h.__staleWhileFetching:void 0):(o||f(this,l,nt).call(this,t,"expire"),n&&s&&(n.returnedStale=true),s?h:void 0)):(n&&(n.get="hit"),d?h.__staleWhileFetching:(f(this,l,xt).call(this,a),r&&e(this,ct).call(this,a),h))}else n&&(n.get="miss");}delete(t){return f(this,l,nt).call(this,t,"delete")}clear(){return f(this,l,Nt).call(this,"delete")}},B=new WeakMap,j=new WeakMap,$=new WeakMap,lt=new WeakMap,q=new WeakMap,gt=new WeakMap,mt=new WeakMap,J=new WeakMap,C=new WeakMap,Y=new WeakMap,E=new WeakMap,x=new WeakMap,g=new WeakMap,G=new WeakMap,V=new WeakMap,k=new WeakMap,F=new WeakMap,X=new WeakMap,D=new WeakMap,Q=new WeakMap,Z=new WeakMap,U=new WeakMap,K=new WeakMap,tt=new WeakMap,at=new WeakMap,I=new WeakMap,bt=new WeakMap,l=new WeakSet,Gt=function(){let t=new Tt(e(this,B)),i=new Tt(e(this,B));p(this,U,t),p(this,Z,i);let s=this.ttlAutopurge?new Array(e(this,B)):void 0;p(this,K,s),p(this,Ht,(a,h,d=e(this,J).now())=>{i[a]=h!==0?d:0,t[a]=h,r(a,h);}),p(this,ct,a=>{i[a]=t[a]!==0?e(this,J).now():0,r(a,t[a]);});let r=this.ttlAutopurge?(a,h)=>{if(s?.[a]&&(clearTimeout(s[a]),s[a]=void 0),h&&h!==0&&s){let d=setTimeout(()=>{e(this,P).call(this,a)&&f(this,l,nt).call(this,e(this,x)[a],"expire");},h+1);d.unref&&d.unref(),s[a]=d;}}:()=>{};p(this,it,(a,h)=>{if(t[h]){let d=t[h],y=i[h];if(!d||!y)return;a.ttl=d,a.start=y,a.now=o||n();let m=a.now-y;a.remainingTTL=d-m;}});let o=0,n=()=>{let a=e(this,J).now();if(this.ttlResolution>0){o=a;let h=setTimeout(()=>o=0,this.ttlResolution);h.unref&&h.unref();}return a};this.getRemainingTTL=a=>{let h=e(this,E).get(a);if(h===void 0)return 0;let d=t[h],y=i[h];if(!d||!y)return 1/0;let m=(o||n())-y;return d-m},p(this,P,a=>{let h=i[a],d=t[a];return !!d&&!!h&&(o||n())-h>d});},ct=new WeakMap,it=new WeakMap,Ht=new WeakMap,P=new WeakMap,qt=function(){let t=new Tt(e(this,B));p(this,Y,0),p(this,Q,t),p(this,ft,i=>{p(this,Y,e(this,Y)-t[i]),t[i]=0;}),p(this,At,(i,s,r,o)=>{if(f(this,l,_).call(this,s))return 0;if(!st(r))if(o){if(typeof o!="function")throw new TypeError("sizeCalculation must be a function");if(r=o(s,i),!st(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}),p(this,St,(i,s,r)=>{if(t[i]=s,e(this,j)){let o=e(this,j)-t[i];for(;e(this,Y)>o;)f(this,l,Ct).call(this,true);}p(this,Y,e(this,Y)+t[i]),r&&(r.entrySize=s,r.totalCalculatedSize=e(this,Y));});},ft=new WeakMap,St=new WeakMap,At=new WeakMap,rt=function*({allowStale:t=this.allowStale}={}){if(e(this,C))for(let i=e(this,F);!(!f(this,l,It).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,k)));)i=e(this,V)[i];},ot=function*({allowStale:t=this.allowStale}={}){if(e(this,C))for(let i=e(this,k);!(!f(this,l,It).call(this,i)||((t||!e(this,P).call(this,i))&&(yield i),i===e(this,F)));)i=e(this,G)[i];},It=function(t){return t!==void 0&&e(this,E).get(e(this,x)[t])===t},Ct=function(t){var o;let i=e(this,k),s=e(this,x)[i],r=e(this,g)[i];return e(this,at)&&f(this,l,_).call(this,r)?r.__abortController.abort(new Error("evicted")):(e(this,tt)||e(this,I))&&(e(this,tt)&&((o=e(this,$))==null||o.call(this,r,s,"evict")),e(this,I)&&e(this,D)?.push([r,s,"evict"])),e(this,ft).call(this,i),e(this,K)?.[i]&&(clearTimeout(e(this,K)[i]),e(this,K)[i]=void 0),t&&(e(this,x)[i]=void 0,e(this,g)[i]=void 0,e(this,X).push(i)),e(this,C)===1?(p(this,k,p(this,F,0)),e(this,X).length=0):p(this,k,e(this,G)[i]),e(this,E).delete(s),Ot(this,C)._--,i},Ft=function(t,i,s,r){let o=i===void 0?void 0:e(this,g)[i];if(f(this,l,_).call(this,o))return o;let n=new Dt,{signal:a}=s;a?.addEventListener("abort",()=>n.abort(a.reason),{signal:n.signal});let h={signal:n.signal,options:s,context:r},d=(H,w=false)=>{let{aborted:b}=n.signal,z=s.ignoreFetchAbort&&H!==void 0,R=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&H!==void 0);if(s.status&&(b&&!w?(s.status.fetchAborted=true,s.status.fetchError=n.signal.reason,z&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),b&&!z&&!w)return m(n.signal.reason,R);let L=T,A=e(this,g)[i];return (A===T||z&&w&&A===void 0)&&(H===void 0?L.__staleWhileFetching!==void 0?e(this,g)[i]=L.__staleWhileFetching:f(this,l,nt).call(this,t,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(t,H,h.options))),H},y=H=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=H),m(H,false)),m=(H,w)=>{let{aborted:b}=n.signal,z=b&&s.allowStaleOnFetchAbort,R=z||s.allowStaleOnFetchRejection,L=R||s.noDeleteOnFetchRejection,A=T;if(e(this,g)[i]===T&&(!L||!w&&A.__staleWhileFetching===void 0?f(this,l,nt).call(this,t,"fetch"):z||(e(this,g)[i]=A.__staleWhileFetching)),R)return s.status&&A.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),A.__staleWhileFetching;if(A.__returned===A)throw H},v=(H,w)=>{var z;let b=(z=e(this,gt))==null?void 0:z.call(this,t,o,h);b&&b instanceof Promise&&b.then(R=>H(R===void 0?void 0:R),w),n.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(H(void 0),s.allowStaleOnFetchAbort&&(H=R=>d(R,true)));});};s.status&&(s.status.fetchDispatched=true);let T=new Promise(v).then(d,y),W=Object.assign(T,{__abortController:n,__staleWhileFetching:o,__returned:void 0});return i===void 0?(this.set(t,W,{...h.options,status:void 0}),i=e(this,E).get(t)):e(this,g)[i]=W,W},_=function(t){if(!e(this,at))return false;let i=t;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Dt},Rt=function(t,i){e(this,V)[i]=t,e(this,G)[t]=i;},xt=function(t){t!==e(this,F)&&(t===e(this,k)?p(this,k,e(this,G)[t]):f(this,l,Rt).call(this,e(this,V)[t],e(this,G)[t]),f(this,l,Rt).call(this,e(this,F),t),p(this,F,t));},nt=function(t,i){var r,o;let s=false;if(e(this,C)!==0){let n=e(this,E).get(t);if(n!==void 0)if(e(this,K)?.[n]&&(clearTimeout(e(this,K)?.[n]),e(this,K)[n]=void 0),s=true,e(this,C)===1)f(this,l,Nt).call(this,i);else {e(this,ft).call(this,n);let a=e(this,g)[n];if(f(this,l,_).call(this,a)?a.__abortController.abort(new Error("deleted")):(e(this,tt)||e(this,I))&&(e(this,tt)&&((r=e(this,$))==null||r.call(this,a,t,i)),e(this,I)&&e(this,D)?.push([a,t,i])),e(this,E).delete(t),e(this,x)[n]=void 0,e(this,g)[n]=void 0,n===e(this,F))p(this,F,e(this,V)[n]);else if(n===e(this,k))p(this,k,e(this,G)[n]);else {let h=e(this,V)[n];e(this,G)[h]=e(this,G)[n];let d=e(this,G)[n];e(this,V)[d]=e(this,V)[n];}Ot(this,C)._--,e(this,X).push(n);}}if(e(this,I)&&e(this,D)?.length){let n=e(this,D),a;for(;a=n?.shift();)(o=e(this,q))==null||o.call(this,...a);}return s},Nt=function(t){var i,s;for(let r of f(this,l,ot).call(this,{allowStale:true})){let o=e(this,g)[r];if(f(this,l,_).call(this,o))o.__abortController.abort(new Error("deleted"));else {let n=e(this,x)[r];e(this,tt)&&((i=e(this,$))==null||i.call(this,o,n,t)),e(this,I)&&e(this,D)?.push([o,n,t]);}}if(e(this,E).clear(),e(this,g).fill(void 0),e(this,x).fill(void 0),e(this,U)&&e(this,Z)){e(this,U).fill(0),e(this,Z).fill(0);for(let r of e(this,K)??[])r!==void 0&&clearTimeout(r);e(this,K)?.fill(void 0);}if(e(this,Q)&&e(this,Q).fill(0),p(this,k,0),p(this,F,0),e(this,X).length=0,p(this,Y,0),p(this,C,0),e(this,I)&&e(this,D)){let r=e(this,D),o;for(;o=r?.shift();)(s=e(this,q))==null||s.call(this,...o);}},vt);var ht=class{cache;map=new Map;constructor(t){this.cache=new $t({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 u=class c{static _diffHistory=new ht({cacheSize:5});static _stepsInfoHistory=new ht({cacheSize:5});static _narrationHistory=new ht({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return c._originalStepData?c._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(t){c._originalStepData=t;}};var O;(r=>(r.log=(o,...n)=>console.log(`[Pixi\u2019VN] ${o}`,...n),r.warn=(o,...n)=>console.warn(`[Pixi\u2019VN] ${o}`,...n),r.error=(o,...n)=>console.error(`[Pixi\u2019VN] ${o}`,...n),r.info=(o,...n)=>console.info(`[Pixi\u2019VN] ${o}`,...n)))(O||={});function wt(c){try{if(typeof c>"u")return c;let t=JSON.stringify(c);return JSON.parse(t)}catch(t){throw O.error("Error creating exportable element",c,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}function Jt(c,t){let i=wt(c);return t.length>1&&"type"in t[0]&&(t=t.slice().reverse()),t.forEach(s=>{re(i,s);}),i}function re(c,t){let i=c;t.path&&t.path.length>0?t.path.forEach((s,r)=>{if(t.path&&r===t.path.length-1)switch(t.type){case "CHANGE":case "REMOVE":i[s]=t.oldValue;break;case "CREATE":Array.isArray(i)&&typeof s=="number"?i.splice(s,1):delete i[s];break}else i=i[s];}):O.warn("No path found, skipping diff",t);}var Yt=["Date","RegExp","String","Number"],Xt=Object.getOwnPropertyNames(globalThis.Temporal||{});function Mt(c,t,i={cyclesFix:true},s=[]){let r=[],o=Array.isArray(c);for(let a in c){let h=c[a],d=o?+a:a;if(!(a in t)){r.push({type:"REMOVE",path:[d],oldValue:h});continue}let y=t[a],m=typeof h=="object"&&typeof y=="object"&&Array.isArray(h)===Array.isArray(y),v=m&&h?Object.getPrototypeOf(h)?.constructor?.name:void 0;if(h&&y&&m&&!Yt.includes(v)&&!Xt.includes(v)&&(!i.cyclesFix||!s.includes(h))){i.cyclesFix&&s.push(h);let T=Mt(h,y,i,s);i.cyclesFix&&s.pop();for(let W of T)W.path.unshift(d),r.push(W);}else Object.is(h,y)||Xt.includes(v)&&String(h)===String(y)||Yt.includes(v)&&(isNaN(h)?h+""==y+"":+h==+y)||r.push({path:[d],type:"CHANGE",value:y,oldValue:h});}let n=Array.isArray(t);for(let a in t)a in c||r.push({type:"CREATE",path:[n?+a:a],value:t[a]});return r}var Et=class{get stepsInfoMap(){return u._stepsInfoHistory}get diffMap(){return u._diffHistory}get narrationMap(){return u._narrationHistory}get size(){return u._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let t=null;for(let i of this.keys())(t===null||i>t)&&(t=i);return t}get lastDiffKey(){let t=null;for(let i of u._diffHistory.keys())(t===null||i>t)&&(t=i);return t}get goBackMode(){return u.goBackMode}set goBackMode(t){u.goBackMode=t;}keys(){return u._stepsInfoHistory.keys()}get(t){let i=u._narrationHistory.get(t);if(!(i&&Object.keys(i).length===1&&i.stepIndex!==void 0))return i}delete(t){u._stepsInfoHistory.delete(t),u._diffHistory.delete(t),u._narrationHistory.delete(t);}deleteFromKeyOnward(t){Array.from(this.keys()).filter(i=>i>=t).forEach(i=>{this.delete(i);});}previousCheckpointKey(t){let i=0;for(let s of u._diffHistory.keys())s<t&&s>i&&(i=s);return i}getOldGameState(t,i){if(t<=0||this.size===0)return i;let s=this.lastDiffKey;if(typeof s!="number")return O.warn("You can't go back, there is no step to go back"),i;let r=u._diffHistory.get(s);if(r)try{let o=Jt(i,r),n=this.previousCheckpointKey(s)+1;return core.GameUnifier.stepCounter=n,this.deleteFromKeyOnward(n),this.getOldGameState(t-1,o)}catch(o){return O.error("Error applying diff",o),i}else return O.warn("No diff found for the last step, cannot go back"),i}async back(t,i={}){let{steps:s=1}=i;if(!Number.isFinite(s)){O.warn(`[back] The parameter steps must be a valid finite number, received: ${s}`);return}if(s<=0){O.warn(`[back] The parameter steps must be greater than 0, received: ${s}`);return}if(core.GameUnifier.runningStepsCount>0){core.GameUnifier.increaseBackRequest(s);return}if(u._diffHistory.size<1){O.warn("You can't go back, there is no step to go back");return}core.GameUnifier.runningStepsCount++;try{let r=wt(this.getOldGameState(s,u.originalStepData));if(r){await core.GameUnifier.restoreGameStepState(r,core.GameUnifier.navigate);let o=core.GameUnifier.stepCounter-1,n=u._narrationHistory.get(o);if(n&&Object.keys(n).length===1&&n.stepIndex!==void 0){let a=u._stepsInfoHistory.get(o);if(a){let h=this.itemMapper({step:a});u._narrationHistory.set(a.index,h);}}}else O.error("Error going back");u.originalStepData=r;}catch(r){O.error("Error going back",r);}if(core.GameUnifier.runningStepsCount--,core.GameUnifier.runningStepsCount===0&&core.GameUnifier.backRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(t)}isCheckpointStep(t,i){if(u.goBackMode==="step"||t.choices&&t.choices.length>0||t.isRequiredInput)return true;let s=t.openedLabels??[],r=i?.openedLabels??[];return s.length!==r.length?true:s.some((o,n)=>o.label!==r[n]?.label)}add(t,i={}){let s=u.originalStepData,{ignoreSameStep:r}=i,o=core.GameUnifier.currentGameStepState;if(!r&&this.isSameStep(s,o))return;let n=this.lastKey,a=typeof n=="number"?u._stepsInfoHistory.get(n):void 0,h=t.index===0||this.isCheckpointStep(t,a);(async()=>{try{let y=typeof n=="number"?u._narrationHistory.get(n):void 0;if(u._stepsInfoHistory.set(t.index,t),t.index!==0&&h){let T=Mt(s,o);T?u._diffHistory.set(t.index,T):O.warn("It was not possible to create the difference between the two steps");}let m={},v=this.itemMapper({step:t},m);if(u._narrationHistory.set(t.index,v),a&&y&&typeof n=="number"){let T=this.itemMapper({...m,step:a},{});u._narrationHistory.set(n,T);}}catch(y){O.error("Error adding history step",y);}})(),(t.index===0||h)&&(u.originalStepData=o);}itemMapper(t,i){let{step:s,choiceIndexMade:r,inputValue:o,removeDialogue:n}=t,a=s.dialogue;i&&s.isGlued&&(i.removeDialogue=true),n&&(a=void 0);let h=s.choices;if(i&&s.currentLabel&&s.choiceIndexMade!==void 0&&(i.choiceIndexMade=s.choiceIndexMade),s.inputValue&&i&&(i.inputValue=s.inputValue),a||h||o){let d=h?.map((y,m)=>{let v=false;return y.oneTime&&s.alreadyMadeChoices?.includes(m)&&(v=true),{text:y.text,type:y.type,isResponse:false,hidden:v}});if(d){if(d.every(y=>y.hidden)){let y=d.find(m=>m.hidden===false);y&&(y.hidden=false);}r!==void 0&&(d[r].isResponse=true);}return {dialogue:a?{...a,character:a.character?core.GameUnifier.getCharacter(a.character)||a.character:void 0}:void 0,playerMadeChoice:typeof r=="number",choices:d,stepIndex:s.index,inputValue:o,openedLabelsNumber:s.openedLabels?.length}}return {stepIndex:s.index}}get narrativeHistory(){let t=[];return Array.from(this.keys()).sort((s,r)=>s-r).forEach(s=>{let r=this.get(s);r&&t.push(r);}),t}get currentLabelHistory(){let t=[],i=Array.from(this.keys()).sort((h,d)=>d-h);if(i.length===0)return t;let s=i[0];if(typeof s!="number")return t;let r=u._stepsInfoHistory.get(s);if(!r)return t;let o=r.openedLabels;if(!o||!Array.isArray(o)||o.length===0)return t;let n=o[0].currentStepIndex,a=o[0].label;return i.every((h,d)=>{let y=this.get(h);if(y){if(d===0)return t.push(y),true;let m=u._stepsInfoHistory.get(h);if(!m)return true;let v=m.openedLabels;if(!v||!Array.isArray(v)||v.length===0||v[0].label!==a||v[0].currentStepIndex>n)return false;n=v[0].currentStepIndex,t.push(y);}return true}),t.reverse()}get currentPageParagraphs(){let t=[],i;return this.currentLabelHistory.forEach(s=>{t.length===0||s.openedLabelsNumber!==i?t.push([s]):t[t.length-1].push(s),i=s.openedLabelsNumber;}),t}removeNarrativeHistory(t){if(t){let i=Array.from(this.keys()).sort((s,r)=>s-r);i=i.slice(0,t),i.forEach(s=>{u._narrationHistory.delete(s),u._stepsInfoHistory.delete(s),u._diffHistory.delete(s);});}else u._stepsInfoHistory.clear(),u._diffHistory.clear(),u._narrationHistory.clear();}get canGoBack(){return u._diffHistory.size>0}blockGoBack(){core.GameUnifier.runningStepsCount===0&&u._diffHistory.clear();}isSameStep(t,i){if(t.openedLabels.length===i.openedLabels.length)try{let s=JSON.stringify(t.openedLabels),r=JSON.stringify(i.openedLabels);if(s===r&&t.path===i.path&&t.labelIndex===i.labelIndex)return !0}catch(s){return O.error("Error comparing opened labels",s),true}return false}clear(){u._stepsInfoHistory.clear(),u._diffHistory.clear(),u._narrationHistory.clear(),u._originalStepData=void 0;}get stepLimitSaved(){return u.stepLimitSaved}set stepLimitSaved(t){u.stepLimitSaved=t;}export(){let t=Array.from(this.keys()).sort((s,r)=>s-r);t.length>this.stepLimitSaved&&(t=t.slice(t.length-this.stepLimitSaved));let i=[];return t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let o=u._diffHistory.get(s);i.push({...r,diff:o});}}),{stepsHistory:wt(i),originalStepData:wt(u._originalStepData)}}restoreNarrativeHistory(){let t=Array.from(this.keys()).sort((s,r)=>s-r),i={};t.forEach(s=>{let r=u._stepsInfoHistory.get(s);if(r){let o={...i};i={};let n=this.itemMapper({step:r,choiceIndexMade:o.choiceIndexMade,inputValue:o.inputValue,removeDialogue:o.removeDialogue},i);n&&u._narrationHistory.set(s,n);}});}async restore(t){this.clear();try{Object.hasOwn(t,"stepsHistory")?(t.stepsHistory.forEach(s=>{s.diff&&u._diffHistory.set(s.index,s.diff);let r={...s,diff:void 0};u._stepsInfoHistory.set(s.index,r);}),this.restoreNarrativeHistory()):O.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(t,"originalStepData")?u._originalStepData=t.originalStepData:O.warn("Could not import originalStepData data, so will be ignored");}catch(i){O.error("Error importing data",i);}}};var ke=new Et;exports.HistoryManagerStatic=u;exports.stepHistory=ke;
@@ -1,15 +1,48 @@
1
- import { HistoryInfo, GameStepState } from '@drincs/pixi-vn';
1
+ import { GameStepState, HistoryInfo } from '@drincs/pixi-vn';
2
2
  import { Difference } from 'microdiff';
3
3
  import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
4
- import { H as HistoryStep } from './HistoryStep-G9dUn0Lf.cjs';
5
- import { H as HistoryGameState } from './HistoryGameState-C28NcKKl.cjs';
4
+ import { H as HistoryStep } from './HistoryStep-WGB6nA4N.cjs';
5
+ import { H as HistoryGameState } from './HistoryGameState-CGfvq5iL.cjs';
6
6
  import { S as StepLabelPropsType, a as StepLabelResultType } from './StepLabelType-CN97wZzm.cjs';
7
- import { N as NarrationHistory } from './HistoryChoiceMenuOption-DVMD78W7.cjs';
7
+ import { N as NarrationHistory } from './HistoryChoiceMenuOption-BxMSXnyI.cjs';
8
8
  import 'lru-cache';
9
9
  import '@drincs/pixi-vn/canvas';
10
10
  import './StorageElementType-C7ETezlL.cjs';
11
11
 
12
+ /**
13
+ * How often a go-back-able checkpoint is recorded:
14
+ * - `"step"` (default): every single narration step, matching visual-novel-style games
15
+ * where the player may want to undo one line/sprite change at a time.
16
+ * - `"paragraph"`: only when a new paragraph starts (the number of opened labels
17
+ * changes), a choice is proposed, or an input is requested - matching book-style
18
+ * narrations where undoing mid-paragraph doesn't make sense to the player.
19
+ */
20
+ type HistoryGoBackModeType = "step" | "paragraph";
21
+ declare class HistoryManagerStatic {
22
+ static _diffHistory: CachedMap<number, Difference[]>;
23
+ static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
24
+ static _narrationHistory: CachedMap<number, NarrationHistory>;
25
+ static stepLimitSaved: number;
26
+ static goBackMode: HistoryGoBackModeType;
27
+ static _originalStepData: GameStepState | undefined;
28
+ static get originalStepData(): GameStepState;
29
+ static set originalStepData(value: GameStepState);
30
+ }
31
+
12
32
  interface HistoryManagerInterface {
33
+ /**
34
+ * How often a go-back-able checkpoint is recorded.
35
+ * @default "step"
36
+ * - `"step"`: every single narration step, matching visual-novel-style games where
37
+ * the player may want to undo one line/sprite change at a time.
38
+ * - `"paragraph"`: only when a new paragraph starts ({@link HistoryManagerInterface.currentPageParagraphs}),
39
+ * a choice is proposed, or an input is requested - matching book-style narrations
40
+ * where undoing mid-paragraph doesn't make sense to the player. Every step within a
41
+ * paragraph is merged into the checkpoint that closes it out: `back()` from anywhere
42
+ * inside paragraph N jumps all the way to the *start* of paragraph N-1, not to
43
+ * wherever you were right before N began - the whole of paragraph N-1 gets replayed.
44
+ */
45
+ goBackMode: HistoryGoBackModeType;
13
46
  /**
14
47
  * Get the narrative history.
15
48
  * @returns the history of the dialogues, choices and steps
@@ -142,16 +175,6 @@ interface HistoryManagerInterface {
142
175
  restore(data: object): Promise<void>;
143
176
  }
144
177
 
145
- declare class HistoryManagerStatic {
146
- static _diffHistory: CachedMap<number, Difference[]>;
147
- static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
148
- static _narrationHistory: CachedMap<number, NarrationHistory>;
149
- static stepLimitSaved: number;
150
- static _originalStepData: GameStepState | undefined;
151
- static get originalStepData(): GameStepState;
152
- static set originalStepData(value: GameStepState);
153
- }
154
-
155
178
  declare const stepHistory: HistoryManagerInterface;
156
179
 
157
- export { HistoryGameState, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
180
+ export { HistoryGameState, type HistoryGoBackModeType, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
package/dist/history.d.ts CHANGED
@@ -1,15 +1,48 @@
1
- import { HistoryInfo, GameStepState } from '@drincs/pixi-vn';
1
+ import { GameStepState, HistoryInfo } from '@drincs/pixi-vn';
2
2
  import { Difference } from 'microdiff';
3
3
  import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
4
- import { H as HistoryStep } from './HistoryStep-G9dUn0Lf.js';
5
- import { H as HistoryGameState } from './HistoryGameState-CmjUtlkV.js';
4
+ import { H as HistoryStep } from './HistoryStep-WGB6nA4N.js';
5
+ import { H as HistoryGameState } from './HistoryGameState-C8ATx9K6.js';
6
6
  import { S as StepLabelPropsType, a as StepLabelResultType } from './StepLabelType-CN97wZzm.js';
7
- import { N as NarrationHistory } from './HistoryChoiceMenuOption-B8RfQz5H.js';
7
+ import { N as NarrationHistory } from './HistoryChoiceMenuOption-hSI4SHV-.js';
8
8
  import 'lru-cache';
9
9
  import '@drincs/pixi-vn/canvas';
10
10
  import './StorageElementType-C7ETezlL.js';
11
11
 
12
+ /**
13
+ * How often a go-back-able checkpoint is recorded:
14
+ * - `"step"` (default): every single narration step, matching visual-novel-style games
15
+ * where the player may want to undo one line/sprite change at a time.
16
+ * - `"paragraph"`: only when a new paragraph starts (the number of opened labels
17
+ * changes), a choice is proposed, or an input is requested - matching book-style
18
+ * narrations where undoing mid-paragraph doesn't make sense to the player.
19
+ */
20
+ type HistoryGoBackModeType = "step" | "paragraph";
21
+ declare class HistoryManagerStatic {
22
+ static _diffHistory: CachedMap<number, Difference[]>;
23
+ static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
24
+ static _narrationHistory: CachedMap<number, NarrationHistory>;
25
+ static stepLimitSaved: number;
26
+ static goBackMode: HistoryGoBackModeType;
27
+ static _originalStepData: GameStepState | undefined;
28
+ static get originalStepData(): GameStepState;
29
+ static set originalStepData(value: GameStepState);
30
+ }
31
+
12
32
  interface HistoryManagerInterface {
33
+ /**
34
+ * How often a go-back-able checkpoint is recorded.
35
+ * @default "step"
36
+ * - `"step"`: every single narration step, matching visual-novel-style games where
37
+ * the player may want to undo one line/sprite change at a time.
38
+ * - `"paragraph"`: only when a new paragraph starts ({@link HistoryManagerInterface.currentPageParagraphs}),
39
+ * a choice is proposed, or an input is requested - matching book-style narrations
40
+ * where undoing mid-paragraph doesn't make sense to the player. Every step within a
41
+ * paragraph is merged into the checkpoint that closes it out: `back()` from anywhere
42
+ * inside paragraph N jumps all the way to the *start* of paragraph N-1, not to
43
+ * wherever you were right before N began - the whole of paragraph N-1 gets replayed.
44
+ */
45
+ goBackMode: HistoryGoBackModeType;
13
46
  /**
14
47
  * Get the narrative history.
15
48
  * @returns the history of the dialogues, choices and steps
@@ -142,16 +175,6 @@ interface HistoryManagerInterface {
142
175
  restore(data: object): Promise<void>;
143
176
  }
144
177
 
145
- declare class HistoryManagerStatic {
146
- static _diffHistory: CachedMap<number, Difference[]>;
147
- static _stepsInfoHistory: CachedMap<number, Omit<HistoryStep, "diff">>;
148
- static _narrationHistory: CachedMap<number, NarrationHistory>;
149
- static stepLimitSaved: number;
150
- static _originalStepData: GameStepState | undefined;
151
- static get originalStepData(): GameStepState;
152
- static set originalStepData(value: GameStepState);
153
- }
154
-
155
178
  declare const stepHistory: HistoryManagerInterface;
156
179
 
157
- export { HistoryGameState, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
180
+ export { HistoryGameState, type HistoryGoBackModeType, type HistoryManagerInterface, HistoryManagerStatic, stepHistory };
package/dist/history.mjs CHANGED
@@ -1 +1 @@
1
- import'./chunk-JMOSOAGB.mjs';import {d,f,e}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var i=class y{static _diffHistory=new d({cacheSize:5});static _stepsInfoHistory=new d({cacheSize:5});static _narrationHistory=new d({cacheSize:50});static stepLimitSaved=20;static _originalStepData=void 0;static get originalStepData(){return y._originalStepData?f(y._originalStepData):{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{},filters:void 0},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){y._originalStepData=f(e);}};function S(y,e){let r=f(y);return e.length>1&&"type"in e[0]&&(e=e.slice().reverse()),e.forEach(t=>{x(r,t);}),r}function x(y,e$1){let r=y;e$1.path&&e$1.path.length>0?e$1.path.forEach((t,a)=>{if(e$1.path&&a===e$1.path.length-1)switch(e$1.type){case "CHANGE":case "REMOVE":r[t]=e$1.oldValue;break;case "CREATE":Array.isArray(r)&&typeof t=="number"?r.splice(t,1):delete r[t];break}else r=r[t];}):e.warn("No path found, skipping diff",e$1);}var _={Date:true,RegExp:true,String:true,Number:true};function H(y,e,r={cyclesFix:true},t=[]){let a=[],s=Array.isArray(y);for(let o in y){let n=y[o],u=s?+o:o;if(!(o in e)){a.push({type:"REMOVE",path:[u],oldValue:y[o]});continue}let p=e[o],m=typeof n=="object"&&typeof p=="object"&&Array.isArray(n)===Array.isArray(p);n&&p&&m&&!_[Object.getPrototypeOf(n)?.constructor?.name]&&(!r.cyclesFix||!t.includes(n))?a.push.apply(a,H(n,p,r,r.cyclesFix?t.concat([n]):[]).map(f=>(f.path.unshift(u),f))):n!==p&&!(Number.isNaN(n)&&Number.isNaN(p))&&!(m&&(isNaN(n)?n+""==p+"":+n==+p))&&a.push({path:[u],type:"CHANGE",value:p,oldValue:n});}let c=Array.isArray(e);for(let o in e)o in y||a.push({type:"CREATE",path:[c?+o:o],value:e[o]});return a}var h=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){return this.size===0?null:Math.max(...Array.from(this.keys()))}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}getOldGameState(e$1,r){if(e$1<=0||this.size===0)return r;let t=this.lastKey;if(typeof t!="number")return e.warn("You can't go back, there is no step to go back"),r;let a=i._diffHistory.get(t);if(a)try{let s=S(r,a);return GameUnifier.stepCounter=t,this.delete(t),this.getOldGameState(e$1-1,s)}catch(s){return e.error("Error applying diff",s),r}else return e.warn("No diff found for the last step, cannot go back"),r}async back(e$1,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){e.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){e.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){e.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{let a=f(this.getOldGameState(t,i.originalStepData));if(a){await GameUnifier.restoreGameStepState(a,GameUnifier.navigate);let s=GameUnifier.stepCounter-1,c=i._narrationHistory.get(s);if(c&&Object.keys(c).length===1&&c.stepIndex!==void 0){let o=i._stepsInfoHistory.get(s);if(o){let n=this.itemMapper({step:o});i._narrationHistory.set(o.index,n);}}}else e.error("Error going back");i.originalStepData=a;}catch(a){e.error("Error going back",a);}if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1)}add(e$1,r={}){let t=i.originalStepData,{ignoreSameStep:a}=r,s=GameUnifier.currentGameStepState;if(!a&&this.isSameStep(t,s))return;let c=this.lastKey;(async()=>{try{let n,u;if(typeof c=="number"&&(n=i._stepsInfoHistory.get(c),u=i._narrationHistory.get(c)),i._stepsInfoHistory.set(e$1.index,e$1),e$1.index!==0){let f=H(t,s);f?i._diffHistory.set(e$1.index,f):e.warn("It was not possible to create the difference between the two steps");}let p={},m=this.itemMapper({step:e$1},p);if(i._narrationHistory.set(e$1.index,m),n&&u&&typeof c=="number"){let f=this.itemMapper({...p,step:n},{});i._narrationHistory.set(c,f);}}catch(n){e.error("Error adding history step",n);}})(),i.originalStepData=s;}itemMapper(e,r){let{step:t,choiceIndexMade:a,inputValue:s,removeDialogue:c}=e,o=t.dialogue;r&&t.isGlued&&(r.removeDialogue=true),c&&(o=void 0);let n=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),o||n||s){let u=n?.map((p,m)=>{let f=false;return p.oneTime&&t.alreadyMadeChoices?.includes(m)&&(f=true),{text:p.text,type:p.type,isResponse:false,hidden:f}});if(u){if(u.every(p=>p.hidden)){let p=u.find(m=>m.hidden===false);p&&(p.hidden=false);}a!==void 0&&(u[a].isResponse=true);}return {dialogue:o?{...o,character:o.character?GameUnifier.getCharacter(o.character)||o.character:void 0}:void 0,playerMadeChoice:typeof a=="number",choices:u,stepIndex:t.index,inputValue:s,openedLabelsNumber:t.openedLabels?.length}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,a)=>t-a).forEach(t=>{let a=this.get(t);a&&e.push(a);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((n,u)=>u-n);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let a=i._stepsInfoHistory.get(t);if(!a)return e;let s=a.openedLabels;if(!s||!Array.isArray(s)||s.length===0)return e;let c=s[0].currentStepIndex,o=s[0].label;return r.every((n,u)=>{let p=this.get(n);if(p){if(u===0)return e.push(p),true;let m=i._stepsInfoHistory.get(n);if(!m)return true;let f=m.openedLabels;if(!f||!Array.isArray(f)||f.length===0||f[0].label!==o||f[0].currentStepIndex>c)return false;c=f[0].currentStepIndex,e.push(p);}return true}),e.reverse()}get currentPageParagraphs(){let e=[],r;return this.currentLabelHistory.forEach(t=>{e.length===0||t.openedLabelsNumber!==r?e.push([t]):e[e.length-1].push(t),r=t.openedLabelsNumber;}),e}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,a)=>t-a);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){let e=this.lastKey;return typeof e!="number"?false:i._diffHistory.has(e)}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e$1,r){if(e$1.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e$1.openedLabels),a=JSON.stringify(r.openedLabels);if(t===a&&e$1.path===r.path&&e$1.labelIndex===r.labelIndex)return !0}catch(t){return e.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((t,a)=>t-a);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];return e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let s=i._diffHistory.get(t);r.push({...a,diff:s});}}),{stepsHistory:f(r),originalStepData:f(i._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,a)=>t-a),r={};e.forEach(t=>{let a=i._stepsInfoHistory.get(t);if(a){let s={...r};r={};let c=this.itemMapper({step:a,choiceIndexMade:s.choiceIndexMade,inputValue:s.inputValue,removeDialogue:s.removeDialogue},r);c&&i._narrationHistory.set(t,c);}});}async restore(e$1){this.clear();try{Object.hasOwn(e$1,"stepsHistory")?(e$1.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let a={...t,diff:void 0};i._stepsInfoHistory.set(t.index,a);}),this.restoreNarrativeHistory()):e.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(e$1,"originalStepData")?i._originalStepData=e$1.originalStepData:e.warn("Could not import originalStepData data, so will be ignored");}catch(r){e.error("Error importing data",r);}}};var j=new h;export{i as HistoryManagerStatic,j as stepHistory};
1
+ import'./chunk-JMOSOAGB.mjs';import {d,e,f}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier}from'@drincs/pixi-vn/core';var i=class d$1{static _diffHistory=new d({cacheSize:5});static _stepsInfoHistory=new d({cacheSize:5});static _narrationHistory=new d({cacheSize:50});static stepLimitSaved=20;static goBackMode="step";static _originalStepData=void 0;static get originalStepData(){return d$1._originalStepData?d$1._originalStepData:{path:"",storage:{},canvas:{elementAliasesOrder:[],elements:{},stage:{},tickers:{},tickersSteps:{},tickersOnPause:{},tickersToCompleteOnStepEnd:{tikersIds:[],stepAlias:[]}},sound:{soundAliasesOrder:[],soundsPlaying:{},playInStepIndex:{}},labelIndex:-1,openedLabels:[]}}static set originalStepData(e){d$1._originalStepData=e;}};function k(d,e){let r=f(d);return e.length>1&&"type"in e[0]&&(e=e.slice().reverse()),e.forEach(t=>{_(r,t);}),r}function _(d,e$1){let r=d;e$1.path&&e$1.path.length>0?e$1.path.forEach((t,n)=>{if(e$1.path&&n===e$1.path.length-1)switch(e$1.type){case "CHANGE":case "REMOVE":r[t]=e$1.oldValue;break;case "CREATE":Array.isArray(r)&&typeof t=="number"?r.splice(t,1):delete r[t];break}else r=r[t];}):e.warn("No path found, skipping diff",e$1);}var v=["Date","RegExp","String","Number"],M=Object.getOwnPropertyNames(globalThis.Temporal||{});function S(d,e,r={cyclesFix:true},t=[]){let n=[],a=Array.isArray(d);for(let s in d){let o=d[s],u=a?+s:s;if(!(s in e)){n.push({type:"REMOVE",path:[u],oldValue:o});continue}let p=e[s],m=typeof o=="object"&&typeof p=="object"&&Array.isArray(o)===Array.isArray(p),l=m&&o?Object.getPrototypeOf(o)?.constructor?.name:void 0;if(o&&p&&m&&!v.includes(l)&&!M.includes(l)&&(!r.cyclesFix||!t.includes(o))){r.cyclesFix&&t.push(o);let g=S(o,p,r,t);r.cyclesFix&&t.pop();for(let x of g)x.path.unshift(u),n.push(x);}else Object.is(o,p)||M.includes(l)&&String(o)===String(p)||v.includes(l)&&(isNaN(o)?o+""==p+"":+o==+p)||n.push({path:[u],type:"CHANGE",value:p,oldValue:o});}let c=Array.isArray(e);for(let s in e)s in d||n.push({type:"CREATE",path:[c?+s:s],value:e[s]});return n}var b=class{get stepsInfoMap(){return i._stepsInfoHistory}get diffMap(){return i._diffHistory}get narrationMap(){return i._narrationHistory}get size(){return i._stepsInfoHistory.size}get lastKey(){if(this.size===0)return null;let e=null;for(let r of this.keys())(e===null||r>e)&&(e=r);return e}get lastDiffKey(){let e=null;for(let r of i._diffHistory.keys())(e===null||r>e)&&(e=r);return e}get goBackMode(){return i.goBackMode}set goBackMode(e){i.goBackMode=e;}keys(){return i._stepsInfoHistory.keys()}get(e){let r=i._narrationHistory.get(e);if(!(r&&Object.keys(r).length===1&&r.stepIndex!==void 0))return r}delete(e){i._stepsInfoHistory.delete(e),i._diffHistory.delete(e),i._narrationHistory.delete(e);}deleteFromKeyOnward(e){Array.from(this.keys()).filter(r=>r>=e).forEach(r=>{this.delete(r);});}previousCheckpointKey(e){let r=0;for(let t of i._diffHistory.keys())t<e&&t>r&&(r=t);return r}getOldGameState(e$1,r){if(e$1<=0||this.size===0)return r;let t=this.lastDiffKey;if(typeof t!="number")return e.warn("You can't go back, there is no step to go back"),r;let n=i._diffHistory.get(t);if(n)try{let a=k(r,n),c=this.previousCheckpointKey(t)+1;return GameUnifier.stepCounter=c,this.deleteFromKeyOnward(c),this.getOldGameState(e$1-1,a)}catch(a){return e.error("Error applying diff",a),r}else return e.warn("No diff found for the last step, cannot go back"),r}async back(e$1,r={}){let{steps:t=1}=r;if(!Number.isFinite(t)){e.warn(`[back] The parameter steps must be a valid finite number, received: ${t}`);return}if(t<=0){e.warn(`[back] The parameter steps must be greater than 0, received: ${t}`);return}if(GameUnifier.runningStepsCount>0){GameUnifier.increaseBackRequest(t);return}if(i._diffHistory.size<1){e.warn("You can't go back, there is no step to go back");return}GameUnifier.runningStepsCount++;try{let n=f(this.getOldGameState(t,i.originalStepData));if(n){await GameUnifier.restoreGameStepState(n,GameUnifier.navigate);let a=GameUnifier.stepCounter-1,c=i._narrationHistory.get(a);if(c&&Object.keys(c).length===1&&c.stepIndex!==void 0){let s=i._stepsInfoHistory.get(a);if(s){let o=this.itemMapper({step:s});i._narrationHistory.set(s.index,o);}}}else e.error("Error going back");i.originalStepData=n;}catch(n){e.error("Error going back",n);}if(GameUnifier.runningStepsCount--,GameUnifier.runningStepsCount===0&&GameUnifier.backRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1)}isCheckpointStep(e,r){if(i.goBackMode==="step"||e.choices&&e.choices.length>0||e.isRequiredInput)return true;let t=e.openedLabels??[],n=r?.openedLabels??[];return t.length!==n.length?true:t.some((a,c)=>a.label!==n[c]?.label)}add(e$1,r={}){let t=i.originalStepData,{ignoreSameStep:n}=r,a=GameUnifier.currentGameStepState;if(!n&&this.isSameStep(t,a))return;let c=this.lastKey,s=typeof c=="number"?i._stepsInfoHistory.get(c):void 0,o=e$1.index===0||this.isCheckpointStep(e$1,s);(async()=>{try{let p=typeof c=="number"?i._narrationHistory.get(c):void 0;if(i._stepsInfoHistory.set(e$1.index,e$1),e$1.index!==0&&o){let g=S(t,a);g?i._diffHistory.set(e$1.index,g):e.warn("It was not possible to create the difference between the two steps");}let m={},l=this.itemMapper({step:e$1},m);if(i._narrationHistory.set(e$1.index,l),s&&p&&typeof c=="number"){let g=this.itemMapper({...m,step:s},{});i._narrationHistory.set(c,g);}}catch(p){e.error("Error adding history step",p);}})(),(e$1.index===0||o)&&(i.originalStepData=a);}itemMapper(e,r){let{step:t,choiceIndexMade:n,inputValue:a,removeDialogue:c}=e,s=t.dialogue;r&&t.isGlued&&(r.removeDialogue=true),c&&(s=void 0);let o=t.choices;if(r&&t.currentLabel&&t.choiceIndexMade!==void 0&&(r.choiceIndexMade=t.choiceIndexMade),t.inputValue&&r&&(r.inputValue=t.inputValue),s||o||a){let u=o?.map((p,m)=>{let l=false;return p.oneTime&&t.alreadyMadeChoices?.includes(m)&&(l=true),{text:p.text,type:p.type,isResponse:false,hidden:l}});if(u){if(u.every(p=>p.hidden)){let p=u.find(m=>m.hidden===false);p&&(p.hidden=false);}n!==void 0&&(u[n].isResponse=true);}return {dialogue:s?{...s,character:s.character?GameUnifier.getCharacter(s.character)||s.character:void 0}:void 0,playerMadeChoice:typeof n=="number",choices:u,stepIndex:t.index,inputValue:a,openedLabelsNumber:t.openedLabels?.length}}return {stepIndex:t.index}}get narrativeHistory(){let e=[];return Array.from(this.keys()).sort((t,n)=>t-n).forEach(t=>{let n=this.get(t);n&&e.push(n);}),e}get currentLabelHistory(){let e=[],r=Array.from(this.keys()).sort((o,u)=>u-o);if(r.length===0)return e;let t=r[0];if(typeof t!="number")return e;let n=i._stepsInfoHistory.get(t);if(!n)return e;let a=n.openedLabels;if(!a||!Array.isArray(a)||a.length===0)return e;let c=a[0].currentStepIndex,s=a[0].label;return r.every((o,u)=>{let p=this.get(o);if(p){if(u===0)return e.push(p),true;let m=i._stepsInfoHistory.get(o);if(!m)return true;let l=m.openedLabels;if(!l||!Array.isArray(l)||l.length===0||l[0].label!==s||l[0].currentStepIndex>c)return false;c=l[0].currentStepIndex,e.push(p);}return true}),e.reverse()}get currentPageParagraphs(){let e=[],r;return this.currentLabelHistory.forEach(t=>{e.length===0||t.openedLabelsNumber!==r?e.push([t]):e[e.length-1].push(t),r=t.openedLabelsNumber;}),e}removeNarrativeHistory(e){if(e){let r=Array.from(this.keys()).sort((t,n)=>t-n);r=r.slice(0,e),r.forEach(t=>{i._narrationHistory.delete(t),i._stepsInfoHistory.delete(t),i._diffHistory.delete(t);});}else i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear();}get canGoBack(){return i._diffHistory.size>0}blockGoBack(){GameUnifier.runningStepsCount===0&&i._diffHistory.clear();}isSameStep(e$1,r){if(e$1.openedLabels.length===r.openedLabels.length)try{let t=JSON.stringify(e$1.openedLabels),n=JSON.stringify(r.openedLabels);if(t===n&&e$1.path===r.path&&e$1.labelIndex===r.labelIndex)return !0}catch(t){return e.error("Error comparing opened labels",t),true}return false}clear(){i._stepsInfoHistory.clear(),i._diffHistory.clear(),i._narrationHistory.clear(),i._originalStepData=void 0;}get stepLimitSaved(){return i.stepLimitSaved}set stepLimitSaved(e){i.stepLimitSaved=e;}export(){let e=Array.from(this.keys()).sort((t,n)=>t-n);e.length>this.stepLimitSaved&&(e=e.slice(e.length-this.stepLimitSaved));let r=[];return e.forEach(t=>{let n=i._stepsInfoHistory.get(t);if(n){let a=i._diffHistory.get(t);r.push({...n,diff:a});}}),{stepsHistory:f(r),originalStepData:f(i._originalStepData)}}restoreNarrativeHistory(){let e=Array.from(this.keys()).sort((t,n)=>t-n),r={};e.forEach(t=>{let n=i._stepsInfoHistory.get(t);if(n){let a={...r};r={};let c=this.itemMapper({step:n,choiceIndexMade:a.choiceIndexMade,inputValue:a.inputValue,removeDialogue:a.removeDialogue},r);c&&i._narrationHistory.set(t,c);}});}async restore(e$1){this.clear();try{Object.hasOwn(e$1,"stepsHistory")?(e$1.stepsHistory.forEach(t=>{t.diff&&i._diffHistory.set(t.index,t.diff);let n={...t,diff:void 0};i._stepsInfoHistory.set(t.index,n);}),this.restoreNarrativeHistory()):e.warn("Could not import stepsHistory data, so will be ignored"),Object.hasOwn(e$1,"originalStepData")?i._originalStepData=e$1.originalStepData:e.warn("Could not import originalStepData data, so will be ignored");}catch(r){e.error("Error importing data",r);}}};var j=new b;export{i as HistoryManagerStatic,j as stepHistory};
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var at=require('@drincs/pixi-vn/canvas'),Bt=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),it=require('@drincs/pixi-vn/history'),R=require('@drincs/pixi-vn/narration'),ut=require('@drincs/pixi-vn/sound'),G=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');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 at__namespace=/*#__PURE__*/_interopNamespace(at);var Bt__namespace=/*#__PURE__*/_interopNamespace(Bt);var it__namespace=/*#__PURE__*/_interopNamespace(it);var R__namespace=/*#__PURE__*/_interopNamespace(R);var ut__namespace=/*#__PURE__*/_interopNamespace(ut);var G__namespace=/*#__PURE__*/_interopNamespace(G);var Xt=Object.defineProperty;var Jt=l=>{throw TypeError(l)};var ue=(l,e,i)=>e in l?Xt(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var fe=(l,e)=>{for(var i in e)Xt(l,i,{get:e[i],enumerable:true});};var P=(l,e,i)=>ue(l,typeof e!="symbol"?e+"":e,i),jt=(l,e,i)=>e.has(l)||Jt("Cannot "+i);var t=(l,e,i)=>(jt(l,e,"read from private field"),i?i.call(l):e.get(l)),_=(l,e,i)=>e.has(l)?Jt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),f=(l,e,i,s)=>(jt(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(jt(l,e,"access private method"),i);var Rt=(l,e,i,s)=>({set _(r){f(l,e,r);},get _(){return t(l,e,s)}});var me=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,ee=new Set,It=typeof process=="object"&&process?process:{},ie=(l,e,i,s)=>{typeof It.emitWarning=="function"?It.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Pt=globalThis.AbortController,Qt=globalThis.AbortSignal;if(typeof Pt>"u"){Qt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Pt=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 l=It.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=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=l=>!ee.has(l);var lt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),se=l=>lt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?Lt:null:null,Lt=class extends Array{constructor(l){super(l),this.fill(0);}},st,St,_e=(st=class{heap;length;static create(e){let i=se(e);if(!i)return [];f(st,St,true);let s=new st(e,i);return f(st,St,false),s}constructor(e,i){if(!t(st,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,_(st,St,false),st),Zt,te,k,z,$,ft,B,yt,xt,X,U,J,O,b,m,j,V,F,D,Q,C,Z,tt,W,Y,et,pt,I,Et,a,Gt,mt,nt,Tt,H,oe,gt,bt,Ot,ht,ct,Mt,Dt,Ct,E,zt,At,dt,Vt,wt,re=(wt=class{constructor(e){_(this,a);_(this,k);_(this,z);_(this,$);_(this,ft);_(this,B);_(this,yt);_(this,xt);_(this,X);P(this,"ttl");P(this,"ttlResolution");P(this,"ttlAutopurge");P(this,"updateAgeOnGet");P(this,"updateAgeOnHas");P(this,"allowStale");P(this,"noDisposeOnSet");P(this,"noUpdateTTL");P(this,"maxEntrySize");P(this,"sizeCalculation");P(this,"noDeleteOnFetchRejection");P(this,"noDeleteOnStaleGet");P(this,"allowStaleOnFetchAbort");P(this,"allowStaleOnFetchRejection");P(this,"ignoreFetchAbort");_(this,U);_(this,J);_(this,O);_(this,b);_(this,m);_(this,j);_(this,V);_(this,F);_(this,D);_(this,Q);_(this,C);_(this,Z);_(this,tt);_(this,W);_(this,Y);_(this,et);_(this,pt);_(this,I);_(this,Et);_(this,mt,()=>{});_(this,nt,()=>{});_(this,Tt,()=>{});_(this,H,()=>false);_(this,gt,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});P(this,Zt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:d,dispose:v,onInsert:L,disposeAfter:S,noDisposeOnSet:ot,noUpdateTTL:M,maxSize:q=0,maxEntrySize:w=0,sizeCalculation:y,fetchMethod:g,memoMethod:u,noDeleteOnFetchRejection:x,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:A,ignoreFetchAbort:N,perf:K}=e;if(K!==void 0&&typeof K?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(f(this,X,K??me),i!==0&&!lt(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(f(this,k,i),f(this,z,q),this.maxEntrySize=w||t(this,z),this.sizeCalculation=y,this.sizeCalculation){if(!t(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(u!==void 0&&typeof u!="function")throw new TypeError("memoMethod must be a function if defined");if(f(this,xt,u),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(f(this,yt,g),f(this,pt,!!g),f(this,O,new Map),f(this,b,new Array(i).fill(void 0)),f(this,m,new Array(i).fill(void 0)),f(this,j,new vt(i)),f(this,V,new vt(i)),f(this,F,0),f(this,D,0),f(this,Q,_e.create(i)),f(this,U,0),f(this,J,0),typeof v=="function"&&f(this,$,v),typeof L=="function"&&f(this,ft,L),typeof S=="function"?(f(this,B,S),f(this,C,[])):(f(this,B,void 0),f(this,C,void 0)),f(this,et,!!t(this,$)),f(this,Et,!!t(this,ft)),f(this,I,!!t(this,B)),this.noDisposeOnSet=!!ot,this.noUpdateTTL=!!M,this.noDeleteOnFetchRejection=!!x,this.allowStaleOnFetchRejection=!!p,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!N,this.maxEntrySize!==0){if(t(this,z)!==0&&!lt(t(this,z)))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,oe).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=lt(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,Gt).call(this);}if(t(this,k)===0&&this.ttl===0&&t(this,z)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,k)&&!t(this,z)){let Ft="LRU_CACHE_UNBOUNDED";ge(Ft)&&(ee.add(Ft),ie("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ft,wt));}}get perf(){return t(this,X)}static unsafeExposeInternals(e){return {starts:t(e,tt),ttls:t(e,W),autopurgeTimers:t(e,Y),sizes:t(e,Z),keyMap:t(e,O),keyList:t(e,b),valList:t(e,m),next:t(e,j),prev:t(e,V),get head(){return t(e,F)},get tail(){return t(e,D)},free:t(e,Q),isBackgroundFetch:i=>{var s;return c(s=e,a,E).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return c(o=e,a,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return c(s=e,a,At).call(s,i)},indexes:i=>{var s;return c(s=e,a,ht).call(s,i)},rindexes:i=>{var s;return c(s=e,a,ct).call(s,i)},isStale:i=>{var s;return t(s=e,H).call(s,i)}}}get max(){return t(this,k)}get maxSize(){return t(this,z)}get calculatedSize(){return t(this,J)}get size(){return t(this,U)}get fetchMethod(){return t(this,yt)}get memoMethod(){return t(this,xt)}get dispose(){return t(this,$)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,B)}getRemainingTTL(e){return t(this,O).has(e)?1/0:0}*entries(){for(let e of c(this,a,ht).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!c(this,a,E).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*rentries(){for(let e of c(this,a,ct).call(this))t(this,m)[e]!==void 0&&t(this,b)[e]!==void 0&&!c(this,a,E).call(this,t(this,m)[e])&&(yield [t(this,b)[e],t(this,m)[e]]);}*keys(){for(let e of c(this,a,ht).call(this)){let i=t(this,b)[e];i!==void 0&&!c(this,a,E).call(this,t(this,m)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,ct).call(this)){let i=t(this,b)[e];i!==void 0&&!c(this,a,E).call(this,t(this,m)[e])&&(yield i);}}*values(){for(let e of c(this,a,ht).call(this))t(this,m)[e]!==void 0&&!c(this,a,E).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}*rvalues(){for(let e of c(this,a,ct).call(this))t(this,m)[e]!==void 0&&!c(this,a,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 c(this,a,ht).call(this)){let r=t(this,m)[s],n=c(this,a,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 c(this,a,ht).call(this)){let r=t(this,m)[s],n=c(this,a,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 c(this,a,ct).call(this)){let r=t(this,m)[s],n=c(this,a,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 c(this,a,ct).call(this,{allowStale:true}))t(this,H).call(this,i)&&(c(this,a,dt).call(this,t(this,b)[i],"expire"),e=true);return e}info(e){let i=t(this,O).get(e);if(i===void 0)return;let s=t(this,m)[i],r=c(this,a,E).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,W)&&t(this,tt)){let o=t(this,W)[i],h=t(this,tt)[i];if(o&&h){let d=o-(t(this,X).now()-h);n.ttl=d,n.start=Date.now();}}return t(this,Z)&&(n.size=t(this,Z)[i]),n}dump(){let e=[];for(let i of c(this,a,ht).call(this,{allowStale:true})){let s=t(this,b)[i],r=t(this,m)[i],n=c(this,a,E).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,W)&&t(this,tt)){o.ttl=t(this,W)[i];let h=t(this,X).now()-t(this,tt)[i];o.start=Math.floor(Date.now()-h);}t(this,Z)&&(o.size=t(this,Z)[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,X).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var ot,M,q,w;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:d}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,L=t(this,Ot).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&L>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),c(this,a,dt).call(this,e,"set"),this;let S=t(this,U)===0?void 0:t(this,O).get(e);if(S===void 0)S=t(this,U)===0?t(this,D):t(this,Q).length!==0?t(this,Q).pop():t(this,U)===t(this,k)?c(this,a,Dt).call(this,false):t(this,U),t(this,b)[S]=e,t(this,m)[S]=i,t(this,O).set(e,S),t(this,j)[t(this,D)]=S,t(this,V)[S]=t(this,D),f(this,D,S),Rt(this,U)._++,t(this,bt).call(this,S,L,d),d&&(d.set="add"),v=false,t(this,Et)&&((ot=t(this,ft))==null||ot.call(this,i,e,"add"));else {c(this,a,At).call(this,S);let y=t(this,m)[S];if(i!==y){if(t(this,pt)&&c(this,a,E).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=y;g!==void 0&&!o&&(t(this,et)&&((M=t(this,$))==null||M.call(this,g,e,"set")),t(this,I)&&t(this,C)?.push([g,e,"set"]));}else o||(t(this,et)&&((q=t(this,$))==null||q.call(this,y,e,"set")),t(this,I)&&t(this,C)?.push([y,e,"set"]));if(t(this,gt).call(this,S),t(this,bt).call(this,S,L,d),t(this,m)[S]=i,d){d.set="replace";let g=y&&c(this,a,E).call(this,y)?y.__staleWhileFetching:y;g!==void 0&&(d.oldValue=g);}}else d&&(d.set="update");t(this,Et)&&this.onInsert?.(i,e,i===y?"update":"replace");}if(r!==0&&!t(this,W)&&c(this,a,Gt).call(this),t(this,W)&&(v||t(this,Tt).call(this,S,r,n),d&&t(this,nt).call(this,d,S)),!o&&t(this,I)&&t(this,C)){let y=t(this,C),g;for(;g=y?.shift();)(w=t(this,B))==null||w.call(this,...g);}return this}pop(){var e;try{for(;t(this,U);){let i=t(this,m)[t(this,F)];if(c(this,a,Dt).call(this,!0),c(this,a,E).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,I)&&t(this,C)){let i=t(this,C),s;for(;s=i?.shift();)(e=t(this,B))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,O).get(e);if(n!==void 0){let o=t(this,m)[n];if(c(this,a,E).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,H).call(this,n))r&&(r.has="stale",t(this,nt).call(this,r,n));else return s&&t(this,mt).call(this,n),r&&(r.has="hit",t(this,nt).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,O).get(e);if(r===void 0||!s&&t(this,H).call(this,r))return;let n=t(this,m)[r];return c(this,a,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:h=this.noDisposeOnSet,size:d=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ot=this.allowStaleOnFetchRejection,ignoreFetchAbort:M=this.ignoreFetchAbort,allowStaleOnFetchAbort:q=this.allowStaleOnFetchAbort,context:w,forceRefresh:y=false,status:g,signal:u}=i;if(!t(this,pt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let x={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:h,size:d,sizeCalculation:v,noUpdateTTL:L,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:ot,allowStaleOnFetchAbort:q,ignoreFetchAbort:M,status:g,signal:u},T=t(this,O).get(e);if(T===void 0){g&&(g.fetch="miss");let p=c(this,a,Ct).call(this,e,T,x,w);return p.__returned=p}else {let p=t(this,m)[T];if(c(this,a,E).call(this,p)){let vt=s&&p.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",vt&&(g.returnedStale=true)),vt?p.__staleWhileFetching:p.__returned=p}let A=t(this,H).call(this,T);if(!y&&!A)return g&&(g.fetch="hit"),c(this,a,At).call(this,T),r&&t(this,mt).call(this,T),g&&t(this,nt).call(this,g,T),p;let N=c(this,a,Ct).call(this,e,T,x,w),K=N.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=A?"stale":"refresh",K&&A&&(g.returnedStale=true)),K?N.__staleWhileFetching:N.__returned=N}}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,h=this.get(e,o);if(!n&&h!==void 0)return h;let d=s(e,h,{options:o,context:r});return this.set(e,d,o),d}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,h=t(this,O).get(e);if(h!==void 0){let d=t(this,m)[h],v=c(this,a,E).call(this,d);return o&&t(this,nt).call(this,o,h),t(this,H).call(this,h)?(o&&(o.get="stale"),v?(o&&s&&d.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?d.__staleWhileFetching:void 0):(n||c(this,a,dt).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?d:void 0)):(o&&(o.get="hit"),v?d.__staleWhileFetching:(c(this,a,At).call(this,h),r&&t(this,mt).call(this,h),d))}else o&&(o.get="miss");}delete(e){return c(this,a,dt).call(this,e,"delete")}clear(){return c(this,a,Vt).call(this,"delete")}},k=new WeakMap,z=new WeakMap,$=new WeakMap,ft=new WeakMap,B=new WeakMap,yt=new WeakMap,xt=new WeakMap,X=new WeakMap,U=new WeakMap,J=new WeakMap,O=new WeakMap,b=new WeakMap,m=new WeakMap,j=new WeakMap,V=new WeakMap,F=new WeakMap,D=new WeakMap,Q=new WeakMap,C=new WeakMap,Z=new WeakMap,tt=new WeakMap,W=new WeakMap,Y=new WeakMap,et=new WeakMap,pt=new WeakMap,I=new WeakMap,Et=new WeakMap,a=new WeakSet,Gt=function(){let e=new Lt(t(this,k)),i=new Lt(t(this,k));f(this,W,e),f(this,tt,i);let s=this.ttlAutopurge?new Array(t(this,k)):void 0;f(this,Y,s),f(this,Tt,(h,d,v=t(this,X).now())=>{i[h]=d!==0?v:0,e[h]=d,r(h,d);}),f(this,mt,h=>{i[h]=e[h]!==0?t(this,X).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,d)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),d&&d!==0&&s){let v=setTimeout(()=>{t(this,H).call(this,h)&&c(this,a,dt).call(this,t(this,b)[h],"expire");},d+1);v.unref&&v.unref(),s[h]=v;}}:()=>{};f(this,nt,(h,d)=>{if(e[d]){let v=e[d],L=i[d];if(!v||!L)return;h.ttl=v,h.start=L,h.now=n||o();let S=h.now-L;h.remainingTTL=v-S;}});let n=0,o=()=>{let h=t(this,X).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=t(this,O).get(h);if(d===void 0)return 0;let v=e[d],L=i[d];if(!v||!L)return 1/0;let S=(n||o())-L;return v-S},f(this,H,h=>{let d=i[h],v=e[h];return !!v&&!!d&&(n||o())-d>v});},mt=new WeakMap,nt=new WeakMap,Tt=new WeakMap,H=new WeakMap,oe=function(){let e=new Lt(t(this,k));f(this,J,0),f(this,Z,e),f(this,gt,i=>{f(this,J,t(this,J)-e[i]),e[i]=0;}),f(this,Ot,(i,s,r,n)=>{if(c(this,a,E).call(this,s))return 0;if(!lt(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!lt(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}),f(this,bt,(i,s,r)=>{if(e[i]=s,t(this,z)){let n=t(this,z)-e[i];for(;t(this,J)>n;)c(this,a,Dt).call(this,true);}f(this,J,t(this,J)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,J));});},gt=new WeakMap,bt=new WeakMap,Ot=new WeakMap,ht=function*({allowStale:e=this.allowStale}={}){if(t(this,U))for(let i=t(this,D);!(!c(this,a,Mt).call(this,i)||((e||!t(this,H).call(this,i))&&(yield i),i===t(this,F)));)i=t(this,V)[i];},ct=function*({allowStale:e=this.allowStale}={}){if(t(this,U))for(let i=t(this,F);!(!c(this,a,Mt).call(this,i)||((e||!t(this,H).call(this,i))&&(yield i),i===t(this,D)));)i=t(this,j)[i];},Mt=function(e){return e!==void 0&&t(this,O).get(t(this,b)[e])===e},Dt=function(e){var n;let i=t(this,F),s=t(this,b)[i],r=t(this,m)[i];return t(this,pt)&&c(this,a,E).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,et)||t(this,I))&&(t(this,et)&&((n=t(this,$))==null||n.call(this,r,s,"evict")),t(this,I)&&t(this,C)?.push([r,s,"evict"])),t(this,gt).call(this,i),t(this,Y)?.[i]&&(clearTimeout(t(this,Y)[i]),t(this,Y)[i]=void 0),e&&(t(this,b)[i]=void 0,t(this,m)[i]=void 0,t(this,Q).push(i)),t(this,U)===1?(f(this,F,f(this,D,0)),t(this,Q).length=0):f(this,F,t(this,j)[i]),t(this,O).delete(s),Rt(this,U)._--,i},Ct=function(e,i,s,r){let n=i===void 0?void 0:t(this,m)[i];if(c(this,a,E).call(this,n))return n;let o=new Pt,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let d={signal:o.signal,options:s,context:r},v=(w,y=false)=>{let{aborted:g}=o.signal,u=s.ignoreFetchAbort&&w!==void 0,x=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&w!==void 0);if(s.status&&(g&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,u&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!u&&!y)return S(o.signal.reason,x);let T=M,p=t(this,m)[i];return (p===M||u&&y&&p===void 0)&&(w===void 0?T.__staleWhileFetching!==void 0?t(this,m)[i]=T.__staleWhileFetching:c(this,a,dt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,w,d.options))),w},L=w=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=w),S(w,false)),S=(w,y)=>{let{aborted:g}=o.signal,u=g&&s.allowStaleOnFetchAbort,x=u||s.allowStaleOnFetchRejection,T=x||s.noDeleteOnFetchRejection,p=M;if(t(this,m)[i]===M&&(!T||!y&&p.__staleWhileFetching===void 0?c(this,a,dt).call(this,e,"fetch"):u||(t(this,m)[i]=p.__staleWhileFetching)),x)return s.status&&p.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),p.__staleWhileFetching;if(p.__returned===p)throw w},ot=(w,y)=>{var u;let g=(u=t(this,yt))==null?void 0:u.call(this,e,n,d);g&&g instanceof Promise&&g.then(x=>w(x===void 0?void 0:x),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(w(void 0),s.allowStaleOnFetchAbort&&(w=x=>v(x,true)));});};s.status&&(s.status.fetchDispatched=true);let M=new Promise(ot).then(v,L),q=Object.assign(M,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,q,{...d.options,status:void 0}),i=t(this,O).get(e)):t(this,m)[i]=q,q},E=function(e){if(!t(this,pt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Pt},zt=function(e,i){t(this,V)[i]=e,t(this,j)[e]=i;},At=function(e){e!==t(this,D)&&(e===t(this,F)?f(this,F,t(this,j)[e]):c(this,a,zt).call(this,t(this,V)[e],t(this,j)[e]),c(this,a,zt).call(this,t(this,D),e),f(this,D,e));},dt=function(e,i){var r,n;let s=false;if(t(this,U)!==0){let o=t(this,O).get(e);if(o!==void 0)if(t(this,Y)?.[o]&&(clearTimeout(t(this,Y)?.[o]),t(this,Y)[o]=void 0),s=true,t(this,U)===1)c(this,a,Vt).call(this,i);else {t(this,gt).call(this,o);let h=t(this,m)[o];if(c(this,a,E).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,et)||t(this,I))&&(t(this,et)&&((r=t(this,$))==null||r.call(this,h,e,i)),t(this,I)&&t(this,C)?.push([h,e,i])),t(this,O).delete(e),t(this,b)[o]=void 0,t(this,m)[o]=void 0,o===t(this,D))f(this,D,t(this,V)[o]);else if(o===t(this,F))f(this,F,t(this,j)[o]);else {let d=t(this,V)[o];t(this,j)[d]=t(this,j)[o];let v=t(this,j)[o];t(this,V)[v]=t(this,V)[o];}Rt(this,U)._--,t(this,Q).push(o);}}if(t(this,I)&&t(this,C)?.length){let o=t(this,C),h;for(;h=o?.shift();)(n=t(this,B))==null||n.call(this,...h);}return s},Vt=function(e){var i,s;for(let r of c(this,a,ct).call(this,{allowStale:true})){let n=t(this,m)[r];if(c(this,a,E).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,b)[r];t(this,et)&&((i=t(this,$))==null||i.call(this,n,o,e)),t(this,I)&&t(this,C)?.push([n,o,e]);}}if(t(this,O).clear(),t(this,m).fill(void 0),t(this,b).fill(void 0),t(this,W)&&t(this,tt)){t(this,W).fill(0),t(this,tt).fill(0);for(let r of t(this,Y)??[])r!==void 0&&clearTimeout(r);t(this,Y)?.fill(void 0);}if(t(this,Z)&&t(this,Z).fill(0),f(this,F,0),f(this,D,0),t(this,Q).length=0,f(this,J,0),f(this,U,0),t(this,I)&&t(this,C)){let r=t(this,C),n;for(;n=r?.shift();)(s=t(this,B))==null||s.call(this,...n);}},wt);var Nt=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.25";var Wt={version:Ut};var Yt="repeat";function Ht(l){return {type:"pause",duration:l}}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 _t;(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)))(_t||={});function le(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw _t.error("Error creating exportable element",l,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 l=[],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),h=n.slice(ce),d=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(d),e.push(xe,o,Ee,h),r&&e.push(be,qt);}console.info(l.join(`
2
- `),...e);}function $t(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}de();exports.Game=void 0;(g=>{async function l(u,x,T){if(core.GameUnifier.init({navigate:x?.navigate,getCurrentGameStepState:()=>{let p={};try{p=at__namespace.canvas.export();}catch{}return {path:$t(),storage:G__namespace.storage.export(),canvas:p,sound:ut__namespace.sound.export(),labelIndex:R__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:R__namespace.narration.openedLabels}},restoreGameStepState:async(p,A)=>{it__namespace.HistoryManagerStatic._originalStepData=p,R__namespace.NarrationManagerStatic.openedLabels=p.openedLabels,G__namespace.storage.restore(p.storage);try{await at__namespace.canvas.restore(p.canvas),await ut__namespace.sound.restore(p.sound);}catch(N){_t.error("Error restoring game step state:",N);}await A(p.path);},getStepCounter:()=>R__namespace.narration.stepCounter,setStepCounter:p=>{R__namespace.NarrationManagerStatic._stepCounter=p;},getOpenedLabels:()=>R__namespace.narration.openedLabels.length,addHistoryItem:(p,A)=>it__namespace.stepHistory.add(p,A),getCharacter:p=>Bt__namespace.RegisteredCharacters.get(p),processNavigationRequests:(p,A)=>{let N=p,K=Promise.resolve();return p>0?(N--,K=R__namespace.narration.continue(A)):p<0&&(N=0,K=it__namespace.stepHistory.back(A,{steps:p*-1})),{newValue:N,result:K}},animate:(p,A,N,K)=>motion.motion.animate(p,A,N,K),getVariable:(p,A)=>G__namespace.StorageRegistry.getVariable(p,A),setVariable:(p,A,N)=>G__namespace.StorageRegistry.setVariable(p,A,N),removeVariable:(p,A)=>G__namespace.StorageRegistry.removeVariable(p,A),getFlag:p=>G__namespace.storage.getFlag(p),setFlag:(p,A)=>G__namespace.storage.setFlag(p,A),onLabelClosing:p=>G__namespace.StorageRegistry.clearOldTempVariables(p)}),!u||!x){_t.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await at__namespace.canvas.init(u,x,T)}g.init=l;function e(){G__namespace.storage.clear();try{at__namespace.canvas.clear();}catch{}ut__namespace.sound.clear(),R__namespace.narration.clear(),it__namespace.stepHistory.clear();}g.clear=e;function i(){let u={};try{u=at__namespace.canvas.export();}catch{}return {pixivn_version:Ut,stepData:R__namespace.narration.export(),storageData:G__namespace.storage.export(),canvasData:u,soundData:ut__namespace.sound.export(),historyData:it__namespace.stepHistory.export(),path:$t()}}g.exportGameState=i;async function s(u,x){it__namespace.stepHistory.restore(u.historyData);let T=it__namespace.stepHistory.lastKey;if(typeof T=="number"){let p=it__namespace.stepHistory.stepsInfoMap.get(T)||null;await R__namespace.narration.restore(u.stepData,p);}G__namespace.storage.restore(u.storageData);try{await at__namespace.canvas.restore(u.canvasData),await ut__namespace.sound.restore(u.soundData);}catch{}x?await x(u.path):await core.GameUnifier.navigate(u.path);}g.restoreGameState=s;async function r(u,x){return g.clear(),await R__namespace.narration.call(u,x)}g.start=r;function n(u){return JSON.parse(u)}g.jsonToGameState=n;function o(u){core.GameUnifier.onEnd=u;}g.onEnd=o;function h(u){return _t.warn("Game.onError is deprecated. Use Game.addOnError / Game.removeOnError to register multiple handlers."),core.GameUnifier.addOnError((x,T)=>u("step",x,T))}g.onError=h;function d(u){return core.GameUnifier.addOnError(u)}g.addOnError=d;function v(u){return core.GameUnifier.removeOnError(u)}g.removeOnError=v;function L(u){R__namespace.NarrationManagerStatic.onStepStart=u;}g.onStepStart=L;function S(u){R__namespace.NarrationManagerStatic.onLoadingLabel=u;}g.onLoadingLabel=S;function ot(u){R__namespace.NarrationManagerStatic.onStepEnd=u;}g.onStepEnd=ot;function M(u){R__namespace.NarrationManagerStatic.onLabelStarting=u;}g.onLabelStarting=M;function q(u){core.GameUnifier.navigate=u;}g.onNavigate=q;function w(u){return core.GameUnifier.addOnPreContinue(u)}g.addOnPreContinue=w;function y(u){return core.GameUnifier.removeOnPreContinue(u)}g.removeOnPreContinue=y;})(exports.Game||={});var Ze={characterUtils:Bt__namespace,canvasUtils:at__namespace,narrationUtils:R__namespace,soundUtils:ut__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Kt,Pause:Ht,Repeat:Yt,PIXIVN_VERSION:Ut,...kt,...ae,canvas:at__namespace.canvas,narration:R__namespace.narration,sound:ut__namespace.sound,storage:G__namespace.storage,history:it__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Kt;exports.CachedMap=Nt;exports.PIXIVN_VERSION=Ut;exports.Pause=Ht;exports.Repeat=Yt;exports.SYSTEM_RESERVED_STORAGE_KEYS=ve;exports.createExportableElement=le;exports.default=Ze;Object.keys(at).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return at[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(it).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return it[k]}})});Object.keys(R).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return R[k]}})});Object.keys(ut).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return ut[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]}})});
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var M=require('@drincs/pixi-vn/canvas'),qt=require('@drincs/pixi-vn/characters'),core=require('@drincs/pixi-vn/core'),st=require('@drincs/pixi-vn/history'),O=require('@drincs/pixi-vn/narration'),ut=require('@drincs/pixi-vn/sound'),z=require('@drincs/pixi-vn/storage'),motion=require('@drincs/pixi-vn/motion');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 M__namespace=/*#__PURE__*/_interopNamespace(M);var qt__namespace=/*#__PURE__*/_interopNamespace(qt);var st__namespace=/*#__PURE__*/_interopNamespace(st);var O__namespace=/*#__PURE__*/_interopNamespace(O);var ut__namespace=/*#__PURE__*/_interopNamespace(ut);var z__namespace=/*#__PURE__*/_interopNamespace(z);var $t=Object.defineProperty;var Bt=l=>{throw TypeError(l)};var de=(l,e,i)=>e in l?$t(l,e,{enumerable:true,configurable:true,writable:true,value:i}):l[e]=i;var pe=(l,e)=>{for(var i in e)$t(l,i,{get:e[i],enumerable:true});};var N=(l,e,i)=>de(l,typeof e!="symbol"?e+"":e,i),jt=(l,e,i)=>e.has(l)||Bt("Cannot "+i);var t=(l,e,i)=>(jt(l,e,"read from private field"),i?i.call(l):e.get(l)),_=(l,e,i)=>e.has(l)?Bt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(l):e.set(l,i),u=(l,e,i,s)=>(jt(l,e,"write to private field"),e.set(l,i),i),c=(l,e,i)=>(jt(l,e,"access private method"),i);var Rt=(l,e,i,s)=>({set _(r){u(l,e,r);},get _(){return t(l,e,s)}});var ue=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,Zt=new Set,Pt=typeof process=="object"&&process?process:{},te=(l,e,i,s)=>{typeof Pt.emitWarning=="function"?Pt.emitWarning(l,e,i,s):console.error(`[${i}] ${e}: ${l}`);},Nt=globalThis.AbortController,Xt=globalThis.AbortSignal;if(typeof Nt>"u"){Xt=class{onabort;_onabort=[];reason;aborted=false;addEventListener(i,s){this._onabort.push(s);}},Nt=class{constructor(){e();}signal=new Xt;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 l=Pt.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{l&&(l=false,te("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 fe=l=>!Zt.has(l);var lt=l=>l&&l===Math.floor(l)&&l>0&&isFinite(l),ee=l=>lt(l)?l<=Math.pow(2,8)?Uint8Array:l<=Math.pow(2,16)?Uint16Array:l<=Math.pow(2,32)?Uint32Array:l<=Number.MAX_SAFE_INTEGER?Lt:null:null,Lt=class extends Array{constructor(l){super(l),this.fill(0);}},rt,vt,me=(rt=class{heap;length;static create(e){let i=ee(e);if(!i)return [];u(rt,vt,true);let s=new rt(e,i);return u(rt,vt,false),s}constructor(e,i){if(!t(rt,vt))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]}},vt=new WeakMap,_(rt,vt,false),rt),Jt,Qt,q,V,B,ft,X,St,yt,J,R,Q,U,x,m,j,W,F,D,Z,C,tt,et,Y,H,it,pt,P,bt,a,Mt,mt,nt,Tt,K,se,gt,xt,Ut,ht,ct,zt,Dt,Ct,b,Gt,At,dt,Vt,Et,ie=(Et=class{constructor(e){_(this,a);_(this,q);_(this,V);_(this,B);_(this,ft);_(this,X);_(this,St);_(this,yt);_(this,J);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,Q);_(this,U);_(this,x);_(this,m);_(this,j);_(this,W);_(this,F);_(this,D);_(this,Z);_(this,C);_(this,tt);_(this,et);_(this,Y);_(this,H);_(this,it);_(this,pt);_(this,P);_(this,bt);_(this,mt,()=>{});_(this,nt,()=>{});_(this,Tt,()=>{});_(this,K,()=>false);_(this,gt,e=>{});_(this,xt,(e,i,s)=>{});_(this,Ut,(e,i,s,r)=>{if(s||r)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});N(this,Jt,"LRUCache");let{max:i=0,ttl:s,ttlResolution:r=1,ttlAutopurge:n,updateAgeOnGet:o,updateAgeOnHas:h,allowStale:d,dispose:v,onInsert:L,disposeAfter:S,noDisposeOnSet:ot,noUpdateTTL:G,maxSize:$=0,maxEntrySize:E=0,sizeCalculation:y,fetchMethod:g,memoMethod:f,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:T,allowStaleOnFetchRejection:p,allowStaleOnFetchAbort:A,ignoreFetchAbort:I,perf:k}=e;if(k!==void 0&&typeof k?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(u(this,J,k??ue),i!==0&&!lt(i))throw new TypeError("max option must be a nonnegative integer");let _t=i?ee(i):Array;if(!_t)throw new Error("invalid max value: "+i);if(u(this,q,i),u(this,V,$),this.maxEntrySize=E||t(this,V),this.sizeCalculation=y,this.sizeCalculation){if(!t(this,V)&&!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(u(this,yt,f),g!==void 0&&typeof g!="function")throw new TypeError("fetchMethod must be a function if specified");if(u(this,St,g),u(this,pt,!!g),u(this,U,new Map),u(this,x,new Array(i).fill(void 0)),u(this,m,new Array(i).fill(void 0)),u(this,j,new _t(i)),u(this,W,new _t(i)),u(this,F,0),u(this,D,0),u(this,Z,me.create(i)),u(this,R,0),u(this,Q,0),typeof v=="function"&&u(this,B,v),typeof L=="function"&&u(this,ft,L),typeof S=="function"?(u(this,X,S),u(this,C,[])):(u(this,X,void 0),u(this,C,void 0)),u(this,it,!!t(this,B)),u(this,bt,!!t(this,ft)),u(this,P,!!t(this,X)),this.noDisposeOnSet=!!ot,this.noUpdateTTL=!!G,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!p,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!I,this.maxEntrySize!==0){if(t(this,V)!==0&&!lt(t(this,V)))throw new TypeError("maxSize must be a positive integer if specified");if(!lt(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");c(this,a,se).call(this);}if(this.allowStale=!!d,this.noDeleteOnStaleGet=!!T,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!h,this.ttlResolution=lt(r)||r===0?r:1,this.ttlAutopurge=!!n,this.ttl=s||0,this.ttl){if(!lt(this.ttl))throw new TypeError("ttl must be a positive integer if specified");c(this,a,Mt).call(this);}if(t(this,q)===0&&this.ttl===0&&t(this,V)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!t(this,q)&&!t(this,V)){let Ft="LRU_CACHE_UNBOUNDED";fe(Ft)&&(Zt.add(Ft),te("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Ft,Et));}}get perf(){return t(this,J)}static unsafeExposeInternals(e){return {starts:t(e,et),ttls:t(e,Y),autopurgeTimers:t(e,H),sizes:t(e,tt),keyMap:t(e,U),keyList:t(e,x),valList:t(e,m),next:t(e,j),prev:t(e,W),get head(){return t(e,F)},get tail(){return t(e,D)},free:t(e,Z),isBackgroundFetch:i=>{var s;return c(s=e,a,b).call(s,i)},backgroundFetch:(i,s,r,n)=>{var o;return c(o=e,a,Ct).call(o,i,s,r,n)},moveToTail:i=>{var s;return c(s=e,a,At).call(s,i)},indexes:i=>{var s;return c(s=e,a,ht).call(s,i)},rindexes:i=>{var s;return c(s=e,a,ct).call(s,i)},isStale:i=>{var s;return t(s=e,K).call(s,i)}}}get max(){return t(this,q)}get maxSize(){return t(this,V)}get calculatedSize(){return t(this,Q)}get size(){return t(this,R)}get fetchMethod(){return t(this,St)}get memoMethod(){return t(this,yt)}get dispose(){return t(this,B)}get onInsert(){return t(this,ft)}get disposeAfter(){return t(this,X)}getRemainingTTL(e){return t(this,U).has(e)?1/0:0}*entries(){for(let e of c(this,a,ht).call(this))t(this,m)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield [t(this,x)[e],t(this,m)[e]]);}*rentries(){for(let e of c(this,a,ct).call(this))t(this,m)[e]!==void 0&&t(this,x)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield [t(this,x)[e],t(this,m)[e]]);}*keys(){for(let e of c(this,a,ht).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield i);}}*rkeys(){for(let e of c(this,a,ct).call(this)){let i=t(this,x)[e];i!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield i);}}*values(){for(let e of c(this,a,ht).call(this))t(this,m)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}*rvalues(){for(let e of c(this,a,ct).call(this))t(this,m)[e]!==void 0&&!c(this,a,b).call(this,t(this,m)[e])&&(yield t(this,m)[e]);}[(Qt=Symbol.iterator,Jt=Symbol.toStringTag,Qt)](){return this.entries()}find(e,i={}){for(let s of c(this,a,ht).call(this)){let r=t(this,m)[s],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;if(n!==void 0&&e(n,t(this,x)[s],this))return this.get(t(this,x)[s],i)}}forEach(e,i=this){for(let s of c(this,a,ht).call(this)){let r=t(this,m)[s],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,x)[s],this);}}rforEach(e,i=this){for(let s of c(this,a,ct).call(this)){let r=t(this,m)[s],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;n!==void 0&&e.call(i,n,t(this,x)[s],this);}}purgeStale(){let e=false;for(let i of c(this,a,ct).call(this,{allowStale:true}))t(this,K).call(this,i)&&(c(this,a,dt).call(this,t(this,x)[i],"expire"),e=true);return e}info(e){let i=t(this,U).get(e);if(i===void 0)return;let s=t(this,m)[i],r=c(this,a,b).call(this,s)?s.__staleWhileFetching:s;if(r===void 0)return;let n={value:r};if(t(this,Y)&&t(this,et)){let o=t(this,Y)[i],h=t(this,et)[i];if(o&&h){let d=o-(t(this,J).now()-h);n.ttl=d,n.start=Date.now();}}return t(this,tt)&&(n.size=t(this,tt)[i]),n}dump(){let e=[];for(let i of c(this,a,ht).call(this,{allowStale:true})){let s=t(this,x)[i],r=t(this,m)[i],n=c(this,a,b).call(this,r)?r.__staleWhileFetching:r;if(n===void 0||s===void 0)continue;let o={value:n};if(t(this,Y)&&t(this,et)){o.ttl=t(this,Y)[i];let h=t(this,J).now()-t(this,et)[i];o.start=Math.floor(Date.now()-h);}t(this,tt)&&(o.size=t(this,tt)[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,J).now()-r;}this.set(i,s.value,s);}}set(e,i,s={}){var ot,G,$,E;if(i===void 0)return this.delete(e),this;let{ttl:r=this.ttl,start:n,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:d}=s,{noUpdateTTL:v=this.noUpdateTTL}=s,L=t(this,Ut).call(this,e,i,s.size||0,h);if(this.maxEntrySize&&L>this.maxEntrySize)return d&&(d.set="miss",d.maxEntrySizeExceeded=true),c(this,a,dt).call(this,e,"set"),this;let S=t(this,R)===0?void 0:t(this,U).get(e);if(S===void 0)S=t(this,R)===0?t(this,D):t(this,Z).length!==0?t(this,Z).pop():t(this,R)===t(this,q)?c(this,a,Dt).call(this,false):t(this,R),t(this,x)[S]=e,t(this,m)[S]=i,t(this,U).set(e,S),t(this,j)[t(this,D)]=S,t(this,W)[S]=t(this,D),u(this,D,S),Rt(this,R)._++,t(this,xt).call(this,S,L,d),d&&(d.set="add"),v=false,t(this,bt)&&((ot=t(this,ft))==null||ot.call(this,i,e,"add"));else {c(this,a,At).call(this,S);let y=t(this,m)[S];if(i!==y){if(t(this,pt)&&c(this,a,b).call(this,y)){y.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:g}=y;g!==void 0&&!o&&(t(this,it)&&((G=t(this,B))==null||G.call(this,g,e,"set")),t(this,P)&&t(this,C)?.push([g,e,"set"]));}else o||(t(this,it)&&(($=t(this,B))==null||$.call(this,y,e,"set")),t(this,P)&&t(this,C)?.push([y,e,"set"]));if(t(this,gt).call(this,S),t(this,xt).call(this,S,L,d),t(this,m)[S]=i,d){d.set="replace";let g=y&&c(this,a,b).call(this,y)?y.__staleWhileFetching:y;g!==void 0&&(d.oldValue=g);}}else d&&(d.set="update");t(this,bt)&&this.onInsert?.(i,e,i===y?"update":"replace");}if(r!==0&&!t(this,Y)&&c(this,a,Mt).call(this),t(this,Y)&&(v||t(this,Tt).call(this,S,r,n),d&&t(this,nt).call(this,d,S)),!o&&t(this,P)&&t(this,C)){let y=t(this,C),g;for(;g=y?.shift();)(E=t(this,X))==null||E.call(this,...g);}return this}pop(){var e;try{for(;t(this,R);){let i=t(this,m)[t(this,F)];if(c(this,a,Dt).call(this,!0),c(this,a,b).call(this,i)){if(i.__staleWhileFetching)return i.__staleWhileFetching}else if(i!==void 0)return i}}finally{if(t(this,P)&&t(this,C)){let i=t(this,C),s;for(;s=i?.shift();)(e=t(this,X))==null||e.call(this,...s);}}}has(e,i={}){let{updateAgeOnHas:s=this.updateAgeOnHas,status:r}=i,n=t(this,U).get(e);if(n!==void 0){let o=t(this,m)[n];if(c(this,a,b).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(t(this,K).call(this,n))r&&(r.has="stale",t(this,nt).call(this,r,n));else return s&&t(this,mt).call(this,n),r&&(r.has="hit",t(this,nt).call(this,r,n)),true}else r&&(r.has="miss");return false}peek(e,i={}){let{allowStale:s=this.allowStale}=i,r=t(this,U).get(e);if(r===void 0||!s&&t(this,K).call(this,r))return;let n=t(this,m)[r];return c(this,a,b).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:h=this.noDisposeOnSet,size:d=0,sizeCalculation:v=this.sizeCalculation,noUpdateTTL:L=this.noUpdateTTL,noDeleteOnFetchRejection:S=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:ot=this.allowStaleOnFetchRejection,ignoreFetchAbort:G=this.ignoreFetchAbort,allowStaleOnFetchAbort:$=this.allowStaleOnFetchAbort,context:E,forceRefresh:y=false,status:g,signal:f}=i;if(!t(this,pt))return g&&(g.fetch="get"),this.get(e,{allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,status:g});let w={allowStale:s,updateAgeOnGet:r,noDeleteOnStaleGet:n,ttl:o,noDisposeOnSet:h,size:d,sizeCalculation:v,noUpdateTTL:L,noDeleteOnFetchRejection:S,allowStaleOnFetchRejection:ot,allowStaleOnFetchAbort:$,ignoreFetchAbort:G,status:g,signal:f},T=t(this,U).get(e);if(T===void 0){g&&(g.fetch="miss");let p=c(this,a,Ct).call(this,e,T,w,E);return p.__returned=p}else {let p=t(this,m)[T];if(c(this,a,b).call(this,p)){let _t=s&&p.__staleWhileFetching!==void 0;return g&&(g.fetch="inflight",_t&&(g.returnedStale=true)),_t?p.__staleWhileFetching:p.__returned=p}let A=t(this,K).call(this,T);if(!y&&!A)return g&&(g.fetch="hit"),c(this,a,At).call(this,T),r&&t(this,mt).call(this,T),g&&t(this,nt).call(this,g,T),p;let I=c(this,a,Ct).call(this,e,T,w,E),k=I.__staleWhileFetching!==void 0&&s;return g&&(g.fetch=A?"stale":"refresh",k&&A&&(g.returnedStale=true)),k?I.__staleWhileFetching:I.__returned=I}}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,yt);if(!s)throw new Error("no memoMethod provided to constructor");let{context:r,forceRefresh:n,...o}=i,h=this.get(e,o);if(!n&&h!==void 0)return h;let d=s(e,h,{options:o,context:r});return this.set(e,d,o),d}get(e,i={}){let{allowStale:s=this.allowStale,updateAgeOnGet:r=this.updateAgeOnGet,noDeleteOnStaleGet:n=this.noDeleteOnStaleGet,status:o}=i,h=t(this,U).get(e);if(h!==void 0){let d=t(this,m)[h],v=c(this,a,b).call(this,d);return o&&t(this,nt).call(this,o,h),t(this,K).call(this,h)?(o&&(o.get="stale"),v?(o&&s&&d.__staleWhileFetching!==void 0&&(o.returnedStale=true),s?d.__staleWhileFetching:void 0):(n||c(this,a,dt).call(this,e,"expire"),o&&s&&(o.returnedStale=true),s?d:void 0)):(o&&(o.get="hit"),v?d.__staleWhileFetching:(c(this,a,At).call(this,h),r&&t(this,mt).call(this,h),d))}else o&&(o.get="miss");}delete(e){return c(this,a,dt).call(this,e,"delete")}clear(){return c(this,a,Vt).call(this,"delete")}},q=new WeakMap,V=new WeakMap,B=new WeakMap,ft=new WeakMap,X=new WeakMap,St=new WeakMap,yt=new WeakMap,J=new WeakMap,R=new WeakMap,Q=new WeakMap,U=new WeakMap,x=new WeakMap,m=new WeakMap,j=new WeakMap,W=new WeakMap,F=new WeakMap,D=new WeakMap,Z=new WeakMap,C=new WeakMap,tt=new WeakMap,et=new WeakMap,Y=new WeakMap,H=new WeakMap,it=new WeakMap,pt=new WeakMap,P=new WeakMap,bt=new WeakMap,a=new WeakSet,Mt=function(){let e=new Lt(t(this,q)),i=new Lt(t(this,q));u(this,Y,e),u(this,et,i);let s=this.ttlAutopurge?new Array(t(this,q)):void 0;u(this,H,s),u(this,Tt,(h,d,v=t(this,J).now())=>{i[h]=d!==0?v:0,e[h]=d,r(h,d);}),u(this,mt,h=>{i[h]=e[h]!==0?t(this,J).now():0,r(h,e[h]);});let r=this.ttlAutopurge?(h,d)=>{if(s?.[h]&&(clearTimeout(s[h]),s[h]=void 0),d&&d!==0&&s){let v=setTimeout(()=>{t(this,K).call(this,h)&&c(this,a,dt).call(this,t(this,x)[h],"expire");},d+1);v.unref&&v.unref(),s[h]=v;}}:()=>{};u(this,nt,(h,d)=>{if(e[d]){let v=e[d],L=i[d];if(!v||!L)return;h.ttl=v,h.start=L,h.now=n||o();let S=h.now-L;h.remainingTTL=v-S;}});let n=0,o=()=>{let h=t(this,J).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=t(this,U).get(h);if(d===void 0)return 0;let v=e[d],L=i[d];if(!v||!L)return 1/0;let S=(n||o())-L;return v-S},u(this,K,h=>{let d=i[h],v=e[h];return !!v&&!!d&&(n||o())-d>v});},mt=new WeakMap,nt=new WeakMap,Tt=new WeakMap,K=new WeakMap,se=function(){let e=new Lt(t(this,q));u(this,Q,0),u(this,tt,e),u(this,gt,i=>{u(this,Q,t(this,Q)-e[i]),e[i]=0;}),u(this,Ut,(i,s,r,n)=>{if(c(this,a,b).call(this,s))return 0;if(!lt(r))if(n){if(typeof n!="function")throw new TypeError("sizeCalculation must be a function");if(r=n(s,i),!lt(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,xt,(i,s,r)=>{if(e[i]=s,t(this,V)){let n=t(this,V)-e[i];for(;t(this,Q)>n;)c(this,a,Dt).call(this,true);}u(this,Q,t(this,Q)+e[i]),r&&(r.entrySize=s,r.totalCalculatedSize=t(this,Q));});},gt=new WeakMap,xt=new WeakMap,Ut=new WeakMap,ht=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,D);!(!c(this,a,zt).call(this,i)||((e||!t(this,K).call(this,i))&&(yield i),i===t(this,F)));)i=t(this,W)[i];},ct=function*({allowStale:e=this.allowStale}={}){if(t(this,R))for(let i=t(this,F);!(!c(this,a,zt).call(this,i)||((e||!t(this,K).call(this,i))&&(yield i),i===t(this,D)));)i=t(this,j)[i];},zt=function(e){return e!==void 0&&t(this,U).get(t(this,x)[e])===e},Dt=function(e){var n;let i=t(this,F),s=t(this,x)[i],r=t(this,m)[i];return t(this,pt)&&c(this,a,b).call(this,r)?r.__abortController.abort(new Error("evicted")):(t(this,it)||t(this,P))&&(t(this,it)&&((n=t(this,B))==null||n.call(this,r,s,"evict")),t(this,P)&&t(this,C)?.push([r,s,"evict"])),t(this,gt).call(this,i),t(this,H)?.[i]&&(clearTimeout(t(this,H)[i]),t(this,H)[i]=void 0),e&&(t(this,x)[i]=void 0,t(this,m)[i]=void 0,t(this,Z).push(i)),t(this,R)===1?(u(this,F,u(this,D,0)),t(this,Z).length=0):u(this,F,t(this,j)[i]),t(this,U).delete(s),Rt(this,R)._--,i},Ct=function(e,i,s,r){let n=i===void 0?void 0:t(this,m)[i];if(c(this,a,b).call(this,n))return n;let o=new Nt,{signal:h}=s;h?.addEventListener("abort",()=>o.abort(h.reason),{signal:o.signal});let d={signal:o.signal,options:s,context:r},v=(E,y=false)=>{let{aborted:g}=o.signal,f=s.ignoreFetchAbort&&E!==void 0,w=s.ignoreFetchAbort||!!(s.allowStaleOnFetchAbort&&E!==void 0);if(s.status&&(g&&!y?(s.status.fetchAborted=true,s.status.fetchError=o.signal.reason,f&&(s.status.fetchAbortIgnored=true)):s.status.fetchResolved=true),g&&!f&&!y)return S(o.signal.reason,w);let T=G,p=t(this,m)[i];return (p===G||f&&y&&p===void 0)&&(E===void 0?T.__staleWhileFetching!==void 0?t(this,m)[i]=T.__staleWhileFetching:c(this,a,dt).call(this,e,"fetch"):(s.status&&(s.status.fetchUpdated=true),this.set(e,E,d.options))),E},L=E=>(s.status&&(s.status.fetchRejected=true,s.status.fetchError=E),S(E,false)),S=(E,y)=>{let{aborted:g}=o.signal,f=g&&s.allowStaleOnFetchAbort,w=f||s.allowStaleOnFetchRejection,T=w||s.noDeleteOnFetchRejection,p=G;if(t(this,m)[i]===G&&(!T||!y&&p.__staleWhileFetching===void 0?c(this,a,dt).call(this,e,"fetch"):f||(t(this,m)[i]=p.__staleWhileFetching)),w)return s.status&&p.__staleWhileFetching!==void 0&&(s.status.returnedStale=true),p.__staleWhileFetching;if(p.__returned===p)throw E},ot=(E,y)=>{var f;let g=(f=t(this,St))==null?void 0:f.call(this,e,n,d);g&&g instanceof Promise&&g.then(w=>E(w===void 0?void 0:w),y),o.signal.addEventListener("abort",()=>{(!s.ignoreFetchAbort||s.allowStaleOnFetchAbort)&&(E(void 0),s.allowStaleOnFetchAbort&&(E=w=>v(w,true)));});};s.status&&(s.status.fetchDispatched=true);let G=new Promise(ot).then(v,L),$=Object.assign(G,{__abortController:o,__staleWhileFetching:n,__returned:void 0});return i===void 0?(this.set(e,$,{...d.options,status:void 0}),i=t(this,U).get(e)):t(this,m)[i]=$,$},b=function(e){if(!t(this,pt))return false;let i=e;return !!i&&i instanceof Promise&&i.hasOwnProperty("__staleWhileFetching")&&i.__abortController instanceof Nt},Gt=function(e,i){t(this,W)[i]=e,t(this,j)[e]=i;},At=function(e){e!==t(this,D)&&(e===t(this,F)?u(this,F,t(this,j)[e]):c(this,a,Gt).call(this,t(this,W)[e],t(this,j)[e]),c(this,a,Gt).call(this,t(this,D),e),u(this,D,e));},dt=function(e,i){var r,n;let s=false;if(t(this,R)!==0){let o=t(this,U).get(e);if(o!==void 0)if(t(this,H)?.[o]&&(clearTimeout(t(this,H)?.[o]),t(this,H)[o]=void 0),s=true,t(this,R)===1)c(this,a,Vt).call(this,i);else {t(this,gt).call(this,o);let h=t(this,m)[o];if(c(this,a,b).call(this,h)?h.__abortController.abort(new Error("deleted")):(t(this,it)||t(this,P))&&(t(this,it)&&((r=t(this,B))==null||r.call(this,h,e,i)),t(this,P)&&t(this,C)?.push([h,e,i])),t(this,U).delete(e),t(this,x)[o]=void 0,t(this,m)[o]=void 0,o===t(this,D))u(this,D,t(this,W)[o]);else if(o===t(this,F))u(this,F,t(this,j)[o]);else {let d=t(this,W)[o];t(this,j)[d]=t(this,j)[o];let v=t(this,j)[o];t(this,W)[v]=t(this,W)[o];}Rt(this,R)._--,t(this,Z).push(o);}}if(t(this,P)&&t(this,C)?.length){let o=t(this,C),h;for(;h=o?.shift();)(n=t(this,X))==null||n.call(this,...h);}return s},Vt=function(e){var i,s;for(let r of c(this,a,ct).call(this,{allowStale:true})){let n=t(this,m)[r];if(c(this,a,b).call(this,n))n.__abortController.abort(new Error("deleted"));else {let o=t(this,x)[r];t(this,it)&&((i=t(this,B))==null||i.call(this,n,o,e)),t(this,P)&&t(this,C)?.push([n,o,e]);}}if(t(this,U).clear(),t(this,m).fill(void 0),t(this,x).fill(void 0),t(this,Y)&&t(this,et)){t(this,Y).fill(0),t(this,et).fill(0);for(let r of t(this,H)??[])r!==void 0&&clearTimeout(r);t(this,H)?.fill(void 0);}if(t(this,tt)&&t(this,tt).fill(0),u(this,F,0),u(this,D,0),t(this,Z).length=0,u(this,Q,0),u(this,R,0),t(this,P)&&t(this,C)){let r=t(this,C),n;for(;n=r?.shift();)(s=t(this,X))==null||s.call(this,...n);}},Et);var It=class{cache;map=new Map;constructor(e){this.cache=new ie({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 Ot="1.9.0";var Wt={version:Ot};var Yt="__game_layer__";var ge={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 oe={};var Ht={};pe(Ht,{createExportableElement:()=>ne});var wt;(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)))(wt||={});function ne(l){try{if(typeof l>"u")return l;let e=JSON.stringify(l);return JSON.parse(e)}catch(e){throw wt.error("Error creating exportable element",l,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var ve=typeof window<"u"&&typeof document<"u",ae=[" _______ _ _ _ ____ ____ ____ _____ ","|_ __ \\ (_) (_) | | |_ _| |_ _||_ \\|_ _|"," | |__) |__ _ __ __ \\_| \\ \\ / / | \\ | | "," | ___/[ | [ \\ [ ][ | \\ \\ / / | |\\ \\| | "," _| |_ | | > ' < | | \\ ' / _| |_\\ |_ ",`|_____| [___][__]\`\\_][___] \\_/ |_____|\\____| v${Wt.version}`],le=31,Se="background:#2f90da;color:#fff;font-weight:bold;",ye="background:#c832bb;color:#fff;font-weight:bold;",be="background:transparent;font-weight:bold;",Kt=` v${Wt.version}`;function he(){if(!ve)return;let l=[],e=[];for(let i=0;i<ae.length;i++){let s=ae[i],r=s.endsWith(Kt),n=r?s.slice(0,-Kt.length):s,o=n.slice(0,le),h=n.slice(le),d=r?"%c%s%c%s%c%s":"%c%s%c%s";l.push(d),e.push(Se,o,ye,h),r&&e.push(be,Kt);}console.info(l.join(`
2
+ `),...e);}function kt(){let l=window.location.pathname+window.location.hash;return l.includes("#")&&(l=l.split("#")[1]),l}he();exports.Game=void 0;(g=>{async function l(f,w,T){if(core.GameUnifier.init({navigate:w?.navigate,getCurrentGameStepState:()=>{let p=M__namespace.canvas.isInitialized?M__namespace.canvas.export():{};return {path:kt(),storage:z__namespace.storage.export(),canvas:p,sound:ut__namespace.sound.export(),labelIndex:O__namespace.NarrationManagerStatic.currentLabelStepIndex||0,openedLabels:O__namespace.narration.openedLabels}},restoreGameStepState:async(p,A)=>{st__namespace.HistoryManagerStatic._originalStepData=p,O__namespace.NarrationManagerStatic.openedLabels=p.openedLabels,z__namespace.storage.restore(p.storage);try{M__namespace.canvas.isInitialized&&await M__namespace.canvas.restore(p.canvas),await ut__namespace.sound.restore(p.sound);}catch(I){wt.error("Error restoring game step state:",I);}await A(p.path);},getStepCounter:()=>O__namespace.narration.stepCounter,setStepCounter:p=>{O__namespace.NarrationManagerStatic._stepCounter=p;},getOpenedLabels:()=>O__namespace.narration.openedLabels.length,addHistoryItem:(p,A)=>st__namespace.stepHistory.add(p,A),getCharacter:p=>qt__namespace.RegisteredCharacters.get(p),processNavigationRequests:(p,A)=>{let I=p,k=Promise.resolve();return p>0?(I--,k=O__namespace.narration.continue(A)):p<0&&(I=0,k=st__namespace.stepHistory.back(A,{steps:p*-1})),{newValue:I,result:k}},animate:(p,A,I,k)=>motion.motion.animate(p,A,I,k),getVariable:(p,A)=>z__namespace.StorageRegistry.getVariable(p,A),setVariable:(p,A,I)=>z__namespace.StorageRegistry.setVariable(p,A,I),removeVariable:(p,A)=>z__namespace.StorageRegistry.removeVariable(p,A),getFlag:p=>z__namespace.storage.flags.get(p),setFlag:(p,A)=>z__namespace.storage.flags.set(p,A),onLabelClosing:p=>z__namespace.StorageRegistry.clearOldTempVariables(p)}),!f||!w){wt.warn("The canvas element or options are not defined. The canvas will not be initialized.");return}return await M__namespace.canvas.init(f,w,T)}g.init=l;function e(){z__namespace.storage.clear(),M__namespace.canvas.isInitialized&&M__namespace.canvas.clear(),ut__namespace.sound.clear(),O__namespace.narration.clear(),st__namespace.stepHistory.clear();}g.clear=e;function i(){let f=M__namespace.canvas.isInitialized?M__namespace.canvas.export():{};return {pixivn_version:Ot,stepData:O__namespace.narration.export(),storageData:z__namespace.storage.export(),canvasData:f,soundData:ut__namespace.sound.export(),historyData:st__namespace.stepHistory.export(),path:kt()}}g.exportGameState=i;async function s(f){st__namespace.stepHistory.restore(f.historyData);let w=st__namespace.stepHistory.lastKey;if(typeof w=="number"){let T=st__namespace.stepHistory.stepsInfoMap.get(w)||null;await O__namespace.narration.restore(f.stepData,T);}z__namespace.storage.restore(f.storageData);try{M__namespace.canvas.isInitialized&&await M__namespace.canvas.restore(f.canvasData),await ut__namespace.sound.restore(f.soundData);}catch{}await core.GameUnifier.navigate(f.path);}g.restoreGameState=s;async function r(f,w){return g.clear(),await O__namespace.narration.call(f,w)}g.start=r;function n(f){return JSON.parse(f)}g.jsonToGameState=n;function o(f){core.GameUnifier.onEnd=f;}g.onEnd=o;function h(f){return core.GameUnifier.addOnError(f)}g.addOnError=h;function d(f){return core.GameUnifier.removeOnError(f)}g.removeOnError=d;function v(f){O__namespace.NarrationManagerStatic.onStepStart=f;}g.onStepStart=v;function L(f){O__namespace.NarrationManagerStatic.onLoadingLabel=f;}g.onLoadingLabel=L;function S(f){O__namespace.NarrationManagerStatic.onStepEnd=f;}g.onStepEnd=S;function ot(f){O__namespace.NarrationManagerStatic.onLabelStarting=f;}g.onLabelStarting=ot;function G(f){O__namespace.NarrationManagerStatic.onLabelClosing=f;}g.onLabelClosing=G;function $(f){core.GameUnifier.navigate=f;}g.onNavigate=$;function E(f){return core.GameUnifier.addOnPreContinue(f)}g.addOnPreContinue=E;function y(f){return core.GameUnifier.removeOnPreContinue(f)}g.removeOnPreContinue=y;})(exports.Game||={});var Je={characterUtils:qt__namespace,canvasUtils:M__namespace,narrationUtils:O__namespace,soundUtils:ut__namespace,CANVAS_APP_GAME_LAYER_ALIAS:Yt,PIXIVN_VERSION:Ot,...Ht,...oe,canvas:M__namespace.canvas,narration:O__namespace.narration,sound:ut__namespace.sound,storage:z__namespace.storage,history:st__namespace.stepHistory,Game:exports.Game,GameUnifier:core.GameUnifier};exports.CANVAS_APP_GAME_LAYER_ALIAS=Yt;exports.CachedMap=It;exports.PIXIVN_VERSION=Ot;exports.SYSTEM_RESERVED_STORAGE_KEYS=ge;exports.createExportableElement=ne;exports.default=Je;Object.keys(M).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return M[k]}})});Object.keys(qt).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return qt[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(st).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return st[k]}})});Object.keys(O).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return O[k]}})});Object.keys(ut).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return ut[k]}})});Object.keys(z).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return z[k]}})});