@drincs/pixi-vn-json 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var p;(a=>(a.log=(n,...f)=>console.log(`[Pixi\u2019VN Json] ${n}`,...f),a.warn=(n,...f)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...f),a.error=(n,...f)=>console.error(`[Pixi\u2019VN Json] ${n}`,...f),a.info=(n,...f)=>console.info(`[Pixi\u2019VN Json] ${n}`,...f)))(p||={});var k="___param___";var P=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,o){let a=o.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(n=>{t[n]===void 0&&(a==="empty_string"?t[n]="":a==="copy_key"&&(i._beforeToTranslate?t[n]=i._beforeToTranslate(n):t[n]=n));});}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(o=>{i.getConditionalsThenElse(o,e);});else if(t.elements.type==="ifelse"){let o=[];i.getConditionalsThenElse(t.elements,o),o.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let o=[];i.getConditionalsThenElse(t.elements,o),o.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(o=>{i.getConditionalsThenElse(o,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},o={}){let{defaultValue:a="copy_key"}=o;return t.forEach(n=>{if(n.choices){let f=[];Array.isArray(n.choices)?f=[n.choices]:f=i.getConditionalsThenElse(n.choices),f.forEach(s=>s.forEach(l=>{if("type"in l){let u=[];l.type==="ifelse"||l.type==="stepswitch"?i.getConditionalsThenElse(l,u):u=[l],u.map(T=>i.getConditionalsThenElse(T.text)).forEach(T=>{Array.isArray(T)&&T.forEach(h=>{Array.isArray(h)?h.forEach(V=>{typeof V=="string"?i.addKey(e,V,{defaultValue:a}):i.getConditionalsThenElse(V).forEach(b=>{Array.isArray(b)?b.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof b=="string"&&i.addKey(e,b,{defaultValue:a});});}):typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});});}}));}if(n.dialogue){let f=[];Array.isArray(n.dialogue)?f=[n.dialogue]:f=i.getConditionalsThenElse(n.dialogue),f.forEach(s=>{typeof s=="string"?i.addKey(e,s,{defaultValue:a}):"text"in s&&Array.isArray(s.text)&&s.text.forEach(l=>{typeof l=="string"?i.addKey(e,l,{defaultValue:a}):i.getConditionalsThenElse(l).forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):Array.isArray(y)&&y.forEach(T=>{typeof T=="string"?i.addKey(e,T,{defaultValue:a}):i.getConditionalsThenElse(T).forEach(h=>{typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});});});});});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(s=>{Array.isArray(s)?i.generateJsonTranslation(s,e,o):i.generateJsonTranslation([s],e,o);});}),e}};var w=P;function _(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function F(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return M(i);case "ifelse":return r(i.condition)?r(i.then):r(i.else);case "stepswitch":let e=r(i.elements)||[];if(e.length===0){p.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let o=_(0,e.length-1);return r(e[o]);case "loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),r(e[a]);case "sequential":let n,f=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(n=r(e[e.length-1])),f>e.length-1?n:r(e[f]);case "sequentialrandom":let s=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(s==null&&i.end=="lastItem"){let l=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!l||!l?.usedRandomNumbers){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let u=l.usedRandomNumbers[`0-${e.length-1}`];return r(e[u[u.length-1]])}if(s==null){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return r(e[s])}}return i}function v(i){if(i.conditionalStep){let t=pixiVn.createExportableElement(r(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 v(e)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return i}function M(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(n=>{let f=r(n);e.push(f);});else {let n=r(a);e.push(n);}});let o=t?[t,...e]:e;if(o.length===0){p.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return w.t(o);if(typeof o[0]=="object"){let a=o,n,f=a.map((c,x)=>{c=v(c);let d=r(c.dialogue)||"";return x===0?(n=r(c.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),n===false&&(d=`
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var p;(a=>(a.log=(n,...f)=>console.log(`[Pixi\u2019VN Json] ${n}`,...f),a.warn=(n,...f)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...f),a.error=(n,...f)=>console.error(`[Pixi\u2019VN Json] ${n}`,...f),a.info=(n,...f)=>console.info(`[Pixi\u2019VN Json] ${n}`,...f)))(p||={});var k="___param___";var P=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,l){let a=l.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(n=>{t[n]===void 0&&(a==="empty_string"?t[n]="":a==="copy_key"&&(i._beforeToTranslate?t[n]=i._beforeToTranslate(n):t[n]=n));});}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(l=>{i.getConditionalsThenElse(l,e);});else if(t.elements.type==="ifelse"){let l=[];i.getConditionalsThenElse(t.elements,l),l.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let l=[];i.getConditionalsThenElse(t.elements,l),l.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(l=>{i.getConditionalsThenElse(l,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},l={}){let{defaultValue:a="copy_key"}=l;return t.forEach(n=>{if(n.choices){let f=[];Array.isArray(n.choices)?f=[n.choices]:f=i.getConditionalsThenElse(n.choices),f.forEach(r=>r.forEach(o=>{if("type"in o){let u=[];o.type==="ifelse"||o.type==="stepswitch"?i.getConditionalsThenElse(o,u):u=[o],u.map(y=>i.getConditionalsThenElse(y.text)).forEach(y=>{Array.isArray(y)&&y.forEach(m=>{Array.isArray(m)?m.forEach(h=>{typeof h=="string"?i.addKey(e,h,{defaultValue:a}):i.getConditionalsThenElse(h).forEach(b=>{Array.isArray(b)?b.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof b=="string"&&i.addKey(e,b,{defaultValue:a});});}):typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});}}));}if(n.dialogue){let f=[];Array.isArray(n.dialogue)?f=[n.dialogue]:f=i.getConditionalsThenElse(n.dialogue),f.forEach(r=>{if(typeof r=="string")i.addKey(e,r,{defaultValue:a});else if("text"in r){let o=i.getConditionalsThenElse(r.text);typeof o=="string"&&(o=[o]),o.forEach(u=>{typeof u=="string"?i.addKey(e,u,{defaultValue:a}):i.getConditionalsThenElse(u).forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):Array.isArray(y)&&y.forEach(m=>{typeof m=="string"?i.addKey(e,m,{defaultValue:a}):i.getConditionalsThenElse(m).forEach(h=>{typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});});});});}});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(r=>{Array.isArray(r)?i.generateJsonTranslation(r,e,l):i.generateJsonTranslation([r],e,l);});}),e}};var w=P;function F(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function _(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return M(i);case "ifelse":return s(i.condition)?s(i.then):s(i.else);case "stepswitch":let e=s(i.elements)||[];if(e.length===0){p.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let l=F(0,e.length-1);return s(e[l]);case "loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),s(e[a]);case "sequential":let n,f=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(n=s(e[e.length-1])),f>e.length-1?n:s(e[f]);case "sequentialrandom":let r=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(r==null&&i.end=="lastItem"){let o=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!o||!o?.usedRandomNumbers){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let u=o.usedRandomNumbers[`0-${e.length-1}`];return s(e[u[u.length-1]])}if(r==null){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[r])}}return i}function v(i){if(i.conditionalStep){let t=pixiVn.createExportableElement(s(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 v(e)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return i}function M(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(n=>{let f=s(n);e.push(f);});else {let n=s(a);e.push(n);}});let l=t?[t,...e]:e;if(l.length===0){p.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return w.t(l);if(typeof l[0]=="object"){let a=l,n,f=a.map((c,x)=>{c=v(c);let d=s(c.dialogue)||"";return x===0?(n=s(c.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),n===false&&(d=`
2
2
 
3
- `+d),n=r(c.glueEnabled)||false,d)}),s=r(f[0]),l=typeof s=="object"&&"character"in s?s.character:void 0,u=f.flatMap(c=>{let x;c&&typeof c=="object"&&"text"in c?x=c.text:x=c;let d;return Array.isArray(x)?d=x.map(L=>{let G=r(L);return w.t(`${G}`)}):d=r(x)||"",w.t(d)}),y=a.find(c=>c.end),T=a.find(c=>c.choices),h=false,V=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),h=a[a.length-1].glueEnabled,V=a.reverse().find(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let b=a.find(c=>c.labelToOpen),N=[];return a.forEach(c=>{c.operations&&N.forEach(x=>{N.push(x);});}),{dialogue:l?{character:l,text:u}:u,end:y?.end,choices:T?.choices,glueEnabled:h,goNextStep:V,labelToOpen:b?.labelToOpen,operations:N}}}function K(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let t=r(i.leftValue),e=r(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 !!r(i.value);case "union":return W(i)}return !!i}function z(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case "storage":case "tempstorage":return pixiVn.storage.getVariable(i.key);case "flagStorage":return pixiVn.storage.getFlag(i.key);case "label":return pixiVn.narration.getTimesLabelOpened(i.label);case "choice":return pixiVn.narration.getTimesChoiceMade(i.index);case "logic":return r(i.operation);case "params":let t=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];p.warn("getValue params not found");return}return i}function W(i){if(i.unionType==="not")return !r(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=r(i.conditions[e])||false,i.unionType==="and"){if(!t)return false}else if(t)return true;return t}function R(i){let t=r(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=r(t):e=t,i.storageType){case "flagStorage":pixiVn.storage.setFlag(i.key,i.value);break;case "storage":pixiVn.storage.setVariable(i.key,e);break;case "tempstorage":pixiVn.storage.setTempVariable(i.key,e);break;case "params":let o=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];o&&o.length-1>=i.key&&(o[i.key]=e),pixiVn.storage.setTempVariable(`${k}${pixiVn.narration.openedLabels.length-1}`,o);break}}function r(i){let t=F(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return z(t);case "arithmetic":case "arithmeticsingle":return X(t);case "compare":case "valueCondition":case "union":return K(t)}return t}function X(i){let t=r(i.leftValue);switch(i.type){case "arithmetic":let e=r(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 pixiVn.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 D(i){let t=r(i);if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await pixiVn.Assets.load(t.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await pixiVn.Assets.loadBundle(t.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoadBundle(t.aliases);break}break}}async function ue(i,t){let e=r(i);if(e)switch(e.type){case "sound":switch(e.operationType){case "play":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(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 "assets":case "bundle":await D(e);break;case "image":switch(e.operationType){case "show":let s=new pixiVn.ImageSprite(e.props,e.url||e.alias);await I(s,e);break;case "edit":let l=pixiVn.canvas.find(e.alias);l?e.props&&await l.setMemory({...l.memory,...e.props}):p.error(`Image with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "video":switch(e.operationType){case "show":let s=new pixiVn.VideoSprite(e.props,e.url||e.alias);await I(s,e);break;case "edit":let l=pixiVn.canvas.find(e.alias);l?e.props&&await l.setMemory({...l.memory,...e.props}):p.error(`Video with alias ${e.alias} not found.`);break;case "remove":A(e);break;case "pause":let u=pixiVn.canvas.find(e.alias);u?u.paused=true:p.error(`Video with alias ${e.alias} not found.`);break;case "resume":let y=pixiVn.canvas.find(e.alias);y?y.paused=false:p.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let s=new pixiVn.ImageContainer(e.props,e.urls);await I(s,e);break;case "edit":let l=pixiVn.canvas.find(e.alias);l?e.props&&await l.setMemory({...l.memory,...e.props}):p.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let s=pixiVn.canvas.find(e.alias);s?e.props&&(s.memory={...s.memory,...e.props}):p.error(`Canvas Element with alias ${e.alias} not found.`);}catch(s){p.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,s);}break;case "remove":A(e);break}break;case "value":R(e);break;case "operationtoconvert":if(t){let s="";e.values.forEach(u=>{if(typeof u=="string")s+=u;else {let y=r(u);s+=`${y}`;}});let l=await t(s);l&&await ue(l,t);}break;case "input":switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let o=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,o);break;case "move":let a=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break;case "rotate":let n=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,n);break;case "zoom":let f=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,f);break;case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}async function I(i,t){if(t.transition)switch(t.transition.type){case "fade":await pixiVn.showWithFade(t.alias,i,t.transition.props,t.transition.priority);break;case "dissolve":await pixiVn.showWithDissolve(t.alias,i,t.transition.props,t.transition.priority);break;case "movein":case "moveout":await pixiVn.moveIn(t.alias,i,t.transition.props,t.transition.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(t.alias,i,t.transition.props,t.transition.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(t.alias,i,t.transition.props,t.transition.priority);break}else await i.load(),pixiVn.canvas.add(t.alias,i);}function A(i){if(i.transition)switch(i.transition.type){case "fade":pixiVn.removeWithFade(i.alias,i.transition.props,i.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(i.alias,i.transition.props,i.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(i.alias,i.transition.props,i.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(i.alias,i.transition.props,i.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(i.alias,i.transition.props,i.transition.priority);break}else pixiVn.canvas.remove(i.alias);}exports.removeCanvasElement=A;exports.runOperation=ue;exports.showCanvasElemet=I;
3
+ `+d),n=s(c.glueEnabled)||false,d)}),r=s(f[0]),o=typeof r=="object"&&"character"in r?r.character:void 0,u=f.flatMap(c=>{let x;c&&typeof c=="object"&&"text"in c?x=c.text:x=c;let d;return Array.isArray(x)?d=x.map(L=>{let G=s(L);return w.t(`${G}`)}):d=s(x)||"",w.t(d)}),V=a.find(c=>c.end),y=a.find(c=>c.choices),m=false,h=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),m=a[a.length-1].glueEnabled,h=a.reverse().find(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let b=a.find(c=>c.labelToOpen),N=[];return a.forEach(c=>{c.operations&&N.forEach(x=>{N.push(x);});}),{dialogue:o?{character:o,text:u}:u,end:V?.end,choices:y?.choices,glueEnabled:m,goNextStep:h,labelToOpen:b?.labelToOpen,operations:N}}}function K(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let t=s(i.leftValue),e=s(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 !!s(i.value);case "union":return W(i)}return !!i}function z(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case "storage":case "tempstorage":return pixiVn.storage.getVariable(i.key);case "flagStorage":return pixiVn.storage.getFlag(i.key);case "label":return pixiVn.narration.getTimesLabelOpened(i.label);case "choice":return pixiVn.narration.getTimesChoiceMade(i.index);case "logic":return s(i.operation);case "params":let t=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];p.warn("getValue params not found");return}return i}function W(i){if(i.unionType==="not")return !s(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=s(i.conditions[e])||false,i.unionType==="and"){if(!t)return false}else if(t)return true;return t}function R(i){let t=s(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=s(t):e=t,i.storageType){case "flagStorage":pixiVn.storage.setFlag(i.key,i.value);break;case "storage":pixiVn.storage.setVariable(i.key,e);break;case "tempstorage":pixiVn.storage.setTempVariable(i.key,e);break;case "params":let l=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];l&&l.length-1>=i.key&&(l[i.key]=e),pixiVn.storage.setTempVariable(`${k}${pixiVn.narration.openedLabels.length-1}`,l);break}}function s(i){let t=_(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return z(t);case "arithmetic":case "arithmeticsingle":return X(t);case "compare":case "valueCondition":case "union":return K(t)}return t}function X(i){let t=s(i.leftValue);switch(i.type){case "arithmetic":let e=s(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 pixiVn.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 D(i){let t=s(i);if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await pixiVn.Assets.load(t.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await pixiVn.Assets.loadBundle(t.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoadBundle(t.aliases);break}break}}async function ue(i,t){let e=s(i);if(e)switch(e.type){case "sound":switch(e.operationType){case "play":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(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 "assets":case "bundle":await D(e);break;case "image":switch(e.operationType){case "show":let r=new pixiVn.ImageSprite(e.props,e.url||e.alias);await I(r,e);break;case "edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&await o.setMemory({...o.memory,...e.props}):p.error(`Image with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "video":switch(e.operationType){case "show":let r=new pixiVn.VideoSprite(e.props,e.url||e.alias);await I(r,e);break;case "edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&await o.setMemory({...o.memory,...e.props}):p.error(`Video with alias ${e.alias} not found.`);break;case "remove":A(e);break;case "pause":let u=pixiVn.canvas.find(e.alias);u?u.paused=true:p.error(`Video with alias ${e.alias} not found.`);break;case "resume":let V=pixiVn.canvas.find(e.alias);V?V.paused=false:p.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let r=new pixiVn.ImageContainer(e.props,e.urls);await I(r,e);break;case "edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&await o.setMemory({...o.memory,...e.props}):p.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):p.error(`Canvas Element with alias ${e.alias} not found.`);}catch(r){p.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,r);}break;case "remove":A(e);break}break;case "value":R(e);break;case "operationtoconvert":if(t){let r="";e.values.forEach(u=>{if(typeof u=="string")r+=u;else {let V=s(u);r+=`${V}`;}});let o=await t(r);o&&await ue(o,t);}break;case "input":switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let l=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,l);break;case "move":let a=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break;case "rotate":let n=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,n);break;case "zoom":let f=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,f);break;case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}async function I(i,t){if(t.transition)switch(t.transition.type){case "fade":await pixiVn.showWithFade(t.alias,i,t.transition.props,t.transition.priority);break;case "dissolve":await pixiVn.showWithDissolve(t.alias,i,t.transition.props,t.transition.priority);break;case "movein":case "moveout":await pixiVn.moveIn(t.alias,i,t.transition.props,t.transition.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(t.alias,i,t.transition.props,t.transition.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(t.alias,i,t.transition.props,t.transition.priority);break}else await i.load(),pixiVn.canvas.add(t.alias,i);}function A(i){if(i.transition)switch(i.transition.type){case "fade":pixiVn.removeWithFade(i.alias,i.transition.props,i.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(i.alias,i.transition.props,i.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(i.alias,i.transition.props,i.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(i.alias,i.transition.props,i.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(i.alias,i.transition.props,i.transition.priority);break}else pixiVn.canvas.remove(i.alias);}exports.removeCanvasElement=A;exports.runOperation=ue;exports.showCanvasElemet=I;
@@ -1,3 +1,3 @@
1
- import {shakeEffect,ZoomTicker,canvas,RotateTicker,MoveTicker,FadeAlphaTicker,narration,ImageContainer,VideoSprite,ImageSprite,sound,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,storage,Assets,NarrationManagerStatic,SYSTEM_RESERVED_STORAGE_KEYS,createExportableElement}from'@drincs/pixi-vn';var p;(a=>(a.log=(n,...f)=>console.log(`[Pixi\u2019VN Json] ${n}`,...f),a.warn=(n,...f)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...f),a.error=(n,...f)=>console.error(`[Pixi\u2019VN Json] ${n}`,...f),a.info=(n,...f)=>console.info(`[Pixi\u2019VN Json] ${n}`,...f)))(p||={});var k="___param___";var P=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,o){let a=o.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(n=>{t[n]===void 0&&(a==="empty_string"?t[n]="":a==="copy_key"&&(i._beforeToTranslate?t[n]=i._beforeToTranslate(n):t[n]=n));});}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(o=>{i.getConditionalsThenElse(o,e);});else if(t.elements.type==="ifelse"){let o=[];i.getConditionalsThenElse(t.elements,o),o.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let o=[];i.getConditionalsThenElse(t.elements,o),o.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(o=>{i.getConditionalsThenElse(o,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},o={}){let{defaultValue:a="copy_key"}=o;return t.forEach(n=>{if(n.choices){let f=[];Array.isArray(n.choices)?f=[n.choices]:f=i.getConditionalsThenElse(n.choices),f.forEach(s=>s.forEach(l=>{if("type"in l){let u=[];l.type==="ifelse"||l.type==="stepswitch"?i.getConditionalsThenElse(l,u):u=[l],u.map(T=>i.getConditionalsThenElse(T.text)).forEach(T=>{Array.isArray(T)&&T.forEach(h=>{Array.isArray(h)?h.forEach(V=>{typeof V=="string"?i.addKey(e,V,{defaultValue:a}):i.getConditionalsThenElse(V).forEach(b=>{Array.isArray(b)?b.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof b=="string"&&i.addKey(e,b,{defaultValue:a});});}):typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});});}}));}if(n.dialogue){let f=[];Array.isArray(n.dialogue)?f=[n.dialogue]:f=i.getConditionalsThenElse(n.dialogue),f.forEach(s=>{typeof s=="string"?i.addKey(e,s,{defaultValue:a}):"text"in s&&Array.isArray(s.text)&&s.text.forEach(l=>{typeof l=="string"?i.addKey(e,l,{defaultValue:a}):i.getConditionalsThenElse(l).forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):Array.isArray(y)&&y.forEach(T=>{typeof T=="string"?i.addKey(e,T,{defaultValue:a}):i.getConditionalsThenElse(T).forEach(h=>{typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});});});});});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(s=>{Array.isArray(s)?i.generateJsonTranslation(s,e,o):i.generateJsonTranslation([s],e,o);});}),e}};var w=P;function _(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function F(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return M(i);case "ifelse":return r(i.condition)?r(i.then):r(i.else);case "stepswitch":let e=r(i.elements)||[];if(e.length===0){p.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let o=_(0,e.length-1);return r(e[o]);case "loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),r(e[a]);case "sequential":let n,f=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(n=r(e[e.length-1])),f>e.length-1?n:r(e[f]);case "sequentialrandom":let s=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(s==null&&i.end=="lastItem"){let l=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!l||!l?.usedRandomNumbers){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let u=l.usedRandomNumbers[`0-${e.length-1}`];return r(e[u[u.length-1]])}if(s==null){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return r(e[s])}}return i}function v(i){if(i.conditionalStep){let t=createExportableElement(r(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 v(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 M(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(n=>{let f=r(n);e.push(f);});else {let n=r(a);e.push(n);}});let o=t?[t,...e]:e;if(o.length===0){p.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return w.t(o);if(typeof o[0]=="object"){let a=o,n,f=a.map((c,x)=>{c=v(c);let d=r(c.dialogue)||"";return x===0?(n=r(c.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),n===false&&(d=`
1
+ import {shakeEffect,ZoomTicker,canvas,RotateTicker,MoveTicker,FadeAlphaTicker,narration,ImageContainer,VideoSprite,ImageSprite,sound,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,storage,Assets,NarrationManagerStatic,SYSTEM_RESERVED_STORAGE_KEYS,createExportableElement}from'@drincs/pixi-vn';var p;(a=>(a.log=(n,...f)=>console.log(`[Pixi\u2019VN Json] ${n}`,...f),a.warn=(n,...f)=>console.warn(`[Pixi\u2019VN Json] ${n}`,...f),a.error=(n,...f)=>console.error(`[Pixi\u2019VN Json] ${n}`,...f),a.info=(n,...f)=>console.info(`[Pixi\u2019VN Json] ${n}`,...f)))(p||={});var k="___param___";var P=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,l){let a=l.defaultValue||"empty_string";typeof e=="string"&&(e=[e]),Array.isArray(e)&&e.forEach(n=>{t[n]===void 0&&(a==="empty_string"?t[n]="":a==="copy_key"&&(i._beforeToTranslate?t[n]=i._beforeToTranslate(n):t[n]=n));});}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(l=>{i.getConditionalsThenElse(l,e);});else if(t.elements.type==="ifelse"){let l=[];i.getConditionalsThenElse(t.elements,l),l.forEach(a=>{e.push(...a);});}else if(t.elements.type==="stepswitch"){let l=[];i.getConditionalsThenElse(t.elements,l),l.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(l=>{i.getConditionalsThenElse(l,e);})):e.push(t);else t&&e.push(t);return e}static generateJsonTranslation(t,e={},l={}){let{defaultValue:a="copy_key"}=l;return t.forEach(n=>{if(n.choices){let f=[];Array.isArray(n.choices)?f=[n.choices]:f=i.getConditionalsThenElse(n.choices),f.forEach(r=>r.forEach(o=>{if("type"in o){let u=[];o.type==="ifelse"||o.type==="stepswitch"?i.getConditionalsThenElse(o,u):u=[o],u.map(y=>i.getConditionalsThenElse(y.text)).forEach(y=>{Array.isArray(y)&&y.forEach(m=>{Array.isArray(m)?m.forEach(h=>{typeof h=="string"?i.addKey(e,h,{defaultValue:a}):i.getConditionalsThenElse(h).forEach(b=>{Array.isArray(b)?b.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof b=="string"&&i.addKey(e,b,{defaultValue:a});});}):typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});}}));}if(n.dialogue){let f=[];Array.isArray(n.dialogue)?f=[n.dialogue]:f=i.getConditionalsThenElse(n.dialogue),f.forEach(r=>{if(typeof r=="string")i.addKey(e,r,{defaultValue:a});else if("text"in r){let o=i.getConditionalsThenElse(r.text);typeof o=="string"&&(o=[o]),o.forEach(u=>{typeof u=="string"?i.addKey(e,u,{defaultValue:a}):i.getConditionalsThenElse(u).forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):Array.isArray(y)&&y.forEach(m=>{typeof m=="string"?i.addKey(e,m,{defaultValue:a}):i.getConditionalsThenElse(m).forEach(h=>{typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});});});});}});}n.conditionalStep&&i.getConditionalsThenElse(n.conditionalStep).forEach(r=>{Array.isArray(r)?i.generateJsonTranslation(r,e,l):i.generateJsonTranslation([r],e,l);});}),e}};var w=P;function F(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function _(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "resulttocombine":return M(i);case "ifelse":return s(i.condition)?s(i.then):s(i.else);case "stepswitch":let e=s(i.elements)||[];if(e.length===0){p.error("getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case "random":let l=F(0,e.length-1);return s(e[l]);case "loop":let a=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),s(e[a]);case "sequential":let n,f=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(n=s(e[e.length-1])),f>e.length-1?n:s(e[f]);case "sequentialrandom":let r=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(r==null&&i.end=="lastItem"){let o=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!o||!o?.usedRandomNumbers){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let u=o.usedRandomNumbers[`0-${e.length-1}`];return s(e[u[u.length-1]])}if(r==null){p.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[r])}}return i}function v(i){if(i.conditionalStep){let t=createExportableElement(s(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 v(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 M(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(n=>{let f=s(n);e.push(f);});else {let n=s(a);e.push(n);}});let l=t?[t,...e]:e;if(l.length===0){p.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return w.t(l);if(typeof l[0]=="object"){let a=l,n,f=a.map((c,x)=>{c=v(c);let d=s(c.dialogue)||"";return x===0?(n=s(c.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),n===false&&(d=`
2
2
 
3
- `+d),n=r(c.glueEnabled)||false,d)}),s=r(f[0]),l=typeof s=="object"&&"character"in s?s.character:void 0,u=f.flatMap(c=>{let x;c&&typeof c=="object"&&"text"in c?x=c.text:x=c;let d;return Array.isArray(x)?d=x.map(L=>{let G=r(L);return w.t(`${G}`)}):d=r(x)||"",w.t(d)}),y=a.find(c=>c.end),T=a.find(c=>c.choices),h=false,V=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),h=a[a.length-1].glueEnabled,V=a.reverse().find(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let b=a.find(c=>c.labelToOpen),N=[];return a.forEach(c=>{c.operations&&N.forEach(x=>{N.push(x);});}),{dialogue:l?{character:l,text:u}:u,end:y?.end,choices:T?.choices,glueEnabled:h,goNextStep:V,labelToOpen:b?.labelToOpen,operations:N}}}function K(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let t=r(i.leftValue),e=r(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 !!r(i.value);case "union":return W(i)}return !!i}function z(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 r(i.operation);case "params":let t=storage.getVariable(`${k}${narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];p.warn("getValue params not found");return}return i}function W(i){if(i.unionType==="not")return !r(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=r(i.conditions[e])||false,i.unionType==="and"){if(!t)return false}else if(t)return true;return t}function R(i){let t=r(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=r(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 o=storage.getVariable(`${k}${narration.openedLabels.length-1}`)||[];o&&o.length-1>=i.key&&(o[i.key]=e),storage.setTempVariable(`${k}${narration.openedLabels.length-1}`,o);break}}function r(i){let t=F(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return z(t);case "arithmetic":case "arithmeticsingle":return X(t);case "compare":case "valueCondition":case "union":return K(t)}return t}function X(i){let t=r(i.leftValue);switch(i.type){case "arithmetic":let e=r(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 D(i){let t=r(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 ue(i,t){let e=r(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 D(e);break;case "image":switch(e.operationType){case "show":let s=new ImageSprite(e.props,e.url||e.alias);await I(s,e);break;case "edit":let l=canvas.find(e.alias);l?e.props&&await l.setMemory({...l.memory,...e.props}):p.error(`Image with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "video":switch(e.operationType){case "show":let s=new VideoSprite(e.props,e.url||e.alias);await I(s,e);break;case "edit":let l=canvas.find(e.alias);l?e.props&&await l.setMemory({...l.memory,...e.props}):p.error(`Video with alias ${e.alias} not found.`);break;case "remove":A(e);break;case "pause":let u=canvas.find(e.alias);u?u.paused=true:p.error(`Video with alias ${e.alias} not found.`);break;case "resume":let y=canvas.find(e.alias);y?y.paused=false:p.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let s=new ImageContainer(e.props,e.urls);await I(s,e);break;case "edit":let l=canvas.find(e.alias);l?e.props&&await l.setMemory({...l.memory,...e.props}):p.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let s=canvas.find(e.alias);s?e.props&&(s.memory={...s.memory,...e.props}):p.error(`Canvas Element with alias ${e.alias} not found.`);}catch(s){p.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,s);}break;case "remove":A(e);break}break;case "value":R(e);break;case "operationtoconvert":if(t){let s="";e.values.forEach(u=>{if(typeof u=="string")s+=u;else {let y=r(u);s+=`${y}`;}});let l=await t(s);l&&await ue(l,t);}break;case "input":switch(e.operationType){case "request":narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let o=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,o);break;case "move":let a=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "rotate":let n=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,n);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 I(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 A(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);}export{A as removeCanvasElement,ue as runOperation,I as showCanvasElemet};
3
+ `+d),n=s(c.glueEnabled)||false,d)}),r=s(f[0]),o=typeof r=="object"&&"character"in r?r.character:void 0,u=f.flatMap(c=>{let x;c&&typeof c=="object"&&"text"in c?x=c.text:x=c;let d;return Array.isArray(x)?d=x.map(L=>{let G=s(L);return w.t(`${G}`)}):d=s(x)||"",w.t(d)}),V=a.find(c=>c.end),y=a.find(c=>c.choices),m=false,h=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,h=a.reverse().find(c=>!(c.operations&&(!c.dialogue||!c.choices)))?.goNextStep);let b=a.find(c=>c.labelToOpen),N=[];return a.forEach(c=>{c.operations&&N.forEach(x=>{N.push(x);});}),{dialogue:o?{character:o,text:u}:u,end:V?.end,choices:y?.choices,glueEnabled:m,goNextStep:h,labelToOpen:b?.labelToOpen,operations:N}}}function K(i){if(!i)return false;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case "compare":let t=s(i.leftValue),e=s(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 !!s(i.value);case "union":return W(i)}return !!i}function z(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 s(i.operation);case "params":let t=storage.getVariable(`${k}${narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];p.warn("getValue params not found");return}return i}function W(i){if(i.unionType==="not")return !s(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=s(i.conditions[e])||false,i.unionType==="and"){if(!t)return false}else if(t)return true;return t}function R(i){let t=s(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=s(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 l=storage.getVariable(`${k}${narration.openedLabels.length-1}`)||[];l&&l.length-1>=i.key&&(l[i.key]=e),storage.setTempVariable(`${k}${narration.openedLabels.length-1}`,l);break}}function s(i){let t=_(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return z(t);case "arithmetic":case "arithmeticsingle":return X(t);case "compare":case "valueCondition":case "union":return K(t)}return t}function X(i){let t=s(i.leftValue);switch(i.type){case "arithmetic":let e=s(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 D(i){let t=s(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 ue(i,t){let e=s(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 D(e);break;case "image":switch(e.operationType){case "show":let r=new ImageSprite(e.props,e.url||e.alias);await I(r,e);break;case "edit":let o=canvas.find(e.alias);o?e.props&&await o.setMemory({...o.memory,...e.props}):p.error(`Image with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "video":switch(e.operationType){case "show":let r=new VideoSprite(e.props,e.url||e.alias);await I(r,e);break;case "edit":let o=canvas.find(e.alias);o?e.props&&await o.setMemory({...o.memory,...e.props}):p.error(`Video with alias ${e.alias} not found.`);break;case "remove":A(e);break;case "pause":let u=canvas.find(e.alias);u?u.paused=true:p.error(`Video with alias ${e.alias} not found.`);break;case "resume":let V=canvas.find(e.alias);V?V.paused=false:p.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let r=new ImageContainer(e.props,e.urls);await I(r,e);break;case "edit":let o=canvas.find(e.alias);o?e.props&&await o.setMemory({...o.memory,...e.props}):p.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":A(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let r=canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):p.error(`Canvas Element with alias ${e.alias} not found.`);}catch(r){p.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,r);}break;case "remove":A(e);break}break;case "value":R(e);break;case "operationtoconvert":if(t){let r="";e.values.forEach(u=>{if(typeof u=="string")r+=u;else {let V=s(u);r+=`${V}`;}});let o=await t(r);o&&await ue(o,t);}break;case "input":switch(e.operationType){case "request":narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let l=new FadeAlphaTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,l);break;case "move":let a=new MoveTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,a);break;case "rotate":let n=new RotateTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,n);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 I(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 A(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);}export{A as removeCanvasElement,ue as runOperation,I as showCanvasElemet};
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@drincs/pixi-vn');var J="___param___";var E=class e{static _beforeToTranslate=void 0;static _translate=n=>n;static _afterToTranslate=void 0;static t(n){return Array.isArray(n)?n.map(t=>e.translate(`${t}`)):e.translate(`${n}`)}static set beforeToTranslate(n){e._beforeToTranslate=n;}static set translate(n){e._translate=n;}static get translate(){return n=>{let t=n;return e._beforeToTranslate&&(t=e._beforeToTranslate(t)),t=e._translate(t),e._afterToTranslate&&(t=e._afterToTranslate(t)),t}}static set afterToTranslate(n){e._afterToTranslate=n;}static addKey(n,t,o){let i=o.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(a=>{n[a]===void 0&&(i==="empty_string"?n[a]="":i==="copy_key"&&(e._beforeToTranslate?n[a]=e._beforeToTranslate(a):n[a]=a));});}static getConditionalsThenElse(n,t=[]){if(typeof n=="object"&&n&&"type"in n)if(n.type==="ifelse")n.then&&e.getConditionalsThenElse(n.then,t),n.else&&e.getConditionalsThenElse(n.else,t);else if(n.type==="stepswitch"){if(n.elements)if(Array.isArray(n.elements))n.elements.forEach(o=>{e.getConditionalsThenElse(o,t);});else if(n.elements.type==="ifelse"){let o=[];e.getConditionalsThenElse(n.elements,o),o.forEach(i=>{t.push(...i);});}else if(n.elements.type==="stepswitch"){let o=[];e.getConditionalsThenElse(n.elements,o),o.forEach(i=>{t.push(...i);});}else e.getConditionalsThenElse(n.elements,t);}else n.type==="resulttocombine"?(n.firstItem&&e.getConditionalsThenElse(n.firstItem,t),n.secondConditionalItem&&n.secondConditionalItem.forEach(o=>{e.getConditionalsThenElse(o,t);})):t.push(n);else n&&t.push(n);return t}static generateJsonTranslation(n,t={},o={}){let{defaultValue:i="copy_key"}=o;return n.forEach(a=>{if(a.choices){let r=[];Array.isArray(a.choices)?r=[a.choices]:r=e.getConditionalsThenElse(a.choices),r.forEach(f=>f.forEach(u=>{if("type"in u){let T=[];u.type==="ifelse"||u.type==="stepswitch"?e.getConditionalsThenElse(u,T):T=[u],T.map(g=>e.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(p=>{Array.isArray(p)?p.forEach(m=>{typeof m=="string"?e.addKey(t,m,{defaultValue:i}):e.getConditionalsThenElse(m).forEach(V=>{Array.isArray(V)?V.forEach(N=>{typeof N=="string"&&e.addKey(t,N,{defaultValue:i});}):typeof V=="string"&&e.addKey(t,V,{defaultValue:i});});}):typeof p=="string"&&e.addKey(t,p,{defaultValue:i});});});}}));}if(a.dialogue){let r=[];Array.isArray(a.dialogue)?r=[a.dialogue]:r=e.getConditionalsThenElse(a.dialogue),r.forEach(f=>{typeof f=="string"?e.addKey(t,f,{defaultValue:i}):"text"in f&&Array.isArray(f.text)&&f.text.forEach(u=>{typeof u=="string"?e.addKey(t,u,{defaultValue:i}):e.getConditionalsThenElse(u).forEach(h=>{typeof h=="string"?e.addKey(t,h,{defaultValue:i}):Array.isArray(h)&&h.forEach(g=>{typeof g=="string"?e.addKey(t,g,{defaultValue:i}):e.getConditionalsThenElse(g).forEach(p=>{typeof p=="string"&&e.addKey(t,p,{defaultValue:i});});});});});});}a.conditionalStep&&e.getConditionalsThenElse(a.conditionalStep).forEach(f=>{Array.isArray(f)?e.generateJsonTranslation(f,t,o):e.generateJsonTranslation([f],t,o);});}),t}};var P=E;var x;(i=>(i.log=(a,...r)=>console.log(`[Pixi\u2019VN Json] ${a}`,...r),i.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...r),i.error=(a,...r)=>console.error(`[Pixi\u2019VN Json] ${a}`,...r),i.info=(a,...r)=>console.info(`[Pixi\u2019VN Json] ${a}`,...r)))(x||={});function R(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function w(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return L(e);case "ifelse":return s(e.condition)?s(e.then):s(e.else);case "stepswitch":let t=s(e.elements)||[];if(t.length===0){x.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=R(0,t.length-1);return s(t[o]);case "loop":let i=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return i>t.length-1&&(i=i%t.length),s(t[i]);case "sequential":let a,r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(a=s(t[t.length-1])),r>t.length-1?a:s(t[r]);case "sequentialrandom":let f=pixiVn.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(f==null&&e.end=="lastItem"){let u=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let T=u.usedRandomNumbers[`0-${t.length-1}`];return s(t[T[T.length-1]])}if(f==null){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(t[f])}}return e}function A(e){if(e.conditionalStep){let n=pixiVn.createExportableElement(s(e.conditionalStep));if(n?.glueEnabled===void 0&&delete n?.glueEnabled,n?.goNextStep===void 0&&delete n?.goNextStep,n?.end===void 0&&delete n?.end,n?.choices===void 0&&delete n?.choices,n?.dialogue===void 0&&delete n?.dialogue,n?.labelToOpen===void 0&&delete n?.labelToOpen,n?.operations===void 0&&delete n?.operations,n){let t={...e,conditionalStep:void 0,...n};return A(t)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function L(e){let n=e.firstItem,t=[];e.secondConditionalItem?.forEach(i=>{if(Array.isArray(i))i.forEach(a=>{let r=s(a);t.push(r);});else {let a=s(i);t.push(a);}});let o=n?[n,...t]:t;if(o.length===0){x.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return P.t(o);if(typeof o[0]=="object"){let i=o,a,r=i.map((l,y)=>{l=A(l);let c=s(l.dialogue)||"";return y===0?(a=s(l.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),a===false&&(c=`
1
+ 'use strict';var pixiVn=require('@drincs/pixi-vn');var E="___param___";var b=class e{static _beforeToTranslate=void 0;static _translate=n=>n;static _afterToTranslate=void 0;static t(n){return Array.isArray(n)?n.map(t=>e.translate(`${t}`)):e.translate(`${n}`)}static set beforeToTranslate(n){e._beforeToTranslate=n;}static set translate(n){e._translate=n;}static get translate(){return n=>{let t=n;return e._beforeToTranslate&&(t=e._beforeToTranslate(t)),t=e._translate(t),e._afterToTranslate&&(t=e._afterToTranslate(t)),t}}static set afterToTranslate(n){e._afterToTranslate=n;}static addKey(n,t,s){let i=s.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(a=>{n[a]===void 0&&(i==="empty_string"?n[a]="":i==="copy_key"&&(e._beforeToTranslate?n[a]=e._beforeToTranslate(a):n[a]=a));});}static getConditionalsThenElse(n,t=[]){if(typeof n=="object"&&n&&"type"in n)if(n.type==="ifelse")n.then&&e.getConditionalsThenElse(n.then,t),n.else&&e.getConditionalsThenElse(n.else,t);else if(n.type==="stepswitch"){if(n.elements)if(Array.isArray(n.elements))n.elements.forEach(s=>{e.getConditionalsThenElse(s,t);});else if(n.elements.type==="ifelse"){let s=[];e.getConditionalsThenElse(n.elements,s),s.forEach(i=>{t.push(...i);});}else if(n.elements.type==="stepswitch"){let s=[];e.getConditionalsThenElse(n.elements,s),s.forEach(i=>{t.push(...i);});}else e.getConditionalsThenElse(n.elements,t);}else n.type==="resulttocombine"?(n.firstItem&&e.getConditionalsThenElse(n.firstItem,t),n.secondConditionalItem&&n.secondConditionalItem.forEach(s=>{e.getConditionalsThenElse(s,t);})):t.push(n);else n&&t.push(n);return t}static generateJsonTranslation(n,t={},s={}){let{defaultValue:i="copy_key"}=s;return n.forEach(a=>{if(a.choices){let r=[];Array.isArray(a.choices)?r=[a.choices]:r=e.getConditionalsThenElse(a.choices),r.forEach(f=>f.forEach(u=>{if("type"in u){let c=[];u.type==="ifelse"||u.type==="stepswitch"?e.getConditionalsThenElse(u,c):c=[u],c.map(T=>e.getConditionalsThenElse(T.text)).forEach(T=>{Array.isArray(T)&&T.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?e.addKey(t,y,{defaultValue:i}):e.getConditionalsThenElse(y).forEach(m=>{Array.isArray(m)?m.forEach(V=>{typeof V=="string"&&e.addKey(t,V,{defaultValue:i});}):typeof m=="string"&&e.addKey(t,m,{defaultValue:i});});}):typeof g=="string"&&e.addKey(t,g,{defaultValue:i});});});}}));}if(a.dialogue){let r=[];Array.isArray(a.dialogue)?r=[a.dialogue]:r=e.getConditionalsThenElse(a.dialogue),r.forEach(f=>{if(typeof f=="string")e.addKey(t,f,{defaultValue:i});else if("text"in f){let u=e.getConditionalsThenElse(f.text);typeof u=="string"&&(u=[u]),u.forEach(c=>{typeof c=="string"?e.addKey(t,c,{defaultValue:i}):e.getConditionalsThenElse(c).forEach(T=>{typeof T=="string"?e.addKey(t,T,{defaultValue:i}):Array.isArray(T)&&T.forEach(g=>{typeof g=="string"?e.addKey(t,g,{defaultValue:i}):e.getConditionalsThenElse(g).forEach(y=>{typeof y=="string"&&e.addKey(t,y,{defaultValue:i});});});});});}});}a.conditionalStep&&e.getConditionalsThenElse(a.conditionalStep).forEach(f=>{Array.isArray(f)?e.generateJsonTranslation(f,t,s):e.generateJsonTranslation([f],t,s);});}),t}};var J=b;var x;(i=>(i.log=(a,...r)=>console.log(`[Pixi\u2019VN Json] ${a}`,...r),i.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...r),i.error=(a,...r)=>console.error(`[Pixi\u2019VN Json] ${a}`,...r),i.info=(a,...r)=>console.info(`[Pixi\u2019VN Json] ${a}`,...r)))(x||={});function R(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function w(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return L(e);case "ifelse":return o(e.condition)?o(e.then):o(e.else);case "stepswitch":let t=o(e.elements)||[];if(t.length===0){x.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let s=R(0,t.length-1);return o(t[s]);case "loop":let i=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return i>t.length-1&&(i=i%t.length),o(t[i]);case "sequential":let a,r=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(a=o(t[t.length-1])),r>t.length-1?a:o(t[r]);case "sequentialrandom":let f=pixiVn.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(f==null&&e.end=="lastItem"){let u=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=u.usedRandomNumbers[`0-${t.length-1}`];return o(t[c[c.length-1]])}if(f==null){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return o(t[f])}}return e}function A(e){if(e.conditionalStep){let n=pixiVn.createExportableElement(o(e.conditionalStep));if(n?.glueEnabled===void 0&&delete n?.glueEnabled,n?.goNextStep===void 0&&delete n?.goNextStep,n?.end===void 0&&delete n?.end,n?.choices===void 0&&delete n?.choices,n?.dialogue===void 0&&delete n?.dialogue,n?.labelToOpen===void 0&&delete n?.labelToOpen,n?.operations===void 0&&delete n?.operations,n){let t={...e,conditionalStep:void 0,...n};return A(t)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return e}function L(e){let n=e.firstItem,t=[];e.secondConditionalItem?.forEach(i=>{if(Array.isArray(i))i.forEach(a=>{let r=o(a);t.push(r);});else {let a=o(i);t.push(a);}});let s=n?[n,...t]:t;if(s.length===0){x.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return J.t(s);if(typeof s[0]=="object"){let i=s,a,r=i.map((l,h)=>{l=A(l);let d=o(l.dialogue)||"";return h===0?(a=o(l.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),a===false&&(d=`
2
2
 
3
- `+c),a=s(l.glueEnabled)||false,c)}),f=s(r[0]),u=typeof f=="object"&&"character"in f?f.character:void 0,T=r.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let c;return Array.isArray(y)?c=y.map(I=>{let O=s(I);return P.t(`${O}`)}):c=s(y)||"",P.t(c)}),h=i.find(l=>l.end),g=i.find(l=>l.choices),p=false,m=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),p=i[i.length-1].glueEnabled,m=i.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let V=i.find(l=>l.labelToOpen),N=[];return i.forEach(l=>{l.operations&&N.forEach(y=>{N.push(y);});}),{dialogue:u?{character:u,text:T}:T,end:h?.end,choices:g?.choices,glueEnabled:p,goNextStep:m,labelToOpen:V?.labelToOpen,operations:N}}}function G(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let n=s(e.leftValue),t=s(e.rightValue);switch(e.operator){case "==":return n===t;case "!=":return n!==t;case "<":return n<t;case "<=":return n<=t;case ">":return n>t;case ">=":return n>=t;case "CONTAINS":return n.toString().includes(t.toString())}break;case "valueCondition":return !!s(e.value);case "union":return _(e)}return !!e}function k(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return pixiVn.storage.getVariable(e.key);case "flagStorage":return pixiVn.storage.getFlag(e.key);case "label":return pixiVn.narration.getTimesLabelOpened(e.label);case "choice":return pixiVn.narration.getTimesChoiceMade(e.index);case "logic":return s(e.operation);case "params":let n=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];if(n&&n.length>e.key)return n[e.key];x.warn("getValue params not found");return}return e}function _(e){if(e.unionType==="not")return !s(e.condition);let n=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(n=s(e.conditions[t])||false,e.unionType==="and"){if(!n)return false}else if(n)return true;return n}function B(e){let n=s(e.value),t;switch(n&&typeof n=="object"&&"type"in n?t=s(n):t=n,e.storageType){case "flagStorage":pixiVn.storage.setFlag(e.key,e.value);break;case "storage":pixiVn.storage.setVariable(e.key,t);break;case "tempstorage":pixiVn.storage.setTempVariable(e.key,t);break;case "params":let o=pixiVn.storage.getVariable(`${J}${pixiVn.narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=t),pixiVn.storage.setTempVariable(`${J}${pixiVn.narration.openedLabels.length-1}`,o);break}}function s(e){let n=w(e);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case "value":return k(n);case "arithmetic":case "arithmeticsingle":return F(n);case "compare":case "valueCondition":case "union":return G(n)}return n}function F(e){let n=s(e.leftValue);switch(e.type){case "arithmetic":let t=s(e.rightValue);switch(e.operator){case "*":return n*t;case "/":return n/t;case "+":return n+t;case "-":return n-t;case "%":return n%t;case "POW":return Math.pow(n,t);case "RANDOM":return pixiVn.narration.getRandomNumber(n,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(n);case "FLOOR":return Math.floor(n);case "FLOAT":return parseFloat(n)}break}}exports.getConditionalStep=A;exports.getLogichValue=s;exports.setStorageJson=B;
3
+ `+d),a=o(l.glueEnabled)||false,d)}),f=o(r[0]),u=typeof f=="object"&&"character"in f?f.character:void 0,c=r.flatMap(l=>{let h;l&&typeof l=="object"&&"text"in l?h=l.text:h=l;let d;return Array.isArray(h)?d=h.map(I=>{let O=o(I);return J.t(`${O}`)}):d=o(h)||"",J.t(d)}),C=i.find(l=>l.end),T=i.find(l=>l.choices),g=false,y=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),g=i[i.length-1].glueEnabled,y=i.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let m=i.find(l=>l.labelToOpen),V=[];return i.forEach(l=>{l.operations&&V.forEach(h=>{V.push(h);});}),{dialogue:u?{character:u,text:c}:c,end:C?.end,choices:T?.choices,glueEnabled:g,goNextStep:y,labelToOpen:m?.labelToOpen,operations:V}}}function G(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let n=o(e.leftValue),t=o(e.rightValue);switch(e.operator){case "==":return n===t;case "!=":return n!==t;case "<":return n<t;case "<=":return n<=t;case ">":return n>t;case ">=":return n>=t;case "CONTAINS":return n.toString().includes(t.toString())}break;case "valueCondition":return !!o(e.value);case "union":return _(e)}return !!e}function k(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return pixiVn.storage.getVariable(e.key);case "flagStorage":return pixiVn.storage.getFlag(e.key);case "label":return pixiVn.narration.getTimesLabelOpened(e.label);case "choice":return pixiVn.narration.getTimesChoiceMade(e.index);case "logic":return o(e.operation);case "params":let n=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];if(n&&n.length>e.key)return n[e.key];x.warn("getValue params not found");return}return e}function _(e){if(e.unionType==="not")return !o(e.condition);let n=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(n=o(e.conditions[t])||false,e.unionType==="and"){if(!n)return false}else if(n)return true;return n}function B(e){let n=o(e.value),t;switch(n&&typeof n=="object"&&"type"in n?t=o(n):t=n,e.storageType){case "flagStorage":pixiVn.storage.setFlag(e.key,e.value);break;case "storage":pixiVn.storage.setVariable(e.key,t);break;case "tempstorage":pixiVn.storage.setTempVariable(e.key,t);break;case "params":let s=pixiVn.storage.getVariable(`${E}${pixiVn.narration.openedLabels.length-1}`)||[];s&&s.length-1>=e.key&&(s[e.key]=t),pixiVn.storage.setTempVariable(`${E}${pixiVn.narration.openedLabels.length-1}`,s);break}}function o(e){let n=w(e);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case "value":return k(n);case "arithmetic":case "arithmeticsingle":return F(n);case "compare":case "valueCondition":case "union":return G(n)}return n}function F(e){let n=o(e.leftValue);switch(e.type){case "arithmetic":let t=o(e.rightValue);switch(e.operator){case "*":return n*t;case "/":return n/t;case "+":return n+t;case "-":return n-t;case "%":return n%t;case "POW":return Math.pow(n,t);case "RANDOM":return pixiVn.narration.getRandomNumber(n,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(n);case "FLOOR":return Math.floor(n);case "FLOAT":return parseFloat(n)}break}}exports.getConditionalStep=A;exports.getLogichValue=o;exports.setStorageJson=B;
@@ -1,3 +1,3 @@
1
- import {createExportableElement,storage,SYSTEM_RESERVED_STORAGE_KEYS,narration,NarrationManagerStatic}from'@drincs/pixi-vn';var J="___param___";var E=class e{static _beforeToTranslate=void 0;static _translate=n=>n;static _afterToTranslate=void 0;static t(n){return Array.isArray(n)?n.map(t=>e.translate(`${t}`)):e.translate(`${n}`)}static set beforeToTranslate(n){e._beforeToTranslate=n;}static set translate(n){e._translate=n;}static get translate(){return n=>{let t=n;return e._beforeToTranslate&&(t=e._beforeToTranslate(t)),t=e._translate(t),e._afterToTranslate&&(t=e._afterToTranslate(t)),t}}static set afterToTranslate(n){e._afterToTranslate=n;}static addKey(n,t,o){let i=o.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(a=>{n[a]===void 0&&(i==="empty_string"?n[a]="":i==="copy_key"&&(e._beforeToTranslate?n[a]=e._beforeToTranslate(a):n[a]=a));});}static getConditionalsThenElse(n,t=[]){if(typeof n=="object"&&n&&"type"in n)if(n.type==="ifelse")n.then&&e.getConditionalsThenElse(n.then,t),n.else&&e.getConditionalsThenElse(n.else,t);else if(n.type==="stepswitch"){if(n.elements)if(Array.isArray(n.elements))n.elements.forEach(o=>{e.getConditionalsThenElse(o,t);});else if(n.elements.type==="ifelse"){let o=[];e.getConditionalsThenElse(n.elements,o),o.forEach(i=>{t.push(...i);});}else if(n.elements.type==="stepswitch"){let o=[];e.getConditionalsThenElse(n.elements,o),o.forEach(i=>{t.push(...i);});}else e.getConditionalsThenElse(n.elements,t);}else n.type==="resulttocombine"?(n.firstItem&&e.getConditionalsThenElse(n.firstItem,t),n.secondConditionalItem&&n.secondConditionalItem.forEach(o=>{e.getConditionalsThenElse(o,t);})):t.push(n);else n&&t.push(n);return t}static generateJsonTranslation(n,t={},o={}){let{defaultValue:i="copy_key"}=o;return n.forEach(a=>{if(a.choices){let r=[];Array.isArray(a.choices)?r=[a.choices]:r=e.getConditionalsThenElse(a.choices),r.forEach(f=>f.forEach(u=>{if("type"in u){let T=[];u.type==="ifelse"||u.type==="stepswitch"?e.getConditionalsThenElse(u,T):T=[u],T.map(g=>e.getConditionalsThenElse(g.text)).forEach(g=>{Array.isArray(g)&&g.forEach(p=>{Array.isArray(p)?p.forEach(m=>{typeof m=="string"?e.addKey(t,m,{defaultValue:i}):e.getConditionalsThenElse(m).forEach(V=>{Array.isArray(V)?V.forEach(N=>{typeof N=="string"&&e.addKey(t,N,{defaultValue:i});}):typeof V=="string"&&e.addKey(t,V,{defaultValue:i});});}):typeof p=="string"&&e.addKey(t,p,{defaultValue:i});});});}}));}if(a.dialogue){let r=[];Array.isArray(a.dialogue)?r=[a.dialogue]:r=e.getConditionalsThenElse(a.dialogue),r.forEach(f=>{typeof f=="string"?e.addKey(t,f,{defaultValue:i}):"text"in f&&Array.isArray(f.text)&&f.text.forEach(u=>{typeof u=="string"?e.addKey(t,u,{defaultValue:i}):e.getConditionalsThenElse(u).forEach(h=>{typeof h=="string"?e.addKey(t,h,{defaultValue:i}):Array.isArray(h)&&h.forEach(g=>{typeof g=="string"?e.addKey(t,g,{defaultValue:i}):e.getConditionalsThenElse(g).forEach(p=>{typeof p=="string"&&e.addKey(t,p,{defaultValue:i});});});});});});}a.conditionalStep&&e.getConditionalsThenElse(a.conditionalStep).forEach(f=>{Array.isArray(f)?e.generateJsonTranslation(f,t,o):e.generateJsonTranslation([f],t,o);});}),t}};var P=E;var x;(i=>(i.log=(a,...r)=>console.log(`[Pixi\u2019VN Json] ${a}`,...r),i.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...r),i.error=(a,...r)=>console.error(`[Pixi\u2019VN Json] ${a}`,...r),i.info=(a,...r)=>console.info(`[Pixi\u2019VN Json] ${a}`,...r)))(x||={});function R(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function w(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return L(e);case "ifelse":return s(e.condition)?s(e.then):s(e.else);case "stepswitch":let t=s(e.elements)||[];if(t.length===0){x.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=R(0,t.length-1);return s(t[o]);case "loop":let i=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return i>t.length-1&&(i=i%t.length),s(t[i]);case "sequential":let a,r=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(a=s(t[t.length-1])),r>t.length-1?a:s(t[r]);case "sequentialrandom":let f=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(f==null&&e.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let T=u.usedRandomNumbers[`0-${t.length-1}`];return s(t[T[T.length-1]])}if(f==null){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(t[f])}}return e}function A(e){if(e.conditionalStep){let n=createExportableElement(s(e.conditionalStep));if(n?.glueEnabled===void 0&&delete n?.glueEnabled,n?.goNextStep===void 0&&delete n?.goNextStep,n?.end===void 0&&delete n?.end,n?.choices===void 0&&delete n?.choices,n?.dialogue===void 0&&delete n?.dialogue,n?.labelToOpen===void 0&&delete n?.labelToOpen,n?.operations===void 0&&delete n?.operations,n){let t={...e,conditionalStep:void 0,...n};return A(t)}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 e}function L(e){let n=e.firstItem,t=[];e.secondConditionalItem?.forEach(i=>{if(Array.isArray(i))i.forEach(a=>{let r=s(a);t.push(r);});else {let a=s(i);t.push(a);}});let o=n?[n,...t]:t;if(o.length===0){x.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return P.t(o);if(typeof o[0]=="object"){let i=o,a,r=i.map((l,y)=>{l=A(l);let c=s(l.dialogue)||"";return y===0?(a=s(l.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),a===false&&(c=`
1
+ import {createExportableElement,storage,SYSTEM_RESERVED_STORAGE_KEYS,narration,NarrationManagerStatic}from'@drincs/pixi-vn';var E="___param___";var b=class e{static _beforeToTranslate=void 0;static _translate=n=>n;static _afterToTranslate=void 0;static t(n){return Array.isArray(n)?n.map(t=>e.translate(`${t}`)):e.translate(`${n}`)}static set beforeToTranslate(n){e._beforeToTranslate=n;}static set translate(n){e._translate=n;}static get translate(){return n=>{let t=n;return e._beforeToTranslate&&(t=e._beforeToTranslate(t)),t=e._translate(t),e._afterToTranslate&&(t=e._afterToTranslate(t)),t}}static set afterToTranslate(n){e._afterToTranslate=n;}static addKey(n,t,s){let i=s.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(a=>{n[a]===void 0&&(i==="empty_string"?n[a]="":i==="copy_key"&&(e._beforeToTranslate?n[a]=e._beforeToTranslate(a):n[a]=a));});}static getConditionalsThenElse(n,t=[]){if(typeof n=="object"&&n&&"type"in n)if(n.type==="ifelse")n.then&&e.getConditionalsThenElse(n.then,t),n.else&&e.getConditionalsThenElse(n.else,t);else if(n.type==="stepswitch"){if(n.elements)if(Array.isArray(n.elements))n.elements.forEach(s=>{e.getConditionalsThenElse(s,t);});else if(n.elements.type==="ifelse"){let s=[];e.getConditionalsThenElse(n.elements,s),s.forEach(i=>{t.push(...i);});}else if(n.elements.type==="stepswitch"){let s=[];e.getConditionalsThenElse(n.elements,s),s.forEach(i=>{t.push(...i);});}else e.getConditionalsThenElse(n.elements,t);}else n.type==="resulttocombine"?(n.firstItem&&e.getConditionalsThenElse(n.firstItem,t),n.secondConditionalItem&&n.secondConditionalItem.forEach(s=>{e.getConditionalsThenElse(s,t);})):t.push(n);else n&&t.push(n);return t}static generateJsonTranslation(n,t={},s={}){let{defaultValue:i="copy_key"}=s;return n.forEach(a=>{if(a.choices){let r=[];Array.isArray(a.choices)?r=[a.choices]:r=e.getConditionalsThenElse(a.choices),r.forEach(f=>f.forEach(u=>{if("type"in u){let c=[];u.type==="ifelse"||u.type==="stepswitch"?e.getConditionalsThenElse(u,c):c=[u],c.map(T=>e.getConditionalsThenElse(T.text)).forEach(T=>{Array.isArray(T)&&T.forEach(g=>{Array.isArray(g)?g.forEach(y=>{typeof y=="string"?e.addKey(t,y,{defaultValue:i}):e.getConditionalsThenElse(y).forEach(m=>{Array.isArray(m)?m.forEach(V=>{typeof V=="string"&&e.addKey(t,V,{defaultValue:i});}):typeof m=="string"&&e.addKey(t,m,{defaultValue:i});});}):typeof g=="string"&&e.addKey(t,g,{defaultValue:i});});});}}));}if(a.dialogue){let r=[];Array.isArray(a.dialogue)?r=[a.dialogue]:r=e.getConditionalsThenElse(a.dialogue),r.forEach(f=>{if(typeof f=="string")e.addKey(t,f,{defaultValue:i});else if("text"in f){let u=e.getConditionalsThenElse(f.text);typeof u=="string"&&(u=[u]),u.forEach(c=>{typeof c=="string"?e.addKey(t,c,{defaultValue:i}):e.getConditionalsThenElse(c).forEach(T=>{typeof T=="string"?e.addKey(t,T,{defaultValue:i}):Array.isArray(T)&&T.forEach(g=>{typeof g=="string"?e.addKey(t,g,{defaultValue:i}):e.getConditionalsThenElse(g).forEach(y=>{typeof y=="string"&&e.addKey(t,y,{defaultValue:i});});});});});}});}a.conditionalStep&&e.getConditionalsThenElse(a.conditionalStep).forEach(f=>{Array.isArray(f)?e.generateJsonTranslation(f,t,s):e.generateJsonTranslation([f],t,s);});}),t}};var J=b;var x;(i=>(i.log=(a,...r)=>console.log(`[Pixi\u2019VN Json] ${a}`,...r),i.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Json] ${a}`,...r),i.error=(a,...r)=>console.error(`[Pixi\u2019VN Json] ${a}`,...r),i.info=(a,...r)=>console.info(`[Pixi\u2019VN Json] ${a}`,...r)))(x||={});function R(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function w(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return L(e);case "ifelse":return o(e.condition)?o(e.then):o(e.else);case "stepswitch":let t=o(e.elements)||[];if(t.length===0){x.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let s=R(0,t.length-1);return o(t[s]);case "loop":let i=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return i>t.length-1&&(i=i%t.length),o(t[i]);case "sequential":let a,r=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(a=o(t[t.length-1])),r>t.length-1?a:o(t[r]);case "sequentialrandom":let f=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:true});if(f==null&&e.end=="lastItem"){let u=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!u||!u?.usedRandomNumbers){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=u.usedRandomNumbers[`0-${t.length-1}`];return o(t[c[c.length-1]])}if(f==null){x.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return o(t[f])}}return e}function A(e){if(e.conditionalStep){let n=createExportableElement(o(e.conditionalStep));if(n?.glueEnabled===void 0&&delete n?.glueEnabled,n?.goNextStep===void 0&&delete n?.goNextStep,n?.end===void 0&&delete n?.end,n?.choices===void 0&&delete n?.choices,n?.dialogue===void 0&&delete n?.dialogue,n?.labelToOpen===void 0&&delete n?.labelToOpen,n?.operations===void 0&&delete n?.operations,n){let t={...e,conditionalStep:void 0,...n};return A(t)}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 e}function L(e){let n=e.firstItem,t=[];e.secondConditionalItem?.forEach(i=>{if(Array.isArray(i))i.forEach(a=>{let r=o(a);t.push(r);});else {let a=o(i);t.push(a);}});let s=n?[n,...t]:t;if(s.length===0){x.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return J.t(s);if(typeof s[0]=="object"){let i=s,a,r=i.map((l,h)=>{l=A(l);let d=o(l.dialogue)||"";return h===0?(a=o(l.glueEnabled)||false,d):(typeof d=="object"&&"text"in d&&(d=d.character+": "+d.text),a===false&&(d=`
2
2
 
3
- `+c),a=s(l.glueEnabled)||false,c)}),f=s(r[0]),u=typeof f=="object"&&"character"in f?f.character:void 0,T=r.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let c;return Array.isArray(y)?c=y.map(I=>{let O=s(I);return P.t(`${O}`)}):c=s(y)||"",P.t(c)}),h=i.find(l=>l.end),g=i.find(l=>l.choices),p=false,m=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),p=i[i.length-1].glueEnabled,m=i.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let V=i.find(l=>l.labelToOpen),N=[];return i.forEach(l=>{l.operations&&N.forEach(y=>{N.push(y);});}),{dialogue:u?{character:u,text:T}:T,end:h?.end,choices:g?.choices,glueEnabled:p,goNextStep:m,labelToOpen:V?.labelToOpen,operations:N}}}function G(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let n=s(e.leftValue),t=s(e.rightValue);switch(e.operator){case "==":return n===t;case "!=":return n!==t;case "<":return n<t;case "<=":return n<=t;case ">":return n>t;case ">=":return n>=t;case "CONTAINS":return n.toString().includes(t.toString())}break;case "valueCondition":return !!s(e.value);case "union":return _(e)}return !!e}function k(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.getVariable(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return s(e.operation);case "params":let n=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];if(n&&n.length>e.key)return n[e.key];x.warn("getValue params not found");return}return e}function _(e){if(e.unionType==="not")return !s(e.condition);let n=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(n=s(e.conditions[t])||false,e.unionType==="and"){if(!n)return false}else if(n)return true;return n}function B(e){let n=s(e.value),t;switch(n&&typeof n=="object"&&"type"in n?t=s(n):t=n,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,t);break;case "tempstorage":storage.setTempVariable(e.key,t);break;case "params":let o=storage.getVariable(`${J}${narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=t),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,o);break}}function s(e){let n=w(e);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case "value":return k(n);case "arithmetic":case "arithmeticsingle":return F(n);case "compare":case "valueCondition":case "union":return G(n)}return n}function F(e){let n=s(e.leftValue);switch(e.type){case "arithmetic":let t=s(e.rightValue);switch(e.operator){case "*":return n*t;case "/":return n/t;case "+":return n+t;case "-":return n-t;case "%":return n%t;case "POW":return Math.pow(n,t);case "RANDOM":return narration.getRandomNumber(n,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(n);case "FLOOR":return Math.floor(n);case "FLOAT":return parseFloat(n)}break}}export{A as getConditionalStep,s as getLogichValue,B as setStorageJson};
3
+ `+d),a=o(l.glueEnabled)||false,d)}),f=o(r[0]),u=typeof f=="object"&&"character"in f?f.character:void 0,c=r.flatMap(l=>{let h;l&&typeof l=="object"&&"text"in l?h=l.text:h=l;let d;return Array.isArray(h)?d=h.map(I=>{let O=o(I);return J.t(`${O}`)}):d=o(h)||"",J.t(d)}),C=i.find(l=>l.end),T=i.find(l=>l.choices),g=false,y=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),g=i[i.length-1].glueEnabled,y=i.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let m=i.find(l=>l.labelToOpen),V=[];return i.forEach(l=>{l.operations&&V.forEach(h=>{V.push(h);});}),{dialogue:u?{character:u,text:c}:c,end:C?.end,choices:T?.choices,glueEnabled:g,goNextStep:y,labelToOpen:m?.labelToOpen,operations:V}}}function G(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let n=o(e.leftValue),t=o(e.rightValue);switch(e.operator){case "==":return n===t;case "!=":return n!==t;case "<":return n<t;case "<=":return n<=t;case ">":return n>t;case ">=":return n>=t;case "CONTAINS":return n.toString().includes(t.toString())}break;case "valueCondition":return !!o(e.value);case "union":return _(e)}return !!e}function k(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return storage.getVariable(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return o(e.operation);case "params":let n=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];if(n&&n.length>e.key)return n[e.key];x.warn("getValue params not found");return}return e}function _(e){if(e.unionType==="not")return !o(e.condition);let n=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(n=o(e.conditions[t])||false,e.unionType==="and"){if(!n)return false}else if(n)return true;return n}function B(e){let n=o(e.value),t;switch(n&&typeof n=="object"&&"type"in n?t=o(n):t=n,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.setVariable(e.key,t);break;case "tempstorage":storage.setTempVariable(e.key,t);break;case "params":let s=storage.getVariable(`${E}${narration.openedLabels.length-1}`)||[];s&&s.length-1>=e.key&&(s[e.key]=t),storage.setTempVariable(`${E}${narration.openedLabels.length-1}`,s);break}}function o(e){let n=w(e);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case "value":return k(n);case "arithmetic":case "arithmeticsingle":return F(n);case "compare":case "valueCondition":case "union":return G(n)}return n}function F(e){let n=o(e.leftValue);switch(e.type){case "arithmetic":let t=o(e.rightValue);switch(e.operator){case "*":return n*t;case "/":return n/t;case "+":return n+t;case "-":return n-t;case "%":return n%t;case "POW":return Math.pow(n,t);case "RANDOM":return narration.getRandomNumber(n,t)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(n);case "FLOOR":return Math.floor(n);case "FLOAT":return parseFloat(n)}break}}export{A as getConditionalStep,o as getLogichValue,B as setStorageJson};
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';var pixiVn=require('@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 j=(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 j=="function")try{r=j("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 u;return n.prototype=s,u=new n,n.prototype=null,u}})(),c={},l=c.lib={},f=l.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=l.WordArray=f.extend({init:function(n,s){n=this.words=n||[],s!=e?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||y).stringify(this)},concat:function(n){var s=this.words,u=n.words,T=this.sigBytes,P=n.sigBytes;if(this.clamp(),T%4)for(var S=0;S<P;S++){var W=u[S>>>2]>>>24-S%4*8&255;s[T+S>>>2]|=W<<24-(T+S)%4*8;}else for(var E=0;E<P;E+=4)s[T+E>>>2]=u[E>>>2];return this.sigBytes+=P,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=f.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],u=0;u<n;u+=4)s.push(a());return new g.init(s,n)}}),d=c.enc={},y=d.Hex={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push((S>>>4).toString(16)),T.push((S&15).toString(16));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T+=2)u[T>>>3]|=parseInt(n.substr(T,2),16)<<24-T%8*4;return new g.init(u,s/2)}},m=d.Latin1={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push(String.fromCharCode(S));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T++)u[T>>>2]|=(n.charCodeAt(T)&255)<<24-T%4*8;return new g.init(u,s)}},x=d.Utf8={stringify:function(n){try{return decodeURIComponent(escape(m.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return m.parse(unescape(encodeURIComponent(n)))}},h=l.BufferedBlockAlgorithm=f.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,u=this._data,T=u.words,P=u.sigBytes,S=this.blockSize,W=S*4,E=P/W;n?E=t.ceil(E):E=t.max((E|0)-this._minBufferSize,0);var D=E*S,Z=t.min(D*4,P);if(D){for(var K=0;K<D;K+=S)this._doProcessBlock(T,K);s=T.splice(0,D),u.sigBytes-=Z;}return new g.init(s,Z)},clone:function(){var n=f.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});l.Hasher=h.extend({cfg:f.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){h.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,u){return new n.init(u).finalize(s)}},_createHmacHelper:function(n){return function(s,u){return new b.HMAC.init(n,u).finalize(s)}}});var b=c.algo={};return c})(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,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(f,g){for(var d=this._hash.words,y=d[0],m=d[1],x=d[2],h=d[3],N=d[4],b=0;b<80;b++){if(b<16)c[b]=f[g+b]|0;else {var n=c[b-3]^c[b-8]^c[b-14]^c[b-16];c[b]=n<<1|n>>>31;}var s=(y<<5|y>>>27)+N+c[b];b<20?s+=(m&x|~m&h)+1518500249:b<40?s+=(m^x^h)+1859775393:b<60?s+=(m&x|m&h|x&h)-1894007588:s+=(m^x^h)-899497514,N=h,h=x,x=m<<30|m>>>2,m=y,y=s;}d[0]=d[0]+y|0,d[1]=d[1]+m|0,d[2]=d[2]+x|0,d[3]=d[3]+h|0,d[4]=d[4]+N|0;},_doFinalize:function(){var f=this._data,g=f.words,d=this._nDataBytes*8,y=f.sigBytes*8;return g[y>>>5]|=128<<24-y%32,g[(y+64>>>9<<4)+14]=Math.floor(d/4294967296),g[(y+64>>>9<<4)+15]=d,f.sigBytes=g.length*4,this._process(),this._hash},clone:function(){var f=a.clone.call(this);return f._hash=this._hash.clone(),f}});t.SHA1=a._createHelper(l),t.HmacSHA1=a._createHmacHelper(l);})(),i.SHA1});});var se=de(re());var k="___param___";var w=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={}){let{defaultValue:a="copy_key"}=r;return t.forEach(o=>{if(o.choices){let c=[];Array.isArray(o.choices)?c=[o.choices]:c=i.getConditionalsThenElse(o.choices),c.forEach(l=>l.forEach(f=>{if("type"in f){let g=[];f.type==="ifelse"||f.type==="stepswitch"?i.getConditionalsThenElse(f,g):g=[f],g.map(y=>i.getConditionalsThenElse(y.text)).forEach(y=>{Array.isArray(y)&&y.forEach(m=>{Array.isArray(m)?m.forEach(x=>{typeof x=="string"?i.addKey(e,x,{defaultValue:a}):i.getConditionalsThenElse(x).forEach(h=>{Array.isArray(h)?h.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});}):typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});}}));}if(o.dialogue){let c=[];Array.isArray(o.dialogue)?c=[o.dialogue]:c=i.getConditionalsThenElse(o.dialogue),c.forEach(l=>{typeof l=="string"?i.addKey(e,l,{defaultValue:a}):"text"in l&&Array.isArray(l.text)&&l.text.forEach(f=>{typeof f=="string"?i.addKey(e,f,{defaultValue:a}):i.getConditionalsThenElse(f).forEach(d=>{typeof d=="string"?i.addKey(e,d,{defaultValue:a}):Array.isArray(d)&&d.forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):i.getConditionalsThenElse(y).forEach(m=>{typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});});});});}o.conditionalStep&&i.getConditionalsThenElse(o.conditionalStep).forEach(l=>{Array.isArray(l)?i.generateJsonTranslation(l,e,r):i.generateJsonTranslation([l],e,r);});}),e}};var $=w;var V;(a=>(a.log=(o,...c)=>console.log(`[Pixi\u2019VN Json] ${o}`,...c),a.warn=(o,...c)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...c),a.error=(o,...c)=>console.error(`[Pixi\u2019VN Json] ${o}`,...c),a.info=(o,...c)=>console.info(`[Pixi\u2019VN Json] ${o}`,...c)))(V||={});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){V.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=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),p(e[a]);case "sequential":let o,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(o=p(e[e.length-1])),c>e.length-1?o:p(e[c]);case "sequentialrandom":let l=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(l==null&&i.end=="lastItem"){let f=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!f||!f?.usedRandomNumbers){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let g=f.usedRandomNumbers[`0-${e.length-1}`];return p(e[g[g.length-1]])}if(l==null){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return p(e[l])}}return i}function L(i){if(i.conditionalStep){let t=pixiVn.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 L(e)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.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 c=p(o);e.push(c);});else {let o=p(a);e.push(o);}});let r=t?[t,...e]:e;if(r.length===0){V.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return $.t(r);if(typeof r[0]=="object"){let a=r,o,c=a.map((n,s)=>{n=L(n);let u=p(n.dialogue)||"";return s===0?(o=p(n.glueEnabled)||false,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===false&&(u=`
1
+ 'use strict';var pixiVn=require('@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 j=(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 j=="function")try{r=j("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 u;return n.prototype=s,u=new n,n.prototype=null,u}})(),c={},l=c.lib={},f=l.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)}}})(),d=l.WordArray=f.extend({init:function(n,s){n=this.words=n||[],s!=e?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||y).stringify(this)},concat:function(n){var s=this.words,u=n.words,T=this.sigBytes,P=n.sigBytes;if(this.clamp(),T%4)for(var S=0;S<P;S++){var W=u[S>>>2]>>>24-S%4*8&255;s[T+S>>>2]|=W<<24-(T+S)%4*8;}else for(var E=0;E<P;E+=4)s[T+E>>>2]=u[E>>>2];return this.sigBytes+=P,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=f.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],u=0;u<n;u+=4)s.push(a());return new d.init(s,n)}}),g=c.enc={},y=g.Hex={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push((S>>>4).toString(16)),T.push((S&15).toString(16));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T+=2)u[T>>>3]|=parseInt(n.substr(T,2),16)<<24-T%8*4;return new d.init(u,s/2)}},x=g.Latin1={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push(String.fromCharCode(S));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T++)u[T>>>2]|=(n.charCodeAt(T)&255)<<24-T%4*8;return new d.init(u,s)}},m=g.Utf8={stringify:function(n){try{return decodeURIComponent(escape(x.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return x.parse(unescape(encodeURIComponent(n)))}},h=l.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=m.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var s,u=this._data,T=u.words,P=u.sigBytes,S=this.blockSize,W=S*4,E=P/W;n?E=t.ceil(E):E=t.max((E|0)-this._minBufferSize,0);var D=E*S,Z=t.min(D*4,P);if(D){for(var K=0;K<D;K+=S)this._doProcessBlock(T,K);s=T.splice(0,D),u.sigBytes-=Z;}return new d.init(s,Z)},clone:function(){var n=f.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});l.Hasher=h.extend({cfg:f.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){h.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,u){return new n.init(u).finalize(s)}},_createHmacHelper:function(n){return function(s,u){return new b.HMAC.init(n,u).finalize(s)}}});var b=c.algo={};return c})(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,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(f,d){for(var g=this._hash.words,y=g[0],x=g[1],m=g[2],h=g[3],N=g[4],b=0;b<80;b++){if(b<16)c[b]=f[d+b]|0;else {var n=c[b-3]^c[b-8]^c[b-14]^c[b-16];c[b]=n<<1|n>>>31;}var s=(y<<5|y>>>27)+N+c[b];b<20?s+=(x&m|~x&h)+1518500249:b<40?s+=(x^m^h)+1859775393:b<60?s+=(x&m|x&h|m&h)-1894007588:s+=(x^m^h)-899497514,N=h,h=m,m=x<<30|x>>>2,x=y,y=s;}g[0]=g[0]+y|0,g[1]=g[1]+x|0,g[2]=g[2]+m|0,g[3]=g[3]+h|0,g[4]=g[4]+N|0;},_doFinalize:function(){var f=this._data,d=f.words,g=this._nDataBytes*8,y=f.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(g/4294967296),d[(y+64>>>9<<4)+15]=g,f.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var f=a.clone.call(this);return f._hash=this._hash.clone(),f}});t.SHA1=a._createHelper(l),t.HmacSHA1=a._createHmacHelper(l);})(),i.SHA1});});var se=de(re());var k="___param___";var w=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={}){let{defaultValue:a="copy_key"}=r;return t.forEach(o=>{if(o.choices){let c=[];Array.isArray(o.choices)?c=[o.choices]:c=i.getConditionalsThenElse(o.choices),c.forEach(l=>l.forEach(f=>{if("type"in f){let d=[];f.type==="ifelse"||f.type==="stepswitch"?i.getConditionalsThenElse(f,d):d=[f],d.map(y=>i.getConditionalsThenElse(y.text)).forEach(y=>{Array.isArray(y)&&y.forEach(x=>{Array.isArray(x)?x.forEach(m=>{typeof m=="string"?i.addKey(e,m,{defaultValue:a}):i.getConditionalsThenElse(m).forEach(h=>{Array.isArray(h)?h.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});}):typeof x=="string"&&i.addKey(e,x,{defaultValue:a});});});}}));}if(o.dialogue){let c=[];Array.isArray(o.dialogue)?c=[o.dialogue]:c=i.getConditionalsThenElse(o.dialogue),c.forEach(l=>{if(typeof l=="string")i.addKey(e,l,{defaultValue:a});else if("text"in l){let f=i.getConditionalsThenElse(l.text);typeof f=="string"&&(f=[f]),f.forEach(d=>{typeof d=="string"?i.addKey(e,d,{defaultValue:a}):i.getConditionalsThenElse(d).forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):Array.isArray(y)&&y.forEach(x=>{typeof x=="string"?i.addKey(e,x,{defaultValue:a}):i.getConditionalsThenElse(x).forEach(m=>{typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});});});}});}o.conditionalStep&&i.getConditionalsThenElse(o.conditionalStep).forEach(l=>{Array.isArray(l)?i.generateJsonTranslation(l,e,r):i.generateJsonTranslation([l],e,r);});}),e}};var $=w;var V;(a=>(a.log=(o,...c)=>console.log(`[Pixi\u2019VN Json] ${o}`,...c),a.warn=(o,...c)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...c),a.error=(o,...c)=>console.error(`[Pixi\u2019VN Json] ${o}`,...c),a.info=(o,...c)=>console.info(`[Pixi\u2019VN Json] ${o}`,...c)))(V||={});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){V.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=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),p(e[a]);case "sequential":let o,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(o=p(e[e.length-1])),c>e.length-1?o:p(e[c]);case "sequentialrandom":let l=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(l==null&&i.end=="lastItem"){let f=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!f||!f?.usedRandomNumbers){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=f.usedRandomNumbers[`0-${e.length-1}`];return p(e[d[d.length-1]])}if(l==null){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return p(e[l])}}return i}function L(i){if(i.conditionalStep){let t=pixiVn.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 L(e)}else pixiVn.storage.getFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.storage.setFlag(pixiVn.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 c=p(o);e.push(c);});else {let o=p(a);e.push(o);}});let r=t?[t,...e]:e;if(r.length===0){V.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return $.t(r);if(typeof r[0]=="object"){let a=r,o,c=a.map((n,s)=>{n=L(n);let u=p(n.dialogue)||"";return s===0?(o=p(n.glueEnabled)||false,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===false&&(u=`
2
2
 
3
- `+u),o=p(n.glueEnabled)||false,u)}),l=p(c[0]),f=typeof l=="object"&&"character"in l?l.character:void 0,g=c.flatMap(n=>{let s;n&&typeof n=="object"&&"text"in n?s=n.text:s=n;let u;return Array.isArray(s)?u=s.map(T=>{let P=p(T);return $.t(`${P}`)}):u=p(s)||"",$.t(u)}),d=a.find(n=>n.end),y=a.find(n=>n.choices),m=false,x=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.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(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let h=a.find(n=>n.labelToOpen),N=[];return a.forEach(n=>{n.operations&&N.forEach(s=>{N.push(s);});}),{dialogue:f?{character:f,text:g}:g,end:d?.end,choices:y?.choices,glueEnabled:m,goNextStep:x,labelToOpen:h?.labelToOpen,operations:N}}}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 pixiVn.storage.getVariable(i.key);case "flagStorage":return pixiVn.storage.getFlag(i.key);case "label":return pixiVn.narration.getTimesLabelOpened(i.label);case "choice":return pixiVn.narration.getTimesChoiceMade(i.index);case "logic":return p(i.operation);case "params":let t=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];V.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":pixiVn.storage.setFlag(i.key,i.value);break;case "storage":pixiVn.storage.setVariable(i.key,e);break;case "tempstorage":pixiVn.storage.setTempVariable(i.key,e);break;case "params":let r=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=e),pixiVn.storage.setTempVariable(`${k}${pixiVn.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 pixiVn.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 pixiVn.Assets.load(t.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await pixiVn.Assets.loadBundle(t.aliases);break;case "lazyload":pixiVn.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":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(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 "assets":case "bundle":await H(e);break;case "image":switch(e.operationType){case "show":let l=new pixiVn.ImageSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=pixiVn.canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Image with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "video":switch(e.operationType){case "show":let l=new pixiVn.VideoSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=pixiVn.canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Video with alias ${e.alias} not found.`);break;case "remove":M(e);break;case "pause":let g=pixiVn.canvas.find(e.alias);g?g.paused=true:V.error(`Video with alias ${e.alias} not found.`);break;case "resume":let d=pixiVn.canvas.find(e.alias);d?d.paused=false:V.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let l=new pixiVn.ImageContainer(e.props,e.urls);await Y(l,e);break;case "edit":let f=pixiVn.canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let l=pixiVn.canvas.find(e.alias);l?e.props&&(l.memory={...l.memory,...e.props}):V.error(`Canvas Element with alias ${e.alias} not found.`);}catch(l){V.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,l);}break;case "remove":M(e);break}break;case "value":X(e);break;case "operationtoconvert":if(t){let l="";e.values.forEach(g=>{if(typeof g=="string")l+=g;else {let d=p(g);l+=`${d}`;}});let f=await t(l);f&&await I(f,t);}break;case "input":switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let r=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,r);break;case "move":let a=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break;case "rotate":let o=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,o);break;case "zoom":let c=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,c);break;case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}async function Y(i,t){if(t.transition)switch(t.transition.type){case "fade":await pixiVn.showWithFade(t.alias,i,t.transition.props,t.transition.priority);break;case "dissolve":await pixiVn.showWithDissolve(t.alias,i,t.transition.props,t.transition.priority);break;case "movein":case "moveout":await pixiVn.moveIn(t.alias,i,t.transition.props,t.transition.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(t.alias,i,t.transition.props,t.transition.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(t.alias,i,t.transition.props,t.transition.priority);break}else await i.load(),pixiVn.canvas.add(t.alias,i);}function M(i){if(i.transition)switch(i.transition.type){case "fade":pixiVn.removeWithFade(i.alias,i.transition.props,i.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(i.alias,i.transition.props,i.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(i.alias,i.transition.props,i.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(i.alias,i.transition.props,i.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(i.alias,i.transition.props,i.transition.priority);break}else pixiVn.canvas.remove(i.alias);}var _=class extends pixiVn.LabelAbstract{constructor(t,e,r,a={}){r||(r={}),r.onLoadingLabel=async()=>{for(let o of e){let c;if(typeof o=="function"?c=o():c=o,c=L(c),c.operations){let l=c.operations.map(f=>H(f));await Promise.all(l);}}},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:w.t(this.getDialogueText(e.text))}:w.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=typeof t=="function"?t():t;r=pixiVn.createExportableElement(r),r=L(r);let a=this.operationStringConvert?x=>this.operationStringConvert(x,r,e):void 0,{operations:o=[]}=r;for(let x of o)await I(x,a);let{labelToOpen:c=[]}=r,l=this.getChoices(r.choices),f=p(r.glueEnabled),g=this.getDialogue(r.dialogue),d=[];Array.isArray(c)||(c=[c]),c.forEach(x=>{let h=p(x);h&&d.push(h);});let y=p(r.goNextStep),m=p(r.end);if(l){let x=l.map(h=>{let N="";if(Array.isArray(h.text)){let n=[];h.text.forEach(s=>{if(typeof s=="string")n.push(w.t(s));else if(s&&typeof s=="object"){let u=p(s);u&&!Array.isArray(u)&&typeof u=="object"&&(u=p(u)||""),u&&(Array.isArray(u)?n=n.concat(w.t(u)):n.push(w.t(u)));}}),N=n;}else typeof h.text=="string"&&(N=w.t(h.text));return {label:h.label,text:N,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});pixiVn.narration.choiceMenuOptions=x;}else pixiVn.narration.choiceMenuOptions=void 0;g!==void 0&&(pixiVn.narration.dialogue=g,this.skipEmptyDialogs&&typeof g=="string"&&(g===""||RegExp(/^\s+$/).test(g))&&(y=true)),f?pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):f===false&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let x of d){let h=x.label;typeof h=="object"&&(h=p(h)||"");let N=x.params?.map(b=>p(b));e={...e,...x.props},x.type==="jump"?(pixiVn.narration.openedLabels.length>0&&pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${k}${pixiVn.narration.openedLabels.length}`,N),await pixiVn.narration.callLabel(h,e)):(pixiVn.storage.setTempVariable(`${k}${pixiVn.narration.openedLabels.length}`,N),await pixiVn.narration.callLabel(h,e));}m==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e,{runNow:true})):m==="label_end"&&pixiVn.narration.closeCurrentLabel(),y&&await pixiVn.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 {V.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let a=i.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(f){V.error("Error parsing imported Pixi'VN JSON",f),l={};}return l}),c=(await Promise.all(a)).map(async l=>{let f=[];if(l.initialOperations){l.initialOperations.forEach(d=>{let y=I(d,e?m=>e(m,{},{}):void 0);f.push(y);});let g={};[...pixiVn.storage.storage.keys()].forEach((d,y)=>{g[d]=pixiVn.storage.storage.get(d);}),pixiVn.storage.startingStorage=g;}if(l.labels){let g=l.labels;for(let d in g)try{let y=g[d],m=new _(d,y,void 0,t);pixiVn.RegisteredLabels.add(m);}catch(y){V.error(`Error creating JSON label ${d}`,y);}}return Promise.all(f)});await Promise.all(c);}exports.LabelJson=_;exports.PIXIVNJSON_PARAM_ID=k;exports.getLogichValue=p;exports.importPixiVNJson=ze;exports.setStorageJson=X;exports.translator=$;
3
+ `+u),o=p(n.glueEnabled)||false,u)}),l=p(c[0]),f=typeof l=="object"&&"character"in l?l.character:void 0,d=c.flatMap(n=>{let s;n&&typeof n=="object"&&"text"in n?s=n.text:s=n;let u;return Array.isArray(s)?u=s.map(T=>{let P=p(T);return $.t(`${P}`)}):u=p(s)||"",$.t(u)}),g=a.find(n=>n.end),y=a.find(n=>n.choices),x=false,m=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),x=a[a.length-1].glueEnabled,m=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let h=a.find(n=>n.labelToOpen),N=[];return a.forEach(n=>{n.operations&&N.forEach(s=>{N.push(s);});}),{dialogue:f?{character:f,text:d}:d,end:g?.end,choices:y?.choices,glueEnabled:x,goNextStep:m,labelToOpen:h?.labelToOpen,operations:N}}}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 pixiVn.storage.getVariable(i.key);case "flagStorage":return pixiVn.storage.getFlag(i.key);case "label":return pixiVn.narration.getTimesLabelOpened(i.label);case "choice":return pixiVn.narration.getTimesChoiceMade(i.index);case "logic":return p(i.operation);case "params":let t=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];V.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":pixiVn.storage.setFlag(i.key,i.value);break;case "storage":pixiVn.storage.setVariable(i.key,e);break;case "tempstorage":pixiVn.storage.setTempVariable(i.key,e);break;case "params":let r=pixiVn.storage.getVariable(`${k}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=e),pixiVn.storage.setTempVariable(`${k}${pixiVn.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 pixiVn.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 pixiVn.Assets.load(t.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await pixiVn.Assets.loadBundle(t.aliases);break;case "lazyload":pixiVn.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":pixiVn.sound.play(e.alias,e.props);break;case "stop":pixiVn.sound.stop(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 "assets":case "bundle":await H(e);break;case "image":switch(e.operationType){case "show":let l=new pixiVn.ImageSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=pixiVn.canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Image with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "video":switch(e.operationType){case "show":let l=new pixiVn.VideoSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=pixiVn.canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Video with alias ${e.alias} not found.`);break;case "remove":M(e);break;case "pause":let d=pixiVn.canvas.find(e.alias);d?d.paused=true:V.error(`Video with alias ${e.alias} not found.`);break;case "resume":let g=pixiVn.canvas.find(e.alias);g?g.paused=false:V.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let l=new pixiVn.ImageContainer(e.props,e.urls);await Y(l,e);break;case "edit":let f=pixiVn.canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let l=pixiVn.canvas.find(e.alias);l?e.props&&(l.memory={...l.memory,...e.props}):V.error(`Canvas Element with alias ${e.alias} not found.`);}catch(l){V.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,l);}break;case "remove":M(e);break}break;case "value":X(e);break;case "operationtoconvert":if(t){let l="";e.values.forEach(d=>{if(typeof d=="string")l+=d;else {let g=p(d);l+=`${g}`;}});let f=await t(l);f&&await I(f,t);}break;case "input":switch(e.operationType){case "request":pixiVn.narration.requestInput({type:e.valueType},e.defaultValue);break}break;case "fade":let r=new pixiVn.FadeAlphaTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,r);break;case "move":let a=new pixiVn.MoveTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,a);break;case "rotate":let o=new pixiVn.RotateTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,o);break;case "zoom":let c=new pixiVn.ZoomTicker(e.props,e.duration,e.priority);pixiVn.canvas.addTicker(e.alias,c);break;case "shake":await pixiVn.shakeEffect(e.alias,e.props,e.priority);break}}async function Y(i,t){if(t.transition)switch(t.transition.type){case "fade":await pixiVn.showWithFade(t.alias,i,t.transition.props,t.transition.priority);break;case "dissolve":await pixiVn.showWithDissolve(t.alias,i,t.transition.props,t.transition.priority);break;case "movein":case "moveout":await pixiVn.moveIn(t.alias,i,t.transition.props,t.transition.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(t.alias,i,t.transition.props,t.transition.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(t.alias,i,t.transition.props,t.transition.priority);break}else await i.load(),pixiVn.canvas.add(t.alias,i);}function M(i){if(i.transition)switch(i.transition.type){case "fade":pixiVn.removeWithFade(i.alias,i.transition.props,i.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(i.alias,i.transition.props,i.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(i.alias,i.transition.props,i.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(i.alias,i.transition.props,i.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(i.alias,i.transition.props,i.transition.priority);break}else pixiVn.canvas.remove(i.alias);}var _=class extends pixiVn.LabelAbstract{constructor(t,e,r,a={}){r||(r={}),r.onLoadingLabel=async()=>{for(let o of e){let c;if(typeof o=="function"?c=o():c=o,c=L(c),c.operations){let l=c.operations.map(f=>H(f));await Promise.all(l);}}},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:w.t(this.getDialogueText(e.text))}:w.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=typeof t=="function"?t():t;r=pixiVn.createExportableElement(r),r=L(r);let a=this.operationStringConvert?m=>this.operationStringConvert(m,r,e):void 0,{operations:o=[]}=r;for(let m of o)await I(m,a);let{labelToOpen:c=[]}=r,l=this.getChoices(r.choices),f=p(r.glueEnabled),d=this.getDialogue(r.dialogue),g=[];Array.isArray(c)||(c=[c]),c.forEach(m=>{let h=p(m);h&&g.push(h);});let y=p(r.goNextStep),x=p(r.end);if(l){let m=l.map(h=>{let N="";if(Array.isArray(h.text)){let n=[];h.text.forEach(s=>{if(typeof s=="string")n.push(w.t(s));else if(s&&typeof s=="object"){let u=p(s);u&&!Array.isArray(u)&&typeof u=="object"&&(u=p(u)||""),u&&(Array.isArray(u)?n=n.concat(w.t(u)):n.push(w.t(u)));}}),N=n;}else typeof h.text=="string"&&(N=w.t(h.text));return {label:h.label,text:N,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});pixiVn.narration.choiceMenuOptions=m;}else pixiVn.narration.choiceMenuOptions=void 0;d!==void 0&&(pixiVn.narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(y=true)),f?pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):f===false&&pixiVn.storage.setFlag(pixiVn.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let m of g){let h=m.label;typeof h=="object"&&(h=p(h)||"");let N=m.params?.map(b=>p(b));e={...e,...m.props},m.type==="jump"?(pixiVn.narration.openedLabels.length>0&&pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${k}${pixiVn.narration.openedLabels.length}`,N),await pixiVn.narration.callLabel(h,e)):(pixiVn.storage.setTempVariable(`${k}${pixiVn.narration.openedLabels.length}`,N),await pixiVn.narration.callLabel(h,e));}x==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e,{runNow:true})):x==="label_end"&&pixiVn.narration.closeCurrentLabel(),y&&await pixiVn.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 {V.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let a=i.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(f){V.error("Error parsing imported Pixi'VN JSON",f),l={};}return l}),c=(await Promise.all(a)).map(async l=>{let f=[];if(l.initialOperations){l.initialOperations.forEach(g=>{let y=I(g,e?x=>e(x,{},{}):void 0);f.push(y);});let d={};[...pixiVn.storage.storage.keys()].forEach((g,y)=>{d[g]=pixiVn.storage.storage.get(g);}),pixiVn.storage.startingStorage=d;}if(l.labels){let d=l.labels;for(let g in d)try{let y=d[g],x=new _(g,y,void 0,t);pixiVn.RegisteredLabels.add(x);}catch(y){V.error(`Error creating JSON label ${g}`,y);}}return Promise.all(f)});await Promise.all(c);}exports.LabelJson=_;exports.PIXIVNJSON_PARAM_ID=k;exports.getLogichValue=p;exports.importPixiVNJson=ze;exports.setStorageJson=X;exports.translator=$;
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import {storage,narration,LabelAbstract,createExportableElement,SYSTEM_RESERVED_STORAGE_KEYS,RegisteredLabels,NarrationManagerStatic,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 j=(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 j=="function")try{r=j("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 u;return n.prototype=s,u=new n,n.prototype=null,u}})(),c={},l=c.lib={},f=l.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=l.WordArray=f.extend({init:function(n,s){n=this.words=n||[],s!=e?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||y).stringify(this)},concat:function(n){var s=this.words,u=n.words,T=this.sigBytes,P=n.sigBytes;if(this.clamp(),T%4)for(var S=0;S<P;S++){var W=u[S>>>2]>>>24-S%4*8&255;s[T+S>>>2]|=W<<24-(T+S)%4*8;}else for(var E=0;E<P;E+=4)s[T+E>>>2]=u[E>>>2];return this.sigBytes+=P,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=f.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],u=0;u<n;u+=4)s.push(a());return new g.init(s,n)}}),d=c.enc={},y=d.Hex={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push((S>>>4).toString(16)),T.push((S&15).toString(16));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T+=2)u[T>>>3]|=parseInt(n.substr(T,2),16)<<24-T%8*4;return new g.init(u,s/2)}},m=d.Latin1={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push(String.fromCharCode(S));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T++)u[T>>>2]|=(n.charCodeAt(T)&255)<<24-T%4*8;return new g.init(u,s)}},x=d.Utf8={stringify:function(n){try{return decodeURIComponent(escape(m.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return m.parse(unescape(encodeURIComponent(n)))}},h=l.BufferedBlockAlgorithm=f.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,u=this._data,T=u.words,P=u.sigBytes,S=this.blockSize,W=S*4,E=P/W;n?E=t.ceil(E):E=t.max((E|0)-this._minBufferSize,0);var D=E*S,Z=t.min(D*4,P);if(D){for(var K=0;K<D;K+=S)this._doProcessBlock(T,K);s=T.splice(0,D),u.sigBytes-=Z;}return new g.init(s,Z)},clone:function(){var n=f.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});l.Hasher=h.extend({cfg:f.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){h.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,u){return new n.init(u).finalize(s)}},_createHmacHelper:function(n){return function(s,u){return new b.HMAC.init(n,u).finalize(s)}}});var b=c.algo={};return c})(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,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(f,g){for(var d=this._hash.words,y=d[0],m=d[1],x=d[2],h=d[3],N=d[4],b=0;b<80;b++){if(b<16)c[b]=f[g+b]|0;else {var n=c[b-3]^c[b-8]^c[b-14]^c[b-16];c[b]=n<<1|n>>>31;}var s=(y<<5|y>>>27)+N+c[b];b<20?s+=(m&x|~m&h)+1518500249:b<40?s+=(m^x^h)+1859775393:b<60?s+=(m&x|m&h|x&h)-1894007588:s+=(m^x^h)-899497514,N=h,h=x,x=m<<30|m>>>2,m=y,y=s;}d[0]=d[0]+y|0,d[1]=d[1]+m|0,d[2]=d[2]+x|0,d[3]=d[3]+h|0,d[4]=d[4]+N|0;},_doFinalize:function(){var f=this._data,g=f.words,d=this._nDataBytes*8,y=f.sigBytes*8;return g[y>>>5]|=128<<24-y%32,g[(y+64>>>9<<4)+14]=Math.floor(d/4294967296),g[(y+64>>>9<<4)+15]=d,f.sigBytes=g.length*4,this._process(),this._hash},clone:function(){var f=a.clone.call(this);return f._hash=this._hash.clone(),f}});t.SHA1=a._createHelper(l),t.HmacSHA1=a._createHmacHelper(l);})(),i.SHA1});});var se=de(re());var k="___param___";var w=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={}){let{defaultValue:a="copy_key"}=r;return t.forEach(o=>{if(o.choices){let c=[];Array.isArray(o.choices)?c=[o.choices]:c=i.getConditionalsThenElse(o.choices),c.forEach(l=>l.forEach(f=>{if("type"in f){let g=[];f.type==="ifelse"||f.type==="stepswitch"?i.getConditionalsThenElse(f,g):g=[f],g.map(y=>i.getConditionalsThenElse(y.text)).forEach(y=>{Array.isArray(y)&&y.forEach(m=>{Array.isArray(m)?m.forEach(x=>{typeof x=="string"?i.addKey(e,x,{defaultValue:a}):i.getConditionalsThenElse(x).forEach(h=>{Array.isArray(h)?h.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});}):typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});}}));}if(o.dialogue){let c=[];Array.isArray(o.dialogue)?c=[o.dialogue]:c=i.getConditionalsThenElse(o.dialogue),c.forEach(l=>{typeof l=="string"?i.addKey(e,l,{defaultValue:a}):"text"in l&&Array.isArray(l.text)&&l.text.forEach(f=>{typeof f=="string"?i.addKey(e,f,{defaultValue:a}):i.getConditionalsThenElse(f).forEach(d=>{typeof d=="string"?i.addKey(e,d,{defaultValue:a}):Array.isArray(d)&&d.forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):i.getConditionalsThenElse(y).forEach(m=>{typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});});});});}o.conditionalStep&&i.getConditionalsThenElse(o.conditionalStep).forEach(l=>{Array.isArray(l)?i.generateJsonTranslation(l,e,r):i.generateJsonTranslation([l],e,r);});}),e}};var $=w;var V;(a=>(a.log=(o,...c)=>console.log(`[Pixi\u2019VN Json] ${o}`,...c),a.warn=(o,...c)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...c),a.error=(o,...c)=>console.error(`[Pixi\u2019VN Json] ${o}`,...c),a.info=(o,...c)=>console.info(`[Pixi\u2019VN Json] ${o}`,...c)))(V||={});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){V.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,c=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(o=p(e[e.length-1])),c>e.length-1?o:p(e[c]);case "sequentialrandom":let l=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(l==null&&i.end=="lastItem"){let f=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!f||!f?.usedRandomNumbers){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let g=f.usedRandomNumbers[`0-${e.length-1}`];return p(e[g[g.length-1]])}if(l==null){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return p(e[l])}}return i}function L(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 L(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 c=p(o);e.push(c);});else {let o=p(a);e.push(o);}});let r=t?[t,...e]:e;if(r.length===0){V.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return $.t(r);if(typeof r[0]=="object"){let a=r,o,c=a.map((n,s)=>{n=L(n);let u=p(n.dialogue)||"";return s===0?(o=p(n.glueEnabled)||false,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===false&&(u=`
1
+ import {storage,narration,LabelAbstract,createExportableElement,SYSTEM_RESERVED_STORAGE_KEYS,RegisteredLabels,NarrationManagerStatic,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 j=(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 j=="function")try{r=j("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 u;return n.prototype=s,u=new n,n.prototype=null,u}})(),c={},l=c.lib={},f=l.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)}}})(),d=l.WordArray=f.extend({init:function(n,s){n=this.words=n||[],s!=e?this.sigBytes=s:this.sigBytes=n.length*4;},toString:function(n){return (n||y).stringify(this)},concat:function(n){var s=this.words,u=n.words,T=this.sigBytes,P=n.sigBytes;if(this.clamp(),T%4)for(var S=0;S<P;S++){var W=u[S>>>2]>>>24-S%4*8&255;s[T+S>>>2]|=W<<24-(T+S)%4*8;}else for(var E=0;E<P;E+=4)s[T+E>>>2]=u[E>>>2];return this.sigBytes+=P,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=f.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var s=[],u=0;u<n;u+=4)s.push(a());return new d.init(s,n)}}),g=c.enc={},y=g.Hex={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push((S>>>4).toString(16)),T.push((S&15).toString(16));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T+=2)u[T>>>3]|=parseInt(n.substr(T,2),16)<<24-T%8*4;return new d.init(u,s/2)}},x=g.Latin1={stringify:function(n){for(var s=n.words,u=n.sigBytes,T=[],P=0;P<u;P++){var S=s[P>>>2]>>>24-P%4*8&255;T.push(String.fromCharCode(S));}return T.join("")},parse:function(n){for(var s=n.length,u=[],T=0;T<s;T++)u[T>>>2]|=(n.charCodeAt(T)&255)<<24-T%4*8;return new d.init(u,s)}},m=g.Utf8={stringify:function(n){try{return decodeURIComponent(escape(x.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return x.parse(unescape(encodeURIComponent(n)))}},h=l.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=m.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var s,u=this._data,T=u.words,P=u.sigBytes,S=this.blockSize,W=S*4,E=P/W;n?E=t.ceil(E):E=t.max((E|0)-this._minBufferSize,0);var D=E*S,Z=t.min(D*4,P);if(D){for(var K=0;K<D;K+=S)this._doProcessBlock(T,K);s=T.splice(0,D),u.sigBytes-=Z;}return new d.init(s,Z)},clone:function(){var n=f.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});l.Hasher=h.extend({cfg:f.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){h.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,u){return new n.init(u).finalize(s)}},_createHmacHelper:function(n){return function(s,u){return new b.HMAC.init(n,u).finalize(s)}}});var b=c.algo={};return c})(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,c=[],l=o.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(f,d){for(var g=this._hash.words,y=g[0],x=g[1],m=g[2],h=g[3],N=g[4],b=0;b<80;b++){if(b<16)c[b]=f[d+b]|0;else {var n=c[b-3]^c[b-8]^c[b-14]^c[b-16];c[b]=n<<1|n>>>31;}var s=(y<<5|y>>>27)+N+c[b];b<20?s+=(x&m|~x&h)+1518500249:b<40?s+=(x^m^h)+1859775393:b<60?s+=(x&m|x&h|m&h)-1894007588:s+=(x^m^h)-899497514,N=h,h=m,m=x<<30|x>>>2,x=y,y=s;}g[0]=g[0]+y|0,g[1]=g[1]+x|0,g[2]=g[2]+m|0,g[3]=g[3]+h|0,g[4]=g[4]+N|0;},_doFinalize:function(){var f=this._data,d=f.words,g=this._nDataBytes*8,y=f.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(g/4294967296),d[(y+64>>>9<<4)+15]=g,f.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var f=a.clone.call(this);return f._hash=this._hash.clone(),f}});t.SHA1=a._createHelper(l),t.HmacSHA1=a._createHmacHelper(l);})(),i.SHA1});});var se=de(re());var k="___param___";var w=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={}){let{defaultValue:a="copy_key"}=r;return t.forEach(o=>{if(o.choices){let c=[];Array.isArray(o.choices)?c=[o.choices]:c=i.getConditionalsThenElse(o.choices),c.forEach(l=>l.forEach(f=>{if("type"in f){let d=[];f.type==="ifelse"||f.type==="stepswitch"?i.getConditionalsThenElse(f,d):d=[f],d.map(y=>i.getConditionalsThenElse(y.text)).forEach(y=>{Array.isArray(y)&&y.forEach(x=>{Array.isArray(x)?x.forEach(m=>{typeof m=="string"?i.addKey(e,m,{defaultValue:a}):i.getConditionalsThenElse(m).forEach(h=>{Array.isArray(h)?h.forEach(N=>{typeof N=="string"&&i.addKey(e,N,{defaultValue:a});}):typeof h=="string"&&i.addKey(e,h,{defaultValue:a});});}):typeof x=="string"&&i.addKey(e,x,{defaultValue:a});});});}}));}if(o.dialogue){let c=[];Array.isArray(o.dialogue)?c=[o.dialogue]:c=i.getConditionalsThenElse(o.dialogue),c.forEach(l=>{if(typeof l=="string")i.addKey(e,l,{defaultValue:a});else if("text"in l){let f=i.getConditionalsThenElse(l.text);typeof f=="string"&&(f=[f]),f.forEach(d=>{typeof d=="string"?i.addKey(e,d,{defaultValue:a}):i.getConditionalsThenElse(d).forEach(y=>{typeof y=="string"?i.addKey(e,y,{defaultValue:a}):Array.isArray(y)&&y.forEach(x=>{typeof x=="string"?i.addKey(e,x,{defaultValue:a}):i.getConditionalsThenElse(x).forEach(m=>{typeof m=="string"&&i.addKey(e,m,{defaultValue:a});});});});});}});}o.conditionalStep&&i.getConditionalsThenElse(o.conditionalStep).forEach(l=>{Array.isArray(l)?i.generateJsonTranslation(l,e,r):i.generateJsonTranslation([l],e,r);});}),e}};var $=w;var V;(a=>(a.log=(o,...c)=>console.log(`[Pixi\u2019VN Json] ${o}`,...c),a.warn=(o,...c)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...c),a.error=(o,...c)=>console.error(`[Pixi\u2019VN Json] ${o}`,...c),a.info=(o,...c)=>console.info(`[Pixi\u2019VN Json] ${o}`,...c)))(V||={});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){V.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,c=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(o=p(e[e.length-1])),c>e.length-1?o:p(e[c]);case "sequentialrandom":let l=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:true});if(l==null&&i.end=="lastItem"){let f=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!f||!f?.usedRandomNumbers){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let d=f.usedRandomNumbers[`0-${e.length-1}`];return p(e[d[d.length-1]])}if(l==null){V.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return p(e[l])}}return i}function L(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 L(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 c=p(o);e.push(c);});else {let o=p(a);e.push(o);}});let r=t?[t,...e]:e;if(r.length===0){V.warn("combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return $.t(r);if(typeof r[0]=="object"){let a=r,o,c=a.map((n,s)=>{n=L(n);let u=p(n.dialogue)||"";return s===0?(o=p(n.glueEnabled)||false,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===false&&(u=`
2
2
 
3
- `+u),o=p(n.glueEnabled)||false,u)}),l=p(c[0]),f=typeof l=="object"&&"character"in l?l.character:void 0,g=c.flatMap(n=>{let s;n&&typeof n=="object"&&"text"in n?s=n.text:s=n;let u;return Array.isArray(s)?u=s.map(T=>{let P=p(T);return $.t(`${P}`)}):u=p(s)||"",$.t(u)}),d=a.find(n=>n.end),y=a.find(n=>n.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(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let h=a.find(n=>n.labelToOpen),N=[];return a.forEach(n=>{n.operations&&N.forEach(s=>{N.push(s);});}),{dialogue:f?{character:f,text:g}:g,end:d?.end,choices:y?.choices,glueEnabled:m,goNextStep:x,labelToOpen:h?.labelToOpen,operations:N}}}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];V.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 l=new ImageSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Image with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "video":switch(e.operationType){case "show":let l=new VideoSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.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:V.error(`Video with alias ${e.alias} not found.`);break;case "resume":let d=canvas.find(e.alias);d?d.paused=false:V.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let l=new ImageContainer(e.props,e.urls);await Y(l,e);break;case "edit":let f=canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let l=canvas.find(e.alias);l?e.props&&(l.memory={...l.memory,...e.props}):V.error(`Canvas Element with alias ${e.alias} not found.`);}catch(l){V.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,l);}break;case "remove":M(e);break}break;case "value":X(e);break;case "operationtoconvert":if(t){let l="";e.values.forEach(g=>{if(typeof g=="string")l+=g;else {let d=p(g);l+=`${d}`;}});let f=await t(l);f&&await I(f,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 c=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,c);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 _=class extends LabelAbstract{constructor(t,e,r,a={}){r||(r={}),r.onLoadingLabel=async()=>{for(let o of e){let c;if(typeof o=="function"?c=o():c=o,c=L(c),c.operations){let l=c.operations.map(f=>H(f));await Promise.all(l);}}},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:w.t(this.getDialogueText(e.text))}:w.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=typeof t=="function"?t():t;r=createExportableElement(r),r=L(r);let a=this.operationStringConvert?x=>this.operationStringConvert(x,r,e):void 0,{operations:o=[]}=r;for(let x of o)await I(x,a);let{labelToOpen:c=[]}=r,l=this.getChoices(r.choices),f=p(r.glueEnabled),g=this.getDialogue(r.dialogue),d=[];Array.isArray(c)||(c=[c]),c.forEach(x=>{let h=p(x);h&&d.push(h);});let y=p(r.goNextStep),m=p(r.end);if(l){let x=l.map(h=>{let N="";if(Array.isArray(h.text)){let n=[];h.text.forEach(s=>{if(typeof s=="string")n.push(w.t(s));else if(s&&typeof s=="object"){let u=p(s);u&&!Array.isArray(u)&&typeof u=="object"&&(u=p(u)||""),u&&(Array.isArray(u)?n=n.concat(w.t(u)):n.push(w.t(u)));}}),N=n;}else typeof h.text=="string"&&(N=w.t(h.text));return {label:h.label,text:N,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});narration.choiceMenuOptions=x;}else narration.choiceMenuOptions=void 0;g!==void 0&&(narration.dialogue=g,this.skipEmptyDialogs&&typeof g=="string"&&(g===""||RegExp(/^\s+$/).test(g))&&(y=true)),f?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):f===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let x of d){let h=x.label;typeof h=="object"&&(h=p(h)||"");let N=x.params?.map(b=>p(b));e={...e,...x.props},x.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${k}${narration.openedLabels.length}`,N),await narration.callLabel(h,e)):(storage.setTempVariable(`${k}${narration.openedLabels.length}`,N),await narration.callLabel(h,e));}m==="game_end"?(narration.closeAllLabels(),await narration.goNext(e,{runNow:true})):m==="label_end"&&narration.closeCurrentLabel(),y&&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 {V.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let a=i.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(f){V.error("Error parsing imported Pixi'VN JSON",f),l={};}return l}),c=(await Promise.all(a)).map(async l=>{let f=[];if(l.initialOperations){l.initialOperations.forEach(d=>{let y=I(d,e?m=>e(m,{},{}):void 0);f.push(y);});let g={};[...storage.storage.keys()].forEach((d,y)=>{g[d]=storage.storage.get(d);}),storage.startingStorage=g;}if(l.labels){let g=l.labels;for(let d in g)try{let y=g[d],m=new _(d,y,void 0,t);RegisteredLabels.add(m);}catch(y){V.error(`Error creating JSON label ${d}`,y);}}return Promise.all(f)});await Promise.all(c);}export{_ as LabelJson,k as PIXIVNJSON_PARAM_ID,p as getLogichValue,ze as importPixiVNJson,X as setStorageJson,$ as translator};
3
+ `+u),o=p(n.glueEnabled)||false,u)}),l=p(c[0]),f=typeof l=="object"&&"character"in l?l.character:void 0,d=c.flatMap(n=>{let s;n&&typeof n=="object"&&"text"in n?s=n.text:s=n;let u;return Array.isArray(s)?u=s.map(T=>{let P=p(T);return $.t(`${P}`)}):u=p(s)||"",$.t(u)}),g=a.find(n=>n.end),y=a.find(n=>n.choices),x=false,m=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),x=a[a.length-1].glueEnabled,m=a.reverse().find(n=>!(n.operations&&(!n.dialogue||!n.choices)))?.goNextStep);let h=a.find(n=>n.labelToOpen),N=[];return a.forEach(n=>{n.operations&&N.forEach(s=>{N.push(s);});}),{dialogue:f?{character:f,text:d}:d,end:g?.end,choices:y?.choices,glueEnabled:x,goNextStep:m,labelToOpen:h?.labelToOpen,operations:N}}}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];V.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 l=new ImageSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Image with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "video":switch(e.operationType){case "show":let l=new VideoSprite(e.props,e.url||e.alias);await Y(l,e);break;case "edit":let f=canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`Video with alias ${e.alias} not found.`);break;case "remove":M(e);break;case "pause":let d=canvas.find(e.alias);d?d.paused=true:V.error(`Video with alias ${e.alias} not found.`);break;case "resume":let g=canvas.find(e.alias);g?g.paused=false:V.error(`Video with alias ${e.alias} not found.`);break}break;case "imagecontainer":switch(e.operationType){case "show":let l=new ImageContainer(e.props,e.urls);await Y(l,e);break;case "edit":let f=canvas.find(e.alias);f?e.props&&await f.setMemory({...f.memory,...e.props}):V.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":M(e);break}break;case "canvaselement":switch(e.operationType){case "edit":try{let l=canvas.find(e.alias);l?e.props&&(l.memory={...l.memory,...e.props}):V.error(`Canvas Element with alias ${e.alias} not found.`);}catch(l){V.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,l);}break;case "remove":M(e);break}break;case "value":X(e);break;case "operationtoconvert":if(t){let l="";e.values.forEach(d=>{if(typeof d=="string")l+=d;else {let g=p(d);l+=`${g}`;}});let f=await t(l);f&&await I(f,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 c=new ZoomTicker(e.props,e.duration,e.priority);canvas.addTicker(e.alias,c);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 _=class extends LabelAbstract{constructor(t,e,r,a={}){r||(r={}),r.onLoadingLabel=async()=>{for(let o of e){let c;if(typeof o=="function"?c=o():c=o,c=L(c),c.operations){let l=c.operations.map(f=>H(f));await Promise.all(l);}}},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:w.t(this.getDialogueText(e.text))}:w.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=typeof t=="function"?t():t;r=createExportableElement(r),r=L(r);let a=this.operationStringConvert?m=>this.operationStringConvert(m,r,e):void 0,{operations:o=[]}=r;for(let m of o)await I(m,a);let{labelToOpen:c=[]}=r,l=this.getChoices(r.choices),f=p(r.glueEnabled),d=this.getDialogue(r.dialogue),g=[];Array.isArray(c)||(c=[c]),c.forEach(m=>{let h=p(m);h&&g.push(h);});let y=p(r.goNextStep),x=p(r.end);if(l){let m=l.map(h=>{let N="";if(Array.isArray(h.text)){let n=[];h.text.forEach(s=>{if(typeof s=="string")n.push(w.t(s));else if(s&&typeof s=="object"){let u=p(s);u&&!Array.isArray(u)&&typeof u=="object"&&(u=p(u)||""),u&&(Array.isArray(u)?n=n.concat(w.t(u)):n.push(w.t(u)));}}),N=n;}else typeof h.text=="string"&&(N=w.t(h.text));return {label:h.label,text:N,props:h.props,type:h.type,oneTime:h.oneTime,onlyHaveNoChoice:h.onlyHaveNoChoice,autoSelect:h.autoSelect}});narration.choiceMenuOptions=m;}else narration.choiceMenuOptions=void 0;d!==void 0&&(narration.dialogue=d,this.skipEmptyDialogs&&typeof d=="string"&&(d===""||RegExp(/^\s+$/).test(d))&&(y=true)),f?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):f===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let m of g){let h=m.label;typeof h=="object"&&(h=p(h)||"");let N=m.params?.map(b=>p(b));e={...e,...m.props},m.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${k}${narration.openedLabels.length}`,N),await narration.callLabel(h,e)):(storage.setTempVariable(`${k}${narration.openedLabels.length}`,N),await narration.callLabel(h,e));}x==="game_end"?(narration.closeAllLabels(),await narration.goNext(e,{runNow:true})):x==="label_end"&&narration.closeCurrentLabel(),y&&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 {V.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let a=i.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(f){V.error("Error parsing imported Pixi'VN JSON",f),l={};}return l}),c=(await Promise.all(a)).map(async l=>{let f=[];if(l.initialOperations){l.initialOperations.forEach(g=>{let y=I(g,e?x=>e(x,{},{}):void 0);f.push(y);});let d={};[...storage.storage.keys()].forEach((g,y)=>{d[g]=storage.storage.get(g);}),storage.startingStorage=d;}if(l.labels){let d=l.labels;for(let g in d)try{let y=d[g],x=new _(g,y,void 0,t);RegisteredLabels.add(x);}catch(y){V.error(`Error creating JSON label ${g}`,y);}}return Promise.all(f)});await Promise.all(c);}export{_ as LabelJson,k as PIXIVNJSON_PARAM_ID,p as getLogichValue,ze as importPixiVNJson,X as setStorageJson,$ as translator};