@drincs/pixi-vn 1.4.2 → 1.4.4
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/dist/canvas.cjs +2 -2
- package/dist/canvas.mjs +1 -1
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/chunk-GFG3MDHE.mjs +1 -0
- package/dist/{chunk-IKZP57DP.mjs → chunk-TIA4D2N7.mjs} +1 -1
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/narration.cjs +1 -1
- package/dist/narration.mjs +1 -1
- package/dist/pixi.d.ts +3 -0
- package/dist/{pixi.js.mjs → pixi.js} +143 -143
- package/dist/storage.cjs +1 -1
- package/dist/storage.mjs +1 -1
- package/package.json +6 -6
- package/dist/chunk-YDXQLPAR.mjs +0 -1
- package/dist/pixi.js.cjs +0 -3395
- package/dist/pixi.js.d.cts +0 -1
- package/dist/pixi.js.d.ts +0 -1
package/dist/narration.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var mt=Object.create;var Ke=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var tt=u=>{throw TypeError(u)};var Lt=(u,e,t)=>e in u?Ke(u,e,{enumerable:true,configurable:true,writable:true,value:t}):u[e]=t;var We=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});var rt=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports);var Tt=(u,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of gt(e))!_t.call(u,i)&&i!==t&&Ke(u,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return u};var Et=(u,e,t)=>(t=u!=null?mt(yt(u)):{},Tt(Ke(t,"default",{value:u,enumerable:true}),u));var E=(u,e,t)=>Lt(u,typeof e!="symbol"?e+"":e,t),Be=(u,e,t)=>e.has(u)||tt("Cannot "+t);var r=(u,e,t)=>(Be(u,e,"read from private field"),t?t.call(u):e.get(u)),R=(u,e,t)=>e.has(u)?tt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,t),S=(u,e,t,n)=>(Be(u,e,"write to private field"),e.set(u,t),t),f=(u,e,t)=>(Be(u,e,"access private method"),t);var Ue=(u,e,t,n)=>({set _(i){S(u,e,i);},get _(){return r(u,e,n)}});var ct=rt((Ge,ht)=>{(function(u,e){typeof Ge=="object"?ht.exports=Ge=e():typeof define=="function"&&define.amd?define([],e):u.CryptoJS=e();})(Ge,function(){var u=u||(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 We=="function")try{n=We("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 o(){}return function(d){var w;return o.prototype=d,w=new o,o.prototype=null,w}})(),s={},l=s.lib={},c=l.Base=(function(){return {extend:function(o){var d=a(this);return o&&d.mixIn(o),(!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 o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var d in o)o.hasOwnProperty(d)&&(this[d]=o[d]);o.hasOwnProperty("toString")&&(this.toString=o.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=l.WordArray=c.extend({init:function(o,d){o=this.words=o||[],d!=t?this.sigBytes=d:this.sigBytes=o.length*4;},toString:function(o){return (o||C).stringify(this)},concat:function(o){var d=this.words,w=o.words,L=this.sigBytes,x=o.sigBytes;if(this.clamp(),L%4)for(var U=0;U<x;U++){var oe=w[U>>>2]>>>24-U%4*8&255;d[L+U>>>2]|=oe<<24-(L+U)%4*8;}else for(var H=0;H<x;H+=4)d[L+H>>>2]=w[H>>>2];return this.sigBytes+=x,this},clamp:function(){var o=this.words,d=this.sigBytes;o[d>>>2]&=4294967295<<32-d%4*8,o.length=e.ceil(d/4);},clone:function(){var o=c.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var d=[],w=0;w<o;w+=4)d.push(i());return new y.init(d,o)}}),p=s.enc={},C=p.Hex={stringify:function(o){for(var d=o.words,w=o.sigBytes,L=[],x=0;x<w;x++){var U=d[x>>>2]>>>24-x%4*8&255;L.push((U>>>4).toString(16)),L.push((U&15).toString(16));}return L.join("")},parse:function(o){for(var d=o.length,w=[],L=0;L<d;L+=2)w[L>>>3]|=parseInt(o.substr(L,2),16)<<24-L%8*4;return new y.init(w,d/2)}},N=p.Latin1={stringify:function(o){for(var d=o.words,w=o.sigBytes,L=[],x=0;x<w;x++){var U=d[x>>>2]>>>24-x%4*8&255;L.push(String.fromCharCode(U));}return L.join("")},parse:function(o){for(var d=o.length,w=[],L=0;L<d;L++)w[L>>>2]|=(o.charCodeAt(L)&255)<<24-L%4*8;return new y.init(w,d)}},P=p.Utf8={stringify:function(o){try{return decodeURIComponent(escape(N.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return N.parse(unescape(encodeURIComponent(o)))}},D=l.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(o){typeof o=="string"&&(o=P.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes;},_process:function(o){var d,w=this._data,L=w.words,x=w.sigBytes,U=this.blockSize,oe=U*4,H=x/oe;o?H=e.ceil(H):H=e.max((H|0)-this._minBufferSize,0);var J=H*U,ue=e.min(J*4,x);if(J){for(var De=0;De<J;De+=U)this._doProcessBlock(L,De);d=L.splice(0,J),w.sigBytes-=ue;}return new y.init(d,ue)},clone:function(){var o=c.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});l.Hasher=D.extend({cfg:c.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset();},reset:function(){D.reset.call(this),this._doReset();},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(o){return function(d,w){return new o.init(w).finalize(d)}},_createHmacHelper:function(o){return function(d,w){return new I.HMAC.init(o,w).finalize(d)}}});var I=s.algo={};return s})(Math);return u});});var pt=rt((He,dt)=>{(function(u,e){typeof He=="object"?dt.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(u.CryptoJS);})(He,function(u){return (function(){var e=u,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,s=[],l=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,y){for(var p=this._hash.words,C=p[0],N=p[1],P=p[2],D=p[3],v=p[4],I=0;I<80;I++){if(I<16)s[I]=c[y+I]|0;else {var o=s[I-3]^s[I-8]^s[I-14]^s[I-16];s[I]=o<<1|o>>>31;}var d=(C<<5|C>>>27)+v+s[I];I<20?d+=(N&P|~N&D)+1518500249:I<40?d+=(N^P^D)+1859775393:I<60?d+=(N&P|N&D|P&D)-1894007588:d+=(N^P^D)-899497514,v=D,D=P,P=N<<30|N>>>2,N=C,C=d;}p[0]=p[0]+C|0,p[1]=p[1]+N|0,p[2]=p[2]+P|0,p[3]=p[3]+D|0,p[4]=p[4]+v|0;},_doFinalize:function(){var c=this._data,y=c.words,p=this._nDataBytes*8,C=c.sigBytes*8;return y[C>>>5]|=128<<24-C%32,y[(C+64>>>9<<4)+14]=Math.floor(p/4294967296),y[(C+64>>>9<<4)+15]=p,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(l),e.HmacSHA1=i._createHmacHelper(l);})(),u.SHA1});});var O={CURRENT_DIALOGUE_MEMORY_KEY:"___current_dialogue_memory___",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"___last_dialogue_added_in_step_memory___",CURRENT_MENU_OPTIONS_MEMORY_KEY:"___current_menu_options_memory___",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"___last_menu_options_added_in_step_memory___",CURRENT_INPUT_VALUE_MEMORY_KEY:"_input_value_",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"___last_input_added_in_step_memory___",CURRENT_INPUT_INFO_MEMORY_KEY:"___current_input_info_memory___",CHARACTER_CATEGORY_KEY:"___character___",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"___opened_labels_counter___",ALL_CHOICES_MADE_KEY:"___all_choices_made___",CURRENT_STEP_TIMES_COUNTER_KEY:"___current_step_times_counter___",LAST_STEP_GLUED:"___last_step_glued___"};var _;(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)))(_||(_={}));function le(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw _.error("Error creating exportable element",u,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,at=new Set,je=typeof process=="object"&&process?process:{},ot=(u,e,t,n)=>{typeof je.emitWarning=="function"?je.emitWarning(u,e,t,n):console.error(`[${t}] ${e}: ${u}`);},Ve=globalThis.AbortController,nt=globalThis.AbortSignal;if(typeof Ve>"u"){nt=class{constructor(){E(this,"onabort");E(this,"_onabort",[]);E(this,"reason");E(this,"aborted",false);}addEventListener(n,i){this._onabort.push(i);}},Ve=class{constructor(){E(this,"signal",new nt);e();}abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=true;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n);}}};let u=je.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,ot("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=u=>!at.has(u);var de=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),lt=u=>de(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Le:null:null,Le=class extends Array{constructor(e){super(e),this.fill(0);}},Te,Se=class Se{constructor(e,t){E(this,"heap");E(this,"length");if(!r(Se,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=lt(e);if(!t)return [];S(Se,Te,true);let n=new Se(e,t);return S(Se,Te,false),n}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};Te=new WeakMap,R(Se,Te,false);var $e=Se,it,st,X,B,Q,ge,Z,Ee,Ce,ee,F,te,Y,M,T,K,j,G,V,re,z,ne,ie,$,k,se,me,W,Ie,h,ke,ye,he,Me,q,ut,_e,we,Ne,pe,fe,qe,Ye,Fe,A,Xe,Ae,be,Je,Qe=class Qe{constructor(e){R(this,h);R(this,X);R(this,B);R(this,Q);R(this,ge);R(this,Z);R(this,Ee);R(this,Ce);R(this,ee);E(this,"ttl");E(this,"ttlResolution");E(this,"ttlAutopurge");E(this,"updateAgeOnGet");E(this,"updateAgeOnHas");E(this,"allowStale");E(this,"noDisposeOnSet");E(this,"noUpdateTTL");E(this,"maxEntrySize");E(this,"sizeCalculation");E(this,"noDeleteOnFetchRejection");E(this,"noDeleteOnStaleGet");E(this,"allowStaleOnFetchAbort");E(this,"allowStaleOnFetchRejection");E(this,"ignoreFetchAbort");R(this,F);R(this,te);R(this,Y);R(this,M);R(this,T);R(this,K);R(this,j);R(this,G);R(this,V);R(this,re);R(this,z);R(this,ne);R(this,ie);R(this,$);R(this,k);R(this,se);R(this,me);R(this,W);R(this,Ie);R(this,ye,()=>{});R(this,he,()=>{});R(this,Me,()=>{});R(this,q,()=>false);R(this,_e,e=>{});R(this,we,(e,t,n)=>{});R(this,Ne,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});E(this,it,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:s,updateAgeOnHas:l,allowStale:c,dispose:y,onInsert:p,disposeAfter:C,noDisposeOnSet:N,noUpdateTTL:P,maxSize:D=0,maxEntrySize:v=0,sizeCalculation:I,fetchMethod:o,memoMethod:d,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:L,allowStaleOnFetchRejection:x,allowStaleOnFetchAbort:U,ignoreFetchAbort:oe,perf:H}=e;if(H!==void 0&&typeof H?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,H??Ct),t!==0&&!de(t))throw new TypeError("max option must be a nonnegative integer");let J=t?lt(t):Array;if(!J)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,D),this.maxEntrySize=v||r(this,B),this.sizeCalculation=I,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),o!==void 0&&typeof o!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,Ee,o),S(this,me,!!o),S(this,Y,new Map),S(this,M,new Array(t).fill(void 0)),S(this,T,new Array(t).fill(void 0)),S(this,K,new J(t)),S(this,j,new J(t)),S(this,G,0),S(this,V,0),S(this,re,$e.create(t)),S(this,F,0),S(this,te,0),typeof y=="function"&&S(this,Q,y),typeof p=="function"&&S(this,ge,p),typeof C=="function"?(S(this,Z,C),S(this,z,[])):(S(this,Z,void 0),S(this,z,void 0)),S(this,se,!!r(this,Q)),S(this,Ie,!!r(this,ge)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!N,this.noUpdateTTL=!!P,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!x,this.allowStaleOnFetchAbort=!!U,this.ignoreFetchAbort=!!oe,this.maxEntrySize!==0){if(r(this,B)!==0&&!de(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!de(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,h,ut).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!L,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!l,this.ttlResolution=de(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!de(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,h,ke).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 ue="LRU_CACHE_UNBOUNDED";It(ue)&&(at.add(ue),ot("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ue,Qe));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,$),autopurgeTimers:r(e,k),sizes:r(e,ne),keyMap:r(e,Y),keyList:r(e,M),valList:r(e,T),next:r(e,K),prev:r(e,j),get head(){return r(e,G)},get tail(){return r(e,V)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,h,A).call(n,t)},backgroundFetch:(t,n,i,a)=>{var s;return f(s=e,h,Fe).call(s,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,h,Ae).call(n,t)},indexes:t=>{var n;return f(n=e,h,pe).call(n,t)},rindexes:t=>{var n;return f(n=e,h,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,F)}get fetchMethod(){return r(this,Ee)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,Q)}get onInsert(){return r(this,ge)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,Y).has(e)?1/0:0}*entries(){for(let e of f(this,h,pe).call(this))r(this,T)[e]!==void 0&&r(this,M)[e]!==void 0&&!f(this,h,A).call(this,r(this,T)[e])&&(yield [r(this,M)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,h,fe).call(this))r(this,T)[e]!==void 0&&r(this,M)[e]!==void 0&&!f(this,h,A).call(this,r(this,T)[e])&&(yield [r(this,M)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,h,pe).call(this)){let t=r(this,M)[e];t!==void 0&&!f(this,h,A).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,h,fe).call(this)){let t=r(this,M)[e];t!==void 0&&!f(this,h,A).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,h,pe).call(this))r(this,T)[e]!==void 0&&!f(this,h,A).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,h,fe).call(this))r(this,T)[e]!==void 0&&!f(this,h,A).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(st=Symbol.iterator,it=Symbol.toStringTag,st)](){return this.entries()}find(e,t={}){for(let n of f(this,h,pe).call(this)){let i=r(this,T)[n],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,M)[n],this))return this.get(r(this,M)[n],t)}}forEach(e,t=this){for(let n of f(this,h,pe).call(this)){let i=r(this,T)[n],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,M)[n],this);}}rforEach(e,t=this){for(let n of f(this,h,fe).call(this)){let i=r(this,T)[n],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,M)[n],this);}}purgeStale(){let e=false;for(let t of f(this,h,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,h,be).call(this,r(this,M)[t],"expire"),e=true);return e}info(e){let t=r(this,Y).get(e);if(t===void 0)return;let n=r(this,T)[t],i=f(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,$)&&r(this,ie)){let s=r(this,$)[t],l=r(this,ie)[t];if(s&&l){let c=s-(r(this,ee).now()-l);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,h,pe).call(this,{allowStale:true})){let n=r(this,M)[t],i=r(this,T)[t],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let s={value:a};if(r(this,$)&&r(this,ie)){s.ttl=r(this,$)[t];let l=r(this,ee).now()-r(this,ie)[t];s.start=Math.floor(Date.now()-l);}r(this,ne)&&(s.size=r(this,ne)[t]),e.unshift([n,s]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var N,P,D,v;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,p=r(this,Ne).call(this,e,t,n.size||0,l);if(this.maxEntrySize&&p>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),f(this,h,be).call(this,e,"set"),this;let C=r(this,F)===0?void 0:r(this,Y).get(e);if(C===void 0)C=r(this,F)===0?r(this,V):r(this,re).length!==0?r(this,re).pop():r(this,F)===r(this,X)?f(this,h,Ye).call(this,false):r(this,F),r(this,M)[C]=e,r(this,T)[C]=t,r(this,Y).set(e,C),r(this,K)[r(this,V)]=C,r(this,j)[C]=r(this,V),S(this,V,C),Ue(this,F)._++,r(this,we).call(this,C,p,c),c&&(c.set="add"),y=false,r(this,Ie)&&((N=r(this,ge))==null||N.call(this,t,e,"add"));else {f(this,h,Ae).call(this,C);let I=r(this,T)[C];if(t!==I){if(r(this,me)&&f(this,h,A).call(this,I)){I.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:o}=I;o!==void 0&&!s&&(r(this,se)&&((P=r(this,Q))==null||P.call(this,o,e,"set")),r(this,W)&&r(this,z)?.push([o,e,"set"]));}else s||(r(this,se)&&((D=r(this,Q))==null||D.call(this,I,e,"set")),r(this,W)&&r(this,z)?.push([I,e,"set"]));if(r(this,_e).call(this,C),r(this,we).call(this,C,p,c),r(this,T)[C]=t,c){c.set="replace";let o=I&&f(this,h,A).call(this,I)?I.__staleWhileFetching:I;o!==void 0&&(c.oldValue=o);}}else c&&(c.set="update");r(this,Ie)&&this.onInsert?.(t,e,t===I?"update":"replace");}if(i!==0&&!r(this,$)&&f(this,h,ke).call(this),r(this,$)&&(y||r(this,Me).call(this,C,i,a),c&&r(this,he).call(this,c,C)),!s&&r(this,W)&&r(this,z)){let I=r(this,z),o;for(;o=I?.shift();)(v=r(this,Z))==null||v.call(this,...o);}return this}pop(){var e;try{for(;r(this,F);){let t=r(this,T)[r(this,G)];if(f(this,h,Ye).call(this,!0),f(this,h,A).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,z)){let t=r(this,z),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,Y).get(e);if(a!==void 0){let s=r(this,T)[a];if(f(this,h,A).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,he).call(this,i,a));else return n&&r(this,ye).call(this,a),i&&(i.has="hit",r(this,he).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,Y).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,T)[i];return f(this,h,A).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:C=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:N=this.allowStaleOnFetchRejection,ignoreFetchAbort:P=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:v,forceRefresh:I=false,status:o,signal:d}=t;if(!r(this,me))return o&&(o.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:o});let w={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:s,noDisposeOnSet:l,size:c,sizeCalculation:y,noUpdateTTL:p,noDeleteOnFetchRejection:C,allowStaleOnFetchRejection:N,allowStaleOnFetchAbort:D,ignoreFetchAbort:P,status:o,signal:d},L=r(this,Y).get(e);if(L===void 0){o&&(o.fetch="miss");let x=f(this,h,Fe).call(this,e,L,w,v);return x.__returned=x}else {let x=r(this,T)[L];if(f(this,h,A).call(this,x)){let ue=n&&x.__staleWhileFetching!==void 0;return o&&(o.fetch="inflight",ue&&(o.returnedStale=true)),ue?x.__staleWhileFetching:x.__returned=x}let U=r(this,q).call(this,L);if(!I&&!U)return o&&(o.fetch="hit"),f(this,h,Ae).call(this,L),i&&r(this,ye).call(this,L),o&&r(this,he).call(this,o,L),x;let oe=f(this,h,Fe).call(this,e,L,w,v),J=oe.__staleWhileFetching!==void 0&&n;return o&&(o.fetch=U?"stale":"refresh",J&&U&&(o.returnedStale=true)),J?oe.__staleWhileFetching:oe.__returned=oe}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...s}=t,l=this.get(e,s);if(!a&&l!==void 0)return l;let c=n(e,l,{options:s,context:i});return this.set(e,c,s),c}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:s}=t,l=r(this,Y).get(e);if(l!==void 0){let c=r(this,T)[l],y=f(this,h,A).call(this,c);return s&&r(this,he).call(this,s,l),r(this,q).call(this,l)?(s&&(s.get="stale"),y?(s&&n&&c.__staleWhileFetching!==void 0&&(s.returnedStale=true),n?c.__staleWhileFetching:void 0):(a||f(this,h,be).call(this,e,"expire"),s&&n&&(s.returnedStale=true),n?c:void 0)):(s&&(s.get="hit"),y?c.__staleWhileFetching:(f(this,h,Ae).call(this,l),i&&r(this,ye).call(this,l),c))}else s&&(s.get="miss");}delete(e){return f(this,h,be).call(this,e,"delete")}clear(){return f(this,h,Je).call(this,"delete")}};X=new WeakMap,B=new WeakMap,Q=new WeakMap,ge=new WeakMap,Z=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,ee=new WeakMap,F=new WeakMap,te=new WeakMap,Y=new WeakMap,M=new WeakMap,T=new WeakMap,K=new WeakMap,j=new WeakMap,G=new WeakMap,V=new WeakMap,re=new WeakMap,z=new WeakMap,ne=new WeakMap,ie=new WeakMap,$=new WeakMap,k=new WeakMap,se=new WeakMap,me=new WeakMap,W=new WeakMap,Ie=new WeakMap,h=new WeakSet,ke=function(){let e=new Le(r(this,X)),t=new Le(r(this,X));S(this,$,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,k,n),S(this,Me,(s,l,c=r(this,ee).now())=>{if(t[s]=l!==0?c:0,e[s]=l,n?.[s]&&(clearTimeout(n[s]),n[s]=void 0),l!==0&&n){let y=setTimeout(()=>{r(this,q).call(this,s)&&f(this,h,be).call(this,r(this,M)[s],"expire");},l+1);y.unref&&y.unref(),n[s]=y;}}),S(this,ye,s=>{t[s]=e[s]!==0?r(this,ee).now():0;}),S(this,he,(s,l)=>{if(e[l]){let c=e[l],y=t[l];if(!c||!y)return;s.ttl=c,s.start=y,s.now=i||a();let p=s.now-y;s.remainingTTL=c-p;}});let i=0,a=()=>{let s=r(this,ee).now();if(this.ttlResolution>0){i=s;let l=setTimeout(()=>i=0,this.ttlResolution);l.unref&&l.unref();}return s};this.getRemainingTTL=s=>{let l=r(this,Y).get(s);if(l===void 0)return 0;let c=e[l],y=t[l];if(!c||!y)return 1/0;let p=(i||a())-y;return c-p},S(this,q,s=>{let l=t[s],c=e[s];return !!c&&!!l&&(i||a())-l>c});},ye=new WeakMap,he=new WeakMap,Me=new WeakMap,q=new WeakMap,ut=function(){let e=new Le(r(this,X));S(this,te,0),S(this,ne,e),S(this,_e,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Ne,(t,n,i,a)=>{if(f(this,h,A).call(this,n))return 0;if(!de(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!de(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,we,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,h,Ye).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},_e=new WeakMap,we=new WeakMap,Ne=new WeakMap,pe=function*({allowStale:e=this.allowStale}={}){if(r(this,F))for(let t=r(this,V);!(!f(this,h,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,G)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,F))for(let t=r(this,G);!(!f(this,h,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,V)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,Y).get(r(this,M)[e])===e},Ye=function(e){var a;let t=r(this,G),n=r(this,M)[t],i=r(this,T)[t];return r(this,me)&&f(this,h,A).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,se)||r(this,W))&&(r(this,se)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,z)?.push([i,n,"evict"])),r(this,_e).call(this,t),r(this,k)?.[t]&&(clearTimeout(r(this,k)[t]),r(this,k)[t]=void 0),e&&(r(this,M)[t]=void 0,r(this,T)[t]=void 0,r(this,re).push(t)),r(this,F)===1?(S(this,G,S(this,V,0)),r(this,re).length=0):S(this,G,r(this,K)[t]),r(this,Y).delete(n),Ue(this,F)._--,t},Fe=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,h,A).call(this,a))return a;let s=new Ve,{signal:l}=n;l?.addEventListener("abort",()=>s.abort(l.reason),{signal:s.signal});let c={signal:s.signal,options:n,context:i},y=(v,I=false)=>{let{aborted:o}=s.signal,d=n.ignoreFetchAbort&&v!==void 0;if(n.status&&(o&&!I?(n.status.fetchAborted=true,n.status.fetchError=s.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),o&&!d&&!I)return C(s.signal.reason);let w=P,L=r(this,T)[t];return (L===P||d&&I&&L===void 0)&&(v===void 0?w.__staleWhileFetching!==void 0?r(this,T)[t]=w.__staleWhileFetching:f(this,h,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,v,c.options))),v},p=v=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=v),C(v)),C=v=>{let{aborted:I}=s.signal,o=I&&n.allowStaleOnFetchAbort,d=o||n.allowStaleOnFetchRejection,w=d||n.noDeleteOnFetchRejection,L=P;if(r(this,T)[t]===P&&(!w||L.__staleWhileFetching===void 0?f(this,h,be).call(this,e,"fetch"):o||(r(this,T)[t]=L.__staleWhileFetching)),d)return n.status&&L.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),L.__staleWhileFetching;if(L.__returned===L)throw v},N=(v,I)=>{var d;let o=(d=r(this,Ee))==null?void 0:d.call(this,e,a,c);o&&o instanceof Promise&&o.then(w=>v(w===void 0?void 0:w),I),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(v(void 0),n.allowStaleOnFetchAbort&&(v=w=>y(w,true)));});};n.status&&(n.status.fetchDispatched=true);let P=new Promise(N).then(y,p),D=Object.assign(P,{__abortController:s,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,D,{...c.options,status:void 0}),t=r(this,Y).get(e)):r(this,T)[t]=D,D},A=function(e){if(!r(this,me))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ve},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},Ae=function(e){e!==r(this,V)&&(e===r(this,G)?S(this,G,r(this,K)[e]):f(this,h,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,h,Xe).call(this,r(this,V),e),S(this,V,e));},be=function(e,t){var i,a;let n=false;if(r(this,F)!==0){let s=r(this,Y).get(e);if(s!==void 0)if(r(this,k)?.[s]&&(clearTimeout(r(this,k)?.[s]),r(this,k)[s]=void 0),n=true,r(this,F)===1)f(this,h,Je).call(this,t);else {r(this,_e).call(this,s);let l=r(this,T)[s];if(f(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,se)||r(this,W))&&(r(this,se)&&((i=r(this,Q))==null||i.call(this,l,e,t)),r(this,W)&&r(this,z)?.push([l,e,t])),r(this,Y).delete(e),r(this,M)[s]=void 0,r(this,T)[s]=void 0,s===r(this,V))S(this,V,r(this,j)[s]);else if(s===r(this,G))S(this,G,r(this,K)[s]);else {let c=r(this,j)[s];r(this,K)[c]=r(this,K)[s];let y=r(this,K)[s];r(this,j)[y]=r(this,j)[s];}Ue(this,F)._--,r(this,re).push(s);}}if(r(this,W)&&r(this,z)?.length){let s=r(this,z),l;for(;l=s?.shift();)(a=r(this,Z))==null||a.call(this,...l);}return n},Je=function(e){var t,n;for(let i of f(this,h,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,h,A).call(this,a))a.__abortController.abort(new Error("deleted"));else {let s=r(this,M)[i];r(this,se)&&((t=r(this,Q))==null||t.call(this,a,s,e)),r(this,W)&&r(this,z)?.push([a,s,e]);}}if(r(this,Y).clear(),r(this,T).fill(void 0),r(this,M).fill(void 0),r(this,$)&&r(this,ie)){r(this,$).fill(0),r(this,ie).fill(0);for(let i of r(this,k)??[])i!==void 0&&clearTimeout(i);r(this,k)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,G,0),S(this,V,0),r(this,re).length=0,S(this,te,0),S(this,F,0),r(this,W)&&r(this,z)){let i=r(this,z),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}};var ze=Qe;var Oe=class{constructor(e){E(this,"cache");E(this,"map",new Map);this.cache=new ze({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(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 Re=new Oe({cacheSize:10}),Ze;(a=>{function u(s){let l=Re.get(s);if(!l){_.error(`Label "${s}" not found`);return}return l}a.get=u;function e(s){if(Array.isArray(s)){s.forEach(l=>e(l));return}Re.has(s.id)&&_.info(`Label "${s.id}" already exists, it will be overwritten`),Re.set(s.id,s);}a.add=e;function t(){return Array.from(Re.values())}a.values=t;function n(s){return Re.has(s)}a.has=n;function i(){return Array.from(Re.keys())}a.keys=i;})(Ze||(Ze={}));var ae=Ze;var m=class m{constructor(){}static get allOpenedLabels(){return unifier.GameUnifier.getVariable(O.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){unifier.GameUnifier.setVariable(O.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=m.currentLabelStepIndex;if(t===null)return _.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=m.currentLabelId,a=m._currentLabel;if(!i||t===null||!a)return _.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let s=a.getStepSha(t)||"error",l=unifier.GameUnifier.getVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return l[i]||(l[i]={}),(!l[i][n]||l[i][n].stepSha1!=s)&&(l[i][n]={stepSha1:s}),l[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=m.currentLabelStepIndex,i=n+e,a=m.currentLabelId;if(!a||n===null){_.error("currentLabelId or currentLabelStepIndex is null");return}let s=unifier.GameUnifier.getVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[a]||(s[a]={}),s[a][i]=t,unifier.GameUnifier.setVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static getCurrentStepTimesCounter(e=""){let t=m._stepCounter,n=m.getCurrentStepTimesCounterData(e);if(!n)return _.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||n.lastStepIndexs||[];return i.find(s=>s===t)||(i.push(t),delete n.lastStepIndexs,n.stepCounters=i,m.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let s=m.getCurrentStepTimesCounterData(i);if(!s)return;let l=s.usedRandomNumbers||{},c=Array.from({length:t-e+1},(C,N)=>N+e).filter(C=>!l[`${e}-${t}`]?.includes(C));if(c.length===0)return;let y=Math.floor(Math.random()*c.length),p=c[y];return l[`${e}-${t}`]||(l[`${e}-${t}`]=[]),l[`${e}-${t}`].push(p),s.usedRandomNumbers=l,m.setCurrentStepTimesCounterData(i,s),p}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=m.currentLabelStepIndex,n=t+e,i=m.currentLabelId;if(!i||t===null){_.error("currentLabelId or currentLabelStepIndex is null");return}let a=unifier.GameUnifier.getVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},unifier.GameUnifier.setVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return unifier.GameUnifier.getVariable(O.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){unifier.GameUnifier.setVariable(O.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){m._stepCounter++;}static get openedLabels(){return le(m._openedLabels)}static set openedLabels(e){m._openedLabels=le(e);}static get originalOpenedLabels(){return le(m._originalOpenedLabels)}static set originalOpenedLabels(e){m._originalOpenedLabels=le(e);}static get _currentLabel(){if(m.currentLabelId)return ae.get(m.currentLabelId)}static get currentLabelId(){if(m._openedLabels.length>0)return m._openedLabels[m._openedLabels.length-1].label}static get currentLabelStepIndex(){return m._openedLabels.length>0?m._openedLabels[m._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=m.allOpenedLabels,i=m.allOpenedLabels[e]?.biggestStep||0,a=m.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},m.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=m.allChoicesMade,s=a.findIndex(l=>l.labelId===e&&l.stepIndex===t&&l.choiceIndex===i&&l.stepSha1===n);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[s].madeTimes++,m.allChoicesMade=a;}static pushNewLabel(e){if(!ae.get(e))throw new Error(`[Pixi\u2019VN] Label ${e} not found`);m._openedLabels.push({label:e,currentStepIndex:0});let n=m.allOpenedLabels,i=m.allOpenedLabels[e]?.biggestStep||0,a=m.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},m.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(m._openedLabels.length>0){let e=m._openedLabels[m._openedLabels.length-1];m._openedLabels[m._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){m._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return m.onLoadingLabel&&e===0&&n.push(m.onLoadingLabel(e,t)),m._onStepStart&&n.push(m._onStepStart(e,t)),await Promise.all(n)}}};E(m,"choiceMadeTemp"),E(m,"lastHistoryStep",null),E(m,"_stepCounter",0),E(m,"_openedLabels",[]),E(m,"_originalOpenedLabels",[]),E(m,"_onStepStart"),E(m,"onLoadingLabel"),E(m,"onStepEnd");var b=m;var Pe=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,s,l,c=unifier.GameUnifier.getVariable(O.LAST_STEP_GLUED)===this.stepCounter;unifier.GameUnifier.getVariable(O.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=unifier.GameUnifier.getVariable(O.CURRENT_DIALOGUE_MEMORY_KEY)),unifier.GameUnifier.getVariable(O.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=unifier.GameUnifier.getVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY)),unifier.GameUnifier.getVariable(O.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l=unifier.GameUnifier.getVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,p={currentLabel:b.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:l,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:c,openedLabels:y};b.originalOpenedLabels=y,unifier.GameUnifier.addHistoryItem(p,{ignoreSameStep:i}),b.lastHistoryStep=p,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){_.warn("No label to close");return}if(!this.currentLabel){_.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,unifier.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),unifier.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=ae.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||(_.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&_.warn("The player must make a choice"),false):this.isRequiredInput?(t&&_.warn("The player must enter a value"),false):true}get canContinue(){return unifier.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){_.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){_.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&unifier.GameUnifier.runningStepsCount!==0){unifier.GameUnifier.increaseContinueRequest(i);return}i>1&&unifier.GameUnifier.increaseContinueRequest(i-1),unifier.GameUnifier.runningStepsCount++;let a;try{unifier.GameUnifier.runningStepsCount===1&&await unifier.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(s){throw _.error("Error continuing",s),s}finally{unifier.GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep()||a;}return a}async afterRunCurrentStep(){if(unifier.GameUnifier.runningStepsCount===0&&unifier.GameUnifier.continueRequestsCount!==0)return await unifier.GameUnifier.processNavigationRequests()}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){_.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){_.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(p){_.error("Error running onStepStart",p),this.onStepError&&await this.onStepError(p,e);return}let s=a.getStepById(i);if(!s){_.error("step not found");return}let l=a.getStepSha(i);l||(_.warn("stepSha not found, setting to ERROR"),l="error");let c,y;try{c=await s(e,{labelId:a.id});}catch(p){_.error("Error running step",p),y=p;}try{let p=this.choices;if(p?.length===1&&p[0].autoSelect){let C=p[0];c=await this.selectChoice(C,e);}}catch(p){_.error("Error auto-selecting choice",p),y===void 0&&(y=p);}try{let p=b.lastHistoryStep;n!==void 0&&p&&(l=p.stepSha1,l||(_.warn("stepSha not found, setting to ERROR"),l="error"),b.addChoicesMade(p.currentLabel||"error",typeof p.labelStepIndex=="number"?p.labelStepIndex:-1,p.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(p){_.warn("Error adding choice made to history",p);}try{unifier.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(l,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(p){_.warn("Error adding step to history",p);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(p){_.warn("Error running onStepEnd",p);}return y&&this.onStepError&&await this.onStepError(y,e),c}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1)return b.openedLabels=[],unifier.GameUnifier.onEnd?await unifier.GameUnifier.onEnd(e,{labelId:"end"}):void 0}}else if(this.openedLabels.length===0){if(b.openedLabels=b.originalOpenedLabels,unifier.GameUnifier.onEnd)return await unifier.GameUnifier.onEnd(e,{labelId:"end"});_.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.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");return}else _.error("currentLabelId not found");}async call(e,t,n){let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,unifier.GameUnifier.runningStepsCount++;let s;try{let l=ae.get(a);if(!l)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);b.pushNewLabel(l.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw _.error("Error calling label",l),l}finally{unifier.GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async jump(e,t,n){this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,unifier.GameUnifier.runningStepsCount++;let s;try{let l=ae.get(a);if(!l)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);b.pushNewLabel(l.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw _.error("Error jumping to label",l),l}finally{unifier.GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw _.error(`Type ${n} not found`),new Error(`[Pixi\u2019VN] Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw _.error("For closeChoiceMenu, the type must be close"),new Error("[Pixi\u2019VN] 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(){let e=unifier.GameUnifier.onError;if(e)return async(t,n)=>{try{return await e("step",t,n)}catch(i){_.error("Error in onError handler",i);}}}set onStepError(e){unifier.GameUnifier.onError=(t,n,i)=>e(n,i);}get dialogue(){let e=unifier.GameUnifier.getVariable(O.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?unifier.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){unifier.GameUnifier.setVariable(O.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=unifier.GameUnifier.getVariable(O.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;}unifier.GameUnifier.setVariable(O.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{unifier.GameUnifier.setVariable(O.CURRENT_DIALOGUE_MEMORY_KEY,le({...e,character:typeof e.character=="string"?e.character:e.character?.id})),unifier.GameUnifier.setVariable(O.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw _.error("DialogueInterface cannot contain functions or classes"),t}}get choices(){let e=unifier.GameUnifier.getVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,s)=>({...a,choiceIndex:s})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,s)=>a.oneTime&&i&&i.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){unifier.GameUnifier.setVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{unifier.GameUnifier.setVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY,le(e)),unifier.GameUnifier.setVariable(O.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw _.error("ChoiceInterface cannot contain functions or classes"),t}}get dialogGlue(){return unifier.GameUnifier.getFlag(O.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){unifier.GameUnifier.setFlag(O.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return unifier.GameUnifier.getVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),unifier.GameUnifier.setVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY,e),unifier.GameUnifier.setVariable(O.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return unifier.GameUnifier.getVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return unifier.GameUnifier.getVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,unifier.GameUnifier.setVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?unifier.GameUnifier.setVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY,t):unifier.GameUnifier.removeVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){unifier.GameUnifier.removeVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY),unifier.GameUnifier.removeVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:le(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=ae.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,e.hasOwnProperty("openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):_.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?b._stepCounter=e.stepCounter:e.hasOwnProperty("lastStepIndex")?b._stepCounter=e.lastStepIndex:_.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){_.error("Error running onLoadingLabel",n);}}catch(n){_.error("Error importing data",n);}}};function Ot(u,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:u,type:n?.type||"call"}}var et="close";function Rt(u,e){return {...e,type:et,text:u}}var ft=Et(pt());var xe=class{constructor(e,t){E(this,"id");E(this,"_onStepStart");E(this,"_onLoadingLabel");E(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var ve=class extends xe{constructor(t,n,i){super(t,i);E(this,"_steps");this._steps=n;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return _.warn("stepSha not found, setting to ERROR"),"error";try{let n=this.steps[t];return (0,ft.default)(n.toString().toLocaleLowerCase()).toString()}catch(n){return _.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(u,e,t){let n=new ve(u,e,t);return ae.add(n),n}var Or=new Pe;
|
|
1
|
+
'use strict';var unifier=require('@drincs/pixi-vn/unifier');var mt=Object.create;var Ke=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,_t=Object.prototype.hasOwnProperty;var tt=u=>{throw TypeError(u)};var Lt=(u,e,t)=>e in u?Ke(u,e,{enumerable:true,configurable:true,writable:true,value:t}):u[e]=t;var We=(u=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(u,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):u)(function(u){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+u+'" is not supported')});var rt=(u,e)=>()=>(e||u((e={exports:{}}).exports,e),e.exports);var Tt=(u,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of gt(e))!_t.call(u,i)&&i!==t&&Ke(u,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return u};var Et=(u,e,t)=>(t=u!=null?mt(yt(u)):{},Tt(Ke(t,"default",{value:u,enumerable:true}),u));var T=(u,e,t)=>Lt(u,typeof e!="symbol"?e+"":e,t),Be=(u,e,t)=>e.has(u)||tt("Cannot "+t);var r=(u,e,t)=>(Be(u,e,"read from private field"),t?t.call(u):e.get(u)),x=(u,e,t)=>e.has(u)?tt("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(u):e.set(u,t),S=(u,e,t,n)=>(Be(u,e,"write to private field"),e.set(u,t),t),f=(u,e,t)=>(Be(u,e,"access private method"),t);var Ue=(u,e,t,n)=>({set _(i){S(u,e,i);},get _(){return r(u,e,n)}});var ct=rt((Ge,ht)=>{(function(u,e){typeof Ge=="object"?ht.exports=Ge=e():typeof define=="function"&&define.amd?define([],e):u.CryptoJS=e();})(Ge,function(){var u=u||(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 We=="function")try{n=We("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 o(){}return function(d){var w;return o.prototype=d,w=new o,o.prototype=null,w}})(),s={},l=s.lib={},c=l.Base=(function(){return {extend:function(o){var d=a(this);return o&&d.mixIn(o),(!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 o=this.extend();return o.init.apply(o,arguments),o},init:function(){},mixIn:function(o){for(var d in o)o.hasOwnProperty(d)&&(this[d]=o[d]);o.hasOwnProperty("toString")&&(this.toString=o.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=l.WordArray=c.extend({init:function(o,d){o=this.words=o||[],d!=t?this.sigBytes=d:this.sigBytes=o.length*4;},toString:function(o){return (o||E).stringify(this)},concat:function(o){var d=this.words,w=o.words,I=this.sigBytes,R=o.sigBytes;if(this.clamp(),I%4)for(var U=0;U<R;U++){var oe=w[U>>>2]>>>24-U%4*8&255;d[I+U>>>2]|=oe<<24-(I+U)%4*8;}else for(var H=0;H<R;H+=4)d[I+H>>>2]=w[H>>>2];return this.sigBytes+=R,this},clamp:function(){var o=this.words,d=this.sigBytes;o[d>>>2]&=4294967295<<32-d%4*8,o.length=e.ceil(d/4);},clone:function(){var o=c.clone.call(this);return o.words=this.words.slice(0),o},random:function(o){for(var d=[],w=0;w<o;w+=4)d.push(i());return new y.init(d,o)}}),p=s.enc={},E=p.Hex={stringify:function(o){for(var d=o.words,w=o.sigBytes,I=[],R=0;R<w;R++){var U=d[R>>>2]>>>24-R%4*8&255;I.push((U>>>4).toString(16)),I.push((U&15).toString(16));}return I.join("")},parse:function(o){for(var d=o.length,w=[],I=0;I<d;I+=2)w[I>>>3]|=parseInt(o.substr(I,2),16)<<24-I%8*4;return new y.init(w,d/2)}},N=p.Latin1={stringify:function(o){for(var d=o.words,w=o.sigBytes,I=[],R=0;R<w;R++){var U=d[R>>>2]>>>24-R%4*8&255;I.push(String.fromCharCode(U));}return I.join("")},parse:function(o){for(var d=o.length,w=[],I=0;I<d;I++)w[I>>>2]|=(o.charCodeAt(I)&255)<<24-I%4*8;return new y.init(w,d)}},P=p.Utf8={stringify:function(o){try{return decodeURIComponent(escape(N.stringify(o)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(o){return N.parse(unescape(encodeURIComponent(o)))}},D=l.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(o){typeof o=="string"&&(o=P.parse(o)),this._data.concat(o),this._nDataBytes+=o.sigBytes;},_process:function(o){var d,w=this._data,I=w.words,R=w.sigBytes,U=this.blockSize,oe=U*4,H=R/oe;o?H=e.ceil(H):H=e.max((H|0)-this._minBufferSize,0);var J=H*U,ue=e.min(J*4,R);if(J){for(var De=0;De<J;De+=U)this._doProcessBlock(I,De);d=I.splice(0,J),w.sigBytes-=ue;}return new y.init(d,ue)},clone:function(){var o=c.clone.call(this);return o._data=this._data.clone(),o},_minBufferSize:0});l.Hasher=D.extend({cfg:c.extend(),init:function(o){this.cfg=this.cfg.extend(o),this.reset();},reset:function(){D.reset.call(this),this._doReset();},update:function(o){return this._append(o),this._process(),this},finalize:function(o){o&&this._append(o);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(o){return function(d,w){return new o.init(w).finalize(d)}},_createHmacHelper:function(o){return function(d,w){return new C.HMAC.init(o,w).finalize(d)}}});var C=s.algo={};return s})(Math);return u});});var pt=rt((He,dt)=>{(function(u,e){typeof He=="object"?dt.exports=He=e(ct()):typeof define=="function"&&define.amd?define(["./core"],e):e(u.CryptoJS);})(He,function(u){return (function(){var e=u,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,s=[],l=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,y){for(var p=this._hash.words,E=p[0],N=p[1],P=p[2],D=p[3],v=p[4],C=0;C<80;C++){if(C<16)s[C]=c[y+C]|0;else {var o=s[C-3]^s[C-8]^s[C-14]^s[C-16];s[C]=o<<1|o>>>31;}var d=(E<<5|E>>>27)+v+s[C];C<20?d+=(N&P|~N&D)+1518500249:C<40?d+=(N^P^D)+1859775393:C<60?d+=(N&P|N&D|P&D)-1894007588:d+=(N^P^D)-899497514,v=D,D=P,P=N<<30|N>>>2,N=E,E=d;}p[0]=p[0]+E|0,p[1]=p[1]+N|0,p[2]=p[2]+P|0,p[3]=p[3]+D|0,p[4]=p[4]+v|0;},_doFinalize:function(){var c=this._data,y=c.words,p=this._nDataBytes*8,E=c.sigBytes*8;return y[E>>>5]|=128<<24-E%32,y[(E+64>>>9<<4)+14]=Math.floor(p/4294967296),y[(E+64>>>9<<4)+15]=p,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(l),e.HmacSHA1=i._createHmacHelper(l);})(),u.SHA1});});var O={CURRENT_DIALOGUE_MEMORY_KEY:"___current_dialogue_memory___",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"___last_dialogue_added_in_step_memory___",CURRENT_MENU_OPTIONS_MEMORY_KEY:"___current_menu_options_memory___",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"___last_menu_options_added_in_step_memory___",CURRENT_INPUT_VALUE_MEMORY_KEY:"_input_value_",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"___last_input_added_in_step_memory___",CURRENT_INPUT_INFO_MEMORY_KEY:"___current_input_info_memory___",CHARACTER_CATEGORY_KEY:"___character___",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"___opened_labels_counter___",ALL_CHOICES_MADE_KEY:"___all_choices_made___",CURRENT_STEP_TIMES_COUNTER_KEY:"___current_step_times_counter___",LAST_STEP_GLUED:"___last_step_glued___"};var _;(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)))(_||(_={}));function le(u){try{if(typeof u>"u")return u;let e=JSON.stringify(u);return JSON.parse(e)}catch(e){throw _.error("Error creating exportable element",u,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}var Ct=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,at=new Set,je=typeof process=="object"&&process?process:{},ot=(u,e,t,n)=>{typeof je.emitWarning=="function"?je.emitWarning(u,e,t,n):console.error(`[${t}] ${e}: ${u}`);},Ve=globalThis.AbortController,nt=globalThis.AbortSignal;if(typeof Ve>"u"){nt=class{constructor(){T(this,"onabort");T(this,"_onabort",[]);T(this,"reason");T(this,"aborted",false);}addEventListener(n,i){this._onabort.push(i);}},Ve=class{constructor(){T(this,"signal",new nt);e();}abort(n){if(!this.signal.aborted){this.signal.reason=n,this.signal.aborted=true;for(let i of this.signal._onabort)i(n);this.signal.onabort?.(n);}}};let u=je.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{u&&(u=false,ot("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=u=>!at.has(u);var de=u=>u&&u===Math.floor(u)&&u>0&&isFinite(u),lt=u=>de(u)?u<=Math.pow(2,8)?Uint8Array:u<=Math.pow(2,16)?Uint16Array:u<=Math.pow(2,32)?Uint32Array:u<=Number.MAX_SAFE_INTEGER?Le:null:null,Le=class extends Array{constructor(e){super(e),this.fill(0);}},Te,Se=class Se{constructor(e,t){T(this,"heap");T(this,"length");if(!r(Se,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}static create(e){let t=lt(e);if(!t)return [];S(Se,Te,true);let n=new Se(e,t);return S(Se,Te,false),n}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}};Te=new WeakMap,x(Se,Te,false);var $e=Se,it,st,X,B,Q,ge,Z,Ee,Ce,ee,F,te,Y,M,L,K,j,G,V,re,z,ne,ie,$,k,se,me,W,Ie,h,ke,ye,he,Me,q,ut,_e,we,Ne,pe,fe,qe,Ye,Fe,A,Xe,Ae,be,Je,Qe=class Qe{constructor(e){x(this,h);x(this,X);x(this,B);x(this,Q);x(this,ge);x(this,Z);x(this,Ee);x(this,Ce);x(this,ee);T(this,"ttl");T(this,"ttlResolution");T(this,"ttlAutopurge");T(this,"updateAgeOnGet");T(this,"updateAgeOnHas");T(this,"allowStale");T(this,"noDisposeOnSet");T(this,"noUpdateTTL");T(this,"maxEntrySize");T(this,"sizeCalculation");T(this,"noDeleteOnFetchRejection");T(this,"noDeleteOnStaleGet");T(this,"allowStaleOnFetchAbort");T(this,"allowStaleOnFetchRejection");T(this,"ignoreFetchAbort");x(this,F);x(this,te);x(this,Y);x(this,M);x(this,L);x(this,K);x(this,j);x(this,G);x(this,V);x(this,re);x(this,z);x(this,ne);x(this,ie);x(this,$);x(this,k);x(this,se);x(this,me);x(this,W);x(this,Ie);x(this,ye,()=>{});x(this,he,()=>{});x(this,Me,()=>{});x(this,q,()=>false);x(this,_e,e=>{});x(this,we,(e,t,n)=>{});x(this,Ne,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});T(this,it,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:s,updateAgeOnHas:l,allowStale:c,dispose:y,onInsert:p,disposeAfter:E,noDisposeOnSet:N,noUpdateTTL:P,maxSize:D=0,maxEntrySize:v=0,sizeCalculation:C,fetchMethod:o,memoMethod:d,noDeleteOnFetchRejection:w,noDeleteOnStaleGet:I,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:U,ignoreFetchAbort:oe,perf:H}=e;if(H!==void 0&&typeof H?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,H??Ct),t!==0&&!de(t))throw new TypeError("max option must be a nonnegative integer");let J=t?lt(t):Array;if(!J)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,D),this.maxEntrySize=v||r(this,B),this.sizeCalculation=C,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),o!==void 0&&typeof o!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,Ee,o),S(this,me,!!o),S(this,Y,new Map),S(this,M,new Array(t).fill(void 0)),S(this,L,new Array(t).fill(void 0)),S(this,K,new J(t)),S(this,j,new J(t)),S(this,G,0),S(this,V,0),S(this,re,$e.create(t)),S(this,F,0),S(this,te,0),typeof y=="function"&&S(this,Q,y),typeof p=="function"&&S(this,ge,p),typeof E=="function"?(S(this,Z,E),S(this,z,[])):(S(this,Z,void 0),S(this,z,void 0)),S(this,se,!!r(this,Q)),S(this,Ie,!!r(this,ge)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!N,this.noUpdateTTL=!!P,this.noDeleteOnFetchRejection=!!w,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!U,this.ignoreFetchAbort=!!oe,this.maxEntrySize!==0){if(r(this,B)!==0&&!de(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!de(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,h,ut).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!I,this.updateAgeOnGet=!!s,this.updateAgeOnHas=!!l,this.ttlResolution=de(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!de(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,h,ke).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 ue="LRU_CACHE_UNBOUNDED";It(ue)&&(at.add(ue),ot("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",ue,Qe));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,$),autopurgeTimers:r(e,k),sizes:r(e,ne),keyMap:r(e,Y),keyList:r(e,M),valList:r(e,L),next:r(e,K),prev:r(e,j),get head(){return r(e,G)},get tail(){return r(e,V)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,h,A).call(n,t)},backgroundFetch:(t,n,i,a)=>{var s;return f(s=e,h,Fe).call(s,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,h,Ae).call(n,t)},indexes:t=>{var n;return f(n=e,h,pe).call(n,t)},rindexes:t=>{var n;return f(n=e,h,fe).call(n,t)},isStale:t=>{var n;return r(n=e,q).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,F)}get fetchMethod(){return r(this,Ee)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,Q)}get onInsert(){return r(this,ge)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,Y).has(e)?1/0:0}*entries(){for(let e of f(this,h,pe).call(this))r(this,L)[e]!==void 0&&r(this,M)[e]!==void 0&&!f(this,h,A).call(this,r(this,L)[e])&&(yield [r(this,M)[e],r(this,L)[e]]);}*rentries(){for(let e of f(this,h,fe).call(this))r(this,L)[e]!==void 0&&r(this,M)[e]!==void 0&&!f(this,h,A).call(this,r(this,L)[e])&&(yield [r(this,M)[e],r(this,L)[e]]);}*keys(){for(let e of f(this,h,pe).call(this)){let t=r(this,M)[e];t!==void 0&&!f(this,h,A).call(this,r(this,L)[e])&&(yield t);}}*rkeys(){for(let e of f(this,h,fe).call(this)){let t=r(this,M)[e];t!==void 0&&!f(this,h,A).call(this,r(this,L)[e])&&(yield t);}}*values(){for(let e of f(this,h,pe).call(this))r(this,L)[e]!==void 0&&!f(this,h,A).call(this,r(this,L)[e])&&(yield r(this,L)[e]);}*rvalues(){for(let e of f(this,h,fe).call(this))r(this,L)[e]!==void 0&&!f(this,h,A).call(this,r(this,L)[e])&&(yield r(this,L)[e]);}[(st=Symbol.iterator,it=Symbol.toStringTag,st)](){return this.entries()}find(e,t={}){for(let n of f(this,h,pe).call(this)){let i=r(this,L)[n],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,M)[n],this))return this.get(r(this,M)[n],t)}}forEach(e,t=this){for(let n of f(this,h,pe).call(this)){let i=r(this,L)[n],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,M)[n],this);}}rforEach(e,t=this){for(let n of f(this,h,fe).call(this)){let i=r(this,L)[n],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,M)[n],this);}}purgeStale(){let e=false;for(let t of f(this,h,fe).call(this,{allowStale:true}))r(this,q).call(this,t)&&(f(this,h,be).call(this,r(this,M)[t],"expire"),e=true);return e}info(e){let t=r(this,Y).get(e);if(t===void 0)return;let n=r(this,L)[t],i=f(this,h,A).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,$)&&r(this,ie)){let s=r(this,$)[t],l=r(this,ie)[t];if(s&&l){let c=s-(r(this,ee).now()-l);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,h,pe).call(this,{allowStale:true})){let n=r(this,M)[t],i=r(this,L)[t],a=f(this,h,A).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let s={value:a};if(r(this,$)&&r(this,ie)){s.ttl=r(this,$)[t];let l=r(this,ee).now()-r(this,ie)[t];s.start=Math.floor(Date.now()-l);}r(this,ne)&&(s.size=r(this,ne)[t]),e.unshift([n,s]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var N,P,D,v;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:s=this.noDisposeOnSet,sizeCalculation:l=this.sizeCalculation,status:c}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,p=r(this,Ne).call(this,e,t,n.size||0,l);if(this.maxEntrySize&&p>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),f(this,h,be).call(this,e,"set"),this;let E=r(this,F)===0?void 0:r(this,Y).get(e);if(E===void 0)E=r(this,F)===0?r(this,V):r(this,re).length!==0?r(this,re).pop():r(this,F)===r(this,X)?f(this,h,Ye).call(this,false):r(this,F),r(this,M)[E]=e,r(this,L)[E]=t,r(this,Y).set(e,E),r(this,K)[r(this,V)]=E,r(this,j)[E]=r(this,V),S(this,V,E),Ue(this,F)._++,r(this,we).call(this,E,p,c),c&&(c.set="add"),y=false,r(this,Ie)&&((N=r(this,ge))==null||N.call(this,t,e,"add"));else {f(this,h,Ae).call(this,E);let C=r(this,L)[E];if(t!==C){if(r(this,me)&&f(this,h,A).call(this,C)){C.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:o}=C;o!==void 0&&!s&&(r(this,se)&&((P=r(this,Q))==null||P.call(this,o,e,"set")),r(this,W)&&r(this,z)?.push([o,e,"set"]));}else s||(r(this,se)&&((D=r(this,Q))==null||D.call(this,C,e,"set")),r(this,W)&&r(this,z)?.push([C,e,"set"]));if(r(this,_e).call(this,E),r(this,we).call(this,E,p,c),r(this,L)[E]=t,c){c.set="replace";let o=C&&f(this,h,A).call(this,C)?C.__staleWhileFetching:C;o!==void 0&&(c.oldValue=o);}}else c&&(c.set="update");r(this,Ie)&&this.onInsert?.(t,e,t===C?"update":"replace");}if(i!==0&&!r(this,$)&&f(this,h,ke).call(this),r(this,$)&&(y||r(this,Me).call(this,E,i,a),c&&r(this,he).call(this,c,E)),!s&&r(this,W)&&r(this,z)){let C=r(this,z),o;for(;o=C?.shift();)(v=r(this,Z))==null||v.call(this,...o);}return this}pop(){var e;try{for(;r(this,F);){let t=r(this,L)[r(this,G)];if(f(this,h,Ye).call(this,!0),f(this,h,A).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,z)){let t=r(this,z),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,Y).get(e);if(a!==void 0){let s=r(this,L)[a];if(f(this,h,A).call(this,s)&&s.__staleWhileFetching===void 0)return false;if(r(this,q).call(this,a))i&&(i.has="stale",r(this,he).call(this,i,a));else return n&&r(this,ye).call(this,a),i&&(i.has="hit",r(this,he).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,Y).get(e);if(i===void 0||!n&&r(this,q).call(this,i))return;let a=r(this,L)[i];return f(this,h,A).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:s=this.ttl,noDisposeOnSet:l=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:p=this.noUpdateTTL,noDeleteOnFetchRejection:E=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:N=this.allowStaleOnFetchRejection,ignoreFetchAbort:P=this.ignoreFetchAbort,allowStaleOnFetchAbort:D=this.allowStaleOnFetchAbort,context:v,forceRefresh:C=false,status:o,signal:d}=t;if(!r(this,me))return o&&(o.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:o});let w={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:s,noDisposeOnSet:l,size:c,sizeCalculation:y,noUpdateTTL:p,noDeleteOnFetchRejection:E,allowStaleOnFetchRejection:N,allowStaleOnFetchAbort:D,ignoreFetchAbort:P,status:o,signal:d},I=r(this,Y).get(e);if(I===void 0){o&&(o.fetch="miss");let R=f(this,h,Fe).call(this,e,I,w,v);return R.__returned=R}else {let R=r(this,L)[I];if(f(this,h,A).call(this,R)){let ue=n&&R.__staleWhileFetching!==void 0;return o&&(o.fetch="inflight",ue&&(o.returnedStale=true)),ue?R.__staleWhileFetching:R.__returned=R}let U=r(this,q).call(this,I);if(!C&&!U)return o&&(o.fetch="hit"),f(this,h,Ae).call(this,I),i&&r(this,ye).call(this,I),o&&r(this,he).call(this,o,I),R;let oe=f(this,h,Fe).call(this,e,I,w,v),J=oe.__staleWhileFetching!==void 0&&n;return o&&(o.fetch=U?"stale":"refresh",J&&U&&(o.returnedStale=true)),J?oe.__staleWhileFetching:oe.__returned=oe}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...s}=t,l=this.get(e,s);if(!a&&l!==void 0)return l;let c=n(e,l,{options:s,context:i});return this.set(e,c,s),c}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:s}=t,l=r(this,Y).get(e);if(l!==void 0){let c=r(this,L)[l],y=f(this,h,A).call(this,c);return s&&r(this,he).call(this,s,l),r(this,q).call(this,l)?(s&&(s.get="stale"),y?(s&&n&&c.__staleWhileFetching!==void 0&&(s.returnedStale=true),n?c.__staleWhileFetching:void 0):(a||f(this,h,be).call(this,e,"expire"),s&&n&&(s.returnedStale=true),n?c:void 0)):(s&&(s.get="hit"),y?c.__staleWhileFetching:(f(this,h,Ae).call(this,l),i&&r(this,ye).call(this,l),c))}else s&&(s.get="miss");}delete(e){return f(this,h,be).call(this,e,"delete")}clear(){return f(this,h,Je).call(this,"delete")}};X=new WeakMap,B=new WeakMap,Q=new WeakMap,ge=new WeakMap,Z=new WeakMap,Ee=new WeakMap,Ce=new WeakMap,ee=new WeakMap,F=new WeakMap,te=new WeakMap,Y=new WeakMap,M=new WeakMap,L=new WeakMap,K=new WeakMap,j=new WeakMap,G=new WeakMap,V=new WeakMap,re=new WeakMap,z=new WeakMap,ne=new WeakMap,ie=new WeakMap,$=new WeakMap,k=new WeakMap,se=new WeakMap,me=new WeakMap,W=new WeakMap,Ie=new WeakMap,h=new WeakSet,ke=function(){let e=new Le(r(this,X)),t=new Le(r(this,X));S(this,$,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,k,n),S(this,Me,(s,l,c=r(this,ee).now())=>{if(t[s]=l!==0?c:0,e[s]=l,n?.[s]&&(clearTimeout(n[s]),n[s]=void 0),l!==0&&n){let y=setTimeout(()=>{r(this,q).call(this,s)&&f(this,h,be).call(this,r(this,M)[s],"expire");},l+1);y.unref&&y.unref(),n[s]=y;}}),S(this,ye,s=>{t[s]=e[s]!==0?r(this,ee).now():0;}),S(this,he,(s,l)=>{if(e[l]){let c=e[l],y=t[l];if(!c||!y)return;s.ttl=c,s.start=y,s.now=i||a();let p=s.now-y;s.remainingTTL=c-p;}});let i=0,a=()=>{let s=r(this,ee).now();if(this.ttlResolution>0){i=s;let l=setTimeout(()=>i=0,this.ttlResolution);l.unref&&l.unref();}return s};this.getRemainingTTL=s=>{let l=r(this,Y).get(s);if(l===void 0)return 0;let c=e[l],y=t[l];if(!c||!y)return 1/0;let p=(i||a())-y;return c-p},S(this,q,s=>{let l=t[s],c=e[s];return !!c&&!!l&&(i||a())-l>c});},ye=new WeakMap,he=new WeakMap,Me=new WeakMap,q=new WeakMap,ut=function(){let e=new Le(r(this,X));S(this,te,0),S(this,ne,e),S(this,_e,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Ne,(t,n,i,a)=>{if(f(this,h,A).call(this,n))return 0;if(!de(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!de(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,we,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,h,Ye).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},_e=new WeakMap,we=new WeakMap,Ne=new WeakMap,pe=function*({allowStale:e=this.allowStale}={}){if(r(this,F))for(let t=r(this,V);!(!f(this,h,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,G)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,F))for(let t=r(this,G);!(!f(this,h,qe).call(this,t)||((e||!r(this,q).call(this,t))&&(yield t),t===r(this,V)));)t=r(this,K)[t];},qe=function(e){return e!==void 0&&r(this,Y).get(r(this,M)[e])===e},Ye=function(e){var a;let t=r(this,G),n=r(this,M)[t],i=r(this,L)[t];return r(this,me)&&f(this,h,A).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,se)||r(this,W))&&(r(this,se)&&((a=r(this,Q))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,z)?.push([i,n,"evict"])),r(this,_e).call(this,t),r(this,k)?.[t]&&(clearTimeout(r(this,k)[t]),r(this,k)[t]=void 0),e&&(r(this,M)[t]=void 0,r(this,L)[t]=void 0,r(this,re).push(t)),r(this,F)===1?(S(this,G,S(this,V,0)),r(this,re).length=0):S(this,G,r(this,K)[t]),r(this,Y).delete(n),Ue(this,F)._--,t},Fe=function(e,t,n,i){let a=t===void 0?void 0:r(this,L)[t];if(f(this,h,A).call(this,a))return a;let s=new Ve,{signal:l}=n;l?.addEventListener("abort",()=>s.abort(l.reason),{signal:s.signal});let c={signal:s.signal,options:n,context:i},y=(v,C=false)=>{let{aborted:o}=s.signal,d=n.ignoreFetchAbort&&v!==void 0,w=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&v!==void 0);if(n.status&&(o&&!C?(n.status.fetchAborted=true,n.status.fetchError=s.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),o&&!d&&!C)return E(s.signal.reason,w);let I=P,R=r(this,L)[t];return (R===P||d&&C&&R===void 0)&&(v===void 0?I.__staleWhileFetching!==void 0?r(this,L)[t]=I.__staleWhileFetching:f(this,h,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,v,c.options))),v},p=v=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=v),E(v,false)),E=(v,C)=>{let{aborted:o}=s.signal,d=o&&n.allowStaleOnFetchAbort,w=d||n.allowStaleOnFetchRejection,I=w||n.noDeleteOnFetchRejection,R=P;if(r(this,L)[t]===P&&(!I||!C&&R.__staleWhileFetching===void 0?f(this,h,be).call(this,e,"fetch"):d||(r(this,L)[t]=R.__staleWhileFetching)),w)return n.status&&R.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),R.__staleWhileFetching;if(R.__returned===R)throw v},N=(v,C)=>{var d;let o=(d=r(this,Ee))==null?void 0:d.call(this,e,a,c);o&&o instanceof Promise&&o.then(w=>v(w===void 0?void 0:w),C),s.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(v(void 0),n.allowStaleOnFetchAbort&&(v=w=>y(w,true)));});};n.status&&(n.status.fetchDispatched=true);let P=new Promise(N).then(y,p),D=Object.assign(P,{__abortController:s,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,D,{...c.options,status:void 0}),t=r(this,Y).get(e)):r(this,L)[t]=D,D},A=function(e){if(!r(this,me))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ve},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},Ae=function(e){e!==r(this,V)&&(e===r(this,G)?S(this,G,r(this,K)[e]):f(this,h,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,h,Xe).call(this,r(this,V),e),S(this,V,e));},be=function(e,t){var i,a;let n=false;if(r(this,F)!==0){let s=r(this,Y).get(e);if(s!==void 0)if(r(this,k)?.[s]&&(clearTimeout(r(this,k)?.[s]),r(this,k)[s]=void 0),n=true,r(this,F)===1)f(this,h,Je).call(this,t);else {r(this,_e).call(this,s);let l=r(this,L)[s];if(f(this,h,A).call(this,l)?l.__abortController.abort(new Error("deleted")):(r(this,se)||r(this,W))&&(r(this,se)&&((i=r(this,Q))==null||i.call(this,l,e,t)),r(this,W)&&r(this,z)?.push([l,e,t])),r(this,Y).delete(e),r(this,M)[s]=void 0,r(this,L)[s]=void 0,s===r(this,V))S(this,V,r(this,j)[s]);else if(s===r(this,G))S(this,G,r(this,K)[s]);else {let c=r(this,j)[s];r(this,K)[c]=r(this,K)[s];let y=r(this,K)[s];r(this,j)[y]=r(this,j)[s];}Ue(this,F)._--,r(this,re).push(s);}}if(r(this,W)&&r(this,z)?.length){let s=r(this,z),l;for(;l=s?.shift();)(a=r(this,Z))==null||a.call(this,...l);}return n},Je=function(e){var t,n;for(let i of f(this,h,fe).call(this,{allowStale:true})){let a=r(this,L)[i];if(f(this,h,A).call(this,a))a.__abortController.abort(new Error("deleted"));else {let s=r(this,M)[i];r(this,se)&&((t=r(this,Q))==null||t.call(this,a,s,e)),r(this,W)&&r(this,z)?.push([a,s,e]);}}if(r(this,Y).clear(),r(this,L).fill(void 0),r(this,M).fill(void 0),r(this,$)&&r(this,ie)){r(this,$).fill(0),r(this,ie).fill(0);for(let i of r(this,k)??[])i!==void 0&&clearTimeout(i);r(this,k)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,G,0),S(this,V,0),r(this,re).length=0,S(this,te,0),S(this,F,0),r(this,W)&&r(this,z)){let i=r(this,z),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}};var ze=Qe;var Oe=class{constructor(e){T(this,"cache");T(this,"map",new Map);this.cache=new ze({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){return this.cache.clear(),this.map.clear()}delete(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 Re=new Oe({cacheSize:10}),Ze;(a=>{function u(s){let l=Re.get(s);if(!l){_.error(`Label "${s}" not found`);return}return l}a.get=u;function e(s){if(Array.isArray(s)){s.forEach(l=>e(l));return}Re.has(s.id)&&_.info(`Label "${s.id}" already exists, it will be overwritten`),Re.set(s.id,s);}a.add=e;function t(){return Array.from(Re.values())}a.values=t;function n(s){return Re.has(s)}a.has=n;function i(){return Array.from(Re.keys())}a.keys=i;})(Ze||(Ze={}));var ae=Ze;var m=class m{constructor(){}static get allOpenedLabels(){return unifier.GameUnifier.getVariable(O.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){unifier.GameUnifier.setVariable(O.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=m.currentLabelStepIndex;if(t===null)return _.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=m.currentLabelId,a=m._currentLabel;if(!i||t===null||!a)return _.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let s=a.getStepSha(t)||"error",l=unifier.GameUnifier.getVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return l[i]||(l[i]={}),(!l[i][n]||l[i][n].stepSha1!=s)&&(l[i][n]={stepSha1:s}),l[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=m.currentLabelStepIndex,i=n+e,a=m.currentLabelId;if(!a||n===null){_.error("currentLabelId or currentLabelStepIndex is null");return}let s=unifier.GameUnifier.getVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[a]||(s[a]={}),s[a][i]=t,unifier.GameUnifier.setVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static getCurrentStepTimesCounter(e=""){let t=m._stepCounter,n=m.getCurrentStepTimesCounterData(e);if(!n)return _.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||n.lastStepIndexs||[];return i.find(s=>s===t)||(i.push(t),delete n.lastStepIndexs,n.stepCounters=i,m.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let s=m.getCurrentStepTimesCounterData(i);if(!s)return;let l=s.usedRandomNumbers||{},c=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!l[`${e}-${t}`]?.includes(E));if(c.length===0)return;let y=Math.floor(Math.random()*c.length),p=c[y];return l[`${e}-${t}`]||(l[`${e}-${t}`]=[]),l[`${e}-${t}`].push(p),s.usedRandomNumbers=l,m.setCurrentStepTimesCounterData(i,s),p}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=m.currentLabelStepIndex,n=t+e,i=m.currentLabelId;if(!i||t===null){_.error("currentLabelId or currentLabelStepIndex is null");return}let a=unifier.GameUnifier.getVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},unifier.GameUnifier.setVariable(O.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return unifier.GameUnifier.getVariable(O.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){unifier.GameUnifier.setVariable(O.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){m._stepCounter++;}static get openedLabels(){return le(m._openedLabels)}static set openedLabels(e){m._openedLabels=le(e);}static get originalOpenedLabels(){return le(m._originalOpenedLabels)}static set originalOpenedLabels(e){m._originalOpenedLabels=le(e);}static get _currentLabel(){if(m.currentLabelId)return ae.get(m.currentLabelId)}static get currentLabelId(){if(m._openedLabels.length>0)return m._openedLabels[m._openedLabels.length-1].label}static get currentLabelStepIndex(){return m._openedLabels.length>0?m._openedLabels[m._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=m.allOpenedLabels,i=m.allOpenedLabels[e]?.biggestStep||0,a=m.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},m.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=m.allChoicesMade,s=a.findIndex(l=>l.labelId===e&&l.stepIndex===t&&l.choiceIndex===i&&l.stepSha1===n);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[s].madeTimes++,m.allChoicesMade=a;}static pushNewLabel(e){if(!ae.get(e))throw new Error(`[Pixi\u2019VN] Label ${e} not found`);m._openedLabels.push({label:e,currentStepIndex:0});let n=m.allOpenedLabels,i=m.allOpenedLabels[e]?.biggestStep||0,a=m.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},m.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(m._openedLabels.length>0){let e=m._openedLabels[m._openedLabels.length-1];m._openedLabels[m._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static set onStepStart(e){m._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return m.onLoadingLabel&&e===0&&n.push(m.onLoadingLabel(e,t)),m._onStepStart&&n.push(m._onStepStart(e,t)),await Promise.all(n)}}};T(m,"choiceMadeTemp"),T(m,"lastHistoryStep",null),T(m,"_stepCounter",0),T(m,"_openedLabels",[]),T(m,"_originalOpenedLabels",[]),T(m,"_onStepStart"),T(m,"onLoadingLabel"),T(m,"onStepEnd");var b=m;var Pe=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,s,l,c=unifier.GameUnifier.getVariable(O.LAST_STEP_GLUED)===this.stepCounter;unifier.GameUnifier.getVariable(O.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=unifier.GameUnifier.getVariable(O.CURRENT_DIALOGUE_MEMORY_KEY)),unifier.GameUnifier.getVariable(O.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=unifier.GameUnifier.getVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY)),unifier.GameUnifier.getVariable(O.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(l=unifier.GameUnifier.getVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,p={currentLabel:b.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:l,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:c,openedLabels:y};b.originalOpenedLabels=y,unifier.GameUnifier.addHistoryItem(p,{ignoreSameStep:i}),b.lastHistoryStep=p,b.increaseStepCounter();}closeCurrentLabel(){if(!b.currentLabelId){_.warn("No label to close");return}if(!this.currentLabel){_.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,unifier.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),unifier.GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=ae.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||(_.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choices;return n&&n.length>0?(t&&_.warn("The player must make a choice"),false):this.isRequiredInput?(t&&_.warn("The player must enter a value"),false):true}get canContinue(){return unifier.GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){_.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){_.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&unifier.GameUnifier.runningStepsCount!==0){unifier.GameUnifier.increaseContinueRequest(i);return}i>1&&unifier.GameUnifier.increaseContinueRequest(i-1),unifier.GameUnifier.runningStepsCount++;let a;try{unifier.GameUnifier.runningStepsCount===1&&await unifier.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(s){throw _.error("Error continuing",s),s}finally{unifier.GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep()||a;}return a}async afterRunCurrentStep(){if(unifier.GameUnifier.runningStepsCount===0&&unifier.GameUnifier.continueRequestsCount!==0)return await unifier.GameUnifier.processNavigationRequests()}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){_.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){_.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(p){_.error("Error running onStepStart",p),this.onStepError&&await this.onStepError(p,e);return}let s=a.getStepById(i);if(!s){_.error("step not found");return}let l=a.getStepSha(i);l||(_.warn("stepSha not found, setting to ERROR"),l="error");let c,y;try{c=await s(e,{labelId:a.id});}catch(p){_.error("Error running step",p),y=p;}try{let p=this.choices;if(p?.length===1&&p[0].autoSelect){let E=p[0];c=await this.selectChoice(E,e);}}catch(p){_.error("Error auto-selecting choice",p),y===void 0&&(y=p);}try{let p=b.lastHistoryStep;n!==void 0&&p&&(l=p.stepSha1,l||(_.warn("stepSha not found, setting to ERROR"),l="error"),b.addChoicesMade(p.currentLabel||"error",typeof p.labelStepIndex=="number"?p.labelStepIndex:-1,p.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(p){_.warn("Error adding choice made to history",p);}try{unifier.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(l,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(p){_.warn("Error adding step to history",p);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(p){_.warn("Error running onStepEnd",p);}return y&&this.onStepError&&await this.onStepError(y,e),c}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1)return b.openedLabels=[],unifier.GameUnifier.onEnd?await unifier.GameUnifier.onEnd(e,{labelId:"end"}):void 0}}else if(this.openedLabels.length===0){if(b.openedLabels=b.originalOpenedLabels,unifier.GameUnifier.onEnd)return await unifier.GameUnifier.onEnd(e,{labelId:"end"});_.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.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");return}else _.error("currentLabelId not found");}async call(e,t,n){let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,unifier.GameUnifier.runningStepsCount++;let s;try{let l=ae.get(a);if(!l)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);b.pushNewLabel(l.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw _.error("Error calling label",l),l}finally{unifier.GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async jump(e,t,n){this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:i}=n||{},a;typeof e=="string"?a=e:a=e.id,unifier.GameUnifier.runningStepsCount++;let s;try{let l=ae.get(a);if(!l)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);b.pushNewLabel(l.id),s=await this.runCurrentStep(t,{choiceMade:i});}catch(l){throw _.error("Error jumping to label",l),l}finally{unifier.GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async selectChoice(e,t){this.choices=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw _.error(`Type ${n} not found`),new Error(`[Pixi\u2019VN] Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw _.error("For closeChoiceMenu, the type must be close"),new Error("[Pixi\u2019VN] 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(){let e=unifier.GameUnifier.onError;if(e)return async(t,n)=>{try{return await e("step",t,n)}catch(i){_.error("Error in onError handler",i);}}}set onStepError(e){unifier.GameUnifier.onError=(t,n,i)=>e(n,i);}get dialogue(){let e=unifier.GameUnifier.getVariable(O.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?unifier.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){unifier.GameUnifier.setVariable(O.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=unifier.GameUnifier.getVariable(O.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;}unifier.GameUnifier.setVariable(O.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{unifier.GameUnifier.setVariable(O.CURRENT_DIALOGUE_MEMORY_KEY,le({...e,character:typeof e.character=="string"?e.character:e.character?.id})),unifier.GameUnifier.setVariable(O.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw _.error("DialogueInterface cannot contain functions or classes"),t}}get choices(){let e=unifier.GameUnifier.getVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,s)=>({...a,choiceIndex:s})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,s)=>a.oneTime&&i&&i.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){unifier.GameUnifier.setVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{unifier.GameUnifier.setVariable(O.CURRENT_MENU_OPTIONS_MEMORY_KEY,le(e)),unifier.GameUnifier.setVariable(O.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw _.error("ChoiceInterface cannot contain functions or classes"),t}}get dialogGlue(){return unifier.GameUnifier.getFlag(O.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){unifier.GameUnifier.setFlag(O.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return unifier.GameUnifier.getVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),unifier.GameUnifier.setVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY,e),unifier.GameUnifier.setVariable(O.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return unifier.GameUnifier.getVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return unifier.GameUnifier.getVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,unifier.GameUnifier.setVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?unifier.GameUnifier.setVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY,t):unifier.GameUnifier.removeVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){unifier.GameUnifier.removeVariable(O.CURRENT_INPUT_INFO_MEMORY_KEY),unifier.GameUnifier.removeVariable(O.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:le(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=ae.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,e.hasOwnProperty("openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):_.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?b._stepCounter=e.stepCounter:e.hasOwnProperty("lastStepIndex")?b._stepCounter=e.lastStepIndex:_.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){_.error("Error running onLoadingLabel",n);}}catch(n){_.error("Error importing data",n);}}};function Ot(u,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:u,type:n?.type||"call"}}var et="close";function Rt(u,e){return {...e,type:et,text:u}}var ft=Et(pt());var xe=class{constructor(e,t){T(this,"id");T(this,"_onStepStart");T(this,"_onLoadingLabel");T(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var ve=class extends xe{constructor(t,n,i){super(t,i);T(this,"_steps");this._steps=n;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return _.warn("stepSha not found, setting to ERROR"),"error";try{let n=this.steps[t];return (0,ft.default)(n.toString().toLocaleLowerCase()).toString()}catch(n){return _.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(u,e,t){let n=new ve(u,e,t);return ae.add(n),n}var Or=new Pe;
|
|
2
2
|
exports.Close=et;exports.Label=ve;exports.LabelAbstract=xe;exports.NarrationManagerStatic=b;exports.RegisteredLabels=ae;exports.narration=Or;exports.newChoiceOption=Ot;exports.newCloseChoiceOption=Rt;exports.newLabel=bt;
|
package/dist/narration.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a as a$1}from'./chunk-HVEJJGVC.mjs';import'./chunk-XSN6P5JL.mjs';import {a as a$2}from'./chunk-6GO4XVS7.mjs';import {a}from'./chunk-YDXQLPAR.mjs';import {d,c,j,k}from'./chunk-GNJIUFU2.mjs';import {GameUnifier}from'@drincs/pixi-vn/unifier';var T=new a({cacheSize:10}),R;(a=>{function m(s){let u=T.get(s);if(!u){j.error(`Label "${s}" not found`);return}return u}a.get=m;function e(s){if(Array.isArray(s)){s.forEach(u=>e(u));return}T.has(s.id)&&j.info(`Label "${s.id}" already exists, it will be overwritten`),T.set(s.id,s);}a.add=e;function t(){return Array.from(T.values())}a.values=t;function r(s){return T.has(s)}a.has=r;function n(){return Array.from(T.keys())}a.keys=n;})(R||(R={}));var f=R;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(a$2.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(a$2.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return j.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n=i.currentLabelId,a=i._currentLabel;if(!n||t===null||!a)return j.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let s=a.getStepSha(t)||"error",u=GameUnifier.getVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n]||(u[n]={}),(!u[n][r]||u[n][r].stepSha1!=s)&&(u[n][r]={stepSha1:s}),u[n][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n=r+e,a=i.currentLabelId;if(!a||r===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let s=GameUnifier.getVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[a]||(s[a]={}),s[a][n]=t,GameUnifier.setVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return j.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||r.lastStepIndexs||[];return n.find(s=>s===t)||(n.push(t),delete r.lastStepIndexs,r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let s=i.getCurrentStepTimesCounterData(n);if(!s)return;let u=s.usedRandomNumbers||{},S=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!u[`${e}-${t}`]?.includes(E));if(S.length===0)return;let L=Math.floor(Math.random()*S.length),c=S[L];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(c),s.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,s),c}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n=i.currentLabelId;if(!n||t===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n]||(a[n]={}),a[n][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(a$2.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(a$2.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return k(i._openedLabels)}static set openedLabels(e){i._openedLabels=k(e);}static get originalOpenedLabels(){return k(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=k(e);}static get _currentLabel(){if(i.currentLabelId)return f.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,s=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[s].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!f.get(e))throw new Error(`[Pixi\u2019VN] 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 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)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;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}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n}=t,a,s,u,S=GameUnifier.getVariable(a$2.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(a$2.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(a$2.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=GameUnifier.getVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(a$2.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,c={currentLabel:o.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:L};o.originalOpenedLabels=L,GameUnifier.addHistoryItem(c,{ignoreSameStep:n}),o.lastHistoryStep=c,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){j.warn("No label to close");return}if(!this.currentLabel){j.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=f.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(j.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&j.warn("The player must make a choice"),false):this.isRequiredInput?(t&&j.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){j.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){j.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,t);}catch(s){throw j.error("Error continuing",s),s}finally{GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep()||a;}return a}async afterRunCurrentStep(){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests()}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){j.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){j.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(c){j.error("Error running onStepStart",c),this.onStepError&&await this.onStepError(c,e);return}let s=a.getStepById(n);if(!s){j.error("step not found");return}let u=a.getStepSha(n);u||(j.warn("stepSha not found, setting to ERROR"),u="error");let S,L;try{S=await s(e,{labelId:a.id});}catch(c){j.error("Error running step",c),L=c;}try{let c=this.choices;if(c?.length===1&&c[0].autoSelect){let E=c[0];S=await this.selectChoice(E,e);}}catch(c){j.error("Error auto-selecting choice",c),L===void 0&&(L=c);}try{let c=o.lastHistoryStep;r!==void 0&&c&&(u=c.stepSha1,u||(j.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(c.currentLabel||"error",typeof c.labelStepIndex=="number"?c.labelStepIndex:-1,c.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(c){j.warn("Error adding choice made to history",c);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(c){j.warn("Error adding step to history",c);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(c){j.warn("Error running onStepEnd",c);}return L&&this.onStepError&&await this.onStepError(L,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1)return o.openedLabels=[],GameUnifier.onEnd?await GameUnifier.onEnd(e,{labelId:"end"}):void 0}}else if(this.openedLabels.length===0){if(o.openedLabels=o.originalOpenedLabels,GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});j.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.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");return}else j.error("currentLabelId not found");}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let s;try{let u=f.get(a);if(!u)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);o.pushNewLabel(u.id),s=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error calling label",u),u}finally{GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async jump(e,t,r){this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let s;try{let u=f.get(a);if(!u)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);o.pushNewLabel(u.id),s=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error jumping to label",u),u}finally{GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async selectChoice(e,t){this.choices=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 j.error(`Type ${r} not found`),new Error(`[Pixi\u2019VN] Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw j.error("For closeChoiceMenu, the type must be close"),new Error("[Pixi\u2019VN] 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(){let e=GameUnifier.onError;if(e)return async(t,r)=>{try{return await e("step",t,r)}catch(n){j.error("Error in onError handler",n);}}}set onStepError(e){GameUnifier.onError=(t,r,n)=>e(r,n);}get dialogue(){let e=GameUnifier.getVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(a$2.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;}GameUnifier.setVariable(a$2.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY,k({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(a$2.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw j.error("DialogueInterface cannot contain functions or classes"),t}}get choices(){let e=GameUnifier.getVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,s)=>({...a,choiceIndex:s})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,s)=>a.oneTime&&n&&n.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY,k(e)),GameUnifier.setVariable(a$2.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw j.error("ChoiceInterface cannot contain functions or classes"),t}}get dialogGlue(){return GameUnifier.getFlag(a$2.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(a$2.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(a$2.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:k(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=f.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,e.hasOwnProperty("openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):j.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?o._stepCounter=e.stepCounter:e.hasOwnProperty("lastStepIndex")?o._stepCounter=e.lastStepIndex:j.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){j.error("Error running onLoadingLabel",r);}}catch(r){j.error("Error importing data",r);}}};function D(m,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:m,type:r?.type||"call"}}var _="close";function v(m,e){return {...e,type:_,text:m}}var M=c(a$1(),1);var C=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var I=class extends C{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return j.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,M.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return j.warn("stepSha not found, setting to ERROR",r),"error"}}};function x(m,e,t){let r=new I(m,e,t);return f.add(r),r}var Se=new g;
|
|
1
|
+
import {a as a$1}from'./chunk-HVEJJGVC.mjs';import'./chunk-XSN6P5JL.mjs';import {a as a$2}from'./chunk-6GO4XVS7.mjs';import {a}from'./chunk-GFG3MDHE.mjs';import {d,c,j,k}from'./chunk-GNJIUFU2.mjs';import {GameUnifier}from'@drincs/pixi-vn/unifier';var T=new a({cacheSize:10}),R;(a=>{function m(s){let u=T.get(s);if(!u){j.error(`Label "${s}" not found`);return}return u}a.get=m;function e(s){if(Array.isArray(s)){s.forEach(u=>e(u));return}T.has(s.id)&&j.info(`Label "${s.id}" already exists, it will be overwritten`),T.set(s.id,s);}a.add=e;function t(){return Array.from(T.values())}a.values=t;function r(s){return T.has(s)}a.has=r;function n(){return Array.from(T.keys())}a.keys=n;})(R||(R={}));var f=R;var i=class i{constructor(){}static get allOpenedLabels(){return GameUnifier.getVariable(a$2.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(a$2.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return j.error("currentLabelStepIndex is null"),null;let r=`${t}${e}`,n=i.currentLabelId,a=i._currentLabel;if(!n||t===null||!a)return j.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let s=a.getStepSha(t)||"error",u=GameUnifier.getVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return u[n]||(u[n]={}),(!u[n][r]||u[n][r].stepSha1!=s)&&(u[n][r]={stepSha1:s}),u[n][r]}static setCurrentStepTimesCounterData(e="",t){let r=i.currentLabelStepIndex,n=r+e,a=i.currentLabelId;if(!a||r===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let s=GameUnifier.getVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY)||{};s[a]||(s[a]={}),s[a][n]=t,GameUnifier.setVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY,s);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e);if(!r)return j.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||r.lastStepIndexs||[];return n.find(s=>s===t)||(n.push(t),delete r.lastStepIndexs,r.stepCounters=n,i.setCurrentStepTimesCounterData(e,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let s=i.getCurrentStepTimesCounterData(n);if(!s)return;let u=s.usedRandomNumbers||{},S=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!u[`${e}-${t}`]?.includes(E));if(S.length===0)return;let L=Math.floor(Math.random()*S.length),c=S[L];return u[`${e}-${t}`]||(u[`${e}-${t}`]=[]),u[`${e}-${t}`].push(c),s.usedRandomNumbers=u,i.setCurrentStepTimesCounterData(n,s),c}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r=t+e,n=i.currentLabelId;if(!n||t===null){j.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n]||(a[n]={}),a[n][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(a$2.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(a$2.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(a$2.ALL_CHOICES_MADE_KEY,e);}static increaseStepCounter(){i._stepCounter++;}static get openedLabels(){return k(i._openedLabels)}static set openedLabels(e){i._openedLabels=k(e);}static get originalOpenedLabels(){return k(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=k(e);}static get _currentLabel(){if(i.currentLabelId)return f.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,s=a.findIndex(u=>u.labelId===e&&u.stepIndex===t&&u.choiceIndex===n&&u.stepSha1===r);s<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[s].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!f.get(e))throw new Error(`[Pixi\u2019VN] 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 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)}}};d(i,"choiceMadeTemp"),d(i,"lastHistoryStep",null),d(i,"_stepCounter",0),d(i,"_openedLabels",[]),d(i,"_originalOpenedLabels",[]),d(i,"_onStepStart"),d(i,"onLoadingLabel"),d(i,"onStepEnd");var o=i;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}addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n}=t,a,s,u,S=GameUnifier.getVariable(a$2.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(a$2.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(a$2.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(s=GameUnifier.getVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(a$2.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(u=GameUnifier.getVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,c={currentLabel:o.currentLabelId,dialogue:a,choices:s,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:u,alreadyMadeChoices:this.alreadyCurrentStepMadeChoices,isGlued:S,openedLabels:L};o.originalOpenedLabels=L,GameUnifier.addHistoryItem(c,{ignoreSameStep:n}),o.lastHistoryStep=c,o.increaseStepCounter();}closeCurrentLabel(){if(!o.currentLabelId){j.warn("No label to close");return}if(!this.currentLabel){j.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=f.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r=t.getStepSha(e);return r||(j.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,r=this.choices;return r&&r.length>0?(t&&j.warn("The player must make a choice"),false):this.isRequiredInput?(t&&j.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){j.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){j.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,t);}catch(s){throw j.error("Error continuing",s),s}finally{GameUnifier.runningStepsCount--,a=await this.afterRunCurrentStep()||a;}return a}async afterRunCurrentStep(){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests()}async runCurrentStep(e,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){j.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){j.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(c){j.error("Error running onStepStart",c),this.onStepError&&await this.onStepError(c,e);return}let s=a.getStepById(n);if(!s){j.error("step not found");return}let u=a.getStepSha(n);u||(j.warn("stepSha not found, setting to ERROR"),u="error");let S,L;try{S=await s(e,{labelId:a.id});}catch(c){j.error("Error running step",c),L=c;}try{let c=this.choices;if(c?.length===1&&c[0].autoSelect){let E=c[0];S=await this.selectChoice(E,e);}}catch(c){j.error("Error auto-selecting choice",c),L===void 0&&(L=c);}try{let c=o.lastHistoryStep;r!==void 0&&c&&(u=c.stepSha1,u||(j.warn("stepSha not found, setting to ERROR"),u="error"),o.addChoicesMade(c.currentLabel||"error",typeof c.labelStepIndex=="number"?c.labelStepIndex:-1,c.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(c){j.warn("Error adding choice made to history",c);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),this.addStepHistory(u,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(c){j.warn("Error adding step to history",c);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(c){j.warn("Error running onStepEnd",c);}return L&&this.onStepError&&await this.onStepError(L,e),S}else {if(this.openedLabels.length>1)return this.closeCurrentLabel(),await this.continue(e,t);if(this.openedLabels.length===1)return o.openedLabels=[],GameUnifier.onEnd?await GameUnifier.onEnd(e,{labelId:"end"}):void 0}}else if(this.openedLabels.length===0){if(o.openedLabels=o.originalOpenedLabels,GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});j.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.web.app/start/other-narrative-features.html#how-manage-the-end-of-the-game");return}else j.error("currentLabelId not found");}async call(e,t,r){let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let s;try{let u=f.get(a);if(!u)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);o.pushNewLabel(u.id),s=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error calling label",u),u}finally{GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async jump(e,t,r){this.openedLabels.length>0&&this.closeCurrentLabel();let{choiceMade:n}=r||{},a;typeof e=="string"?a=e:a=e.id,GameUnifier.runningStepsCount++;let s;try{let u=f.get(a);if(!u)throw new Error(`[Pixi\u2019VN] Label ${a} not found`);o.pushNewLabel(u.id),s=await this.runCurrentStep(t,{choiceMade:n});}catch(u){throw j.error("Error jumping to label",u),u}finally{GameUnifier.runningStepsCount--,s=await this.afterRunCurrentStep()||s;}return s}async selectChoice(e,t){this.choices=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 j.error(`Type ${r} not found`),new Error(`[Pixi\u2019VN] Type ${r} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw j.error("For closeChoiceMenu, the type must be close"),new Error("[Pixi\u2019VN] 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(){let e=GameUnifier.onError;if(e)return async(t,r)=>{try{return await e("step",t,r)}catch(n){j.error("Error in onError handler",n);}}}set onStepError(e){GameUnifier.onError=(t,r,n)=>e(r,n);}get dialogue(){let e=GameUnifier.getVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(a$2.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;}GameUnifier.setVariable(a$2.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(a$2.CURRENT_DIALOGUE_MEMORY_KEY,k({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(a$2.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw j.error("DialogueInterface cannot contain functions or classes"),t}}get choices(){let e=GameUnifier.getVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,s)=>({...a,choiceIndex:s})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,s)=>a.oneTime&&n&&n.includes(s)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choices(e){if(!e||e.length===0){GameUnifier.setVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(a$2.CURRENT_MENU_OPTIONS_MEMORY_KEY,k(e)),GameUnifier.setVariable(a$2.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch(t){throw j.error("ChoiceInterface cannot contain functions or classes"),t}}get dialogGlue(){return GameUnifier.getFlag(a$2.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(a$2.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(a$2.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e,t){e.isRequired=true,GameUnifier.setVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(a$2.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(a$2.CURRENT_INPUT_VALUE_MEMORY_KEY);}clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:k(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=f.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,e.hasOwnProperty("openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):j.warn("Could not import openedLabels data, so will be ignored"),e.hasOwnProperty("stepCounter")?o._stepCounter=e.stepCounter:e.hasOwnProperty("lastStepIndex")?o._stepCounter=e.lastStepIndex:j.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){j.error("Error running onLoadingLabel",r);}}catch(r){j.error("Error importing data",r);}}};function D(m,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:m,type:r?.type||"call"}}var _="close";function v(m,e){return {...e,type:_,text:m}}var M=c(a$1(),1);var C=class{constructor(e,t){d(this,"id");d(this,"_onStepStart");d(this,"_onLoadingLabel");d(this,"_onStepEnd");this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}get onLoadingLabel(){return this._onLoadingLabel}get onStepEnd(){return this._onStepEnd}};var I=class extends C{constructor(t,r,n){super(t,n);d(this,"_steps");this._steps=r;}get stepCount(){return this.steps.length}getStepById(t){return this.steps[t]}get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(t){if(t<0||t>=this.steps.length)return j.warn("stepSha not found, setting to ERROR"),"error";try{let r=this.steps[t];return (0,M.default)(r.toString().toLocaleLowerCase()).toString()}catch(r){return j.warn("stepSha not found, setting to ERROR",r),"error"}}};function x(m,e,t){let r=new I(m,e,t);return f.add(r),r}var Se=new g;
|
|
2
2
|
export{_ as Close,I as Label,C as LabelAbstract,o as NarrationManagerStatic,f as RegisteredLabels,Se as narration,D as newChoiceOption,v as newCloseChoiceOption,x as newLabel};
|
package/dist/pixi.d.ts
ADDED