@drincs/pixi-vn 1.6.4 → 1.7.2

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