UNPKG

@drincs/pixi-vn-ink

Version:

Pixi'VN gives you the ability to write your own narrative using Ink

3 lines (2 loc) 103 kB
'use strict';var pixiVn=require('@drincs/pixi-vn'),canvas=require('@drincs/pixi-vn/canvas'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),storage=require('@drincs/pixi-vn/storage'),characters=require('@drincs/pixi-vn/characters'),u=require('zod'),mapper=require('@drincs/pixi-vn-ink/mapper'),parser=require('@drincs/pixi-vn-ink/parser');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var u__default=/*#__PURE__*/_interopDefault(u);var Tt=Object.create;var Ze=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var _t=Object.getOwnPropertyNames;var jt=Object.getPrototypeOf,It=Object.prototype.hasOwnProperty;var fe=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var zt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var Jt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _t(t))!It.call(e,n)&&n!==r&&Ze(e,n,{get:()=>t[n],enumerable:!(i=Lt(t,n))||i.enumerable});return e};var $t=(e,t,r)=>(r=e!=null?Tt(jt(e)):{},Jt(Ze(r,"default",{value:e,enumerable:true}),e));var Nt=zt(Ne=>{Object.defineProperty(Ne,"__esModule",{value:true});Ne.ErrorType=void 0;var kt;(function(e){e[e.Author=0]="Author",e[e.Warning=1]="Warning",e[e.Error=2]="Error";})(kt||(Ne.ErrorType=kt={}));});var Rt=Object.defineProperty,Mt=(e,t,r)=>t in e?Rt(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,X=(e,t,r)=>Mt(e,typeof t!="symbol"?t+"":t,r),W;(e=>(e.log=(t,...r)=>console.log(`[Pixi\u2019VN Json] ${t}`,...r),e.warn=(t,...r)=>console.warn(`[Pixi\u2019VN Json] ${t}`,...r),e.error=(t,...r)=>console.error(`[Pixi\u2019VN Json] ${t}`,...r),e.info=(t,...r)=>console.info(`[Pixi\u2019VN Json] ${t}`,...r)))(W||(W={}));var H=class N{static init(t){t.loadAssets&&(N._loadAssets=t.loadAssets),t.soundOperation&&(N._soundOperation=t.soundOperation),t.imageOperation&&(N._imageOperation=t.imageOperation),t.videoOperation&&(N._videoOperation=t.videoOperation),t.imageContainerOperation&&(N._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(N._textOperation=t.textOperation),t.canvasElementOperation&&(N._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(N._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(N._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(N._narrationOperation=t.narrationOperation),t.effectOperation&&(N._effectOperation=t.effectOperation),t.animateOperation&&(N._animateOperation=t.animateOperation),t.getLogichValue&&(N._getLogichValue=t.getLogichValue),t.getConditionalStep&&(N._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return N._loadAssets}static get soundOperation(){return N._soundOperation}static get imageOperation(){return N._imageOperation}static get videoOperation(){return N._videoOperation}static get imageContainerOperation(){return N._imageContainerOperation}static get textOperation(){return N._textOperation}static get canvasElementOperation(){return N._canvasElementOperation}static get setStorageValue(){return N._setStorageValue}static get setInitialStorageValue(){return N._setInitialStorageValue}static get narrationOperation(){return N._narrationOperation}static get effectOperation(){return N._effectOperation}static get animateOperation(){return N._animateOperation}static get getLogichValue(){return N._getLogichValue}static get getConditionalStep(){return N._getConditionalStep}};X(H,"_loadAssets",()=>{}),X(H,"_soundOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_imageOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_videoOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_imageContainerOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_textOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_canvasElementOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_setStorageValue",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_setInitialStorageValue",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_narrationOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_effectOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_animateOperation",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_getLogichValue",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),X(H,"_getConditionalStep",()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var h=H;var Ht=Object.defineProperty,Wt=(e,t,r)=>t in e?Ht(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,_e=(e,t,r)=>Wt(e,typeof t!="symbol"?t+"":t,r);function qt(e,t={}){let r="";return e.values.forEach(i=>{if(typeof i=="string")r+=i;else {let n=h.getLogichValue(i,t);r+=`${n}`;}}),r}var ve=class O{static t(t){return Array.isArray(t)?t.map(r=>O.translate(`${r}`)):O.translate(`${t}`)}static set beforeToTranslate(t){O._beforeToTranslate=t;}static set translate(t){O._translate=t;}static get translate(){return t=>{let r=t;return O._beforeToTranslate&&(r=O._beforeToTranslate(r)),r=O._translate(r),O._afterToTranslate&&(r=O._afterToTranslate(r)),r}}static set afterToTranslate(t){O._afterToTranslate=t;}static addKey(t,r,i){let n=i.defaultValue||"empty_string";typeof r=="string"&&(r=[r]),Array.isArray(r)&&r.forEach(o=>{t[o]===void 0&&(n==="empty_string"?t[o]="":n==="copy_key"&&(O._beforeToTranslate?t[o]=O._beforeToTranslate(o):t[o]=o));});}static getConditionalsThenElse(t,r=[]){if(typeof t=="object"&&t&&"type"in t)if(t.type==="ifelse")t.then&&O.getConditionalsThenElse(t.then,r),t.else&&O.getConditionalsThenElse(t.else,r);else if(t.type==="stepswitch"){if(t.elements)if(Array.isArray(t.elements))t.elements.forEach(i=>{O.getConditionalsThenElse(i,r);});else if(t.elements.type==="ifelse"){let i=[];O.getConditionalsThenElse(t.elements,i),i.forEach(n=>{r.push(...n);});}else if(t.elements.type==="stepswitch"){let i=[];O.getConditionalsThenElse(t.elements,i),i.forEach(n=>{r.push(...n);});}else O.getConditionalsThenElse(t.elements,r);}else t.type==="resulttocombine"?(t.firstItem&&O.getConditionalsThenElse(t.firstItem,r),t.secondConditionalItem&&t.secondConditionalItem.forEach(i=>{O.getConditionalsThenElse(i,r);})):r.push(t);else t&&r.push(t);return r}static async generateJsonTranslation(t,r={},i={}){let{defaultValue:n="copy_key",operationStringConvert:o}=i,d=t.map(async A=>{if(A.choices){let p=[];Array.isArray(A.choices)?p=[A.choices]:p=O.getConditionalsThenElse(A.choices),p.forEach(v=>v.forEach(F=>{if("type"in F){let B=[];F.type==="ifelse"||F.type==="stepswitch"?O.getConditionalsThenElse(F,B):B=[F],B.map(C=>O.getConditionalsThenElse(C.text)).forEach(C=>{Array.isArray(C)&&C.forEach(x=>{Array.isArray(x)?x.forEach(P=>{typeof P=="string"?O.addKey(r,P,{defaultValue:n}):O.getConditionalsThenElse(P).forEach(m=>{Array.isArray(m)?m.forEach(y=>{typeof y=="string"&&O.addKey(r,y,{defaultValue:n});}):typeof m=="string"&&O.addKey(r,m,{defaultValue:n});});}):typeof x=="string"&&O.addKey(r,x,{defaultValue:n});});});}}));}if(A.dialogue){let p=[];Array.isArray(A.dialogue)?p=[A.dialogue]:p=O.getConditionalsThenElse(A.dialogue),p.forEach(v=>{if(typeof v=="string")O.addKey(r,v,{defaultValue:n});else if("text"in v){let F=O.getConditionalsThenElse(v.text);typeof F=="string"&&(F=[F]),F.forEach(B=>{typeof B=="string"?O.addKey(r,B,{defaultValue:n}):O.getConditionalsThenElse(B).forEach(C=>{typeof C=="string"?O.addKey(r,C,{defaultValue:n}):Array.isArray(C)&&C.forEach(x=>{typeof x=="string"?O.addKey(r,x,{defaultValue:n}):O.getConditionalsThenElse(x).forEach(P=>{typeof P=="string"&&O.addKey(r,P,{defaultValue:n});});});});});}});}if(A.operations)for(let p of A.operations){if(p.type==="operationtoconvert"&&o){let v=qt(p),F=await o(v,A,{});if(!F)return;p=F;}p.type==="text"&&p.operationType==="show"&&O.addKey(r,p.text,{defaultValue:n});}A.conditionalStep&&O.getConditionalsThenElse(A.conditionalStep).forEach(p=>{Array.isArray(p)?O.generateJsonTranslation(p,r,i):O.generateJsonTranslation([p],r,i);});});return await Promise.all(d),r}};_e(ve,"_beforeToTranslate"),_e(ve,"_translate",e=>e),_e(ve,"_afterToTranslate");var Ut=ve,z=Ut;var fr=Object.defineProperty,hr=(e,t,r)=>t in e?fr(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,Y=(e,t,r)=>hr(e,typeof t!="symbol"?t+"":t,r);async function et(e){let t=h.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await canvas.Assets.load(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await canvas.Assets.loadBundle(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(t.aliases);break}break}}var k;(e=>(e.log=(t,...r)=>console.log(`[Pixi\u2019VN Json] ${t}`,...r),e.warn=(t,...r)=>console.warn(`[Pixi\u2019VN Json] ${t}`,...r),e.error=(t,...r)=>console.error(`[Pixi\u2019VN Json] ${t}`,...r),e.info=(t,...r)=>console.info(`[Pixi\u2019VN Json] ${t}`,...r)))(k||(k={}));async function Be(e,t,r){switch(r.type){case "fade":await canvas.showWithFade(t.alias,e,r.props,r.priority);break;case "dissolve":await canvas.showWithDissolve(t.alias,e,r.props,r.priority);break;case "movein":case "moveout":await canvas.moveIn(t.alias,e,r.props,r.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(t.alias,e,r.props,r.priority);break;case "pushin":case "pushout":await canvas.pushIn(t.alias,e,r.props,r.priority);break}}function me(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function tt(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageSprite(e.props,e.url||e.alias);await Be(t,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):k.error(`Image with alias ${e.alias} not found.`);break}case "remove":me(e);break}}async function rt(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.VideoSprite(e.props,e.url||e.alias);await Be(t,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):k.error(`Video with alias ${e.alias} not found.`);break}case "remove":me(e);break;case "pause":case "resume":{let t=canvas.canvas.find(e.alias);t?t.paused=e.operationType==="pause":k.error(`Video with alias ${e.alias} not found.`);break}}}async function it(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageContainer(e.props,e.urls);await Be(t,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):k.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":me(e);break}}async function nt(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=z.t(e.text),e.transition){let t=new canvas.Text(e.props);await Be(t,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):k.error(`Text with alias ${e.alias} not found.`);break}case "remove":me(e);break}}async function at(e){switch(e.operationType){case "edit":try{let t=canvas.canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):k.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){k.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":me(e);break}}async function ut(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function ot(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function st(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function lt(e){switch(e.operationType){case "play":e.url?sound.sound.play(e.alias,e.url,e.props):sound.sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.sound.stop(e.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.sound.pause(e.alias);break;case "channel":sound.sound.findChannel(e.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.sound.resume(e.alias);break;case "channel":sound.sound.findChannel(e.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,r])=>{let i=sound.sound.find(e.alias);i&&(t==="volume"?i.volume.value=r:i.paused=r);});break}}var je="___param___",q=class T{static init(t){t.loadAssets&&(T._loadAssets=t.loadAssets),t.soundOperation&&(T._soundOperation=t.soundOperation),t.imageOperation&&(T._imageOperation=t.imageOperation),t.videoOperation&&(T._videoOperation=t.videoOperation),t.imageContainerOperation&&(T._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(T._textOperation=t.textOperation),t.canvasElementOperation&&(T._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(T._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(T._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(T._narrationOperation=t.narrationOperation),t.effectOperation&&(T._effectOperation=t.effectOperation),t.animateOperation&&(T._animateOperation=t.animateOperation),t.getLogichValue&&(T._getLogichValue=t.getLogichValue),t.getConditionalStep&&(T._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return T._loadAssets}static get soundOperation(){return T._soundOperation}static get imageOperation(){return T._imageOperation}static get videoOperation(){return T._videoOperation}static get imageContainerOperation(){return T._imageContainerOperation}static get textOperation(){return T._textOperation}static get canvasElementOperation(){return T._canvasElementOperation}static get setStorageValue(){return T._setStorageValue}static get setInitialStorageValue(){return T._setInitialStorageValue}static get narrationOperation(){return T._narrationOperation}static get effectOperation(){return T._effectOperation}static get animateOperation(){return T._animateOperation}static get getLogichValue(){return T._getLogichValue}static get getConditionalStep(){return T._getConditionalStep}};Y(q,"_loadAssets",()=>{}),Y(q,"_soundOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_imageOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_videoOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_imageContainerOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_textOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_canvasElementOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_setStorageValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_setInitialStorageValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_narrationOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_effectOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_animateOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_getLogichValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),Y(q,"_getConditionalStep",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var gr=q;function Ar(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let r=t[e.functionName];if(typeof r=="function"){let i=e.args.map(n=>gr.getLogichValue(n,t));return r(...i)}else k.warn(`getLogichValue function ${e.functionName} not found in props`);}}function ct(e,t){let r=h.getLogichValue(e,t);return r&&typeof r=="object"&&"type"in r?h.getLogichValue(r,t):r}function pt(e,t={}){let r=ct(e.value,t);switch(e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,r);break;case "tempstorage":storage.storage.setTempVariable(e.key,r);break;case "params":{let i=storage.storage.get(`${je}${narration.narration.openedLabels.length-1}`)||[];i.length>e.key&&(i[e.key]=r),storage.storage.setTempVariable(`${je}${narration.narration.openedLabels.length-1}`,i);break}}}function Dt(e,t={}){let r=ct(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:r};break}}function Ie(e,t={}){let r=ze(e,t);if(r&&typeof r=="object"&&"type"in r)switch(r.type){case "value":return Cr(r,t);case "arithmetic":case "arithmeticsingle":return mr(r,t);case "compare":case "union":return Er(r,t);case "function":return Ar(r,t)}return r}function mr(e,t){let r=h.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let i=h.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return r*i;case "/":return r/i;case "+":return typeof r=="string"||typeof i=="string"?`${r}${i}`:Array.isArray(r)&&Array.isArray(i)?[...r,...i]:Array.isArray(r)?[...r,i]:Array.isArray(i)?[r,...i]:r+i;case "-":if(Array.isArray(r)&&Array.isArray(i))return r.filter(n=>!i.includes(n));if(Array.isArray(r))return r.filter(n=>n!==i);if(Array.isArray(i)){k.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return r-i;case "%":return r%i;case "POW":return r**i;case "RANDOM":return narration.narration.getRandomNumber(r,i);case "INTERSECTION":if(Array.isArray(r)&&Array.isArray(i))return r.filter(n=>i.includes(n));k.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:k.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(r);case "FLOOR":return Math.floor(r)}break}}function Cr(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return h.getLogichValue(e.operation,t);case "params":{let r=storage.storage.get(`${je}${narration.narration.openedLabels.length-1}`)||[];if(r&&r.length>e.key)return r[e.key];k.warn("getValue params not found");return}}return e}function Er(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let r=h.getLogichValue(e.leftValue,t),i=h.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(r)&&Array.isArray(i)?r.length===i.length&&r.every(n=>i.includes(n)):r===i;case "!=":return Array.isArray(r)&&Array.isArray(i)?r.length!==i.length||!r.every(n=>i.includes(n)):r!==i;case "<":return typeof r=="string"&&typeof i=="string"?r.localeCompare(i)<0:Array.isArray(r)&&Array.isArray(i)?r.length<i.length:r<i;case "<=":return typeof r=="string"&&typeof i=="string"?r.localeCompare(i)<=0:Array.isArray(r)&&Array.isArray(i)?r.length<=i.length:r<=i;case ">":return typeof r=="string"&&typeof i=="string"?r.localeCompare(i)>0:Array.isArray(r)&&Array.isArray(i)?r.length>i.length:r>i;case ">=":return typeof r=="string"&&typeof i=="string"?r.localeCompare(i)>=0:Array.isArray(r)&&Array.isArray(i)?r.length>=i.length:r>=i;case "CONTAINS":return Array.isArray(r)&&Array.isArray(i)?i.every(n=>r.includes(n)):Array.isArray(r)?r.includes(i):r.toString().includes(i.toString())}break}case "value":{let r=h.getLogichValue(e,t);return Array.isArray(r)?r.length>0:r&&typeof r=="object"?Object.keys(r).length>0:!!r}case "union":return Fr(e,t)}return !!e}function Fr(e,t){if(e.unionType==="not"){let i=Ie(e.condition,t);return Array.isArray(i)?i.length===0:i&&typeof i=="object"?Object.keys(i).length===0:!i}let r=i=>h.getLogichValue(i,t)||false;return e.unionType==="and"?e.conditions.every(r):e.conditions.some(r)}function yr(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function ze(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return vr(e,t);case "ifelse":return h.getLogichValue(e.condition,t)?h.getLogichValue(e.then,t):h.getLogichValue(e.else,t);case "stepswitch":{let r=h.getLogichValue(e.elements,t)||[];if(r.length===0){k.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let i=yr(0,r.length-1);return h.getLogichValue(r[i],t)}case "loop":{let i=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return i>r.length-1?(i=i%r.length,h.getLogichValue(r[i],t)):h.getLogichValue(r[i],t)}case "sequential":{let i,n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(i=h.getLogichValue(r[r.length-1],t)),n>r.length-1?i:h.getLogichValue(r[n],t)}case "sequentialrandom":{let i=narration.NarrationManagerStatic.getRandomNumber(0,r.length-1,{nestedId:e.nestedId,onceOnly:true});if(i===void 0&&e.end==="lastItem"){let n=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!n?.usedRandomNumbers){k.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let o=n.usedRandomNumbers[`0-${r.length-1}`];return h.getLogichValue(r[o[o.length-1]],t)}if(i===void 0){k.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return h.getLogichValue(r[i],t)}}}}return e}function be(e,t={}){if(e.conditionalStep){let r=pixiVn.createExportableElement(h.getLogichValue(e.conditionalStep,t));if(r?.glueEnabled===void 0&&delete r?.glueEnabled,r?.goNextStep===void 0&&delete r?.goNextStep,r?.end===void 0&&delete r?.end,r?.choices===void 0&&delete r?.choices,r?.dialogue===void 0&&delete r?.dialogue,r?.labelToOpen===void 0&&delete r?.labelToOpen,r?.operations===void 0&&delete r?.operations,r){let i={...e,conditionalStep:void 0,...r};return be(i,t)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function vr(e,t){let r=e.firstItem,i=(e.secondConditionalItem??[]).flatMap(o=>Array.isArray(o)?o.map(d=>h.getLogichValue(d,t)):[h.getLogichValue(o,t)]),n=r?[r,...i]:i;if(n.length===0){k.warn("combinateResult toCheck.length === 0");return}if(typeof n[0]=="string")return z.t(n);if(typeof n[0]=="object"){let o=n,d,A=false,p=o.map((s,a)=>{s=be(s,t);let l=h.getLogichValue(s.dialogue,t)||"";return a===0?(d=h.getLogichValue(s.glueEnabled,t)||false,l):(typeof l=="object"&&"text"in l&&(l=`${l.character}: ${l.text}`),d===false&&A&&(l=` ${l}`),l&&(A=true),d=h.getLogichValue(s.glueEnabled,t)||false,l)}),v=h.getLogichValue(p[0],t),F=typeof v=="object"&&"character"in v?v.character:void 0,B=p.flatMap(s=>{let a;s&&typeof s=="object"&&"text"in s?a=s.text:a=s;let l;return Array.isArray(a)?l=a.map(D=>{let f=h.getLogichValue(D,t);return z.t(`${f}`)}):l=h.getLogichValue(a,t)||"",z.t(l)}),C=o.find(s=>s.end),x=o.find(s=>s.choices),P=false,m=false;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&(narration.narration.dialogGlue=true),P=o[o.length-1].glueEnabled,m=o.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let y=o.find(s=>s.labelToOpen),g=[];return o.forEach(s=>{s.operations&&(g=[...g,...s.operations]);}),{dialogue:F?{character:F,text:B}:B,end:C?.end,choices:x?.choices,glueEnabled:P,goNextStep:m,labelToOpen:y?.labelToOpen,operations:g}}}var br=Object.create,Je=Object.defineProperty,Or=Object.getOwnPropertyDescriptor,Vr=Object.getOwnPropertyNames,Pr=Object.getPrototypeOf,Sr=Object.prototype.hasOwnProperty,kr=(e,t,r)=>t in e?Je(e,t,{enumerable:true,configurable:true,writable:true,value:r}):e[t]=r,ft=(e=>typeof fe<"u"?fe:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof fe<"u"?fe:t)[r]}):e)(function(e){if(typeof fe<"u")return fe.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')}),At=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Nr=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Vr(t))!Sr.call(e,n)&&n!==r&&Je(e,n,{get:()=>t[n],enumerable:!(i=Or(t,n))||i.enumerable});return e},Tr=(e,t,r)=>(r=e!=null?br(Pr(e)):{},Nr(Je(r,"default",{value:e,enumerable:true}),e)),M=(e,t,r)=>kr(e,typeof t!="symbol"?t+"":t,r),Lr=At((e,t)=>{(function(r,i){typeof e=="object"?t.exports=e=i():typeof define=="function"&&define.amd?define([],i):r.CryptoJS=i();})(e,function(){var r=r||(function(i,n){var o;if(typeof window<"u"&&window.crypto&&(o=window.crypto),typeof self<"u"&&self.crypto&&(o=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(o=globalThis.crypto),!o&&typeof window<"u"&&window.msCrypto&&(o=window.msCrypto),!o&&typeof global<"u"&&global.crypto&&(o=global.crypto),!o&&typeof ft=="function")try{o=ft("crypto");}catch{}var d=function(){if(o){if(typeof o.getRandomValues=="function")try{return o.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof o.randomBytes=="function")try{return o.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},A=Object.create||(function(){function s(){}return function(a){var l;return s.prototype=a,l=new s,s.prototype=null,l}})(),p={},v=p.lib={},F=v.Base=(function(){return {extend:function(s){var a=A(this);return s&&a.mixIn(s),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var s=this.extend();return s.init.apply(s,arguments),s},init:function(){},mixIn:function(s){for(var a in s)s.hasOwnProperty(a)&&(this[a]=s[a]);s.hasOwnProperty("toString")&&(this.toString=s.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),B=v.WordArray=F.extend({init:function(s,a){s=this.words=s||[],a!=n?this.sigBytes=a:this.sigBytes=s.length*4;},toString:function(s){return (s||x).stringify(this)},concat:function(s){var a=this.words,l=s.words,D=this.sigBytes,f=s.sigBytes;if(this.clamp(),D%4)for(var w=0;w<f;w++){var I=l[w>>>2]>>>24-w%4*8&255;a[D+w>>>2]|=I<<24-(D+w)%4*8;}else for(var Z=0;Z<f;Z+=4)a[D+Z>>>2]=l[Z>>>2];return this.sigBytes+=f,this},clamp:function(){var s=this.words,a=this.sigBytes;s[a>>>2]&=4294967295<<32-a%4*8,s.length=i.ceil(a/4);},clone:function(){var s=F.clone.call(this);return s.words=this.words.slice(0),s},random:function(s){for(var a=[],l=0;l<s;l+=4)a.push(d());return new B.init(a,s)}}),C=p.enc={},x=C.Hex={stringify:function(s){for(var a=s.words,l=s.sigBytes,D=[],f=0;f<l;f++){var w=a[f>>>2]>>>24-f%4*8&255;D.push((w>>>4).toString(16)),D.push((w&15).toString(16));}return D.join("")},parse:function(s){for(var a=s.length,l=[],D=0;D<a;D+=2)l[D>>>3]|=parseInt(s.substr(D,2),16)<<24-D%8*4;return new B.init(l,a/2)}},P=C.Latin1={stringify:function(s){for(var a=s.words,l=s.sigBytes,D=[],f=0;f<l;f++){var w=a[f>>>2]>>>24-f%4*8&255;D.push(String.fromCharCode(w));}return D.join("")},parse:function(s){for(var a=s.length,l=[],D=0;D<a;D++)l[D>>>2]|=(s.charCodeAt(D)&255)<<24-D%4*8;return new B.init(l,a)}},m=C.Utf8={stringify:function(s){try{return decodeURIComponent(escape(P.stringify(s)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(s){return P.parse(unescape(encodeURIComponent(s)))}},y=v.BufferedBlockAlgorithm=F.extend({reset:function(){this._data=new B.init,this._nDataBytes=0;},_append:function(s){typeof s=="string"&&(s=m.parse(s)),this._data.concat(s),this._nDataBytes+=s.sigBytes;},_process:function(s){var a,l=this._data,D=l.words,f=l.sigBytes,w=this.blockSize,I=w*4,Z=f/I;s?Z=i.ceil(Z):Z=i.max((Z|0)-this._minBufferSize,0);var de=Z*w,Ae=i.min(de*4,f);if(de){for(var Le=0;Le<de;Le+=w)this._doProcessBlock(D,Le);a=D.splice(0,de),l.sigBytes-=Ae;}return new B.init(a,Ae)},clone:function(){var s=F.clone.call(this);return s._data=this._data.clone(),s},_minBufferSize:0});v.Hasher=y.extend({cfg:F.extend(),init:function(s){this.cfg=this.cfg.extend(s),this.reset();},reset:function(){y.reset.call(this),this._doReset();},update:function(s){return this._append(s),this._process(),this},finalize:function(s){s&&this._append(s);var a=this._doFinalize();return a},blockSize:16,_createHelper:function(s){return function(a,l){return new s.init(l).finalize(a)}},_createHmacHelper:function(s){return function(a,l){return new g.HMAC.init(s,l).finalize(a)}}});var g=p.algo={};return p})(Math);return r});}),_r=At((e,t)=>{(function(r,i){typeof e=="object"?t.exports=e=i(Lr()):typeof define=="function"&&define.amd?define(["./core"],i):i(r.CryptoJS);})(e,function(r){return (function(){var i=r,n=i.lib,o=n.WordArray,d=n.Hasher,A=i.algo,p=[],v=A.SHA1=d.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(F,B){for(var C=this._hash.words,x=C[0],P=C[1],m=C[2],y=C[3],g=C[4],s=0;s<80;s++){if(s<16)p[s]=F[B+s]|0;else {var a=p[s-3]^p[s-8]^p[s-14]^p[s-16];p[s]=a<<1|a>>>31;}var l=(x<<5|x>>>27)+g+p[s];s<20?l+=(P&m|~P&y)+1518500249:s<40?l+=(P^m^y)+1859775393:s<60?l+=(P&m|P&y|m&y)-1894007588:l+=(P^m^y)-899497514,g=y,y=m,m=P<<30|P>>>2,P=x,x=l;}C[0]=C[0]+x|0,C[1]=C[1]+P|0,C[2]=C[2]+m|0,C[3]=C[3]+y|0,C[4]=C[4]+g|0;},_doFinalize:function(){var F=this._data,B=F.words,C=this._nDataBytes*8,x=F.sigBytes*8;return B[x>>>5]|=128<<24-x%32,B[(x+64>>>9<<4)+14]=Math.floor(C/4294967296),B[(x+64>>>9<<4)+15]=C,F.sigBytes=B.length*4,this._process(),this._hash},clone:function(){var F=d.clone.call(this);return F._hash=this._hash.clone(),F}});i.SHA1=d._createHelper(v),i.HmacSHA1=d._createHmacHelper(v);})(),r.SHA1});}),ht="___param___",$;(e=>(e.log=(t,...r)=>console.log(`[Pixi\u2019VN Json] ${t}`,...r),e.warn=(t,...r)=>console.warn(`[Pixi\u2019VN Json] ${t}`,...r),e.error=(t,...r)=>console.error(`[Pixi\u2019VN Json] ${t}`,...r),e.info=(t,...r)=>console.info(`[Pixi\u2019VN Json] ${t}`,...r)))($||($={}));var K=class L{static init(t){t.loadAssets&&(L._loadAssets=t.loadAssets),t.soundOperation&&(L._soundOperation=t.soundOperation),t.imageOperation&&(L._imageOperation=t.imageOperation),t.videoOperation&&(L._videoOperation=t.videoOperation),t.imageContainerOperation&&(L._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(L._textOperation=t.textOperation),t.canvasElementOperation&&(L._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(L._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(L._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(L._narrationOperation=t.narrationOperation),t.effectOperation&&(L._effectOperation=t.effectOperation),t.animateOperation&&(L._animateOperation=t.animateOperation),t.getLogichValue&&(L._getLogichValue=t.getLogichValue),t.getConditionalStep&&(L._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return L._loadAssets}static get soundOperation(){return L._soundOperation}static get imageOperation(){return L._imageOperation}static get videoOperation(){return L._videoOperation}static get imageContainerOperation(){return L._imageContainerOperation}static get textOperation(){return L._textOperation}static get canvasElementOperation(){return L._canvasElementOperation}static get setStorageValue(){return L._setStorageValue}static get setInitialStorageValue(){return L._setInitialStorageValue}static get narrationOperation(){return L._narrationOperation}static get effectOperation(){return L._effectOperation}static get animateOperation(){return L._animateOperation}static get getLogichValue(){return L._getLogichValue}static get getConditionalStep(){return L._getConditionalStep}};M(K,"_loadAssets",()=>{}),M(K,"_soundOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_imageOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_videoOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_imageContainerOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_textOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_canvasElementOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_setStorageValue",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_setInitialStorageValue",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_narrationOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_effectOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_animateOperation",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_getLogichValue",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),M(K,"_getConditionalStep",()=>{throw $.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var jr=K;function Ir(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let r=t[e.functionName];if(typeof r=="function"){let i=e.args.map(n=>jr.getLogichValue(n,t));return r(...i)}else $.warn(`getLogichValue function ${e.functionName} not found in props`);}}function zr(e,t={}){let r="";return e.values.forEach(i=>{if(typeof i=="string")r+=i;else {let n=h.getLogichValue(i,t);r+=`${n}`;}}),r}async function mt(e,t,r){let i=h.getLogichValue(e,t);if(i)switch(i.type){case "sound":h.soundOperation(i);break;case "assets":case "bundle":await h.loadAssets(i);break;case "image":await h.imageOperation(i);break;case "video":await h.videoOperation(i);break;case "imagecontainer":await h.imageContainerOperation(i);break;case "text":await h.textOperation(i);break;case "canvaselement":await h.canvasElementOperation(i);break;case "value":h.setStorageValue(i,t);break;case "operationtoconvert":if(r){let n=zr(i,t),o=await r(n);o&&await mt(o,t,r);}break;case "input":case "dialogue":h.narrationOperation(i);break;case "shake":await h.effectOperation(i);break;case "animate":case "animate-sequence":h.animateOperation(i);break;case "function":await Ir(i,t);break}}function gt(e){let t=h.getLogichValue(e,{});t&&t.type==="value"&&t.storageOperationType==="set"&&(t.storageType==="storage"||t.storageType==="tempstorage")&&h.setInitialStorageValue(t);}var Jr=Tr(_r()),$r=class extends narration.LabelAbstract{constructor(e,t,r,i={}){r||(r={}),r.onLoadingLabel=async()=>{for(let n of t){let o;if(typeof n=="function"?o=n():o=n,o=h.getConditionalStep(o),o.operations)try{let d=o.operations.map(A=>h.loadAssets(A));await Promise.all(d);}catch(d){$.error("The operation in the onLoadingLabel function of the label has an error:",d);}}},super(e,r),M(this,"_steps"),M(this,"operationStringConvert"),M(this,"skipEmptyDialogs",false),this._steps=t,this.operationStringConvert=i.operationStringConvert,this.skipEmptyDialogs=i.skipEmptyDialogs||false;}get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let t=this._steps[e];return this.stepConverter(t)}getStepSha(e){if(e<0||e>=this.steps.length)return;let t=this._steps[e];return (0, Jr.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(e,t){let r="";if(Array.isArray(e)){let i=[];e.forEach(n=>{if(typeof n=="string")i.push(n);else if(n&&typeof n=="object"){let o=h.getLogichValue(n,t);o?(o&&!Array.isArray(o)&&typeof o=="object"&&(o=h.getLogichValue(o,t)||""),Array.isArray(o)?i=i.map(d=>`${d}`).concat(o):i.push(`${o}`)):i.push(`${n}`);}else i.push(`${n}`);}),r=i;}else {let i=h.getLogichValue(e,t);i&&!Array.isArray(i)&&typeof i=="object"&&(i=h.getLogichValue(i,t)),i&&Array.isArray(i)?r=i.map(n=>`${n}`):r=`${i}`;}return r}getDialogue(e,t){if(e==null)return;let r=h.getLogichValue(e,t);return r==null?`${r}`:typeof r=="object"&&"character"in r&&"text"in r?{character:r.character,text:z.t(this.getDialogueText(r.text,t))}:z.t(this.getDialogueText(r,t))}getChoices(e,t){return h.getLogichValue(e,t)?.map(r=>h.getLogichValue(r,t)).filter(r=>r!==void 0)}stepConverter(e){return async t=>{let r=typeof e=="function"?e():e;r=pixiVn.createExportableElement(r),r=h.getConditionalStep(r,t);let i=this.operationStringConvert?C=>this.operationStringConvert(C,r,t):void 0,{operations:n=[]}=r;for(let C of n)await mt(C,t,i);let{labelToOpen:o=[]}=r,d=this.getChoices(r.choices,t),A=h.getLogichValue(r.glueEnabled,t),p=this.getDialogue(r.dialogue,t),v=[];Array.isArray(o)||(o=[o]),o.forEach(C=>{let x=h.getLogichValue(C,t);x&&v.push(x);});let F=h.getLogichValue(r.goNextStep,t),B=h.getLogichValue(r.end,t);if(d){let C=d.map(x=>{let P="";if(Array.isArray(x.text)){let m=[];x.text.forEach(y=>{if(typeof y=="string")m.push(z.t(y));else if(y&&typeof y=="object"){let g=h.getLogichValue(y,t);g&&!Array.isArray(g)&&typeof g=="object"&&(g=h.getLogichValue(g,t)||""),g&&(Array.isArray(g)?m=m.concat(z.t(g)):m.push(z.t(g)));}}),P=m;}else typeof x.text=="string"&&(P=z.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.narration.choices=C;}else narration.narration.choices=void 0;p!==void 0&&(narration.narration.dialogue=p,this.skipEmptyDialogs&&typeof p=="string"&&(p===""||RegExp(/^\s+$/).test(p))&&(F=true)),A?narration.narration.dialogGlue=true:A===false&&(narration.narration.dialogGlue=false);for(let C of v){let x=C.label;typeof x=="object"&&(x=h.getLogichValue(x,t)||"");let P=C.params?.map(m=>h.getLogichValue(m,t));t={...t,...C.props},C.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${ht}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t)):(storage.storage.setTempVariable(`${ht}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t));}B==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(t,{runNow:true})):B==="label_end"&&narration.narration.closeCurrentLabel(),F&&await narration.narration.continue(t,{runNow:true});}}};async function $e(e,t={}){if(!Array.isArray(e))if(typeof e=="object"||typeof e=="string")e=[e];else {$.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=e.map(o=>{if(typeof o=="string")try{return JSON.parse(o)}catch(d){return $.error("Error parsing imported Pixi'VN JSON",d),{}}return o}),i=r.map(async o=>{if(o.initialOperations)for(let d of o.initialOperations)d.type==="value"&&(typeof d.value!="object"||!d.value||!("type"in d.value))&&gt(d);return Promise.resolve()});await Promise.all(i);let n=r.map(async o=>{if(o.initialOperations)for(let d of o.initialOperations)(d.type!=="value"||d.type==="value"&&typeof d.value=="object"&&d.value&&"type"in d.value)&&gt(d);if(o.labels){let d=o.labels;for(let A in d)try{let p=d[A],v=new $r(A,p,void 0,t);narration.RegisteredLabels.add(v);}catch(p){$.error(`Error creating JSON label ${A}`,p);}}return Promise.resolve()});await Promise.all(n);}exports.VariableGetter=void 0;(e=>{let t=new Set;function r(o){t.add(o);}e.add=r;function i(){t.clear();}e.clear=i;function n(o,d={}){let A=F=>Ie(F,d)??void 0,p=ze(o,d);if(t.size===0)return A(p);let v=A;for(let F of t){let B=v;v=C=>F(C,B)??void 0;}return v(p)}e.getLogichValue=n;})(exports.VariableGetter||(exports.VariableGetter={}));exports.TextReplaces=void 0;(e=>{e.options={replaceRegex:/\[([^\]]+)\]/};let t=[],r=false,i=false;function n(v,F){t.push({fn:v,opts:F});let B=F.type??"before-translation";B==="before-translation"&&!r?(z.beforeToTranslate=C=>A(C,{type:"before-translation"}),r=true):B==="after-translation"&&!i&&(z.afterToTranslate=C=>A(C,{type:"after-translation"}),i=true);}e.add=n;function o(v){let F=t.findIndex(B=>B.fn===v);F!==-1&&t.splice(F,1);}e.remove=o;function d(){return t.map(v=>v.opts)}e.info=d;function A(v,F){let B=t.filter(C=>(C.opts.type??"before-translation")===F.type);for(let C of B)v=p(v,C.fn,C.opts.validation);return v}e.replace=A;function p(v,F,B){let C=new RegExp(e.options.replaceRegex.source,"g"),x=[...v.matchAll(C)],P=new Set,m=[];for(let y of x)P.has(y[1])||(P.add(y[1]),m.push(y[1]));for(let y of m){if(B==="characterId"){if(!characters.RegisteredCharacters.has(y))continue}else if(B!=="all"){if(B instanceof RegExp){if(!B.test(y))continue}else if(B instanceof u.ZodType&&!B.safeParse(y).success)continue}let g=F(y);g!==void 0&&(v=v.replaceAll(`[${y}]`,g));}return v}})(exports.TextReplaces||(exports.TextReplaces={}));function Me(){h.init({animateOperation:ot,canvasElementOperation:at,effectOperation:ut,imageContainerOperation:it,imageOperation:tt,textOperation:nt,narrationOperation:st,loadAssets:et,soundOperation:lt,videoOperation:rt,setStorageValue:pt,setInitialStorageValue:Dt,getLogi