@drincs/pixi-vn 1.8.11 → 1.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/{ContainerMemory-BjcfYRU7.d.cts → ContainerMemory-D2HtgX7w.d.cts} +1 -1
  2. package/dist/{ContainerMemory-BjcfYRU7.d.ts → ContainerMemory-D2HtgX7w.d.ts} +1 -1
  3. package/dist/{HistoryChoiceMenuOption-CEmjDDJH.d.cts → HistoryChoiceMenuOption-BMsYentw.d.cts} +1 -1
  4. package/dist/{HistoryChoiceMenuOption-CN7NkcxU.d.ts → HistoryChoiceMenuOption-DQ-pnuPU.d.ts} +1 -1
  5. package/dist/{HistoryGameState-3ztYdv84.d.cts → HistoryGameState-C28NcKKl.d.cts} +1 -1
  6. package/dist/{HistoryGameState-D4t2fY9x.d.ts → HistoryGameState-CmjUtlkV.d.ts} +1 -1
  7. package/dist/{HistoryStep-DtOryKAZ.d.cts → HistoryStep-G9dUn0Lf.d.cts} +36 -4
  8. package/dist/{HistoryStep-DtOryKAZ.d.ts → HistoryStep-G9dUn0Lf.d.ts} +36 -4
  9. package/dist/{OpenedLabel-t6PvSzaL.d.cts → OpenedLabel-BxfL31aQ.d.cts} +1 -1
  10. package/dist/{OpenedLabel-DJby8qPc.d.ts → OpenedLabel-DLfFuZgk.d.ts} +1 -1
  11. package/dist/{SoundManagerInterface-TgOPqm2L.d.cts → SoundManagerInterface-Dd0b88_N.d.cts} +2 -2
  12. package/dist/{SoundManagerInterface-TgOPqm2L.d.ts → SoundManagerInterface-Dd0b88_N.d.ts} +2 -2
  13. package/dist/canvas.d.cts +2 -2
  14. package/dist/canvas.d.ts +2 -2
  15. package/dist/characters.cjs +1 -1
  16. package/dist/characters.d.cts +47 -5
  17. package/dist/characters.d.ts +47 -5
  18. package/dist/characters.mjs +1 -1
  19. package/dist/history.d.cts +3 -3
  20. package/dist/history.d.ts +3 -3
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.d.cts +7 -7
  23. package/dist/index.d.ts +7 -7
  24. package/dist/index.mjs +1 -1
  25. package/dist/narration.cjs +1 -1
  26. package/dist/narration.d.cts +15 -10
  27. package/dist/narration.d.ts +15 -10
  28. package/dist/narration.mjs +2 -2
  29. package/dist/sound.d.cts +2 -2
  30. package/dist/sound.d.ts +2 -2
  31. package/dist/vite-listener.cjs +1 -1
  32. package/dist/vite-listener.d.cts +1 -1
  33. package/dist/vite-listener.d.ts +1 -1
  34. package/dist/vite-listener.mjs +1 -1
  35. package/dist/vite.cjs +2 -1
  36. package/dist/vite.d.cts +47 -2
  37. package/dist/vite.d.ts +47 -2
  38. package/dist/vite.mjs +2 -1
  39. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- 'use strict';var core=require('./core.cjs');var yt=Object.create;var We=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Qe=o=>{throw TypeError(o)};var Tt=(o,e,t)=>e in o?We(o,e,{enumerable:true,configurable:true,writable:true,value:t}):o[e]=t;var Be=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var Ze=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports);var _t=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(o,i)&&i!==t&&We(o,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return o};var Et=(o,e,t)=>(t=o!=null?yt(gt(o)):{},_t(We(t,"default",{value:o,enumerable:true}),o));var z=(o,e,t)=>Tt(o,typeof e!="symbol"?e+"":e,t),je=(o,e,t)=>e.has(o)||Qe("Cannot "+t);var r=(o,e,t)=>(je(o,e,"read from private field"),t?t.call(o):e.get(o)),v=(o,e,t)=>e.has(o)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,t),S=(o,e,t,n)=>(je(o,e,"write to private field"),e.set(o,t),t),f=(o,e,t)=>(je(o,e,"access private method"),t);var Ue=(o,e,t,n)=>({set _(i){S(o,e,i);},get _(){return r(o,e,n)}});var ct=Ze((ze,pt)=>{(function(o,e){typeof ze=="object"?pt.exports=ze=e():typeof define=="function"&&define.amd?define([],e):o.CryptoJS=e();})(ze,function(){var o=o||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function l(){}return function(d){var C;return l.prototype=d,C=new l,l.prototype=null,C}})(),s={},h=s.lib={},p=h.Base=(function(){return {extend:function(l){var d=a(this);return l&&d.mixIn(l),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=h.WordArray=p.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||L).stringify(this)},concat:function(l){var d=this.words,C=l.words,E=this.sigBytes,O=l.sigBytes;if(this.clamp(),E%4)for(var P=0;P<O;P++){var oe=C[P>>>2]>>>24-P%4*8&255;d[E+P>>>2]|=oe<<24-(E+P)%4*8;}else for(var G=0;G<O;G+=4)d[E+G>>>2]=C[G>>>2];return this.sigBytes+=O,this},clamp:function(){var l=this.words,d=this.sigBytes;l[d>>>2]&=4294967295<<32-d%4*8,l.length=e.ceil(d/4);},clone:function(){var l=p.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],C=0;C<l;C+=4)d.push(i());return new y.init(d,l)}}),u=s.enc={},L=u.Hex={stringify:function(l){for(var d=l.words,C=l.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push((P>>>4).toString(16)),E.push((P&15).toString(16));}return E.join("")},parse:function(l){for(var d=l.length,C=[],E=0;E<d;E+=2)C[E>>>3]|=parseInt(l.substr(E,2),16)<<24-E%8*4;return new y.init(C,d/2)}},M=u.Latin1={stringify:function(l){for(var d=l.words,C=l.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push(String.fromCharCode(P));}return E.join("")},parse:function(l){for(var d=l.length,C=[],E=0;E<d;E++)C[E>>>2]|=(l.charCodeAt(E)&255)<<24-E%4*8;return new y.init(C,d)}},N=u.Utf8={stringify:function(l){try{return decodeURIComponent(escape(M.stringify(l)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(l){return M.parse(unescape(encodeURIComponent(l)))}},D=h.BufferedBlockAlgorithm=p.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(l){typeof l=="string"&&(l=N.parse(l)),this._data.concat(l),this._nDataBytes+=l.sigBytes;},_process:function(l){var d,C=this._data,E=C.words,O=C.sigBytes,P=this.blockSize,oe=P*4,G=O/oe;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var J=G*P,Le=e.min(J*4,O);if(J){for(var Ke=0;Ke<J;Ke+=P)this._doProcessBlock(E,Ke);d=E.splice(0,J),C.sigBytes-=Le;}return new y.init(d,Le)},clone:function(){var l=p.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});h.Hasher=D.extend({cfg:p.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){D.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(l){return function(d,C){return new l.init(C).finalize(d)}},_createHmacHelper:function(l){return function(d,C){return new _.HMAC.init(l,C).finalize(d)}}});var _=s.algo={};return s})(Math);return o});});var dt=Ze((He,ut)=>{(function(o,e){typeof He=="object"?ut.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(o.CryptoJS);})(He,function(o){return (function(){var e=o,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,s=[],h=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(p,y){for(var u=this._hash.words,L=u[0],M=u[1],N=u[2],D=u[3],w=u[4],_=0;_<80;_++){if(_<16)s[_]=p[y+_]|0;else {var l=s[_-3]^s[_-8]^s[_-14]^s[_-16];s[_]=l<<1|l>>>31;}var d=(L<<5|L>>>27)+w+s[_];_<20?d+=(M&N|~M&D)+1518500249:_<40?d+=(M^N^D)+1859775393:_<60?d+=(M&N|M&D|N&D)-1894007588:d+=(M^N^D)-899497514,w=D,D=N,N=M<<30|M>>>2,M=L,L=d;}u[0]=u[0]+L|0,u[1]=u[1]+M|0,u[2]=u[2]+N|0,u[3]=u[3]+D|0,u[4]=u[4]+w|0;},_doFinalize:function(){var p=this._data,y=p.words,u=this._nDataBytes*8,L=p.sigBytes*8;return y[L>>>5]|=128<<24-L%32,y[(L+64>>>9<<4)+14]=Math.floor(u/4294967296),y[(L+64>>>9<<4)+15]=u,p.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var p=i.clone.call(this);return p._hash=this._hash.clone(),p}});e.SHA1=i._createHelper(h),e.HmacSHA1=i._createHmacHelper(h);})(),o.SHA1});});var R="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(o,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(o,e,t,n):console.error(`[${t}] ${e}: ${o}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let o=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{o&&(o=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=o=>!nt.has(o);var ue=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),at=o=>ue(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(o){super(o),this.fill(0);}},le,Te,Ot=(le=class{heap;length;static create(e){let t=at(e);if(!t)return [];S(le,Te,true);let n=new le(e,t);return S(le,Te,false),n}constructor(e,t){if(!r(le,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(le,Te,false),le),tt,rt,X,B,Q,Se,Z,_e,Ee,ee,Y,te,U,A,T,K,j,H,F,re,V,ne,ie,k,$,ae,ye,W,Ce,c,$e,me,he,Me,q,ot,ge,Ie,Ne,de,fe,qe,Fe,Ve,x,Xe,Ae,be,Je,Oe,st=(Oe=class{constructor(e){v(this,c);v(this,X);v(this,B);v(this,Q);v(this,Se);v(this,Z);v(this,_e);v(this,Ee);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,T);v(this,K);v(this,j);v(this,H);v(this,F);v(this,re);v(this,V);v(this,ne);v(this,ie);v(this,k);v(this,$);v(this,ae);v(this,ye);v(this,W);v(this,Ce);v(this,me,()=>{});v(this,he,()=>{});v(this,Me,()=>{});v(this,q,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Ne,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:s,updateAgeOnHas:h,allowStale:p,dispose:y,onInsert:u,disposeAfter:L,noDisposeOnSet:M,noUpdateTTL:N,maxSize:D=0,maxEntrySize:w=0,sizeCalculation:_,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:P,ignoreFetchAbort:oe,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,G??Ct),t!==0&&!ue(t))throw new TypeError("max option must be a nonnegative integer");let J=t?at(t):Array;if(!J)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,D),this.maxEntrySize=w||r(this,B),this.sizeCalculation=_,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(S(this,Ee,d),l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,_e,l),S(this,ye,!!l),S(this,U,new Map),S(this,A,new Array(t).fill(void 0)),S(this,T,new Array(t).fill(void 0)),S(this,K,new J(t)),S(this,j,new J(t)),S(this,H,0),S(this,F,0),S(this,re,Ot.create(t)),S(this,Y,0),S(this,te,0),typeof y=="function"&&S(this,Q,y),typeof u=="function"&&S(this,Se,u),typeof L=="function"?(S(this,Z,L),S(this,V,[])):(S(this,Z,void 0),S(this,V,void 0)),S(this,ae,!!r(this,Q)),S(this,Ce,!!r(this,Se)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!oe,this.maxEntrySize!==0){if(r(this,B)!==0&&!ue(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!ue(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,c,ot).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!h,this.ttlResolution=ue(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!ue(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,c,$e).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let Le="LRU_CACHE_UNBOUNDED";It(Le)&&(nt.add(Le),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,Oe));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,$),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,T),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,F)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,c,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var s;return f(s=e,c,Ve).call(s,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,c,Ae).call(n,t)},indexes:t=>{var n;return f(n=e,c,de).call(n,t)},rindexes:t=>{var n;return f(n=e,c,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,_e)}get memoMethod(){return r(this,Ee)}get dispose(){return r(this,Q)}get onInsert(){return r(this,Se)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,c,de).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,c,fe).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,c,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,c,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,c,de).call(this))r(this,T)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,c,fe).call(this))r(this,T)[e]!==void 0&&!f(this,c,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,c,de).call(this)){let i=r(this,T)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,c,de).call(this)){let i=r(this,T)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,c,fe).call(this)){let i=r(this,T)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,c,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,c,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,T)[t],i=f(this,c,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let s=r(this,k)[t],h=r(this,ie)[t];if(s&&h){let p=s-(r(this,ee).now()-h);a.ttl=p,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,c,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,T)[t],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let s={value:a};if(r(this,k)&&r(this,ie)){s.ttl=r(this,k)[t];let h=r(this,ee).now()-r(this,ie)[t];s.start=Math.floor(Date.now()-h);}r(this,ne)&&(s.size=r(this,ne)[t]),e.unshift([n,s]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,D,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:h=this.sizeCalculation,status:p}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,u=r(this,Ne).call(this,e,t,n.size||0,h);if(this.maxEntrySize&&u>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),f(this,c,be).call(this,e,"set"),this;let L=r(this,Y)===0?void 0:r(this,U).get(e);if(L===void 0)L=r(this,Y)===0?r(this,F):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,c,Fe).call(this,false):r(this,Y),r(this,A)[L]=e,r(this,T)[L]=t,r(this,U).set(e,L),r(this,K)[r(this,F)]=L,r(this,j)[L]=r(this,F),S(this,F,L),Ue(this,Y)._++,r(this,Ie).call(this,L,u,p),p&&(p.set="add"),y=false,r(this,Ce)&&((M=r(this,Se))==null||M.call(this,t,e,"add"));else {f(this,c,Ae).call(this,L);let _=r(this,T)[L];if(t!==_){if(r(this,ye)&&f(this,c,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=_;l!==void 0&&!s&&(r(this,ae)&&((N=r(this,Q))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,V)?.push([l,e,"set"]));}else s||(r(this,ae)&&((D=r(this,Q))==null||D.call(this,_,e,"set")),r(this,W)&&r(this,V)?.push([_,e,"set"]));if(r(this,ge).call(this,L),r(this,Ie).call(this,L,u,p),r(this,T)[L]=t,p){p.set="replace";let l=_&&f(this,c,x).call(this,_)?_.__staleWhileFetching:_;l!==void 0&&(p.oldValue=l);}}else p&&(p.set="update");r(this,Ce)&&this.onInsert?.(t,e,t===_?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,c,$e).call(this),r(this,k)&&(y||r(this,Me).call(this,L,i,a),p&&r(this,he).call(this,p,L)),!s&&r(this,W)&&r(this,V)){let _=r(this,V),l;for(;l=_?.shift();)(w=r(this,Z))==null||w.call(this,...l);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,T)[r(this,H)];if(f(this,c,Fe).call(this,!0),f(this,c,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,V)){let t=r(this,V),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let s=r(this,T)[a];if(f(this,c,x).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,he).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,he).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,T)[i];return f(this,c,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:h=this.noDisposeOnSet,size:p=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:L=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:w,forceRefresh:_=false,status:l,signal:d}=t;if(!r(this,ye))return l&&(l.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let C={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:s,noDisposeOnSet:h,size:p,sizeCalculation:y,noUpdateTTL:u,noDeleteOnFetchRejection:L,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:N,status:l,signal:d},E=r(this,U).get(e);if(E===void 0){l&&(l.fetch="miss");let O=f(this,c,Ve).call(this,e,E,C,w);return O.__returned=O}else {let O=r(this,T)[E];if(f(this,c,x).call(this,O)){let J=n&&O.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",J&&(l.returnedStale=true)),J?O.__staleWhileFetching:O.__returned=O}let P=r(this,q).call(this,E);if(!_&&!P)return l&&(l.fetch="hit"),f(this,c,Ae).call(this,E),i&&r(this,me).call(this,E),l&&r(this,he).call(this,l,E),O;let oe=f(this,c,Ve).call(this,e,E,C,w),G=oe.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=P?"stale":"refresh",G&&P&&(l.returnedStale=true)),G?oe.__staleWhileFetching:oe.__returned=oe}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ee);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...s}=t,h=this.get(e,s);if(!a&&h!==void 0)return h;let p=n(e,h,{options:s,context:i});return this.set(e,p,s),p}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:s}=t,h=r(this,U).get(e);if(h!==void 0){let p=r(this,T)[h],y=f(this,c,x).call(this,p);return s&&r(this,he).call(this,s,h),r(this,q).call(this,h)?(s&&(s.get="stale"),y?(s&&n&&p.__staleWhileFetching!==void 0&&(s.returnedStale=true),n?p.__staleWhileFetching:void 0):(a||f(this,c,be).call(this,e,"expire"),s&&n&&(s.returnedStale=true),n?p:void 0)):(s&&(s.get="hit"),y?p.__staleWhileFetching:(f(this,c,Ae).call(this,h),i&&r(this,me).call(this,h),p))}else s&&(s.get="miss");}delete(e){return f(this,c,be).call(this,e,"delete")}clear(){return f(this,c,Je).call(this,"delete")}},X=new WeakMap,B=new WeakMap,Q=new WeakMap,Se=new WeakMap,Z=new WeakMap,_e=new WeakMap,Ee=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,T=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,F=new WeakMap,re=new WeakMap,V=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,$=new WeakMap,ae=new WeakMap,ye=new WeakMap,W=new WeakMap,Ce=new WeakMap,c=new WeakSet,$e=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));S(this,k,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,$,n),S(this,Me,(h,p,y=r(this,ee).now())=>{t[h]=p!==0?y:0,e[h]=p,i(h,p);}),S(this,me,h=>{t[h]=e[h]!==0?r(this,ee).now():0,i(h,e[h]);});let i=this.ttlAutopurge?(h,p)=>{if(n?.[h]&&(clearTimeout(n[h]),n[h]=void 0),p&&p!==0&&n){let y=setTimeout(()=>{r(this,q).call(this,h)&&f(this,c,be).call(this,r(this,A)[h],"expire");},p+1);y.unref&&y.unref(),n[h]=y;}}:()=>{};S(this,he,(h,p)=>{if(e[p]){let y=e[p],u=t[p];if(!y||!u)return;h.ttl=y,h.start=u,h.now=a||s();let L=h.now-u;h.remainingTTL=y-L;}});let a=0,s=()=>{let h=r(this,ee).now();if(this.ttlResolution>0){a=h;let p=setTimeout(()=>a=0,this.ttlResolution);p.unref&&p.unref();}return h};this.getRemainingTTL=h=>{let p=r(this,U).get(h);if(p===void 0)return 0;let y=e[p],u=t[p];if(!y||!u)return 1/0;let L=(a||s())-u;return y-L},S(this,q,h=>{let p=t[h],y=e[h];return !!y&&!!p&&(a||s())-p>y});},me=new WeakMap,he=new WeakMap,Me=new WeakMap,q=new WeakMap,ot=function(){let e=new Ye(r(this,X));S(this,te,0),S(this,ne,e),S(this,ge,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Ne,(t,n,i,a)=>{if(f(this,c,x).call(this,n))return 0;if(!ue(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!ue(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),S(this,Ie,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,c,Fe).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Ie=new WeakMap,Ne=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,F);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,F)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Fe=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,T)[t];return r(this,ye)&&f(this,c,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,V)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,$)?.[t]&&(clearTimeout(r(this,$)[t]),r(this,$)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,T)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(S(this,H,S(this,F,0)),r(this,re).length=0):S(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Ve=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,c,x).call(this,a))return a;let s=new Ge,{signal:h}=n;h?.addEventListener("abort",()=>s.abort(h.reason),{signal:s.signal});let p={signal:s.signal,options:n,context:i},y=(w,_=false)=>{let{aborted:l}=s.signal,d=n.ignoreFetchAbort&&w!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!_?(n.status.fetchAborted=true,n.status.fetchError=s.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!_)return L(s.signal.reason,C);let E=N,O=r(this,T)[t];return (O===N||d&&_&&O===void 0)&&(w===void 0?E.__staleWhileFetching!==void 0?r(this,T)[t]=E.__staleWhileFetching:f(this,c,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,p.options))),w},u=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),L(w,false)),L=(w,_)=>{let{aborted:l}=s.signal,d=l&&n.allowStaleOnFetchAbort,C=d||n.allowStaleOnFetchRejection,E=C||n.noDeleteOnFetchRejection,O=N;if(r(this,T)[t]===N&&(!E||!_&&O.__staleWhileFetching===void 0?f(this,c,be).call(this,e,"fetch"):d||(r(this,T)[t]=O.__staleWhileFetching)),C)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw w},M=(w,_)=>{var d;let l=(d=r(this,_e))==null?void 0:d.call(this,e,a,p);l&&l instanceof Promise&&l.then(C=>w(C===void 0?void 0:C),_),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=C=>y(C,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(y,u),D=Object.assign(N,{__abortController:s,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,D,{...p.options,status:void 0}),t=r(this,U).get(e)):r(this,T)[t]=D,D},x=function(e){if(!r(this,ye))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},Ae=function(e){e!==r(this,F)&&(e===r(this,H)?S(this,H,r(this,K)[e]):f(this,c,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,c,Xe).call(this,r(this,F),e),S(this,F,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let s=r(this,U).get(e);if(s!==void 0)if(r(this,$)?.[s]&&(clearTimeout(r(this,$)?.[s]),r(this,$)[s]=void 0),n=true,r(this,Y)===1)f(this,c,Je).call(this,t);else {r(this,ge).call(this,s);let h=r(this,T)[s];if(f(this,c,x).call(this,h)?h.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,Q))==null||i.call(this,h,e,t)),r(this,W)&&r(this,V)?.push([h,e,t])),r(this,U).delete(e),r(this,A)[s]=void 0,r(this,T)[s]=void 0,s===r(this,F))S(this,F,r(this,j)[s]);else if(s===r(this,H))S(this,H,r(this,K)[s]);else {let p=r(this,j)[s];r(this,K)[p]=r(this,K)[s];let y=r(this,K)[s];r(this,j)[y]=r(this,j)[s];}Ue(this,Y)._--,r(this,re).push(s);}}if(r(this,W)&&r(this,V)?.length){let s=r(this,V),h;for(;h=s?.shift();)(a=r(this,Z))==null||a.call(this,...h);}return n},Je=function(e){var t,n;for(let i of f(this,c,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,c,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let s=r(this,A)[i];r(this,ae)&&((t=r(this,Q))==null||t.call(this,a,s,e)),r(this,W)&&r(this,V)?.push([a,s,e]);}}if(r(this,U).clear(),r(this,T).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,$)??[])i!==void 0&&clearTimeout(i);r(this,$)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,H,0),S(this,F,0),r(this,re).length=0,S(this,te,0),S(this,Y,0),r(this,W)&&r(this,V)){let i=r(this,V),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Oe);var De=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var g;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN] ${a}`,...s)))(g||={});var Re=new De({cacheSize:10}),lt;(a=>{function o(s){let h=Re.get(s);if(!h){g.error(`Label "${s}" not found`);return}return h}a.get=o;function e(s){if(Array.isArray(s)){s.forEach(h=>{e(h);});return}Re.has(s.id)&&g.info(`Label "${s.id}" already exists, it will be overwritten`),Re.set(s.id,s);}a.add=e;function t(){return Array.from(Re.values())}a.values=t;function n(s){return Re.has(s)}a.has=n;function i(){return Array.from(Re.keys())}a.keys=i;})(lt||={});var se=lt;function pe(o){try{if(typeof o>"u")return o;let e=JSON.stringify(o);return JSON.parse(e)}catch(e){throw g.error("Error creating exportable element",o,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class o{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(R,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(R,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=o.currentLabelStepIndex;if(t===null)return g.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=o.currentLabelId,a=o._currentLabel;if(!i||t===null||!a)return g.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let s=a.getStepSha(t)||"error",h=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return h[i]||(h[i]={}),(!h[i][n]||h[i][n].stepSha1!==s)&&(h[i][n]={stepSha1:s}),h[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=o.currentLabelStepIndex,i=n+e,a=o.currentLabelId;if(!a||n===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let s=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[a]||(s[a]={}),s[a][i]=t,core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static getCurrentStepTimesCounter(e=""){let t=o._stepCounter,n=o.getCurrentStepTimesCounterData(e);if(!n)return g.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(s=>s===t)||(i.push(t),n.stepCounters=i,o.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let s=o.getCurrentStepTimesCounterData(i);if(!s)return;let h=s.usedRandomNumbers||{},p=Array.from({length:t-e+1},(L,M)=>M+e).filter(L=>!h[`${e}-${t}`]?.includes(L));if(p.length===0)return;let y=Math.floor(Math.random()*p.length),u=p[y];return h[`${e}-${t}`]||(h[`${e}-${t}`]=[]),h[`${e}-${t}`].push(u),s.usedRandomNumbers=h,o.setCurrentStepTimesCounterData(i,s),u}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=o.currentLabelStepIndex,n=t+e,i=o.currentLabelId;if(!i||t===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(R,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(R,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){o._stepCounter++;}static _openedLabels=[];static get openedLabels(){return pe(o._openedLabels)}static set openedLabels(e){o._openedLabels=pe(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return pe(o._originalOpenedLabels)}static set originalOpenedLabels(e){o._originalOpenedLabels=pe(e);}static get _currentLabel(){if(o.currentLabelId)return se.get(o.currentLabelId)}static get currentLabelId(){if(o._openedLabels.length>0)return o._openedLabels[o._openedLabels.length-1].label}static get currentLabelStepIndex(){return o._openedLabels.length>0?o._openedLabels[o._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=o.allOpenedLabels,i=o.allOpenedLabels[e]?.biggestStep||0,a=o.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},o.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=o.allChoicesMade,s=a.findIndex(h=>h.labelId===e&&h.stepIndex===t&&h.choiceIndex===i&&h.stepSha1===n);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[s].madeTimes++,o.allChoicesMade=a;}static pushNewLabel(e){if(!se.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);o._openedLabels.push({label:e,currentStepIndex:0});let n=o.allOpenedLabels,i=o.allOpenedLabels[e]?.biggestStep||0,a=o.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},o.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(o._openedLabels.length>0){let e=o._openedLabels[o._openedLabels.length-1];o._openedLabels[o._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){o._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return o.onLoadingLabel&&e===0&&n.push(o.onLoadingLabel(e,t)),o._onStepStart&&n.push(o._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd};var Pe=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,s,h,p=core.GameUnifier.getVariable(R,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(h=core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,u={currentLabel:b.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:h,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:p,openedLabels:y};b.originalOpenedLabels=y,core.GameUnifier.addHistoryItem(u,{ignoreSameStep:i}),b.lastHistoryStep=u,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){g.warn("No label to close");return}if(!this.currentLabel){g.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=se.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(g.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&g.warn("The player must make a choice"),false):this.isRequiredInput?(t&&g.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){g.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){g.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(s){throw g.error("Error continuing",s),s}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});g.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){g.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){g.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(u){g.error("Error running onStepStart",u),this.onStepError&&await this.onStepError(u,e);return}let s=a.getStepById(i);if(!s){g.error("step not found");return}let h=a.getStepSha(i);h||(g.warn("stepSha not found, setting to ERROR"),h="error");let p,y;try{p=await s(e,{labelId:a.id});}catch(u){g.error("Error running step",u),y=u;}try{let u=this.choices;if(u?.length===1&&u[0].autoSelect){let L=u[0];p=await this.selectChoice(L,e);}}catch(u){g.error("Error auto-selecting choice",u),y||(y=u);}try{let u=b.lastHistoryStep;n!==void 0&&u&&(h=u.stepSha1,h||(g.warn("stepSha not found, setting to ERROR"),h="error"),b.addChoicesMade(u.currentLabel||"error",typeof u.labelStepIndex=="number"?u.labelStepIndex:-1,u.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(u){g.warn("Error adding choice made to history",u);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(h,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(u){g.warn("Error adding step to history",u);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(u){g.warn("Error running onStepEnd",u);}return y&&this.onStepError&&await this.onStepError(y,e),p}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){b.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;g.error("currentLabelId not found");}}async call(e,t,n){let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let s;try{let h=se.get(a);if(!h)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(h.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(h){throw g.error("Error calling label",h),h}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||s}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let s;try{let h=se.get(a);if(!h)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(h.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(h){throw g.error("Error jumping to label",h),h}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||s}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw g.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw g.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){g.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(R,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,pe({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,s)=>({...a,choiceIndex:s})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,s)=>a.oneTime&&i?.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,pe(e)),core.GameUnifier.setVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,core.GameUnifier.setVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:pe(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=se.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):g.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:g.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){g.error("Error running onLoadingLabel",n);}}catch(n){g.error("Error importing data",n);}}};function xt(o,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:o,type:n?.type||"call"}}var ht="close";function At(o,e){return {...e,type:ht,text:o}}var ft=Et(dt());var we=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var xe=class extends we{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){if(e<0||e>=this.steps.length)return g.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e];return (0,ft.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return g.warn("stepSha not found, setting to ERROR",t),"error"}}};function bt(o,e,t){let n=new xe(o,e,t);return se.add(n),n}var Er=new Pe;
1
+ 'use strict';var core=require('./core.cjs');var St=Object.create;var We=Object.defineProperty;var yt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Qe=s=>{throw TypeError(s)};var _t=(s,e,t)=>e in s?We(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var Be=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ze=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var Tt=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(s,i)&&i!==t&&We(s,i,{get:()=>e[i],enumerable:!(n=yt(e,i))||n.enumerable});return s};var Et=(s,e,t)=>(t=s!=null?St(gt(s)):{},Tt(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>_t(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Qe("Cannot "+t);var r=(s,e,t)=>(je(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),y=(s,e,t,n)=>(je(s,e,"write to private field"),e.set(s,t),t),f=(s,e,t)=>(je(s,e,"access private method"),t);var Ue=(s,e,t,n)=>({set _(i){y(s,e,i);},get _(){return r(s,e,n)}});var ct=Ze((ze,pt)=>{(function(s,e){typeof ze=="object"?pt.exports=ze=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(ze,function(){var s=s||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function h(){}return function(d){var C;return h.prototype=d,C=new h,h.prototype=null,C}})(),o={},l=o.lib={},p=l.Base=(function(){return {extend:function(h){var d=a(this);return h&&d.mixIn(h),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var h=this.extend();return h.init.apply(h,arguments),h},init:function(){},mixIn:function(h){for(var d in h)h.hasOwnProperty(d)&&(this[d]=h[d]);h.hasOwnProperty("toString")&&(this.toString=h.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),S=l.WordArray=p.extend({init:function(h,d){h=this.words=h||[],d!=t?this.sigBytes=d:this.sigBytes=h.length*4;},toString:function(h){return (h||L).stringify(this)},concat:function(h){var d=this.words,C=h.words,E=this.sigBytes,O=h.sigBytes;if(this.clamp(),E%4)for(var P=0;P<O;P++){var oe=C[P>>>2]>>>24-P%4*8&255;d[E+P>>>2]|=oe<<24-(E+P)%4*8;}else for(var G=0;G<O;G+=4)d[E+G>>>2]=C[G>>>2];return this.sigBytes+=O,this},clamp:function(){var h=this.words,d=this.sigBytes;h[d>>>2]&=4294967295<<32-d%4*8,h.length=e.ceil(d/4);},clone:function(){var h=p.clone.call(this);return h.words=this.words.slice(0),h},random:function(h){for(var d=[],C=0;C<h;C+=4)d.push(i());return new S.init(d,h)}}),u=o.enc={},L=u.Hex={stringify:function(h){for(var d=h.words,C=h.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push((P>>>4).toString(16)),E.push((P&15).toString(16));}return E.join("")},parse:function(h){for(var d=h.length,C=[],E=0;E<d;E+=2)C[E>>>3]|=parseInt(h.substr(E,2),16)<<24-E%8*4;return new S.init(C,d/2)}},M=u.Latin1={stringify:function(h){for(var d=h.words,C=h.sigBytes,E=[],O=0;O<C;O++){var P=d[O>>>2]>>>24-O%4*8&255;E.push(String.fromCharCode(P));}return E.join("")},parse:function(h){for(var d=h.length,C=[],E=0;E<d;E++)C[E>>>2]|=(h.charCodeAt(E)&255)<<24-E%4*8;return new S.init(C,d)}},N=u.Utf8={stringify:function(h){try{return decodeURIComponent(escape(M.stringify(h)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(h){return M.parse(unescape(encodeURIComponent(h)))}},D=l.BufferedBlockAlgorithm=p.extend({reset:function(){this._data=new S.init,this._nDataBytes=0;},_append:function(h){typeof h=="string"&&(h=N.parse(h)),this._data.concat(h),this._nDataBytes+=h.sigBytes;},_process:function(h){var d,C=this._data,E=C.words,O=C.sigBytes,P=this.blockSize,oe=P*4,G=O/oe;h?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var J=G*P,_e=e.min(J*4,O);if(J){for(var Ke=0;Ke<J;Ke+=P)this._doProcessBlock(E,Ke);d=E.splice(0,J),C.sigBytes-=_e;}return new S.init(d,_e)},clone:function(){var h=p.clone.call(this);return h._data=this._data.clone(),h},_minBufferSize:0});l.Hasher=D.extend({cfg:p.extend(),init:function(h){this.cfg=this.cfg.extend(h),this.reset();},reset:function(){D.reset.call(this),this._doReset();},update:function(h){return this._append(h),this._process(),this},finalize:function(h){h&&this._append(h);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(h){return function(d,C){return new h.init(C).finalize(d)}},_createHmacHelper:function(h){return function(d,C){return new T.HMAC.init(h,C).finalize(d)}}});var T=o.algo={};return o})(Math);return s});});var dt=Ze((He,ut)=>{(function(s,e){typeof He=="object"?ut.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(He,function(s){return (function(){var e=s,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,o=[],l=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(p,S){for(var u=this._hash.words,L=u[0],M=u[1],N=u[2],D=u[3],w=u[4],T=0;T<80;T++){if(T<16)o[T]=p[S+T]|0;else {var h=o[T-3]^o[T-8]^o[T-14]^o[T-16];o[T]=h<<1|h>>>31;}var d=(L<<5|L>>>27)+w+o[T];T<20?d+=(M&N|~M&D)+1518500249:T<40?d+=(M^N^D)+1859775393:T<60?d+=(M&N|M&D|N&D)-1894007588:d+=(M^N^D)-899497514,w=D,D=N,N=M<<30|M>>>2,M=L,L=d;}u[0]=u[0]+L|0,u[1]=u[1]+M|0,u[2]=u[2]+N|0,u[3]=u[3]+D|0,u[4]=u[4]+w|0;},_doFinalize:function(){var p=this._data,S=p.words,u=this._nDataBytes*8,L=p.sigBytes*8;return S[L>>>5]|=128<<24-L%32,S[(L+64>>>9<<4)+14]=Math.floor(u/4294967296),S[(L+64>>>9<<4)+15]=u,p.sigBytes=S.length*4,this._process(),this._hash},clone:function(){var p=i.clone.call(this);return p._hash=this._hash.clone(),p}});e.SHA1=i._createHelper(l),e.HmacSHA1=i._createHmacHelper(l);})(),s.SHA1});});var R="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(s,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let s=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=s=>!nt.has(s);var ue=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>ue(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(s){super(s),this.fill(0);}},le,Te,Ot=(le=class{heap;length;static create(e){let t=at(e);if(!t)return [];y(le,Te,true);let n=new le(e,t);return y(le,Te,false),n}constructor(e,t){if(!r(le,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(le,Te,false),le),tt,rt,X,B,Q,ye,Z,Ee,Ce,ee,Y,te,U,A,_,K,j,H,F,re,V,ne,ie,k,$,ae,Se,W,Ie,c,$e,me,he,Me,q,ot,ge,Oe,Ne,de,fe,qe,Fe,Ve,x,Xe,Ae,be,Je,Re,st=(Re=class{constructor(e){v(this,c);v(this,X);v(this,B);v(this,Q);v(this,ye);v(this,Z);v(this,Ee);v(this,Ce);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,_);v(this,K);v(this,j);v(this,H);v(this,F);v(this,re);v(this,V);v(this,ne);v(this,ie);v(this,k);v(this,$);v(this,ae);v(this,Se);v(this,W);v(this,Ie);v(this,me,()=>{});v(this,he,()=>{});v(this,Me,()=>{});v(this,q,()=>false);v(this,ge,e=>{});v(this,Oe,(e,t,n)=>{});v(this,Ne,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:l,allowStale:p,dispose:S,onInsert:u,disposeAfter:L,noDisposeOnSet:M,noUpdateTTL:N,maxSize:D=0,maxEntrySize:w=0,sizeCalculation:T,fetchMethod:h,memoMethod:d,noDeleteOnFetchRejection:C,noDeleteOnStaleGet:E,allowStaleOnFetchRejection:O,allowStaleOnFetchAbort:P,ignoreFetchAbort:oe,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(y(this,ee,G??Ct),t!==0&&!ue(t))throw new TypeError("max option must be a nonnegative integer");let J=t?at(t):Array;if(!J)throw new Error("invalid max value: "+t);if(y(this,X,t),y(this,B,D),this.maxEntrySize=w||r(this,B),this.sizeCalculation=T,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(y(this,Ce,d),h!==void 0&&typeof h!="function")throw new TypeError("fetchMethod must be a function if specified");if(y(this,Ee,h),y(this,Se,!!h),y(this,U,new Map),y(this,A,new Array(t).fill(void 0)),y(this,_,new Array(t).fill(void 0)),y(this,K,new J(t)),y(this,j,new J(t)),y(this,H,0),y(this,F,0),y(this,re,Ot.create(t)),y(this,Y,0),y(this,te,0),typeof S=="function"&&y(this,Q,S),typeof u=="function"&&y(this,ye,u),typeof L=="function"?(y(this,Z,L),y(this,V,[])):(y(this,Z,void 0),y(this,V,void 0)),y(this,ae,!!r(this,Q)),y(this,Ie,!!r(this,ye)),y(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!C,this.allowStaleOnFetchRejection=!!O,this.allowStaleOnFetchAbort=!!P,this.ignoreFetchAbort=!!oe,this.maxEntrySize!==0){if(r(this,B)!==0&&!ue(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!ue(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,c,ot).call(this);}if(this.allowStale=!!p,this.noDeleteOnStaleGet=!!E,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!l,this.ttlResolution=ue(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!ue(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,c,$e).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let _e="LRU_CACHE_UNBOUNDED";It(_e)&&(nt.add(_e),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",_e,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,$),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,_),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,F)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,c,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,c,Ve).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,c,Ae).call(n,t)},indexes:t=>{var n;return f(n=e,c,de).call(n,t)},rindexes:t=>{var n;return f(n=e,c,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,Ee)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,Q)}get onInsert(){return r(this,ye)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,c,de).call(this))r(this,_)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield [r(this,A)[e],r(this,_)[e]]);}*rentries(){for(let e of f(this,c,fe).call(this))r(this,_)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield [r(this,A)[e],r(this,_)[e]]);}*keys(){for(let e of f(this,c,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield t);}}*rkeys(){for(let e of f(this,c,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield t);}}*values(){for(let e of f(this,c,de).call(this))r(this,_)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield r(this,_)[e]);}*rvalues(){for(let e of f(this,c,fe).call(this))r(this,_)[e]!==void 0&&!f(this,c,x).call(this,r(this,_)[e])&&(yield r(this,_)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,c,de).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,c,de).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,c,fe).call(this)){let i=r(this,_)[n],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,c,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,c,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,_)[t],i=f(this,c,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let o=r(this,k)[t],l=r(this,ie)[t];if(o&&l){let p=o-(r(this,ee).now()-l);a.ttl=p,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,c,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,_)[t],a=f(this,c,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(r(this,k)&&r(this,ie)){o.ttl=r(this,k)[t];let l=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-l);}r(this,ne)&&(o.size=r(this,ne)[t]),e.unshift([n,o]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,D,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:p}=n,{noUpdateTTL:S=this.noUpdateTTL}=n,u=r(this,Ne).call(this,e,t,n.size||0,l);if(this.maxEntrySize&&u>this.maxEntrySize)return p&&(p.set="miss",p.maxEntrySizeExceeded=true),f(this,c,be).call(this,e,"set"),this;let L=r(this,Y)===0?void 0:r(this,U).get(e);if(L===void 0)L=r(this,Y)===0?r(this,F):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,c,Fe).call(this,false):r(this,Y),r(this,A)[L]=e,r(this,_)[L]=t,r(this,U).set(e,L),r(this,K)[r(this,F)]=L,r(this,j)[L]=r(this,F),y(this,F,L),Ue(this,Y)._++,r(this,Oe).call(this,L,u,p),p&&(p.set="add"),S=false,r(this,Ie)&&((M=r(this,ye))==null||M.call(this,t,e,"add"));else {f(this,c,Ae).call(this,L);let T=r(this,_)[L];if(t!==T){if(r(this,Se)&&f(this,c,x).call(this,T)){T.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:h}=T;h!==void 0&&!o&&(r(this,ae)&&((N=r(this,Q))==null||N.call(this,h,e,"set")),r(this,W)&&r(this,V)?.push([h,e,"set"]));}else o||(r(this,ae)&&((D=r(this,Q))==null||D.call(this,T,e,"set")),r(this,W)&&r(this,V)?.push([T,e,"set"]));if(r(this,ge).call(this,L),r(this,Oe).call(this,L,u,p),r(this,_)[L]=t,p){p.set="replace";let h=T&&f(this,c,x).call(this,T)?T.__staleWhileFetching:T;h!==void 0&&(p.oldValue=h);}}else p&&(p.set="update");r(this,Ie)&&this.onInsert?.(t,e,t===T?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,c,$e).call(this),r(this,k)&&(S||r(this,Me).call(this,L,i,a),p&&r(this,he).call(this,p,L)),!o&&r(this,W)&&r(this,V)){let T=r(this,V),h;for(;h=T?.shift();)(w=r(this,Z))==null||w.call(this,...h);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,_)[r(this,H)];if(f(this,c,Fe).call(this,!0),f(this,c,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,V)){let t=r(this,V),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let o=r(this,_)[a];if(f(this,c,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,he).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,he).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,_)[i];return f(this,c,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:p=0,sizeCalculation:S=this.sizeCalculation,noUpdateTTL:u=this.noUpdateTTL,noDeleteOnFetchRejection:L=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:w,forceRefresh:T=false,status:h,signal:d}=t;if(!r(this,Se))return h&&(h.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:h});let C={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:l,size:p,sizeCalculation:S,noUpdateTTL:u,noDeleteOnFetchRejection:L,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:D,ignoreFetchAbort:N,status:h,signal:d},E=r(this,U).get(e);if(E===void 0){h&&(h.fetch="miss");let O=f(this,c,Ve).call(this,e,E,C,w);return O.__returned=O}else {let O=r(this,_)[E];if(f(this,c,x).call(this,O)){let J=n&&O.__staleWhileFetching!==void 0;return h&&(h.fetch="inflight",J&&(h.returnedStale=true)),J?O.__staleWhileFetching:O.__returned=O}let P=r(this,q).call(this,E);if(!T&&!P)return h&&(h.fetch="hit"),f(this,c,Ae).call(this,E),i&&r(this,me).call(this,E),h&&r(this,he).call(this,h,E),O;let oe=f(this,c,Ve).call(this,e,E,C,w),G=oe.__staleWhileFetching!==void 0&&n;return h&&(h.fetch=P?"stale":"refresh",G&&P&&(h.returnedStale=true)),G?oe.__staleWhileFetching:oe.__returned=oe}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...o}=t,l=this.get(e,o);if(!a&&l!==void 0)return l;let p=n(e,l,{options:o,context:i});return this.set(e,p,o),p}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,l=r(this,U).get(e);if(l!==void 0){let p=r(this,_)[l],S=f(this,c,x).call(this,p);return o&&r(this,he).call(this,o,l),r(this,q).call(this,l)?(o&&(o.get="stale"),S?(o&&n&&p.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?p.__staleWhileFetching:void 0):(a||f(this,c,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?p:void 0)):(o&&(o.get="hit"),S?p.__staleWhileFetching:(f(this,c,Ae).call(this,l),i&&r(this,me).call(this,l),p))}else o&&(o.get="miss");}delete(e){return f(this,c,be).call(this,e,"delete")}clear(){return f(this,c,Je).call(this,"delete")}},X=new WeakMap,B=new WeakMap,Q=new WeakMap,ye=new WeakMap,Z=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,_=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,F=new WeakMap,re=new WeakMap,V=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,$=new WeakMap,ae=new WeakMap,Se=new WeakMap,W=new WeakMap,Ie=new WeakMap,c=new WeakSet,$e=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));y(this,k,e),y(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;y(this,$,n),y(this,Me,(l,p,S=r(this,ee).now())=>{t[l]=p!==0?S:0,e[l]=p,i(l,p);}),y(this,me,l=>{t[l]=e[l]!==0?r(this,ee).now():0,i(l,e[l]);});let i=this.ttlAutopurge?(l,p)=>{if(n?.[l]&&(clearTimeout(n[l]),n[l]=void 0),p&&p!==0&&n){let S=setTimeout(()=>{r(this,q).call(this,l)&&f(this,c,be).call(this,r(this,A)[l],"expire");},p+1);S.unref&&S.unref(),n[l]=S;}}:()=>{};y(this,he,(l,p)=>{if(e[p]){let S=e[p],u=t[p];if(!S||!u)return;l.ttl=S,l.start=u,l.now=a||o();let L=l.now-u;l.remainingTTL=S-L;}});let a=0,o=()=>{let l=r(this,ee).now();if(this.ttlResolution>0){a=l;let p=setTimeout(()=>a=0,this.ttlResolution);p.unref&&p.unref();}return l};this.getRemainingTTL=l=>{let p=r(this,U).get(l);if(p===void 0)return 0;let S=e[p],u=t[p];if(!S||!u)return 1/0;let L=(a||o())-u;return S-L},y(this,q,l=>{let p=t[l],S=e[l];return !!S&&!!p&&(a||o())-p>S});},me=new WeakMap,he=new WeakMap,Me=new WeakMap,q=new WeakMap,ot=function(){let e=new Ye(r(this,X));y(this,te,0),y(this,ne,e),y(this,ge,t=>{y(this,te,r(this,te)-e[t]),e[t]=0;}),y(this,Ne,(t,n,i,a)=>{if(f(this,c,x).call(this,n))return 0;if(!ue(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!ue(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),y(this,Oe,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,c,Fe).call(this,true);}y(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Oe=new WeakMap,Ne=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,F);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,c,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,F)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Fe=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,_)[t];return r(this,Se)&&f(this,c,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,V)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,$)?.[t]&&(clearTimeout(r(this,$)[t]),r(this,$)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,_)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(y(this,H,y(this,F,0)),r(this,re).length=0):y(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Ve=function(e,t,n,i){let a=t===void 0?void 0:r(this,_)[t];if(f(this,c,x).call(this,a))return a;let o=new Ge,{signal:l}=n;l?.addEventListener("abort",()=>o.abort(l.reason),{signal:o.signal});let p={signal:o.signal,options:n,context:i},S=(w,T=false)=>{let{aborted:h}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,C=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(h&&!T?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),h&&!d&&!T)return L(o.signal.reason,C);let E=N,O=r(this,_)[t];return (O===N||d&&T&&O===void 0)&&(w===void 0?E.__staleWhileFetching!==void 0?r(this,_)[t]=E.__staleWhileFetching:f(this,c,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,p.options))),w},u=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),L(w,false)),L=(w,T)=>{let{aborted:h}=o.signal,d=h&&n.allowStaleOnFetchAbort,C=d||n.allowStaleOnFetchRejection,E=C||n.noDeleteOnFetchRejection,O=N;if(r(this,_)[t]===N&&(!E||!T&&O.__staleWhileFetching===void 0?f(this,c,be).call(this,e,"fetch"):d||(r(this,_)[t]=O.__staleWhileFetching)),C)return n.status&&O.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),O.__staleWhileFetching;if(O.__returned===O)throw w},M=(w,T)=>{var d;let h=(d=r(this,Ee))==null?void 0:d.call(this,e,a,p);h&&h instanceof Promise&&h.then(C=>w(C===void 0?void 0:C),T),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=C=>S(C,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(S,u),D=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,D,{...p.options,status:void 0}),t=r(this,U).get(e)):r(this,_)[t]=D,D},x=function(e){if(!r(this,Se))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},Ae=function(e){e!==r(this,F)&&(e===r(this,H)?y(this,H,r(this,K)[e]):f(this,c,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,c,Xe).call(this,r(this,F),e),y(this,F,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let o=r(this,U).get(e);if(o!==void 0)if(r(this,$)?.[o]&&(clearTimeout(r(this,$)?.[o]),r(this,$)[o]=void 0),n=true,r(this,Y)===1)f(this,c,Je).call(this,t);else {r(this,ge).call(this,o);let l=r(this,_)[o];if(f(this,c,x).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,Q))==null||i.call(this,l,e,t)),r(this,W)&&r(this,V)?.push([l,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,_)[o]=void 0,o===r(this,F))y(this,F,r(this,j)[o]);else if(o===r(this,H))y(this,H,r(this,K)[o]);else {let p=r(this,j)[o];r(this,K)[p]=r(this,K)[o];let S=r(this,K)[o];r(this,j)[S]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,V)?.length){let o=r(this,V),l;for(;l=o?.shift();)(a=r(this,Z))==null||a.call(this,...l);}return n},Je=function(e){var t,n;for(let i of f(this,c,fe).call(this,{allowStale:true})){let a=r(this,_)[i];if(f(this,c,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,Q))==null||t.call(this,a,o,e)),r(this,W)&&r(this,V)?.push([a,o,e]);}}if(r(this,U).clear(),r(this,_).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,$)??[])i!==void 0&&clearTimeout(i);r(this,$)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),y(this,H,0),y(this,F,0),r(this,re).length=0,y(this,te,0),y(this,Y,0),r(this,W)&&r(this,V)){let i=r(this,V),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var De=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var g;(i=>(i.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),i.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),i.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(g||={});var Le=new De({cacheSize:10}),lt;(o=>{function s(l){let p=Le.get(l);if(!p){g.error(`Label "${l}" not found`);return}return p}o.get=s;function e(l){if(Array.isArray(l)){l.forEach(p=>{e(p);});return}Le.has(l.id)&&g.info(`Label "${l.id}" already exists, it will be overwritten`),Le.set(l.id,l);}o.add=e;function t(){return Array.from(Le.values())}o.values=t;function n(l){return Le.has(l)}o.has=n;function i(){return Array.from(Le.keys())}o.keys=i;function a(){Le.clear();}o.clear=a;})(lt||={});var se=lt;function pe(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw g.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class s{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(R,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(R,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return g.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return g.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",l=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return l[i]||(l[i]={}),(!l[i][n]||l[i][n].stepSha1!==o)&&(l[i][n]={stepSha1:o}),l[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return g.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(o=>o===t)||(i.push(t),n.stepCounters=i,s.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let o=s.getCurrentStepTimesCounterData(i);if(!o)return;let l=o.usedRandomNumbers||{},p=Array.from({length:t-e+1},(L,M)=>M+e).filter(L=>!l[`${e}-${t}`]?.includes(L));if(p.length===0)return;let S=Math.floor(Math.random()*p.length),u=p[S];return l[`${e}-${t}`]||(l[`${e}-${t}`]=[]),l[`${e}-${t}`].push(u),o.usedRandomNumbers=l,s.setCurrentStepTimesCounterData(i,o),u}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=s.currentLabelStepIndex,n=t+e,i=s.currentLabelId;if(!i||t===null){g.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(R,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(R,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return pe(s._openedLabels)}static set openedLabels(e){s._openedLabels=pe(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return pe(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=pe(e);}static get _currentLabel(){if(s.currentLabelId)return se.get(s.currentLabelId)}static get currentLabelId(){if(s._openedLabels.length>0)return s._openedLabels[s._openedLabels.length-1].label}static get currentLabelStepIndex(){return s._openedLabels.length>0?s._openedLabels[s._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},s.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=s.allChoicesMade,o=a.findIndex(l=>l.labelId===e&&l.stepIndex===t&&l.choiceIndex===i&&l.stepSha1===n);o<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[o].madeTimes++,s.allChoicesMade=a;}static pushNewLabel(e){if(!se.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);s._openedLabels.push({label:e,currentStepIndex:0});let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},s.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(s._openedLabels.length>0){let e=s._openedLabels[s._openedLabels.length-1];s._openedLabels[s._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){s._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return s.onLoadingLabel&&e===0&&n.push(s.onLoadingLabel(e,t)),s._onStepStart&&n.push(s._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd};var Pe=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,l,p=core.GameUnifier.getVariable(R,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l=core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let S=b.openedLabels,u={currentLabel:b.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:l,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:p,openedLabels:S};b.originalOpenedLabels=S,core.GameUnifier.addHistoryItem(u,{ignoreSameStep:i}),b.lastHistoryStep=u,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){g.warn("No label to close");return}if(!this.currentLabel){g.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=se.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(g.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&g.warn("The player must make a choice"),false):this.isRequiredInput?(t&&g.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){g.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){g.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(o){throw g.error("Error continuing",o),o}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});g.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){g.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){g.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(u){g.error("Error running onStepStart",u),this.onStepError&&await this.onStepError(u,e);return}let o=a.getStepById(i);if(!o){g.error("step not found");return}let l=a.getStepSha(i);l||(g.warn("stepSha not found, setting to ERROR"),l="error");let p,S;try{p=await o(e,{labelId:a.id});}catch(u){g.error("Error running step",u),S=u;}try{let u=this.choices;if(u?.length===1&&u[0].autoSelect){let L=u[0];p=await this.selectChoice(L,e);}}catch(u){g.error("Error auto-selecting choice",u),S||(S=u);}try{let u=b.lastHistoryStep;n!==void 0&&u&&(l=u.stepSha1,l||(g.warn("stepSha not found, setting to ERROR"),l="error"),b.addChoicesMade(u.currentLabel||"error",typeof u.labelStepIndex=="number"?u.labelStepIndex:-1,u.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(u){g.warn("Error adding choice made to history",u);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(l,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(u){g.warn("Error adding step to history",u);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(u){g.warn("Error running onStepEnd",u);}return S&&this.onStepError&&await this.onStepError(S,e),p}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1){b.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;g.error("currentLabelId not found");}}async call(e,t,n){let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let o;try{let l=se.get(a);if(!l)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(l.id),o=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw g.error("Error calling label",l),l}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||o}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,core.GameUnifier.runningStepsCount++;let o;try{let l=se.get(a);if(!l)throw new core.PixiError("unregistered_element",`Label ${a} not found`);b.pushNewLabel(l.id),o=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw g.error("Error jumping to label",l),l}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||o}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw g.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw g.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){g.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(R,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(R,I.CURRENT_DIALOGUE_MEMORY_KEY,pe({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(R,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,o)=>({...a,choiceIndex:o})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,o)=>a.oneTime&&i?.includes(o)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,pe(e)),core.GameUnifier.setVariable(R,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw g.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(R,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,core.GameUnifier.setVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:pe(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=se.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):g.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:g.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){g.error("Error running onLoadingLabel",n);}}catch(n){g.error("Error importing data",n);}}};function xt(s,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:s,type:n?.type||"call"}}var ht="close";function At(s,e){return {...e,type:ht,text:s}}var ft=Et(dt());var we=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var xe=class extends we{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){if(e<0||e>=this.steps.length)return g.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e];return (0,ft.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return g.warn("stepSha not found, setting to ERROR",t),"error"}}};function bt(s,e,t){let n=new xe(s,e,t);return se.add(n),n}var Er=new Pe;
2
2
  exports.Label=xe;exports.LabelAbstract=we;exports.NarrationManagerStatic=b;exports.RegisteredLabels=se;exports.narration=Er;exports.newChoiceOption=xt;exports.newCloseChoiceOption=At;exports.newLabel=bt;
@@ -1,10 +1,11 @@
1
1
  import { S as StorageElementType, a as StorageObjectType } from './StorageElementType-C7ETezlL.cjs';
2
- import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-DtOryKAZ.cjs';
2
+ import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-G9dUn0Lf.cjs';
3
+ export { P as PixivnLabelIds } from './HistoryStep-G9dUn0Lf.cjs';
3
4
  import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
4
- import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-CEmjDDJH.cjs';
5
- export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-CEmjDDJH.cjs';
5
+ import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-BMsYentw.cjs';
6
+ export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-BMsYentw.cjs';
6
7
  import { S as StepLabelPropsType, a as StepLabelResultType, b as StepLabelType } from './StepLabelType-CN97wZzm.cjs';
7
- import { O as OpenedLabel } from './OpenedLabel-t6PvSzaL.cjs';
8
+ import { O as OpenedLabel } from './OpenedLabel-BxfL31aQ.cjs';
8
9
  import { LabelProps as LabelProps$1 } from '@drincs/pixi-vn/canvas';
9
10
  import 'microdiff';
10
11
 
@@ -377,11 +378,11 @@ declare abstract class LabelAbstract<TLabel, TProps extends {} = {}, StepIdType
377
378
  * @param id is the id of the label
378
379
  * @param props is the properties of the label
379
380
  */
380
- constructor(id: LabelIdType, props?: LabelProps<TLabel, StepIdType>);
381
+ constructor(id: string, props?: LabelProps<TLabel, StepIdType>);
381
382
  /**
382
383
  * Get the id of the label. This variable is used in the system to get the label by id, {@link RegisteredLabels.get}
383
384
  */
384
- readonly id: LabelIdType;
385
+ readonly id: string;
385
386
  /**
386
387
  * Get the number of steps in the label. This variable is used in the system to get the number of steps in the label.
387
388
  * @returns The number of steps in the label
@@ -487,7 +488,7 @@ type LabelSteps<T extends {}> = [StepLabelType<T>, ...StepLabelType<Partial<T>>[
487
488
  * @param props An object with the `label`'s options
488
489
  * @returns The created label
489
490
  */
490
- declare function newLabel<T extends {} = {}>(id: LabelIdType, steps: LabelSteps<T> | (() => LabelSteps<T>), props?: LabelProps<Label<T>>): Label<T>;
491
+ declare function newLabel<T extends {} = {}>(id: string, steps: LabelSteps<T> | (() => LabelSteps<T>), props?: LabelProps<Label<T>>): Label<T>;
491
492
 
492
493
  declare namespace RegisteredLabels {
493
494
  /**
@@ -495,7 +496,7 @@ declare namespace RegisteredLabels {
495
496
  * @param id The id of the label
496
497
  * @returns The label or undefined if it does not exist
497
498
  */
498
- function get<T = LabelAbstract<any>>(id: LabelIdType): T | undefined;
499
+ function get<T = LabelAbstract<any>, T2 extends LabelIdType | string = LabelIdType>(id: T2): T | undefined;
499
500
  /**
500
501
  * Saves a label in the system
501
502
  * @param label The label to be saved
@@ -516,7 +517,11 @@ declare namespace RegisteredLabels {
516
517
  * Get a list of all label ids registered.
517
518
  * @returns An array of label ids.
518
519
  */
519
- function keys(): string[];
520
+ function keys(): LabelIdType[];
521
+ /**
522
+ * Removes all registered labels.
523
+ */
524
+ function clear(): void;
520
525
  }
521
526
 
522
527
  interface ChoiceInterface {
@@ -706,4 +711,4 @@ type InputInfo = {
706
711
 
707
712
  declare const narration: NarrationManagerInterface;
708
713
 
709
- export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
714
+ export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, LabelIdType, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
@@ -1,10 +1,11 @@
1
1
  import { S as StorageElementType, a as StorageObjectType } from './StorageElementType-C7ETezlL.js';
2
- import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-DtOryKAZ.js';
2
+ import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-G9dUn0Lf.js';
3
+ export { P as PixivnLabelIds } from './HistoryStep-G9dUn0Lf.js';
3
4
  import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
4
- import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-CN7NkcxU.js';
5
- export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-CN7NkcxU.js';
5
+ import { L as LabelRunModeType, C as CloseType } from './HistoryChoiceMenuOption-DQ-pnuPU.js';
6
+ export { H as HistoryChoiceMenuOption, N as NarrationHistory } from './HistoryChoiceMenuOption-DQ-pnuPU.js';
6
7
  import { S as StepLabelPropsType, a as StepLabelResultType, b as StepLabelType } from './StepLabelType-CN97wZzm.js';
7
- import { O as OpenedLabel } from './OpenedLabel-DJby8qPc.js';
8
+ import { O as OpenedLabel } from './OpenedLabel-DLfFuZgk.js';
8
9
  import { LabelProps as LabelProps$1 } from '@drincs/pixi-vn/canvas';
9
10
  import 'microdiff';
10
11
 
@@ -377,11 +378,11 @@ declare abstract class LabelAbstract<TLabel, TProps extends {} = {}, StepIdType
377
378
  * @param id is the id of the label
378
379
  * @param props is the properties of the label
379
380
  */
380
- constructor(id: LabelIdType, props?: LabelProps<TLabel, StepIdType>);
381
+ constructor(id: string, props?: LabelProps<TLabel, StepIdType>);
381
382
  /**
382
383
  * Get the id of the label. This variable is used in the system to get the label by id, {@link RegisteredLabels.get}
383
384
  */
384
- readonly id: LabelIdType;
385
+ readonly id: string;
385
386
  /**
386
387
  * Get the number of steps in the label. This variable is used in the system to get the number of steps in the label.
387
388
  * @returns The number of steps in the label
@@ -487,7 +488,7 @@ type LabelSteps<T extends {}> = [StepLabelType<T>, ...StepLabelType<Partial<T>>[
487
488
  * @param props An object with the `label`'s options
488
489
  * @returns The created label
489
490
  */
490
- declare function newLabel<T extends {} = {}>(id: LabelIdType, steps: LabelSteps<T> | (() => LabelSteps<T>), props?: LabelProps<Label<T>>): Label<T>;
491
+ declare function newLabel<T extends {} = {}>(id: string, steps: LabelSteps<T> | (() => LabelSteps<T>), props?: LabelProps<Label<T>>): Label<T>;
491
492
 
492
493
  declare namespace RegisteredLabels {
493
494
  /**
@@ -495,7 +496,7 @@ declare namespace RegisteredLabels {
495
496
  * @param id The id of the label
496
497
  * @returns The label or undefined if it does not exist
497
498
  */
498
- function get<T = LabelAbstract<any>>(id: LabelIdType): T | undefined;
499
+ function get<T = LabelAbstract<any>, T2 extends LabelIdType | string = LabelIdType>(id: T2): T | undefined;
499
500
  /**
500
501
  * Saves a label in the system
501
502
  * @param label The label to be saved
@@ -516,7 +517,11 @@ declare namespace RegisteredLabels {
516
517
  * Get a list of all label ids registered.
517
518
  * @returns An array of label ids.
518
519
  */
519
- function keys(): string[];
520
+ function keys(): LabelIdType[];
521
+ /**
522
+ * Removes all registered labels.
523
+ */
524
+ function clear(): void;
520
525
  }
521
526
 
522
527
  interface ChoiceInterface {
@@ -706,4 +711,4 @@ type InputInfo = {
706
711
 
707
712
  declare const narration: NarrationManagerInterface;
708
713
 
709
- export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
714
+ export { type ChoiceInterface, type ChoiceOptionInterface, type CloseChoiceOptionInterface, DialogueInterface, HistoryStep, type InputInfo, Label, LabelAbstract, LabelIdType, type LabelProps, LabelRunModeType, type LabelSteps, type NarrationGameState, type NarrationManagerInterface, NarrationManagerStatic, OpenedLabel, RegisteredLabels, type StepLabelProps, StepLabelPropsType, type StepLabelResult, StepLabelResultType, StepLabelType, type StoredChoiceInterface, type StoredIndexedChoiceInterface, narration, newChoiceOption, newCloseChoiceOption, newLabel };
@@ -1,2 +1,2 @@
1
- import {a}from'./chunk-6GLWL3NH.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {d,c,e,f as f$1}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'./core.mjs';var h=new d({cacheSize:10}),R;(a=>{function i(p){let u=h.get(p);if(!u){e.error(`Label "${p}" not found`);return}return u}a.get=i;function e$1(p){if(Array.isArray(p)){p.forEach(u=>{e$1(u);});return}h.has(p.id)&&e.info(`Label "${p.id}" already exists, it will be overwritten`),h.set(p.id,p);}a.add=e$1;function t(){return Array.from(h.values())}a.values=t;function r(p){return h.has(p)}a.has=r;function n(){return Array.from(h.keys())}a.keys=n;})(R||={});var f=R;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e$1=""){let t=i.currentLabelStepIndex;if(t===null)return e.error("currentLabelStepIndex is null"),null;let r=`${t}${e$1}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let p=a.getStepSha(t)||"error",u=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n$1]||(u[n$1]={}),(!u[n$1][r]||u[n$1][r].stepSha1!==p)&&(u[n$1][r]={stepSha1:p}),u[n$1][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n$1=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};p[a]||(p[a]={}),p[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,p);}static getCurrentStepTimesCounter(e$1=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e$1);if(!r)return e.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(p=>p===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e$1,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let p=i.getCurrentStepTimesCounterData(n);if(!p)return;let u=p.usedRandomNumbers||{},m=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!u[`${e}-${t}`]?.includes(E));if(m.length===0)return;let L=Math.floor(Math.random()*m.length),b=m[L];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(b),p.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,p),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e$1=""){let t=i.currentLabelStepIndex,r=t+e$1,n$1=i.currentLabelId;if(!n$1||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return f$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=f$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return f$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=f$1(e);}static get _currentLabel(){if(i.currentLabelId)return f.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,p=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);p<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[p].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!f.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd};var C=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,p,u,m=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:p,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:m,openedLabels:L};o.originalOpenedLabels=L,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){e.warn("No label to close");return}if(!this.currentLabel){e.error("currentLabel not found");return}let e$1=o.openedLabels;e$1.pop(),o.openedLabels=e$1,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=f.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e$1=o.currentLabelStepIndex,t=this.currentLabel;if(e$1===null||!t)return;let r=t.getStepSha(e$1);return r||(e.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e$1&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&e.warn("The player must make a choice"),false):this.isRequiredInput?(t&&e.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e$1,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){e.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){e.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e$1,t);}catch(p){throw e.error("Error continuing",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e$1)||a}async afterRunCurrentStep(e$1){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e$1,{labelId:"end"});e.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e$1,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){e.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){e.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){e.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e$1);return}let p=a.getStepById(n);if(!p){e.error("step not found");return}let u=a.getStepSha(n);u||(e.warn("stepSha not found, setting to ERROR"),u="error");let m,L;try{m=await p(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),L=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let E=b[0];m=await this.selectChoice(E,e$1);}}catch(b){e.error("Error auto-selecting choice",b),L||(L=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(u=b.stepSha1,u||(e.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){e.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){e.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){e.warn("Error running onStepEnd",b);}return L&&this.onStepError&&await this.onStepError(L,e$1),m}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e$1,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async call(e$1,t,r){let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let p;try{let u=f.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw e.error("Error calling label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async jump(e$1,t,r){if(this.stepCounter===0)return await this.call(e$1,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let p;try{let u=f.get(a);if(!u)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(u.id),p=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw e.error("Error jumping to label",u),u}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||p}async selectChoice(e$1,t){this.choices=void 0;let r=e$1.type;switch(r){case "call":return await this.call(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "jump":return await this.jump(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "close":return await this.closeChoiceMenu(e$1,{...e$1.props,...t});default:throw e.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e$1,t){if(e$1.type!=="close")throw e.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e$1.choiceIndex=="number"&&(r=e$1.choiceIndex),e$1.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e$1,t)=>{try{await GameUnifier.runOnError(e$1,t);}catch(r){e.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e$1){if(e$1===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e$1=="string"||Array.isArray(e$1))&&(e$1={text:e$1}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e$1.text)?r=[...r,...e$1.text]:r=[...r,e$1.text],e$1.text=r,e$1.character=e$1.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,f$1({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,p)=>({...a,choiceIndex:p})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,p)=>a.oneTime&&n?.includes(p)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,f$1(e$1)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:f$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=f.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e$1,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e$1,"openedLabels")?(o.openedLabels=e$1.openedLabels,o.originalOpenedLabels=o.openedLabels):e.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e$1,"stepCounter")?o._stepCounter=e$1.stepCounter:e.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){e.error("Error running onLoadingLabel",r);}}catch(r){e.error("Error importing data",r);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var I=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var g=class extends I{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e$1){if(e$1<0||e$1>=this.steps.length)return e.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e$1];return (0,M.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return e.warn("stepSha not found, setting to ERROR",t),"error"}}};function x(i,e,t){let r=new g(i,e,t);return f.add(r),r}var fe=new C;
2
- export{g as Label,I as LabelAbstract,o as NarrationManagerStatic,f as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
1
+ import {a}from'./chunk-6GLWL3NH.mjs';import {l,n}from'./chunk-IWAXXFXE.mjs';import {d,c,e,f}from'./chunk-HQQ5WH6C.mjs';import {GameUnifier,PixiError}from'./core.mjs';var h=new d({cacheSize:10}),R;(d=>{function i(p){let f=h.get(p);if(!f){e.error(`Label "${p}" not found`);return}return f}d.get=i;function e$1(p){if(Array.isArray(p)){p.forEach(f=>{e$1(f);});return}h.has(p.id)&&e.info(`Label "${p.id}" already exists, it will be overwritten`),h.set(p.id,p);}d.add=e$1;function t(){return Array.from(h.values())}d.values=t;function r(p){return h.has(p)}d.has=r;function n(){return Array.from(h.keys())}d.keys=n;function a(){h.clear();}d.clear=a;})(R||={});var L=R;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(l,n.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(l,n.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e$1=""){let t=i.currentLabelStepIndex;if(t===null)return e.error("currentLabelStepIndex is null"),null;let r=`${t}${e$1}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let d=a.getStepSha(t)||"error",p=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[n$1]||(p[n$1]={}),(!p[n$1][r]||p[n$1][r].stepSha1!==d)&&(p[n$1][r]={stepSha1:d}),p[n$1][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n$1=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let d=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};d[a]||(d[a]={}),d[a][n$1]=t,GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,d);}static getCurrentStepTimesCounter(e$1=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e$1);if(!r)return e.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(d=>d===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e$1,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let d=i.getCurrentStepTimesCounterData(n);if(!d)return;let p=d.usedRandomNumbers||{},f=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!p[`${e}-${t}`]?.includes(E));if(f.length===0)return;let S=Math.floor(Math.random()*f.length),b=f[S];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(b),d.usedRandomNumbers=p,i.setCurrentStepTimesCounterData(n,d),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e$1=""){let t=i.currentLabelStepIndex,r=t+e$1,n$1=i.currentLabelId;if(!n$1||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(l,n.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(l,n.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(l,n.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return f(i._openedLabels)}static set openedLabels(e){i._openedLabels=f(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return f(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=f(e);}static get _currentLabel(){if(i.currentLabelId)return L.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,d=a.findIndex(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===n&&p.stepSha1===r);d<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[d].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!L.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd};var C=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,d,p,f=GameUnifier.getVariable(l,n.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(d=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY));let S=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:d,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:p,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:f,openedLabels:S};o.originalOpenedLabels=S,GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){e.warn("No label to close");return}if(!this.currentLabel){e.error("currentLabel not found");return}let e$1=o.openedLabels;e$1.pop(),o.openedLabels=e$1,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=L.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e$1=o.currentLabelStepIndex,t=this.currentLabel;if(e$1===null||!t)return;let r=t.getStepSha(e$1);return r||(e.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e$1&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&e.warn("The player must make a choice"),false):this.isRequiredInput?(t&&e.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e$1,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){e.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){e.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e$1,t);}catch(d){throw e.error("Error continuing",d),d}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e$1)||a}async afterRunCurrentStep(e$1){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e$1,{labelId:"end"});e.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e$1,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){e.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){e.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){e.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e$1);return}let d=a.getStepById(n);if(!d){e.error("step not found");return}let p=a.getStepSha(n);p||(e.warn("stepSha not found, setting to ERROR"),p="error");let f,S;try{f=await d(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),S=b;}try{let b=this.choices;if(b?.length===1&&b[0].autoSelect){let E=b[0];f=await this.selectChoice(E,e$1);}}catch(b){e.error("Error auto-selecting choice",b),S||(S=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(p=b.stepSha1,p||(e.warn("stepSha not found, setting to ERROR"),p="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){e.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(p,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){e.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){e.warn("Error running onStepEnd",b);}return S&&this.onStepError&&await this.onStepError(S,e$1),f}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e$1,t);if(this.openedLabels.length===1){o.openedLabels=[];return}}}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async call(e$1,t,r){let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let d;try{let p=L.get(a);if(!p)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(p.id),d=await this.runCurrentStep(t,{choiceMade:n});}catch(p){throw e.error("Error calling label",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||d}async jump(e$1,t,r){if(this.stepCounter===0)return await this.call(e$1,t,r);this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e$1=="string"?a=e$1:a=e$1.id,GameUnifier.runningStepsCount++;let d;try{let p=L.get(a);if(!p)throw new PixiError("unregistered_element",`Label ${a} not found`);o.pushNewLabel(p.id),d=await this.runCurrentStep(t,{choiceMade:n});}catch(p){throw e.error("Error jumping to label",p),p}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||d}async selectChoice(e$1,t){this.choices=void 0;let r=e$1.type;switch(r){case "call":return await this.call(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "jump":return await this.jump(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "close":return await this.closeChoiceMenu(e$1,{...e$1.props,...t});default:throw e.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e$1,t){if(e$1.type!=="close")throw e.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e$1.choiceIndex=="number"&&(r=e$1.choiceIndex),e$1.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e$1,t)=>{try{await GameUnifier.runOnError(e$1,t);}catch(r){e.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e$1){if(e$1===void 0){GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e$1=="string"||Array.isArray(e$1))&&(e$1={text:e$1}),this.dialogGlue){let t=GameUnifier.getVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e$1.text)?r=[...r,...e$1.text]:r=[...r,e$1.text],e$1.text=r,e$1.character=e$1.character||t.character;}GameUnifier.setVariable(l,n.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(l,n.CURRENT_DIALOGUE_MEMORY_KEY,f({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(l,n.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choices(){let e=GameUnifier.getVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,d)=>({...a,choiceIndex:d})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,d)=>a.oneTime&&n?.includes(d)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(l,n.CURRENT_MENU_OPTIONS_MEMORY_KEY,f(e$1)),GameUnifier.setVariable(l,n.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get dialogGlue(){return GameUnifier.getFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(n.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(l,n.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(l,n.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(l,n.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:f(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=L.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e$1,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e$1,"openedLabels")?(o.openedLabels=e$1.openedLabels,o.originalOpenedLabels=o.openedLabels):e.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e$1,"stepCounter")?o._stepCounter=e$1.stepCounter:e.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){e.error("Error running onLoadingLabel",r);}}catch(r){e.error("Error importing data",r);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var g=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var I=class extends g{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e$1){if(e$1<0||e$1>=this.steps.length)return e.warn("stepSha not found, setting to ERROR"),"error";try{let t=this.steps[e$1];return (0,M.default)(t.toString().toLocaleLowerCase()).toString()}catch(t){return e.warn("stepSha not found, setting to ERROR",t),"error"}}};function x(i,e,t){let r=new I(i,e,t);return L.add(r),r}var fe=new C;
2
+ export{I as Label,g as LabelAbstract,o as NarrationManagerStatic,L as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
package/dist/sound.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MediaInterface, b as MediaMemory, A as AudioChannelInterface, c as SoundManagerInterface } from './SoundManagerInterface-TgOPqm2L.cjs';
2
- export { C as ChannelOptions, E as ExportedSound, a as ExportedSoundPlay, S as SoundGameState, d as SoundOptions, e as SoundPlay, f as SoundPlayOptions, g as SoundPlayOptionsWithChannel } from './SoundManagerInterface-TgOPqm2L.cjs';
1
+ import { M as MediaInterface, b as MediaMemory, A as AudioChannelInterface, a as SoundManagerInterface } from './SoundManagerInterface-Dd0b88_N.cjs';
2
+ export { C as ChannelOptions, E as ExportedSound, c as ExportedSoundPlay, S as SoundGameState, d as SoundOptions, e as SoundPlay, f as SoundPlayOptions, g as SoundPlayOptionsWithChannel } from './SoundManagerInterface-Dd0b88_N.cjs';
3
3
  import { C as CachedMap } from './CachedMap-DZLvJAnA.cjs';
4
4
  import { Player, PlayerOptions, ToneAudioNode, ToneAudioBuffer } from 'tone';
5
5
  import 'lru-cache';
package/dist/sound.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { M as MediaInterface, b as MediaMemory, A as AudioChannelInterface, c as SoundManagerInterface } from './SoundManagerInterface-TgOPqm2L.js';
2
- export { C as ChannelOptions, E as ExportedSound, a as ExportedSoundPlay, S as SoundGameState, d as SoundOptions, e as SoundPlay, f as SoundPlayOptions, g as SoundPlayOptionsWithChannel } from './SoundManagerInterface-TgOPqm2L.js';
1
+ import { M as MediaInterface, b as MediaMemory, A as AudioChannelInterface, a as SoundManagerInterface } from './SoundManagerInterface-Dd0b88_N.js';
2
+ export { C as ChannelOptions, E as ExportedSound, c as ExportedSoundPlay, S as SoundGameState, d as SoundOptions, e as SoundPlay, f as SoundPlayOptions, g as SoundPlayOptionsWithChannel } from './SoundManagerInterface-Dd0b88_N.js';
3
3
  import { C as CachedMap } from './CachedMap-DZLvJAnA.js';
4
4
  import { Player, PlayerOptions, ToneAudioNode, ToneAudioBuffer } from 'tone';
5
5
  import 'lru-cache';
@@ -1 +1 @@
1
- 'use strict';var canvas=require('./canvas.cjs'),characters=require('./characters.cjs'),narration=require('./narration.cjs'),l=require('./pixi/index.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var i="/__pixi-vn/characters",a="/__pixi-vn/labels",c="/__pixi-vn/assets/manifest",p="/__pixi-vn/canvas-options";async function e(t,s,r="data"){try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(n){console.warn(`Failed to send ${r} to ${t}:`,n);}}function d(){let t=l__default.default.Assets.resolver._assetMap,s=l__default.default.Assets.resolver._bundles;return {bundles:Object.entries(s).map(([r,n])=>({name:r,assets:n.flatMap(I=>t[I]??[])}))}}function _(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function m(){if(_()){try{let t=characters.RegisteredCharacters.values();await e(i,t,"characters");}catch(t){console.warn("Error collecting characters:",t);}try{let t=narration.RegisteredLabels.keys();await e(a,t,"labels");}catch(t){console.warn("Error collecting labels:",t);}try{let t=d();await e(c,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}if(canvas.canvas.isInitialized)try{let t={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};await e(p,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}exports.isViteDevelopmentMode=_;exports.setupPixivnViteData=m;
1
+ 'use strict';var canvas=require('./canvas.cjs'),a=require('./pixi/index.js');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var a__default=/*#__PURE__*/_interopDefault(a);var o="/__pixi-vn/assets/manifest",r="/__pixi-vn/canvas-options";async function c(t,e,s="data"){try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(n){console.warn(`Failed to send ${s} to ${t}:`,n);}}function l(){let t=a__default.default.Assets.resolver._assetMap,e=a__default.default.Assets.resolver._bundles;return {bundles:Object.entries(e).map(([s,n])=>({name:s,assets:n.flatMap(_=>t[_]??[])}))}}function p(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function f(){if(p()){try{let t=l();await c(o,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}if(canvas.canvas.isInitialized)try{let t={height:canvas.canvas.app.screen.height,width:canvas.canvas.app.screen.width};await c(r,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}exports.isViteDevelopmentMode=p;exports.setupPixivnViteData=f;
@@ -9,7 +9,7 @@
9
9
  declare function isViteDevelopmentMode(): boolean;
10
10
  /**
11
11
  * Initializes Pixi VN development tools by syncing game state with the Vite dev server.
12
- * Sends registered characters, labels, assets manifest, and canvas options.
12
+ * Sends assets manifest and canvas options.
13
13
  *
14
14
  * **Note:** This function only operates in Vite development mode and is a no-op in production.
15
15
  *
@@ -9,7 +9,7 @@
9
9
  declare function isViteDevelopmentMode(): boolean;
10
10
  /**
11
11
  * Initializes Pixi VN development tools by syncing game state with the Vite dev server.
12
- * Sends registered characters, labels, assets manifest, and canvas options.
12
+ * Sends assets manifest and canvas options.
13
13
  *
14
14
  * **Note:** This function only operates in Vite development mode and is a no-op in production.
15
15
  *
@@ -1 +1 @@
1
- import {a,b,c,d}from'./chunk-3BBZHKU4.mjs';import'./chunk-K7JIC2F2.mjs';import {canvas}from'./canvas.mjs';import {RegisteredCharacters}from'./characters.mjs';import {RegisteredLabels}from'./narration.mjs';import p from'./pixi/index.js';async function t(e,s,r="data"){try{await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});}catch(o){console.warn(`Failed to send ${r} to ${e}:`,o);}}function A(){let e=p.Assets.resolver._assetMap,s=p.Assets.resolver._bundles;return {bundles:Object.entries(s).map(([r,o])=>({name:r,assets:o.flatMap(d=>e[d]??[])}))}}function f(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function h(){if(f()){try{let e=RegisteredCharacters.values();await t(a,e,"characters");}catch(e){console.warn("Error collecting characters:",e);}try{let e=RegisteredLabels.keys();await t(b,e,"labels");}catch(e){console.warn("Error collecting labels:",e);}try{let e=A();await t(c,e,"assets manifest");}catch(e){console.warn("Error collecting assets manifest:",e);}if(canvas.isInitialized)try{let e={height:canvas.app.screen.height,width:canvas.app.screen.width};await t(d,e,"canvas options");}catch(e){console.warn("Error collecting canvas options:",e);}}}export{f as isViteDevelopmentMode,h as setupPixivnViteData};
1
+ import {c as c$1,d as d$1}from'./chunk-3BBZHKU4.mjs';import'./chunk-K7JIC2F2.mjs';import {canvas}from'./canvas.mjs';import a from'./pixi/index.js';async function c(t,e,s="data"){try{await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});}catch(n){console.warn(`Failed to send ${s} to ${t}:`,n);}}function f(){let t=a.Assets.resolver._assetMap,e=a.Assets.resolver._bundles;return {bundles:Object.entries(e).map(([s,n])=>({name:s,assets:n.flatMap(l=>t[l]??[])}))}}function p(){return typeof window>"u"||typeof document>"u"?false:!!document.querySelector('script[src^="/@vite/client"]')}async function d(){if(p()){try{let t=f();await c(c$1,t,"assets manifest");}catch(t){console.warn("Error collecting assets manifest:",t);}if(canvas.isInitialized)try{let t={height:canvas.app.screen.height,width:canvas.app.screen.width};await c(d$1,t,"canvas options");}catch(t){console.warn("Error collecting canvas options:",t);}}}export{p as isViteDevelopmentMode,d as setupPixivnViteData};
package/dist/vite.cjs CHANGED
@@ -1 +1,2 @@
1
- 'use strict';var fs=require('fs'),tinyglobby=require('tinyglobby');var D=Object.create;var V=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var X=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,$=Object.prototype.hasOwnProperty;var G=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var J=(e,t,s,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of X(t))!$.call(e,i)&&i!==s&&V(e,i,{get:()=>t[i],enumerable:!(c=F(t,i))||c.enumerable});return e};var H=(e,t,s)=>(s=e!=null?D(k(e)):{},J(V(s,"default",{value:e,enumerable:true}),e));var N=G((q,S)=>{var f=process||{},O=f.argv||[],u=f.env||{},j=!(u.NO_COLOR||O.includes("--no-color"))&&(!!u.FORCE_COLOR||O.includes("--color")||f.platform==="win32"||(f.stdout||{}).isTTY&&u.TERM!=="dumb"||!!u.CI),z=(e,t,s=e)=>c=>{let i=""+c,a=i.indexOf(t,e.length);return ~a?e+Y(i,t,s,a)+t:e+i+t},Y=(e,t,s,c)=>{let i="",a=0;do i+=e.substring(a,c)+s,a=c+t.length,c=e.indexOf(t,a);while(~c);return i+e.substring(a)},R=(e=j)=>{let t=e?z:()=>String;return {isColorSupported:e,reset:t("\x1B[0m","\x1B[0m"),bold:t("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:t("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:t("\x1B[3m","\x1B[23m"),underline:t("\x1B[4m","\x1B[24m"),inverse:t("\x1B[7m","\x1B[27m"),hidden:t("\x1B[8m","\x1B[28m"),strikethrough:t("\x1B[9m","\x1B[29m"),black:t("\x1B[30m","\x1B[39m"),red:t("\x1B[31m","\x1B[39m"),green:t("\x1B[32m","\x1B[39m"),yellow:t("\x1B[33m","\x1B[39m"),blue:t("\x1B[34m","\x1B[39m"),magenta:t("\x1B[35m","\x1B[39m"),cyan:t("\x1B[36m","\x1B[39m"),white:t("\x1B[37m","\x1B[39m"),gray:t("\x1B[90m","\x1B[39m"),bgBlack:t("\x1B[40m","\x1B[49m"),bgRed:t("\x1B[41m","\x1B[49m"),bgGreen:t("\x1B[42m","\x1B[49m"),bgYellow:t("\x1B[43m","\x1B[49m"),bgBlue:t("\x1B[44m","\x1B[49m"),bgMagenta:t("\x1B[45m","\x1B[49m"),bgCyan:t("\x1B[46m","\x1B[49m"),bgWhite:t("\x1B[47m","\x1B[49m"),blackBright:t("\x1B[90m","\x1B[39m"),redBright:t("\x1B[91m","\x1B[39m"),greenBright:t("\x1B[92m","\x1B[39m"),yellowBright:t("\x1B[93m","\x1B[39m"),blueBright:t("\x1B[94m","\x1B[39m"),magentaBright:t("\x1B[95m","\x1B[39m"),cyanBright:t("\x1B[96m","\x1B[39m"),whiteBright:t("\x1B[97m","\x1B[39m"),bgBlackBright:t("\x1B[100m","\x1B[49m"),bgRedBright:t("\x1B[101m","\x1B[49m"),bgGreenBright:t("\x1B[102m","\x1B[49m"),bgYellowBright:t("\x1B[103m","\x1B[49m"),bgBlueBright:t("\x1B[104m","\x1B[49m"),bgMagentaBright:t("\x1B[105m","\x1B[49m"),bgCyanBright:t("\x1B[106m","\x1B[49m"),bgWhiteBright:t("\x1B[107m","\x1B[49m")}};S.exports=R();S.exports.createColors=R;});var p="/__pixi-vn/characters",I="/__pixi-vn/labels",v="/__pixi-vn/assets/manifest",_="/__pixi-vn/canvas-options";var y=H(N());var L=y.default.cyan("(pixi-vn)");function P(e){return e?Array.isArray(e)?e:[e]:[]}function W(e){let t=[],s=[];for(let c of e)try{let i=fs.readFileSync(c,"utf-8"),a=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=a.exec(i))!==null;)s.push(d[1]);let g=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=g.exec(i))!==null;)t.push(d[1]);}catch{}return {charIds:t,labelIds:s}}function K(e){let t,s,c=new Promise(r=>{s=r;}),i=[...P(e?.content),...P(e?.characters),...P(e?.labels)],a=[],d=[],g=new Set,C=[];async function A(r,o=[]){try{a=(await r("@drincs/pixi-vn")).RegisteredCharacters?.values()??[];}catch{a=[];}try{d=(await r("@drincs/pixi-vn")).RegisteredLabels?.keys()??[];}catch{d=[];}if(o.length>0){let{charIds:n,labelIds:m}=W(o),h=new Set(a.map(b=>b.id)),M=new Set(d);for(let b of n)h.has(b)||a.push({id:b});for(let b of m)M.has(b)||d.push(b);}let l=a.map(n=>n.id).join(", ")||"none";t?.logger.info(`${L} ${y.default.dim(`${a.length} character(s): [${l}], ${d.length} label(s)`)}`,{timestamp:true});}async function w(r,o){let l=await tinyglobby.glob(i,{cwd:o,absolute:true,onlyFiles:true}),n=[];for(let m of l){g.add(m);try{await r(m);}catch{n.push(m);}}await A(r,n),s();}async function T(r){for(let n of g)for(let m of r.moduleGraph.getModulesByFile(n)??[])r.moduleGraph.invalidateModule(m);try{(await r.ssrLoadModule("@drincs/pixi-vn/characters")).registeredCharacters?.clear?.();}catch{}let o=await tinyglobby.glob(i,{cwd:t.root,absolute:true,onlyFiles:true}),l=[];for(let n of o){g.add(n);try{await r.ssrLoadModule(n);}catch{l.push(n);}}await A(n=>r.ssrLoadModule(n),l);for(let n of C)n();}let E={characters:null,labels:null,manifest:null,canvasOptions:null};function x(r,o){return (l,n)=>{if(n.setHeader("Content-Type","application/json"),l.method==="GET"){let m=E[r];if(m===null){n.statusCode=404,n.end(JSON.stringify({error:`${o} not initialized`}));return}n.statusCode=200,n.end(JSON.stringify(m));return}if(l.method==="POST"){let m="";l.on("data",h=>{m+=h.toString();}),l.on("end",()=>{try{E[r]=JSON.parse(m),n.statusCode=201,n.end(JSON.stringify({message:`${o} updated successfully`}));}catch{n.statusCode=400,n.end(JSON.stringify({error:`Invalid JSON format for ${o}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:c,get characters(){return a},onReload(r){C.push(r);}},configResolved(r){t=r,i.length===0&&s();},async buildStart(){if(t?.command!=="build"||i.length===0)return;let{createServer:r}=await import('vite'),o=await r({root:t.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true}});try{await w(l=>o.ssrLoadModule(l),t.root);}catch{s();}finally{await o.close();}},configureServer(r){i.length>0&&w(o=>r.ssrLoadModule(o),t.root).catch(()=>{s();}),r.middlewares.use(p,x("characters","Characters")),r.middlewares.use(I,x("labels","Labels")),r.middlewares.use(v,x("manifest","Manifest")),r.middlewares.use(_,x("canvasOptions","Canvas options"));},hotUpdate({file:r,server:o}){if(i.length>0&&g.has(r))return T(o).catch(l=>{t?.logger.error(`${L} Failed to reload content.`,{error:l instanceof Error?l:new Error(String(l)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=v;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=_;exports.PIXIVN_DEV_API_CHARACTERS=p;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=K;
1
+ 'use strict';var fs=require('fs'),path=require('path'),tinyglobby=require('tinyglobby');var J=Object.create;var N=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var U=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var Y=(n,e,o,m)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of H(e))!z.call(n,s)&&s!==o&&N(n,s,{get:()=>e[s],enumerable:!(m=G(e,s))||m.enumerable});return n};var W=(n,e,o)=>(o=n!=null?J(j(n)):{},Y(N(o,"default",{value:n,enumerable:true}),n));var F=U((ce,_)=>{var f=process||{},B=f.argv||[],p=f.env||{},K=!(p.NO_COLOR||B.includes("--no-color"))&&(!!p.FORCE_COLOR||B.includes("--color")||f.platform==="win32"||(f.stdout||{}).isTTY&&p.TERM!=="dumb"||!!p.CI),Q=(n,e,o=n)=>m=>{let s=""+m,l=s.indexOf(e,n.length);return ~l?n+Z(s,e,o,l)+e:n+s+e},Z=(n,e,o,m)=>{let s="",l=0;do s+=n.substring(l,m)+o,l=m+e.length,m=n.indexOf(e,l);while(~m);return s+n.substring(l)},T=(n=K)=>{let e=n?Q:()=>String;return {isColorSupported:n,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};_.exports=T();_.exports.createColors=T;});var y="/__pixi-vn/characters",I="/__pixi-vn/labels",S="/__pixi-vn/assets/manifest",P="/__pixi-vn/canvas-options";var C=W(F());var w=C.default.cyan("(pixi-vn)");function A(n){return n?Array.isArray(n)?n:[n]:[]}function se(n){let e=[],o=[];for(let m of n)try{let s=fs.readFileSync(m,"utf-8"),l=/newLabel\(\s*["']([^"']+)["']/g,d;for(;(d=l.exec(s))!==null;)o.push(d[1]);let b=/new\s+\w*[Cc]haracter\(\s*["']([^"']+)["']/g;for(;(d=b.exec(s))!==null;)e.push(d[1]);}catch{}return {charIds:e,labelIds:o}}function ae(n){let e,o,m=new Promise(t=>{o=t;}),s=[...A(n?.content),...A(n?.characters),...A(n?.labels)],l=[],d=[],b=new Set,E=[],h=new Map;function R(){if(!n?.typeFilePath||!e)return null;let t=n.typeFilePath;return path.isAbsolute(t)?t:path.resolve(e.root,t)}function D(){let t=[...d,...Array.from(h.values()).flat()];return Array.from(new Set(t))}function k(t,i,a){fs.mkdirSync(path.dirname(t),{recursive:true});let r=["// @ts-nocheck","/* eslint-disable */","// noinspection JSUnusedGlobalSymbols","// This file is auto-generated by @drincs/pixi-vn vite plugin. Do not edit manually."];if(i.length>0){r.push('declare module "@drincs/pixi-vn/characters" {'),r.push(" interface PixivnCharacterIds {");for(let c of i)r.push(` ${JSON.stringify(c)}: never;`);r.push(" }"),r.push("}");}if(a.length>0){r.push('declare module "@drincs/pixi-vn/narration" {'),r.push(" interface PixivnLabelIds {");for(let c of a)r.push(` ${JSON.stringify(c)}: never;`);r.push(" }"),r.push("}");}r.push("export {};"),r.push(""),fs.writeFileSync(t,r.join(`
2
+ `),"utf-8");}function u(){let t=R();if(t)try{k(t,l.map(i=>i.id),D());}catch(i){e?.logger.error(`${w} Failed to write type file "${t}".`,{error:i instanceof Error?i:new Error(String(i)),timestamp:true});}}async function V(t,i=[]){try{l=(await t("@drincs/pixi-vn/characters")).RegisteredCharacters?.values()??[];}catch{l=[];}try{d=(await t("@drincs/pixi-vn/narration")).RegisteredLabels?.keys()??[];}catch{d=[];}if(i.length>0){let{charIds:r,labelIds:c}=se(i),v=new Set(l.map(g=>g.id)),$=new Set(d);for(let g of r)v.has(g)||l.push({id:g});for(let g of c)$.has(g)||d.push(g);}let a=l.map(r=>r.id).join(", ")||"none";e?.logger.info(`${w} ${C.default.dim(`${l.length} character(s): [${a}], ${d.length} label(s)`)}`,{timestamp:true});}async function O(t,i){try{await t("@drincs/pixi-vn/characters");}catch{}try{await t("@drincs/pixi-vn/narration");}catch{}let a=await tinyglobby.glob(s,{cwd:i,absolute:true,onlyFiles:true}),r=[];for(let c of a){b.add(c);try{await t(c);}catch{r.push(c);}}await V(t,r),u(),o();}async function X(t){for(let r of b)for(let c of t.moduleGraph.getModulesByFile(r)??[])t.moduleGraph.invalidateModule(c);try{(await t.ssrLoadModule("@drincs/pixi-vn/characters")).RegisteredCharacters?.clear?.();}catch{}try{(await t.ssrLoadModule("@drincs/pixi-vn/narration")).RegisteredLabels?.clear?.();}catch{}let i=await tinyglobby.glob(s,{cwd:e.root,absolute:true,onlyFiles:true}),a=[];for(let r of i){b.add(r);try{await t.ssrLoadModule(r);}catch{a.push(r);}}await V(r=>t.ssrLoadModule(r),a),u();for(let r of E)r();}let L={characters:null,labels:null,manifest:null,canvasOptions:null};function x(t,i){return (a,r)=>{if(r.setHeader("Content-Type","application/json"),a.method==="GET"){let c=L[t];if(c===null){r.statusCode=404,r.end(JSON.stringify({error:`${i} not initialized`}));return}r.statusCode=200,r.end(JSON.stringify(c));return}if(a.method==="POST"){let c="";a.on("data",v=>{c+=v.toString();}),a.on("end",()=>{try{L[t]=JSON.parse(c),r.statusCode=201,r.end(JSON.stringify({message:`${i} updated successfully`}));}catch{r.statusCode=400,r.end(JSON.stringify({error:`Invalid JSON format for ${i}`}));}});}}}return {name:"vite-plugin-pixi-vn",enforce:"pre",api:{contentLoaded:m,get characters(){return l},onReload(t){E.push(t);},setExternalLabels(t,i){h.set(t,i),u();},clearExternalLabels(t){h.delete(t),u();}},config(t,i){if(i.command==="serve"&&s.length>0)return {ssr:{noExternal:["@drincs/pixi-vn"]}}},configResolved(t){e=t,s.length===0&&o();},async buildStart(){if(e?.command!=="build"||s.length===0)return;let{createServer:t}=await import('vite'),i=await t({root:e.root,configFile:false,server:{middlewareMode:true},appType:"custom",logLevel:"silent",optimizeDeps:{noDiscovery:true},ssr:{noExternal:["@drincs/pixi-vn"]}});try{await O(a=>i.ssrLoadModule(a),e.root);}catch{o();}finally{await i.close();}},configureServer(t){s.length>0&&O(i=>t.ssrLoadModule(i),e.root).catch(()=>{o();}),t.middlewares.use(y,x("characters","Characters")),t.middlewares.use(I,x("labels","Labels")),t.middlewares.use(S,x("manifest","Manifest")),t.middlewares.use(P,x("canvasOptions","Canvas options"));},hotUpdate({file:t,server:i}){let a=R();if(a&&t===a)return [];if(s.length>0&&b.has(t))return X(i).catch(r=>{e?.logger.error(`${w} Failed to reload content.`,{error:r instanceof Error?r:new Error(String(r)),timestamp:true});}),[]}}}exports.PIXIVN_DEV_API_ASSETS_MANIFEST=S;exports.PIXIVN_DEV_API_CANVAS_OPTIONS=P;exports.PIXIVN_DEV_API_CHARACTERS=y;exports.PIXIVN_DEV_API_LABELS=I;exports.vitePluginPixivn=ae;