@drincs/pixi-vn-json 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Pixi’VN + Json Integration
2
2
 
3
+ ![pixi-vn-cover-json](https://github.com/user-attachments/assets/ec9aa39e-6e3c-4198-8a65-e1fce1f1d637)
4
+
3
5
  Pixi’VN can be integrated with JSON files to create a visual novel. This method is useful for:
4
6
 
5
7
  * Add a new narrative to Pixi’VN (It was used to create the integration with [Ink](https://pixi-vn.web.app/ink/ink.html) and [Ren'Py](https://pixi-vn.web.app/renpy/renpy.html))
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof $=="function")try{r=$("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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(a());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 L=C*N,j=i.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-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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 R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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 oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof $=="function")try{r=$("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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(a());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 L=C*N,j=i.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-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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?.operations===void 0&&delete i?.operations,i){let e={...t,conditionalStep:void 0,...i};return R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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=`
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.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 me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=pixiVn.canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await W(a,i);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var z=class extends pixiVn.LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operation)for(let p of i.operation)await W(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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=z;
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.forEach(n=>{n.operations&&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,operations:S}}}function me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=pixiVn.canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await W(a,i);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var z=class extends pixiVn.LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operations)for(let p of i.operations)await W(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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=z;
@@ -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 oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof $=="function")try{r=$("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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(a());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 L=C*N,j=i.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-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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 R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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 oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof $=="function")try{r=$("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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(a());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 L=C*N,j=i.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-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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?.operations===void 0&&delete i?.operations,i){let e={...t,conditionalStep:void 0,...i};return R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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=`
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.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 me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await W(a,i);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var z=class extends LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operation)for(let p of i.operation)await W(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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{z as default};
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.forEach(n=>{n.operations&&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,operations:S}}}function me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await W(a,i);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var z=class extends LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operations)for(let p of i.operations)await W(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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{z as default};
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var F=(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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof F=="function")try{r=F("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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 H=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=H<<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(a());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,H=N*4,C=b/H;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var L=C*N,j=i.min(L*4,b);if(L){for(var $=0;$<L;$+=N)this._doProcessBlock(m,$);o=m.splice(0,L),u.sigBytes-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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 R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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 oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var F=(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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof F=="function")try{r=F("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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 H=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=H<<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(a());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,H=N*4,C=b/H;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var L=C*N,j=i.min(L*4,b);if(L){for(var $=0;$<L;$+=N)this._doProcessBlock(m,$);o=m.splice(0,L),u.sigBytes-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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?.operations===void 0&&delete i?.operations,i){let e={...t,conditionalStep:void 0,...i};return R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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=`
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.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 me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 z(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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=pixiVn.canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await z(a,i);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var G=class extends pixiVn.LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operation)for(let p of i.operation)await z(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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=G;
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.forEach(n=>{n.operations&&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,operations:S}}}function me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 z(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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=pixiVn.canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await z(a,i);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var G=class extends pixiVn.LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operations)for(let p of i.operations)await z(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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=G;
@@ -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 oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var F=(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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof F=="function")try{r=F("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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 H=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=H<<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(a());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,H=N*4,C=b/H;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var L=C*N,j=i.min(L*4,b);if(L){for(var $=0;$<L;$+=N)this._doProcessBlock(m,$);o=m.splice(0,L),u.sigBytes-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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 R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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 oe=Object.create;var K=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var F=(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 M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of le(i))!ce.call(t,a)&&a!==e&&K(t,a,{get:()=>i[a],enumerable:!(r=se(i,a))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?oe(fe(t)):{},ue(K(e,"default",{value:t,enumerable:!0}),t));var X=M((O,U)=>{(function(t,i){typeof O=="object"?U.exports=O=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(O,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof F=="function")try{r=F("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},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 H=u[N>>>2]>>>24-N%4*8&255;o[m+N>>>2]|=H<<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(a());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,H=N*4,C=b/H;n?C=i.ceil(C):C=i.max((C|0)-this._minBufferSize,0);var L=C*N,j=i.min(L*4,b);if(L){for(var $=0;$<L;$+=N)this._doProcessBlock(m,$);o=m.splice(0,L),u.sigBytes-=j;}return new p.init(o,j)},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 Y=M((k,q)=>{(function(t,i){typeof k=="object"?q.exports=k=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(k,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,a=e.Hasher,l=i.algo,c=[],h=l.SHA1=a.extend({_doReset:function(){this._hash=new r.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=a.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=a._createHelper(h),i.HmacSHA1=a._createHmacHelper(h);}(),t.SHA1});});var ae=pe(Y());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,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(l=>{i[l]===void 0&&(a==="empty_string"?i[l]="":a==="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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(a=>{e.push(...a);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(a=>{if(a.choices){let l=[];Array.isArray(a.choices)?l=[a.choices]:l=t.getConditionalsThenElse(a.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,r):t.getConditionalsThenElse(y).forEach(T=>{Array.isArray(T)?T.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof T=="string"&&t.addKey(e,T,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(a.dialogue){let l=[];Array.isArray(a.dialogue)?l=[a.dialogue]:l=t.getConditionalsThenElse(a.dialogue),l.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(s=>{typeof s=="string"?t.addKey(e,s,r):t.getConditionalsThenElse(s).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}a.conditionalStep&&t.getConditionalsThenElse(a.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var D=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return a>e.length-1&&(a=a%e.length),f(e[a]);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 R(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?.operations===void 0&&delete i?.operations,i){let e={...t,conditionalStep:void 0,...i};return R(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(l=>{let c=f(l);e.push(c);});else {let l=f(a);e.push(l);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return D.t(r).join("");if(typeof r[0]=="object"){let a=r,l,c=a.map((n,o)=>{n=R(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=`
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.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 me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 z(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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await z(a,i);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var G=class extends LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operation)for(let p of i.operation)await z(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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{G as LabelJson};
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 D.t(`${b}`)}).join(""):u=f(o)||"",D.t(u)}).join(""),s=a.find(n=>n.end),g=a.find(n=>n.choices),y=!1,T=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=a[a.length-1].glueEnabled,T=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let x=a.find(n=>n.labelToOpen),S=[];return a.forEach(n=>{n.operations&&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,operations:S}}}function me(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 Te(t)}return !!t}function xe(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 Te(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 Z(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 r=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return be(i);case"compare":case"valueCondition":case"union":return me(i)}return i}function be(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 z(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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=canvas.find(e.alias);r?e.props&&(r.memory={...r.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 a=canvas.find(e.alias);a?a.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":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(l=>{if(typeof l=="string")r+=l;else {let c=f(l);r+=`${c}`;}});let a=await i(r);a&&await z(a,i);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var G=class extends LabelAbstract{constructor(i,e,r,a={}){super(i,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.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 r=[];i.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let l=f(a);l?(l&&!Array.isArray(l)&&typeof l=="object"&&(l=f(l)||""),Array.isArray(l)?r=r.concat(l):r.push(`${l}`)):r.push(`${a}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(a=>f(a)).filter(a=>a!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=R(i),i.operations)for(let p of i.operations)await z(p,this.operationStringConvert?s=>this.operationStringConvert(s,e):void 0);let r=this.getChoices(i.choices),a=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(r){let p=r.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)),a?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!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{G as LabelJson};
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var ae=Object.create;var M=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var j=(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 K=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of le(i))!ce.call(t,o)&&o!==e&&M(t,o,{get:()=>i[o],enumerable:!(r=se(i,o))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?ae(fe(t)):{},ue(M(e,"default",{value:t,enumerable:!0}),t));var X=K((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(I,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof j=="function")try{r=j("crypto");}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function n(){}return function(a){var u;return n.prototype=a,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var a=s(this);return n&&a.mixIn(n),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var a in n)n.hasOwnProperty(a)&&(this[a]=n[a]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,a){n=this.words=n||[],a!=e?this.sigBytes=a:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var a=this.words,u=n.words,m=this.sigBytes,T=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<T;N++){var H=u[N>>>2]>>>24-N%4*8&255;a[m+N>>>2]|=H<<24-(m+N)%4*8;}else for(var S=0;S<T;S+=4)a[m+S>>>2]=u[S>>>2];return this.sigBytes+=T,this},clamp:function(){var n=this.words,a=this.sigBytes;n[a>>>2]&=4294967295<<32-a%4*8,n.length=i.ceil(a/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var a=[],u=0;u<n;u+=4)a.push(o());return new p.init(a,n)}}),l=c.enc={},g=l.Hex={stringify:function(n){for(var a=n.words,u=n.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var a=n.length,u=[],m=0;m<a;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,a/2)}},y=l.Latin1={stringify:function(n){for(var a=n.words,u=n.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var a=n.length,u=[],m=0;m<a;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,a)}},b=l.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=b.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var a,u=this._data,m=u.words,T=u.sigBytes,N=this.blockSize,H=N*4,S=T/H;n?S=i.ceil(S):S=i.max((S|0)-this._minBufferSize,0);var k=S*N,z=i.min(k*4,T);if(k){for(var F=0;F<k;F+=N)this._doProcessBlock(m,F);a=m.splice(0,k),u.sigBytes-=z;}return new p.init(a,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 a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(n){return function(a,u){return new n.init(u).finalize(a)}},_createHmacHelper:function(n){return function(a,u){return new V.HMAC.init(n,u).finalize(a)}}});var V=c.algo={};return c}(Math);return t});});var Y=K((D,q)=>{(function(t,i){typeof D=="object"?q.exports=D=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(D,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,o=e.Hasher,s=i.algo,c=[],h=s.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var l=this._hash.words,g=l[0],y=l[1],b=l[2],x=l[3],C=l[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 a=(g<<5|g>>>27)+C+c[V];V<20?a+=(y&b|~y&x)+1518500249:V<40?a+=(y^b^x)+1859775393:V<60?a+=(y&b|y&x|b&x)-1894007588:a+=(y^b^x)-899497514,C=x,x=b,b=y<<30|y>>>2,y=g,g=a;}l[0]=l[0]+g|0,l[1]=l[1]+y|0,l[2]=l[2]+b|0,l[3]=l[3]+x|0,l[4]=l[4]+C|0;},_doFinalize:function(){var d=this._data,p=d.words,l=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(l/4294967296),p[(g+64>>>9<<4)+15]=l,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=o.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=o._createHelper(h),i.HmacSHA1=o._createHmacHelper(h);}(),t.SHA1});});var oe=pe(Y());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,r){let o=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(s=>{i[s]===void 0&&(o==="empty_string"?i[s]="":o==="copy_key"&&(i[s]=s));});}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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(o=>{if(o.choices){let s=[];Array.isArray(o.choices)?s=[o.choices]:s=t.getConditionalsThenElse(o.choices),s.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(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,r):t.getConditionalsThenElse(y).forEach(b=>{Array.isArray(b)?b.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof b=="string"&&t.addKey(e,b,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(o.dialogue){let s=[];Array.isArray(o.dialogue)?s=[o.dialogue]:s=t.getConditionalsThenElse(o.dialogue),s.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(l=>{typeof l=="string"?t.addKey(e,l,r):t.getConditionalsThenElse(l).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}o.conditionalStep&&t.getConditionalsThenElse(o.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var R=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let o=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>e.length-1&&(o=o%e.length),f(e[o]);case"sequential":let s,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(s=f(e[e.length-1])),c>e.length-1?s: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 G(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 G(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(s=>{let c=f(s);e.push(c);});else {let s=f(o);e.push(s);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return R.t(r).join("");if(typeof r[0]=="object"){let o=r,s,c=o.map((n,a)=>{n=G(n);let u=f(n.dialogue)||"";return a===0?(s=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),s===!1&&(u=`
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var ae=Object.create;var M=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var j=(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 K=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var ue=(t,i,e,r)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of le(i))!ce.call(t,o)&&o!==e&&M(t,o,{get:()=>i[o],enumerable:!(r=se(i,o))||r.enumerable});return t};var pe=(t,i,e)=>(e=t!=null?ae(fe(t)):{},ue(M(e,"default",{value:t,enumerable:!0}),t));var X=K((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(I,function(){var t=t||function(i,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof j=="function")try{r=j("crypto");}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function n(){}return function(a){var u;return n.prototype=a,u=new n,n.prototype=null,u}}(),c={},h=c.lib={},d=h.Base=function(){return {extend:function(n){var a=s(this);return n&&a.mixIn(n),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var a in n)n.hasOwnProperty(a)&&(this[a]=n[a]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=h.WordArray=d.extend({init:function(n,a){n=this.words=n||[],a!=e?this.sigBytes=a:this.sigBytes=n.length*4;},toString:function(n){return (n||g).stringify(this)},concat:function(n){var a=this.words,u=n.words,m=this.sigBytes,T=n.sigBytes;if(this.clamp(),m%4)for(var N=0;N<T;N++){var H=u[N>>>2]>>>24-N%4*8&255;a[m+N>>>2]|=H<<24-(m+N)%4*8;}else for(var S=0;S<T;S+=4)a[m+S>>>2]=u[S>>>2];return this.sigBytes+=T,this},clamp:function(){var n=this.words,a=this.sigBytes;n[a>>>2]&=4294967295<<32-a%4*8,n.length=i.ceil(a/4);},clone:function(){var n=d.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var a=[],u=0;u<n;u+=4)a.push(o());return new p.init(a,n)}}),l=c.enc={},g=l.Hex={stringify:function(n){for(var a=n.words,u=n.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push((N>>>4).toString(16)),m.push((N&15).toString(16));}return m.join("")},parse:function(n){for(var a=n.length,u=[],m=0;m<a;m+=2)u[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new p.init(u,a/2)}},y=l.Latin1={stringify:function(n){for(var a=n.words,u=n.sigBytes,m=[],T=0;T<u;T++){var N=a[T>>>2]>>>24-T%4*8&255;m.push(String.fromCharCode(N));}return m.join("")},parse:function(n){for(var a=n.length,u=[],m=0;m<a;m++)u[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new p.init(u,a)}},b=l.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=b.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var a,u=this._data,m=u.words,T=u.sigBytes,N=this.blockSize,H=N*4,S=T/H;n?S=i.ceil(S):S=i.max((S|0)-this._minBufferSize,0);var k=S*N,z=i.min(k*4,T);if(k){for(var F=0;F<k;F+=N)this._doProcessBlock(m,F);a=m.splice(0,k),u.sigBytes-=z;}return new p.init(a,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 a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(n){return function(a,u){return new n.init(u).finalize(a)}},_createHmacHelper:function(n){return function(a,u){return new V.HMAC.init(n,u).finalize(a)}}});var V=c.algo={};return c}(Math);return t});});var Y=K((D,q)=>{(function(t,i){typeof D=="object"?q.exports=D=i(X()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(D,function(t){return function(){var i=t,e=i.lib,r=e.WordArray,o=e.Hasher,s=i.algo,c=[],h=s.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(d,p){for(var l=this._hash.words,g=l[0],y=l[1],b=l[2],x=l[3],C=l[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 a=(g<<5|g>>>27)+C+c[V];V<20?a+=(y&b|~y&x)+1518500249:V<40?a+=(y^b^x)+1859775393:V<60?a+=(y&b|y&x|b&x)-1894007588:a+=(y^b^x)-899497514,C=x,x=b,b=y<<30|y>>>2,y=g,g=a;}l[0]=l[0]+g|0,l[1]=l[1]+y|0,l[2]=l[2]+b|0,l[3]=l[3]+x|0,l[4]=l[4]+C|0;},_doFinalize:function(){var d=this._data,p=d.words,l=this._nDataBytes*8,g=d.sigBytes*8;return p[g>>>5]|=128<<24-g%32,p[(g+64>>>9<<4)+14]=Math.floor(l/4294967296),p[(g+64>>>9<<4)+15]=l,d.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var d=o.clone.call(this);return d._hash=this._hash.clone(),d}});i.SHA1=o._createHelper(h),i.HmacSHA1=o._createHmacHelper(h);}(),t.SHA1});});var oe=pe(Y());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,r){let o=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(s=>{i[s]===void 0&&(o==="empty_string"?i[s]="":o==="copy_key"&&(i[s]=s));});}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(r=>{t.getConditionalsThenElse(r,e);});else if(i.elements.type==="ifelse"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else if(i.elements.type==="stepswitch"){let r=[];t.getConditionalsThenElse(i.elements,r),r.forEach(o=>{e.push(...o);});}else t.getConditionalsThenElse(i.elements,e);}else i.type==="resulttocombine"?(i.firstItem&&t.getConditionalsThenElse(i.firstItem,e),i.secondConditionalItem&&i.secondConditionalItem.forEach(r=>{t.getConditionalsThenElse(r,e);})):e.push(i);else i&&e.push(i);return e}static generateJsonTranslation(i,e={},r={}){return i.forEach(o=>{if(o.choices){let s=[];Array.isArray(o.choices)?s=[o.choices]:s=t.getConditionalsThenElse(o.choices),s.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(l=>t.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?t.addKey(e,y,r):t.getConditionalsThenElse(y).forEach(b=>{Array.isArray(b)?b.forEach(x=>{typeof x=="string"&&t.addKey(e,x,r);}):typeof b=="string"&&t.addKey(e,b,r);});}):typeof g=="string"&&t.addKey(e,g,r);});});}}));}if(o.dialogue){let s=[];Array.isArray(o.dialogue)?s=[o.dialogue]:s=t.getConditionalsThenElse(o.dialogue),s.forEach(c=>{typeof c=="string"?t.addKey(e,c,r):"text"in c&&Array.isArray(c.text)&&c.text.forEach(h=>{typeof h=="string"?t.addKey(e,h,r):t.getConditionalsThenElse(h).forEach(p=>{typeof p=="string"?t.addKey(e,p,r):Array.isArray(p)&&p.forEach(l=>{typeof l=="string"?t.addKey(e,l,r):t.getConditionalsThenElse(l).forEach(g=>{typeof g=="string"&&t.addKey(e,g,r);});});});});});}o.conditionalStep&&t.getConditionalsThenElse(o.conditionalStep).forEach(c=>{Array.isArray(c)?t.generateJsonTranslation(c,e,r):t.generateJsonTranslation([c],e,r);});}),e}};var R=P;function ge(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function he(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 e=f(t.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let r=ge(0,e.length-1);return f(e[r]);case"loop":let o=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return o>e.length-1&&(o=o%e.length),f(e[o]);case"sequential":let s,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(s=f(e[e.length-1])),c>e.length-1?s: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 G(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?.operations===void 0&&delete i?.operations,i){let e={...t,conditionalStep:void 0,...i};return G(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 ye(t){let i=t.firstItem,e=[];t.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(s=>{let c=f(s);e.push(c);});else {let s=f(o);e.push(s);}});let r=i?[i,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return R.t(r).join("");if(typeof r[0]=="object"){let o=r,s,c=o.map((n,a)=>{n=G(n);let u=f(n.dialogue)||"";return a===0?(s=f(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),s===!1&&(u=`
2
2
 
3
- `+u),s=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 a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let u;return Array.isArray(a)?u=a.map(m=>{let T=f(m);return R.t(`${T}`)}).join(""):u=f(a)||"",R.t(u)}).join(""),l=o.find(n=>n.end),g=o.find(n=>n.choices),y=!1,b=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=o[o.length-1].glueEnabled,b=o.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let x=o.find(n=>n.labelToOpen),C=[];return o.forEach(n=>{n.operation&&C.forEach(a=>{C.push(a);});}),{dialogue:d?{character:d,text:p}:p,end:l?.end,choices:g?.choices,glueEnabled:y,goNextStep:b,labelToOpen:x?.labelToOpen,operation:C}}}function me(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 be(t)}return !!t}function xe(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 be(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 Z(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 r=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return Te(i);case"compare":case"valueCondition":case"union":return me(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 L(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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 o=pixiVn.canvas.find(e.alias);o?o.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let s=pixiVn.canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(s=>{if(typeof s=="string")r+=s;else {let c=f(s);r+=`${c}`;}});let o=await i(r);o&&await L(o,i);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var _=class extends pixiVn.LabelAbstract{constructor(i,e,r,o={}){super(i,r),this._steps=e,this.operationStringConvert=o.operationStringConvert,this.skipEmptyDialogs=o.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, oe.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let r=[];i.forEach(o=>{if(typeof o=="string")r.push(o);else if(o&&typeof o=="object"){let s=f(o);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=f(s)||""),Array.isArray(s)?r=r.concat(s):r.push(`${s}`)):r.push(`${o}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(o=>f(o)).filter(o=>o!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=G(i),i.operation)for(let p of i.operation)await L(p,this.operationStringConvert?l=>this.operationStringConvert(l,e):void 0);let r=this.getChoices(i.choices),o=f(i.glueEnabled),s=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let l=f(p);l&&c.push(l);}));let h=f(i.goNextStep),d=f(i.end);if(r){let p=r.map(l=>{let g="";if(Array.isArray(l.text)){let y=[];l.text.forEach(b=>{if(typeof b=="string")y.push(P.t(b));else if(b&&typeof b=="object"){let x=f(b);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 l.text=="string"&&(g=P.t(l.text));return new pixiVn.ChoiceMenuOption(g,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});pixiVn.narration.choiceMenuOptions=p;}else pixiVn.narration.choiceMenuOptions=void 0;s!==void 0&&(pixiVn.narration.dialogue=s,this.skipEmptyDialogs&&typeof s=="string"&&(s===""||RegExp(/^\s+$/).test(s))&&(h=!0)),o?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):o===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let l=p.label;typeof l=="object"&&(l=f(l)||"");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(l,e)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(l,e));}d==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):d==="label_end"&&pixiVn.narration.closeCurrentLabel(),h&&await pixiVn.narration.goNext(e);}}};function ri(t,i={}){let e=i?.operationStringConvert;try{typeof t=="string"&&(t=JSON.parse(t));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);return}if(typeof t!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.initialOperations){for(let r of t.initialOperations)L(r,e?o=>e(o,{}):void 0);pixiVn.StorageManagerStatic.saveStorageAsBasicStorage();}if(t.labels){let r=t.labels;for(let o in r)try{let s=r[o],c=new _(o,s,void 0,i);pixiVn.saveLabel(c);}catch(s){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${o}`,s);}}}exports.importPixiVNJson=ri;
3
+ `+u),s=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 a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let u;return Array.isArray(a)?u=a.map(m=>{let T=f(m);return R.t(`${T}`)}).join(""):u=f(a)||"",R.t(u)}).join(""),l=o.find(n=>n.end),g=o.find(n=>n.choices),y=!1,b=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),y=o[o.length-1].glueEnabled,b=o.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let x=o.find(n=>n.labelToOpen),C=[];return o.forEach(n=>{n.operations&&C.forEach(a=>{C.push(a);});}),{dialogue:d?{character:d,text:p}:p,end:l?.end,choices:g?.choices,glueEnabled:y,goNextStep:b,labelToOpen:x?.labelToOpen,operations:C}}}function me(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 be(t)}return !!t}function xe(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 be(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 Z(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 r=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=t.key&&(r[t.key]=e),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,r);break}}function f(t){let i=he(t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return xe(i);case"arithmetic":case"arithmeticsingle":return Te(i);case"compare":case"valueCondition":case"union":return me(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 L(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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.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 o=pixiVn.canvas.find(e.alias);o?o.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let s=pixiVn.canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":Z(e);break;case"oprationtoconvert":if(i){let r="";e.values.forEach(s=>{if(typeof s=="string")r+=s;else {let c=f(s);r+=`${c}`;}});let o=await i(r);o&&await L(o,i);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var _=class extends pixiVn.LabelAbstract{constructor(i,e,r,o={}){super(i,r),this._steps=e,this.operationStringConvert=o.operationStringConvert,this.skipEmptyDialogs=o.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, oe.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(i){let e="";if(Array.isArray(i)){let r=[];i.forEach(o=>{if(typeof o=="string")r.push(o);else if(o&&typeof o=="object"){let s=f(o);s?(s&&!Array.isArray(s)&&typeof s=="object"&&(s=f(s)||""),Array.isArray(s)?r=r.concat(s):r.push(`${s}`)):r.push(`${o}`);}}),e=r;}else {let r=f(i)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=f(r)||""),e=r;}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(o=>f(o)).filter(o=>o!==void 0)}stepConverter(i){return async e=>{if(typeof i=="function"&&(i=i()),i=G(i),i.operations)for(let p of i.operations)await L(p,this.operationStringConvert?l=>this.operationStringConvert(l,e):void 0);let r=this.getChoices(i.choices),o=f(i.glueEnabled),s=this.getDialogue(i.dialogue),c=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(p=>{let l=f(p);l&&c.push(l);}));let h=f(i.goNextStep),d=f(i.end);if(r){let p=r.map(l=>{let g="";if(Array.isArray(l.text)){let y=[];l.text.forEach(b=>{if(typeof b=="string")y.push(P.t(b));else if(b&&typeof b=="object"){let x=f(b);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 l.text=="string"&&(g=P.t(l.text));return new pixiVn.ChoiceMenuOption(g,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});pixiVn.narration.choiceMenuOptions=p;}else pixiVn.narration.choiceMenuOptions=void 0;s!==void 0&&(pixiVn.narration.dialogue=s,this.skipEmptyDialogs&&typeof s=="string"&&(s===""||RegExp(/^\s+$/).test(s))&&(h=!0)),o?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):o===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);for(let p of c){let l=p.label;typeof l=="object"&&(l=f(l)||"");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(l,e)):(pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length}`,g),await pixiVn.narration.callLabel(l,e));}d==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):d==="label_end"&&pixiVn.narration.closeCurrentLabel(),h&&await pixiVn.narration.goNext(e);}}};function ri(t,i={}){let e=i?.operationStringConvert;try{typeof t=="string"&&(t=JSON.parse(t));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);return}if(typeof t!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.initialOperations){for(let r of t.initialOperations)L(r,e?o=>e(o,{}):void 0);pixiVn.StorageManagerStatic.saveStorageAsBasicStorage();}if(t.labels){let r=t.labels;for(let o in r)try{let s=r[o],c=new _(o,s,void 0,i);pixiVn.saveLabel(c);}catch(s){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${o}`,s);}}}exports.importPixiVNJson=ri;