@drincs/pixi-vn-json 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var H=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ce=(t,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of se(i))!fe.call(t,r)&&r!==e&&M(t,r,{get:()=>i[r],enumerable:!(a=oe(i,r))||a.enumerable});return t};var ue=(t,i,e)=>(e=t!=null?re(le(t)):{},ce(M(e,"default",{value:t,enumerable:!0}),t));var U=j((L,K)=>{(function(t,i){typeof L=="object"?K.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,e){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof H=="function")try{a=H("crypto");}catch{}var r=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function n(){}return function(o){var u;return n.prototype=o,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var o=l(this);return n&&o.mixIn(n),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var o in n)n.hasOwnProperty(o)&&(this[o]=n[o]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,o){n=this.words=n||[],o!=e?this.sigBytes=o:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var o=this.words,u=n.words,m=this.sigBytes,b=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var B=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=B<<24-(m+N)%4*8;}else for(var C=0;C<b;C+=4)o[m+C>>>2]=u[C>>>2];return this.sigBytes+=b,this},clamp:function(){var n=this.words,o=this.sigBytes;n[o>>>2]&=4294967295<<32-o%4*8,n.length=i.ceil(o/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var o=[],u=0;u<n;u+=4)o.push(r());return new p.init(o,n)}}),s=c.enc={},g=s.Hex={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,o/2)}},y=s.Latin1={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,o)}},T=s.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},x=h.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=T.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,B=N*4,C=b/B;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var O=C*N,z=i.min(O*4,b);if(O){for(var G=0;G<O;G+=N)this._doProcessBlock(m,G);o=m.splice(0,O),u.sigBytes-=z;}return new p.init(o,z)},clone:function(){var n=d.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});h.Hasher=x.extend({cfg:d.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(n){return function(o,u){return new n.init(u).finalize(o)}},_createHmacHelper:function(n){return function(o,u){return new V.HMAC.init(n,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,i){typeof k=="object"?X.exports=k=i(U()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,a=e.WordArray,r=e.Hasher,l=i.algo,c=[],h=l.SHA1=r.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var s=this._hash.words,g=s[0],y=s[1],T=s[2],x=s[3],S=s[4],V=0;V<80;V++){if(V<16)c[V]=d[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var o=(g<<5|g>>>27)+S+c[V];V<20?o+=(y&T|~y&x)+1518500249:V<40?o+=(y^T^x)+1859775393:V<60?o+=(y&T|y&x|T&x)-1894007588:o+=(y^T^x)-899497514,S=x,x=T,T=y<<30|y>>>2,y=g,g=o;}s[0]=s[0]+g|0,s[1]=s[1]+y|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+S|0;},_doFinalize:function(){var d=this._data,p=d.words,s=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(s/4294967296),p[(g+64>>>9<<4)+15]=s,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=r._createHelper(h),i.HmacSHA1=r._createHmacHelper(h);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>t._translate(`${e}`)):t._translate(`${i}`)}static set translate(i){t._translate=i;}static addKey(i,e,a){let r=a.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(r==="empty_string"?i[l]="":r==="copy_key"&&(i[l]=l));});}static getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&t.getConditionalsThenElse(i.then,e),i.else&&t.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(a=>{t.getConditionalsThenElse(a,e);});else if(i.elements.type==="ifelse"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else if(i.elements.type==="stepswitch"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(a=>{t.getConditionalsThenElse(a,e);})):e.push(i);else i&&e.push(i);return e}static generateTranslateJson(i,e={},a={}){return i.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?t.getConditionalsThenElse(h,d):d=[h],d.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,a):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,a);}):typeof T=="string"&&t.addKey(e,T,a);});}):typeof g=="string"&&t.addKey(e,g,a);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,a):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,a):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,a):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,a):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,a);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateTranslateJson(c,e,a):t.generateTranslateJson([c],e,a);});}),e}};function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return he(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let a=de(0,e.length-1);return f(e[a]);case"loop":let r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>e.length-1&&(r=r%e.length),f(e[r]);case"sequential":let l,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(e[e.length-1])),c>e.length-1?l:f(e[c]);case"sequentialrandom":let h=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(h==null&&t.end=="lastItem"){let d=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=d.usedRandomNumbers[`0-${e.length-1}`];return f(e[p[p.length-1]])}if(h==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(e[h])}}return t}function I(t){if(t.conditionalStep){let i=pixiVn.createExportableElement(f(t.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operation===void 0&&delete i?.operation,i){let e={...t,conditionalStep:void 0,...i};return I(e)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function he(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(r);e.push(l);}});let a=i?[i,...e]:e;if(a.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof a[0]=="string")return P.t(a).join("");if(typeof a[0]=="object"){let r=a,l,c=r.map((n,o)=>{n=I(n);let u=f(n.dialogue)||"";return o===0?(l=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var H=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ce=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of se(e))!fe.call(t,r)&&r!==n&&M(t,r,{get:()=>e[r],enumerable:!(i=oe(e,r))||i.enumerable});return t};var ue=(t,e,n)=>(n=t!=null?re(le(t)):{},ce(M(n,"default",{value:t,enumerable:!0}),t));var U=j((O,K)=>{(function(t,e){typeof O=="object"?K.exports=O=e():typeof define=="function"&&define.amd?define([],e):t.CryptoJS=e();})(O,function(){var t=t||function(e,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof H=="function")try{i=H("crypto");}catch{}var r=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function a(){}return function(o){var u;return a.prototype=o,u=new a,a.prototype=null,u}}(),c={},p=c.lib={},g=p.Base=function(){return {extend:function(a){var o=l(this);return a&&o.mixIn(a),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var o in a)a.hasOwnProperty(o)&&(this[o]=a[o]);a.hasOwnProperty("toString")&&(this.toString=a.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),d=p.WordArray=g.extend({init:function(a,o){a=this.words=a||[],o!=n?this.sigBytes=o:this.sigBytes=a.length*4;},toString:function(a){return (a||y).stringify(this)},concat:function(a){var o=this.words,u=a.words,m=this.sigBytes,b=a.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var B=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=B<<24-(m+N)%4*8;}else for(var S=0;S<b;S+=4)o[m+S>>>2]=u[S>>>2];return this.sigBytes+=b,this},clamp:function(){var a=this.words,o=this.sigBytes;a[o>>>2]&=4294967295<<32-o%4*8,a.length=e.ceil(o/4);},clone:function(){var a=g.clone.call(this);return a.words=this.words.slice(0),a},random:function(a){for(var o=[],u=0;u<a;u+=4)o.push(r());return new d.init(o,a)}}),s=c.enc={},y=s.Hex={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(a.substr(m,2),16)<<24-m%8*4;return new d.init(u,o/2)}},h=s.Latin1={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m++)u[m>>>2]|=(a.charCodeAt(m)&255)<<24-m%4*8;return new d.init(u,o)}},T=s.Utf8={stringify:function(a){try{return decodeURIComponent(escape(h.stringify(a)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(a){return h.parse(unescape(encodeURIComponent(a)))}},x=p.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(a){typeof a=="string"&&(a=T.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes;},_process:function(a){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,B=N*4,S=b/B;a?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var L=S*N,z=e.min(L*4,b);if(L){for(var G=0;G<L;G+=N)this._doProcessBlock(m,G);o=m.splice(0,L),u.sigBytes-=z;}return new d.init(o,z)},clone:function(){var a=g.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});p.Hasher=x.extend({cfg:g.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(a){return function(o,u){return new a.init(u).finalize(o)}},_createHmacHelper:function(a){return function(o,u){return new V.HMAC.init(a,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,e){typeof k=="object"?X.exports=k=e(U()):typeof define=="function"&&define.amd?define(["./core"],e):e(t.CryptoJS);})(k,function(t){return function(){var e=t,n=e.lib,i=n.WordArray,r=n.Hasher,l=e.algo,c=[],p=l.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,d){for(var s=this._hash.words,y=s[0],h=s[1],T=s[2],x=s[3],v=s[4],V=0;V<80;V++){if(V<16)c[V]=g[d+V]|0;else {var a=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=a<<1|a>>>31;}var o=(y<<5|y>>>27)+v+c[V];V<20?o+=(h&T|~h&x)+1518500249:V<40?o+=(h^T^x)+1859775393:V<60?o+=(h&T|h&x|T&x)-1894007588:o+=(h^T^x)-899497514,v=x,x=T,T=h<<30|h>>>2,h=y,y=o;}s[0]=s[0]+y|0,s[1]=s[1]+h|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+v|0;},_doFinalize:function(){var g=this._data,d=g.words,s=this._nDataBytes*8,y=g.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(s/4294967296),d[(y+64>>>9<<4)+15]=s,g.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var g=r.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=r._createHelper(p),e.HmacSHA1=r._createHmacHelper(p);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(n=>t._translate(`${n}`)):t._translate(`${e}`)}static set translate(e){t._translate=e;}static addKey(e,n,i){let r=i.defaultValue||"empty_string";typeof n=="string"&&(n=[n]),Array.isArray(n)&&n.forEach(l=>{e[l]===void 0&&(r==="empty_string"?e[l]="":r==="copy_key"&&(e[l]=l));});}static getConditionalsThenElse(e,n=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,n),e.else&&t.getConditionalsThenElse(e.else,n);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(i=>{t.getConditionalsThenElse(i,n);});else if(e.elements.type==="ifelse"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else if(e.elements.type==="stepswitch"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else t.getConditionalsThenElse(e.elements,n);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,n),e.secondConditionalItem&&e.secondConditionalItem.forEach(i=>{t.getConditionalsThenElse(i,n);})):n.push(e);else e&&n.push(e);return n}static generateJsonTranslation(e,n={},i={}){return e.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(p=>{if("type"in p){let g=[];p.type==="ifelse"||p.type==="stepswitch"?t.getConditionalsThenElse(p,g):g=[p],g.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(y=>{Array.isArray(y)?y.forEach(h=>{typeof h=="string"?t.addKey(n,h,i):t.getConditionalsThenElse(h).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(n,x,i);}):typeof T=="string"&&t.addKey(n,T,i);});}):typeof y=="string"&&t.addKey(n,y,i);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(n,c,i):"text"in c&&Array.isArray(c.text)&&c.text.forEach(p=>{typeof p=="string"?t.addKey(n,p,i):t.getConditionalsThenElse(p).forEach(d=>{typeof d=="string"?t.addKey(n,d,i):Array.isArray(d)&&d.forEach(s=>{typeof s=="string"?t.addKey(n,s,i):t.getConditionalsThenElse(s).forEach(y=>{typeof y=="string"&&t.addKey(n,y,i);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,n,i):t.generateJsonTranslation([c],n,i);});}),n}};function de(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return ye(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let n=f(t.elements)||[];if(n.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let i=de(0,n.length-1);return f(n[i]);case"loop":let r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>n.length-1&&(r=r%n.length),f(n[r]);case"sequential":let l,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(n[n.length-1])),c>n.length-1?l:f(n[c]);case"sequentialrandom":let p=pixiVn.NarrationManagerStatic.getRandomNumber(0,n.length-1,{nestedId:t.nestedId,onceOnly:!0});if(p==null&&t.end=="lastItem"){let g=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=g.usedRandomNumbers[`0-${n.length-1}`];return f(n[d[d.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(n[p])}}return t}function I(t){if(t.conditionalStep){let e=pixiVn.createExportableElement(f(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operation===void 0&&delete e?.operation,e){let n={...t,conditionalStep:void 0,...e};return I(n)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function ye(t){let e=t.firstItem,n=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);n.push(c);});else {let l=f(r);n.push(l);}});let i=e?[e,...n]:n;if(i.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return P.t(i).join("");if(typeof i[0]=="object"){let r=i,l,c=r.map((a,o)=>{a=I(a);let u=f(a.dialogue)||"";return o===0?(l=f(a.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
2
2
 
3
- `+u),l=f(n.glueEnabled)||!1,u)}),h=f(c[0]),d=typeof h=="object"&&"character"in h?h.character:void 0,p=c.map(n=>{let o;n&&typeof n=="object"&&"text"in n?o=n.text:o=n;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(n=>n.end),g=r.find(n=>n.choices),y=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=r[r.length-1].glueEnabled,T=r.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=r.find(n=>n.labelToOpen),S=[];return r.forEach(n=>{n.operation&&S.forEach(o=>{S.push(o);});}),{dialogue:d?{character:d,text:p}:p,end:s?.end,choices:g?.choices,glueEnabled:y,goNextStep:T,labelToOpen:x?.labelToOpen,operation:S}}}function ye(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let i=f(t.leftValue),e=f(t.rightValue);switch(t.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"choice":return pixiVn.narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let i=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>t.key)return i[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let i=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(i=f(t.conditions[e])||!1,t.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function Q(t){let i=f(t.value),e;switch(i&&typeof i=="object"&&"type"in i?e=f(i):e=i,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,e);break;case"tempstorage":pixiVn.storage.setTempVariable(t.key,e);break;case"params":let a=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];a&&a.length-1>=t.key&&(a[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,a);break}}function f(t){let i=ge(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return me(i);case"arithmetic":case"arithmeticsingle":return Te(i);case"compare":case"valueCondition":case"union":return ye(i)}return i}function Te(t){let i=f(t.leftValue);switch(t.type){case"arithmetic":let e=f(t.rightValue);switch(t.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return pixiVn.narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function F(t,i){let e=f(t);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(e.alias);break;case"pause":pixiVn.sound.pause(e.alias);break;case"resume":pixiVn.sound.resume(e.alias);break;case"volume":pixiVn.sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let a=pixiVn.canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new pixiVn.CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let a=pixiVn.canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let r=pixiVn.canvas.find(e.alias);r?r.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let l=pixiVn.canvas.find(e.alias);l?l.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":Q(e);break;case"oprationtoconvert":if(i){let a="";e.values.forEach(l=>{if(typeof l=="string")a+=l;else {let c=f(l);a+=`${c}`;}});let r=i(a);r&&await F(r);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var W=class extends pixiVn.LabelAbstract{constructor(i,e,a,r={}){super(i,a),this._steps=e,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(i=>this.stepConverter(i))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(i){if(i<0||i>=this.steps.length)return;let e=this._steps[i];return (0, ae.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let a=[];i.forEach(r=>{if(typeof r=="string")a.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?a=a.concat(l):a.push(`${l}`)):a.push(`${r}`);}}),e=a;}else {let a=f(i)||"";a&&!Array.isArray(a)&&typeof a=="object"&&(a=f(a)||""),e=a;}return `${e}`}getDialogue(i){let e=f(i);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:P.t(this.getDialogueText(e.text))}:P.t(this.getDialogueText(e));if(e!=null)return `${e}`}getChoices(i){return f(i)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=I(i),i.operation)for(let p of i.operation)await F(p,this.operationStringConvert);let a=this.getChoices(i.choices),r=f(i.glueEnabled),l=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let s=f(p);s&&c.push(s);}));let h=f(i.goNextStep),d=f(i.end);if(a){let p=a.map(s=>{let g="";if(Array.isArray(s.text)){let y=[];s.text.forEach(T=>{if(typeof T=="string")y.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?y=y.concat(P.t(x)):y.push(P.t(x)));}}),g=y.join();}else typeof s.text=="string"&&(g=P.t(s.text));return new pixiVn.ChoiceMenuOption(g,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});pixiVn.narration.choiceMenuOptions=p;}else pixiVn.narration.choiceMenuOptions=void 0;l!==void 0&&(pixiVn.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=!0)),r?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let s=p.label;typeof s=="object"&&(s=f(s)||"");let g=p.params?.map(y=>f(y));e={...e,...p.props},p.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(s,e)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(s,e));}d==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):d==="label_end"&&pixiVn.narration.closeCurrentLabel(),h&&await pixiVn.narration.goNext(e);}}};module.exports=W;
3
+ `+u),l=f(a.glueEnabled)||!1,u)}),p=f(c[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,d=c.map(a=>{let o;a&&typeof a=="object"&&"text"in a?o=a.text:o=a;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(a=>a.end),y=r.find(a=>a.choices),h=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=r[r.length-1].glueEnabled,T=r.reverse().find(a=>!(a.operation&&(!a.dialogue||!a.choices)))?.goNextStep);let x=r.find(a=>a.labelToOpen),v=[];return r.forEach(a=>{a.operation&&v.forEach(o=>{v.push(o);});}),{dialogue:g?{character:g,text:d}:d,end:s?.end,choices:y?.choices,glueEnabled:h,goNextStep:T,labelToOpen:x?.labelToOpen,operation:v}}}function he(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let e=f(t.leftValue),n=f(t.rightValue);switch(t.operator){case"==":return e===n;case"!=":return e!==n;case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"CONTAINS":return e.toString().includes(n.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"choice":return pixiVn.narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let e=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let e=t.unionType==="and";for(let n=0;n<t.conditions.length;n++)if(e=f(t.conditions[n])||!1,t.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function Q(t){let e=f(t.value),n;switch(e&&typeof e=="object"&&"type"in e?n=f(e):n=e,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,n);break;case"tempstorage":pixiVn.storage.setTempVariable(t.key,n);break;case"params":let i=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];i&&i.length-1>=t.key&&(i[t.key]=n),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,i);break}}function f(t){let e=ge(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return me(e);case"arithmetic":case"arithmeticsingle":return Te(e);case"compare":case"valueCondition":case"union":return he(e)}return e}function Te(t){let e=f(t.leftValue);switch(t.type){case"arithmetic":let n=f(t.rightValue);switch(t.operator){case"*":return e*n;case"/":return e/n;case"+":return e+n;case"-":return e-n;case"%":return e%n;case"POW":return Math.pow(e,n);case"RANDOM":return pixiVn.narration.getRandomNumber(e,n)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}async function F(t,e,n){let i=f(t);if(i)switch(i.type){case"sound":switch(i.operationType){case"add":pixiVn.sound.add(i.alias,{...i.props,url:i.url});break;case"play":pixiVn.sound.play(i.alias,i.props);break;case"remove":pixiVn.sound.remove(i.alias);break;case"pause":pixiVn.sound.pause(i.alias);break;case"resume":pixiVn.sound.resume(i.alias);break;case"volume":pixiVn.sound.volume(i.alias,i.value);break}break;case"image":switch(i.operationType){case"show":if(i.transition)switch(i.transition.type){case"fade":await pixiVn.showWithFadeTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(i.alias,i.url,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(i.alias,i.url,i.transition.props,i.transition.priority);break}else await pixiVn.showImage(i.alias,i.url);break;case"edit":let r=pixiVn.canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${i.alias} not found.`);break;case"remove":pixiVn.canvas.remove(i.alias);break}break;case"video":switch(i.operationType){case"show":if(i.transition){let p=new pixiVn.CanvasVideo;switch(p.videoLink=i.url,i.transition.type){case"fade":await pixiVn.showWithFadeTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(i.alias,p,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(i.alias,p,i.transition.props,i.transition.priority);break}}else await pixiVn.showVideo(i.alias,i.url);break;case"edit":let r=pixiVn.canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"remove":pixiVn.canvas.remove(i.alias);break;case"pause":let l=pixiVn.canvas.find(i.alias);l?l.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"resume":let c=pixiVn.canvas.find(i.alias);c?c.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break}break;case"value":Q(i);break;case"oprationtoconvert":if(n){let r="";i.values.forEach(c=>{if(typeof c=="string")r+=c;else {let p=f(c);r+=`${p}`;}});let l=n(r,e);l&&await F(l,e,n);}break;case"input":switch(i.operationType){case"request":pixiVn.narration.requestInput({type:i.valueType});break}break}}var W=class extends pixiVn.LabelAbstract{constructor(e,n,i,r={}){super(e,i),this._steps=n,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(e){if(e<0||e>=this.steps.length)return;let n=this._steps[e];return (0, ae.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(e){let n="";if(Array.isArray(e)){let i=[];e.forEach(r=>{if(typeof r=="string")i.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?i=i.concat(l):i.push(`${l}`)):i.push(`${r}`);}}),n=i;}else {let i=f(e)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=f(i)||""),n=i;}return `${n}`}getDialogue(e){let n=f(e);if(n)return typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:P.t(this.getDialogueText(n.text))}:P.t(this.getDialogueText(n));if(n!=null)return `${n}`}getChoices(e){return f(e)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(e){return async n=>{if(typeof e=="function"&&(e=e()),e=I(e),e.operation)for(let d of e.operation)await F(d,n,this.operationStringConvert);let i=this.getChoices(e.choices),r=f(e.glueEnabled),l=this.getDialogue(e.dialogue),c=[];e.labelToOpen&&(Array.isArray(e.labelToOpen)||(e.labelToOpen=[e.labelToOpen]),e.labelToOpen.forEach(d=>{let s=f(d);s&&c.push(s);}));let p=f(e.goNextStep),g=f(e.end);if(i){let d=i.map(s=>{let y="";if(Array.isArray(s.text)){let h=[];s.text.forEach(T=>{if(typeof T=="string")h.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?h=h.concat(P.t(x)):h.push(P.t(x)));}}),y=h.join();}else typeof s.text=="string"&&(y=P.t(s.text));return new pixiVn.ChoiceMenuOption(y,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});pixiVn.narration.choiceMenuOptions=d;}else pixiVn.narration.choiceMenuOptions=void 0;l!==void 0&&(pixiVn.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(p=!0)),r?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let d of c){let s=d.label;typeof s=="object"&&(s=f(s)||"");let y=d.params?.map(h=>f(h));n={...n,...d.props},d.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,y),await pixiVn.narration.callLabel(s,n)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,y),await pixiVn.narration.callLabel(s,n));}g==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(n)):g==="label_end"&&pixiVn.narration.closeCurrentLabel(),p&&await pixiVn.narration.goNext(n);}}};module.exports=W;
@@ -1,4 +1,4 @@
1
- import { LabelAbstract, LabelProps, StepLabelType } from '@drincs/pixi-vn';
1
+ import { StepLabelPropsType, LabelAbstract, LabelProps, StepLabelType } from '@drincs/pixi-vn';
2
2
  import PixiVNJsonLabelStep from '../interface/PixiVNJsonLabelStep.cjs';
3
3
  import { PixiVNJsonOperation } from '../interface/PixiVNJsonOperations.cjs';
4
4
  import '../PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
@@ -11,7 +11,7 @@ type LabelJsonOptions = {
11
11
  /**
12
12
  * Function that converts a string to a {@link PixiVNJsonOperation}.
13
13
  */
14
- operationStringConvert?: (value: string) => PixiVNJsonOperation | undefined;
14
+ operationStringConvert?: (value: string, props: StepLabelPropsType<any>) => PixiVNJsonOperation | undefined;
15
15
  /**
16
16
  * If true and a dialog is empty or has only spaces, {@link PixiVNJsonLabelStep.goNextStep} will be set to true.
17
17
  */
@@ -1,4 +1,4 @@
1
- import { LabelAbstract, LabelProps, StepLabelType } from '@drincs/pixi-vn';
1
+ import { StepLabelPropsType, LabelAbstract, LabelProps, StepLabelType } from '@drincs/pixi-vn';
2
2
  import PixiVNJsonLabelStep from '../interface/PixiVNJsonLabelStep.js';
3
3
  import { PixiVNJsonOperation } from '../interface/PixiVNJsonOperations.js';
4
4
  import '../PixiVNJsonConditionalStatements-CVkQSKpq.js';
@@ -11,7 +11,7 @@ type LabelJsonOptions = {
11
11
  /**
12
12
  * Function that converts a string to a {@link PixiVNJsonOperation}.
13
13
  */
14
- operationStringConvert?: (value: string) => PixiVNJsonOperation | undefined;
14
+ operationStringConvert?: (value: string, props: StepLabelPropsType<any>) => PixiVNJsonOperation | undefined;
15
15
  /**
16
16
  * If true and a dialog is empty or has only spaces, {@link PixiVNJsonLabelStep.goNextStep} will be set to true.
17
17
  */
@@ -1,3 +1,3 @@
1
- import {LabelAbstract,ChoiceMenuOption,narration,setFlag,storage,createExportableElement,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound,NarrationManagerStatic}from'@drincs/pixi-vn';var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var H=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ce=(t,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of se(i))!fe.call(t,r)&&r!==e&&M(t,r,{get:()=>i[r],enumerable:!(a=oe(i,r))||a.enumerable});return t};var ue=(t,i,e)=>(e=t!=null?re(le(t)):{},ce(M(e,"default",{value:t,enumerable:!0}),t));var U=j((L,K)=>{(function(t,i){typeof L=="object"?K.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,e){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof H=="function")try{a=H("crypto");}catch{}var r=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function n(){}return function(o){var u;return n.prototype=o,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var o=l(this);return n&&o.mixIn(n),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var o in n)n.hasOwnProperty(o)&&(this[o]=n[o]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,o){n=this.words=n||[],o!=e?this.sigBytes=o:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var o=this.words,u=n.words,m=this.sigBytes,b=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var B=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=B<<24-(m+N)%4*8;}else for(var C=0;C<b;C+=4)o[m+C>>>2]=u[C>>>2];return this.sigBytes+=b,this},clamp:function(){var n=this.words,o=this.sigBytes;n[o>>>2]&=4294967295<<32-o%4*8,n.length=i.ceil(o/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var o=[],u=0;u<n;u+=4)o.push(r());return new p.init(o,n)}}),s=c.enc={},g=s.Hex={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,o/2)}},y=s.Latin1={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,o)}},T=s.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},x=h.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=T.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,B=N*4,C=b/B;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var O=C*N,z=i.min(O*4,b);if(O){for(var G=0;G<O;G+=N)this._doProcessBlock(m,G);o=m.splice(0,O),u.sigBytes-=z;}return new p.init(o,z)},clone:function(){var n=d.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});h.Hasher=x.extend({cfg:d.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(n){return function(o,u){return new n.init(u).finalize(o)}},_createHmacHelper:function(n){return function(o,u){return new V.HMAC.init(n,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,i){typeof k=="object"?X.exports=k=i(U()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,a=e.WordArray,r=e.Hasher,l=i.algo,c=[],h=l.SHA1=r.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var s=this._hash.words,g=s[0],y=s[1],T=s[2],x=s[3],S=s[4],V=0;V<80;V++){if(V<16)c[V]=d[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var o=(g<<5|g>>>27)+S+c[V];V<20?o+=(y&T|~y&x)+1518500249:V<40?o+=(y^T^x)+1859775393:V<60?o+=(y&T|y&x|T&x)-1894007588:o+=(y^T^x)-899497514,S=x,x=T,T=y<<30|y>>>2,y=g,g=o;}s[0]=s[0]+g|0,s[1]=s[1]+y|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+S|0;},_doFinalize:function(){var d=this._data,p=d.words,s=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(s/4294967296),p[(g+64>>>9<<4)+15]=s,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=r._createHelper(h),i.HmacSHA1=r._createHmacHelper(h);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>t._translate(`${e}`)):t._translate(`${i}`)}static set translate(i){t._translate=i;}static addKey(i,e,a){let r=a.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(r==="empty_string"?i[l]="":r==="copy_key"&&(i[l]=l));});}static getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&t.getConditionalsThenElse(i.then,e),i.else&&t.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(a=>{t.getConditionalsThenElse(a,e);});else if(i.elements.type==="ifelse"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else if(i.elements.type==="stepswitch"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(a=>{t.getConditionalsThenElse(a,e);})):e.push(i);else i&&e.push(i);return e}static generateTranslateJson(i,e={},a={}){return i.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?t.getConditionalsThenElse(h,d):d=[h],d.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,a):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,a);}):typeof T=="string"&&t.addKey(e,T,a);});}):typeof g=="string"&&t.addKey(e,g,a);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,a):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,a):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,a):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,a):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,a);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateTranslateJson(c,e,a):t.generateTranslateJson([c],e,a);});}),e}};function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return he(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let a=de(0,e.length-1);return f(e[a]);case"loop":let r=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>e.length-1&&(r=r%e.length),f(e[r]);case"sequential":let l,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(e[e.length-1])),c>e.length-1?l:f(e[c]);case"sequentialrandom":let h=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(h==null&&t.end=="lastItem"){let d=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=d.usedRandomNumbers[`0-${e.length-1}`];return f(e[p[p.length-1]])}if(h==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(e[h])}}return t}function I(t){if(t.conditionalStep){let i=createExportableElement(f(t.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operation===void 0&&delete i?.operation,i){let e={...t,conditionalStep:void 0,...i};return I(e)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function he(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(r);e.push(l);}});let a=i?[i,...e]:e;if(a.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof a[0]=="string")return P.t(a).join("");if(typeof a[0]=="object"){let r=a,l,c=r.map((n,o)=>{n=I(n);let u=f(n.dialogue)||"";return o===0?(l=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
1
+ import {LabelAbstract,ChoiceMenuOption,narration,setFlag,storage,createExportableElement,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound,NarrationManagerStatic}from'@drincs/pixi-vn';var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var H=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ce=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of se(e))!fe.call(t,r)&&r!==n&&M(t,r,{get:()=>e[r],enumerable:!(i=oe(e,r))||i.enumerable});return t};var ue=(t,e,n)=>(n=t!=null?re(le(t)):{},ce(M(n,"default",{value:t,enumerable:!0}),t));var U=j((O,K)=>{(function(t,e){typeof O=="object"?K.exports=O=e():typeof define=="function"&&define.amd?define([],e):t.CryptoJS=e();})(O,function(){var t=t||function(e,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof H=="function")try{i=H("crypto");}catch{}var r=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function a(){}return function(o){var u;return a.prototype=o,u=new a,a.prototype=null,u}}(),c={},p=c.lib={},g=p.Base=function(){return {extend:function(a){var o=l(this);return a&&o.mixIn(a),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var o in a)a.hasOwnProperty(o)&&(this[o]=a[o]);a.hasOwnProperty("toString")&&(this.toString=a.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),d=p.WordArray=g.extend({init:function(a,o){a=this.words=a||[],o!=n?this.sigBytes=o:this.sigBytes=a.length*4;},toString:function(a){return (a||y).stringify(this)},concat:function(a){var o=this.words,u=a.words,m=this.sigBytes,b=a.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var B=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=B<<24-(m+N)%4*8;}else for(var S=0;S<b;S+=4)o[m+S>>>2]=u[S>>>2];return this.sigBytes+=b,this},clamp:function(){var a=this.words,o=this.sigBytes;a[o>>>2]&=4294967295<<32-o%4*8,a.length=e.ceil(o/4);},clone:function(){var a=g.clone.call(this);return a.words=this.words.slice(0),a},random:function(a){for(var o=[],u=0;u<a;u+=4)o.push(r());return new d.init(o,a)}}),s=c.enc={},y=s.Hex={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(a.substr(m,2),16)<<24-m%8*4;return new d.init(u,o/2)}},h=s.Latin1={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m++)u[m>>>2]|=(a.charCodeAt(m)&255)<<24-m%4*8;return new d.init(u,o)}},T=s.Utf8={stringify:function(a){try{return decodeURIComponent(escape(h.stringify(a)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(a){return h.parse(unescape(encodeURIComponent(a)))}},x=p.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(a){typeof a=="string"&&(a=T.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes;},_process:function(a){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,B=N*4,S=b/B;a?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var L=S*N,z=e.min(L*4,b);if(L){for(var G=0;G<L;G+=N)this._doProcessBlock(m,G);o=m.splice(0,L),u.sigBytes-=z;}return new d.init(o,z)},clone:function(){var a=g.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});p.Hasher=x.extend({cfg:g.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(a){return function(o,u){return new a.init(u).finalize(o)}},_createHmacHelper:function(a){return function(o,u){return new V.HMAC.init(a,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,e){typeof k=="object"?X.exports=k=e(U()):typeof define=="function"&&define.amd?define(["./core"],e):e(t.CryptoJS);})(k,function(t){return function(){var e=t,n=e.lib,i=n.WordArray,r=n.Hasher,l=e.algo,c=[],p=l.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,d){for(var s=this._hash.words,y=s[0],h=s[1],T=s[2],x=s[3],v=s[4],V=0;V<80;V++){if(V<16)c[V]=g[d+V]|0;else {var a=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=a<<1|a>>>31;}var o=(y<<5|y>>>27)+v+c[V];V<20?o+=(h&T|~h&x)+1518500249:V<40?o+=(h^T^x)+1859775393:V<60?o+=(h&T|h&x|T&x)-1894007588:o+=(h^T^x)-899497514,v=x,x=T,T=h<<30|h>>>2,h=y,y=o;}s[0]=s[0]+y|0,s[1]=s[1]+h|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+v|0;},_doFinalize:function(){var g=this._data,d=g.words,s=this._nDataBytes*8,y=g.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(s/4294967296),d[(y+64>>>9<<4)+15]=s,g.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var g=r.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=r._createHelper(p),e.HmacSHA1=r._createHmacHelper(p);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(n=>t._translate(`${n}`)):t._translate(`${e}`)}static set translate(e){t._translate=e;}static addKey(e,n,i){let r=i.defaultValue||"empty_string";typeof n=="string"&&(n=[n]),Array.isArray(n)&&n.forEach(l=>{e[l]===void 0&&(r==="empty_string"?e[l]="":r==="copy_key"&&(e[l]=l));});}static getConditionalsThenElse(e,n=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,n),e.else&&t.getConditionalsThenElse(e.else,n);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(i=>{t.getConditionalsThenElse(i,n);});else if(e.elements.type==="ifelse"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else if(e.elements.type==="stepswitch"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else t.getConditionalsThenElse(e.elements,n);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,n),e.secondConditionalItem&&e.secondConditionalItem.forEach(i=>{t.getConditionalsThenElse(i,n);})):n.push(e);else e&&n.push(e);return n}static generateJsonTranslation(e,n={},i={}){return e.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(p=>{if("type"in p){let g=[];p.type==="ifelse"||p.type==="stepswitch"?t.getConditionalsThenElse(p,g):g=[p],g.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(y=>{Array.isArray(y)?y.forEach(h=>{typeof h=="string"?t.addKey(n,h,i):t.getConditionalsThenElse(h).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(n,x,i);}):typeof T=="string"&&t.addKey(n,T,i);});}):typeof y=="string"&&t.addKey(n,y,i);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(n,c,i):"text"in c&&Array.isArray(c.text)&&c.text.forEach(p=>{typeof p=="string"?t.addKey(n,p,i):t.getConditionalsThenElse(p).forEach(d=>{typeof d=="string"?t.addKey(n,d,i):Array.isArray(d)&&d.forEach(s=>{typeof s=="string"?t.addKey(n,s,i):t.getConditionalsThenElse(s).forEach(y=>{typeof y=="string"&&t.addKey(n,y,i);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,n,i):t.generateJsonTranslation([c],n,i);});}),n}};function de(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return ye(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let n=f(t.elements)||[];if(n.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let i=de(0,n.length-1);return f(n[i]);case"loop":let r=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>n.length-1&&(r=r%n.length),f(n[r]);case"sequential":let l,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(n[n.length-1])),c>n.length-1?l:f(n[c]);case"sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,n.length-1,{nestedId:t.nestedId,onceOnly:!0});if(p==null&&t.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=g.usedRandomNumbers[`0-${n.length-1}`];return f(n[d[d.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(n[p])}}return t}function I(t){if(t.conditionalStep){let e=createExportableElement(f(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operation===void 0&&delete e?.operation,e){let n={...t,conditionalStep:void 0,...e};return I(n)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function ye(t){let e=t.firstItem,n=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);n.push(c);});else {let l=f(r);n.push(l);}});let i=e?[e,...n]:n;if(i.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return P.t(i).join("");if(typeof i[0]=="object"){let r=i,l,c=r.map((a,o)=>{a=I(a);let u=f(a.dialogue)||"";return o===0?(l=f(a.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
2
2
 
3
- `+u),l=f(n.glueEnabled)||!1,u)}),h=f(c[0]),d=typeof h=="object"&&"character"in h?h.character:void 0,p=c.map(n=>{let o;n&&typeof n=="object"&&"text"in n?o=n.text:o=n;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(n=>n.end),g=r.find(n=>n.choices),y=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=r[r.length-1].glueEnabled,T=r.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=r.find(n=>n.labelToOpen),S=[];return r.forEach(n=>{n.operation&&S.forEach(o=>{S.push(o);});}),{dialogue:d?{character:d,text:p}:p,end:s?.end,choices:g?.choices,glueEnabled:y,goNextStep:T,labelToOpen:x?.labelToOpen,operation:S}}}function ye(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let i=f(t.leftValue),e=f(t.rightValue);switch(t.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return storage.getVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"choice":return narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let i=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(i&&i.length>t.key)return i[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let i=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(i=f(t.conditions[e])||!1,t.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function Q(t){let i=f(t.value),e;switch(i&&typeof i=="object"&&"type"in i?e=f(i):e=i,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,e);break;case"tempstorage":storage.setTempVariable(t.key,e);break;case"params":let a=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];a&&a.length-1>=t.key&&(a[t.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,a);break}}function f(t){let i=ge(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return me(i);case"arithmetic":case"arithmeticsingle":return Te(i);case"compare":case"valueCondition":case"union":return ye(i)}return i}function Te(t){let i=f(t.leftValue);switch(t.type){case"arithmetic":let e=f(t.rightValue);switch(t.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function F(t,i){let e=f(t);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(e.alias);break;case"pause":sound.pause(e.alias);break;case"resume":sound.resume(e.alias);break;case"volume":sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let a=canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let a=canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let r=canvas.find(e.alias);r?r.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let l=canvas.find(e.alias);l?l.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":Q(e);break;case"oprationtoconvert":if(i){let a="";e.values.forEach(l=>{if(typeof l=="string")a+=l;else {let c=f(l);a+=`${c}`;}});let r=i(a);r&&await F(r);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var W=class extends LabelAbstract{constructor(i,e,a,r={}){super(i,a),this._steps=e,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(i=>this.stepConverter(i))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(i){if(i<0||i>=this.steps.length)return;let e=this._steps[i];return (0, ae.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let a=[];i.forEach(r=>{if(typeof r=="string")a.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?a=a.concat(l):a.push(`${l}`)):a.push(`${r}`);}}),e=a;}else {let a=f(i)||"";a&&!Array.isArray(a)&&typeof a=="object"&&(a=f(a)||""),e=a;}return `${e}`}getDialogue(i){let e=f(i);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:P.t(this.getDialogueText(e.text))}:P.t(this.getDialogueText(e));if(e!=null)return `${e}`}getChoices(i){return f(i)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=I(i),i.operation)for(let p of i.operation)await F(p,this.operationStringConvert);let a=this.getChoices(i.choices),r=f(i.glueEnabled),l=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let s=f(p);s&&c.push(s);}));let h=f(i.goNextStep),d=f(i.end);if(a){let p=a.map(s=>{let g="";if(Array.isArray(s.text)){let y=[];s.text.forEach(T=>{if(typeof T=="string")y.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?y=y.concat(P.t(x)):y.push(P.t(x)));}}),g=y.join();}else typeof s.text=="string"&&(g=P.t(s.text));return new ChoiceMenuOption(g,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});narration.choiceMenuOptions=p;}else narration.choiceMenuOptions=void 0;l!==void 0&&(narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=!0)),r?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let s=p.label;typeof s=="object"&&(s=f(s)||"");let g=p.params?.map(y=>f(y));e={...e,...p.props},p.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${E}${narration.openedLabels.length}`,g),await narration.callLabel(s,e)):(storage.setTempVariable(`${E}${narration.openedLabels.length}`,g),await narration.callLabel(s,e));}d==="game_end"?(narration.closeAllLabels(),await narration.goNext(e)):d==="label_end"&&narration.closeCurrentLabel(),h&&await narration.goNext(e);}}};export{W as default};
3
+ `+u),l=f(a.glueEnabled)||!1,u)}),p=f(c[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,d=c.map(a=>{let o;a&&typeof a=="object"&&"text"in a?o=a.text:o=a;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(a=>a.end),y=r.find(a=>a.choices),h=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=r[r.length-1].glueEnabled,T=r.reverse().find(a=>!(a.operation&&(!a.dialogue||!a.choices)))?.goNextStep);let x=r.find(a=>a.labelToOpen),v=[];return r.forEach(a=>{a.operation&&v.forEach(o=>{v.push(o);});}),{dialogue:g?{character:g,text:d}:d,end:s?.end,choices:y?.choices,glueEnabled:h,goNextStep:T,labelToOpen:x?.labelToOpen,operation:v}}}function he(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let e=f(t.leftValue),n=f(t.rightValue);switch(t.operator){case"==":return e===n;case"!=":return e!==n;case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"CONTAINS":return e.toString().includes(n.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return storage.getVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"choice":return narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let e=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let e=t.unionType==="and";for(let n=0;n<t.conditions.length;n++)if(e=f(t.conditions[n])||!1,t.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function Q(t){let e=f(t.value),n;switch(e&&typeof e=="object"&&"type"in e?n=f(e):n=e,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,n);break;case"tempstorage":storage.setTempVariable(t.key,n);break;case"params":let i=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];i&&i.length-1>=t.key&&(i[t.key]=n),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,i);break}}function f(t){let e=ge(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return me(e);case"arithmetic":case"arithmeticsingle":return Te(e);case"compare":case"valueCondition":case"union":return he(e)}return e}function Te(t){let e=f(t.leftValue);switch(t.type){case"arithmetic":let n=f(t.rightValue);switch(t.operator){case"*":return e*n;case"/":return e/n;case"+":return e+n;case"-":return e-n;case"%":return e%n;case"POW":return Math.pow(e,n);case"RANDOM":return narration.getRandomNumber(e,n)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}async function F(t,e,n){let i=f(t);if(i)switch(i.type){case"sound":switch(i.operationType){case"add":sound.add(i.alias,{...i.props,url:i.url});break;case"play":sound.play(i.alias,i.props);break;case"remove":sound.remove(i.alias);break;case"pause":sound.pause(i.alias);break;case"resume":sound.resume(i.alias);break;case"volume":sound.volume(i.alias,i.value);break}break;case"image":switch(i.operationType){case"show":if(i.transition)switch(i.transition.type){case"fade":await showWithFadeTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"dissolve":await showWithDissolveTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await moveIn(i.alias,i.url,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(i.alias,i.url,i.transition.props,i.transition.priority);break}else await showImage(i.alias,i.url);break;case"edit":let r=canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${i.alias} not found.`);break;case"remove":canvas.remove(i.alias);break}break;case"video":switch(i.operationType){case"show":if(i.transition){let p=new CanvasVideo;switch(p.videoLink=i.url,i.transition.type){case"fade":await showWithFadeTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"dissolve":await showWithDissolveTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await moveIn(i.alias,p,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(i.alias,p,i.transition.props,i.transition.priority);break}}else await showVideo(i.alias,i.url);break;case"edit":let r=canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"remove":canvas.remove(i.alias);break;case"pause":let l=canvas.find(i.alias);l?l.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"resume":let c=canvas.find(i.alias);c?c.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break}break;case"value":Q(i);break;case"oprationtoconvert":if(n){let r="";i.values.forEach(c=>{if(typeof c=="string")r+=c;else {let p=f(c);r+=`${p}`;}});let l=n(r,e);l&&await F(l,e,n);}break;case"input":switch(i.operationType){case"request":narration.requestInput({type:i.valueType});break}break}}var W=class extends LabelAbstract{constructor(e,n,i,r={}){super(e,i),this._steps=n,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(e){if(e<0||e>=this.steps.length)return;let n=this._steps[e];return (0, ae.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(e){let n="";if(Array.isArray(e)){let i=[];e.forEach(r=>{if(typeof r=="string")i.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?i=i.concat(l):i.push(`${l}`)):i.push(`${r}`);}}),n=i;}else {let i=f(e)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=f(i)||""),n=i;}return `${n}`}getDialogue(e){let n=f(e);if(n)return typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:P.t(this.getDialogueText(n.text))}:P.t(this.getDialogueText(n));if(n!=null)return `${n}`}getChoices(e){return f(e)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(e){return async n=>{if(typeof e=="function"&&(e=e()),e=I(e),e.operation)for(let d of e.operation)await F(d,n,this.operationStringConvert);let i=this.getChoices(e.choices),r=f(e.glueEnabled),l=this.getDialogue(e.dialogue),c=[];e.labelToOpen&&(Array.isArray(e.labelToOpen)||(e.labelToOpen=[e.labelToOpen]),e.labelToOpen.forEach(d=>{let s=f(d);s&&c.push(s);}));let p=f(e.goNextStep),g=f(e.end);if(i){let d=i.map(s=>{let y="";if(Array.isArray(s.text)){let h=[];s.text.forEach(T=>{if(typeof T=="string")h.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?h=h.concat(P.t(x)):h.push(P.t(x)));}}),y=h.join();}else typeof s.text=="string"&&(y=P.t(s.text));return new ChoiceMenuOption(y,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});narration.choiceMenuOptions=d;}else narration.choiceMenuOptions=void 0;l!==void 0&&(narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(p=!0)),r?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let d of c){let s=d.label;typeof s=="object"&&(s=f(s)||"");let y=d.params?.map(h=>f(h));n={...n,...d.props},d.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${E}${narration.openedLabels.length}`,y),await narration.callLabel(s,n)):(storage.setTempVariable(`${E}${narration.openedLabels.length}`,y),await narration.callLabel(s,n));}g==="game_end"?(narration.closeAllLabels(),await narration.goNext(n)):g==="label_end"&&narration.closeCurrentLabel(),p&&await narration.goNext(n);}}};export{W as default};
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var $=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ce=(t,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of se(i))!fe.call(t,r)&&r!==e&&M(t,r,{get:()=>i[r],enumerable:!(a=oe(i,r))||a.enumerable});return t};var ue=(t,i,e)=>(e=t!=null?re(le(t)):{},ce(M(e,"default",{value:t,enumerable:!0}),t));var U=j((L,K)=>{(function(t,i){typeof L=="object"?K.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,e){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof $=="function")try{a=$("crypto");}catch{}var r=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function n(){}return function(o){var u;return n.prototype=o,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var o=l(this);return n&&o.mixIn(n),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var o in n)n.hasOwnProperty(o)&&(this[o]=n[o]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,o){n=this.words=n||[],o!=e?this.sigBytes=o:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var o=this.words,u=n.words,m=this.sigBytes,b=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var G=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=G<<24-(m+N)%4*8;}else for(var C=0;C<b;C+=4)o[m+C>>>2]=u[C>>>2];return this.sigBytes+=b,this},clamp:function(){var n=this.words,o=this.sigBytes;n[o>>>2]&=4294967295<<32-o%4*8,n.length=i.ceil(o/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var o=[],u=0;u<n;u+=4)o.push(r());return new p.init(o,n)}}),s=c.enc={},g=s.Hex={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,o/2)}},y=s.Latin1={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,o)}},T=s.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},x=h.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=T.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,G=N*4,C=b/G;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var O=C*N,z=i.min(O*4,b);if(O){for(var H=0;H<O;H+=N)this._doProcessBlock(m,H);o=m.splice(0,O),u.sigBytes-=z;}return new p.init(o,z)},clone:function(){var n=d.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});h.Hasher=x.extend({cfg:d.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(n){return function(o,u){return new n.init(u).finalize(o)}},_createHmacHelper:function(n){return function(o,u){return new V.HMAC.init(n,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,i){typeof k=="object"?X.exports=k=i(U()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,a=e.WordArray,r=e.Hasher,l=i.algo,c=[],h=l.SHA1=r.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var s=this._hash.words,g=s[0],y=s[1],T=s[2],x=s[3],S=s[4],V=0;V<80;V++){if(V<16)c[V]=d[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var o=(g<<5|g>>>27)+S+c[V];V<20?o+=(y&T|~y&x)+1518500249:V<40?o+=(y^T^x)+1859775393:V<60?o+=(y&T|y&x|T&x)-1894007588:o+=(y^T^x)-899497514,S=x,x=T,T=y<<30|y>>>2,y=g,g=o;}s[0]=s[0]+g|0,s[1]=s[1]+y|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+S|0;},_doFinalize:function(){var d=this._data,p=d.words,s=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(s/4294967296),p[(g+64>>>9<<4)+15]=s,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=r._createHelper(h),i.HmacSHA1=r._createHmacHelper(h);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>t._translate(`${e}`)):t._translate(`${i}`)}static set translate(i){t._translate=i;}static addKey(i,e,a){let r=a.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(r==="empty_string"?i[l]="":r==="copy_key"&&(i[l]=l));});}static getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&t.getConditionalsThenElse(i.then,e),i.else&&t.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(a=>{t.getConditionalsThenElse(a,e);});else if(i.elements.type==="ifelse"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else if(i.elements.type==="stepswitch"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(a=>{t.getConditionalsThenElse(a,e);})):e.push(i);else i&&e.push(i);return e}static generateTranslateJson(i,e={},a={}){return i.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?t.getConditionalsThenElse(h,d):d=[h],d.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,a):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,a);}):typeof T=="string"&&t.addKey(e,T,a);});}):typeof g=="string"&&t.addKey(e,g,a);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,a):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,a):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,a):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,a):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,a);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateTranslateJson(c,e,a):t.generateTranslateJson([c],e,a);});}),e}};function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return he(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let a=de(0,e.length-1);return f(e[a]);case"loop":let r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>e.length-1&&(r=r%e.length),f(e[r]);case"sequential":let l,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(e[e.length-1])),c>e.length-1?l:f(e[c]);case"sequentialrandom":let h=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(h==null&&t.end=="lastItem"){let d=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=d.usedRandomNumbers[`0-${e.length-1}`];return f(e[p[p.length-1]])}if(h==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(e[h])}}return t}function I(t){if(t.conditionalStep){let i=pixiVn.createExportableElement(f(t.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operation===void 0&&delete i?.operation,i){let e={...t,conditionalStep:void 0,...i};return I(e)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function he(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(r);e.push(l);}});let a=i?[i,...e]:e;if(a.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof a[0]=="string")return P.t(a).join("");if(typeof a[0]=="object"){let r=a,l,c=r.map((n,o)=>{n=I(n);let u=f(n.dialogue)||"";return o===0?(l=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var $=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ce=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of se(e))!fe.call(t,r)&&r!==n&&M(t,r,{get:()=>e[r],enumerable:!(i=oe(e,r))||i.enumerable});return t};var ue=(t,e,n)=>(n=t!=null?re(le(t)):{},ce(M(n,"default",{value:t,enumerable:!0}),t));var U=j((O,K)=>{(function(t,e){typeof O=="object"?K.exports=O=e():typeof define=="function"&&define.amd?define([],e):t.CryptoJS=e();})(O,function(){var t=t||function(e,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof $=="function")try{i=$("crypto");}catch{}var r=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function a(){}return function(o){var u;return a.prototype=o,u=new a,a.prototype=null,u}}(),c={},p=c.lib={},g=p.Base=function(){return {extend:function(a){var o=l(this);return a&&o.mixIn(a),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var o in a)a.hasOwnProperty(o)&&(this[o]=a[o]);a.hasOwnProperty("toString")&&(this.toString=a.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),d=p.WordArray=g.extend({init:function(a,o){a=this.words=a||[],o!=n?this.sigBytes=o:this.sigBytes=a.length*4;},toString:function(a){return (a||y).stringify(this)},concat:function(a){var o=this.words,u=a.words,m=this.sigBytes,b=a.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var G=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=G<<24-(m+N)%4*8;}else for(var S=0;S<b;S+=4)o[m+S>>>2]=u[S>>>2];return this.sigBytes+=b,this},clamp:function(){var a=this.words,o=this.sigBytes;a[o>>>2]&=4294967295<<32-o%4*8,a.length=e.ceil(o/4);},clone:function(){var a=g.clone.call(this);return a.words=this.words.slice(0),a},random:function(a){for(var o=[],u=0;u<a;u+=4)o.push(r());return new d.init(o,a)}}),s=c.enc={},y=s.Hex={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(a.substr(m,2),16)<<24-m%8*4;return new d.init(u,o/2)}},h=s.Latin1={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m++)u[m>>>2]|=(a.charCodeAt(m)&255)<<24-m%4*8;return new d.init(u,o)}},T=s.Utf8={stringify:function(a){try{return decodeURIComponent(escape(h.stringify(a)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(a){return h.parse(unescape(encodeURIComponent(a)))}},x=p.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(a){typeof a=="string"&&(a=T.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes;},_process:function(a){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,G=N*4,S=b/G;a?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var L=S*N,z=e.min(L*4,b);if(L){for(var H=0;H<L;H+=N)this._doProcessBlock(m,H);o=m.splice(0,L),u.sigBytes-=z;}return new d.init(o,z)},clone:function(){var a=g.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});p.Hasher=x.extend({cfg:g.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(a){return function(o,u){return new a.init(u).finalize(o)}},_createHmacHelper:function(a){return function(o,u){return new V.HMAC.init(a,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,e){typeof k=="object"?X.exports=k=e(U()):typeof define=="function"&&define.amd?define(["./core"],e):e(t.CryptoJS);})(k,function(t){return function(){var e=t,n=e.lib,i=n.WordArray,r=n.Hasher,l=e.algo,c=[],p=l.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,d){for(var s=this._hash.words,y=s[0],h=s[1],T=s[2],x=s[3],v=s[4],V=0;V<80;V++){if(V<16)c[V]=g[d+V]|0;else {var a=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=a<<1|a>>>31;}var o=(y<<5|y>>>27)+v+c[V];V<20?o+=(h&T|~h&x)+1518500249:V<40?o+=(h^T^x)+1859775393:V<60?o+=(h&T|h&x|T&x)-1894007588:o+=(h^T^x)-899497514,v=x,x=T,T=h<<30|h>>>2,h=y,y=o;}s[0]=s[0]+y|0,s[1]=s[1]+h|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+v|0;},_doFinalize:function(){var g=this._data,d=g.words,s=this._nDataBytes*8,y=g.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(s/4294967296),d[(y+64>>>9<<4)+15]=s,g.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var g=r.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=r._createHelper(p),e.HmacSHA1=r._createHmacHelper(p);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(n=>t._translate(`${n}`)):t._translate(`${e}`)}static set translate(e){t._translate=e;}static addKey(e,n,i){let r=i.defaultValue||"empty_string";typeof n=="string"&&(n=[n]),Array.isArray(n)&&n.forEach(l=>{e[l]===void 0&&(r==="empty_string"?e[l]="":r==="copy_key"&&(e[l]=l));});}static getConditionalsThenElse(e,n=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,n),e.else&&t.getConditionalsThenElse(e.else,n);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(i=>{t.getConditionalsThenElse(i,n);});else if(e.elements.type==="ifelse"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else if(e.elements.type==="stepswitch"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else t.getConditionalsThenElse(e.elements,n);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,n),e.secondConditionalItem&&e.secondConditionalItem.forEach(i=>{t.getConditionalsThenElse(i,n);})):n.push(e);else e&&n.push(e);return n}static generateJsonTranslation(e,n={},i={}){return e.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(p=>{if("type"in p){let g=[];p.type==="ifelse"||p.type==="stepswitch"?t.getConditionalsThenElse(p,g):g=[p],g.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(y=>{Array.isArray(y)?y.forEach(h=>{typeof h=="string"?t.addKey(n,h,i):t.getConditionalsThenElse(h).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(n,x,i);}):typeof T=="string"&&t.addKey(n,T,i);});}):typeof y=="string"&&t.addKey(n,y,i);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(n,c,i):"text"in c&&Array.isArray(c.text)&&c.text.forEach(p=>{typeof p=="string"?t.addKey(n,p,i):t.getConditionalsThenElse(p).forEach(d=>{typeof d=="string"?t.addKey(n,d,i):Array.isArray(d)&&d.forEach(s=>{typeof s=="string"?t.addKey(n,s,i):t.getConditionalsThenElse(s).forEach(y=>{typeof y=="string"&&t.addKey(n,y,i);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,n,i):t.generateJsonTranslation([c],n,i);});}),n}};function de(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return ye(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let n=f(t.elements)||[];if(n.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let i=de(0,n.length-1);return f(n[i]);case"loop":let r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>n.length-1&&(r=r%n.length),f(n[r]);case"sequential":let l,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(n[n.length-1])),c>n.length-1?l:f(n[c]);case"sequentialrandom":let p=pixiVn.NarrationManagerStatic.getRandomNumber(0,n.length-1,{nestedId:t.nestedId,onceOnly:!0});if(p==null&&t.end=="lastItem"){let g=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=g.usedRandomNumbers[`0-${n.length-1}`];return f(n[d[d.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(n[p])}}return t}function I(t){if(t.conditionalStep){let e=pixiVn.createExportableElement(f(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operation===void 0&&delete e?.operation,e){let n={...t,conditionalStep:void 0,...e};return I(n)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function ye(t){let e=t.firstItem,n=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);n.push(c);});else {let l=f(r);n.push(l);}});let i=e?[e,...n]:n;if(i.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return P.t(i).join("");if(typeof i[0]=="object"){let r=i,l,c=r.map((a,o)=>{a=I(a);let u=f(a.dialogue)||"";return o===0?(l=f(a.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
2
2
 
3
- `+u),l=f(n.glueEnabled)||!1,u)}),h=f(c[0]),d=typeof h=="object"&&"character"in h?h.character:void 0,p=c.map(n=>{let o;n&&typeof n=="object"&&"text"in n?o=n.text:o=n;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(n=>n.end),g=r.find(n=>n.choices),y=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=r[r.length-1].glueEnabled,T=r.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=r.find(n=>n.labelToOpen),S=[];return r.forEach(n=>{n.operation&&S.forEach(o=>{S.push(o);});}),{dialogue:d?{character:d,text:p}:p,end:s?.end,choices:g?.choices,glueEnabled:y,goNextStep:T,labelToOpen:x?.labelToOpen,operation:S}}}function ye(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let i=f(t.leftValue),e=f(t.rightValue);switch(t.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"choice":return pixiVn.narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let i=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>t.key)return i[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let i=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(i=f(t.conditions[e])||!1,t.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function Q(t){let i=f(t.value),e;switch(i&&typeof i=="object"&&"type"in i?e=f(i):e=i,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,e);break;case"tempstorage":pixiVn.storage.setTempVariable(t.key,e);break;case"params":let a=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];a&&a.length-1>=t.key&&(a[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,a);break}}function f(t){let i=ge(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return me(i);case"arithmetic":case"arithmeticsingle":return Te(i);case"compare":case"valueCondition":case"union":return ye(i)}return i}function Te(t){let i=f(t.leftValue);switch(t.type){case"arithmetic":let e=f(t.rightValue);switch(t.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return pixiVn.narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function W(t,i){let e=f(t);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(e.alias);break;case"pause":pixiVn.sound.pause(e.alias);break;case"resume":pixiVn.sound.resume(e.alias);break;case"volume":pixiVn.sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let a=pixiVn.canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new pixiVn.CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let a=pixiVn.canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let r=pixiVn.canvas.find(e.alias);r?r.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let l=pixiVn.canvas.find(e.alias);l?l.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":Q(e);break;case"oprationtoconvert":if(i){let a="";e.values.forEach(l=>{if(typeof l=="string")a+=l;else {let c=f(l);a+=`${c}`;}});let r=i(a);r&&await W(r);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var B=class extends pixiVn.LabelAbstract{constructor(i,e,a,r={}){super(i,a),this._steps=e,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(i=>this.stepConverter(i))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(i){if(i<0||i>=this.steps.length)return;let e=this._steps[i];return (0, ae.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let a=[];i.forEach(r=>{if(typeof r=="string")a.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?a=a.concat(l):a.push(`${l}`)):a.push(`${r}`);}}),e=a;}else {let a=f(i)||"";a&&!Array.isArray(a)&&typeof a=="object"&&(a=f(a)||""),e=a;}return `${e}`}getDialogue(i){let e=f(i);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:P.t(this.getDialogueText(e.text))}:P.t(this.getDialogueText(e));if(e!=null)return `${e}`}getChoices(i){return f(i)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=I(i),i.operation)for(let p of i.operation)await W(p,this.operationStringConvert);let a=this.getChoices(i.choices),r=f(i.glueEnabled),l=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let s=f(p);s&&c.push(s);}));let h=f(i.goNextStep),d=f(i.end);if(a){let p=a.map(s=>{let g="";if(Array.isArray(s.text)){let y=[];s.text.forEach(T=>{if(typeof T=="string")y.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?y=y.concat(P.t(x)):y.push(P.t(x)));}}),g=y.join();}else typeof s.text=="string"&&(g=P.t(s.text));return new pixiVn.ChoiceMenuOption(g,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});pixiVn.narration.choiceMenuOptions=p;}else pixiVn.narration.choiceMenuOptions=void 0;l!==void 0&&(pixiVn.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=!0)),r?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let s=p.label;typeof s=="object"&&(s=f(s)||"");let g=p.params?.map(y=>f(y));e={...e,...p.props},p.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(s,e)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(s,e));}d==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):d==="label_end"&&pixiVn.narration.closeCurrentLabel(),h&&await pixiVn.narration.goNext(e);}}};exports.LabelJson=B;
3
+ `+u),l=f(a.glueEnabled)||!1,u)}),p=f(c[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,d=c.map(a=>{let o;a&&typeof a=="object"&&"text"in a?o=a.text:o=a;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(a=>a.end),y=r.find(a=>a.choices),h=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=r[r.length-1].glueEnabled,T=r.reverse().find(a=>!(a.operation&&(!a.dialogue||!a.choices)))?.goNextStep);let x=r.find(a=>a.labelToOpen),v=[];return r.forEach(a=>{a.operation&&v.forEach(o=>{v.push(o);});}),{dialogue:g?{character:g,text:d}:d,end:s?.end,choices:y?.choices,glueEnabled:h,goNextStep:T,labelToOpen:x?.labelToOpen,operation:v}}}function he(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let e=f(t.leftValue),n=f(t.rightValue);switch(t.operator){case"==":return e===n;case"!=":return e!==n;case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"CONTAINS":return e.toString().includes(n.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"choice":return pixiVn.narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let e=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let e=t.unionType==="and";for(let n=0;n<t.conditions.length;n++)if(e=f(t.conditions[n])||!1,t.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function Q(t){let e=f(t.value),n;switch(e&&typeof e=="object"&&"type"in e?n=f(e):n=e,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,n);break;case"tempstorage":pixiVn.storage.setTempVariable(t.key,n);break;case"params":let i=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];i&&i.length-1>=t.key&&(i[t.key]=n),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,i);break}}function f(t){let e=ge(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return me(e);case"arithmetic":case"arithmeticsingle":return Te(e);case"compare":case"valueCondition":case"union":return he(e)}return e}function Te(t){let e=f(t.leftValue);switch(t.type){case"arithmetic":let n=f(t.rightValue);switch(t.operator){case"*":return e*n;case"/":return e/n;case"+":return e+n;case"-":return e-n;case"%":return e%n;case"POW":return Math.pow(e,n);case"RANDOM":return pixiVn.narration.getRandomNumber(e,n)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}async function W(t,e,n){let i=f(t);if(i)switch(i.type){case"sound":switch(i.operationType){case"add":pixiVn.sound.add(i.alias,{...i.props,url:i.url});break;case"play":pixiVn.sound.play(i.alias,i.props);break;case"remove":pixiVn.sound.remove(i.alias);break;case"pause":pixiVn.sound.pause(i.alias);break;case"resume":pixiVn.sound.resume(i.alias);break;case"volume":pixiVn.sound.volume(i.alias,i.value);break}break;case"image":switch(i.operationType){case"show":if(i.transition)switch(i.transition.type){case"fade":await pixiVn.showWithFadeTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(i.alias,i.url,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(i.alias,i.url,i.transition.props,i.transition.priority);break}else await pixiVn.showImage(i.alias,i.url);break;case"edit":let r=pixiVn.canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${i.alias} not found.`);break;case"remove":pixiVn.canvas.remove(i.alias);break}break;case"video":switch(i.operationType){case"show":if(i.transition){let p=new pixiVn.CanvasVideo;switch(p.videoLink=i.url,i.transition.type){case"fade":await pixiVn.showWithFadeTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(i.alias,p,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(i.alias,p,i.transition.props,i.transition.priority);break}}else await pixiVn.showVideo(i.alias,i.url);break;case"edit":let r=pixiVn.canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"remove":pixiVn.canvas.remove(i.alias);break;case"pause":let l=pixiVn.canvas.find(i.alias);l?l.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"resume":let c=pixiVn.canvas.find(i.alias);c?c.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break}break;case"value":Q(i);break;case"oprationtoconvert":if(n){let r="";i.values.forEach(c=>{if(typeof c=="string")r+=c;else {let p=f(c);r+=`${p}`;}});let l=n(r,e);l&&await W(l,e,n);}break;case"input":switch(i.operationType){case"request":pixiVn.narration.requestInput({type:i.valueType});break}break}}var B=class extends pixiVn.LabelAbstract{constructor(e,n,i,r={}){super(e,i),this._steps=n,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(e){if(e<0||e>=this.steps.length)return;let n=this._steps[e];return (0, ae.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(e){let n="";if(Array.isArray(e)){let i=[];e.forEach(r=>{if(typeof r=="string")i.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?i=i.concat(l):i.push(`${l}`)):i.push(`${r}`);}}),n=i;}else {let i=f(e)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=f(i)||""),n=i;}return `${n}`}getDialogue(e){let n=f(e);if(n)return typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:P.t(this.getDialogueText(n.text))}:P.t(this.getDialogueText(n));if(n!=null)return `${n}`}getChoices(e){return f(e)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(e){return async n=>{if(typeof e=="function"&&(e=e()),e=I(e),e.operation)for(let d of e.operation)await W(d,n,this.operationStringConvert);let i=this.getChoices(e.choices),r=f(e.glueEnabled),l=this.getDialogue(e.dialogue),c=[];e.labelToOpen&&(Array.isArray(e.labelToOpen)||(e.labelToOpen=[e.labelToOpen]),e.labelToOpen.forEach(d=>{let s=f(d);s&&c.push(s);}));let p=f(e.goNextStep),g=f(e.end);if(i){let d=i.map(s=>{let y="";if(Array.isArray(s.text)){let h=[];s.text.forEach(T=>{if(typeof T=="string")h.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?h=h.concat(P.t(x)):h.push(P.t(x)));}}),y=h.join();}else typeof s.text=="string"&&(y=P.t(s.text));return new pixiVn.ChoiceMenuOption(y,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});pixiVn.narration.choiceMenuOptions=d;}else pixiVn.narration.choiceMenuOptions=void 0;l!==void 0&&(pixiVn.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(p=!0)),r?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let d of c){let s=d.label;typeof s=="object"&&(s=f(s)||"");let y=d.params?.map(h=>f(h));n={...n,...d.props},d.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,y),await pixiVn.narration.callLabel(s,n)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,y),await pixiVn.narration.callLabel(s,n));}g==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(n)):g==="label_end"&&pixiVn.narration.closeCurrentLabel(),p&&await pixiVn.narration.goNext(n);}}};exports.LabelJson=B;
@@ -1,3 +1,3 @@
1
- import {LabelAbstract,ChoiceMenuOption,narration,setFlag,storage,createExportableElement,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound,NarrationManagerStatic}from'@drincs/pixi-vn';var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var $=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,e)=>(typeof require<"u"?require:i)[e]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ce=(t,i,e,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of se(i))!fe.call(t,r)&&r!==e&&M(t,r,{get:()=>i[r],enumerable:!(a=oe(i,r))||a.enumerable});return t};var ue=(t,i,e)=>(e=t!=null?re(le(t)):{},ce(M(e,"default",{value:t,enumerable:!0}),t));var U=j((L,K)=>{(function(t,i){typeof L=="object"?K.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,e){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof $=="function")try{a=$("crypto");}catch{}var r=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function n(){}return function(o){var u;return n.prototype=o,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var o=l(this);return n&&o.mixIn(n),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var o in n)n.hasOwnProperty(o)&&(this[o]=n[o]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,o){n=this.words=n||[],o!=e?this.sigBytes=o:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var o=this.words,u=n.words,m=this.sigBytes,b=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var G=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=G<<24-(m+N)%4*8;}else for(var C=0;C<b;C+=4)o[m+C>>>2]=u[C>>>2];return this.sigBytes+=b,this},clamp:function(){var n=this.words,o=this.sigBytes;n[o>>>2]&=4294967295<<32-o%4*8,n.length=i.ceil(o/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var o=[],u=0;u<n;u+=4)o.push(r());return new p.init(o,n)}}),s=c.enc={},g=s.Hex={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,o/2)}},y=s.Latin1={stringify:function(n){for(var o=n.words,u=n.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var o=n.length,u=[],m=0;m<o;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,o)}},T=s.Utf8={stringify:function(n){try{return decodeURIComponent(escape(y.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return y.parse(unescape(encodeURIComponent(n)))}},x=h.BufferedBlockAlgorithm=d.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=T.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,G=N*4,C=b/G;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var O=C*N,z=i.min(O*4,b);if(O){for(var H=0;H<O;H+=N)this._doProcessBlock(m,H);o=m.splice(0,O),u.sigBytes-=z;}return new p.init(o,z)},clone:function(){var n=d.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});h.Hasher=x.extend({cfg:d.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(n){return function(o,u){return new n.init(u).finalize(o)}},_createHmacHelper:function(n){return function(o,u){return new V.HMAC.init(n,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,i){typeof k=="object"?X.exports=k=i(U()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,a=e.WordArray,r=e.Hasher,l=i.algo,c=[],h=l.SHA1=r.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var s=this._hash.words,g=s[0],y=s[1],T=s[2],x=s[3],S=s[4],V=0;V<80;V++){if(V<16)c[V]=d[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var o=(g<<5|g>>>27)+S+c[V];V<20?o+=(y&T|~y&x)+1518500249:V<40?o+=(y^T^x)+1859775393:V<60?o+=(y&T|y&x|T&x)-1894007588:o+=(y^T^x)-899497514,S=x,x=T,T=y<<30|y>>>2,y=g,g=o;}s[0]=s[0]+g|0,s[1]=s[1]+y|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+S|0;},_doFinalize:function(){var d=this._data,p=d.words,s=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(s/4294967296),p[(g+64>>>9<<4)+15]=s,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=r.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=r._createHelper(h),i.HmacSHA1=r._createHmacHelper(h);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=i=>i;static t(i){return Array.isArray(i)?i.map(e=>t._translate(`${e}`)):t._translate(`${i}`)}static set translate(i){t._translate=i;}static addKey(i,e,a){let r=a.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(r==="empty_string"?i[l]="":r==="copy_key"&&(i[l]=l));});}static getConditionalsThenElse(i,e=[]){if(typeof i=="object"&&i&&"type"in i)if(i.type==="ifelse")i.then&&t.getConditionalsThenElse(i.then,e),i.else&&t.getConditionalsThenElse(i.else,e);else if(i.type==="stepswitch"){if(i.elements)if(Array.isArray(i.elements))i.elements.forEach(a=>{t.getConditionalsThenElse(a,e);});else if(i.elements.type==="ifelse"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else if(i.elements.type==="stepswitch"){let a=[];t.getConditionalsThenElse(i.elements,a),a.forEach(r=>{e.push(...r);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(a=>{t.getConditionalsThenElse(a,e);})):e.push(i);else i&&e.push(i);return e}static generateTranslateJson(i,e={},a={}){return i.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(h=>{if("type"in h){let d=[];h.type==="ifelse"||h.type==="stepswitch"?t.getConditionalsThenElse(h,d):d=[h],d.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,a):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,a);}):typeof T=="string"&&t.addKey(e,T,a);});}):typeof g=="string"&&t.addKey(e,g,a);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,a):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,a):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,a):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,a):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,a);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateTranslateJson(c,e,a):t.generateTranslateJson([c],e,a);});}),e}};function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return he(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let a=de(0,e.length-1);return f(e[a]);case"loop":let r=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>e.length-1&&(r=r%e.length),f(e[r]);case"sequential":let l,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(e[e.length-1])),c>e.length-1?l:f(e[c]);case"sequentialrandom":let h=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(h==null&&t.end=="lastItem"){let d=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=d.usedRandomNumbers[`0-${e.length-1}`];return f(e[p[p.length-1]])}if(h==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(e[h])}}return t}function I(t){if(t.conditionalStep){let i=createExportableElement(f(t.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operation===void 0&&delete i?.operation,i){let e={...t,conditionalStep:void 0,...i};return I(e)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function he(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(r);e.push(l);}});let a=i?[i,...e]:e;if(a.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof a[0]=="string")return P.t(a).join("");if(typeof a[0]=="object"){let r=a,l,c=r.map((n,o)=>{n=I(n);let u=f(n.dialogue)||"";return o===0?(l=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
1
+ import {LabelAbstract,ChoiceMenuOption,narration,setFlag,storage,createExportableElement,getFlag,canvas,CanvasVideo,zoomIn,moveIn,showWithDissolveTransition,showWithFadeTransition,showVideo,showImage,sound,NarrationManagerStatic}from'@drincs/pixi-vn';var re=Object.create;var M=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,fe=Object.prototype.hasOwnProperty;var $=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ce=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of se(e))!fe.call(t,r)&&r!==n&&M(t,r,{get:()=>e[r],enumerable:!(i=oe(e,r))||i.enumerable});return t};var ue=(t,e,n)=>(n=t!=null?re(le(t)):{},ce(M(n,"default",{value:t,enumerable:!0}),t));var U=j((O,K)=>{(function(t,e){typeof O=="object"?K.exports=O=e():typeof define=="function"&&define.amd?define([],e):t.CryptoJS=e();})(O,function(){var t=t||function(e,n){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof $=="function")try{i=$("crypto");}catch{}var r=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function a(){}return function(o){var u;return a.prototype=o,u=new a,a.prototype=null,u}}(),c={},p=c.lib={},g=p.Base=function(){return {extend:function(a){var o=l(this);return a&&o.mixIn(a),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var a=this.extend();return a.init.apply(a,arguments),a},init:function(){},mixIn:function(a){for(var o in a)a.hasOwnProperty(o)&&(this[o]=a[o]);a.hasOwnProperty("toString")&&(this.toString=a.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),d=p.WordArray=g.extend({init:function(a,o){a=this.words=a||[],o!=n?this.sigBytes=o:this.sigBytes=a.length*4;},toString:function(a){return (a||y).stringify(this)},concat:function(a){var o=this.words,u=a.words,m=this.sigBytes,b=a.sigBytes;if(this.clamp(),m%4)for(var N=0;N<b;N++){var G=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=G<<24-(m+N)%4*8;}else for(var S=0;S<b;S+=4)o[m+S>>>2]=u[S>>>2];return this.sigBytes+=b,this},clamp:function(){var a=this.words,o=this.sigBytes;a[o>>>2]&=4294967295<<32-o%4*8,a.length=e.ceil(o/4);},clone:function(){var a=g.clone.call(this);return a.words=this.words.slice(0),a},random:function(a){for(var o=[],u=0;u<a;u+=4)o.push(r());return new d.init(o,a)}}),s=c.enc={},y=s.Hex={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m+=2)u[m>>>3]|=parseInt(a.substr(m,2),16)<<24-m%8*4;return new d.init(u,o/2)}},h=s.Latin1={stringify:function(a){for(var o=a.words,u=a.sigBytes,m=[],b=0;b<u;b++){var N=o[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(a){for(var o=a.length,u=[],m=0;m<o;m++)u[m>>>2]|=(a.charCodeAt(m)&255)<<24-m%4*8;return new d.init(u,o)}},T=s.Utf8={stringify:function(a){try{return decodeURIComponent(escape(h.stringify(a)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(a){return h.parse(unescape(encodeURIComponent(a)))}},x=p.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(a){typeof a=="string"&&(a=T.parse(a)),this._data.concat(a),this._nDataBytes+=a.sigBytes;},_process:function(a){var o,u=this._data,m=u.words,b=u.sigBytes,N=this.blockSize,G=N*4,S=b/G;a?S=e.ceil(S):S=e.max((S|0)-this._minBufferSize,0);var L=S*N,z=e.min(L*4,b);if(L){for(var H=0;H<L;H+=N)this._doProcessBlock(m,H);o=m.splice(0,L),u.sigBytes-=z;}return new d.init(o,z)},clone:function(){var a=g.clone.call(this);return a._data=this._data.clone(),a},_minBufferSize:0});p.Hasher=x.extend({cfg:g.extend(),init:function(a){this.cfg=this.cfg.extend(a),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(a){return this._append(a),this._process(),this},finalize:function(a){a&&this._append(a);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(a){return function(o,u){return new a.init(u).finalize(o)}},_createHmacHelper:function(a){return function(o,u){return new V.HMAC.init(a,u).finalize(o)}}});var V=c.algo={};return c}(Math);return t});});var q=j((k,X)=>{(function(t,e){typeof k=="object"?X.exports=k=e(U()):typeof define=="function"&&define.amd?define(["./core"],e):e(t.CryptoJS);})(k,function(t){return function(){var e=t,n=e.lib,i=n.WordArray,r=n.Hasher,l=e.algo,c=[],p=l.SHA1=r.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,d){for(var s=this._hash.words,y=s[0],h=s[1],T=s[2],x=s[3],v=s[4],V=0;V<80;V++){if(V<16)c[V]=g[d+V]|0;else {var a=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=a<<1|a>>>31;}var o=(y<<5|y>>>27)+v+c[V];V<20?o+=(h&T|~h&x)+1518500249:V<40?o+=(h^T^x)+1859775393:V<60?o+=(h&T|h&x|T&x)-1894007588:o+=(h^T^x)-899497514,v=x,x=T,T=h<<30|h>>>2,h=y,y=o;}s[0]=s[0]+y|0,s[1]=s[1]+h|0,s[2]=s[2]+T|0,s[3]=s[3]+x|0,s[4]=s[4]+v|0;},_doFinalize:function(){var g=this._data,d=g.words,s=this._nDataBytes*8,y=g.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(s/4294967296),d[(y+64>>>9<<4)+15]=s,g.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var g=r.clone.call(this);return g._hash=this._hash.clone(),g}});e.SHA1=r._createHelper(p),e.HmacSHA1=r._createHmacHelper(p);}(),t.SHA1});});var ae=ue(q());var E="___param___";var P=class t{static _translate=e=>e;static t(e){return Array.isArray(e)?e.map(n=>t._translate(`${n}`)):t._translate(`${e}`)}static set translate(e){t._translate=e;}static addKey(e,n,i){let r=i.defaultValue||"empty_string";typeof n=="string"&&(n=[n]),Array.isArray(n)&&n.forEach(l=>{e[l]===void 0&&(r==="empty_string"?e[l]="":r==="copy_key"&&(e[l]=l));});}static getConditionalsThenElse(e,n=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&t.getConditionalsThenElse(e.then,n),e.else&&t.getConditionalsThenElse(e.else,n);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(i=>{t.getConditionalsThenElse(i,n);});else if(e.elements.type==="ifelse"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else if(e.elements.type==="stepswitch"){let i=[];t.getConditionalsThenElse(e.elements,i),i.forEach(r=>{n.push(...r);});}else t.getConditionalsThenElse(e.elements,n);}else e.type==="resulttocombine"?(e.firstItem&&t.getConditionalsThenElse(e.firstItem,n),e.secondConditionalItem&&e.secondConditionalItem.forEach(i=>{t.getConditionalsThenElse(i,n);})):n.push(e);else e&&n.push(e);return n}static generateJsonTranslation(e,n={},i={}){return e.forEach(r=>{if(r.choices){let l=[];Array.isArray(r.choices)?l=[r.choices]:l=t.getConditionalsThenElse(r.choices),l.forEach(c=>c.forEach(p=>{if("type"in p){let g=[];p.type==="ifelse"||p.type==="stepswitch"?t.getConditionalsThenElse(p,g):g=[p],g.map(s=>t.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(y=>{Array.isArray(y)?y.forEach(h=>{typeof h=="string"?t.addKey(n,h,i):t.getConditionalsThenElse(h).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(n,x,i);}):typeof T=="string"&&t.addKey(n,T,i);});}):typeof y=="string"&&t.addKey(n,y,i);});});}}));}if(r.dialogue){let l=[];Array.isArray(r.dialogue)?l=[r.dialogue]:l=t.getConditionalsThenElse(r.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(n,c,i):"text"in c&&Array.isArray(c.text)&&c.text.forEach(p=>{typeof p=="string"?t.addKey(n,p,i):t.getConditionalsThenElse(p).forEach(d=>{typeof d=="string"?t.addKey(n,d,i):Array.isArray(d)&&d.forEach(s=>{typeof s=="string"?t.addKey(n,s,i):t.getConditionalsThenElse(s).forEach(y=>{typeof y=="string"&&t.addKey(n,y,i);});});});});});}r.conditionalStep&&t.getConditionalsThenElse(r.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,n,i):t.generateJsonTranslation([c],n,i);});}),n}};function de(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function ge(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return ye(t);case"ifelse":return f(t.condition)?f(t.then):f(t.else);case"stepswitch":let n=f(t.elements)||[];if(n.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let i=de(0,n.length-1);return f(n[i]);case"loop":let r=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return r>n.length-1&&(r=r%n.length),f(n[r]);case"sequential":let l,c=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(l=f(n[n.length-1])),c>n.length-1?l:f(n[c]);case"sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,n.length-1,{nestedId:t.nestedId,onceOnly:!0});if(p==null&&t.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=g.usedRandomNumbers[`0-${n.length-1}`];return f(n[d[d.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return f(n[p])}}return t}function I(t){if(t.conditionalStep){let e=createExportableElement(f(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operation===void 0&&delete e?.operation,e){let n={...t,conditionalStep:void 0,...e};return I(n)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return t}function ye(t){let e=t.firstItem,n=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(l=>{let c=f(l);n.push(c);});else {let l=f(r);n.push(l);}});let i=e?[e,...n]:n;if(i.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return P.t(i).join("");if(typeof i[0]=="object"){let r=i,l,c=r.map((a,o)=>{a=I(a);let u=f(a.dialogue)||"";return o===0?(l=f(a.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),l===!1&&(u=`
2
2
 
3
- `+u),l=f(n.glueEnabled)||!1,u)}),h=f(c[0]),d=typeof h=="object"&&"character"in h?h.character:void 0,p=c.map(n=>{let o;n&&typeof n=="object"&&"text"in n?o=n.text:o=n;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(n=>n.end),g=r.find(n=>n.choices),y=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=r[r.length-1].glueEnabled,T=r.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=r.find(n=>n.labelToOpen),S=[];return r.forEach(n=>{n.operation&&S.forEach(o=>{S.push(o);});}),{dialogue:d?{character:d,text:p}:p,end:s?.end,choices:g?.choices,glueEnabled:y,goNextStep:T,labelToOpen:x?.labelToOpen,operation:S}}}function ye(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let i=f(t.leftValue),e=f(t.rightValue);switch(t.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return storage.getVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"choice":return narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let i=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(i&&i.length>t.key)return i[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let i=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(i=f(t.conditions[e])||!1,t.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function Q(t){let i=f(t.value),e;switch(i&&typeof i=="object"&&"type"in i?e=f(i):e=i,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,e);break;case"tempstorage":storage.setTempVariable(t.key,e);break;case"params":let a=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];a&&a.length-1>=t.key&&(a[t.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,a);break}}function f(t){let i=ge(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return me(i);case"arithmetic":case"arithmeticsingle":return Te(i);case"compare":case"valueCondition":case"union":return ye(i)}return i}function Te(t){let i=f(t.leftValue);switch(t.type){case"arithmetic":let e=f(t.rightValue);switch(t.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function W(t,i){let e=f(t);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(e.alias);break;case"pause":sound.pause(e.alias);break;case"resume":sound.resume(e.alias);break;case"volume":sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let a=canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let a=canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let r=canvas.find(e.alias);r?r.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let l=canvas.find(e.alias);l?l.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":Q(e);break;case"oprationtoconvert":if(i){let a="";e.values.forEach(l=>{if(typeof l=="string")a+=l;else {let c=f(l);a+=`${c}`;}});let r=i(a);r&&await W(r);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var B=class extends LabelAbstract{constructor(i,e,a,r={}){super(i,a),this._steps=e,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(i=>this.stepConverter(i))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(i){if(i<0||i>=this.steps.length)return;let e=this._steps[i];return (0, ae.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let a=[];i.forEach(r=>{if(typeof r=="string")a.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?a=a.concat(l):a.push(`${l}`)):a.push(`${r}`);}}),e=a;}else {let a=f(i)||"";a&&!Array.isArray(a)&&typeof a=="object"&&(a=f(a)||""),e=a;}return `${e}`}getDialogue(i){let e=f(i);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:P.t(this.getDialogueText(e.text))}:P.t(this.getDialogueText(e));if(e!=null)return `${e}`}getChoices(i){return f(i)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=I(i),i.operation)for(let p of i.operation)await W(p,this.operationStringConvert);let a=this.getChoices(i.choices),r=f(i.glueEnabled),l=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let s=f(p);s&&c.push(s);}));let h=f(i.goNextStep),d=f(i.end);if(a){let p=a.map(s=>{let g="";if(Array.isArray(s.text)){let y=[];s.text.forEach(T=>{if(typeof T=="string")y.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?y=y.concat(P.t(x)):y.push(P.t(x)));}}),g=y.join();}else typeof s.text=="string"&&(g=P.t(s.text));return new ChoiceMenuOption(g,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});narration.choiceMenuOptions=p;}else narration.choiceMenuOptions=void 0;l!==void 0&&(narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=!0)),r?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let s=p.label;typeof s=="object"&&(s=f(s)||"");let g=p.params?.map(y=>f(y));e={...e,...p.props},p.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${E}${narration.openedLabels.length}`,g),await narration.callLabel(s,e)):(storage.setTempVariable(`${E}${narration.openedLabels.length}`,g),await narration.callLabel(s,e));}d==="game_end"?(narration.closeAllLabels(),await narration.goNext(e)):d==="label_end"&&narration.closeCurrentLabel(),h&&await narration.goNext(e);}}};export{B as LabelJson};
3
+ `+u),l=f(a.glueEnabled)||!1,u)}),p=f(c[0]),g=typeof p=="object"&&"character"in p?p.character:void 0,d=c.map(a=>{let o;a&&typeof a=="object"&&"text"in a?o=a.text:o=a;let u;return Array.isArray(o)?u=o.map(m=>{let b=f(m);return P.t(`${b}`)}).join(""):u=f(o)||"",P.t(u)}).join(""),s=r.find(a=>a.end),y=r.find(a=>a.choices),h=!1,T=!1;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=r[r.length-1].glueEnabled,T=r.reverse().find(a=>!(a.operation&&(!a.dialogue||!a.choices)))?.goNextStep);let x=r.find(a=>a.labelToOpen),v=[];return r.forEach(a=>{a.operation&&v.forEach(o=>{v.push(o);});}),{dialogue:g?{character:g,text:d}:d,end:s?.end,choices:y?.choices,glueEnabled:h,goNextStep:T,labelToOpen:x?.labelToOpen,operation:v}}}function he(t){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let e=f(t.leftValue),n=f(t.rightValue);switch(t.operator){case"==":return e===n;case"!=":return e!==n;case"<":return e<n;case"<=":return e<=n;case">":return e>n;case">=":return e>=n;case"CONTAINS":return e.toString().includes(n.toString())}break;case"valueCondition":return !!f(t.value);case"union":return xe(t)}return !!t}function me(t){if(t&&typeof t=="object"&&"type"in t&&t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":case"tempstorage":return storage.getVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"choice":return narration.getTimesChoiceMade(t.index);case"logic":return f(t.operation);case"params":let e=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return t}function xe(t){if(t.unionType==="not")return !f(t.condition);let e=t.unionType==="and";for(let n=0;n<t.conditions.length;n++)if(e=f(t.conditions[n])||!1,t.unionType==="and"){if(!e)return !1}else if(e)return !0;return e}function Q(t){let e=f(t.value),n;switch(e&&typeof e=="object"&&"type"in e?n=f(e):n=e,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,n);break;case"tempstorage":storage.setTempVariable(t.key,n);break;case"params":let i=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];i&&i.length-1>=t.key&&(i[t.key]=n),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,i);break}}function f(t){let e=ge(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"value":return me(e);case"arithmetic":case"arithmeticsingle":return Te(e);case"compare":case"valueCondition":case"union":return he(e)}return e}function Te(t){let e=f(t.leftValue);switch(t.type){case"arithmetic":let n=f(t.rightValue);switch(t.operator){case"*":return e*n;case"/":return e/n;case"+":return e+n;case"-":return e-n;case"%":return e%n;case"POW":return Math.pow(e,n);case"RANDOM":return narration.getRandomNumber(e,n)}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(e);case"FLOOR":return Math.floor(e);case"FLOAT":return parseFloat(e)}break}}async function W(t,e,n){let i=f(t);if(i)switch(i.type){case"sound":switch(i.operationType){case"add":sound.add(i.alias,{...i.props,url:i.url});break;case"play":sound.play(i.alias,i.props);break;case"remove":sound.remove(i.alias);break;case"pause":sound.pause(i.alias);break;case"resume":sound.resume(i.alias);break;case"volume":sound.volume(i.alias,i.value);break}break;case"image":switch(i.operationType){case"show":if(i.transition)switch(i.transition.type){case"fade":await showWithFadeTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"dissolve":await showWithDissolveTransition(i.alias,i.url,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await moveIn(i.alias,i.url,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(i.alias,i.url,i.transition.props,i.transition.priority);break}else await showImage(i.alias,i.url);break;case"edit":let r=canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${i.alias} not found.`);break;case"remove":canvas.remove(i.alias);break}break;case"video":switch(i.operationType){case"show":if(i.transition){let p=new CanvasVideo;switch(p.videoLink=i.url,i.transition.type){case"fade":await showWithFadeTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"dissolve":await showWithDissolveTransition(i.alias,p,i.transition.props,i.transition.priority);break;case"movein":case"moveout":await moveIn(i.alias,p,i.transition.props,i.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(i.alias,p,i.transition.props,i.transition.priority);break}}else await showVideo(i.alias,i.url);break;case"edit":let r=canvas.find(i.alias);r?i.props&&(r.memory={...r.memory,...i.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"remove":canvas.remove(i.alias);break;case"pause":let l=canvas.find(i.alias);l?l.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break;case"resume":let c=canvas.find(i.alias);c?c.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${i.alias} not found.`);break}break;case"value":Q(i);break;case"oprationtoconvert":if(n){let r="";i.values.forEach(c=>{if(typeof c=="string")r+=c;else {let p=f(c);r+=`${p}`;}});let l=n(r,e);l&&await W(l,e,n);}break;case"input":switch(i.operationType){case"request":narration.requestInput({type:i.valueType});break}break}}var B=class extends LabelAbstract{constructor(e,n,i,r={}){super(e,i),this._steps=n,this.operationStringConvert=r.operationStringConvert,this.skipEmptyDialogs=r.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(e){if(e<0||e>=this.steps.length)return;let n=this._steps[e];return (0, ae.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(e){let n="";if(Array.isArray(e)){let i=[];e.forEach(r=>{if(typeof r=="string")i.push(r);else if(r&&typeof r=="object"){let l=f(r);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?i=i.concat(l):i.push(`${l}`)):i.push(`${r}`);}}),n=i;}else {let i=f(e)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=f(i)||""),n=i;}return `${n}`}getDialogue(e){let n=f(e);if(n)return typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:P.t(this.getDialogueText(n.text))}:P.t(this.getDialogueText(n));if(n!=null)return `${n}`}getChoices(e){return f(e)?.map(r=>f(r)).filter(r=>r!==void 0)}stepConverter(e){return async n=>{if(typeof e=="function"&&(e=e()),e=I(e),e.operation)for(let d of e.operation)await W(d,n,this.operationStringConvert);let i=this.getChoices(e.choices),r=f(e.glueEnabled),l=this.getDialogue(e.dialogue),c=[];e.labelToOpen&&(Array.isArray(e.labelToOpen)||(e.labelToOpen=[e.labelToOpen]),e.labelToOpen.forEach(d=>{let s=f(d);s&&c.push(s);}));let p=f(e.goNextStep),g=f(e.end);if(i){let d=i.map(s=>{let y="";if(Array.isArray(s.text)){let h=[];s.text.forEach(T=>{if(typeof T=="string")h.push(P.t(T));else if(T&&typeof T=="object"){let x=f(T);x&&!Array.isArray(x)&&typeof x=="object"&&(x=f(x)||""),x&&(Array.isArray(x)?h=h.concat(P.t(x)):h.push(P.t(x)));}}),y=h.join();}else typeof s.text=="string"&&(y=P.t(s.text));return new ChoiceMenuOption(y,s.label,s.props,{type:s.type,oneTime:s.oneTime,onlyHaveNoChoice:s.onlyHaveNoChoice,autoSelect:s.autoSelect})});narration.choiceMenuOptions=d;}else narration.choiceMenuOptions=void 0;l!==void 0&&(narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(p=!0)),r?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):r===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let d of c){let s=d.label;typeof s=="object"&&(s=f(s)||"");let y=d.params?.map(h=>f(h));n={...n,...d.props},d.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${E}${narration.openedLabels.length}`,y),await narration.callLabel(s,n)):(storage.setTempVariable(`${E}${narration.openedLabels.length}`,y),await narration.callLabel(s,n));}g==="game_end"?(narration.closeAllLabels(),await narration.goNext(n)):g==="label_end"&&narration.closeCurrentLabel(),p&&await narration.goNext(n);}}};export{B as LabelJson};