@drincs/pixi-vn 1.9.2 → 1.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{ContainerMemory-BpDgacyr.d.cts → ContainerMemory-DNqSVzLY.d.cts} +12 -116
- package/dist/{ContainerMemory-BpDgacyr.d.ts → ContainerMemory-DNqSVzLY.d.ts} +12 -116
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +1279 -551
- package/dist/canvas.d.ts +1279 -551
- package/dist/canvas.mjs +2 -2
- package/dist/characters.cjs +1 -1
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-6GLWL3NH.mjs → chunk-5MVDNAT4.mjs} +1 -1
- package/dist/chunk-6OABTG5R.mjs +1 -0
- package/dist/chunk-AW5XWF24.mjs +1 -0
- package/dist/chunk-LXIKP2K5.mjs +1 -0
- package/dist/chunk-S7HZUIEI.mjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +61 -5
- package/dist/core.d.ts +61 -5
- package/dist/core.mjs +1 -1
- package/dist/filters.cjs +1 -0
- package/dist/filters.d.cts +182 -0
- package/dist/filters.d.ts +182 -0
- package/dist/filters.mjs +1 -0
- package/dist/history.cjs +1 -1
- package/dist/history.d.cts +2 -2
- package/dist/history.d.ts +2 -2
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +30 -8
- package/dist/motion.d.ts +30 -8
- package/dist/motion.mjs +1 -1
- package/dist/narration.cjs +1 -1
- package/dist/narration.d.cts +2 -1
- package/dist/narration.d.ts +2 -1
- package/dist/narration.mjs +1 -1
- package/dist/pixi/browser.js +170 -169
- package/dist/sound.mjs +1 -1
- package/dist/storage.cjs +1 -1
- package/dist/storage.d.cts +1 -1
- package/dist/storage.d.ts +1 -1
- package/dist/storage.mjs +1 -1
- package/dist/tickers.cjs +1 -0
- package/dist/tickers.d.cts +555 -0
- package/dist/tickers.d.ts +555 -0
- package/dist/tickers.mjs +1 -0
- package/dist/vite.cjs +6 -4
- package/dist/vite.d.cts +64 -0
- package/dist/vite.d.ts +64 -0
- package/dist/vite.mjs +6 -4
- package/dist/worker.cjs +1 -0
- package/dist/worker.d.cts +153 -0
- package/dist/worker.d.ts +153 -0
- package/dist/worker.mjs +1 -0
- package/package.json +28 -1
- package/dist/chunk-HQQ5WH6C.mjs +0 -1
- package/dist/chunk-I7DOUH5V.mjs +0 -1
package/dist/motion.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var canvas=require('@drincs/pixi-vn/canvas'),H=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 H__default=/*#__PURE__*/_interopDefault(H);var G=Object.create;var z=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var q=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,a)=>(typeof require<"u"?require:e)[a]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var D=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var nt=(s,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Z(e))!et.call(s,n)&&n!==a&&z(s,n,{get:()=>e[n],enumerable:!(i=Q(e,n))||i.enumerable});return s};var it=(s,e,a)=>(a=s!=null?G(tt(s)):{},nt(z(a,"default",{value:s,enumerable:true}),s));var X=D((W,U)=>{(function(s,e){typeof W=="object"?U.exports=W=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(W,function(){var s=s||(function(e,a){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 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.")},o=Object.create||(function(){function t(){}return function(r){var m;return t.prototype=r,m=new t,t.prototype=null,m}})(),c={},u=c.lib={},h=u.Base=(function(){return {extend:function(t){var r=o(this);return t&&r.mixIn(t),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments);}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),l=u.WordArray=h.extend({init:function(t,r){t=this.words=t||[],r!=a?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||v).stringify(this)},concat:function(t){var r=this.words,m=t.words,p=this.sigBytes,y=t.sigBytes;if(this.clamp(),p%4)for(var g=0;g<y;g++){var k=m[g>>>2]>>>24-g%4*8&255;r[p+g>>>2]|=k<<24-(p+g)%4*8;}else for(var O=0;O<y;O+=4)r[p+O>>>2]=m[O>>>2];return this.sigBytes+=y,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],m=0;m<t;m+=4)r.push(n());return new l.init(r,t)}}),f=c.enc={},v=f.Hex={stringify:function(t){for(var r=t.words,m=t.sigBytes,p=[],y=0;y<m;y++){var g=r[y>>>2]>>>24-y%4*8&255;p.push((g>>>4).toString(16)),p.push((g&15).toString(16));}return p.join("")},parse:function(t){for(var r=t.length,m=[],p=0;p<r;p+=2)m[p>>>3]|=parseInt(t.substr(p,2),16)<<24-p%8*4;return new l.init(m,r/2)}},A=f.Latin1={stringify:function(t){for(var r=t.words,m=t.sigBytes,p=[],y=0;y<m;y++){var g=r[y>>>2]>>>24-y%4*8&255;p.push(String.fromCharCode(g));}return p.join("")},parse:function(t){for(var r=t.length,m=[],p=0;p<r;p++)m[p>>>2]|=(t.charCodeAt(p)&255)<<24-p%4*8;return new l.init(m,r)}},b=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(A.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return A.parse(unescape(encodeURIComponent(t)))}},x=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new l.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=b.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,m=this._data,p=m.words,y=m.sigBytes,g=this.blockSize,k=g*4,O=y/k;t?O=e.ceil(O):O=e.max((O|0)-this._minBufferSize,0);var S=O*g,_=e.min(S*4,y);if(S){for(var E=0;E<S;E+=g)this._doProcessBlock(p,E);r=p.splice(0,S),m.sigBytes-=_;}return new l.init(r,_)},clone:function(){var t=h.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=x.extend({cfg:h.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 r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,m){return new t.init(m).finalize(r)}},_createHmacHelper:function(t){return function(r,m){return new d.HMAC.init(t,m).finalize(r)}}});var d=c.algo={};return c})(Math);return s});});var K=D((R,$)=>{(function(s,e){typeof R=="object"?$.exports=R=e(X()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(R,function(s){return (function(){var e=s,a=e.lib,i=a.WordArray,n=a.Hasher,o=e.algo,c=[],u=o.SHA1=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,l){for(var f=this._hash.words,v=f[0],A=f[1],b=f[2],x=f[3],T=f[4],d=0;d<80;d++){if(d<16)c[d]=h[l+d]|0;else {var t=c[d-3]^c[d-8]^c[d-14]^c[d-16];c[d]=t<<1|t>>>31;}var r=(v<<5|v>>>27)+T+c[d];d<20?r+=(A&b|~A&x)+1518500249:d<40?r+=(A^b^x)+1859775393:d<60?r+=(A&b|A&x|b&x)-1894007588:r+=(A^b^x)-899497514,T=x,x=b,b=A<<30|A>>>2,A=v,v=r;}f[0]=f[0]+v|0,f[1]=f[1]+A|0,f[2]=f[2]+b|0,f[3]=f[3]+x|0,f[4]=f[4]+T|0;},_doFinalize:function(){var h=this._data,l=h.words,f=this._nDataBytes*8,v=h.sigBytes*8;return l[v>>>5]|=128<<24-v%32,l[(v+64>>>9<<4)+14]=Math.floor(f/4294967296),l[(v+64>>>9<<4)+15]=f,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(u),e.HmacSHA1=n._createHmacHelper(u);})(),s.SHA1});});var j=s=>e=>{let a=({lastTime:i})=>e(i);return {start:(i=true)=>{s.add(a),s.start();},stop:()=>s.remove(a),now:()=>s.lastTime}};function B(s,e,a){if(Array.isArray(s)&&Array.isArray(s[0])){e&&"repeat"in e&&e?.repeat===null&&(e.repeat=1/0),s.forEach(c=>{if(Array.isArray(c)&&c.length===3){let[u,h,l]=c;l&&"repeat"in l&&l?.repeat===null&&(l.repeat=1/0);}});let{ticker:i=new H__default.default.Ticker,driver:n=j(i),...o}=e||{};return motion.animate(s,{driver:n,...o})}else {a&&"repeat"in a&&a?.repeat===null&&(a.repeat=1/0);let{ticker:i=new H__default.default.Ticker,driver:n=j(i),...o}=a||{};return motion.animate(s,e,{driver:n,...o})}}function rt(s,e){let{ticker:a=new H__default.default.Ticker,driver:i=j(a),repeat:n,...o}=e||{},c={x:0},u=[],h=[],l=0;s.forEach((b,x)=>{let{onComplete:T,onPlay:d,delay:t=0,duration:r=.3,...m}=b,p=typeof t=="function"?t(0,1):t,y=l+p,g=y+r;u.push({start:y,end:g,onPlay:d,onComplete:T}),h.push([c,{x:x+1},{...m,delay:t,duration:r}]),l=g;});let f=l,v=B(h,{...o,repeat:n,driver:i});if(u.length>0&&f>0){let k=function(){if(r)return;for(t+=a.deltaMS/1e3;!r&&t>=f;){if(p(),d++,d>=x){g();return}t-=f;}let S=y(t);S===-1?T>=0&&p():S!==T&&m(S);};let b=n===null?1/0:n,x=b===void 0?1:b+1,T=-1,d=0,t=0,r=false,m=S=>{T>=0&&u[T].onComplete?.(),T=S,u[T].onPlay?.();},p=()=>{T>=0&&u[T].onComplete?.(),T=-1;},y=S=>{for(let _=0;_<u.length;_++){if(S<u[_].start)return -1;if(S<u[_].end)return _}return u.length-1},g=()=>{r=true,a.remove(k);};a.add(k);let O=v.stop.bind(v);v.stop=()=>{g(),O();};}return v}var N=it(K());var C=class{constructor(e,a){let{duration:i,priority:n,id:o=this.generateTickerId(a),canvasElementAliases:c=[]}=a||{};this._args=e,this.duration=i,this.priority=n,this.id=o,this.canvasElementAliases=c;}id;_args;get args(){return {...this._args,time:this._animation?.time}}duration;priority;ticker=new H__default.default.Ticker;_animation;stopped=false;_paused=false;canvasElementAliases=[];getItemByAlias(e){if(!this.canvasElementAliases.includes(e))return;let a=canvas.canvas.find(e);if(a)return a}generateTickerId(...e){try{return (0,N.default)(JSON.stringify(e)).toString()+"_motion_"+Math.random().toString(36).substring(7)}catch(a){throw new core.PixiError("not_json_serializable",`Error to generate ticker id: ${a}`)}}timeout=50;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());}onComplete=()=>{let e=this.id,a=this._args.options?.aliasToRemoveAfter||[];typeof a=="string"&&(a=[a]);let i=this._args.options?.tickerAliasToResume||[];typeof i=="string"&&(i=[i]);let n=this._args.options?.tickerIdToResume||[];typeof n=="string"&&(n=[n]),canvas.canvas.tickers.onComplete(e,{aliasToRemoveAfter:a,tickerAliasToResume:i,tickerIdToResume:n,stopTicker:false});};createItem(e){return new Proxy({alias:e},{set:({alias:a},i,n)=>{if(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===n)return true;let o=this.getItemByAlias(a);if(!o)return true;switch(i){case "pivotX":o.pivot.x=n;break;case "pivotY":o.pivot.y=n;break;case "scaleX":o.scale.x=n;break;case "scaleY":o.scale.y=n;break;default:o[i]=n;break}return true},get:({alias:a},i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let n=this.getItemByAlias(a);if(!n)return;let o;switch(i){case "pivotX":o=n.pivot.x;break;case "pivotY":o=n.pivot.y;break;case "scaleX":o=n.scale.x;break;case "scaleY":o=n.scale.y;break;default:o=n[i];break}return this._args.startState={...this._args.startState,[i]:o},o},has:({alias:a},i)=>{let n=this.getItemByAlias(a);if(!n)return false;switch(i){case "pivotX":return "pivot"in n&&"x"in n.pivot;case "pivotY":return "pivot"in n&&"y"in n.pivot;case "scaleX":return "scale"in n&&"x"in n.scale;case "scaleY":return "scale"in n&&"y"in n.scale;default:return i in n}},ownKeys:({alias:a})=>{let i=this.getItemByAlias(a);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 I=class extends C{get animation(){let e=this._animation;if(e)return e;let a=this.canvasElementAliases[0],i=this.createItem(a),n=this._args.sequence.map((o,c)=>[i,o[0],{...o[1]||{},ticker:this.ticker,onComplete:c===this._args.sequence.length-1?()=>this.onComplete():void 0}]);return e=B(n,this._args.options),this._args.time&&(this.animation.time=this._args.time),this._animation=e,e}alias="motion-sequence"};var w=class extends C{get animation(){let e=this._animation;if(e)return e;let a=this.canvasElementAliases.map(i=>this.createItem(i));return e=B(a,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker}),this._args.time&&(e.time=this._args.time),this._animation=e,e}alias="motion"};var P;(n=>(n.log=(o,...c)=>console.log(`[Pixi\u2019VN] ${o}`,...c),n.warn=(o,...c)=>console.warn(`[Pixi\u2019VN] ${o}`,...c),n.error=(o,...c)=>console.error(`[Pixi\u2019VN] ${o}`,...c),n.info=(o,...c)=>console.info(`[Pixi\u2019VN] ${o}`,...c)))(P||={});function M(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw P.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var F;(e=>{function s(a,i,n,o){try{i=M(i);}catch(f){throw P.error("animate keyframes cannot contain functions or classes"),f}try{n=M(n);}catch(f){throw P.error("animate options cannot contain functions or classes"),f}let c=[];typeof a=="string"?c=[a]:Array.isArray(a)?c=a.map(f=>typeof f=="string"?f:f.label):c=[a.label];let u;Array.isArray(i)?u=new I({sequence:i,options:n},{priority:o,canvasElementAliases:c}):u=new w({keyframes:i,options:n},{priority:o,canvasElementAliases:c});let h=canvas.canvas.tickers.add(c,u),{completeOnContinue:l}=n||{};return h&&l&&canvas.canvas.tickers.completeOnStepEnd({id:h}),h}e.animate=s;})(F||={});var ct=F;canvas.RegisteredTickers.add(w,"motion");canvas.RegisteredTickers.add(I,"motion-sequence");exports.animate=B;exports.motion=ct;exports.motionDriver=j;exports.timeline=rt;
|
|
1
|
+
'use strict';var tickers=require('@drincs/pixi-vn/tickers'),U=require('@drincs/pixi-vn/pixi.js'),motion=require('motion'),canvas=require('@drincs/pixi-vn/canvas'),core=require('@drincs/pixi-vn/core');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var U__default=/*#__PURE__*/_interopDefault(U);var it=Object.create;var X=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var M=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var $=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var ot=(o,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of rt(t))!at.call(o,e)&&e!==r&&X(o,e,{get:()=>t[e],enumerable:!(i=nt(t,e))||i.enumerable});return o};var N=(o,t,r)=>(r=o!=null?it(st(o)):{},ot(X(r,"default",{value:o,enumerable:true}),o));var L=$((F,K)=>{(function(o,t){typeof F=="object"?K.exports=F=t():typeof define=="function"&&define.amd?define([],t):o.CryptoJS=t();})(F,function(){var o=o||(function(t,r){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 M=="function")try{i=M("crypto");}catch{}var e=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.")},a=Object.create||(function(){function n(){}return function(s){var d;return n.prototype=s,d=new n,n.prototype=null,d}})(),c={},l=c.lib={},h=l.Base=(function(){return {extend:function(n){var s=a(this);return n&&s.mixIn(n),(!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 n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var s in n)n.hasOwnProperty(s)&&(this[s]=n[s]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),u=l.WordArray=h.extend({init:function(n,s){n=this.words=n||[],s!=r?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||m).stringify(this)},concat:function(n){var s=this.words,d=n.words,f=this.sigBytes,v=n.sigBytes;if(this.clamp(),f%4)for(var T=0;T<v;T++){var I=d[T>>>2]>>>24-T%4*8&255;s[f+T>>>2]|=I<<24-(f+T)%4*8;}else for(var k=0;k<v;k+=4)s[f+k>>>2]=d[k>>>2];return this.sigBytes+=v,this},clamp:function(){var n=this.words,s=this.sigBytes;n[s>>>2]&=4294967295<<32-s%4*8,n.length=t.ceil(s/4);},clone:function(){var n=h.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],d=0;d<n;d+=4)s.push(e());return new u.init(s,n)}}),p=c.enc={},m=p.Hex={stringify:function(n){for(var s=n.words,d=n.sigBytes,f=[],v=0;v<d;v++){var T=s[v>>>2]>>>24-v%4*8&255;f.push((T>>>4).toString(16)),f.push((T&15).toString(16));}return f.join("")},parse:function(n){for(var s=n.length,d=[],f=0;f<s;f+=2)d[f>>>3]|=parseInt(n.substr(f,2),16)<<24-f%8*4;return new u.init(d,s/2)}},b=p.Latin1={stringify:function(n){for(var s=n.words,d=n.sigBytes,f=[],v=0;v<d;v++){var T=s[v>>>2]>>>24-v%4*8&255;f.push(String.fromCharCode(T));}return f.join("")},parse:function(n){for(var s=n.length,d=[],f=0;f<s;f++)d[f>>>2]|=(n.charCodeAt(f)&255)<<24-f%4*8;return new u.init(d,s)}},A=p.Utf8={stringify:function(n){try{return decodeURIComponent(escape(b.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return b.parse(unescape(encodeURIComponent(n)))}},_=l.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=A.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var s,d=this._data,f=d.words,v=d.sigBytes,T=this.blockSize,I=T*4,k=v/I;n?k=t.ceil(k):k=t.max((k|0)-this._minBufferSize,0);var x=k*T,S=t.min(x*4,v);if(x){for(var D=0;D<x;D+=T)this._doProcessBlock(f,D);s=f.splice(0,x),d.sigBytes-=S;}return new u.init(s,S)},clone:function(){var n=h.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});l.Hasher=_.extend({cfg:h.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){_.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var s=this._doFinalize();return s},blockSize:512/32,_createHelper:function(n){return function(s,d){return new n.init(d).finalize(s)}},_createHmacHelper:function(n){return function(s,d){return new y.HMAC.init(n,d).finalize(s)}}});var y=c.algo={};return c})(Math);return o});});var Y=$((q,V)=>{(function(o,t){typeof q=="object"?V.exports=q=t(L()):typeof define=="function"&&define.amd?define(["./core"],t):t(o.CryptoJS);})(q,function(o){return (function(){var t=o,r=t.lib,i=r.WordArray,e=r.Hasher,a=t.algo,c=[],l=a.SHA1=e.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,u){for(var p=this._hash.words,m=p[0],b=p[1],A=p[2],_=p[3],g=p[4],y=0;y<80;y++){if(y<16)c[y]=h[u+y]|0;else {var n=c[y-3]^c[y-8]^c[y-14]^c[y-16];c[y]=n<<1|n>>>31;}var s=(m<<5|m>>>27)+g+c[y];y<20?s+=(b&A|~b&_)+1518500249:y<40?s+=(b^A^_)+1859775393:y<60?s+=(b&A|b&_|A&_)-1894007588:s+=(b^A^_)-899497514,g=_,_=A,A=b<<30|b>>>2,b=m,m=s;}p[0]=p[0]+m|0,p[1]=p[1]+b|0,p[2]=p[2]+A|0,p[3]=p[3]+_|0,p[4]=p[4]+g|0;},_doFinalize:function(){var h=this._data,u=h.words,p=this._nDataBytes*8,m=h.sigBytes*8;return u[m>>>5]|=128<<24-m%32,u[(m+64>>>9<<4)+14]=Math.floor(p/4294967296),u[(m+64>>>9<<4)+15]=p,h.sigBytes=u.length*4,this._process(),this._hash},clone:function(){var h=e.clone.call(this);return h._hash=this._hash.clone(),h}});t.SHA1=e._createHelper(l),t.HmacSHA1=e._createHmacHelper(l);})(),o.SHA1});});var E=o=>t=>{let r=({lastTime:i})=>t(i);return {start:(i=true)=>{o.add(r),o.start();},stop:()=>o.remove(r),now:()=>o.lastTime}};function O(o,t,r){if(Array.isArray(o)&&Array.isArray(o[0])){t&&"repeat"in t&&t?.repeat===null&&(t.repeat=1/0),o.forEach(c=>{if(Array.isArray(c)&&c.length===3){let[l,h,u]=c;u&&"repeat"in u&&u?.repeat===null&&(u.repeat=1/0);}});let{ticker:i=new U__default.default.Ticker,driver:e=E(i),...a}=t||{};return motion.animate(o,{driver:e,...a})}else {r&&"repeat"in r&&r?.repeat===null&&(r.repeat=1/0);let{ticker:i=new U__default.default.Ticker,driver:e=E(i),...a}=r||{};return motion.animate(o,t,{driver:e,...a})}}function ct(o,t){let{ticker:r=new U__default.default.Ticker,driver:i=E(r),repeat:e,...a}=t||{},c={x:0},l=[],h=[],u=0;o.forEach((A,_)=>{let{onComplete:g,onPlay:y,delay:n=0,duration:s=.3,...d}=A,f=typeof n=="function"?n(0,1):n,v=u+f,T=v+s;l.push({start:v,end:T,onPlay:y,onComplete:g}),h.push([c,{x:_+1},{...d,delay:n,duration:s}]),u=T;});let p=u,m=O(h,{...a,repeat:e,driver:i});if(l.length>0&&p>0){let I=function(){if(s)return;for(n+=r.deltaMS/1e3;!s&&n>=p;){if(f(),y++,y>=_){T();return}n-=p;}let x=v(n);x===-1?g>=0&&f():x!==g&&d(x);};let A=e===null?1/0:e,_=A===void 0?1:A+1,g=-1,y=0,n=0,s=false,d=x=>{g>=0&&l[g].onComplete?.(),g=x,l[g].onPlay?.();},f=()=>{g>=0&&l[g].onComplete?.(),g=-1;},v=x=>{for(let S=0;S<l.length;S++){if(x<l[S].start)return -1;if(x<l[S].end)return S}return l.length-1},T=()=>{s=true,r.remove(I);};r.add(I);let k=m.stop.bind(m);m.stop=()=>{T(),k();};}return m}var Z=N(Y());var j=class o{constructor(t,r){let{filter:i,apply:e,duration:a,priority:c,id:l=this.generateTickerId(t),canvasElementAliases:h=[],cleanup:u}=r||{},p=i?void 0:o.resolveFilterRef(t.filterRef),m=i??p;if(!m&&!e)throw new core.PixiError("not_implemented","MotionFilterTicker requires either a `filter` instance, an `apply` callback, or a resolvable `filterRef`; it cannot be reconstructed from saved/serialized ticker args.");this._args=t,this.filter=m,this.apply=e,this.duration=a,this.priority=c,this.id=l,this.canvasElementAliases=h;let b=p&&t.filterRef?.detach?t.filterRef.alias:void 0;this.cleanup=u??(b&&p?()=>o.detachFilter(b,p):void 0);}id;filter;apply;cleanup;_args;static resolveFilterRef(t){if(t)return o.componentFilters(t.alias)[t.index]}static componentFilters(t){let r=canvas.canvas.find(t)?.filters;return r?Array.isArray(r)?[...r]:[r]:[]}static detachFilter(t,r){let i=canvas.canvas.find(t);if(i){let e=o.componentFilters(t).filter(a=>a!==r);i.filters=e.length>0?e:null;}r.destroy();}get args(){let t=this._args.filterRef;if(t&&this.filter){let r=o.componentFilters(t.alias).indexOf(this.filter);r!==-1&&(t={...t,index:r});}return {...this._args,filterRef:t,time:this._animation?.time}}duration;priority;ticker=new U__default.default.Ticker;_animation;stopped=false;_paused=false;suppressWritesDuring(t){let r=this._paused;this._paused=true;try{return t()}finally{this._paused=r;}}canvasElementAliases=[];generateTickerId(...t){try{return (0,Z.default)(JSON.stringify(t)).toString()+"_motion_filter_"+Math.random().toString(36).substring(7)}catch(r){throw new core.PixiError("not_json_serializable",`Error to generate ticker id: ${r}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(t=>setTimeout(t,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){if(this.args.options?.autoplay===false)return;this._paused=false;let t=this.animation;typeof this._args.time=="number"?(this._paused=true,t.play(),this.ticker.addOnce(()=>{this._paused=false;})):t.play();}onComplete=()=>{let t=this.cleanup;t&&this.ticker.addOnce(()=>t());let r=this.id,i=this._args.options?.aliasToRemoveAfter||[];typeof i=="string"&&(i=[i]);let e=this._args.options?.tickerAliasToResume||[];typeof e=="string"&&(e=[e]);let a=this._args.options?.tickerIdToResume||[];typeof a=="string"&&(a=[a]),tickers.tickers.onComplete(r,{aliasToRemoveAfter:i,tickerAliasToResume:e,tickerIdToResume:a,stopTicker:false});};createItem(){let t=this.filter;return new Proxy(t,{set:(r,i,e)=>(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===e||(r[i]=e),true),get:(r,i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let e=r[i];return this._args.startState={...this._args.startState,[i]:e},e}})}createUpdateHandler(t){return ()=>{this.stopped||this._paused||this.apply?.(t.value);}}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 P=class extends j{get animation(){let t=this._animation;if(t)return t;let r=typeof this._args.time=="number",i=()=>{if(this.filter){let a=this.createItem();return O(a,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker})}let e={value:0};return O(e,this._args.keyframes,{...this._args.options,onUpdate:this.createUpdateHandler(e),onComplete:()=>this.onComplete(),ticker:this.ticker})};return t=r?this.suppressWritesDuring(i):i(),r&&(t.time=this._args.time),this._animation=t,t}alias="motion-filter"};var tt=N(Y());var w=class{constructor(t,r){let{duration:i,priority:e,id:a=this.generateTickerId(r),canvasElementAliases:c=[]}=r||{};this._args=t,this.duration=i,this.priority=e,this.id=a,this.canvasElementAliases=c;}id;_args;get args(){return {...this._args,time:this._animation?.time}}duration;priority;ticker=new U__default.default.Ticker;_animation;stopped=false;_paused=false;suppressWritesDuring(t){let r=this._paused;this._paused=true;try{return t()}finally{this._paused=r;}}canvasElementAliases=[];getItemByAlias(t){if(!this.canvasElementAliases.includes(t))return;let r=canvas.canvas.find(t);if(r)return r}generateTickerId(...t){try{return (0,tt.default)(JSON.stringify(t)).toString()+"_motion_"+Math.random().toString(36).substring(7)}catch(r){throw new core.PixiError("not_json_serializable",`Error to generate ticker id: ${r}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(t=>setTimeout(t,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){if(this.args.options?.autoplay===false)return;this._paused=false;let t=this.animation;typeof this._args.time=="number"?(this._paused=true,t.play(),this.ticker.addOnce(()=>{this._paused=false;})):t.play();}onComplete=()=>{let t=this.id,r=this._args.options?.aliasToRemoveAfter||[];typeof r=="string"&&(r=[r]);let i=this._args.options?.tickerAliasToResume||[];typeof i=="string"&&(i=[i]);let e=this._args.options?.tickerIdToResume||[];typeof e=="string"&&(e=[e]),tickers.tickers.onComplete(t,{aliasToRemoveAfter:r,tickerAliasToResume:i,tickerIdToResume:e,stopTicker:false});};createItem(t){return new Proxy({alias:t},{set:({alias:r},i,e)=>{if(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===e)return true;let a=this.getItemByAlias(r);if(!a)return true;switch(i){case "pivotX":a.pivot.x=e;break;case "pivotY":a.pivot.y=e;break;case "scaleX":a.scale.x=e;break;case "scaleY":a.scale.y=e;break;default:a[i]=e;break}return true},get:({alias:r},i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let e=this.getItemByAlias(r);if(!e)return;let a;switch(i){case "pivotX":a=e.pivot.x;break;case "pivotY":a=e.pivot.y;break;case "scaleX":a=e.scale.x;break;case "scaleY":a=e.scale.y;break;default:a=e[i];break}return this._args.startState={...this._args.startState,[i]:a},a},has:({alias:r},i)=>{let e=this.getItemByAlias(r);if(!e)return false;switch(i){case "pivotX":return "pivot"in e&&"x"in e.pivot;case "pivotY":return "pivot"in e&&"y"in e.pivot;case "scaleX":return "scale"in e&&"x"in e.scale;case "scaleY":return "scale"in e&&"y"in e.scale;default:return i in e}},ownKeys:({alias:r})=>{let i=this.getItemByAlias(r);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 R=class extends w{get animation(){let t=this._animation;if(t)return t;let r=this.canvasElementAliases[0],i=this.createItem(r),e=this._args.sequence.map((c,l)=>[i,c[0],{...c[1]||{},ticker:this.ticker,onComplete:l===this._args.sequence.length-1?()=>this.onComplete():void 0}]),a=typeof this._args.time=="number";return t=a?this.suppressWritesDuring(()=>O(e,this._args.options)):O(e,this._args.options),a&&(t.time=this._args.time),this._animation=t,t}alias="motion-sequence"};var B=class extends w{get animation(){let t=this._animation;if(t)return t;let r=this.canvasElementAliases.map(a=>this.createItem(a)),i=typeof this._args.time=="number",e=()=>O(r,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker});return t=i?this.suppressWritesDuring(e):e(),i&&(t.time=this._args.time),this._animation=t,t}alias="motion"};var C;(e=>(e.log=(a,...c)=>console.log(`[Pixi\u2019VN] ${a}`,...c),e.warn=(a,...c)=>console.warn(`[Pixi\u2019VN] ${a}`,...c),e.error=(a,...c)=>console.error(`[Pixi\u2019VN] ${a}`,...c),e.info=(a,...c)=>console.info(`[Pixi\u2019VN] ${a}`,...c)))(C||={});function W(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw C.error("Error creating exportable element",o,t),new core.PixiError("not_json_serializable","Error creating exportable element")}}var et;(r=>{function o(i,e,a,c){try{e=W(e);}catch(m){throw C.error("animate keyframes cannot contain functions or classes"),m}try{a=W(a);}catch(m){throw C.error("animate options cannot contain functions or classes"),m}let l=[];typeof i=="string"?l=[i]:Array.isArray(i)?l=i.map(m=>typeof m=="string"?m:m.label):l=[i.label];let h;Array.isArray(e)?h=new R({sequence:e,options:a},{priority:c,canvasElementAliases:l}):h=new B({keyframes:e,options:a},{priority:c,canvasElementAliases:l});let u=tickers.tickers.add(l,h),{completeOnContinue:p}=a||{};return u&&p&&tickers.tickers.completeOnStepEnd({id:u}),u}r.animate=o;function t(i,e,a,c,l,h,u){try{a=W(a);}catch(g){throw C.error("animateFilter keyframes cannot contain functions or classes"),g}try{c=W(c);}catch(g){throw C.error("animateFilter options cannot contain functions or classes"),g}let p=Array.isArray(i)?i:[i],m;if(e){let g=p[0],y=g?canvas.canvas.find(g):void 0,s=(y?.filters?Array.isArray(y.filters)?y.filters:[y.filters]:[]).indexOf(e);s!==-1&&(m={alias:g,index:s,detach:u?true:void 0});}let b=new P({keyframes:a,options:c,filterRef:m},{filter:e,apply:h,priority:l,canvasElementAliases:p,cleanup:u}),A=tickers.tickers.add(p,b),{completeOnContinue:_}=c||{};return A&&_&&tickers.tickers.completeOnStepEnd({id:A}),A}r.animateFilter=t;})(et||={});var gt=et;tickers.RegisteredTickers.add(B,"motion");tickers.RegisteredTickers.add(R,"motion-sequence");tickers.RegisteredTickers.add(P,"motion-filter");exports.animate=O;exports.motion=gt;exports.motionDriver=E;exports.timeline=ct;
|
package/dist/motion.d.cts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasBaseInterface } from '@drincs/pixi-vn/canvas';
|
|
2
|
+
import { CommonTickerProps } from '@drincs/pixi-vn/tickers';
|
|
2
3
|
import { AnimationOptions as AnimationOptions$1, ObjectTarget, At, SequenceOptions as SequenceOptions$1, AnimationPlaybackControlsWithThen, ObjectSegment as ObjectSegment$1 } from 'motion';
|
|
3
4
|
export { At } from 'motion';
|
|
4
|
-
import { UPDATE_PRIORITY, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
|
+
import { UPDATE_PRIORITY, Filter, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
6
|
|
|
6
7
|
interface MotionComponentExtension {
|
|
7
|
-
pivot?: number;
|
|
8
|
-
pivotX?: number;
|
|
9
|
-
pivotY?: number;
|
|
10
|
-
scale?: number;
|
|
11
|
-
scaleX?: number;
|
|
12
|
-
scaleY?: number;
|
|
8
|
+
pivot?: number | number[];
|
|
9
|
+
pivotX?: number | number[];
|
|
10
|
+
pivotY?: number | number[];
|
|
11
|
+
scale?: number | number[];
|
|
12
|
+
scaleX?: number | number[];
|
|
13
|
+
scaleY?: number | number[];
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type AnimationOptionsCommon = Omit<AnimationOptions$1, "onComplete" | "onPlay" | "onStop" | "onUpdate" | "onRepeat">;
|
|
@@ -48,6 +49,27 @@ declare namespace motion {
|
|
|
48
49
|
* @throws {PixiError} when `sequence` or `options` contain functions or class instances that cannot be serialized to JSON.
|
|
49
50
|
*/
|
|
50
51
|
function animate<T extends CanvasBaseInterface<any>>(components: T | string, sequence: (ObjectSegment<T> | ObjectSegmentWithTransition$1<T>)[], options?: SequenceOptions, priority?: UPDATE_PRIORITY): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Animate either a `Filter`'s own properties, or a plain numeric "progress" value with no live
|
|
54
|
+
* target (as opposed to {@link animate}, which animates a canvas element's properties) - see
|
|
55
|
+
* {@link MotionFilterTicker}. The latter is the generic mechanism behind the mask-based transitions
|
|
56
|
+
* (`wipeIn`/`wipeOut`, `irisIn`/`irisOut`, `splitIn`/`splitOut`): they have no canvas element or
|
|
57
|
+
* Filter property to write directly, just a number and a side effect (redrawing mask geometry).
|
|
58
|
+
* @param components The canvas element alias(es) the filter is attached to, or otherwise associated
|
|
59
|
+
* with this animation (kept for the same cleanup/transfer bookkeeping every other ticker
|
|
60
|
+
* participates in).
|
|
61
|
+
* @param filter The `Filter` instance to animate, or `undefined` to animate a plain value instead
|
|
62
|
+
* (in which case `keyframes` describes that value, e.g. `{ value: [0, 1] }`, and `apply` is required).
|
|
63
|
+
* @param keyframes The keyframes to animate the filter's properties (or the plain value) with.
|
|
64
|
+
* @param options The animation options.
|
|
65
|
+
* @param priority The update priority of the ticker.
|
|
66
|
+
* @param apply Called on every frame with the current interpolated value - required when `filter` is
|
|
67
|
+
* `undefined`, ignored otherwise (the filter's own properties are written to directly instead).
|
|
68
|
+
* @param cleanup Called once, right before completion handling, to detach/destroy the filter or tear
|
|
69
|
+
* down whatever `apply` was driving.
|
|
70
|
+
* @returns The id of the ticker, or `undefined` if the ticker was not added.
|
|
71
|
+
*/
|
|
72
|
+
function animateFilter(components: string | string[], filter: Filter | undefined, keyframes: Record<string, any>, options?: AnimationOptions, priority?: UPDATE_PRIORITY, apply?: (value: number) => void, cleanup?: () => void): string | undefined;
|
|
51
73
|
}
|
|
52
74
|
|
|
53
75
|
type SegmentOptions = AnimationOptions$1 & At;
|
package/dist/motion.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasBaseInterface } from '@drincs/pixi-vn/canvas';
|
|
2
|
+
import { CommonTickerProps } from '@drincs/pixi-vn/tickers';
|
|
2
3
|
import { AnimationOptions as AnimationOptions$1, ObjectTarget, At, SequenceOptions as SequenceOptions$1, AnimationPlaybackControlsWithThen, ObjectSegment as ObjectSegment$1 } from 'motion';
|
|
3
4
|
export { At } from 'motion';
|
|
4
|
-
import { UPDATE_PRIORITY, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
|
+
import { UPDATE_PRIORITY, Filter, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
6
|
|
|
6
7
|
interface MotionComponentExtension {
|
|
7
|
-
pivot?: number;
|
|
8
|
-
pivotX?: number;
|
|
9
|
-
pivotY?: number;
|
|
10
|
-
scale?: number;
|
|
11
|
-
scaleX?: number;
|
|
12
|
-
scaleY?: number;
|
|
8
|
+
pivot?: number | number[];
|
|
9
|
+
pivotX?: number | number[];
|
|
10
|
+
pivotY?: number | number[];
|
|
11
|
+
scale?: number | number[];
|
|
12
|
+
scaleX?: number | number[];
|
|
13
|
+
scaleY?: number | number[];
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type AnimationOptionsCommon = Omit<AnimationOptions$1, "onComplete" | "onPlay" | "onStop" | "onUpdate" | "onRepeat">;
|
|
@@ -48,6 +49,27 @@ declare namespace motion {
|
|
|
48
49
|
* @throws {PixiError} when `sequence` or `options` contain functions or class instances that cannot be serialized to JSON.
|
|
49
50
|
*/
|
|
50
51
|
function animate<T extends CanvasBaseInterface<any>>(components: T | string, sequence: (ObjectSegment<T> | ObjectSegmentWithTransition$1<T>)[], options?: SequenceOptions, priority?: UPDATE_PRIORITY): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Animate either a `Filter`'s own properties, or a plain numeric "progress" value with no live
|
|
54
|
+
* target (as opposed to {@link animate}, which animates a canvas element's properties) - see
|
|
55
|
+
* {@link MotionFilterTicker}. The latter is the generic mechanism behind the mask-based transitions
|
|
56
|
+
* (`wipeIn`/`wipeOut`, `irisIn`/`irisOut`, `splitIn`/`splitOut`): they have no canvas element or
|
|
57
|
+
* Filter property to write directly, just a number and a side effect (redrawing mask geometry).
|
|
58
|
+
* @param components The canvas element alias(es) the filter is attached to, or otherwise associated
|
|
59
|
+
* with this animation (kept for the same cleanup/transfer bookkeeping every other ticker
|
|
60
|
+
* participates in).
|
|
61
|
+
* @param filter The `Filter` instance to animate, or `undefined` to animate a plain value instead
|
|
62
|
+
* (in which case `keyframes` describes that value, e.g. `{ value: [0, 1] }`, and `apply` is required).
|
|
63
|
+
* @param keyframes The keyframes to animate the filter's properties (or the plain value) with.
|
|
64
|
+
* @param options The animation options.
|
|
65
|
+
* @param priority The update priority of the ticker.
|
|
66
|
+
* @param apply Called on every frame with the current interpolated value - required when `filter` is
|
|
67
|
+
* `undefined`, ignored otherwise (the filter's own properties are written to directly instead).
|
|
68
|
+
* @param cleanup Called once, right before completion handling, to detach/destroy the filter or tear
|
|
69
|
+
* down whatever `apply` was driving.
|
|
70
|
+
* @returns The id of the ticker, or `undefined` if the ticker was not added.
|
|
71
|
+
*/
|
|
72
|
+
function animateFilter(components: string | string[], filter: Filter | undefined, keyframes: Record<string, any>, options?: AnimationOptions, priority?: UPDATE_PRIORITY, apply?: (value: number) => void, cleanup?: () => void): string | undefined;
|
|
51
73
|
}
|
|
52
74
|
|
|
53
75
|
type SegmentOptions = AnimationOptions$1 & At;
|
package/dist/motion.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {RegisteredTickers,canvas}from'@drincs/pixi-vn/canvas';import H from'@drincs/pixi-vn/pixi.js';import {animate}from'motion';import {PixiError}from'@drincs/pixi-vn/core';var G=Object.create;var z=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var q=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,a)=>(typeof require<"u"?require:e)[a]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var D=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var nt=(s,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Z(e))!et.call(s,n)&&n!==a&&z(s,n,{get:()=>e[n],enumerable:!(i=Q(e,n))||i.enumerable});return s};var it=(s,e,a)=>(a=s!=null?G(tt(s)):{},nt(z(a,"default",{value:s,enumerable:true}),s));var X=D((W,U)=>{(function(s,e){typeof W=="object"?U.exports=W=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(W,function(){var s=s||(function(e,a){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 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.")},o=Object.create||(function(){function t(){}return function(r){var m;return t.prototype=r,m=new t,t.prototype=null,m}})(),c={},u=c.lib={},h=u.Base=(function(){return {extend:function(t){var r=o(this);return t&&r.mixIn(t),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments);}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),l=u.WordArray=h.extend({init:function(t,r){t=this.words=t||[],r!=a?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||v).stringify(this)},concat:function(t){var r=this.words,m=t.words,p=this.sigBytes,y=t.sigBytes;if(this.clamp(),p%4)for(var g=0;g<y;g++){var k=m[g>>>2]>>>24-g%4*8&255;r[p+g>>>2]|=k<<24-(p+g)%4*8;}else for(var O=0;O<y;O+=4)r[p+O>>>2]=m[O>>>2];return this.sigBytes+=y,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],m=0;m<t;m+=4)r.push(n());return new l.init(r,t)}}),f=c.enc={},v=f.Hex={stringify:function(t){for(var r=t.words,m=t.sigBytes,p=[],y=0;y<m;y++){var g=r[y>>>2]>>>24-y%4*8&255;p.push((g>>>4).toString(16)),p.push((g&15).toString(16));}return p.join("")},parse:function(t){for(var r=t.length,m=[],p=0;p<r;p+=2)m[p>>>3]|=parseInt(t.substr(p,2),16)<<24-p%8*4;return new l.init(m,r/2)}},A=f.Latin1={stringify:function(t){for(var r=t.words,m=t.sigBytes,p=[],y=0;y<m;y++){var g=r[y>>>2]>>>24-y%4*8&255;p.push(String.fromCharCode(g));}return p.join("")},parse:function(t){for(var r=t.length,m=[],p=0;p<r;p++)m[p>>>2]|=(t.charCodeAt(p)&255)<<24-p%4*8;return new l.init(m,r)}},b=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(A.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return A.parse(unescape(encodeURIComponent(t)))}},x=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new l.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=b.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,m=this._data,p=m.words,y=m.sigBytes,g=this.blockSize,k=g*4,O=y/k;t?O=e.ceil(O):O=e.max((O|0)-this._minBufferSize,0);var S=O*g,_=e.min(S*4,y);if(S){for(var E=0;E<S;E+=g)this._doProcessBlock(p,E);r=p.splice(0,S),m.sigBytes-=_;}return new l.init(r,_)},clone:function(){var t=h.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=x.extend({cfg:h.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 r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,m){return new t.init(m).finalize(r)}},_createHmacHelper:function(t){return function(r,m){return new d.HMAC.init(t,m).finalize(r)}}});var d=c.algo={};return c})(Math);return s});});var K=D((R,$)=>{(function(s,e){typeof R=="object"?$.exports=R=e(X()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(R,function(s){return (function(){var e=s,a=e.lib,i=a.WordArray,n=a.Hasher,o=e.algo,c=[],u=o.SHA1=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,l){for(var f=this._hash.words,v=f[0],A=f[1],b=f[2],x=f[3],T=f[4],d=0;d<80;d++){if(d<16)c[d]=h[l+d]|0;else {var t=c[d-3]^c[d-8]^c[d-14]^c[d-16];c[d]=t<<1|t>>>31;}var r=(v<<5|v>>>27)+T+c[d];d<20?r+=(A&b|~A&x)+1518500249:d<40?r+=(A^b^x)+1859775393:d<60?r+=(A&b|A&x|b&x)-1894007588:r+=(A^b^x)-899497514,T=x,x=b,b=A<<30|A>>>2,A=v,v=r;}f[0]=f[0]+v|0,f[1]=f[1]+A|0,f[2]=f[2]+b|0,f[3]=f[3]+x|0,f[4]=f[4]+T|0;},_doFinalize:function(){var h=this._data,l=h.words,f=this._nDataBytes*8,v=h.sigBytes*8;return l[v>>>5]|=128<<24-v%32,l[(v+64>>>9<<4)+14]=Math.floor(f/4294967296),l[(v+64>>>9<<4)+15]=f,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(u),e.HmacSHA1=n._createHmacHelper(u);})(),s.SHA1});});var j=s=>e=>{let a=({lastTime:i})=>e(i);return {start:(i=true)=>{s.add(a),s.start();},stop:()=>s.remove(a),now:()=>s.lastTime}};function B(s,e,a){if(Array.isArray(s)&&Array.isArray(s[0])){e&&"repeat"in e&&e?.repeat===null&&(e.repeat=1/0),s.forEach(c=>{if(Array.isArray(c)&&c.length===3){let[u,h,l]=c;l&&"repeat"in l&&l?.repeat===null&&(l.repeat=1/0);}});let{ticker:i=new H.Ticker,driver:n=j(i),...o}=e||{};return animate(s,{driver:n,...o})}else {a&&"repeat"in a&&a?.repeat===null&&(a.repeat=1/0);let{ticker:i=new H.Ticker,driver:n=j(i),...o}=a||{};return animate(s,e,{driver:n,...o})}}function rt(s,e){let{ticker:a=new H.Ticker,driver:i=j(a),repeat:n,...o}=e||{},c={x:0},u=[],h=[],l=0;s.forEach((b,x)=>{let{onComplete:T,onPlay:d,delay:t=0,duration:r=.3,...m}=b,p=typeof t=="function"?t(0,1):t,y=l+p,g=y+r;u.push({start:y,end:g,onPlay:d,onComplete:T}),h.push([c,{x:x+1},{...m,delay:t,duration:r}]),l=g;});let f=l,v=B(h,{...o,repeat:n,driver:i});if(u.length>0&&f>0){let k=function(){if(r)return;for(t+=a.deltaMS/1e3;!r&&t>=f;){if(p(),d++,d>=x){g();return}t-=f;}let S=y(t);S===-1?T>=0&&p():S!==T&&m(S);};let b=n===null?1/0:n,x=b===void 0?1:b+1,T=-1,d=0,t=0,r=false,m=S=>{T>=0&&u[T].onComplete?.(),T=S,u[T].onPlay?.();},p=()=>{T>=0&&u[T].onComplete?.(),T=-1;},y=S=>{for(let _=0;_<u.length;_++){if(S<u[_].start)return -1;if(S<u[_].end)return _}return u.length-1},g=()=>{r=true,a.remove(k);};a.add(k);let O=v.stop.bind(v);v.stop=()=>{g(),O();};}return v}var N=it(K());var C=class{constructor(e,a){let{duration:i,priority:n,id:o=this.generateTickerId(a),canvasElementAliases:c=[]}=a||{};this._args=e,this.duration=i,this.priority=n,this.id=o,this.canvasElementAliases=c;}id;_args;get args(){return {...this._args,time:this._animation?.time}}duration;priority;ticker=new H.Ticker;_animation;stopped=false;_paused=false;canvasElementAliases=[];getItemByAlias(e){if(!this.canvasElementAliases.includes(e))return;let a=canvas.find(e);if(a)return a}generateTickerId(...e){try{return (0,N.default)(JSON.stringify(e)).toString()+"_motion_"+Math.random().toString(36).substring(7)}catch(a){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${a}`)}}timeout=50;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());}onComplete=()=>{let e=this.id,a=this._args.options?.aliasToRemoveAfter||[];typeof a=="string"&&(a=[a]);let i=this._args.options?.tickerAliasToResume||[];typeof i=="string"&&(i=[i]);let n=this._args.options?.tickerIdToResume||[];typeof n=="string"&&(n=[n]),canvas.tickers.onComplete(e,{aliasToRemoveAfter:a,tickerAliasToResume:i,tickerIdToResume:n,stopTicker:false});};createItem(e){return new Proxy({alias:e},{set:({alias:a},i,n)=>{if(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===n)return true;let o=this.getItemByAlias(a);if(!o)return true;switch(i){case "pivotX":o.pivot.x=n;break;case "pivotY":o.pivot.y=n;break;case "scaleX":o.scale.x=n;break;case "scaleY":o.scale.y=n;break;default:o[i]=n;break}return true},get:({alias:a},i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let n=this.getItemByAlias(a);if(!n)return;let o;switch(i){case "pivotX":o=n.pivot.x;break;case "pivotY":o=n.pivot.y;break;case "scaleX":o=n.scale.x;break;case "scaleY":o=n.scale.y;break;default:o=n[i];break}return this._args.startState={...this._args.startState,[i]:o},o},has:({alias:a},i)=>{let n=this.getItemByAlias(a);if(!n)return false;switch(i){case "pivotX":return "pivot"in n&&"x"in n.pivot;case "pivotY":return "pivot"in n&&"y"in n.pivot;case "scaleX":return "scale"in n&&"x"in n.scale;case "scaleY":return "scale"in n&&"y"in n.scale;default:return i in n}},ownKeys:({alias:a})=>{let i=this.getItemByAlias(a);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 I=class extends C{get animation(){let e=this._animation;if(e)return e;let a=this.canvasElementAliases[0],i=this.createItem(a),n=this._args.sequence.map((o,c)=>[i,o[0],{...o[1]||{},ticker:this.ticker,onComplete:c===this._args.sequence.length-1?()=>this.onComplete():void 0}]);return e=B(n,this._args.options),this._args.time&&(this.animation.time=this._args.time),this._animation=e,e}alias="motion-sequence"};var w=class extends C{get animation(){let e=this._animation;if(e)return e;let a=this.canvasElementAliases.map(i=>this.createItem(i));return e=B(a,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker}),this._args.time&&(e.time=this._args.time),this._animation=e,e}alias="motion"};var P;(n=>(n.log=(o,...c)=>console.log(`[Pixi\u2019VN] ${o}`,...c),n.warn=(o,...c)=>console.warn(`[Pixi\u2019VN] ${o}`,...c),n.error=(o,...c)=>console.error(`[Pixi\u2019VN] ${o}`,...c),n.info=(o,...c)=>console.info(`[Pixi\u2019VN] ${o}`,...c)))(P||={});function M(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw P.error("Error creating exportable element",s,e),new PixiError("not_json_serializable","Error creating exportable element")}}var F;(e=>{function s(a,i,n,o){try{i=M(i);}catch(f){throw P.error("animate keyframes cannot contain functions or classes"),f}try{n=M(n);}catch(f){throw P.error("animate options cannot contain functions or classes"),f}let c=[];typeof a=="string"?c=[a]:Array.isArray(a)?c=a.map(f=>typeof f=="string"?f:f.label):c=[a.label];let u;Array.isArray(i)?u=new I({sequence:i,options:n},{priority:o,canvasElementAliases:c}):u=new w({keyframes:i,options:n},{priority:o,canvasElementAliases:c});let h=canvas.tickers.add(c,u),{completeOnContinue:l}=n||{};return h&&l&&canvas.tickers.completeOnStepEnd({id:h}),h}e.animate=s;})(F||={});var ct=F;RegisteredTickers.add(w,"motion");RegisteredTickers.add(I,"motion-sequence");export{B as animate,ct as motion,j as motionDriver,rt as timeline};
|
|
1
|
+
import {RegisteredTickers,tickers}from'@drincs/pixi-vn/tickers';import U from'@drincs/pixi-vn/pixi.js';import {animate}from'motion';import {canvas}from'@drincs/pixi-vn/canvas';import {PixiError}from'@drincs/pixi-vn/core';var it=Object.create;var X=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty;var M=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var $=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var ot=(o,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of rt(t))!at.call(o,e)&&e!==r&&X(o,e,{get:()=>t[e],enumerable:!(i=nt(t,e))||i.enumerable});return o};var N=(o,t,r)=>(r=o!=null?it(st(o)):{},ot(X(r,"default",{value:o,enumerable:true}),o));var L=$((F,K)=>{(function(o,t){typeof F=="object"?K.exports=F=t():typeof define=="function"&&define.amd?define([],t):o.CryptoJS=t();})(F,function(){var o=o||(function(t,r){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 M=="function")try{i=M("crypto");}catch{}var e=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.")},a=Object.create||(function(){function n(){}return function(s){var d;return n.prototype=s,d=new n,n.prototype=null,d}})(),c={},l=c.lib={},h=l.Base=(function(){return {extend:function(n){var s=a(this);return n&&s.mixIn(n),(!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 n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var s in n)n.hasOwnProperty(s)&&(this[s]=n[s]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),u=l.WordArray=h.extend({init:function(n,s){n=this.words=n||[],s!=r?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||m).stringify(this)},concat:function(n){var s=this.words,d=n.words,f=this.sigBytes,v=n.sigBytes;if(this.clamp(),f%4)for(var T=0;T<v;T++){var I=d[T>>>2]>>>24-T%4*8&255;s[f+T>>>2]|=I<<24-(f+T)%4*8;}else for(var k=0;k<v;k+=4)s[f+k>>>2]=d[k>>>2];return this.sigBytes+=v,this},clamp:function(){var n=this.words,s=this.sigBytes;n[s>>>2]&=4294967295<<32-s%4*8,n.length=t.ceil(s/4);},clone:function(){var n=h.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],d=0;d<n;d+=4)s.push(e());return new u.init(s,n)}}),p=c.enc={},m=p.Hex={stringify:function(n){for(var s=n.words,d=n.sigBytes,f=[],v=0;v<d;v++){var T=s[v>>>2]>>>24-v%4*8&255;f.push((T>>>4).toString(16)),f.push((T&15).toString(16));}return f.join("")},parse:function(n){for(var s=n.length,d=[],f=0;f<s;f+=2)d[f>>>3]|=parseInt(n.substr(f,2),16)<<24-f%8*4;return new u.init(d,s/2)}},b=p.Latin1={stringify:function(n){for(var s=n.words,d=n.sigBytes,f=[],v=0;v<d;v++){var T=s[v>>>2]>>>24-v%4*8&255;f.push(String.fromCharCode(T));}return f.join("")},parse:function(n){for(var s=n.length,d=[],f=0;f<s;f++)d[f>>>2]|=(n.charCodeAt(f)&255)<<24-f%4*8;return new u.init(d,s)}},A=p.Utf8={stringify:function(n){try{return decodeURIComponent(escape(b.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return b.parse(unescape(encodeURIComponent(n)))}},_=l.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new u.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=A.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var s,d=this._data,f=d.words,v=d.sigBytes,T=this.blockSize,I=T*4,k=v/I;n?k=t.ceil(k):k=t.max((k|0)-this._minBufferSize,0);var x=k*T,S=t.min(x*4,v);if(x){for(var D=0;D<x;D+=T)this._doProcessBlock(f,D);s=f.splice(0,x),d.sigBytes-=S;}return new u.init(s,S)},clone:function(){var n=h.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});l.Hasher=_.extend({cfg:h.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){_.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var s=this._doFinalize();return s},blockSize:512/32,_createHelper:function(n){return function(s,d){return new n.init(d).finalize(s)}},_createHmacHelper:function(n){return function(s,d){return new y.HMAC.init(n,d).finalize(s)}}});var y=c.algo={};return c})(Math);return o});});var Y=$((q,V)=>{(function(o,t){typeof q=="object"?V.exports=q=t(L()):typeof define=="function"&&define.amd?define(["./core"],t):t(o.CryptoJS);})(q,function(o){return (function(){var t=o,r=t.lib,i=r.WordArray,e=r.Hasher,a=t.algo,c=[],l=a.SHA1=e.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,u){for(var p=this._hash.words,m=p[0],b=p[1],A=p[2],_=p[3],g=p[4],y=0;y<80;y++){if(y<16)c[y]=h[u+y]|0;else {var n=c[y-3]^c[y-8]^c[y-14]^c[y-16];c[y]=n<<1|n>>>31;}var s=(m<<5|m>>>27)+g+c[y];y<20?s+=(b&A|~b&_)+1518500249:y<40?s+=(b^A^_)+1859775393:y<60?s+=(b&A|b&_|A&_)-1894007588:s+=(b^A^_)-899497514,g=_,_=A,A=b<<30|b>>>2,b=m,m=s;}p[0]=p[0]+m|0,p[1]=p[1]+b|0,p[2]=p[2]+A|0,p[3]=p[3]+_|0,p[4]=p[4]+g|0;},_doFinalize:function(){var h=this._data,u=h.words,p=this._nDataBytes*8,m=h.sigBytes*8;return u[m>>>5]|=128<<24-m%32,u[(m+64>>>9<<4)+14]=Math.floor(p/4294967296),u[(m+64>>>9<<4)+15]=p,h.sigBytes=u.length*4,this._process(),this._hash},clone:function(){var h=e.clone.call(this);return h._hash=this._hash.clone(),h}});t.SHA1=e._createHelper(l),t.HmacSHA1=e._createHmacHelper(l);})(),o.SHA1});});var E=o=>t=>{let r=({lastTime:i})=>t(i);return {start:(i=true)=>{o.add(r),o.start();},stop:()=>o.remove(r),now:()=>o.lastTime}};function O(o,t,r){if(Array.isArray(o)&&Array.isArray(o[0])){t&&"repeat"in t&&t?.repeat===null&&(t.repeat=1/0),o.forEach(c=>{if(Array.isArray(c)&&c.length===3){let[l,h,u]=c;u&&"repeat"in u&&u?.repeat===null&&(u.repeat=1/0);}});let{ticker:i=new U.Ticker,driver:e=E(i),...a}=t||{};return animate(o,{driver:e,...a})}else {r&&"repeat"in r&&r?.repeat===null&&(r.repeat=1/0);let{ticker:i=new U.Ticker,driver:e=E(i),...a}=r||{};return animate(o,t,{driver:e,...a})}}function ct(o,t){let{ticker:r=new U.Ticker,driver:i=E(r),repeat:e,...a}=t||{},c={x:0},l=[],h=[],u=0;o.forEach((A,_)=>{let{onComplete:g,onPlay:y,delay:n=0,duration:s=.3,...d}=A,f=typeof n=="function"?n(0,1):n,v=u+f,T=v+s;l.push({start:v,end:T,onPlay:y,onComplete:g}),h.push([c,{x:_+1},{...d,delay:n,duration:s}]),u=T;});let p=u,m=O(h,{...a,repeat:e,driver:i});if(l.length>0&&p>0){let I=function(){if(s)return;for(n+=r.deltaMS/1e3;!s&&n>=p;){if(f(),y++,y>=_){T();return}n-=p;}let x=v(n);x===-1?g>=0&&f():x!==g&&d(x);};let A=e===null?1/0:e,_=A===void 0?1:A+1,g=-1,y=0,n=0,s=false,d=x=>{g>=0&&l[g].onComplete?.(),g=x,l[g].onPlay?.();},f=()=>{g>=0&&l[g].onComplete?.(),g=-1;},v=x=>{for(let S=0;S<l.length;S++){if(x<l[S].start)return -1;if(x<l[S].end)return S}return l.length-1},T=()=>{s=true,r.remove(I);};r.add(I);let k=m.stop.bind(m);m.stop=()=>{T(),k();};}return m}var Z=N(Y());var j=class o{constructor(t,r){let{filter:i,apply:e,duration:a,priority:c,id:l=this.generateTickerId(t),canvasElementAliases:h=[],cleanup:u}=r||{},p=i?void 0:o.resolveFilterRef(t.filterRef),m=i??p;if(!m&&!e)throw new PixiError("not_implemented","MotionFilterTicker requires either a `filter` instance, an `apply` callback, or a resolvable `filterRef`; it cannot be reconstructed from saved/serialized ticker args.");this._args=t,this.filter=m,this.apply=e,this.duration=a,this.priority=c,this.id=l,this.canvasElementAliases=h;let b=p&&t.filterRef?.detach?t.filterRef.alias:void 0;this.cleanup=u??(b&&p?()=>o.detachFilter(b,p):void 0);}id;filter;apply;cleanup;_args;static resolveFilterRef(t){if(t)return o.componentFilters(t.alias)[t.index]}static componentFilters(t){let r=canvas.find(t)?.filters;return r?Array.isArray(r)?[...r]:[r]:[]}static detachFilter(t,r){let i=canvas.find(t);if(i){let e=o.componentFilters(t).filter(a=>a!==r);i.filters=e.length>0?e:null;}r.destroy();}get args(){let t=this._args.filterRef;if(t&&this.filter){let r=o.componentFilters(t.alias).indexOf(this.filter);r!==-1&&(t={...t,index:r});}return {...this._args,filterRef:t,time:this._animation?.time}}duration;priority;ticker=new U.Ticker;_animation;stopped=false;_paused=false;suppressWritesDuring(t){let r=this._paused;this._paused=true;try{return t()}finally{this._paused=r;}}canvasElementAliases=[];generateTickerId(...t){try{return (0,Z.default)(JSON.stringify(t)).toString()+"_motion_filter_"+Math.random().toString(36).substring(7)}catch(r){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${r}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(t=>setTimeout(t,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){if(this.args.options?.autoplay===false)return;this._paused=false;let t=this.animation;typeof this._args.time=="number"?(this._paused=true,t.play(),this.ticker.addOnce(()=>{this._paused=false;})):t.play();}onComplete=()=>{let t=this.cleanup;t&&this.ticker.addOnce(()=>t());let r=this.id,i=this._args.options?.aliasToRemoveAfter||[];typeof i=="string"&&(i=[i]);let e=this._args.options?.tickerAliasToResume||[];typeof e=="string"&&(e=[e]);let a=this._args.options?.tickerIdToResume||[];typeof a=="string"&&(a=[a]),tickers.onComplete(r,{aliasToRemoveAfter:i,tickerAliasToResume:e,tickerIdToResume:a,stopTicker:false});};createItem(){let t=this.filter;return new Proxy(t,{set:(r,i,e)=>(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===e||(r[i]=e),true),get:(r,i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let e=r[i];return this._args.startState={...this._args.startState,[i]:e},e}})}createUpdateHandler(t){return ()=>{this.stopped||this._paused||this.apply?.(t.value);}}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 P=class extends j{get animation(){let t=this._animation;if(t)return t;let r=typeof this._args.time=="number",i=()=>{if(this.filter){let a=this.createItem();return O(a,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker})}let e={value:0};return O(e,this._args.keyframes,{...this._args.options,onUpdate:this.createUpdateHandler(e),onComplete:()=>this.onComplete(),ticker:this.ticker})};return t=r?this.suppressWritesDuring(i):i(),r&&(t.time=this._args.time),this._animation=t,t}alias="motion-filter"};var tt=N(Y());var w=class{constructor(t,r){let{duration:i,priority:e,id:a=this.generateTickerId(r),canvasElementAliases:c=[]}=r||{};this._args=t,this.duration=i,this.priority=e,this.id=a,this.canvasElementAliases=c;}id;_args;get args(){return {...this._args,time:this._animation?.time}}duration;priority;ticker=new U.Ticker;_animation;stopped=false;_paused=false;suppressWritesDuring(t){let r=this._paused;this._paused=true;try{return t()}finally{this._paused=r;}}canvasElementAliases=[];getItemByAlias(t){if(!this.canvasElementAliases.includes(t))return;let r=canvas.find(t);if(r)return r}generateTickerId(...t){try{return (0,tt.default)(JSON.stringify(t)).toString()+"_motion_"+Math.random().toString(36).substring(7)}catch(r){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${r}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(t=>setTimeout(t,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){if(this.args.options?.autoplay===false)return;this._paused=false;let t=this.animation;typeof this._args.time=="number"?(this._paused=true,t.play(),this.ticker.addOnce(()=>{this._paused=false;})):t.play();}onComplete=()=>{let t=this.id,r=this._args.options?.aliasToRemoveAfter||[];typeof r=="string"&&(r=[r]);let i=this._args.options?.tickerAliasToResume||[];typeof i=="string"&&(i=[i]);let e=this._args.options?.tickerIdToResume||[];typeof e=="string"&&(e=[e]),tickers.onComplete(t,{aliasToRemoveAfter:r,tickerAliasToResume:i,tickerIdToResume:e,stopTicker:false});};createItem(t){return new Proxy({alias:t},{set:({alias:r},i,e)=>{if(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===e)return true;let a=this.getItemByAlias(r);if(!a)return true;switch(i){case "pivotX":a.pivot.x=e;break;case "pivotY":a.pivot.y=e;break;case "scaleX":a.scale.x=e;break;case "scaleY":a.scale.y=e;break;default:a[i]=e;break}return true},get:({alias:r},i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let e=this.getItemByAlias(r);if(!e)return;let a;switch(i){case "pivotX":a=e.pivot.x;break;case "pivotY":a=e.pivot.y;break;case "scaleX":a=e.scale.x;break;case "scaleY":a=e.scale.y;break;default:a=e[i];break}return this._args.startState={...this._args.startState,[i]:a},a},has:({alias:r},i)=>{let e=this.getItemByAlias(r);if(!e)return false;switch(i){case "pivotX":return "pivot"in e&&"x"in e.pivot;case "pivotY":return "pivot"in e&&"y"in e.pivot;case "scaleX":return "scale"in e&&"x"in e.scale;case "scaleY":return "scale"in e&&"y"in e.scale;default:return i in e}},ownKeys:({alias:r})=>{let i=this.getItemByAlias(r);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 R=class extends w{get animation(){let t=this._animation;if(t)return t;let r=this.canvasElementAliases[0],i=this.createItem(r),e=this._args.sequence.map((c,l)=>[i,c[0],{...c[1]||{},ticker:this.ticker,onComplete:l===this._args.sequence.length-1?()=>this.onComplete():void 0}]),a=typeof this._args.time=="number";return t=a?this.suppressWritesDuring(()=>O(e,this._args.options)):O(e,this._args.options),a&&(t.time=this._args.time),this._animation=t,t}alias="motion-sequence"};var B=class extends w{get animation(){let t=this._animation;if(t)return t;let r=this.canvasElementAliases.map(a=>this.createItem(a)),i=typeof this._args.time=="number",e=()=>O(r,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker});return t=i?this.suppressWritesDuring(e):e(),i&&(t.time=this._args.time),this._animation=t,t}alias="motion"};var C;(e=>(e.log=(a,...c)=>console.log(`[Pixi\u2019VN] ${a}`,...c),e.warn=(a,...c)=>console.warn(`[Pixi\u2019VN] ${a}`,...c),e.error=(a,...c)=>console.error(`[Pixi\u2019VN] ${a}`,...c),e.info=(a,...c)=>console.info(`[Pixi\u2019VN] ${a}`,...c)))(C||={});function W(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw C.error("Error creating exportable element",o,t),new PixiError("not_json_serializable","Error creating exportable element")}}var et;(r=>{function o(i,e,a,c){try{e=W(e);}catch(m){throw C.error("animate keyframes cannot contain functions or classes"),m}try{a=W(a);}catch(m){throw C.error("animate options cannot contain functions or classes"),m}let l=[];typeof i=="string"?l=[i]:Array.isArray(i)?l=i.map(m=>typeof m=="string"?m:m.label):l=[i.label];let h;Array.isArray(e)?h=new R({sequence:e,options:a},{priority:c,canvasElementAliases:l}):h=new B({keyframes:e,options:a},{priority:c,canvasElementAliases:l});let u=tickers.add(l,h),{completeOnContinue:p}=a||{};return u&&p&&tickers.completeOnStepEnd({id:u}),u}r.animate=o;function t(i,e,a,c,l,h,u){try{a=W(a);}catch(g){throw C.error("animateFilter keyframes cannot contain functions or classes"),g}try{c=W(c);}catch(g){throw C.error("animateFilter options cannot contain functions or classes"),g}let p=Array.isArray(i)?i:[i],m;if(e){let g=p[0],y=g?canvas.find(g):void 0,s=(y?.filters?Array.isArray(y.filters)?y.filters:[y.filters]:[]).indexOf(e);s!==-1&&(m={alias:g,index:s,detach:u?true:void 0});}let b=new P({keyframes:a,options:c,filterRef:m},{filter:e,apply:h,priority:l,canvasElementAliases:p,cleanup:u}),A=tickers.add(p,b),{completeOnContinue:_}=c||{};return A&&_&&tickers.completeOnStepEnd({id:A}),A}r.animateFilter=t;})(et||={});var gt=et;RegisteredTickers.add(B,"motion");RegisteredTickers.add(R,"motion-sequence");RegisteredTickers.add(P,"motion-filter");export{O as animate,gt as motion,E as motionDriver,ct as timeline};
|
package/dist/narration.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn/core');var yt=Object.create;var We=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Je=s=>{throw TypeError(s)};var Tt=(s,e,t)=>e in s?We(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var Be=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ze=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var _t=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(s,i)&&i!==t&&We(s,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return s};var Ct=(s,e,t)=>(t=s!=null?yt(gt(s)):{},_t(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>Tt(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Je("Cannot "+t);var r=(s,e,t)=>(je(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),S=(s,e,t,n)=>(je(s,e,"write to private field"),e.set(s,t),t),f=(s,e,t)=>(je(s,e,"access private method"),t);var Ue=(s,e,t,n)=>({set _(i){S(s,e,i);},get _(){return r(s,e,n)}});var ut=Ze((ze,ct)=>{(function(s,e){typeof ze=="object"?ct.exports=ze=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(ze,function(){var s=s||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function l(){}return function(d){var E;return l.prototype=d,E=new l,l.prototype=null,E}})(),o={},p=o.lib={},c=p.Base=(function(){return {extend:function(l){var d=a(this);return l&&d.mixIn(l),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=p.WordArray=c.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||g).stringify(this)},concat:function(l){var d=this.words,E=l.words,C=this.sigBytes,R=l.sigBytes;if(this.clamp(),C%4)for(var D=0;D<R;D++){var se=E[D>>>2]>>>24-D%4*8&255;d[C+D>>>2]|=se<<24-(C+D)%4*8;}else for(var G=0;G<R;G+=4)d[C+G>>>2]=E[G>>>2];return this.sigBytes+=R,this},clamp:function(){var l=this.words,d=this.sigBytes;l[d>>>2]&=4294967295<<32-d%4*8,l.length=e.ceil(d/4);},clone:function(){var l=c.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],E=0;E<l;E+=4)d.push(i());return new y.init(d,l)}}),h=o.enc={},g=h.Hex={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push((D>>>4).toString(16)),C.push((D&15).toString(16));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C+=2)E[C>>>3]|=parseInt(l.substr(C,2),16)<<24-C%8*4;return new y.init(E,d/2)}},M=h.Latin1={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push(String.fromCharCode(D));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C++)E[C>>>2]|=(l.charCodeAt(C)&255)<<24-C%4*8;return new y.init(E,d)}},N=h.Utf8={stringify:function(l){try{return decodeURIComponent(escape(M.stringify(l)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(l){return M.parse(unescape(encodeURIComponent(l)))}},P=p.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(l){typeof l=="string"&&(l=N.parse(l)),this._data.concat(l),this._nDataBytes+=l.sigBytes;},_process:function(l){var d,E=this._data,C=E.words,R=E.sigBytes,D=this.blockSize,se=D*4,G=R/se;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var Q=G*D,Le=e.min(Q*4,R);if(Q){for(var Ke=0;Ke<Q;Ke+=D)this._doProcessBlock(C,Ke);d=C.splice(0,Q),E.sigBytes-=Le;}return new y.init(d,Le)},clone:function(){var l=c.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});p.Hasher=P.extend({cfg:c.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){P.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(l){return function(d,E){return new l.init(E).finalize(d)}},_createHmacHelper:function(l){return function(d,E){return new _.HMAC.init(l,E).finalize(d)}}});var _=o.algo={};return o})(Math);return s});});var dt=Ze((He,ht)=>{(function(s,e){typeof He=="object"?ht.exports=He=e(ut()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(He,function(s){return (function(){var e=s,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,o=[],p=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,y){for(var h=this._hash.words,g=h[0],M=h[1],N=h[2],P=h[3],w=h[4],_=0;_<80;_++){if(_<16)o[_]=c[y+_]|0;else {var l=o[_-3]^o[_-8]^o[_-14]^o[_-16];o[_]=l<<1|l>>>31;}var d=(g<<5|g>>>27)+w+o[_];_<20?d+=(M&N|~M&P)+1518500249:_<40?d+=(M^N^P)+1859775393:_<60?d+=(M&N|M&P|N&P)-1894007588:d+=(M^N^P)-899497514,w=P,P=N,N=M<<30|M>>>2,M=g,g=d;}h[0]=h[0]+g|0,h[1]=h[1]+M|0,h[2]=h[2]+N|0,h[3]=h[3]+P|0,h[4]=h[4]+w|0;},_doFinalize:function(){var c=this._data,y=c.words,h=this._nDataBytes*8,g=c.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(h/4294967296),y[(g+64>>>9<<4)+15]=h,c.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var c=i.clone.call(this);return c._hash=this._hash.clone(),c}});e.SHA1=i._createHelper(p),e.HmacSHA1=i._createHmacHelper(p);})(),s.SHA1});});var O="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Et=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(s,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let s=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=s=>!nt.has(s);var he=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>he(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(s){super(s),this.fill(0);}},oe,Te,Rt=(oe=class{heap;length;static create(e){let t=at(e);if(!t)return [];S(oe,Te,true);let n=new oe(e,t);return S(oe,Te,false),n}constructor(e,t){if(!r(oe,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(oe,Te,false),oe),tt,rt,X,B,J,Se,Z,_e,Ce,ee,Y,te,U,A,T,K,j,H,V,re,F,ne,ie,k,q,ae,ye,W,Ee,u,qe,me,pe,Ae,$,ot,ge,Ie,Me,de,fe,$e,Ve,Fe,x,Xe,xe,be,Qe,Re,st=(Re=class{constructor(e){v(this,u);v(this,X);v(this,B);v(this,J);v(this,Se);v(this,Z);v(this,_e);v(this,Ce);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,T);v(this,K);v(this,j);v(this,H);v(this,V);v(this,re);v(this,F);v(this,ne);v(this,ie);v(this,k);v(this,q);v(this,ae);v(this,ye);v(this,W);v(this,Ee);v(this,me,()=>{});v(this,pe,()=>{});v(this,Ae,()=>{});v(this,$,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Me,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:p,allowStale:c,dispose:y,onInsert:h,disposeAfter:g,noDisposeOnSet:M,noUpdateTTL:N,maxSize:P=0,maxEntrySize:w=0,sizeCalculation:_,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:se,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,G??Et),t!==0&&!he(t))throw new TypeError("max option must be a nonnegative integer");let Q=t?at(t):Array;if(!Q)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,P),this.maxEntrySize=w||r(this,B),this.sizeCalculation=_,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(S(this,Ce,d),l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,_e,l),S(this,ye,!!l),S(this,U,new Map),S(this,A,new Array(t).fill(void 0)),S(this,T,new Array(t).fill(void 0)),S(this,K,new Q(t)),S(this,j,new Q(t)),S(this,H,0),S(this,V,0),S(this,re,Rt.create(t)),S(this,Y,0),S(this,te,0),typeof y=="function"&&S(this,J,y),typeof h=="function"&&S(this,Se,h),typeof g=="function"?(S(this,Z,g),S(this,F,[])):(S(this,Z,void 0),S(this,F,void 0)),S(this,ae,!!r(this,J)),S(this,Ee,!!r(this,Se)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!se,this.maxEntrySize!==0){if(r(this,B)!==0&&!he(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!he(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,u,ot).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!p,this.ttlResolution=he(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!he(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,u,qe).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let Le="LRU_CACHE_UNBOUNDED";It(Le)&&(nt.add(Le),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,q),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,T),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,V)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,u,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,u,Fe).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,u,xe).call(n,t)},indexes:t=>{var n;return f(n=e,u,de).call(n,t)},rindexes:t=>{var n;return f(n=e,u,fe).call(n,t)},isStale:t=>{var n;return r(n=e,$).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,_e)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,J)}get onInsert(){return r(this,Se)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,u,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,u,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,u,fe).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,u,fe).call(this,{allowStale:true}))r(this,$).call(this,t)&&(f(this,u,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,T)[t],i=f(this,u,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let o=r(this,k)[t],p=r(this,ie)[t];if(o&&p){let c=o-(r(this,ee).now()-p);a.ttl=c,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,u,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,T)[t],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(r(this,k)&&r(this,ie)){o.ttl=r(this,k)[t];let p=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-p);}r(this,ne)&&(o.size=r(this,ne)[t]),e.unshift([n,o]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,P,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:p=this.sizeCalculation,status:c}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,h=r(this,Me).call(this,e,t,n.size||0,p);if(this.maxEntrySize&&h>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),f(this,u,be).call(this,e,"set"),this;let g=r(this,Y)===0?void 0:r(this,U).get(e);if(g===void 0)g=r(this,Y)===0?r(this,V):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,u,Ve).call(this,false):r(this,Y),r(this,A)[g]=e,r(this,T)[g]=t,r(this,U).set(e,g),r(this,K)[r(this,V)]=g,r(this,j)[g]=r(this,V),S(this,V,g),Ue(this,Y)._++,r(this,Ie).call(this,g,h,c),c&&(c.set="add"),y=false,r(this,Ee)&&((M=r(this,Se))==null||M.call(this,t,e,"add"));else {f(this,u,xe).call(this,g);let _=r(this,T)[g];if(t!==_){if(r(this,ye)&&f(this,u,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=_;l!==void 0&&!o&&(r(this,ae)&&((N=r(this,J))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,F)?.push([l,e,"set"]));}else o||(r(this,ae)&&((P=r(this,J))==null||P.call(this,_,e,"set")),r(this,W)&&r(this,F)?.push([_,e,"set"]));if(r(this,ge).call(this,g),r(this,Ie).call(this,g,h,c),r(this,T)[g]=t,c){c.set="replace";let l=_&&f(this,u,x).call(this,_)?_.__staleWhileFetching:_;l!==void 0&&(c.oldValue=l);}}else c&&(c.set="update");r(this,Ee)&&this.onInsert?.(t,e,t===_?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,u,qe).call(this),r(this,k)&&(y||r(this,Ae).call(this,g,i,a),c&&r(this,pe).call(this,c,g)),!o&&r(this,W)&&r(this,F)){let _=r(this,F),l;for(;l=_?.shift();)(w=r(this,Z))==null||w.call(this,...l);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,T)[r(this,H)];if(f(this,u,Ve).call(this,!0),f(this,u,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,F)){let t=r(this,F),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let o=r(this,T)[a];if(f(this,u,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,$).call(this,a))i&&(i.has="stale",r(this,pe).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,pe).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,$).call(this,i))return;let a=r(this,T)[i];return f(this,u,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:w,forceRefresh:_=false,status:l,signal:d}=t;if(!r(this,ye))return l&&(l.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:p,size:c,sizeCalculation:y,noUpdateTTL:h,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,status:l,signal:d},C=r(this,U).get(e);if(C===void 0){l&&(l.fetch="miss");let R=f(this,u,Fe).call(this,e,C,E,w);return R.__returned=R}else {let R=r(this,T)[C];if(f(this,u,x).call(this,R)){let Q=n&&R.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",Q&&(l.returnedStale=true)),Q?R.__staleWhileFetching:R.__returned=R}let D=r(this,$).call(this,C);if(!_&&!D)return l&&(l.fetch="hit"),f(this,u,xe).call(this,C),i&&r(this,me).call(this,C),l&&r(this,pe).call(this,l,C),R;let se=f(this,u,Fe).call(this,e,C,E,w),G=se.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=D?"stale":"refresh",G&&D&&(l.returnedStale=true)),G?se.__staleWhileFetching:se.__returned=se}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...o}=t,p=this.get(e,o);if(!a&&p!==void 0)return p;let c=n(e,p,{options:o,context:i});return this.set(e,c,o),c}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,p=r(this,U).get(e);if(p!==void 0){let c=r(this,T)[p],y=f(this,u,x).call(this,c);return o&&r(this,pe).call(this,o,p),r(this,$).call(this,p)?(o&&(o.get="stale"),y?(o&&n&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?c.__staleWhileFetching:void 0):(a||f(this,u,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?c:void 0)):(o&&(o.get="hit"),y?c.__staleWhileFetching:(f(this,u,xe).call(this,p),i&&r(this,me).call(this,p),c))}else o&&(o.get="miss");}delete(e){return f(this,u,be).call(this,e,"delete")}clear(){return f(this,u,Qe).call(this,"delete")}},X=new WeakMap,B=new WeakMap,J=new WeakMap,Se=new WeakMap,Z=new WeakMap,_e=new WeakMap,Ce=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,T=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,V=new WeakMap,re=new WeakMap,F=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,q=new WeakMap,ae=new WeakMap,ye=new WeakMap,W=new WeakMap,Ee=new WeakMap,u=new WeakSet,qe=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));S(this,k,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,q,n),S(this,Ae,(p,c,y=r(this,ee).now())=>{t[p]=c!==0?y:0,e[p]=c,i(p,c);}),S(this,me,p=>{t[p]=e[p]!==0?r(this,ee).now():0,i(p,e[p]);});let i=this.ttlAutopurge?(p,c)=>{if(n?.[p]&&(clearTimeout(n[p]),n[p]=void 0),c&&c!==0&&n){let y=setTimeout(()=>{r(this,$).call(this,p)&&f(this,u,be).call(this,r(this,A)[p],"expire");},c+1);y.unref&&y.unref(),n[p]=y;}}:()=>{};S(this,pe,(p,c)=>{if(e[c]){let y=e[c],h=t[c];if(!y||!h)return;p.ttl=y,p.start=h,p.now=a||o();let g=p.now-h;p.remainingTTL=y-g;}});let a=0,o=()=>{let p=r(this,ee).now();if(this.ttlResolution>0){a=p;let c=setTimeout(()=>a=0,this.ttlResolution);c.unref&&c.unref();}return p};this.getRemainingTTL=p=>{let c=r(this,U).get(p);if(c===void 0)return 0;let y=e[c],h=t[c];if(!y||!h)return 1/0;let g=(a||o())-h;return y-g},S(this,$,p=>{let c=t[p],y=e[p];return !!y&&!!c&&(a||o())-c>y});},me=new WeakMap,pe=new WeakMap,Ae=new WeakMap,$=new WeakMap,ot=function(){let e=new Ye(r(this,X));S(this,te,0),S(this,ne,e),S(this,ge,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Me,(t,n,i,a)=>{if(f(this,u,x).call(this,n))return 0;if(!he(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!he(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),S(this,Ie,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,u,Ve).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Ie=new WeakMap,Me=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,V);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,V)));)t=r(this,K)[t];},$e=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Ve=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,T)[t];return r(this,ye)&&f(this,u,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,J))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,F)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,q)?.[t]&&(clearTimeout(r(this,q)[t]),r(this,q)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,T)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(S(this,H,S(this,V,0)),r(this,re).length=0):S(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Fe=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,u,x).call(this,a))return a;let o=new Ge,{signal:p}=n;p?.addEventListener("abort",()=>o.abort(p.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:i},y=(w,_=false)=>{let{aborted:l}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,E=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!_?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!_)return g(o.signal.reason,E);let C=N,R=r(this,T)[t];return (R===N||d&&_&&R===void 0)&&(w===void 0?C.__staleWhileFetching!==void 0?r(this,T)[t]=C.__staleWhileFetching:f(this,u,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,c.options))),w},h=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),g(w,false)),g=(w,_)=>{let{aborted:l}=o.signal,d=l&&n.allowStaleOnFetchAbort,E=d||n.allowStaleOnFetchRejection,C=E||n.noDeleteOnFetchRejection,R=N;if(r(this,T)[t]===N&&(!C||!_&&R.__staleWhileFetching===void 0?f(this,u,be).call(this,e,"fetch"):d||(r(this,T)[t]=R.__staleWhileFetching)),E)return n.status&&R.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),R.__staleWhileFetching;if(R.__returned===R)throw w},M=(w,_)=>{var d;let l=(d=r(this,_e))==null?void 0:d.call(this,e,a,c);l&&l instanceof Promise&&l.then(E=>w(E===void 0?void 0:E),_),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=E=>y(E,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(y,h),P=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,P,{...c.options,status:void 0}),t=r(this,U).get(e)):r(this,T)[t]=P,P},x=function(e){if(!r(this,ye))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},xe=function(e){e!==r(this,V)&&(e===r(this,H)?S(this,H,r(this,K)[e]):f(this,u,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,u,Xe).call(this,r(this,V),e),S(this,V,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let o=r(this,U).get(e);if(o!==void 0)if(r(this,q)?.[o]&&(clearTimeout(r(this,q)?.[o]),r(this,q)[o]=void 0),n=true,r(this,Y)===1)f(this,u,Qe).call(this,t);else {r(this,ge).call(this,o);let p=r(this,T)[o];if(f(this,u,x).call(this,p)?p.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,J))==null||i.call(this,p,e,t)),r(this,W)&&r(this,F)?.push([p,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,T)[o]=void 0,o===r(this,V))S(this,V,r(this,j)[o]);else if(o===r(this,H))S(this,H,r(this,K)[o]);else {let c=r(this,j)[o];r(this,K)[c]=r(this,K)[o];let y=r(this,K)[o];r(this,j)[y]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,F)?.length){let o=r(this,F),p;for(;p=o?.shift();)(a=r(this,Z))==null||a.call(this,...p);}return n},Qe=function(e){var t,n;for(let i of f(this,u,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,u,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,J))==null||t.call(this,a,o,e)),r(this,W)&&r(this,F)?.push([a,o,e]);}}if(r(this,U).clear(),r(this,T).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,q)??[])i!==void 0&&clearTimeout(i);r(this,q)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,H,0),S(this,V,0),r(this,re).length=0,S(this,te,0),S(this,Y,0),r(this,W)&&r(this,F)){let i=r(this,F),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var Ne=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var L;(i=>(i.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),i.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),i.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(L||={});var Oe=new Ne({cacheSize:10}),lt;(o=>{function s(p){let c=Oe.get(p);if(!c){L.error(`Label "${p}" not found`);return}return c}o.get=s;function e(...p){for(let c of p)Oe.set(c.id,c);}o.add=e;function t(){return Array.from(Oe.values())}o.values=t;function n(p){return Oe.has(p)}o.has=n;function i(){return Array.from(Oe.keys())}o.keys=i;function a(){Oe.clear();}o.clear=a;})(lt||={});var le=lt;function ce(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw L.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class s{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(O,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(O,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return L.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return L.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",p=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[i]||(p[i]={}),(!p[i][n]||p[i][n].stepSha1!==o)&&(p[i][n]={stepSha1:o}),p[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return L.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(o=>o===t)||(i.push(t),n.stepCounters=i,s.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let o=s.getCurrentStepTimesCounterData(i);if(!o)return;let p=o.usedRandomNumbers||{},c=Array.from({length:t-e+1},(g,M)=>M+e).filter(g=>!p[`${e}-${t}`]?.includes(g));if(c.length===0)return;let y=Math.floor(Math.random()*c.length),h=c[y];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(h),o.usedRandomNumbers=p,s.setCurrentStepTimesCounterData(i,o),h}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=s.currentLabelStepIndex,n=t+e,i=s.currentLabelId;if(!i||t===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(O,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(O,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return ce(s._openedLabels)}static set openedLabels(e){s._openedLabels=ce(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return ce(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=ce(e);}static get _currentLabel(){if(s.currentLabelId)return le.get(s.currentLabelId)}static get currentLabelId(){if(s._openedLabels.length>0)return s._openedLabels[s._openedLabels.length-1].label}static get currentLabelStepIndex(){return s._openedLabels.length>0?s._openedLabels[s._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},s.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=s.allChoicesMade,o=a.findIndex(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===i&&p.stepSha1===n);o<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[o].madeTimes++,s.allChoicesMade=a;}static pushNewLabel(e){if(!le.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);s._openedLabels.push({label:e,currentStepIndex:0});let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},s.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(s._openedLabels.length>0){let e=s._openedLabels[s._openedLabels.length-1];s._openedLabels[s._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){s._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return s.onLoadingLabel&&e===0&&n.push(s.onLoadingLabel(e,t)),s._onStepStart&&n.push(s._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd;static onLabelStarting;static onLabelClosing};var De=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,p,c=core.GameUnifier.getVariable(O,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,h={currentLabel:b.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:p,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:c,openedLabels:y};b.originalOpenedLabels=y,core.GameUnifier.addHistoryItem(h,{ignoreSameStep:i}),b.lastHistoryStep=h,b.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=b.currentLabelStepIndex,n=this.currentLabel;if(!(t===null||!n))return b.allChoicesMade.filter(i=>i.labelId===n.id&&i.stepIndex===t&&i.stepSha1===e).map(i=>i.choiceIndex)}closeCurrentLabel(){if(!b.currentLabelId){L.warn("No label to close");return}if(!this.currentLabel){L.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}labels={get opened(){return b.openedLabels},get current(){return b._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=le.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(L.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){this.addStepHistory("dev",{ignoreSameStep:true});}getCanContinue(e){let t=e?.showWarn||false,n=this.choicesValue;return n&&n.length>0?(t&&L.warn("The player must make a choice"),false):this.isRequiredInput?(t&&L.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0||this.openedLabels.length===0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){L.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){L.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(o){throw L.error("Error continuing",o),o}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});L.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){L.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){L.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(h){L.error("Error running onStepStart",h),this.onStepError&&await this.onStepError(h,e);return}let o=a.getStepById(i);if(!o){L.error("step not found");return}let p=a.getStepSha(i);p||(L.warn("stepSha not found, setting to ERROR"),p="error");let c,y;try{c=await o(e,{labelId:a.id});}catch(h){L.error("Error running step",h),y=h;}try{let h=this.choicesValue;if(h?.length===1&&h[0].autoSelect){let g=h[0];c=await this.selectChoice(g,e);}}catch(h){L.error("Error auto-selecting choice",h),y||(y=h);}try{let h=b.lastHistoryStep;n!==void 0&&h&&(p=h.stepSha1,p||(L.warn("stepSha not found, setting to ERROR"),p="error"),b.addChoicesMade(h.currentLabel||"error",typeof h.labelStepIndex=="number"?h.labelStepIndex:-1,h.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(h){L.warn("Error adding choice made to history",h);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),this.addStepHistory(p,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(h){L.warn("Error adding step to history",h);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(h){L.warn("Error running onStepEnd",h);}return y&&this.onStepError&&await this.onStepError(y,e),c}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e,t)}else {if(this.openedLabels.length===0)return;L.error("currentLabelId not found");}}async closeLabel(e,t,n){let i=async()=>(this.closeCurrentLabel(),await this.continue(t,n));return b.onLabelClosing?await b.onLabelClosing(e,t,i):await i()}async startLabel(e,t,n){let i=async()=>{let{choiceMade:a,closeCurrentLabel:o,type:p}=n;o&&this.openedLabels.length>0&&this.closeCurrentLabel(),core.GameUnifier.runningStepsCount++;let c;try{let y=le.get(e);if(!y)throw new core.PixiError("unregistered_element",`Label ${e} not found`);b.pushNewLabel(y.id),c=await this.runCurrentStep(t,{choiceMade:a});}catch(y){throw L.error(`Error ${p} label`,y),y}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||c};return b.onLabelStarting?await b.onLabelStarting(e,t,n,i):await i()}async call(e,t,n){let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,type:"calling"})}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choicesValue=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw L.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw L.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){L.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(O,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,ce({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choicesValue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,o)=>({...a,choiceIndex:o})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,o)=>a.oneTime&&i?.includes(o)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choicesValue(e){if(!e||e.length===0){core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,ce(e)),core.GameUnifier.setVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}choicesObj=(()=>{let e=this,t={select:(n,i)=>e.selectChoice(n,i)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:n=>{e.choicesValue=n;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,core.GameUnifier.setVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,n)=>e.requestInput(t,n),removeRequest:()=>e.removeInputRequest()}})();clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:ce(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=le.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):L.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:L.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){L.error("Error running onLoadingLabel",n);}}catch(n){L.error("Error importing data",n);}}};function xt(s,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:s,type:n?.type||"call"}}var pt="close";function At(s,e){return {...e,type:pt,text:s}}var ft=Ct(dt());var ve=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var we=class extends ve{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&L.warn("stepSha not found, setting to ERROR"),"error";try{return (0,ft.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(n){return L.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(s,e,t){let n=new we(s,e,t);return le.add(n),n}var Cr=new De;
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn/core');var yt=Object.create;var We=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,Lt=Object.prototype.hasOwnProperty;var Je=s=>{throw TypeError(s)};var Tt=(s,e,t)=>e in s?We(s,e,{enumerable:true,configurable:true,writable:true,value:t}):s[e]=t;var Be=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var Ze=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var _t=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of mt(e))!Lt.call(s,i)&&i!==t&&We(s,i,{get:()=>e[i],enumerable:!(n=St(e,i))||n.enumerable});return s};var Ct=(s,e,t)=>(t=s!=null?yt(gt(s)):{},_t(We(t,"default",{value:s,enumerable:true}),s));var z=(s,e,t)=>Tt(s,typeof e!="symbol"?e+"":e,t),je=(s,e,t)=>e.has(s)||Je("Cannot "+t);var r=(s,e,t)=>(je(s,e,"read from private field"),t?t.call(s):e.get(s)),v=(s,e,t)=>e.has(s)?Je("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(s):e.set(s,t),S=(s,e,t,n)=>(je(s,e,"write to private field"),e.set(s,t),t),f=(s,e,t)=>(je(s,e,"access private method"),t);var Ue=(s,e,t,n)=>({set _(i){S(s,e,i);},get _(){return r(s,e,n)}});var ut=Ze((ze,ct)=>{(function(s,e){typeof ze=="object"?ct.exports=ze=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(ze,function(){var s=s||(function(e,t){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof Be=="function")try{n=Be("crypto");}catch{}var i=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},a=Object.create||(function(){function l(){}return function(d){var E;return l.prototype=d,E=new l,l.prototype=null,E}})(),o={},p=o.lib={},c=p.Base=(function(){return {extend:function(l){var d=a(this);return l&&d.mixIn(l),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var l=this.extend();return l.init.apply(l,arguments),l},init:function(){},mixIn:function(l){for(var d in l)l.hasOwnProperty(d)&&(this[d]=l[d]);l.hasOwnProperty("toString")&&(this.toString=l.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),y=p.WordArray=c.extend({init:function(l,d){l=this.words=l||[],d!=t?this.sigBytes=d:this.sigBytes=l.length*4;},toString:function(l){return (l||g).stringify(this)},concat:function(l){var d=this.words,E=l.words,C=this.sigBytes,R=l.sigBytes;if(this.clamp(),C%4)for(var D=0;D<R;D++){var se=E[D>>>2]>>>24-D%4*8&255;d[C+D>>>2]|=se<<24-(C+D)%4*8;}else for(var G=0;G<R;G+=4)d[C+G>>>2]=E[G>>>2];return this.sigBytes+=R,this},clamp:function(){var l=this.words,d=this.sigBytes;l[d>>>2]&=4294967295<<32-d%4*8,l.length=e.ceil(d/4);},clone:function(){var l=c.clone.call(this);return l.words=this.words.slice(0),l},random:function(l){for(var d=[],E=0;E<l;E+=4)d.push(i());return new y.init(d,l)}}),h=o.enc={},g=h.Hex={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push((D>>>4).toString(16)),C.push((D&15).toString(16));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C+=2)E[C>>>3]|=parseInt(l.substr(C,2),16)<<24-C%8*4;return new y.init(E,d/2)}},M=h.Latin1={stringify:function(l){for(var d=l.words,E=l.sigBytes,C=[],R=0;R<E;R++){var D=d[R>>>2]>>>24-R%4*8&255;C.push(String.fromCharCode(D));}return C.join("")},parse:function(l){for(var d=l.length,E=[],C=0;C<d;C++)E[C>>>2]|=(l.charCodeAt(C)&255)<<24-C%4*8;return new y.init(E,d)}},N=h.Utf8={stringify:function(l){try{return decodeURIComponent(escape(M.stringify(l)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(l){return M.parse(unescape(encodeURIComponent(l)))}},P=p.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new y.init,this._nDataBytes=0;},_append:function(l){typeof l=="string"&&(l=N.parse(l)),this._data.concat(l),this._nDataBytes+=l.sigBytes;},_process:function(l){var d,E=this._data,C=E.words,R=E.sigBytes,D=this.blockSize,se=D*4,G=R/se;l?G=e.ceil(G):G=e.max((G|0)-this._minBufferSize,0);var Q=G*D,Le=e.min(Q*4,R);if(Q){for(var Ke=0;Ke<Q;Ke+=D)this._doProcessBlock(C,Ke);d=C.splice(0,Q),E.sigBytes-=Le;}return new y.init(d,Le)},clone:function(){var l=c.clone.call(this);return l._data=this._data.clone(),l},_minBufferSize:0});p.Hasher=P.extend({cfg:c.extend(),init:function(l){this.cfg=this.cfg.extend(l),this.reset();},reset:function(){P.reset.call(this),this._doReset();},update:function(l){return this._append(l),this._process(),this},finalize:function(l){l&&this._append(l);var d=this._doFinalize();return d},blockSize:512/32,_createHelper:function(l){return function(d,E){return new l.init(E).finalize(d)}},_createHmacHelper:function(l){return function(d,E){return new _.HMAC.init(l,E).finalize(d)}}});var _=o.algo={};return o})(Math);return s});});var dt=Ze((He,ht)=>{(function(s,e){typeof He=="object"?ht.exports=He=e(ut()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(He,function(s){return (function(){var e=s,t=e.lib,n=t.WordArray,i=t.Hasher,a=e.algo,o=[],p=a.SHA1=i.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(c,y){for(var h=this._hash.words,g=h[0],M=h[1],N=h[2],P=h[3],w=h[4],_=0;_<80;_++){if(_<16)o[_]=c[y+_]|0;else {var l=o[_-3]^o[_-8]^o[_-14]^o[_-16];o[_]=l<<1|l>>>31;}var d=(g<<5|g>>>27)+w+o[_];_<20?d+=(M&N|~M&P)+1518500249:_<40?d+=(M^N^P)+1859775393:_<60?d+=(M&N|M&P|N&P)-1894007588:d+=(M^N^P)-899497514,w=P,P=N,N=M<<30|M>>>2,M=g,g=d;}h[0]=h[0]+g|0,h[1]=h[1]+M|0,h[2]=h[2]+N|0,h[3]=h[3]+P|0,h[4]=h[4]+w|0;},_doFinalize:function(){var c=this._data,y=c.words,h=this._nDataBytes*8,g=c.sigBytes*8;return y[g>>>5]|=128<<24-g%32,y[(g+64>>>9<<4)+14]=Math.floor(h/4294967296),y[(g+64>>>9<<4)+15]=h,c.sigBytes=y.length*4,this._process(),this._hash},clone:function(){var c=i.clone.call(this);return c._hash=this._hash.clone(),c}});e.SHA1=i._createHelper(p),e.HmacSHA1=i._createHmacHelper(p);})(),s.SHA1});});var O="narration";var I={CURRENT_DIALOGUE_MEMORY_KEY:"dialogue",LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY:"dialogue:step_counter",CURRENT_MENU_OPTIONS_MEMORY_KEY:"choice:options",LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY:"choice:step_counter",CURRENT_INPUT_VALUE_MEMORY_KEY:"input:value",LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY:"input:step_counter",CURRENT_INPUT_INFO_MEMORY_KEY:"input:info",CHARACTER_CATEGORY_KEY:"character",ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY:"___glue___",OPENED_LABELS_COUNTER_KEY:"label:opened",ALL_CHOICES_MADE_KEY:"choices:made",CURRENT_STEP_TIMES_COUNTER_KEY:"label:history",LAST_STEP_GLUED:"glue:last_step"};var Et=typeof performance=="object"&&performance&&typeof performance.now=="function"?performance:Date,nt=new Set,ke=typeof process=="object"&&process?process:{},it=(s,e,t,n)=>{typeof ke.emitWarning=="function"?ke.emitWarning(s,e,t,n):console.error(`[${t}] ${e}: ${s}`);},Ge=globalThis.AbortController,et=globalThis.AbortSignal;if(typeof Ge>"u"){et=class{onabort;_onabort=[];reason;aborted=false;addEventListener(t,n){this._onabort.push(n);}},Ge=class{constructor(){e();}signal=new et;abort(t){if(!this.signal.aborted){this.signal.reason=t,this.signal.aborted=true;for(let n of this.signal._onabort)n(t);this.signal.onabort?.(t);}}};let s=ke.env?.LRU_CACHE_IGNORE_AC_WARNING!=="1",e=()=>{s&&(s=false,it("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.","NO_ABORT_CONTROLLER","ENOTSUP",e));};}var It=s=>!nt.has(s);var he=s=>s&&s===Math.floor(s)&&s>0&&isFinite(s),at=s=>he(s)?s<=Math.pow(2,8)?Uint8Array:s<=Math.pow(2,16)?Uint16Array:s<=Math.pow(2,32)?Uint32Array:s<=Number.MAX_SAFE_INTEGER?Ye:null:null,Ye=class extends Array{constructor(s){super(s),this.fill(0);}},oe,Te,Rt=(oe=class{heap;length;static create(e){let t=at(e);if(!t)return [];S(oe,Te,true);let n=new oe(e,t);return S(oe,Te,false),n}constructor(e,t){if(!r(oe,Te))throw new TypeError("instantiate Stack using Stack.create(n)");this.heap=new t(e),this.length=0;}push(e){this.heap[this.length++]=e;}pop(){return this.heap[--this.length]}},Te=new WeakMap,v(oe,Te,false),oe),tt,rt,X,B,J,Se,Z,_e,Ce,ee,Y,te,U,A,T,K,j,H,V,re,F,ne,ie,k,q,ae,ye,W,Ee,u,qe,me,pe,Ae,$,ot,ge,Ie,Me,de,fe,$e,Ve,Fe,x,Xe,xe,be,Qe,Re,st=(Re=class{constructor(e){v(this,u);v(this,X);v(this,B);v(this,J);v(this,Se);v(this,Z);v(this,_e);v(this,Ce);v(this,ee);z(this,"ttl");z(this,"ttlResolution");z(this,"ttlAutopurge");z(this,"updateAgeOnGet");z(this,"updateAgeOnHas");z(this,"allowStale");z(this,"noDisposeOnSet");z(this,"noUpdateTTL");z(this,"maxEntrySize");z(this,"sizeCalculation");z(this,"noDeleteOnFetchRejection");z(this,"noDeleteOnStaleGet");z(this,"allowStaleOnFetchAbort");z(this,"allowStaleOnFetchRejection");z(this,"ignoreFetchAbort");v(this,Y);v(this,te);v(this,U);v(this,A);v(this,T);v(this,K);v(this,j);v(this,H);v(this,V);v(this,re);v(this,F);v(this,ne);v(this,ie);v(this,k);v(this,q);v(this,ae);v(this,ye);v(this,W);v(this,Ee);v(this,me,()=>{});v(this,pe,()=>{});v(this,Ae,()=>{});v(this,$,()=>false);v(this,ge,e=>{});v(this,Ie,(e,t,n)=>{});v(this,Me,(e,t,n,i)=>{if(n||i)throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");return 0});z(this,tt,"LRUCache");let{max:t=0,ttl:n,ttlResolution:i=1,ttlAutopurge:a,updateAgeOnGet:o,updateAgeOnHas:p,allowStale:c,dispose:y,onInsert:h,disposeAfter:g,noDisposeOnSet:M,noUpdateTTL:N,maxSize:P=0,maxEntrySize:w=0,sizeCalculation:_,fetchMethod:l,memoMethod:d,noDeleteOnFetchRejection:E,noDeleteOnStaleGet:C,allowStaleOnFetchRejection:R,allowStaleOnFetchAbort:D,ignoreFetchAbort:se,perf:G}=e;if(G!==void 0&&typeof G?.now!="function")throw new TypeError("perf option must have a now() method if specified");if(S(this,ee,G??Et),t!==0&&!he(t))throw new TypeError("max option must be a nonnegative integer");let Q=t?at(t):Array;if(!Q)throw new Error("invalid max value: "+t);if(S(this,X,t),S(this,B,P),this.maxEntrySize=w||r(this,B),this.sizeCalculation=_,this.sizeCalculation){if(!r(this,B)&&!this.maxEntrySize)throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");if(typeof this.sizeCalculation!="function")throw new TypeError("sizeCalculation set to non-function")}if(d!==void 0&&typeof d!="function")throw new TypeError("memoMethod must be a function if defined");if(S(this,Ce,d),l!==void 0&&typeof l!="function")throw new TypeError("fetchMethod must be a function if specified");if(S(this,_e,l),S(this,ye,!!l),S(this,U,new Map),S(this,A,new Array(t).fill(void 0)),S(this,T,new Array(t).fill(void 0)),S(this,K,new Q(t)),S(this,j,new Q(t)),S(this,H,0),S(this,V,0),S(this,re,Rt.create(t)),S(this,Y,0),S(this,te,0),typeof y=="function"&&S(this,J,y),typeof h=="function"&&S(this,Se,h),typeof g=="function"?(S(this,Z,g),S(this,F,[])):(S(this,Z,void 0),S(this,F,void 0)),S(this,ae,!!r(this,J)),S(this,Ee,!!r(this,Se)),S(this,W,!!r(this,Z)),this.noDisposeOnSet=!!M,this.noUpdateTTL=!!N,this.noDeleteOnFetchRejection=!!E,this.allowStaleOnFetchRejection=!!R,this.allowStaleOnFetchAbort=!!D,this.ignoreFetchAbort=!!se,this.maxEntrySize!==0){if(r(this,B)!==0&&!he(r(this,B)))throw new TypeError("maxSize must be a positive integer if specified");if(!he(this.maxEntrySize))throw new TypeError("maxEntrySize must be a positive integer if specified");f(this,u,ot).call(this);}if(this.allowStale=!!c,this.noDeleteOnStaleGet=!!C,this.updateAgeOnGet=!!o,this.updateAgeOnHas=!!p,this.ttlResolution=he(i)||i===0?i:1,this.ttlAutopurge=!!a,this.ttl=n||0,this.ttl){if(!he(this.ttl))throw new TypeError("ttl must be a positive integer if specified");f(this,u,qe).call(this);}if(r(this,X)===0&&this.ttl===0&&r(this,B)===0)throw new TypeError("At least one of max, maxSize, or ttl is required");if(!this.ttlAutopurge&&!r(this,X)&&!r(this,B)){let Le="LRU_CACHE_UNBOUNDED";It(Le)&&(nt.add(Le),it("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.","UnboundedCacheWarning",Le,Re));}}get perf(){return r(this,ee)}static unsafeExposeInternals(e){return {starts:r(e,ie),ttls:r(e,k),autopurgeTimers:r(e,q),sizes:r(e,ne),keyMap:r(e,U),keyList:r(e,A),valList:r(e,T),next:r(e,K),prev:r(e,j),get head(){return r(e,H)},get tail(){return r(e,V)},free:r(e,re),isBackgroundFetch:t=>{var n;return f(n=e,u,x).call(n,t)},backgroundFetch:(t,n,i,a)=>{var o;return f(o=e,u,Fe).call(o,t,n,i,a)},moveToTail:t=>{var n;return f(n=e,u,xe).call(n,t)},indexes:t=>{var n;return f(n=e,u,de).call(n,t)},rindexes:t=>{var n;return f(n=e,u,fe).call(n,t)},isStale:t=>{var n;return r(n=e,$).call(n,t)}}}get max(){return r(this,X)}get maxSize(){return r(this,B)}get calculatedSize(){return r(this,te)}get size(){return r(this,Y)}get fetchMethod(){return r(this,_e)}get memoMethod(){return r(this,Ce)}get dispose(){return r(this,J)}get onInsert(){return r(this,Se)}get disposeAfter(){return r(this,Z)}getRemainingTTL(e){return r(this,U).has(e)?1/0:0}*entries(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*rentries(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&r(this,A)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield [r(this,A)[e],r(this,T)[e]]);}*keys(){for(let e of f(this,u,de).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*rkeys(){for(let e of f(this,u,fe).call(this)){let t=r(this,A)[e];t!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield t);}}*values(){for(let e of f(this,u,de).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}*rvalues(){for(let e of f(this,u,fe).call(this))r(this,T)[e]!==void 0&&!f(this,u,x).call(this,r(this,T)[e])&&(yield r(this,T)[e]);}[(rt=Symbol.iterator,tt=Symbol.toStringTag,rt)](){return this.entries()}find(e,t={}){for(let n of f(this,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;if(a!==void 0&&e(a,r(this,A)[n],this))return this.get(r(this,A)[n],t)}}forEach(e,t=this){for(let n of f(this,u,de).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}rforEach(e,t=this){for(let n of f(this,u,fe).call(this)){let i=r(this,T)[n],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;a!==void 0&&e.call(t,a,r(this,A)[n],this);}}purgeStale(){let e=false;for(let t of f(this,u,fe).call(this,{allowStale:true}))r(this,$).call(this,t)&&(f(this,u,be).call(this,r(this,A)[t],"expire"),e=true);return e}info(e){let t=r(this,U).get(e);if(t===void 0)return;let n=r(this,T)[t],i=f(this,u,x).call(this,n)?n.__staleWhileFetching:n;if(i===void 0)return;let a={value:i};if(r(this,k)&&r(this,ie)){let o=r(this,k)[t],p=r(this,ie)[t];if(o&&p){let c=o-(r(this,ee).now()-p);a.ttl=c,a.start=Date.now();}}return r(this,ne)&&(a.size=r(this,ne)[t]),a}dump(){let e=[];for(let t of f(this,u,de).call(this,{allowStale:true})){let n=r(this,A)[t],i=r(this,T)[t],a=f(this,u,x).call(this,i)?i.__staleWhileFetching:i;if(a===void 0||n===void 0)continue;let o={value:a};if(r(this,k)&&r(this,ie)){o.ttl=r(this,k)[t];let p=r(this,ee).now()-r(this,ie)[t];o.start=Math.floor(Date.now()-p);}r(this,ne)&&(o.size=r(this,ne)[t]),e.unshift([n,o]);}return e}load(e){this.clear();for(let[t,n]of e){if(n.start){let i=Date.now()-n.start;n.start=r(this,ee).now()-i;}this.set(t,n.value,n);}}set(e,t,n={}){var M,N,P,w;if(t===void 0)return this.delete(e),this;let{ttl:i=this.ttl,start:a,noDisposeOnSet:o=this.noDisposeOnSet,sizeCalculation:p=this.sizeCalculation,status:c}=n,{noUpdateTTL:y=this.noUpdateTTL}=n,h=r(this,Me).call(this,e,t,n.size||0,p);if(this.maxEntrySize&&h>this.maxEntrySize)return c&&(c.set="miss",c.maxEntrySizeExceeded=true),f(this,u,be).call(this,e,"set"),this;let g=r(this,Y)===0?void 0:r(this,U).get(e);if(g===void 0)g=r(this,Y)===0?r(this,V):r(this,re).length!==0?r(this,re).pop():r(this,Y)===r(this,X)?f(this,u,Ve).call(this,false):r(this,Y),r(this,A)[g]=e,r(this,T)[g]=t,r(this,U).set(e,g),r(this,K)[r(this,V)]=g,r(this,j)[g]=r(this,V),S(this,V,g),Ue(this,Y)._++,r(this,Ie).call(this,g,h,c),c&&(c.set="add"),y=false,r(this,Ee)&&((M=r(this,Se))==null||M.call(this,t,e,"add"));else {f(this,u,xe).call(this,g);let _=r(this,T)[g];if(t!==_){if(r(this,ye)&&f(this,u,x).call(this,_)){_.__abortController.abort(new Error("replaced"));let{__staleWhileFetching:l}=_;l!==void 0&&!o&&(r(this,ae)&&((N=r(this,J))==null||N.call(this,l,e,"set")),r(this,W)&&r(this,F)?.push([l,e,"set"]));}else o||(r(this,ae)&&((P=r(this,J))==null||P.call(this,_,e,"set")),r(this,W)&&r(this,F)?.push([_,e,"set"]));if(r(this,ge).call(this,g),r(this,Ie).call(this,g,h,c),r(this,T)[g]=t,c){c.set="replace";let l=_&&f(this,u,x).call(this,_)?_.__staleWhileFetching:_;l!==void 0&&(c.oldValue=l);}}else c&&(c.set="update");r(this,Ee)&&this.onInsert?.(t,e,t===_?"update":"replace");}if(i!==0&&!r(this,k)&&f(this,u,qe).call(this),r(this,k)&&(y||r(this,Ae).call(this,g,i,a),c&&r(this,pe).call(this,c,g)),!o&&r(this,W)&&r(this,F)){let _=r(this,F),l;for(;l=_?.shift();)(w=r(this,Z))==null||w.call(this,...l);}return this}pop(){var e;try{for(;r(this,Y);){let t=r(this,T)[r(this,H)];if(f(this,u,Ve).call(this,!0),f(this,u,x).call(this,t)){if(t.__staleWhileFetching)return t.__staleWhileFetching}else if(t!==void 0)return t}}finally{if(r(this,W)&&r(this,F)){let t=r(this,F),n;for(;n=t?.shift();)(e=r(this,Z))==null||e.call(this,...n);}}}has(e,t={}){let{updateAgeOnHas:n=this.updateAgeOnHas,status:i}=t,a=r(this,U).get(e);if(a!==void 0){let o=r(this,T)[a];if(f(this,u,x).call(this,o)&&o.__staleWhileFetching===void 0)return false;if(r(this,$).call(this,a))i&&(i.has="stale",r(this,pe).call(this,i,a));else return n&&r(this,me).call(this,a),i&&(i.has="hit",r(this,pe).call(this,i,a)),true}else i&&(i.has="miss");return false}peek(e,t={}){let{allowStale:n=this.allowStale}=t,i=r(this,U).get(e);if(i===void 0||!n&&r(this,$).call(this,i))return;let a=r(this,T)[i];return f(this,u,x).call(this,a)?a.__staleWhileFetching:a}async fetch(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,ttl:o=this.ttl,noDisposeOnSet:p=this.noDisposeOnSet,size:c=0,sizeCalculation:y=this.sizeCalculation,noUpdateTTL:h=this.noUpdateTTL,noDeleteOnFetchRejection:g=this.noDeleteOnFetchRejection,allowStaleOnFetchRejection:M=this.allowStaleOnFetchRejection,ignoreFetchAbort:N=this.ignoreFetchAbort,allowStaleOnFetchAbort:P=this.allowStaleOnFetchAbort,context:w,forceRefresh:_=false,status:l,signal:d}=t;if(!r(this,ye))return l&&(l.fetch="get"),this.get(e,{allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,status:l});let E={allowStale:n,updateAgeOnGet:i,noDeleteOnStaleGet:a,ttl:o,noDisposeOnSet:p,size:c,sizeCalculation:y,noUpdateTTL:h,noDeleteOnFetchRejection:g,allowStaleOnFetchRejection:M,allowStaleOnFetchAbort:P,ignoreFetchAbort:N,status:l,signal:d},C=r(this,U).get(e);if(C===void 0){l&&(l.fetch="miss");let R=f(this,u,Fe).call(this,e,C,E,w);return R.__returned=R}else {let R=r(this,T)[C];if(f(this,u,x).call(this,R)){let Q=n&&R.__staleWhileFetching!==void 0;return l&&(l.fetch="inflight",Q&&(l.returnedStale=true)),Q?R.__staleWhileFetching:R.__returned=R}let D=r(this,$).call(this,C);if(!_&&!D)return l&&(l.fetch="hit"),f(this,u,xe).call(this,C),i&&r(this,me).call(this,C),l&&r(this,pe).call(this,l,C),R;let se=f(this,u,Fe).call(this,e,C,E,w),G=se.__staleWhileFetching!==void 0&&n;return l&&(l.fetch=D?"stale":"refresh",G&&D&&(l.returnedStale=true)),G?se.__staleWhileFetching:se.__returned=se}}async forceFetch(e,t={}){let n=await this.fetch(e,t);if(n===void 0)throw new Error("fetch() returned undefined");return n}memo(e,t={}){let n=r(this,Ce);if(!n)throw new Error("no memoMethod provided to constructor");let{context:i,forceRefresh:a,...o}=t,p=this.get(e,o);if(!a&&p!==void 0)return p;let c=n(e,p,{options:o,context:i});return this.set(e,c,o),c}get(e,t={}){let{allowStale:n=this.allowStale,updateAgeOnGet:i=this.updateAgeOnGet,noDeleteOnStaleGet:a=this.noDeleteOnStaleGet,status:o}=t,p=r(this,U).get(e);if(p!==void 0){let c=r(this,T)[p],y=f(this,u,x).call(this,c);return o&&r(this,pe).call(this,o,p),r(this,$).call(this,p)?(o&&(o.get="stale"),y?(o&&n&&c.__staleWhileFetching!==void 0&&(o.returnedStale=true),n?c.__staleWhileFetching:void 0):(a||f(this,u,be).call(this,e,"expire"),o&&n&&(o.returnedStale=true),n?c:void 0)):(o&&(o.get="hit"),y?c.__staleWhileFetching:(f(this,u,xe).call(this,p),i&&r(this,me).call(this,p),c))}else o&&(o.get="miss");}delete(e){return f(this,u,be).call(this,e,"delete")}clear(){return f(this,u,Qe).call(this,"delete")}},X=new WeakMap,B=new WeakMap,J=new WeakMap,Se=new WeakMap,Z=new WeakMap,_e=new WeakMap,Ce=new WeakMap,ee=new WeakMap,Y=new WeakMap,te=new WeakMap,U=new WeakMap,A=new WeakMap,T=new WeakMap,K=new WeakMap,j=new WeakMap,H=new WeakMap,V=new WeakMap,re=new WeakMap,F=new WeakMap,ne=new WeakMap,ie=new WeakMap,k=new WeakMap,q=new WeakMap,ae=new WeakMap,ye=new WeakMap,W=new WeakMap,Ee=new WeakMap,u=new WeakSet,qe=function(){let e=new Ye(r(this,X)),t=new Ye(r(this,X));S(this,k,e),S(this,ie,t);let n=this.ttlAutopurge?new Array(r(this,X)):void 0;S(this,q,n),S(this,Ae,(p,c,y=r(this,ee).now())=>{t[p]=c!==0?y:0,e[p]=c,i(p,c);}),S(this,me,p=>{t[p]=e[p]!==0?r(this,ee).now():0,i(p,e[p]);});let i=this.ttlAutopurge?(p,c)=>{if(n?.[p]&&(clearTimeout(n[p]),n[p]=void 0),c&&c!==0&&n){let y=setTimeout(()=>{r(this,$).call(this,p)&&f(this,u,be).call(this,r(this,A)[p],"expire");},c+1);y.unref&&y.unref(),n[p]=y;}}:()=>{};S(this,pe,(p,c)=>{if(e[c]){let y=e[c],h=t[c];if(!y||!h)return;p.ttl=y,p.start=h,p.now=a||o();let g=p.now-h;p.remainingTTL=y-g;}});let a=0,o=()=>{let p=r(this,ee).now();if(this.ttlResolution>0){a=p;let c=setTimeout(()=>a=0,this.ttlResolution);c.unref&&c.unref();}return p};this.getRemainingTTL=p=>{let c=r(this,U).get(p);if(c===void 0)return 0;let y=e[c],h=t[c];if(!y||!h)return 1/0;let g=(a||o())-h;return y-g},S(this,$,p=>{let c=t[p],y=e[p];return !!y&&!!c&&(a||o())-c>y});},me=new WeakMap,pe=new WeakMap,Ae=new WeakMap,$=new WeakMap,ot=function(){let e=new Ye(r(this,X));S(this,te,0),S(this,ne,e),S(this,ge,t=>{S(this,te,r(this,te)-e[t]),e[t]=0;}),S(this,Me,(t,n,i,a)=>{if(f(this,u,x).call(this,n))return 0;if(!he(i))if(a){if(typeof a!="function")throw new TypeError("sizeCalculation must be a function");if(i=a(n,t),!he(i))throw new TypeError("sizeCalculation return invalid (expect positive integer)")}else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");return i}),S(this,Ie,(t,n,i)=>{if(e[t]=n,r(this,B)){let a=r(this,B)-e[t];for(;r(this,te)>a;)f(this,u,Ve).call(this,true);}S(this,te,r(this,te)+e[t]),i&&(i.entrySize=n,i.totalCalculatedSize=r(this,te));});},ge=new WeakMap,Ie=new WeakMap,Me=new WeakMap,de=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,V);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,H)));)t=r(this,j)[t];},fe=function*({allowStale:e=this.allowStale}={}){if(r(this,Y))for(let t=r(this,H);!(!f(this,u,$e).call(this,t)||((e||!r(this,$).call(this,t))&&(yield t),t===r(this,V)));)t=r(this,K)[t];},$e=function(e){return e!==void 0&&r(this,U).get(r(this,A)[e])===e},Ve=function(e){var a;let t=r(this,H),n=r(this,A)[t],i=r(this,T)[t];return r(this,ye)&&f(this,u,x).call(this,i)?i.__abortController.abort(new Error("evicted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((a=r(this,J))==null||a.call(this,i,n,"evict")),r(this,W)&&r(this,F)?.push([i,n,"evict"])),r(this,ge).call(this,t),r(this,q)?.[t]&&(clearTimeout(r(this,q)[t]),r(this,q)[t]=void 0),e&&(r(this,A)[t]=void 0,r(this,T)[t]=void 0,r(this,re).push(t)),r(this,Y)===1?(S(this,H,S(this,V,0)),r(this,re).length=0):S(this,H,r(this,K)[t]),r(this,U).delete(n),Ue(this,Y)._--,t},Fe=function(e,t,n,i){let a=t===void 0?void 0:r(this,T)[t];if(f(this,u,x).call(this,a))return a;let o=new Ge,{signal:p}=n;p?.addEventListener("abort",()=>o.abort(p.reason),{signal:o.signal});let c={signal:o.signal,options:n,context:i},y=(w,_=false)=>{let{aborted:l}=o.signal,d=n.ignoreFetchAbort&&w!==void 0,E=n.ignoreFetchAbort||!!(n.allowStaleOnFetchAbort&&w!==void 0);if(n.status&&(l&&!_?(n.status.fetchAborted=true,n.status.fetchError=o.signal.reason,d&&(n.status.fetchAbortIgnored=true)):n.status.fetchResolved=true),l&&!d&&!_)return g(o.signal.reason,E);let C=N,R=r(this,T)[t];return (R===N||d&&_&&R===void 0)&&(w===void 0?C.__staleWhileFetching!==void 0?r(this,T)[t]=C.__staleWhileFetching:f(this,u,be).call(this,e,"fetch"):(n.status&&(n.status.fetchUpdated=true),this.set(e,w,c.options))),w},h=w=>(n.status&&(n.status.fetchRejected=true,n.status.fetchError=w),g(w,false)),g=(w,_)=>{let{aborted:l}=o.signal,d=l&&n.allowStaleOnFetchAbort,E=d||n.allowStaleOnFetchRejection,C=E||n.noDeleteOnFetchRejection,R=N;if(r(this,T)[t]===N&&(!C||!_&&R.__staleWhileFetching===void 0?f(this,u,be).call(this,e,"fetch"):d||(r(this,T)[t]=R.__staleWhileFetching)),E)return n.status&&R.__staleWhileFetching!==void 0&&(n.status.returnedStale=true),R.__staleWhileFetching;if(R.__returned===R)throw w},M=(w,_)=>{var d;let l=(d=r(this,_e))==null?void 0:d.call(this,e,a,c);l&&l instanceof Promise&&l.then(E=>w(E===void 0?void 0:E),_),o.signal.addEventListener("abort",()=>{(!n.ignoreFetchAbort||n.allowStaleOnFetchAbort)&&(w(void 0),n.allowStaleOnFetchAbort&&(w=E=>y(E,true)));});};n.status&&(n.status.fetchDispatched=true);let N=new Promise(M).then(y,h),P=Object.assign(N,{__abortController:o,__staleWhileFetching:a,__returned:void 0});return t===void 0?(this.set(e,P,{...c.options,status:void 0}),t=r(this,U).get(e)):r(this,T)[t]=P,P},x=function(e){if(!r(this,ye))return false;let t=e;return !!t&&t instanceof Promise&&t.hasOwnProperty("__staleWhileFetching")&&t.__abortController instanceof Ge},Xe=function(e,t){r(this,j)[t]=e,r(this,K)[e]=t;},xe=function(e){e!==r(this,V)&&(e===r(this,H)?S(this,H,r(this,K)[e]):f(this,u,Xe).call(this,r(this,j)[e],r(this,K)[e]),f(this,u,Xe).call(this,r(this,V),e),S(this,V,e));},be=function(e,t){var i,a;let n=false;if(r(this,Y)!==0){let o=r(this,U).get(e);if(o!==void 0)if(r(this,q)?.[o]&&(clearTimeout(r(this,q)?.[o]),r(this,q)[o]=void 0),n=true,r(this,Y)===1)f(this,u,Qe).call(this,t);else {r(this,ge).call(this,o);let p=r(this,T)[o];if(f(this,u,x).call(this,p)?p.__abortController.abort(new Error("deleted")):(r(this,ae)||r(this,W))&&(r(this,ae)&&((i=r(this,J))==null||i.call(this,p,e,t)),r(this,W)&&r(this,F)?.push([p,e,t])),r(this,U).delete(e),r(this,A)[o]=void 0,r(this,T)[o]=void 0,o===r(this,V))S(this,V,r(this,j)[o]);else if(o===r(this,H))S(this,H,r(this,K)[o]);else {let c=r(this,j)[o];r(this,K)[c]=r(this,K)[o];let y=r(this,K)[o];r(this,j)[y]=r(this,j)[o];}Ue(this,Y)._--,r(this,re).push(o);}}if(r(this,W)&&r(this,F)?.length){let o=r(this,F),p;for(;p=o?.shift();)(a=r(this,Z))==null||a.call(this,...p);}return n},Qe=function(e){var t,n;for(let i of f(this,u,fe).call(this,{allowStale:true})){let a=r(this,T)[i];if(f(this,u,x).call(this,a))a.__abortController.abort(new Error("deleted"));else {let o=r(this,A)[i];r(this,ae)&&((t=r(this,J))==null||t.call(this,a,o,e)),r(this,W)&&r(this,F)?.push([a,o,e]);}}if(r(this,U).clear(),r(this,T).fill(void 0),r(this,A).fill(void 0),r(this,k)&&r(this,ie)){r(this,k).fill(0),r(this,ie).fill(0);for(let i of r(this,q)??[])i!==void 0&&clearTimeout(i);r(this,q)?.fill(void 0);}if(r(this,ne)&&r(this,ne).fill(0),S(this,H,0),S(this,V,0),r(this,re).length=0,S(this,te,0),S(this,Y,0),r(this,W)&&r(this,F)){let i=r(this,F),a;for(;a=i?.shift();)(n=r(this,Z))==null||n.call(this,...a);}},Re);var Ne=class{cache;map=new Map;constructor(e){this.cache=new st({max:e.cacheSize}),this.map=new Map;}get[Symbol.iterator](){return this.map[Symbol.iterator]}get[Symbol.toStringTag](){return this.map[Symbol.toStringTag]}clear(){this.cache.clear(),this.map.clear();}delete(e){let t=this.map.delete(e);return t&&this.cache.delete(e),t}get forEach(){return this.map.forEach}get(e){let t=this.cache.get(e);return t||this.map.get(e)}has(e){return this.map.has(e)}set(e,t){return this.map.set(e,t),this.cache.set(e,t),this}get size(){return this.map.size}entries(){return this.map.entries()}keys(){return this.map.keys()}values(){return this.map.values()}};var L;(i=>(i.log=(a,...o)=>console.log(`[Pixi\u2019VN] ${a}`,...o),i.warn=(a,...o)=>console.warn(`[Pixi\u2019VN] ${a}`,...o),i.error=(a,...o)=>console.error(`[Pixi\u2019VN] ${a}`,...o),i.info=(a,...o)=>console.info(`[Pixi\u2019VN] ${a}`,...o)))(L||={});var Oe=new Ne({cacheSize:10}),lt;(o=>{function s(p){let c=Oe.get(p);if(!c){L.error(`Label "${p}" not found`);return}return c}o.get=s;function e(...p){for(let c of p)Oe.set(c.id,c);}o.add=e;function t(){return Array.from(Oe.values())}o.values=t;function n(p){return Oe.has(p)}o.has=n;function i(){return Array.from(Oe.keys())}o.keys=i;function a(){Oe.clear();}o.clear=a;})(lt||={});var le=lt;function ce(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw L.error("Error creating exportable element",s,e),new core.PixiError("not_json_serializable","Error creating exportable element")}}var b=class s{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return core.GameUnifier.getVariable(O,I.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){core.GameUnifier.setVariable(O,I.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=s.currentLabelStepIndex;if(t===null)return L.error("currentLabelStepIndex is null"),null;let n=`${t}${e}`,i=s.currentLabelId,a=s._currentLabel;if(!i||t===null||!a)return L.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let o=a.getStepSha(t)||"error",p=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return p[i]||(p[i]={}),(!p[i][n]||p[i][n].stepSha1!==o)&&(p[i][n]={stepSha1:o}),p[i][n]}static setCurrentStepTimesCounterData(e="",t){let n=s.currentLabelStepIndex,i=n+e,a=s.currentLabelId;if(!a||n===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let o=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};o[a]||(o[a]={}),o[a][i]=t,core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,o);}static getCurrentStepTimesCounter(e=""){let t=s._stepCounter,n=s.getCurrentStepTimesCounterData(e);if(!n)return L.error("getCurrentStepTimesCounter obj is null"),0;let i=n.stepCounters||[];return i.find(o=>o===t)||(i.push(t),n.stepCounters=i,s.setCurrentStepTimesCounterData(e,n)),i.length}static getRandomNumber(e,t,n={}){let i=n.nestedId||"";if(n.onceOnly||false){let o=s.getCurrentStepTimesCounterData(i);if(!o)return;let p=o.usedRandomNumbers||{},c=Array.from({length:t-e+1},(g,M)=>M+e).filter(g=>!p[`${e}-${t}`]?.includes(g));if(c.length===0)return;let y=Math.floor(Math.random()*c.length),h=c[y];return p[`${e}-${t}`]||(p[`${e}-${t}`]=[]),p[`${e}-${t}`].push(h),o.usedRandomNumbers=p,s.setCurrentStepTimesCounterData(i,o),h}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=s.currentLabelStepIndex,n=t+e,i=s.currentLabelId;if(!i||t===null){L.error("currentLabelId or currentLabelStepIndex is null");return}let a=core.GameUnifier.getVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[i]||(a[i]={}),a[i][n]={stepCounters:[],stepSha1:""},core.GameUnifier.setVariable(O,I.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return core.GameUnifier.getVariable(O,I.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){core.GameUnifier.setVariable(O,I.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){s._stepCounter++;}static _openedLabels=[];static get openedLabels(){return ce(s._openedLabels)}static set openedLabels(e){s._openedLabels=ce(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return ce(s._originalOpenedLabels)}static set originalOpenedLabels(e){s._originalOpenedLabels=ce(e);}static get _currentLabel(){if(s.currentLabelId)return le.get(s.currentLabelId)}static get currentLabelId(){if(s._openedLabels.length>0)return s._openedLabels[s._openedLabels.length-1].label}static get currentLabelStepIndex(){return s._openedLabels.length>0?s._openedLabels[s._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;(!i||i<t)&&(n[e]={biggestStep:t,openCount:a},s.allOpenedLabels=n);}static addChoicesMade(e,t,n,i){let a=s.allChoicesMade,o=a.findIndex(p=>p.labelId===e&&p.stepIndex===t&&p.choiceIndex===i&&p.stepSha1===n);o<0?a.push({labelId:e,stepIndex:t,choiceIndex:i,stepSha1:n,madeTimes:1}):a[o].madeTimes++,s.allChoicesMade=a;}static pushNewLabel(e){if(!le.get(e))throw new core.PixiError("unregistered_element",`Label ${e} not found`);s._openedLabels.push({label:e,currentStepIndex:0});let n=s.allOpenedLabels,i=s.allOpenedLabels[e]?.biggestStep||0,a=s.allOpenedLabels[e]?.openCount||0;n[e]={biggestStep:i,openCount:a+1},s.allOpenedLabels=n;}static increaseCurrentStepIndex(){if(s._openedLabels.length>0){let e=s._openedLabels[s._openedLabels.length-1];s._openedLabels[s._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){s._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let n=[];return s.onLoadingLabel&&e===0&&n.push(s.onLoadingLabel(e,t)),s._onStepStart&&n.push(s._onStepStart(e,t)),await Promise.all(n)}}static onLoadingLabel;static onStepEnd;static onLabelStarting;static onLabelClosing};var De=class{get currentStepTimesCounter(){return b.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){b.resetCurrentStepTimesCounter();}getRandomNumber(e,t,n={}){return b.getRandomNumber(e,t,n)}get stepCounter(){return b._stepCounter}get openedLabels(){return b.openedLabels}get currentLabel(){return b._currentLabel}async addStepHistory(e,t={}){let{choiceMade:n,ignoreSameStep:i}=t,a,o,p,c=core.GameUnifier.getVariable(O,I.LAST_STEP_GLUED)===this.stepCounter;core.GameUnifier.getVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(o=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY)),core.GameUnifier.getVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(p=core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY));let y=b.openedLabels,h={currentLabel:b.currentLabelId,dialogue:a,choices:o,stepSha1:e,index:this.stepCounter,labelStepIndex:b.currentLabelStepIndex,choiceIndexMade:n,inputValue:p,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:c,openedLabels:y};b.originalOpenedLabels=y,await core.GameUnifier.addHistoryItem(h,{ignoreSameStep:i}),b.lastHistoryStep=h,b.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=b.currentLabelStepIndex,n=this.currentLabel;if(!(t===null||!n))return b.allChoicesMade.filter(i=>i.labelId===n.id&&i.stepIndex===t&&i.stepSha1===e).map(i=>i.choiceIndex)}closeCurrentLabel(){if(!b.currentLabelId){L.warn("No label to close");return}if(!this.currentLabel){L.error("currentLabel not found");return}let e=b.openedLabels;e.pop(),b.openedLabels=e,core.GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;b.openedLabels.length>0;)this.closeCurrentLabel(),core.GameUnifier.onLabelClosing(this.openedLabels.length);}labels={get opened(){return b.openedLabels},get current(){return b._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let i=b.allOpenedLabels[t]?.biggestStep||0;if(i){let a=le.get(t);if(a)return a.stepCount<=i}return false}get alreadyCurrentStepMadeChoicesObj(){let e=b.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let n=t.getStepSha(e);return n||(L.warn("stepSha not found, setting to ERROR"),n="error"),b.allChoicesMade.filter(i=>i.labelId===t?.id&&i.stepIndex===e&&i.stepSha1===n)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=b.currentLabelId;if(e){let t=b.allOpenedLabels[e]?.openCount||0;if(b.currentLabelStepIndex&&t>=b.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return b.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e){let t=e?.showWarn||false,n=this.choicesValue;return n&&n.length>0?(t&&L.warn("The player must make a choice"),false):this.isRequiredInput?(t&&L.warn("The player must enter a value"),false):true}get canContinue(){return core.GameUnifier.runningStepsCount!==0||this.openedLabels.length===0?false:this.getCanContinue()}async onStepStart(e,t){let n=[];return e.onStepStart&&n.push(e.onStepStart(t,e)),b.onStepStart&&n.push(b.onStepStart(t,e)),await Promise.all(n)}async onStepEnd(e,t){let n=[];return e.onStepEnd&&n.push(e.onStepEnd(t,e)),b.onStepEnd&&n.push(b.onStepEnd(t,e)),await Promise.all(n)}async continue(e,t={}){let{runNow:n=false,steps:i=1}=t;if(!Number.isFinite(i)){L.warn(`[continue] The parameter steps must be a valid finite number, received: ${i}`);return}if(i<=0){L.warn(`[continue] The parameter steps must be greater than 0, received: ${i}`);return}if(!n&&!this.getCanContinue({showWarn:true}))return;if(!n&&core.GameUnifier.runningStepsCount!==0){core.GameUnifier.increaseContinueRequest(i);return}i>1&&core.GameUnifier.increaseContinueRequest(i-1),core.GameUnifier.runningStepsCount++;let a;try{core.GameUnifier.runningStepsCount===1&&await core.GameUnifier.onPreContinue(),b.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(o){throw L.error("Error continuing",o),o}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(core.GameUnifier.runningStepsCount===0&&core.GameUnifier.continueRequestsCount!==0)return await core.GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(core.GameUnifier.onEnd)return await core.GameUnifier.onEnd(e,{labelId:"end"});L.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:n}=t;if(b.currentLabelId){let i=b.currentLabelStepIndex;if(i===null){L.error("currentLabelStepIndex is null");return}let a=b._currentLabel;if(!a){L.error("currentLabel not found");return}if(a.stepCount>i){try{await this.onStepStart(a,i);}catch(h){L.error("Error running onStepStart",h),this.onStepError&&await this.onStepError(h,e);return}let o=a.getStepById(i);if(!o){L.error("step not found");return}let p=a.getStepSha(i);p||(L.warn("stepSha not found, setting to ERROR"),p="error");let c,y;try{c=await o(e,{labelId:a.id});}catch(h){L.error("Error running step",h),y=h;}try{let h=this.choicesValue;if(h?.length===1&&h[0].autoSelect){let g=h[0];c=await this.selectChoice(g,e);}}catch(h){L.error("Error auto-selecting choice",h),y||(y=h);}try{let h=b.lastHistoryStep;n!==void 0&&h&&(p=h.stepSha1,p||(L.warn("stepSha not found, setting to ERROR"),p="error"),b.addChoicesMade(h.currentLabel||"error",typeof h.labelStepIndex=="number"?h.labelStepIndex:-1,h.stepSha1||"error",n),b.choiceMadeTemp=n);}catch(h){L.warn("Error adding choice made to history",h);}try{core.GameUnifier.runningStepsCount===1&&(b.addLabelHistory(a.id,i),await this.addStepHistory(p,{...t,choiceMade:b.choiceMadeTemp}),b.choiceMadeTemp=void 0);}catch(h){L.warn("Error adding step to history",h);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,b.currentLabelStepIndex||0);}catch(h){L.warn("Error running onStepEnd",h);}return y&&this.onStepError&&await this.onStepError(y,e),c}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e,t)}else {if(this.openedLabels.length===0)return;L.error("currentLabelId not found");}}async closeLabel(e,t,n){let i=async()=>(this.closeCurrentLabel(),await this.continue(t,n));return b.onLabelClosing?await b.onLabelClosing(e,t,i):await i()}async startLabel(e,t,n){let i=async()=>{let{choiceMade:a,closeCurrentLabel:o,type:p}=n;o&&this.openedLabels.length>0&&this.closeCurrentLabel(),core.GameUnifier.runningStepsCount++;let c;try{let y=le.get(e);if(!y)throw new core.PixiError("unregistered_element",`Label ${e} not found`);b.pushNewLabel(y.id),c=await this.runCurrentStep(t,{choiceMade:a});}catch(y){throw L.error(`Error ${p} label`,y),y}return core.GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||c};return b.onLabelStarting?await b.onLabelStarting(e,t,n,i):await i()}async call(e,t,n){let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,type:"calling"})}async jump(e,t,n){if(this.stepCounter===0)return await this.call(e,t,n);let{choiceMade:i}=n||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:i,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choicesValue=void 0;let n=e.type;switch(n){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw L.error(`Type ${n} not found`),new core.PixiError("invalid_usage",`Type ${n} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw L.error("For closeChoiceMenu, the type must be close"),new core.PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let n;return typeof e.choiceIndex=="number"&&(n=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:n})}get onStepError(){return async(e,t)=>{try{await core.GameUnifier.runOnError(e,t);}catch(n){L.error("Error in onError handler",n);}}}get dialogue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?core.GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=core.GameUnifier.getVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let n=[];Array.isArray(t.text)?n=[...t.text]:n=[t.text],Array.isArray(e.text)?n=[...n,...e.text]:n=[...n,e.text],e.text=n,e.character=e.character||t.character;}core.GameUnifier.setVariable(O,I.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{core.GameUnifier.setVariable(O,I.CURRENT_DIALOGUE_MEMORY_KEY,ce({...e,character:typeof e.character=="string"?e.character:e.character?.id})),core.GameUnifier.setVariable(O,I.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("DialogueInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choicesValue(){let e=core.GameUnifier.getVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],n=e.map((a,o)=>({...a,choiceIndex:o})),i=this.alreadyCurrentStepMadeChoices;if(n=n.filter((a,o)=>a.oneTime&&i?.includes(o)?false:a.onlyHaveNoChoice?(t.push(a),false):true),n.length>0)return n;if(t.length>0)return [t[0]]}}set choicesValue(e){if(!e||e.length===0){core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{core.GameUnifier.setVariable(O,I.CURRENT_MENU_OPTIONS_MEMORY_KEY,ce(e)),core.GameUnifier.setVariable(O,I.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw L.error("ChoiceInterface cannot contain functions or classes"),new core.PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}choicesObj=(()=>{let e=this,t={select:(n,i)=>e.selectChoice(n,i)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:n=>{e.choicesValue=n;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return core.GameUnifier.getFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){core.GameUnifier.setFlag(I.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,e),core.GameUnifier.setVariable(O,I.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return core.GameUnifier.getVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,core.GameUnifier.setVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?core.GameUnifier.setVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY,t):core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_INFO_MEMORY_KEY),core.GameUnifier.removeVariable(O,I.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,n)=>e.requestInput(t,n),removeRequest:()=>e.removeInputRequest()}})();clear(){b.openedLabels=[],b._stepCounter=0;}export(){return {openedLabels:ce(b.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async n=>{let i=[],a=le.get(n.label);return a&&(a.onLoadingLabel&&i.push(a.onLoadingLabel(e,a)),b.onLoadingLabel&&i.push(b.onLoadingLabel(e,a))),await Promise.all(i)});return await Promise.all(t)}async restore(e,t){this.clear();try{b.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(b.openedLabels=e.openedLabels,b.originalOpenedLabels=b.openedLabels):L.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?b._stepCounter=e.stepCounter:L.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(b.currentLabelStepIndex||0);}catch(n){L.error("Error running onLoadingLabel",n);}}catch(n){L.error("Error importing data",n);}}};function xt(s,e,t,n){let i=typeof e=="string"?e:e.id;return {...n,label:i,props:t,text:s,type:n?.type||"call"}}var pt="close";function At(s,e){return {...e,type:pt,text:s}}var ft=Ct(dt());var ve=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var we=class extends ve{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,n){super(e,n),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&L.warn("stepSha not found, setting to ERROR"),"error";try{return (0,ft.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(n){return L.warn("stepSha not found, setting to ERROR",n),"error"}}};function bt(s,e,t){let n=new we(s,e,t);return le.add(n),n}var Cr=new De;
|
|
2
2
|
exports.Label=we;exports.LabelAbstract=ve;exports.NarrationManagerStatic=b;exports.RegisteredLabels=le;exports.narration=Cr;exports.newChoiceOption=xt;exports.newCloseChoiceOption=At;exports.newLabel=bt;
|
package/dist/narration.d.cts
CHANGED
|
@@ -238,8 +238,9 @@ interface NarrationManagerInterface {
|
|
|
238
238
|
getTimesChoiceMade(index: number): number;
|
|
239
239
|
/**
|
|
240
240
|
* Save the current step to the history.
|
|
241
|
+
* @returns A promise that resolves once the history is saved and the step counter is updated.
|
|
241
242
|
*/
|
|
242
|
-
addCurrentStepToHistory(): void
|
|
243
|
+
addCurrentStepToHistory(): Promise<void>;
|
|
243
244
|
/**
|
|
244
245
|
* Namespace for operations on the input requested to the player.
|
|
245
246
|
*/
|
package/dist/narration.d.ts
CHANGED
|
@@ -238,8 +238,9 @@ interface NarrationManagerInterface {
|
|
|
238
238
|
getTimesChoiceMade(index: number): number;
|
|
239
239
|
/**
|
|
240
240
|
* Save the current step to the history.
|
|
241
|
+
* @returns A promise that resolves once the history is saved and the step counter is updated.
|
|
241
242
|
*/
|
|
242
|
-
addCurrentStepToHistory(): void
|
|
243
|
+
addCurrentStepToHistory(): Promise<void>;
|
|
243
244
|
/**
|
|
244
245
|
* Namespace for operations on the input requested to the player.
|
|
245
246
|
*/
|