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