@drincs/pixi-vn 1.9.4 → 1.9.6
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.
- package/README.md +186 -170
- package/dist/{ContainerMemory-DNqSVzLY.d.cts → ContainerMemory-De04YSUc.d.cts} +2 -1
- package/dist/{ContainerMemory-DNqSVzLY.d.ts → ContainerMemory-De04YSUc.d.ts} +2 -1
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +1008 -918
- package/dist/canvas.d.ts +1008 -918
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.d.cts +3 -2
- package/dist/characters.d.ts +3 -2
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-S7HZUIEI.mjs → chunk-A5FN4SNI.mjs} +1 -1
- package/dist/chunk-B46NFIFC.mjs +1 -0
- package/dist/chunk-FPMP2OWB.mjs +1 -0
- package/dist/{chunk-6OABTG5R.mjs → chunk-OJKUK6GL.mjs} +1 -1
- package/dist/{chunk-5MVDNAT4.mjs → chunk-WYGKBGMH.mjs} +1 -1
- package/dist/chunk-XLRCR56W.mjs +1 -0
- package/dist/core.d.cts +12 -5
- package/dist/core.d.ts +12 -5
- package/dist/filters.cjs +1 -1
- package/dist/filters.d.cts +18 -3
- package/dist/filters.d.ts +18 -3
- package/dist/filters.mjs +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +10 -5
- package/dist/history.d.ts +10 -5
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +16 -7
- package/dist/index.d.ts +16 -7
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +8 -2
- package/dist/motion.d.ts +8 -2
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +2 -2
- package/dist/narration.d.cts +7 -2
- package/dist/narration.d.ts +7 -2
- package/dist/narration.mjs +1 -1
- package/dist/pixi/browser.js +182 -148
- package/dist/sound.cjs +1 -1
- package/dist/sound.d.cts +3 -2
- package/dist/sound.d.ts +3 -2
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +7 -2
- package/dist/storage.d.ts +7 -2
- package/dist/storage.mjs +1 -1
- package/dist/tickers.cjs +1 -1
- package/dist/tickers.d.cts +72 -1
- package/dist/tickers.d.ts +72 -1
- package/dist/tickers.mjs +1 -1
- package/dist/vite-listener.mjs +1 -1
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +2 -1
- package/dist/vite.d.ts +2 -1
- package/dist/vite.mjs +1 -1
- package/dist/worker.cjs +1 -1
- package/dist/worker.d.cts +2 -1
- package/dist/worker.d.ts +2 -1
- package/package.json +11 -10
- package/dist/chunk-AW5XWF24.mjs +0 -1
- package/dist/chunk-K7JIC2F2.mjs +0 -1
package/dist/narration.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');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 Je=s=>{throw TypeError(s)};var Tt=(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 _t=(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=St(e,i))||n.enumerable});return s};var Ct=(s,e,t)=>(t=s!=null?yt(gt(s)):{},_t(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>Tt(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Je("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)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),S=(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){S(s,e,i);},get _(){return r(s,e,n)}});var ut=Ze((ze,ct)=>{(function(s,e){typeof ze=="object"?ct.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 l(){}return function(d){var E;return l.prototype=d,E=new l,l.prototype=null,E}})(),o={},p=o.lib={},c=p.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=p.WordArray=c.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||g).stringify(this)},concat:function(l){var d=this.words,E=l.words,C=this.sigBytes,R=l.sigBytes;if(this.clamp(),C%4)for(var D=0;D<R;D++){var se=E[D>>>2]>>>24-D%4*8&255;d[C+D>>>2]|=se<<24-(C+D)%4*8;}else for(var G=0;G<R;G+=4)d[C+G>>>2]=E[G>>>2];return this.sigBytes+=R,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=c.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],E=0;E<l;E+=4)d.push(i());return new y.init(d,l)}}),h=o.enc={},g=h.Hex={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push((D>>>4).toString(16)),C.push((D&15).toString(16));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C+=2)E[C>>>3]|=parseInt(l.substr(C,2),16)<<24-C%8*4;return new y.init(E,d/2)}},M=h.Latin1={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push(String.fromCharCode(D));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C++)E[C>>>2]|=(l.charCodeAt(C)&255)<<24-C%4*8;return new y.init(E,d)}},N=h.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)))}},P=p.BufferedBlockAlgorithm=c.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,E=this._data,C=E.words,R=E.sigBytes,D=this.blockSize,se=D*4,G=R/se;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var Q=G*D,Le=e.min(Q*4,R);if(Q){for(var Ke=0;Ke<Q;Ke+=D)this._doProcessBlock(C,Ke);d=C.splice(0,Q),E.sigBytes-=Le;}return new y.init(d,Le)},clone:function(){var l=c.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});p.Hasher=P.extend({cfg:c.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){P.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,E){return new l.init(E).finalize(d)}},_createHmacHelper:function(l){return function(d,E){return new _.HMAC.init(l,E).finalize(d)}}});var _=o.algo={};return o})(Math);return s});});var dt=Ze((He,ht)=>{(function(s,e){typeof He=="object"?ht.exports=He=e(ut()):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=[],p=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,y){for(var h=this._hash.words,g=h[0],M=h[1],N=h[2],P=h[3],w=h[4],_=0;_<80;_++){if(_<16)o[_]=c[y+_]|0;else {var l=o[_-3]^o[_-8]^o[_-14]^o[_-16];o[_]=l<<1|l>>>31;}var d=(g<<5|g>>>27)+w+o[_];_<20?d+=(M&N|~M&P)+1518500249:_<40?d+=(M^N^P)+1859775393:_<60?d+=(M&N|M&P|N&P)-1894007588:d+=(M^N^P)-899497514,w=P,P=N,N=M<<30|M>>>2,M=g,g=d;}h[0]=h[0]+g|0,h[1]=h[1]+M|0,h[2]=h[2]+N|0,h[3]=h[3]+P|0,h[4]=h[4]+w|0;},_doFinalize:function(){var c=this._data,y=c.words,h=this._nDataBytes*8,g=c.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(h/4294967296),y[(g+64>>>9<<4)+15]=h,c.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var c=i.clone.call(this);return c._hash=this._hash.clone(),c}});e.SHA1=i._createHelper(p),e.HmacSHA1=i._createHmacHelper(p);})(),s.SHA1});});var O="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 Et=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 he=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>he(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);}},oe,Te,Rt=(oe=class{heap;length;static create(e){let t=at(e);if(!t)return [];S(oe,Te,true);let n=new oe(e,t);return S(oe,Te,false),n}constructor(e,t){if(!r(oe,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(oe,Te,false),oe),tt,rt,X,B,J,Se,Z,_e,Ce,ee,Y,te,U,A,T,K,j,H,V,re,F,ne,ie,k,q,ae,ye,W,Ee,u,qe,me,pe,Ae,$,ot,ge,Ie,Me,de,fe,$e,Ve,Fe,x,Xe,xe,be,Qe,Re,st=(Re=class{constructor(e){v(this,u);v(this,X);v(this,B);v(this,J);v(this,Se);v(this,Z);v(this,_e);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,T);v(this,K);v(this,j);v(this,H);v(this,V);v(this,re);v(this,F);v(this,ne);v(this,ie);v(this,k);v(this,q);v(this,ae);v(this,ye);v(this,W);v(this,Ee);v(this,me,()=>{});v(this,pe,()=>{});v(this,Ae,()=>{});v(this,$,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Me,(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:p,allowStale:c,dispose:y,onInsert:h,disposeAfter:g,noDisposeOnSet:M,noUpdateTTL:N,maxSize:P=0,maxEntrySize:w=0,sizeCalculation:_,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:se,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??Et),t!==0&&!he(t))throw new TypeError("max option must be a nonnegative integer");let Q=t?at(t):Array;if(!Q)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,P),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,Ce,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 Q(t)),S(this,j,new Q(t)),S(this,H,0),S(this,V,0),S(this,re,Rt.create(t)),S(this,Y,0),S(this,te,0),typeof y=="function"&&S(this,J,y),typeof h=="function"&&S(this,Se,h),typeof g=="function"?(S(this,Z,g),S(this,F,[])):(S(this,Z,void 0),S(this,F,void 0)),S(this,ae,!!r(this,J)),S(this,Ee,!!r(this,Se)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!se,this.maxEntrySize!==0){if(r(this,B)!==0&&!he(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!he(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,u,ot).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!p,this.ttlResolution=he(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!he(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,u,qe).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,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,q),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,V)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,u,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,u,Fe).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,u,xe).call(n,t)},indexes:t=>{var n;return f(n=e,u,de).call(n,t)},rindexes:t=>{var n;return f(n=e,u,fe).call(n,t)},isStale:t=>{var n;return r(n=e,$).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,Ce)}get dispose(){return r(this,J)}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,u,de).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,u,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,u,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&!f(this,u,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,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,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,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,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,u,fe).call(this)){let i=r(this,T)[n],a=f(this,u,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,u,fe).call(this,{allowStale:true}))r(this,$).call(this,t)&&(f(this,u,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,u,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],p=r(this,ie)[t];if(o&&p){let c=o-(r(this,ee).now()-p);a.ttl=c,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,u,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,T)[t],a=f(this,u,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 p=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-p);}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,P,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:p=this.sizeCalculation,status:c}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,h=r(this,Me).call(this,e,t,n.size||0,p);if(this.maxEntrySize&&h>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),f(this,u,be).call(this,e,"set"),this;let g=r(this,Y)===0?void 0:r(this,U).get(e);if(g===void 0)g=r(this,Y)===0?r(this,V):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,u,Ve).call(this,false):r(this,Y),r(this,A)[g]=e,r(this,T)[g]=t,r(this,U).set(e,g),r(this,K)[r(this,V)]=g,r(this,j)[g]=r(this,V),S(this,V,g),Ue(this,Y)._++,r(this,Ie).call(this,g,h,c),c&&(c.set="add"),y=false,r(this,Ee)&&((M=r(this,Se))==null||M.call(this,t,e,"add"));else {f(this,u,xe).call(this,g);let _=r(this,T)[g];if(t!==_){if(r(this,ye)&&f(this,u,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=_;l!==void 0&&!o&&(r(this,ae)&&((N=r(this,J))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,F)?.push([l,e,"set"]));}else o||(r(this,ae)&&((P=r(this,J))==null||P.call(this,_,e,"set")),r(this,W)&&r(this,F)?.push([_,e,"set"]));if(r(this,ge).call(this,g),r(this,Ie).call(this,g,h,c),r(this,T)[g]=t,c){c.set="replace";let l=_&&f(this,u,x).call(this,_)?_.__staleWhileFetching:_;l!==void 0&&(c.oldValue=l);}}else c&&(c.set="update");r(this,Ee)&&this.onInsert?.(t,e,t===_?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,u,qe).call(this),r(this,k)&&(y||r(this,Ae).call(this,g,i,a),c&&r(this,pe).call(this,c,g)),!o&&r(this,W)&&r(this,F)){let _=r(this,F),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,u,Ve).call(this,!0),f(this,u,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,F)){let t=r(this,F),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,T)[a];if(f(this,u,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,$).call(this,a))i&&(i.has="stale",r(this,pe).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,pe).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,$).call(this,i))return;let a=r(this,T)[i];return f(this,u,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:p=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=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 E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:p,size:c,sizeCalculation:y,noUpdateTTL:h,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,status:l,signal:d},C=r(this,U).get(e);if(C===void 0){l&&(l.fetch="miss");let R=f(this,u,Fe).call(this,e,C,E,w);return R.__returned=R}else {let R=r(this,T)[C];if(f(this,u,x).call(this,R)){let Q=n&&R.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",Q&&(l.returnedStale=true)),Q?R.__staleWhileFetching:R.__returned=R}let D=r(this,$).call(this,C);if(!_&&!D)return l&&(l.fetch="hit"),f(this,u,xe).call(this,C),i&&r(this,me).call(this,C),l&&r(this,pe).call(this,l,C),R;let se=f(this,u,Fe).call(this,e,C,E,w),G=se.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=D?"stale":"refresh",G&&D&&(l.returnedStale=true)),G?se.__staleWhileFetching:se.__returned=se}}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,p=this.get(e,o);if(!a&&p!==void 0)return p;let c=n(e,p,{options:o,context:i});return this.set(e,c,o),c}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,p=r(this,U).get(e);if(p!==void 0){let c=r(this,T)[p],y=f(this,u,x).call(this,c);return o&&r(this,pe).call(this,o,p),r(this,$).call(this,p)?(o&&(o.get="stale"),y?(o&&n&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?c.__staleWhileFetching:void 0):(a||f(this,u,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?c:void 0)):(o&&(o.get="hit"),y?c.__staleWhileFetching:(f(this,u,xe).call(this,p),i&&r(this,me).call(this,p),c))}else o&&(o.get="miss");}delete(e){return f(this,u,be).call(this,e,"delete")}clear(){return f(this,u,Qe).call(this,"delete")}},X=new WeakMap,B=new WeakMap,J=new WeakMap,Se=new WeakMap,Z=new WeakMap,_e=new WeakMap,Ce=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,V=new WeakMap,re=new WeakMap,F=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,q=new WeakMap,ae=new WeakMap,ye=new WeakMap,W=new WeakMap,Ee=new WeakMap,u=new WeakSet,qe=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,q,n),S(this,Ae,(p,c,y=r(this,ee).now())=>{t[p]=c!==0?y:0,e[p]=c,i(p,c);}),S(this,me,p=>{t[p]=e[p]!==0?r(this,ee).now():0,i(p,e[p]);});let i=this.ttlAutopurge?(p,c)=>{if(n?.[p]&&(clearTimeout(n[p]),n[p]=void 0),c&&c!==0&&n){let y=setTimeout(()=>{r(this,$).call(this,p)&&f(this,u,be).call(this,r(this,A)[p],"expire");},c+1);y.unref&&y.unref(),n[p]=y;}}:()=>{};S(this,pe,(p,c)=>{if(e[c]){let y=e[c],h=t[c];if(!y||!h)return;p.ttl=y,p.start=h,p.now=a||o();let g=p.now-h;p.remainingTTL=y-g;}});let a=0,o=()=>{let p=r(this,ee).now();if(this.ttlResolution>0){a=p;let c=setTimeout(()=>a=0,this.ttlResolution);c.unref&&c.unref();}return p};this.getRemainingTTL=p=>{let c=r(this,U).get(p);if(c===void 0)return 0;let y=e[c],h=t[c];if(!y||!h)return 1/0;let g=(a||o())-h;return y-g},S(this,$,p=>{let c=t[p],y=e[p];return !!y&&!!c&&(a||o())-c>y});},me=new WeakMap,pe=new WeakMap,Ae=new WeakMap,$=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,Me,(t,n,i,a)=>{if(f(this,u,x).call(this,n))return 0;if(!he(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!he(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,u,Ve).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,Me=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,V);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).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,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,V)));)t=r(this,K)[t];},$e=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Ve=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,u,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,J))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,F)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,q)?.[t]&&(clearTimeout(r(this,q)[t]),r(this,q)[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,V,0)),r(this,re).length=0):S(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Fe=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,u,x).call(this,a))return a;let o=new Ge,{signal:p}=n;p?.addEventListener("abort",()=>o.abort(p.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:i},y=(w,_=false)=>{let{aborted:l}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,E=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!_?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!_)return g(o.signal.reason,E);let C=N,R=r(this,T)[t];return (R===N||d&&_&&R===void 0)&&(w===void 0?C.__staleWhileFetching!==void 0?r(this,T)[t]=C.__staleWhileFetching:f(this,u,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,c.options))),w},h=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),g(w,false)),g=(w,_)=>{let{aborted:l}=o.signal,d=l&&n.allowStaleOnFetchAbort,E=d||n.allowStaleOnFetchRejection,C=E||n.noDeleteOnFetchRejection,R=N;if(r(this,T)[t]===N&&(!C||!_&&R.__staleWhileFetching===void 0?f(this,u,be).call(this,e,"fetch"):d||(r(this,T)[t]=R.__staleWhileFetching)),E)return n.status&&R.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),R.__staleWhileFetching;if(R.__returned===R)throw w},M=(w,_)=>{var d;let l=(d=r(this,_e))==null?void 0:d.call(this,e,a,c);l&&l instanceof Promise&&l.then(E=>w(E===void 0?void 0:E),_),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=E=>y(E,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(y,h),P=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,P,{...c.options,status:void 0}),t=r(this,U).get(e)):r(this,T)[t]=P,P},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;},xe=function(e){e!==r(this,V)&&(e===r(this,H)?S(this,H,r(this,K)[e]):f(this,u,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,u,Xe).call(this,r(this,V),e),S(this,V,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,q)?.[o]&&(clearTimeout(r(this,q)?.[o]),r(this,q)[o]=void 0),n=true,r(this,Y)===1)f(this,u,Qe).call(this,t);else {r(this,ge).call(this,o);let p=r(this,T)[o];if(f(this,u,x).call(this,p)?p.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,J))==null||i.call(this,p,e,t)),r(this,W)&&r(this,F)?.push([p,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,T)[o]=void 0,o===r(this,V))S(this,V,r(this,j)[o]);else if(o===r(this,H))S(this,H,r(this,K)[o]);else {let c=r(this,j)[o];r(this,K)[c]=r(this,K)[o];let y=r(this,K)[o];r(this,j)[y]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,F)?.length){let o=r(this,F),p;for(;p=o?.shift();)(a=r(this,Z))==null||a.call(this,...p);}return n},Qe=function(e){var t,n;for(let i of f(this,u,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,u,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,J))==null||t.call(this,a,o,e)),r(this,W)&&r(this,F)?.push([a,o,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,q)??[])i!==void 0&&clearTimeout(i);r(this,q)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,H,0),S(this,V,0),r(this,re).length=0,S(this,te,0),S(this,Y,0),r(this,W)&&r(this,F)){let i=r(this,F),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var Ne=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 L;(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)))(L||={});var Oe=new Ne({cacheSize:10}),lt;(o=>{function s(p){let c=Oe.get(p);if(!c){L.error(`Label "${p}" not found`);return}return c}o.get=s;function e(...p){for(let c of p)Oe.set(c.id,c);}o.add=e;function t(){return Array.from(Oe.values())}o.values=t;function n(p){return Oe.has(p)}o.has=n;function i(){return Array.from(Oe.keys())}o.keys=i;function a(){Oe.clear();}o.clear=a;})(lt||={});var le=lt;function ce(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw L.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(O,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(O,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return L.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return L.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",p=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[i]||(p[i]={}),(!p[i][n]||p[i][n].stepSha1!==o)&&(p[i][n]={stepSha1:o}),p[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return L.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 p=o.usedRandomNumbers||{},c=Array.from({length:t-e+1},(g,M)=>M+e).filter(g=>!p[`${e}-${t}`]?.includes(g));if(c.length===0)return;let y=Math.floor(Math.random()*c.length),h=c[y];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(h),o.usedRandomNumbers=p,s.setCurrentStepTimesCounterData(i,o),h}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){L.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(O,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(O,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return ce(s._openedLabels)}static set openedLabels(e){s._openedLabels=ce(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return ce(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=ce(e);}static get _currentLabel(){if(s.currentLabelId)return le.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(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===i&&p.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(!le.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;static onLabelStarting;static onLabelClosing};var De=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}async addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,p,c=core.GameUnifier.getVariable(O,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,h={currentLabel:b.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:p,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:c,openedLabels:y};b.originalOpenedLabels=y,await core.GameUnifier.addHistoryItem(h,{ignoreSameStep:i}),b.lastHistoryStep=h,b.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=b.currentLabelStepIndex,n=this.currentLabel;if(!(t===null||!n))return b.allChoicesMade.filter(i=>i.labelId===n.id&&i.stepIndex===t&&i.stepSha1===e).map(i=>i.choiceIndex)}closeCurrentLabel(){if(!b.currentLabelId){L.warn("No label to close");return}if(!this.currentLabel){L.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);}labels={get opened(){return b.openedLabels},get current(){return b._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=le.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||(L.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}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e){let t=e?.showWarn||false,n=this.choicesValue;return n&&n.length>0?(t&&L.warn("The player must make a choice"),false):this.isRequiredInput?(t&&L.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0||this.openedLabels.length===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)){L.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){L.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 L.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"});L.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){L.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){L.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(h){L.error("Error running onStepStart",h),this.onStepError&&await this.onStepError(h,e);return}let o=a.getStepById(i);if(!o){L.error("step not found");return}let p=a.getStepSha(i);p||(L.warn("stepSha not found, setting to ERROR"),p="error");let c,y;try{c=await o(e,{labelId:a.id});}catch(h){L.error("Error running step",h),y=h;}try{let h=this.choicesValue;if(h?.length===1&&h[0].autoSelect){let g=h[0];c=await this.selectChoice(g,e);}}catch(h){L.error("Error auto-selecting choice",h),y||(y=h);}try{let h=b.lastHistoryStep;n!==void 0&&h&&(p=h.stepSha1,p||(L.warn("stepSha not found, setting to ERROR"),p="error"),b.addChoicesMade(h.currentLabel||"error",typeof h.labelStepIndex=="number"?h.labelStepIndex:-1,h.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(h){L.warn("Error adding choice made to history",h);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),await this.addStepHistory(p,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(h){L.warn("Error adding step to history",h);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(h){L.warn("Error running onStepEnd",h);}return y&&this.onStepError&&await this.onStepError(y,e),c}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e,t)}else {if(this.openedLabels.length===0)return;L.error("currentLabelId not found");}}async closeLabel(e,t,n){let i=async()=>(this.closeCurrentLabel(),await this.continue(t,n));return b.onLabelClosing?await b.onLabelClosing(e,t,i):await i()}async startLabel(e,t,n){let i=async()=>{let{choiceMade:a,closeCurrentLabel:o,type:p}=n;o&&this.openedLabels.length>0&&this.closeCurrentLabel(),core.GameUnifier.runningStepsCount++;let c;try{let y=le.get(e);if(!y)throw new core.PixiError("unregistered_element",`Label ${e} not found`);b.pushNewLabel(y.id),c=await this.runCurrentStep(t,{choiceMade:a});}catch(y){throw L.error(`Error ${p} label`,y),y}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||c};return b.onLabelStarting?await b.onLabelStarting(e,t,n,i):await i()}async call(e,t,n){let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,type:"calling"})}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choicesValue=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 L.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw L.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){L.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(O,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(O,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(O,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(O,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,ce({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choicesValue(){let e=core.GameUnifier.getVariable(O,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 choicesValue(e){if(!e||e.length===0){core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,ce(e)),core.GameUnifier.setVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}choicesObj=(()=>{let e=this,t={select:(n,i)=>e.selectChoice(n,i)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:n=>{e.choicesValue=n;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}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(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,core.GameUnifier.setVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,n)=>e.requestInput(t,n),removeRequest:()=>e.removeInputRequest()}})();clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:ce(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=le.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):L.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:L.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){L.error("Error running onLoadingLabel",n);}}catch(n){L.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 pt="close";function At(s,e){return {...e,type:pt,text:s}}var ft=Ct(dt());var ve=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 we=class extends ve{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){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&L.warn("stepSha not found, setting to ERROR"),"error";try{return (0,ft.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(n){return L.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(s,e,t){let n=new we(s,e,t);return le.add(n),n}var Cr=new De;
|
|
2
|
-
exports.Label=
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var ft=Object.create;var Ge=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var St=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var Qe=o=>{throw TypeError(o)};var gt=(o,e,t)=>e in o?Ge(o,e,{enumerable:true,configurable:true,writable:true,value:t}):o[e]=t;var Ke=(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 Je=(o,e)=>()=>{try{return e||o((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}};var Lt=(o,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of yt(e))!mt.call(o,i)&&i!==t&&Ge(o,i,{get:()=>e[i],enumerable:!(r=bt(e,i))||r.enumerable});return o};var Tt=(o,e,t)=>(t=o!=null?ft(St(o)):{},Lt(Ge(t,"default",{value:o,enumerable:true}),o));var z=(o,e,t)=>gt(o,typeof e!="symbol"?e+"":e,t),He=(o,e,t)=>e.has(o)||Qe("Cannot "+t);var n=(o,e,t)=>(He(o,e,"read from private field"),t?t.call(o):e.get(o)),w=(o,e,t)=>e.has(o)?Qe("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(o):e.set(o,t),y=(o,e,t,r)=>(He(o,e,"write to private field"),e.set(o,t),t),f=(o,e,t)=>(He(o,e,"access private method"),t);var Ne=(o,e,t,r)=>({set _(i){y(o,e,i);},get _(){return n(o,e,r)}});var ct=Je((Ve,lt)=>{"use strict";(function(o,e){typeof Ve=="object"?lt.exports=Ve=e():typeof define=="function"&&define.amd?define([],e):o.CryptoJS=e();})(Ve,function(){var o=o||(function(e,t){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof Ke=="function")try{r=Ke("crypto");}catch{}var i=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.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(h){var C;return l.prototype=h,C=new l,l.prototype=null,C}})(),s={},c=s.lib={},u=c.Base=(function(){return {extend:function(l){var h=a(this);return l&&h.mixIn(l),(!h.hasOwnProperty("init")||this.init===h.init)&&(h.init=function(){h.$super.init.apply(this,arguments);}),h.init.prototype=h,h.$super=this,h},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var h in l)l.hasOwnProperty(h)&&(this[h]=l[h]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),m=c.WordArray=u.extend({init:function(l,h){l=this.words=l||[],h!=t?this.sigBytes=h:this.sigBytes=l.length*4;},toString:function(l){return (l||_).stringify(this)},concat:function(l){var h=this.words,C=l.words,L=this.sigBytes,A=l.sigBytes;if(this.clamp(),L%4)for(var D=0;D<A;D++){var k=C[D>>>2]>>>24-D%4*8&255;h[L+D>>>2]|=k<<24-(L+D)%4*8;}else for(var K=0;K<A;K+=4)h[L+K>>>2]=C[K>>>2];return this.sigBytes+=A,this},clamp:function(){var l=this.words,h=this.sigBytes;l[h>>>2]&=4294967295<<32-h%4*8,l.length=e.ceil(h/4);},clone:function(){var l=u.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var h=[],C=0;C<l;C+=4)h.push(i());return new m.init(h,l)}}),d=s.enc={},_=d.Hex={stringify:function(l){for(var h=l.words,C=l.sigBytes,L=[],A=0;A<C;A++){var D=h[A>>>2]>>>24-A%4*8&255;L.push((D>>>4).toString(16)),L.push((D&15).toString(16));}return L.join("")},parse:function(l){for(var h=l.length,C=[],L=0;L<h;L+=2)C[L>>>3]|=parseInt(l.substr(L,2),16)<<24-L%8*4;return new m.init(C,h/2)}},M=d.Latin1={stringify:function(l){for(var h=l.words,C=l.sigBytes,L=[],A=0;A<C;A++){var D=h[A>>>2]>>>24-A%4*8&255;L.push(String.fromCharCode(D));}return L.join("")},parse:function(l){for(var h=l.length,C=[],L=0;L<h;L++)C[L>>>2]|=(l.charCodeAt(L)&255)<<24-L%4*8;return new m.init(C,h)}},N=d.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)))}},P=c.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new m.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 h,C=this._data,L=C.words,A=C.sigBytes,D=this.blockSize,k=D*4,K=A/k;l?K=e.ceil(K):K=e.max((K|0)-this._minBufferSize,0);var le=K*D,Re=e.min(le*4,A);if(le){for(var ze=0;ze<le;ze+=D)this._doProcessBlock(L,ze);h=L.splice(0,le),C.sigBytes-=Re;}return new m.init(h,Re)},clone:function(){var l=u.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0}),O=c.Hasher=P.extend({cfg:u.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){P.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var h=this._doFinalize();return h},blockSize:512/32,_createHelper:function(l){return function(h,C){return new l.init(C).finalize(h)}},_createHmacHelper:function(l){return function(h,C){return new E.HMAC.init(l,C).finalize(h)}}}),E=s.algo={};return s})(Math);return o});});var pt=Je((Fe,ut)=>{"use strict";(function(o,e){typeof Fe=="object"?ut.exports=Fe=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(o.CryptoJS);})(Fe,function(o){return (function(){var e=o,t=e.lib,r=t.WordArray,i=t.Hasher,a=e.algo,s=[],c=a.SHA1=i.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,m){for(var d=this._hash.words,_=d[0],M=d[1],N=d[2],P=d[3],O=d[4],E=0;E<80;E++){if(E<16)s[E]=u[m+E]|0;else {var l=s[E-3]^s[E-8]^s[E-14]^s[E-16];s[E]=l<<1|l>>>31;}var h=(_<<5|_>>>27)+O+s[E];E<20?h+=(M&N|~M&P)+1518500249:E<40?h+=(M^N^P)+1859775393:E<60?h+=(M&N|M&P|N&P)-1894007588:h+=(M^N^P)-899497514,O=P,P=N,N=M<<30|M>>>2,M=_,_=h;}d[0]=d[0]+_|0,d[1]=d[1]+M|0,d[2]=d[2]+N|0,d[3]=d[3]+P|0,d[4]=d[4]+O|0;},_doFinalize:function(){var u=this._data,m=u.words,d=this._nDataBytes*8,_=u.sigBytes*8;return m[_>>>5]|=128<<24-_%32,m[(_+64>>>9<<4)+14]=Math.floor(d/4294967296),m[(_+64>>>9<<4)+15]=d,u.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var u=i.clone.call(this);return u._hash=this._hash.clone(),u}});e.SHA1=i._createHelper(c),e.HmacSHA1=i._createHmacHelper(c);})(),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 Se=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,rt=new Set,We=typeof process=="object"&&process?process:{},nt=(o,e,t,r)=>{typeof We.emitWarning=="function"?We.emitWarning(o,e,t,r):console.error(`[${t}] ${e}: ${o}`);},Ue=globalThis.AbortController,Ze=globalThis.AbortSignal;if(typeof Ue>"u"){Ze=class{onabort;_onabort=[];reason;aborted=false;addEventListener(r,i){this._onabort.push(i);}},Ue=class{constructor(){e();}signal=new Ze;abort(r){if(!this.signal.aborted){this.signal.reason=r,this.signal.aborted=true;for(let i of this.signal._onabort)i(r);this.signal.onabort?.(r);}}};let o=We.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{o&&(o=false,nt("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 _t=o=>!rt.has(o);var ce=o=>o&&o===Math.floor(o)&&o>0&&isFinite(o),it=o=>ce(o)?o<=Math.pow(2,8)?Uint8Array:o<=Math.pow(2,16)?Uint16Array:o<=Math.pow(2,32)?Uint32Array:o<=Number.MAX_SAFE_INTEGER?me:null:null,me=class extends Array{constructor(e){super(e),this.fill(0);}},ge,fe=class fe{heap;length;static create(e){let t=it(e);if(!t)return [];y(fe,ge,true);let r=new fe(e,t);return y(fe,ge,false),r}constructor(e,t){if(!n(fe,ge))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]}};ge=new WeakMap,w(fe,ge,false);var Be=fe,et,tt,X,B,Q,J,Le,Te,Y,Z,U,v,T,H,j,G,V,ee,F,te,re,q,ne,de,W,p,je,be,ae,we,$,at,ye,_e,Ae,ue,pe,qe,Pe,De,x,$e,Oe,he,ke,Xe=class Xe{constructor(e){w(this,p);w(this,X);w(this,B);w(this,Q);w(this,J);w(this,Le);w(this,Te);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");w(this,Y);w(this,Z);w(this,U);w(this,v);w(this,T);w(this,H);w(this,j);w(this,G);w(this,V);w(this,ee);w(this,F);w(this,te);w(this,re);w(this,q);w(this,ne);w(this,de);w(this,W);w(this,be,()=>{});w(this,ae,()=>{});w(this,we,()=>{});w(this,$,()=>false);w(this,ye,e=>{});w(this,_e,(e,t,r)=>{});w(this,Ae,(e,t,r,i)=>{if(r||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,et,"LRUCache");let{max:t=0,ttl:r,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:s,updateAgeOnHas:c,allowStale:u,dispose:m,disposeAfter:d,noDisposeOnSet:_,noUpdateTTL:M,maxSize:N=0,maxEntrySize:P=0,sizeCalculation:O,fetchMethod:E,memoMethod:l,noDeleteOnFetchRejection:h,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:L,allowStaleOnFetchAbort:A,ignoreFetchAbort:D}=e;if(t!==0&&!ce(t))throw new TypeError("max option must be a nonnegative integer");let k=t?it(t):Array;if(!k)throw new Error("invalid max value: "+t);if(y(this,X,t),y(this,B,N),this.maxEntrySize=P||n(this,B),this.sizeCalculation=O,this.sizeCalculation){if(!n(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(l!==void 0&&typeof l!="function")throw new TypeError("memoMethod must be a function if defined");if(y(this,Te,l),E!==void 0&&typeof E!="function")throw new TypeError("fetchMethod must be a function if specified");if(y(this,Le,E),y(this,de,!!E),y(this,U,new Map),y(this,v,new Array(t).fill(void 0)),y(this,T,new Array(t).fill(void 0)),y(this,H,new k(t)),y(this,j,new k(t)),y(this,G,0),y(this,V,0),y(this,ee,Be.create(t)),y(this,Y,0),y(this,Z,0),typeof m=="function"&&y(this,Q,m),typeof d=="function"?(y(this,J,d),y(this,F,[])):(y(this,J,void 0),y(this,F,void 0)),y(this,ne,!!n(this,Q)),y(this,W,!!n(this,J)),this.noDisposeOnSet=!!_,this.noUpdateTTL=!!M,this.noDeleteOnFetchRejection=!!h,this.allowStaleOnFetchRejection=!!L,this.allowStaleOnFetchAbort=!!A,this.ignoreFetchAbort=!!D,this.maxEntrySize!==0){if(n(this,B)!==0&&!ce(n(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!ce(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,p,at).call(this);}if(this.allowStale=!!u,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!c,this.ttlResolution=ce(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=r||0,this.ttl){if(!ce(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,p,je).call(this);}if(n(this,X)===0&&this.ttl===0&&n(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!n(this,X)&&!n(this,B)){let K="LRU_CACHE_UNBOUNDED";_t(K)&&(rt.add(K),nt("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",K,Xe));}}static unsafeExposeInternals(e){return {starts:n(e,re),ttls:n(e,q),sizes:n(e,te),keyMap:n(e,U),keyList:n(e,v),valList:n(e,T),next:n(e,H),prev:n(e,j),get head(){return n(e,G)},get tail(){return n(e,V)},free:n(e,ee),isBackgroundFetch:t=>{var r;return f(r=e,p,x).call(r,t)},backgroundFetch:(t,r,i,a)=>{var s;return f(s=e,p,De).call(s,t,r,i,a)},moveToTail:t=>{var r;return f(r=e,p,Oe).call(r,t)},indexes:t=>{var r;return f(r=e,p,ue).call(r,t)},rindexes:t=>{var r;return f(r=e,p,pe).call(r,t)},isStale:t=>{var r;return n(r=e,$).call(r,t)}}}get max(){return n(this,X)}get maxSize(){return n(this,B)}get calculatedSize(){return n(this,Z)}get size(){return n(this,Y)}get fetchMethod(){return n(this,Le)}get memoMethod(){return n(this,Te)}get dispose(){return n(this,Q)}get disposeAfter(){return n(this,J)}getRemainingTTL(e){return n(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,p,ue).call(this))n(this,T)[e]!==void 0&&n(this,v)[e]!==void 0&&!f(this,p,x).call(this,n(this,T)[e])&&(yield [n(this,v)[e],n(this,T)[e]]);}*rentries(){for(let e of f(this,p,pe).call(this))n(this,T)[e]!==void 0&&n(this,v)[e]!==void 0&&!f(this,p,x).call(this,n(this,T)[e])&&(yield [n(this,v)[e],n(this,T)[e]]);}*keys(){for(let e of f(this,p,ue).call(this)){let t=n(this,v)[e];t!==void 0&&!f(this,p,x).call(this,n(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,p,pe).call(this)){let t=n(this,v)[e];t!==void 0&&!f(this,p,x).call(this,n(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,p,ue).call(this))n(this,T)[e]!==void 0&&!f(this,p,x).call(this,n(this,T)[e])&&(yield n(this,T)[e]);}*rvalues(){for(let e of f(this,p,pe).call(this))n(this,T)[e]!==void 0&&!f(this,p,x).call(this,n(this,T)[e])&&(yield n(this,T)[e]);}[(tt=Symbol.iterator,et=Symbol.toStringTag,tt)](){return this.entries()}find(e,t={}){for(let r of f(this,p,ue).call(this)){let i=n(this,T)[r],a=f(this,p,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,n(this,v)[r],this))return this.get(n(this,v)[r],t)}}forEach(e,t=this){for(let r of f(this,p,ue).call(this)){let i=n(this,T)[r],a=f(this,p,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,n(this,v)[r],this);}}rforEach(e,t=this){for(let r of f(this,p,pe).call(this)){let i=n(this,T)[r],a=f(this,p,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,n(this,v)[r],this);}}purgeStale(){let e=false;for(let t of f(this,p,pe).call(this,{allowStale:true}))n(this,$).call(this,t)&&(f(this,p,he).call(this,n(this,v)[t],"expire"),e=true);return e}info(e){let t=n(this,U).get(e);if(t===void 0)return;let r=n(this,T)[t],i=f(this,p,x).call(this,r)?r.__staleWhileFetching:r;if(i===void 0)return;let a={value:i};if(n(this,q)&&n(this,re)){let s=n(this,q)[t],c=n(this,re)[t];if(s&&c){let u=s-(Se.now()-c);a.ttl=u,a.start=Date.now();}}return n(this,te)&&(a.size=n(this,te)[t]),a}dump(){let e=[];for(let t of f(this,p,ue).call(this,{allowStale:true})){let r=n(this,v)[t],i=n(this,T)[t],a=f(this,p,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||r===void 0)continue;let s={value:a};if(n(this,q)&&n(this,re)){s.ttl=n(this,q)[t];let c=Se.now()-n(this,re)[t];s.start=Math.floor(Date.now()-c);}n(this,te)&&(s.size=n(this,te)[t]),e.unshift([r,s]);}return e}load(e){this.clear();for(let[t,r]of e){if(r.start){let i=Date.now()-r.start;r.start=Se.now()-i;}this.set(t,r.value,r);}}set(e,t,r={}){var M,N,P;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:c=this.sizeCalculation,status:u}=r,{noUpdateTTL:m=this.noUpdateTTL}=r,d=n(this,Ae).call(this,e,t,r.size||0,c);if(this.maxEntrySize&&d>this.maxEntrySize)return u&&(u.set="miss",u.maxEntrySizeExceeded=true),f(this,p,he).call(this,e,"set"),this;let _=n(this,Y)===0?void 0:n(this,U).get(e);if(_===void 0)_=n(this,Y)===0?n(this,V):n(this,ee).length!==0?n(this,ee).pop():n(this,Y)===n(this,X)?f(this,p,Pe).call(this,false):n(this,Y),n(this,v)[_]=e,n(this,T)[_]=t,n(this,U).set(e,_),n(this,H)[n(this,V)]=_,n(this,j)[_]=n(this,V),y(this,V,_),Ne(this,Y)._++,n(this,_e).call(this,_,d,u),u&&(u.set="add"),m=false;else {f(this,p,Oe).call(this,_);let O=n(this,T)[_];if(t!==O){if(n(this,de)&&f(this,p,x).call(this,O)){O.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:E}=O;E!==void 0&&!s&&(n(this,ne)&&((M=n(this,Q))==null||M.call(this,E,e,"set")),n(this,W)&&n(this,F)?.push([E,e,"set"]));}else s||(n(this,ne)&&((N=n(this,Q))==null||N.call(this,O,e,"set")),n(this,W)&&n(this,F)?.push([O,e,"set"]));if(n(this,ye).call(this,_),n(this,_e).call(this,_,d,u),n(this,T)[_]=t,u){u.set="replace";let E=O&&f(this,p,x).call(this,O)?O.__staleWhileFetching:O;E!==void 0&&(u.oldValue=E);}}else u&&(u.set="update");}if(i!==0&&!n(this,q)&&f(this,p,je).call(this),n(this,q)&&(m||n(this,we).call(this,_,i,a),u&&n(this,ae).call(this,u,_)),!s&&n(this,W)&&n(this,F)){let O=n(this,F),E;for(;E=O?.shift();)(P=n(this,J))==null||P.call(this,...E);}return this}pop(){var e;try{for(;n(this,Y);){let t=n(this,T)[n(this,G)];if(f(this,p,Pe).call(this,!0),f(this,p,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(n(this,W)&&n(this,F)){let t=n(this,F),r;for(;r=t?.shift();)(e=n(this,J))==null||e.call(this,...r);}}}has(e,t={}){let{updateAgeOnHas:r=this.updateAgeOnHas,status:i}=t,a=n(this,U).get(e);if(a!==void 0){let s=n(this,T)[a];if(f(this,p,x).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(n(this,$).call(this,a))i&&(i.has="stale",n(this,ae).call(this,i,a));else return r&&n(this,be).call(this,a),i&&(i.has="hit",n(this,ae).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:r=this.allowStale}=t,i=n(this,U).get(e);if(i===void 0||!r&&n(this,$).call(this,i))return;let a=n(this,T)[i];return f(this,p,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:c=this.noDisposeOnSet,size:u=0,sizeCalculation:m=this.sizeCalculation,noUpdateTTL:d=this.noUpdateTTL,noDeleteOnFetchRejection:_=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:O,forceRefresh:E=false,status:l,signal:h}=t;if(!n(this,de))return l&&(l.fetch="get"),this.get(e,{allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let C={allowStale:r,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:s,noDisposeOnSet:c,size:u,sizeCalculation:m,noUpdateTTL:d,noDeleteOnFetchRejection:_,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,status:l,signal:h},L=n(this,U).get(e);if(L===void 0){l&&(l.fetch="miss");let A=f(this,p,De).call(this,e,L,C,O);return A.__returned=A}else {let A=n(this,T)[L];if(f(this,p,x).call(this,A)){let Re=r&&A.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",Re&&(l.returnedStale=true)),Re?A.__staleWhileFetching:A.__returned=A}let D=n(this,$).call(this,L);if(!E&&!D)return l&&(l.fetch="hit"),f(this,p,Oe).call(this,L),i&&n(this,be).call(this,L),l&&n(this,ae).call(this,l,L),A;let k=f(this,p,De).call(this,e,L,C,O),le=k.__staleWhileFetching!==void 0&&r;return l&&(l.fetch=D?"stale":"refresh",le&&D&&(l.returnedStale=true)),le?k.__staleWhileFetching:k.__returned=k}}async forceFetch(e,t={}){let r=await this.fetch(e,t);if(r===void 0)throw new Error("fetch() returned undefined");return r}memo(e,t={}){let r=n(this,Te);if(!r)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...s}=t,c=this.get(e,s);if(!a&&c!==void 0)return c;let u=r(e,c,{options:s,context:i});return this.set(e,u,s),u}get(e,t={}){let{allowStale:r=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:s}=t,c=n(this,U).get(e);if(c!==void 0){let u=n(this,T)[c],m=f(this,p,x).call(this,u);return s&&n(this,ae).call(this,s,c),n(this,$).call(this,c)?(s&&(s.get="stale"),m?(s&&r&&u.__staleWhileFetching!==void 0&&(s.returnedStale=true),r?u.__staleWhileFetching:void 0):(a||f(this,p,he).call(this,e,"expire"),s&&r&&(s.returnedStale=true),r?u:void 0)):(s&&(s.get="hit"),m?u.__staleWhileFetching:(f(this,p,Oe).call(this,c),i&&n(this,be).call(this,c),u))}else s&&(s.get="miss");}delete(e){return f(this,p,he).call(this,e,"delete")}clear(){return f(this,p,ke).call(this,"delete")}};X=new WeakMap,B=new WeakMap,Q=new WeakMap,J=new WeakMap,Le=new WeakMap,Te=new WeakMap,Y=new WeakMap,Z=new WeakMap,U=new WeakMap,v=new WeakMap,T=new WeakMap,H=new WeakMap,j=new WeakMap,G=new WeakMap,V=new WeakMap,ee=new WeakMap,F=new WeakMap,te=new WeakMap,re=new WeakMap,q=new WeakMap,ne=new WeakMap,de=new WeakMap,W=new WeakMap,p=new WeakSet,je=function(){let e=new me(n(this,X)),t=new me(n(this,X));y(this,q,e),y(this,re,t),y(this,we,(a,s,c=Se.now())=>{if(t[a]=s!==0?c:0,e[a]=s,s!==0&&this.ttlAutopurge){let u=setTimeout(()=>{n(this,$).call(this,a)&&f(this,p,he).call(this,n(this,v)[a],"expire");},s+1);u.unref&&u.unref();}}),y(this,be,a=>{t[a]=e[a]!==0?Se.now():0;}),y(this,ae,(a,s)=>{if(e[s]){let c=e[s],u=t[s];if(!c||!u)return;a.ttl=c,a.start=u,a.now=r||i();let m=a.now-u;a.remainingTTL=c-m;}});let r=0,i=()=>{let a=Se.now();if(this.ttlResolution>0){r=a;let s=setTimeout(()=>r=0,this.ttlResolution);s.unref&&s.unref();}return a};this.getRemainingTTL=a=>{let s=n(this,U).get(a);if(s===void 0)return 0;let c=e[s],u=t[s];if(!c||!u)return 1/0;let m=(r||i())-u;return c-m},y(this,$,a=>{let s=t[a],c=e[a];return !!c&&!!s&&(r||i())-s>c});},be=new WeakMap,ae=new WeakMap,we=new WeakMap,$=new WeakMap,at=function(){let e=new me(n(this,X));y(this,Z,0),y(this,te,e),y(this,ye,t=>{y(this,Z,n(this,Z)-e[t]),e[t]=0;}),y(this,Ae,(t,r,i,a)=>{if(f(this,p,x).call(this,r))return 0;if(!ce(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(r,t),!ce(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,_e,(t,r,i)=>{if(e[t]=r,n(this,B)){let a=n(this,B)-e[t];for(;n(this,Z)>a;)f(this,p,Pe).call(this,true);}y(this,Z,n(this,Z)+e[t]),i&&(i.entrySize=r,i.totalCalculatedSize=n(this,Z));});},ye=new WeakMap,_e=new WeakMap,Ae=new WeakMap,ue=function*({allowStale:e=this.allowStale}={}){if(n(this,Y))for(let t=n(this,V);!(!f(this,p,qe).call(this,t)||((e||!n(this,$).call(this,t))&&(yield t),t===n(this,G)));)t=n(this,j)[t];},pe=function*({allowStale:e=this.allowStale}={}){if(n(this,Y))for(let t=n(this,G);!(!f(this,p,qe).call(this,t)||((e||!n(this,$).call(this,t))&&(yield t),t===n(this,V)));)t=n(this,H)[t];},qe=function(e){return e!==void 0&&n(this,U).get(n(this,v)[e])===e},Pe=function(e){var a;let t=n(this,G),r=n(this,v)[t],i=n(this,T)[t];return n(this,de)&&f(this,p,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(n(this,ne)||n(this,W))&&(n(this,ne)&&((a=n(this,Q))==null||a.call(this,i,r,"evict")),n(this,W)&&n(this,F)?.push([i,r,"evict"])),n(this,ye).call(this,t),e&&(n(this,v)[t]=void 0,n(this,T)[t]=void 0,n(this,ee).push(t)),n(this,Y)===1?(y(this,G,y(this,V,0)),n(this,ee).length=0):y(this,G,n(this,H)[t]),n(this,U).delete(r),Ne(this,Y)._--,t},De=function(e,t,r,i){let a=t===void 0?void 0:n(this,T)[t];if(f(this,p,x).call(this,a))return a;let s=new Ue,{signal:c}=r;c?.addEventListener("abort",()=>s.abort(c.reason),{signal:s.signal});let u={signal:s.signal,options:r,context:i},m=(O,E=false)=>{let{aborted:l}=s.signal,h=r.ignoreFetchAbort&&O!==void 0;if(r.status&&(l&&!E?(r.status.fetchAborted=true,r.status.fetchError=s.signal.reason,h&&(r.status.fetchAbortIgnored=true)):r.status.fetchResolved=true),l&&!h&&!E)return _(s.signal.reason);let C=N;return n(this,T)[t]===N&&(O===void 0?C.__staleWhileFetching?n(this,T)[t]=C.__staleWhileFetching:f(this,p,he).call(this,e,"fetch"):(r.status&&(r.status.fetchUpdated=true),this.set(e,O,u.options))),O},d=O=>(r.status&&(r.status.fetchRejected=true,r.status.fetchError=O),_(O)),_=O=>{let{aborted:E}=s.signal,l=E&&r.allowStaleOnFetchAbort,h=l||r.allowStaleOnFetchRejection,C=h||r.noDeleteOnFetchRejection,L=N;if(n(this,T)[t]===N&&(!C||L.__staleWhileFetching===void 0?f(this,p,he).call(this,e,"fetch"):l||(n(this,T)[t]=L.__staleWhileFetching)),h)return r.status&&L.__staleWhileFetching!==void 0&&(r.status.returnedStale=true),L.__staleWhileFetching;if(L.__returned===L)throw O},M=(O,E)=>{var h;let l=(h=n(this,Le))==null?void 0:h.call(this,e,a,u);l&&l instanceof Promise&&l.then(C=>O(C===void 0?void 0:C),E),s.signal.addEventListener("abort",()=>{(!r.ignoreFetchAbort||r.allowStaleOnFetchAbort)&&(O(void 0),r.allowStaleOnFetchAbort&&(O=C=>m(C,true)));});};r.status&&(r.status.fetchDispatched=true);let N=new Promise(M).then(m,d),P=Object.assign(N,{__abortController:s,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,P,{...u.options,status:void 0}),t=n(this,U).get(e)):n(this,T)[t]=P,P},x=function(e){if(!n(this,de))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ue},$e=function(e,t){n(this,j)[t]=e,n(this,H)[e]=t;},Oe=function(e){e!==n(this,V)&&(e===n(this,G)?y(this,G,n(this,H)[e]):f(this,p,$e).call(this,n(this,j)[e],n(this,H)[e]),f(this,p,$e).call(this,n(this,V),e),y(this,V,e));},he=function(e,t){var i,a;let r=false;if(n(this,Y)!==0){let s=n(this,U).get(e);if(s!==void 0)if(r=true,n(this,Y)===1)f(this,p,ke).call(this,t);else {n(this,ye).call(this,s);let c=n(this,T)[s];if(f(this,p,x).call(this,c)?c.__abortController.abort(new Error("deleted")):(n(this,ne)||n(this,W))&&(n(this,ne)&&((i=n(this,Q))==null||i.call(this,c,e,t)),n(this,W)&&n(this,F)?.push([c,e,t])),n(this,U).delete(e),n(this,v)[s]=void 0,n(this,T)[s]=void 0,s===n(this,V))y(this,V,n(this,j)[s]);else if(s===n(this,G))y(this,G,n(this,H)[s]);else {let u=n(this,j)[s];n(this,H)[u]=n(this,H)[s];let m=n(this,H)[s];n(this,j)[m]=n(this,j)[s];}Ne(this,Y)._--,n(this,ee).push(s);}}if(n(this,W)&&n(this,F)?.length){let s=n(this,F),c;for(;c=s?.shift();)(a=n(this,J))==null||a.call(this,...c);}return r},ke=function(e){var t,r;for(let i of f(this,p,pe).call(this,{allowStale:true})){let a=n(this,T)[i];if(f(this,p,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let s=n(this,v)[i];n(this,ne)&&((t=n(this,Q))==null||t.call(this,a,s,e)),n(this,W)&&n(this,F)?.push([a,s,e]);}}if(n(this,U).clear(),n(this,T).fill(void 0),n(this,v).fill(void 0),n(this,q)&&n(this,re)&&(n(this,q).fill(0),n(this,re).fill(0)),n(this,te)&&n(this,te).fill(0),y(this,G,0),y(this,V,0),n(this,ee).length=0,y(this,Z,0),y(this,Y,0),n(this,W)&&n(this,F)){let i=n(this,F),a;for(;a=i?.shift();)(r=n(this,J))==null||r.call(this,...a);}};var Ye=Xe;var xe=class{cache;map=new Map;constructor(e){this.cache=new Ye({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 Ce=new xe({cacheSize:10}),st;(s=>{function o(c){let u=Ce.get(c);if(!u){g.error(`Label "${c}" not found`);return}return u}s.get=o;function e(...c){for(let u of c)Ce.set(u.id,u);}s.add=e;function t(){return Array.from(Ce.values())}s.values=t;function r(c){return Ce.has(c)}s.has=r;function i(){return Array.from(Ce.keys())}s.keys=i;function a(){Ce.clear();}s.clear=a;})(st||={});var ie=st;function se(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 r=`${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",c=core.GameUnifier.getVariable(R,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return c[i]||(c[i]={}),(!c[i][r]||c[i][r].stepSha1!==s)&&(c[i][r]={stepSha1:s}),c[i][r]}static setCurrentStepTimesCounterData(e="",t){let r=o.currentLabelStepIndex,i=r+e,a=o.currentLabelId;if(!a||r===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,r=o.getCurrentStepTimesCounterData(e);if(!r)return g.error("getCurrentStepTimesCounter obj is null"),0;let i=r.stepCounters||[];return i.find(s=>s===t)||(i.push(t),r.stepCounters=i,o.setCurrentStepTimesCounterData(e,r)),i.length}static getRandomNumber(e,t,r={}){let i=r.nestedId||"";if(r.onceOnly||false){let s=o.getCurrentStepTimesCounterData(i);if(!s)return;let c=s.usedRandomNumbers||{},u=Array.from({length:t-e+1},(_,M)=>M+e).filter(_=>!c[`${e}-${t}`]?.includes(_));if(u.length===0)return;let m=Math.floor(Math.random()*u.length),d=u[m];return c[`${e}-${t}`]||(c[`${e}-${t}`]=[]),c[`${e}-${t}`].push(d),s.usedRandomNumbers=c,o.setCurrentStepTimesCounterData(i,s),d}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=o.currentLabelStepIndex,r=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][r]={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 se(o._openedLabels)}static set openedLabels(e){o._openedLabels=se(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return se(o._originalOpenedLabels)}static set originalOpenedLabels(e){o._originalOpenedLabels=se(e);}static get _currentLabel(){if(o.currentLabelId)return ie.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 r=o.allOpenedLabels,i=o.allOpenedLabels[e]?.biggestStep||0,a=o.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(r[e]={biggestStep:t,openCount:a},o.allOpenedLabels=r);}static addChoicesMade(e,t,r,i){let a=o.allChoicesMade,s=a.findIndex(c=>c.labelId===e&&c.stepIndex===t&&c.choiceIndex===i&&c.stepSha1===r);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:r,madeTimes:1}):a[s].madeTimes++,o.allChoicesMade=a;}static pushNewLabel(e){if(!ie.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);o._openedLabels.push({label:e,currentStepIndex:0});let r=o.allOpenedLabels,i=o.allOpenedLabels[e]?.biggestStep||0,a=o.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:i,openCount:a+1},o.allOpenedLabels=r;}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 r=[];return o.onLoadingLabel&&e===0&&r.push(o.onLoadingLabel(e,t)),o._onStepStart&&r.push(o._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd;static onLabelStarting;static onLabelClosing};var Me=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return b.getRandomNumber(e,t,r)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}async addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:i}=t,a,s,c,u=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&&(c=core.GameUnifier.getVariable(R,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let m=b.openedLabels,d={currentLabel:b.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:r,inputValue:c,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:u,openedLabels:m};b.originalOpenedLabels=m,await core.GameUnifier.addHistoryItem(d,{ignoreSameStep:i}),b.lastHistoryStep=d,b.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=b.currentLabelStepIndex,r=this.currentLabel;if(!(t===null||!r))return b.allChoicesMade.filter(i=>i.labelId===r.id&&i.stepIndex===t&&i.stepSha1===e).map(i=>i.choiceIndex)}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);}labels={get opened(){return b.openedLabels},get current(){return b._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=ie.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 r=t.getStepSha(e);return r||(g.warn("stepSha not found, setting to ERROR"),r="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===r)}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}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e){let t=e?.showWarn||false,r=this.choicesValue;return r&&r.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||this.openedLabels.length===0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),b.onStepStart&&r.push(b.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),b.onStepEnd&&r.push(b.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=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(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&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:r}=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(d){g.error("Error running onStepStart",d),this.onStepError&&await this.onStepError(d,e);return}let s=a.getStepById(i);if(!s){g.error("step not found");return}let c=a.getStepSha(i);c||(g.warn("stepSha not found, setting to ERROR"),c="error");let u,m;try{u=await s(e,{labelId:a.id});}catch(d){g.error("Error running step",d),m=d;}try{let d=this.choicesValue;if(d?.length===1&&d[0].autoSelect){let _=d[0];u=await this.selectChoice(_,e);}}catch(d){g.error("Error auto-selecting choice",d),m||(m=d);}try{let d=b.lastHistoryStep;r!==void 0&&d&&(c=d.stepSha1,c||(g.warn("stepSha not found, setting to ERROR"),c="error"),b.addChoicesMade(d.currentLabel||"error",typeof d.labelStepIndex=="number"?d.labelStepIndex:-1,d.stepSha1||"error",r),b.choiceMadeTemp=r);}catch(d){g.warn("Error adding choice made to history",d);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),await this.addStepHistory(c,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(d){g.warn("Error adding step to history",d);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(d){g.warn("Error running onStepEnd",d);}return m&&this.onStepError&&await this.onStepError(m,e),u}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e,t)}else {if(this.openedLabels.length===0)return;g.error("currentLabelId not found");}}async closeLabel(e,t,r){let i=async()=>(this.closeCurrentLabel(),await this.continue(t,r));return b.onLabelClosing?await b.onLabelClosing(e,t,i):await i()}async startLabel(e,t,r){let i=async()=>{let{choiceMade:a,closeCurrentLabel:s,type:c}=r;s&&this.openedLabels.length>0&&this.closeCurrentLabel(),core.GameUnifier.runningStepsCount++;let u;try{let m=ie.get(e);if(!m)throw new core.PixiError("unregistered_element",`Label ${e} not found`);b.pushNewLabel(m.id),u=await this.runCurrentStep(t,{choiceMade:a});}catch(m){throw g.error(`Error ${c} label`,m),m}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||u};return b.onLabelStarting?await b.onLabelStarting(e,t,r,i):await i()}async call(e,t,r){let{choiceMade:i}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,type:"calling"})}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);let{choiceMade:i}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choicesValue=void 0;let r=e.type;switch(r){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 ${r} not found`),new core.PixiError("invalid_usage",`Type ${r} 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 r;return typeof e.choiceIndex=="number"&&(r=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(r){g.error("Error in onError handler",r);}}}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 r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,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,se({...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 choicesValue(){let e=core.GameUnifier.getVariable(R,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,s)=>({...a,choiceIndex:s})),i=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,s)=>a.oneTime&&i?.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choicesValue(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,se(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")}}choicesObj=(()=>{let e=this,t={select:(r,i)=>e.selectChoice(r,i)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:r=>{e.choicesValue=r;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}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);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,r)=>e.requestInput(t,r),removeRequest:()=>e.removeInputRequest()}})();clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:se(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let i=[],a=ie.get(r.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(r){g.error("Error running onLoadingLabel",r);}}catch(r){g.error("Error importing data",r);}}};function Rt(o,e,t,r){let i=typeof e=="string"?e:e.id;return {...r,label:i,props:t,text:o,type:r?.type||"call"}}var ot="close";function Ot(o,e){return {...e,type:ot,text:o}}var ht=Tt(pt());var Ee=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 Ie=class extends Ee{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){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&g.warn("stepSha not found, setting to ERROR"),"error";try{return (0,ht.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(r){return g.warn("stepSha not found, setting to ERROR",r),"error"}}};function dt(o,e,t){let r=new Ie(o,e,t);return ie.add(r),r}var mr=new Me;
|
|
2
|
+
exports.Label=Ie;exports.LabelAbstract=Ee;exports.NarrationManagerStatic=b;exports.RegisteredLabels=ie;exports.narration=mr;exports.newChoiceOption=Rt;exports.newCloseChoiceOption=Ot;exports.newLabel=dt;
|
package/dist/narration.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageElementType, StorageObjectType } from './storage.cjs';
|
|
2
2
|
import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-WGB6nA4N.cjs';
|
|
3
3
|
export { P as PixivnLabelIds } from './HistoryStep-WGB6nA4N.cjs';
|
|
4
4
|
import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
|
|
@@ -881,6 +881,11 @@ declare class NarrationManagerStatic {
|
|
|
881
881
|
static onLabelClosing?: (labelId: LabelIdType, props: StepLabelPropsType, defaultClose: () => Promise<StepLabelResultType>) => StepLabelResultType | Promise<StepLabelResultType>;
|
|
882
882
|
}
|
|
883
883
|
|
|
884
|
+
/**
|
|
885
|
+
* The global narration manager instance. It runs the story flow: labels, steps, dialogues,
|
|
886
|
+
* choices, and the current narration state used for save/restore.
|
|
887
|
+
*/
|
|
884
888
|
declare const narration: NarrationManagerInterface;
|
|
885
889
|
|
|
886
|
-
export {
|
|
890
|
+
export { DialogueInterface, HistoryStep, Label, LabelAbstract, LabelIdType, LabelRunModeType, NarrationManagerStatic, OpenedLabel, RegisteredLabels, StepLabelPropsType, StepLabelResultType, StepLabelType, narration, newChoiceOption, newCloseChoiceOption, newLabel };
|
|
891
|
+
export type { ChoiceInterface, ChoiceOptionInterface, CloseChoiceOptionInterface, InputInfo, LabelProps, LabelSteps, NarrationChoicesInterface, NarrationGameState, NarrationInputInterface, NarrationLabelsInterface, NarrationManagerInterface, NarrationQueriesInterface, StepLabelProps, StepLabelResult, StoredChoiceInterface, StoredIndexedChoiceInterface };
|
package/dist/narration.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { StorageElementType, StorageObjectType } from './storage.js';
|
|
2
2
|
import { L as LabelIdType, D as DialogueInterface, H as HistoryStep } from './HistoryStep-WGB6nA4N.js';
|
|
3
3
|
export { P as PixivnLabelIds } from './HistoryStep-WGB6nA4N.js';
|
|
4
4
|
import { ChoiceInterface as ChoiceInterface$1 } from '@drincs/pixi-vn';
|
|
@@ -881,6 +881,11 @@ declare class NarrationManagerStatic {
|
|
|
881
881
|
static onLabelClosing?: (labelId: LabelIdType, props: StepLabelPropsType, defaultClose: () => Promise<StepLabelResultType>) => StepLabelResultType | Promise<StepLabelResultType>;
|
|
882
882
|
}
|
|
883
883
|
|
|
884
|
+
/**
|
|
885
|
+
* The global narration manager instance. It runs the story flow: labels, steps, dialogues,
|
|
886
|
+
* choices, and the current narration state used for save/restore.
|
|
887
|
+
*/
|
|
884
888
|
declare const narration: NarrationManagerInterface;
|
|
885
889
|
|
|
886
|
-
export {
|
|
890
|
+
export { DialogueInterface, HistoryStep, Label, LabelAbstract, LabelIdType, LabelRunModeType, NarrationManagerStatic, OpenedLabel, RegisteredLabels, StepLabelPropsType, StepLabelResultType, StepLabelType, narration, newChoiceOption, newCloseChoiceOption, newLabel };
|
|
891
|
+
export type { ChoiceInterface, ChoiceOptionInterface, CloseChoiceOptionInterface, InputInfo, LabelProps, LabelSteps, NarrationChoicesInterface, NarrationGameState, NarrationInputInterface, NarrationLabelsInterface, NarrationManagerInterface, NarrationQueriesInterface, StepLabelProps, StepLabelResult, StoredChoiceInterface, StoredIndexedChoiceInterface };
|
package/dist/narration.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-5MVDNAT4.mjs';import {k,m}from'./chunk-HD353M4B.mjs';import {a as a$1}from'./chunk-S7HZUIEI.mjs';import {d,c,e}from'./chunk-AW5XWF24.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var h=new d({cacheSize:10}),_;(d=>{function i(c){let f=h.get(c);if(!f){e.error(`Label "${c}" not found`);return}return f}d.get=i;function e$1(...c){for(let f of c)h.set(f.id,f);}d.add=e$1;function t(){return Array.from(h.values())}d.values=t;function r(c){return h.has(c)}d.has=r;function n(){return Array.from(h.keys())}d.keys=n;function a(){h.clear();}d.clear=a;})(_||={});var y=_;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(k,m.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(k,m.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=i.currentLabelId,a=i._currentLabel;if(!n||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let d=a.getStepSha(t)||"error",c=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return c[n]||(c[n]={}),(!c[n][r]||c[n][r].stepSha1!==d)&&(c[n][r]={stepSha1:d}),c[n][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let d=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};d[a]||(d[a]={}),d[a][n]=t,GameUnifier.setVariable(k,m.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 c=d.usedRandomNumbers||{},f=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!c[`${e}-${t}`]?.includes(E));if(f.length===0)return;let L=Math.floor(Math.random()*f.length),b=f[L];return c[`${e}-${t}`]||(c[`${e}-${t}`]=[]),c[`${e}-${t}`].push(b),d.usedRandomNumbers=c,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=i.currentLabelId;if(!n||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n]||(a[n]={}),a[n][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(k,m.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(k,m.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return a$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=a$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return a$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=a$1(e);}static get _currentLabel(){if(i.currentLabelId)return y.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(c=>c.labelId===e&&c.stepIndex===t&&c.choiceIndex===n&&c.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(!y.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;static onLabelStarting;static onLabelClosing};var g=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}async addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n}=t,a,d,c,f=GameUnifier.getVariable(k,m.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(k,m.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(k,m.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(d=GameUnifier.getVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(c=GameUnifier.getVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:d,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:c,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:f,openedLabels:L};o.originalOpenedLabels=L,await GameUnifier.addHistoryItem(b,{ignoreSameStep:n}),o.lastHistoryStep=b,o.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=o.currentLabelStepIndex,r=this.currentLabel;if(!(t===null||!r))return o.allChoicesMade.filter(n=>n.labelId===r.id&&n.stepIndex===t&&n.stepSha1===e).map(n=>n.choiceIndex)}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);}labels={get opened(){return o.openedLabels},get current(){return o._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=y.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}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choicesValue;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||this.openedLabels.length===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 c=a.getStepSha(n);c||(e.warn("stepSha not found, setting to ERROR"),c="error");let f,L;try{f=await d(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),L=b;}try{let b=this.choicesValue;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),L||(L=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(c=b.stepSha1,c||(e.warn("stepSha not found, setting to ERROR"),c="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),await this.addStepHistory(c,{...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),f}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e$1,t)}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async closeLabel(e,t,r){let n=async()=>(this.closeCurrentLabel(),await this.continue(t,r));return o.onLabelClosing?await o.onLabelClosing(e,t,n):await n()}async startLabel(e$1,t,r){let n=async()=>{let{choiceMade:a,closeCurrentLabel:d,type:c}=r;d&&this.openedLabels.length>0&&this.closeCurrentLabel(),GameUnifier.runningStepsCount++;let f;try{let L=y.get(e$1);if(!L)throw new PixiError("unregistered_element",`Label ${e$1} not found`);o.pushNewLabel(L.id),f=await this.runCurrentStep(t,{choiceMade:a});}catch(L){throw e.error(`Error ${c} label`,L),L}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||f};return o.onLabelStarting?await o.onLabelStarting(e$1,t,r,n):await n()}async call(e,t,r){let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,type:"calling"})}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e$1,t){this.choicesValue=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(k,m.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(k,m.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(k,m.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(k,m.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY,a$1({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(k,m.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 choicesValue(){let e=GameUnifier.getVariable(k,m.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 choicesValue(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,a$1(e$1)),GameUnifier.setVariable(k,m.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")}}choicesObj=(()=>{let e=this,t={select:(r,n)=>e.selectChoice(r,n)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:r=>{e.choicesValue=r;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return GameUnifier.getFlag(m.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(m.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,GameUnifier.setVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,r)=>e.requestInput(t,r),removeRequest:()=>e.removeInputRequest()}})();clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:a$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=y.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 T=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 T{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){let t=this.steps;if(e$1<0||e$1>=t.length)return typeof this._steps!="function"&&e.warn("stepSha not found, setting to ERROR"),"error";try{return (0,M.default)(t[e$1].toString().toLocaleLowerCase()).toString()}catch(r){return e.warn("stepSha not found, setting to ERROR",r),"error"}}};function x(i,e,t){let r=new I(i,e,t);return y.add(r),r}var fe=new g;
|
|
1
|
+
import {a}from'./chunk-WYGKBGMH.mjs';import {k,m}from'./chunk-HD353M4B.mjs';import {a as a$1}from'./chunk-A5FN4SNI.mjs';import {d,c,e}from'./chunk-B46NFIFC.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var h=new d({cacheSize:10}),_;(d=>{function i(c){let f=h.get(c);if(!f){e.error(`Label "${c}" not found`);return}return f}d.get=i;function e$1(...c){for(let f of c)h.set(f.id,f);}d.add=e$1;function t(){return Array.from(h.values())}d.values=t;function r(c){return h.has(c)}d.has=r;function n(){return Array.from(h.keys())}d.keys=n;function a(){h.clear();}d.clear=a;})(_||={});var y=_;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(k,m.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(k,m.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=i.currentLabelId,a=i._currentLabel;if(!n||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let d=a.getStepSha(t)||"error",c=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return c[n]||(c[n]={}),(!c[n][r]||c[n][r].stepSha1!==d)&&(c[n][r]={stepSha1:d}),c[n][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let d=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};d[a]||(d[a]={}),d[a][n]=t,GameUnifier.setVariable(k,m.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 c=d.usedRandomNumbers||{},f=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!c[`${e}-${t}`]?.includes(E));if(f.length===0)return;let L=Math.floor(Math.random()*f.length),b=f[L];return c[`${e}-${t}`]||(c[`${e}-${t}`]=[]),c[`${e}-${t}`].push(b),d.usedRandomNumbers=c,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=i.currentLabelId;if(!n||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n]||(a[n]={}),a[n][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(k,m.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(k,m.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return a$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=a$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return a$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=a$1(e);}static get _currentLabel(){if(i.currentLabelId)return y.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(c=>c.labelId===e&&c.stepIndex===t&&c.choiceIndex===n&&c.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(!y.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;static onLabelStarting;static onLabelClosing};var g=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}async addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n}=t,a,d,c,f=GameUnifier.getVariable(k,m.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(k,m.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(k,m.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(d=GameUnifier.getVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(c=GameUnifier.getVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:d,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:c,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:f,openedLabels:L};o.originalOpenedLabels=L,await GameUnifier.addHistoryItem(b,{ignoreSameStep:n}),o.lastHistoryStep=b,o.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=o.currentLabelStepIndex,r=this.currentLabel;if(!(t===null||!r))return o.allChoicesMade.filter(n=>n.labelId===r.id&&n.stepIndex===t&&n.stepSha1===e).map(n=>n.choiceIndex)}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);}labels={get opened(){return o.openedLabels},get current(){return o._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=y.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}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choicesValue;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||this.openedLabels.length===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 c=a.getStepSha(n);c||(e.warn("stepSha not found, setting to ERROR"),c="error");let f,L;try{f=await d(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),L=b;}try{let b=this.choicesValue;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),L||(L=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(c=b.stepSha1,c||(e.warn("stepSha not found, setting to ERROR"),c="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),await this.addStepHistory(c,{...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),f}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e$1,t)}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async closeLabel(e,t,r){let n=async()=>(this.closeCurrentLabel(),await this.continue(t,r));return o.onLabelClosing?await o.onLabelClosing(e,t,n):await n()}async startLabel(e$1,t,r){let n=async()=>{let{choiceMade:a,closeCurrentLabel:d,type:c}=r;d&&this.openedLabels.length>0&&this.closeCurrentLabel(),GameUnifier.runningStepsCount++;let f;try{let L=y.get(e$1);if(!L)throw new PixiError("unregistered_element",`Label ${e$1} not found`);o.pushNewLabel(L.id),f=await this.runCurrentStep(t,{choiceMade:a});}catch(L){throw e.error(`Error ${c} label`,L),L}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||f};return o.onLabelStarting?await o.onLabelStarting(e$1,t,r,n):await n()}async call(e,t,r){let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,type:"calling"})}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e$1,t){this.choicesValue=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(k,m.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(k,m.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(k,m.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(k,m.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY,a$1({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(k,m.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 choicesValue(){let e=GameUnifier.getVariable(k,m.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 choicesValue(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,a$1(e$1)),GameUnifier.setVariable(k,m.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")}}choicesObj=(()=>{let e=this,t={select:(r,n)=>e.selectChoice(r,n)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:r=>{e.choicesValue=r;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return GameUnifier.getFlag(m.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(m.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,GameUnifier.setVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,r)=>e.requestInput(t,r),removeRequest:()=>e.removeInputRequest()}})();clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:a$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=y.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 T=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 T{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){let t=this.steps;if(e$1<0||e$1>=t.length)return typeof this._steps!="function"&&e.warn("stepSha not found, setting to ERROR"),"error";try{return (0,M.default)(t[e$1].toString().toLocaleLowerCase()).toString()}catch(r){return e.warn("stepSha not found, setting to ERROR",r),"error"}}};function x(i,e,t){let r=new I(i,e,t);return y.add(r),r}var fe=new g;
|
|
2
2
|
export{I as Label,T as LabelAbstract,o as NarrationManagerStatic,y as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
|