@drincs/pixi-vn-json 1.5.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import {storage,narration,LabelAbstract,ChoiceMenuOption,SYSTEM_RESERVED_STORAGE_KEYS,RegisteredLabels,NarrationManagerStatic,createExportableElement,Assets,shakeEffect,ZoomTicker,canvas,RotateTicker,MoveTicker,FadeAlphaTicker,ImageContainer,VideoSprite,ImageSprite,sound,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';var se=Object.create;var Z=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,ce=Object.prototype.hasOwnProperty;var K=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var Q=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var pe=(i,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of le(t))!ce.call(i,a)&&a!==e&&Z(i,a,{get:()=>t[a],enumerable:!(n=oe(t,a))||n.enumerable});return i};var ue=(i,t,e)=>(e=i!=null?se(fe(i)):{},pe(Z(e,"default",{value:i,enumerable:true}),i));var te=Q((D,ee)=>{(function(i,t){typeof D=="object"?ee.exports=D=t():typeof define=="function"&&define.amd?define([],t):i.CryptoJS=t();})(D,function(){var i=i||function(t,e){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof K=="function")try{n=K("crypto");}catch{}var a=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function r(){}return function(s){var g;return r.prototype=s,g=new r,r.prototype=null,g}}(),f={},p=f.lib={},u=p.Base=function(){return {extend:function(r){var s=o(this);return r&&s.mixIn(r),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments);}),s.init.prototype=s,s.$super=this,s},create:function(){var r=this.extend();return r.init.apply(r,arguments),r},init:function(){},mixIn:function(r){for(var s in r)r.hasOwnProperty(s)&&(this[s]=r[s]);r.hasOwnProperty("toString")&&(this.toString=r.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),h=p.WordArray=u.extend({init:function(r,s){r=this.words=r||[],s!=e?this.sigBytes=s:this.sigBytes=r.length*4;},toString:function(r){return (r||d).stringify(this)},concat:function(r){var s=this.words,g=r.words,y=this.sigBytes,V=r.sigBytes;if(this.clamp(),y%4)for(var P=0;P<V;P++){var z=g[P>>>2]>>>24-P%4*8&255;s[y+P>>>2]|=z<<24-(y+P)%4*8;}else for(var C=0;C<V;C+=4)s[y+C>>>2]=g[C>>>2];return this.sigBytes+=V,this},clamp:function(){var r=this.words,s=this.sigBytes;r[s>>>2]&=4294967295<<32-s%4*8,r.length=t.ceil(s/4);},clone:function(){var r=u.clone.call(this);return r.words=this.words.slice(0),r},random:function(r){for(var s=[],g=0;g<r;g+=4)s.push(a());return new h.init(s,r)}}),c=f.enc={},d=c.Hex={stringify:function(r){for(var s=r.words,g=r.sigBytes,y=[],V=0;V<g;V++){var P=s[V>>>2]>>>24-V%4*8&255;y.push((P>>>4).toString(16)),y.push((P&15).toString(16));}return y.join("")},parse:function(r){for(var s=r.length,g=[],y=0;y<s;y+=2)g[y>>>3]|=parseInt(r.substr(y,2),16)<<24-y%8*4;return new h.init(g,s/2)}},m=c.Latin1={stringify:function(r){for(var s=r.words,g=r.sigBytes,y=[],V=0;V<g;V++){var P=s[V>>>2]>>>24-V%4*8&255;y.push(String.fromCharCode(P));}return y.join("")},parse:function(r){for(var s=r.length,g=[],y=0;y<s;y++)g[y>>>2]|=(r.charCodeAt(y)&255)<<24-y%4*8;return new h.init(g,s)}},x=c.Utf8={stringify:function(r){try{return decodeURIComponent(escape(m.stringify(r)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(r){return m.parse(unescape(encodeURIComponent(r)))}},T=p.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(r){typeof r=="string"&&(r=x.parse(r)),this._data.concat(r),this._nDataBytes+=r.sigBytes;},_process:function(r){var s,g=this._data,y=g.words,V=g.sigBytes,P=this.blockSize,z=P*4,C=V/z;r?C=t.ceil(C):C=t.max((C|0)-this._minBufferSize,0);var I=C*P,q=t.min(I*4,V);if(I){for(var W=0;W<I;W+=P)this._doProcessBlock(y,W);s=y.splice(0,I),g.sigBytes-=q;}return new h.init(s,q)},clone:function(){var r=u.clone.call(this);return r._data=this._data.clone(),r},_minBufferSize:0});p.Hasher=T.extend({cfg:u.extend(),init:function(r){this.cfg=this.cfg.extend(r),this.reset();},reset:function(){T.reset.call(this),this._doReset();},update:function(r){return this._append(r),this._process(),this},finalize:function(r){r&&this._append(r);var s=this._doFinalize();return s},blockSize:512/32,_createHelper:function(r){return function(s,g){return new r.init(g).finalize(s)}},_createHmacHelper:function(r){return function(s,g){return new N.HMAC.init(r,g).finalize(s)}}});var N=f.algo={};return f}(Math);return i});});var ne=Q((R,ie)=>{(function(i,t){typeof R=="object"?ie.exports=R=t(te()):typeof define=="function"&&define.amd?define(["./core"],t):t(i.CryptoJS);})(R,function(i){return function(){var t=i,e=t.lib,n=e.WordArray,a=e.Hasher,o=t.algo,f=[],p=o.SHA1=a.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,h){for(var c=this._hash.words,d=c[0],m=c[1],x=c[2],T=c[3],b=c[4],N=0;N<80;N++){if(N<16)f[N]=u[h+N]|0;else {var r=f[N-3]^f[N-8]^f[N-14]^f[N-16];f[N]=r<<1|r>>>31;}var s=(d<<5|d>>>27)+b+f[N];N<20?s+=(m&x|~m&T)+1518500249:N<40?s+=(m^x^T)+1859775393:N<60?s+=(m&x|m&T|x&T)-1894007588:s+=(m^x^T)-899497514,b=T,T=x,x=m<<30|m>>>2,m=d,d=s;}c[0]=c[0]+d|0,c[1]=c[1]+m|0,c[2]=c[2]+x|0,c[3]=c[3]+T|0,c[4]=c[4]+b|0;},_doFinalize:function(){var u=this._data,h=u.words,c=this._nDataBytes*8,d=u.sigBytes*8;return h[d>>>5]|=128<<24-d%32,h[(d+64>>>9<<4)+14]=Math.floor(c/4294967296),h[(d+64>>>9<<4)+15]=c,u.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var u=a.clone.call(this);return u._hash=this._hash.clone(),u}});t.SHA1=a._createHelper(p),t.HmacSHA1=a._createHmacHelper(p);}(),i.SHA1});});var ae=ue(ne());var E="___param___";var J=class i{static _beforeToTranslate=void 0;static _translate=t=>t;static _afterToTranslate=void 0;static t(t){return Array.isArray(t)?t.map(e=>i.translate(`${e}`)):i.translate(`${t}`)}static set beforeToTranslate(t){i._beforeToTranslate=t;}static set translate(t){i._translate=t;}static get translate(){return t=>{let e=t;return i._beforeToTranslate&&(e=i._beforeToTranslate(e)),e=i._translate(e),i._afterToTranslate&&(e=i._afterToTranslate(e)),e}}static set afterToTranslate(t){i._afterToTranslate=t;}static addKey(t,e,n){let a=n.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(o=>{t[o]===void 0&&(a==="empty_string"?t[o]="":a==="copy_key"&&(i._beforeToTranslate?t[o]=i._beforeToTranslate(o):t[o]=o));});}static getConditionalsThenElse(t,e=[]){if(typeof t=="object"&&t&&"type"in t)if(t.type==="ifelse")t.then&&i.getConditionalsThenElse(t.then,e),t.else&&i.getConditionalsThenElse(t.else,e);else if(t.type==="stepswitch"){if(t.elements)if(Array.isArray(t.elements))t.elements.forEach(n=>{i.getConditionalsThenElse(n,e);});else if(t.elements.type==="ifelse"){let n=[];i.getConditionalsThenElse(t.elements,n),n.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let n=[];i.getConditionalsThenElse(t.elements,n),n.forEach(a=>{e.push(...a);});}else i.getConditionalsThenElse(t.elements,e);}else t.type==="resulttocombine"?(t.firstItem&&i.getConditionalsThenElse(t.firstItem,e),t.secondConditionalItem&&t.secondConditionalItem.forEach(n=>{i.getConditionalsThenElse(n,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},n={}){return t.forEach(a=>{if(a.choices){let o=[];Array.isArray(a.choices)?o=[a.choices]:o=i.getConditionalsThenElse(a.choices),o.forEach(f=>f.forEach(p=>{if("type"in p){let u=[];p.type==="ifelse"||p.type==="stepswitch"?i.getConditionalsThenElse(p,u):u=[p],u.map(c=>i.getConditionalsThenElse(c.text)).forEach(c=>{Array.isArray(c)&&c.forEach(d=>{Array.isArray(d)?d.forEach(m=>{typeof m=="string"?i.addKey(e,m,n):i.getConditionalsThenElse(m).forEach(x=>{Array.isArray(x)?x.forEach(T=>{typeof T=="string"&&i.addKey(e,T,n);}):typeof x=="string"&&i.addKey(e,x,n);});}):typeof d=="string"&&i.addKey(e,d,n);});});}}));}if(a.dialogue){let o=[];Array.isArray(a.dialogue)?o=[a.dialogue]:o=i.getConditionalsThenElse(a.dialogue),o.forEach(f=>{typeof f=="string"?i.addKey(e,f,n):"text"in f&&Array.isArray(f.text)&&f.text.forEach(p=>{typeof p=="string"?i.addKey(e,p,n):i.getConditionalsThenElse(p).forEach(h=>{typeof h=="string"?i.addKey(e,h,n):Array.isArray(h)&&h.forEach(c=>{typeof c=="string"?i.addKey(e,c,n):i.getConditionalsThenElse(c).forEach(d=>{typeof d=="string"&&i.addKey(e,d,n);});});});});});}a.conditionalStep&&i.getConditionalsThenElse(a.conditionalStep).forEach(f=>{Array.isArray(f)?i.generateJsonTranslation(f,e,n):i.generateJsonTranslation([f],e,n);});}),e}};var B=J;function ge(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function he(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return ye(i);case "ifelse":return l(i.condition)?l(i.then):l(i.else);case "stepswitch":let e=l(i.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let n=ge(0,e.length-1);return l(e[n]);case "loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),l(e[a]);case "sequential":let o,f=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(o=l(e[e.length-1])),f>e.length-1?o:l(e[f]);case "sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(p==null&&i.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!u||!u?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let h=u.usedRandomNumbers[`0-${e.length-1}`];return l(e[h[h.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return l(e[p])}}return i}function O(i){if(i.conditionalStep){let t=createExportableElement(l(i.conditionalStep));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let e={...i,conditionalStep:void 0,...t};return O(e)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return i}function ye(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(o=>{let f=l(o);e.push(f);});else {let o=l(a);e.push(o);}});let n=t?[t,...e]:e;if(n.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof n[0]=="string")return B.t(n).join("");if(typeof n[0]=="object"){let a=n,o,f=a.map((r,s)=>{r=O(r);let g=l(r.dialogue)||"";return s===0?(o=l(r.glueEnabled)||false,g):(typeof g=="object"&&"text"in g&&(g=g.character+": "+g.text),o===false&&(g=`
1
+ import {storage,narration,LabelAbstract,ChoiceMenuOption,SYSTEM_RESERVED_STORAGE_KEYS,RegisteredLabels,NarrationManagerStatic,createExportableElement,Assets,shakeEffect,ZoomTicker,canvas,RotateTicker,MoveTicker,FadeAlphaTicker,ImageContainer,VideoSprite,ImageSprite,sound,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';var oe=Object.create;var Q=Object.defineProperty;var le=Object.getOwnPropertyDescriptor;var fe=Object.getOwnPropertyNames;var ce=Object.getPrototypeOf,pe=Object.prototype.hasOwnProperty;var K=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var ee=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var ue=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of fe(t))!pe.call(i,a)&&a!==e&&Q(i,a,{get:()=>t[a],enumerable:!(r=le(t,a))||r.enumerable});return i};var de=(i,t,e)=>(e=i!=null?oe(ce(i)):{},ue(Q(e,"default",{value:i,enumerable:true}),i));var ie=ee((R,te)=>{(function(i,t){typeof R=="object"?te.exports=R=t():typeof define=="function"&&define.amd?define([],t):i.CryptoJS=t();})(R,function(){var i=i||function(t,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 K=="function")try{r=K("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.")},o=Object.create||function(){function n(){}return function(s){var h;return n.prototype=s,h=new n,n.prototype=null,h}}(),f={},c=f.lib={},u=c.Base=function(){return {extend:function(n){var s=o(this);return n&&s.mixIn(n),(!s.hasOwnProperty("init")||this.init===s.init)&&(s.init=function(){s.$super.init.apply(this,arguments);}),s.init.prototype=s,s.$super=this,s},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var s in n)n.hasOwnProperty(s)&&(this[s]=n[s]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),g=c.WordArray=u.extend({init:function(n,s){n=this.words=n||[],s!=e?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||d).stringify(this)},concat:function(n){var s=this.words,h=n.words,m=this.sigBytes,N=n.sigBytes;if(this.clamp(),m%4)for(var J=0;J<N;J++){var j=h[J>>>2]>>>24-J%4*8&255;s[m+J>>>2]|=j<<24-(m+J)%4*8;}else for(var E=0;E<N;E+=4)s[m+E>>>2]=h[E>>>2];return this.sigBytes+=N,this},clamp:function(){var n=this.words,s=this.sigBytes;n[s>>>2]&=4294967295<<32-s%4*8,n.length=t.ceil(s/4);},clone:function(){var n=u.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],h=0;h<n;h+=4)s.push(a());return new g.init(s,n)}}),l=f.enc={},d=l.Hex={stringify:function(n){for(var s=n.words,h=n.sigBytes,m=[],N=0;N<h;N++){var J=s[N>>>2]>>>24-N%4*8&255;m.push((J>>>4).toString(16)),m.push((J&15).toString(16));}return m.join("")},parse:function(n){for(var s=n.length,h=[],m=0;m<s;m+=2)h[m>>>3]|=parseInt(n.substr(m,2),16)<<24-m%8*4;return new g.init(h,s/2)}},y=l.Latin1={stringify:function(n){for(var s=n.words,h=n.sigBytes,m=[],N=0;N<h;N++){var J=s[N>>>2]>>>24-N%4*8&255;m.push(String.fromCharCode(J));}return m.join("")},parse:function(n){for(var s=n.length,h=[],m=0;m<s;m++)h[m>>>2]|=(n.charCodeAt(m)&255)<<24-m%4*8;return new g.init(h,s)}},x=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)))}},T=c.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new g.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=x.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var s,h=this._data,m=h.words,N=h.sigBytes,J=this.blockSize,j=J*4,E=N/j;n?E=t.ceil(E):E=t.max((E|0)-this._minBufferSize,0);var D=E*J,Z=t.min(D*4,N);if(D){for(var W=0;W<D;W+=J)this._doProcessBlock(m,W);s=m.splice(0,D),h.sigBytes-=Z;}return new g.init(s,Z)},clone:function(){var n=u.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});c.Hasher=T.extend({cfg:u.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){T.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var s=this._doFinalize();return s},blockSize:512/32,_createHelper:function(n){return function(s,h){return new n.init(h).finalize(s)}},_createHmacHelper:function(n){return function(s,h){return new P.HMAC.init(n,h).finalize(s)}}});var P=f.algo={};return f}(Math);return i});});var re=ee((B,ne)=>{(function(i,t){typeof B=="object"?ne.exports=B=t(ie()):typeof define=="function"&&define.amd?define(["./core"],t):t(i.CryptoJS);})(B,function(i){return function(){var t=i,e=t.lib,r=e.WordArray,a=e.Hasher,o=t.algo,f=[],c=o.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(u,g){for(var l=this._hash.words,d=l[0],y=l[1],x=l[2],T=l[3],V=l[4],P=0;P<80;P++){if(P<16)f[P]=u[g+P]|0;else {var n=f[P-3]^f[P-8]^f[P-14]^f[P-16];f[P]=n<<1|n>>>31;}var s=(d<<5|d>>>27)+V+f[P];P<20?s+=(y&x|~y&T)+1518500249:P<40?s+=(y^x^T)+1859775393:P<60?s+=(y&x|y&T|x&T)-1894007588:s+=(y^x^T)-899497514,V=T,T=x,x=y<<30|y>>>2,y=d,d=s;}l[0]=l[0]+d|0,l[1]=l[1]+y|0,l[2]=l[2]+x|0,l[3]=l[3]+T|0,l[4]=l[4]+V|0;},_doFinalize:function(){var u=this._data,g=u.words,l=this._nDataBytes*8,d=u.sigBytes*8;return g[d>>>5]|=128<<24-d%32,g[(d+64>>>9<<4)+14]=Math.floor(l/4294967296),g[(d+64>>>9<<4)+15]=l,u.sigBytes=g.length*4,this._process(),this._hash},clone:function(){var u=a.clone.call(this);return u._hash=this._hash.clone(),u}});t.SHA1=a._createHelper(c),t.HmacSHA1=a._createHmacHelper(c);}(),i.SHA1});});var se=de(re());var k="___param___";var S=class i{static _beforeToTranslate=void 0;static _translate=t=>t;static _afterToTranslate=void 0;static t(t){return Array.isArray(t)?t.map(e=>i.translate(`${e}`)):i.translate(`${t}`)}static set beforeToTranslate(t){i._beforeToTranslate=t;}static set translate(t){i._translate=t;}static get translate(){return t=>{let e=t;return i._beforeToTranslate&&(e=i._beforeToTranslate(e)),e=i._translate(e),i._afterToTranslate&&(e=i._afterToTranslate(e)),e}}static set afterToTranslate(t){i._afterToTranslate=t;}static addKey(t,e,r){let a=r.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(o=>{t[o]===void 0&&(a==="empty_string"?t[o]="":a==="copy_key"&&(i._beforeToTranslate?t[o]=i._beforeToTranslate(o):t[o]=o));});}static getConditionalsThenElse(t,e=[]){if(typeof t=="object"&&t&&"type"in t)if(t.type==="ifelse")t.then&&i.getConditionalsThenElse(t.then,e),t.else&&i.getConditionalsThenElse(t.else,e);else if(t.type==="stepswitch"){if(t.elements)if(Array.isArray(t.elements))t.elements.forEach(r=>{i.getConditionalsThenElse(r,e);});else if(t.elements.type==="ifelse"){let r=[];i.getConditionalsThenElse(t.elements,r),r.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let r=[];i.getConditionalsThenElse(t.elements,r),r.forEach(a=>{e.push(...a);});}else i.getConditionalsThenElse(t.elements,e);}else t.type==="resulttocombine"?(t.firstItem&&i.getConditionalsThenElse(t.firstItem,e),t.secondConditionalItem&&t.secondConditionalItem.forEach(r=>{i.getConditionalsThenElse(r,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},r={}){return t.forEach(a=>{if(a.choices){let o=[];Array.isArray(a.choices)?o=[a.choices]:o=i.getConditionalsThenElse(a.choices),o.forEach(f=>f.forEach(c=>{if("type"in c){let u=[];c.type==="ifelse"||c.type==="stepswitch"?i.getConditionalsThenElse(c,u):u=[c],u.map(l=>i.getConditionalsThenElse(l.text)).forEach(l=>{Array.isArray(l)&&l.forEach(d=>{Array.isArray(d)?d.forEach(y=>{typeof y=="string"?i.addKey(e,y,r):i.getConditionalsThenElse(y).forEach(x=>{Array.isArray(x)?x.forEach(T=>{typeof T=="string"&&i.addKey(e,T,r);}):typeof x=="string"&&i.addKey(e,x,r);});}):typeof d=="string"&&i.addKey(e,d,r);});});}}));}if(a.dialogue){let o=[];Array.isArray(a.dialogue)?o=[a.dialogue]:o=i.getConditionalsThenElse(a.dialogue),o.forEach(f=>{typeof f=="string"?i.addKey(e,f,r):"text"in f&&Array.isArray(f.text)&&f.text.forEach(c=>{typeof c=="string"?i.addKey(e,c,r):i.getConditionalsThenElse(c).forEach(g=>{typeof g=="string"?i.addKey(e,g,r):Array.isArray(g)&&g.forEach(l=>{typeof l=="string"?i.addKey(e,l,r):i.getConditionalsThenElse(l).forEach(d=>{typeof d=="string"&&i.addKey(e,d,r);});});});});});}a.conditionalStep&&i.getConditionalsThenElse(a.conditionalStep).forEach(f=>{Array.isArray(f)?i.generateJsonTranslation(f,e,r):i.generateJsonTranslation([f],e,r);});}),e}};var $=S;var b;(a=>(a.log=(o,...f)=>console.log(`[Pixi\u2019VN Json] ${o}`,...f),a.warn=(o,...f)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...f),a.error=(o,...f)=>console.error(`[Pixi\u2019VN Json] ${o}`,...f),a.info=(o,...f)=>console.info(`[Pixi\u2019VN Json] ${o}`,...f)))(b||={});function he(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function ye(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return me(i);case "ifelse":return p(i.condition)?p(i.then):p(i.else);case "stepswitch":let e=p(i.elements)||[];if(e.length===0){b.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let r=he(0,e.length-1);return p(e[r]);case "loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),p(e[a]);case "sequential":let o,f=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(o=p(e[e.length-1])),f>e.length-1?o:p(e[f]);case "sequentialrandom":let c=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(c==null&&i.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!u||!u?.usedRandomNumbers){b.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let g=u.usedRandomNumbers[`0-${e.length-1}`];return p(e[g[g.length-1]])}if(c==null){b.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return p(e[c])}}return i}function _(i){if(i.conditionalStep){let t=createExportableElement(p(i.conditionalStep));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let e={...i,conditionalStep:void 0,...t};return _(e)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return i}function me(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(o=>{let f=p(o);e.push(f);});else {let o=p(a);e.push(o);}});let r=t?[t,...e]:e;if(r.length===0){b.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return $.t(r).join("");if(typeof r[0]=="object"){let a=r,o,f=a.map((n,s)=>{n=_(n);let h=p(n.dialogue)||"";return s===0?(o=p(n.glueEnabled)||false,h):(typeof h=="object"&&"text"in h&&(h=h.character+": "+h.text),o===false&&(h=`
2
2
 
3
- `+g),o=l(r.glueEnabled)||false,g)}),p=l(f[0]),u=typeof p=="object"&&"character"in p?p.character:void 0,h=f.map(r=>{let s;r&&typeof r=="object"&&"text"in r?s=r.text:s=r;let g;return Array.isArray(s)?g=s.map(y=>{let V=l(y);return B.t(`${V}`)}).join(""):g=l(s)||"",B.t(g)}).join(""),c=a.find(r=>r.end),d=a.find(r=>r.choices),m=false,x=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),m=a[a.length-1].glueEnabled,x=a.reverse().find(r=>!(r.operations&&(!r.dialogue||!r.choices)))?.goNextStep);let T=a.find(r=>r.labelToOpen),b=[];return a.forEach(r=>{r.operations&&b.forEach(s=>{b.push(s);});}),{dialogue:u?{character:u,text:h}:h,end:c?.end,choices:d?.choices,glueEnabled:m,goNextStep:x,labelToOpen:T?.labelToOpen,operations:b}}}function me(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let t=l(i.leftValue),e=l(i.rightValue);switch(i.operator){case "==":return t===e;case "!=":return t!==e;case "<":return t<e;case "<=":return t<=e;case ">":return t>e;case ">=":return t>=e;case "CONTAINS":return t.toString().includes(e.toString())}break;case "valueCondition":return !!l(i.value);case "union":return Te(i)}return !!i}function xe(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case "storage":case "tempstorage":return storage.getVariable(i.key);case "flagStorage":return storage.getFlag(i.key);case "label":return narration.getTimesLabelOpened(i.label);case "choice":return narration.getTimesChoiceMade(i.index);case "logic":return l(i.operation);case "params":let t=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return i}function Te(i){if(i.unionType==="not")return !l(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=l(i.conditions[e])||false,i.unionType==="and"){if(!t)return false}else if(t)return true;return t}function U(i){let t=l(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=l(t):e=t,i.storageType){case "flagStorage":storage.setFlag(i.key,i.value);break;case "storage":storage.setVariable(i.key,e);break;case "tempstorage":storage.setTempVariable(i.key,e);break;case "params":let n=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];n&&n.length-1>=i.key&&(n[i.key]=e),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,n);break}}function l(i){let t=he(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return xe(t);case "arithmetic":case "arithmeticsingle":return be(t);case "compare":case "valueCondition":case "union":return me(t)}return t}function be(i){let t=l(i.leftValue);switch(i.type){case "arithmetic":let e=l(i.rightValue);switch(i.operator){case "*":return t*e;case "/":return t/e;case "+":return t+e;case "-":return t-e;case "%":return t%e;case "POW":return Math.pow(t,e);case "RANDOM":return narration.getRandomNumber(t,e)}case "arithmeticsingle":switch(i.operator){case "INT":return parseInt(t);case "FLOOR":return Math.floor(t);case "FLOAT":return parseFloat(t)}break}}async function F(i){let t=l(i);if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}async function L(i,t){let e=l(i);if(e)switch(e.type){case "sound":switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(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 "assets":case "bundle":await F(e);break;case "image":switch(e.operationType){case "show":let p=new ImageSprite(e.props,e.url||e.alias);await X(p,e);break;case "edit":let u=canvas.find(e.alias);u?e.props&&await u.setMemory({...u.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case "remove":H(e);break}break;case "video":switch(e.operationType){case "show":let p=new VideoSprite(e.props,e.url||e.alias);await X(p,e);break;case "edit":let u=canvas.find(e.alias);u?e.props&&await u.setMemory({...u.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case "remove":H(e);break;case "pause":let h=canvas.find(e.alias);h?h.paused=true:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case "resume":let c=canvas.find(e.alias);c?c.paused=false:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let p=new ImageContainer(e.props,e.urls);await X(p,e);break;case "edit":let u=canvas.find(e.alias);u?e.props&&await u.setMemory({...u.memory,...e.props}):console.error(`[Pixi\u2019VN Json] ImageContainer with alias ${e.alias} not found.`);break;case "remove":H(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let p=canvas.find(e.alias);p?e.props&&(p.memory={...p.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Canvas Element with alias ${e.alias} not found.`);}catch(p){console.error(`[Pixi\u2019VN Json] There was an error while trying to edit the canvas element with alias ${e.alias}.`,p);}break;case "remove":H(e);break}break;case "value":U(e);break;case "operationtoconvert":if(t){let p="";e.values.forEach(h=>{if(typeof h=="string")p+=h;else {let c=l(h);p+=`${c}`;}});let u=await t(p);u&&await L(u,t);}break;case "input":switch(e.operationType){case "request":narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let n=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,n);break;case "move":let a=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "rotate":let o=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,o);break;case "zoom":let f=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,f);break;case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}async function X(i,t){if(t.transition)switch(t.transition.type){case "fade":await showWithFade(t.alias,i,t.transition.props,t.transition.priority);break;case "dissolve":await showWithDissolve(t.alias,i,t.transition.props,t.transition.priority);break;case "movein":case "moveout":await moveIn(t.alias,i,t.transition.props,t.transition.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,i,t.transition.props,t.transition.priority);break;case "pushin":case "pushout":await pushIn(t.alias,i,t.transition.props,t.transition.priority);break}else await i.load(),canvas.add(t.alias,i);}function H(i){if(i.transition)switch(i.transition.type){case "fade":removeWithFade(i.alias,i.transition.props,i.transition.priority);break;case "dissolve":removeWithDissolve(i.alias,i.transition.props,i.transition.priority);break;case "movein":case "moveout":moveOut(i.alias,i.transition.props,i.transition.priority);break;case "zoomin":case "zoomout":zoomOut(i.alias,i.transition.props,i.transition.priority);break;case "pushin":case "pushout":pushOut(i.alias,i.transition.props,i.transition.priority);break}else canvas.remove(i.alias);}var A=class extends LabelAbstract{constructor(t,e,n,a={}){n||(n={}),n.onLoadingLabel=async()=>{for(let o of e){let f;if(typeof o=="function"?f=o():f=o,f=O(f),f.operations){let p=f.operations.map(u=>F(u));await Promise.all(p);}}},super(t,n),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let e=this._steps[t];return this.stepConverter(e)}operationStringConvert;skipEmptyDialogs=false;getStepSha(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, ae.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let n=[];t.forEach(a=>{if(typeof a=="string")n.push(a);else if(a&&typeof a=="object"){let o=l(a);o?(o&&!Array.isArray(o)&&typeof o=="object"&&(o=l(o)||""),Array.isArray(o)?n=n.concat(o):n.push(`${o}`)):n.push(`${a}`);}}),e=n;}else {let n=l(t)||"";n&&!Array.isArray(n)&&typeof n=="object"&&(n=l(n)||""),e=n;}return `${e}`}getDialogue(t){if(t==null)return;let e=l(t);return e==null?"":typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:J.t(this.getDialogueText(e.text))}:J.t(this.getDialogueText(e))}getChoices(t){return l(t)?.map(a=>l(a)).filter(a=>a!==void 0)}stepConverter(t){return async e=>{let n;if(typeof t=="function"?n=t():n=t,n=O(n),n.operations)for(let c of n.operations)await L(c,this.operationStringConvert?d=>this.operationStringConvert(d,n,e):void 0);let a=this.getChoices(n.choices),o=l(n.glueEnabled),f=this.getDialogue(n.dialogue),p=[];n.labelToOpen&&(Array.isArray(n.labelToOpen)||(n.labelToOpen=[n.labelToOpen]),n.labelToOpen.forEach(c=>{let d=l(c);d&&p.push(d);}));let u=l(n.goNextStep),h=l(n.end);if(a){let c=a.map(d=>{let m="";if(Array.isArray(d.text)){let x=[];d.text.forEach(T=>{if(typeof T=="string")x.push(J.t(T));else if(T&&typeof T=="object"){let b=l(T);b&&!Array.isArray(b)&&typeof b=="object"&&(b=l(b)||""),b&&(Array.isArray(b)?x=x.concat(J.t(b)):x.push(J.t(b)));}}),m=x.join();}else typeof d.text=="string"&&(m=J.t(d.text));return new ChoiceMenuOption(m,d.label,d.props,{type:d.type,oneTime:d.oneTime,onlyHaveNoChoice:d.onlyHaveNoChoice,autoSelect:d.autoSelect})});narration.choiceMenuOptions=c;}else narration.choiceMenuOptions=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(u=true)),o?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):o===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let c of p){let d=c.label;typeof d=="object"&&(d=l(d)||"");let m=c.params?.map(x=>l(x));e={...e,...c.props},c.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${E}${narration.openedLabels.length}`,m),await narration.callLabel(d,e)):(storage.setTempVariable(`${E}${narration.openedLabels.length}`,m),await narration.callLabel(d,e));}h==="game_end"?(narration.closeAllLabels(),await narration.goNext(e,{runNow:true})):h==="label_end"&&narration.closeCurrentLabel(),u&&await narration.goNext(e,{runNow:true});}}};function Me(i,t={}){let e=t?.operationStringConvert;try{typeof i=="string"&&(i=JSON.parse(i));}catch(n){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",n);return}if(typeof i!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(i.initialOperations){for(let a of i.initialOperations)L(a,e?o=>e(o,{},{}):void 0);let n={};[...storage.storage.keys()].forEach((a,o)=>{n[a]=storage.storage.get(a);}),storage.startingStorage=n;}if(i.labels){let n=i.labels;for(let a in n)try{let o=n[a],f=new A(a,o,void 0,t);RegisteredLabels.add(f);}catch(o){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${a}`,o);}}}export{A as LabelJson,E as PIXIVNJSON_PARAM_ID,l as getLogichValue,Me as importPixiVNJson,U as setStorageJson,B as translator};
3
+ `+h),o=p(n.glueEnabled)||false,h)}),c=p(f[0]),u=typeof c=="object"&&"character"in c?c.character:void 0,g=f.map(n=>{let s;n&&typeof n=="object"&&"text"in n?s=n.text:s=n;let h;return Array.isArray(s)?h=s.map(m=>{let N=p(m);return $.t(`${N}`)}).join(""):h=p(s)||"",$.t(h)}).join(""),l=a.find(n=>n.end),d=a.find(n=>n.choices),y=false,x=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),y=a[a.length-1].glueEnabled,x=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let T=a.find(n=>n.labelToOpen),V=[];return a.forEach(n=>{n.operations&&V.forEach(s=>{V.push(s);});}),{dialogue:u?{character:u,text:g}:g,end:l?.end,choices:d?.choices,glueEnabled:y,goNextStep:x,labelToOpen:T?.labelToOpen,operations:V}}}function xe(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let t=p(i.leftValue),e=p(i.rightValue);switch(i.operator){case "==":return t===e;case "!=":return t!==e;case "<":return t<e;case "<=":return t<=e;case ">":return t>e;case ">=":return t>=e;case "CONTAINS":return t.toString().includes(e.toString())}break;case "valueCondition":return !!p(i.value);case "union":return be(i)}return !!i}function Te(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case "storage":case "tempstorage":return storage.getVariable(i.key);case "flagStorage":return storage.getFlag(i.key);case "label":return narration.getTimesLabelOpened(i.label);case "choice":return narration.getTimesChoiceMade(i.index);case "logic":return p(i.operation);case "params":let t=storage.getVariable(`${k}${narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];b.warn("getValue params not found");return}return i}function be(i){if(i.unionType==="not")return !p(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=p(i.conditions[e])||false,i.unionType==="and"){if(!t)return false}else if(t)return true;return t}function X(i){let t=p(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=p(t):e=t,i.storageType){case "flagStorage":storage.setFlag(i.key,i.value);break;case "storage":storage.setVariable(i.key,e);break;case "tempstorage":storage.setTempVariable(i.key,e);break;case "params":let r=storage.getVariable(`${k}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=e),storage.setTempVariable(`${k}${narration.openedLabels.length-1}`,r);break}}function p(i){let t=ye(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return Te(t);case "arithmetic":case "arithmeticsingle":return Ve(t);case "compare":case "valueCondition":case "union":return xe(t)}return t}function Ve(i){let t=p(i.leftValue);switch(i.type){case "arithmetic":let e=p(i.rightValue);switch(i.operator){case "*":return t*e;case "/":return t/e;case "+":return t+e;case "-":return t-e;case "%":return t%e;case "POW":return Math.pow(t,e);case "RANDOM":return narration.getRandomNumber(t,e)}case "arithmeticsingle":switch(i.operator){case "INT":return parseInt(t);case "FLOOR":return Math.floor(t);case "FLOAT":return parseFloat(t)}break}}async function H(i){let t=p(i);if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}async function I(i,t){let e=p(i);if(e)switch(e.type){case "sound":switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(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 "assets":case "bundle":await H(e);break;case "image":switch(e.operationType){case "show":let c=new ImageSprite(e.props,e.url||e.alias);await Y(c,e);break;case "edit":let u=canvas.find(e.alias);u?e.props&&await u.setMemory({...u.memory,...e.props}):b.error(`Image with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "video":switch(e.operationType){case "show":let c=new VideoSprite(e.props,e.url||e.alias);await Y(c,e);break;case "edit":let u=canvas.find(e.alias);u?e.props&&await u.setMemory({...u.memory,...e.props}):b.error(`Video with alias ${e.alias} not found.`);break;case "remove":M(e);break;case "pause":let g=canvas.find(e.alias);g?g.paused=true:b.error(`Video with alias ${e.alias} not found.`);break;case "resume":let l=canvas.find(e.alias);l?l.paused=false:b.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let c=new ImageContainer(e.props,e.urls);await Y(c,e);break;case "edit":let u=canvas.find(e.alias);u?e.props&&await u.setMemory({...u.memory,...e.props}):b.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let c=canvas.find(e.alias);c?e.props&&(c.memory={...c.memory,...e.props}):b.error(`Canvas Element with alias ${e.alias} not found.`);}catch(c){b.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,c);}break;case "remove":M(e);break}break;case "value":X(e);break;case "operationtoconvert":if(t){let c="";e.values.forEach(g=>{if(typeof g=="string")c+=g;else {let l=p(g);c+=`${l}`;}});let u=await t(c);u&&await I(u,t);}break;case "input":switch(e.operationType){case "request":narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let r=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,r);break;case "move":let a=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "rotate":let o=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,o);break;case "zoom":let f=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,f);break;case "shake":await shakeEffect(e.alias,e.props,e.priority);break}}async function Y(i,t){if(t.transition)switch(t.transition.type){case "fade":await showWithFade(t.alias,i,t.transition.props,t.transition.priority);break;case "dissolve":await showWithDissolve(t.alias,i,t.transition.props,t.transition.priority);break;case "movein":case "moveout":await moveIn(t.alias,i,t.transition.props,t.transition.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,i,t.transition.props,t.transition.priority);break;case "pushin":case "pushout":await pushIn(t.alias,i,t.transition.props,t.transition.priority);break}else await i.load(),canvas.add(t.alias,i);}function M(i){if(i.transition)switch(i.transition.type){case "fade":removeWithFade(i.alias,i.transition.props,i.transition.priority);break;case "dissolve":removeWithDissolve(i.alias,i.transition.props,i.transition.priority);break;case "movein":case "moveout":moveOut(i.alias,i.transition.props,i.transition.priority);break;case "zoomin":case "zoomout":zoomOut(i.alias,i.transition.props,i.transition.priority);break;case "pushin":case "pushout":pushOut(i.alias,i.transition.props,i.transition.priority);break}else canvas.remove(i.alias);}var O=class extends LabelAbstract{constructor(t,e,r,a={}){r||(r={}),r.onLoadingLabel=async()=>{for(let o of e){let f;if(typeof o=="function"?f=o():f=o,f=_(f),f.operations){let c=f.operations.map(u=>H(u));await Promise.all(c);}}},super(t,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let e=this._steps[t];return this.stepConverter(e)}operationStringConvert;skipEmptyDialogs=false;getStepSha(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, se.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let r=[];t.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let o=p(a);o?(o&&!Array.isArray(o)&&typeof o=="object"&&(o=p(o)||""),Array.isArray(o)?r=r.concat(o):r.push(`${o}`)):r.push(`${a}`);}}),e=r;}else {let r=p(t)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=p(r)||""),e=r;}return `${e}`}getDialogue(t){if(t==null)return;let e=p(t);return e==null?"":typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:S.t(this.getDialogueText(e.text))}:S.t(this.getDialogueText(e))}getChoices(t){return p(t)?.map(a=>p(a)).filter(a=>a!==void 0)}stepConverter(t){return async e=>{let r;if(typeof t=="function"?r=t():r=t,r=_(r),r.operations)for(let l of r.operations)await I(l,this.operationStringConvert?d=>this.operationStringConvert(d,r,e):void 0);let a=this.getChoices(r.choices),o=p(r.glueEnabled),f=this.getDialogue(r.dialogue),c=[];r.labelToOpen&&(Array.isArray(r.labelToOpen)||(r.labelToOpen=[r.labelToOpen]),r.labelToOpen.forEach(l=>{let d=p(l);d&&c.push(d);}));let u=p(r.goNextStep),g=p(r.end);if(a){let l=a.map(d=>{let y="";if(Array.isArray(d.text)){let x=[];d.text.forEach(T=>{if(typeof T=="string")x.push(S.t(T));else if(T&&typeof T=="object"){let V=p(T);V&&!Array.isArray(V)&&typeof V=="object"&&(V=p(V)||""),V&&(Array.isArray(V)?x=x.concat(S.t(V)):x.push(S.t(V)));}}),y=x.join();}else typeof d.text=="string"&&(y=S.t(d.text));return new ChoiceMenuOption(y,d.label,d.props,{type:d.type,oneTime:d.oneTime,onlyHaveNoChoice:d.onlyHaveNoChoice,autoSelect:d.autoSelect})});narration.choiceMenuOptions=l;}else narration.choiceMenuOptions=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(u=true)),o?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):o===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let l of c){let d=l.label;typeof d=="object"&&(d=p(d)||"");let y=l.params?.map(x=>p(x));e={...e,...l.props},l.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${k}${narration.openedLabels.length}`,y),await narration.callLabel(d,e)):(storage.setTempVariable(`${k}${narration.openedLabels.length}`,y),await narration.callLabel(d,e));}g==="game_end"?(narration.closeAllLabels(),await narration.goNext(e,{runNow:true})):g==="label_end"&&narration.closeCurrentLabel(),u&&await narration.goNext(e,{runNow:true});}}};async function ze(i,t={}){let{operationStringConvert:e,skipEmptyDialogs:r}=t;if(!Array.isArray(i))if(typeof i=="object"||typeof i=="string")i=[i];else {b.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let a=i.map(async c=>{if(typeof c=="string")try{c=JSON.parse(c);}catch(u){b.error("Error parsing imported Pixi'VN JSON",u),c={};}return c}),f=(await Promise.all(a)).map(async c=>{let u=[];if(c.initialOperations){c.initialOperations.forEach(l=>{let d=I(l,e?y=>e(y,{},{}):void 0);u.push(d);});let g={};[...storage.storage.keys()].forEach((l,d)=>{g[l]=storage.storage.get(l);}),storage.startingStorage=g;}if(c.labels){let g=c.labels;for(let l in g)try{let d=g[l],y=new O(l,d,void 0,t);RegisteredLabels.add(y);}catch(d){b.error(`Error creating JSON label ${l}`,d);}}return Promise.all(u)});await Promise.all(f);}export{O as LabelJson,k as PIXIVNJSON_PARAM_ID,p as getLogichValue,ze as importPixiVNJson,X as setStorageJson,$ as translator};
@@ -0,0 +1 @@
1
+ 'use strict';exports.logger=void 0;(s=>(s.log=(n,...o)=>console.log(`[Pixi\u2019VN Json] ${n}`,...o),s.warn=(n,...o)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...o),s.error=(n,...o)=>console.error(`[Pixi\u2019VN Json] ${n}`,...o),s.info=(n,...o)=>console.info(`[Pixi\u2019VN Json] ${n}`,...o)))(exports.logger||={});
@@ -0,0 +1,8 @@
1
+ declare namespace logger {
2
+ const log: (message?: any, ...optionalParams: any[]) => void;
3
+ const warn: (message?: any, ...optionalParams: any[]) => void;
4
+ const error: (message?: any, ...optionalParams: any[]) => void;
5
+ const info: (message?: any, ...optionalParams: any[]) => void;
6
+ }
7
+
8
+ export { logger };
@@ -0,0 +1,8 @@
1
+ declare namespace logger {
2
+ const log: (message?: any, ...optionalParams: any[]) => void;
3
+ const warn: (message?: any, ...optionalParams: any[]) => void;
4
+ const error: (message?: any, ...optionalParams: any[]) => void;
5
+ const info: (message?: any, ...optionalParams: any[]) => void;
6
+ }
7
+
8
+ export { logger };
@@ -0,0 +1 @@
1
+ var a;(s=>(s.log=(n,...o)=>console.log(`[Pixi\u2019VN Json] ${n}`,...o),s.warn=(n,...o)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...o),s.error=(n,...o)=>console.error(`[Pixi\u2019VN Json] ${n}`,...o),s.info=(n,...o)=>console.info(`[Pixi\u2019VN Json] ${n}`,...o)))(a||={});export{a as logger};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drincs/pixi-vn-json",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "description": "Pixi'VN can be integrated with JSON files to create a visual novel.",
6
6
  "main": "./dist/index.cjs",
@@ -10,7 +10,8 @@
10
10
  "dist"
11
11
  ],
12
12
  "scripts": {
13
- "build": "tsup"
13
+ "build": "tsup",
14
+ "test": "vitest"
14
15
  },
15
16
  "repository": {
16
17
  "type": "git",
@@ -26,6 +27,7 @@
26
27
  "devDependencies": {
27
28
  "@types/crypto-js": "^4.2.2",
28
29
  "crypto-js": "^4.2.0",
30
+ "jsdom": "^26.1.0",
29
31
  "ts-node": "^10.9.2",
30
32
  "tsup": "^8.4.0",
31
33
  "typescript": "^5.8.3"
@@ -42,5 +44,8 @@
42
44
  "pixi-js",
43
45
  "visual",
44
46
  "visual-novel"
45
- ]
47
+ ],
48
+ "dependencies": {
49
+ "vitest": "^3.1.2"
50
+ }
46
51
  }