@drincs/pixi-vn-ink 0.10.1 → 0.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import {a,c,b,e,d,f}from'./chunk-NG6ODEEE.mjs';import {RegisteredLabels,narration,LabelAbstract,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';import {canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,sound,Assets,narration as narration$1,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';var st=Object.defineProperty,lt=(t,e,i)=>e in t?st(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i,fe=(t,e,i)=>lt(t,typeof e!="symbol"?e+"":e,i),ie=class P{static t(e){return Array.isArray(e)?e.map(i=>P.translate(`${i}`)):P.translate(`${e}`)}static set beforeToTranslate(e){P._beforeToTranslate=e;}static set translate(e){P._translate=e;}static get translate(){return e=>{let i=e;return P._beforeToTranslate&&(i=P._beforeToTranslate(i)),i=P._translate(i),P._afterToTranslate&&(i=P._afterToTranslate(i)),i}}static set afterToTranslate(e){P._afterToTranslate=e;}static addKey(e,i,n){let r=n.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(o=>{e[o]===void 0&&(r==="empty_string"?e[o]="":r==="copy_key"&&(P._beforeToTranslate?e[o]=P._beforeToTranslate(o):e[o]=o));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&P.getConditionalsThenElse(e.then,i),e.else&&P.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(n=>{P.getConditionalsThenElse(n,i);});else if(e.elements.type==="ifelse"){let n=[];P.getConditionalsThenElse(e.elements,n),n.forEach(r=>{i.push(...r);});}else if(e.elements.type==="stepswitch"){let n=[];P.getConditionalsThenElse(e.elements,n),n.forEach(r=>{i.push(...r);});}else P.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&P.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(n=>{P.getConditionalsThenElse(n,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},n={}){let{defaultValue:r="copy_key"}=n;return e.forEach(o=>{if(o.choices){let l=[];Array.isArray(o.choices)?l=[o.choices]:l=P.getConditionalsThenElse(o.choices),l.forEach(g=>g.forEach(c=>{if("type"in c){let p=[];c.type==="ifelse"||c.type==="stepswitch"?P.getConditionalsThenElse(c,p):p=[c],p.map(s=>P.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(d=>{Array.isArray(d)?d.forEach(f=>{typeof f=="string"?P.addKey(i,f,{defaultValue:r}):P.getConditionalsThenElse(f).forEach(y=>{Array.isArray(y)?y.forEach(T=>{typeof T=="string"&&P.addKey(i,T,{defaultValue:r});}):typeof y=="string"&&P.addKey(i,y,{defaultValue:r});});}):typeof d=="string"&&P.addKey(i,d,{defaultValue:r});});});}}));}if(o.dialogue){let l=[];Array.isArray(o.dialogue)?l=[o.dialogue]:l=P.getConditionalsThenElse(o.dialogue),l.forEach(g=>{if(typeof g=="string")P.addKey(i,g,{defaultValue:r});else if("text"in g){let c=P.getConditionalsThenElse(g.text);typeof c=="string"&&(c=[c]),c.forEach(p=>{typeof p=="string"?P.addKey(i,p,{defaultValue:r}):P.getConditionalsThenElse(p).forEach(s=>{typeof s=="string"?P.addKey(i,s,{defaultValue:r}):Array.isArray(s)&&s.forEach(d=>{typeof d=="string"?P.addKey(i,d,{defaultValue:r}):P.getConditionalsThenElse(d).forEach(f=>{typeof f=="string"&&P.addKey(i,f,{defaultValue:r});});});});});}});}o.operations&&o.operations.forEach(l=>{switch(l.type){case "text":switch(l.operationType){case "show":P.addKey(i,l.text,{defaultValue:r});break}break}}),o.conditionalStep&&P.getConditionalsThenElse(o.conditionalStep).forEach(l=>{Array.isArray(l)?P.generateJsonTranslation(l,i,n):P.generateJsonTranslation([l],i,n);});}),i}};fe(ie,"_beforeToTranslate"),fe(ie,"_translate",t=>t),fe(ie,"_afterToTranslate");var pt=ie,J=pt;var ct=Object.defineProperty,ut=(t,e,i)=>e in t?ct(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i,j=(t,e,i)=>ut(t,typeof e!="symbol"?e+"":e,i),k;(t=>(t.log=(e,...i)=>console.log(`[Pixi\u2019VN Json] ${e}`,...i),t.warn=(e,...i)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...i),t.error=(e,...i)=>console.error(`[Pixi\u2019VN Json] ${e}`,...i),t.info=(e,...i)=>console.info(`[Pixi\u2019VN Json] ${e}`,...i)))(k||(k={}));var L=class E{static init(e){E._loadAssets=e.loadAssets,E._soundOperation=e.soundOperation,E._imageOperation=e.imageOperation,E._videoOperation=e.videoOperation,E._imageContainerOperation=e.imageContainerOperation,E._textOperation=e.textOperation,E._canvasElementOperation=e.canvasElementOperation,E._setStorageValue=e.setStorageValue,E._narrationOperation=e.narrationOperation,E._tickerOperation=e.tickerOperation,E._effectOperation=e.effectOperation,E._animateOperation=e.animateOperation,E._getLogichValue=e.getLogichValue,E._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return E._loadAssets}static get soundOperation(){return E._soundOperation}static get imageOperation(){return E._imageOperation}static get videoOperation(){return E._videoOperation}static get textOperation(){return E._textOperation}static get imageContainerOperation(){return E._imageContainerOperation}static get canvasElementOperation(){return E._canvasElementOperation}static get setStorageValue(){return E._setStorageValue}static get narrationOperation(){return E._narrationOperation}static get tickerOperation(){return E._tickerOperation}static get effectOperation(){return E._effectOperation}static get animateOperation(){return E._animateOperation}static get getLogichValue(){return E._getLogichValue}static get getConditionalStep(){return E._getConditionalStep}};j(L,"_loadAssets",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_soundOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_imageOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_videoOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_imageContainerOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_textOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_canvasElementOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_setStorageValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_narrationOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_tickerOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_effectOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_animateOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_getLogichValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_getConditionalStep",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var O=L;var dt=Object.create,de=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyNames,mt=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty,xt=(t,e,i)=>e in t?de(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i,Le=(t=>typeof a<"u"?a:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof a<"u"?a:e)[i]}):t)(function(t){if(typeof a<"u")return a.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),_e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bt=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of yt(e))!Tt.call(t,r)&&r!==i&&de(t,r,{get:()=>e[r],enumerable:!(n=ht(e,r))||n.enumerable});return t},vt=(t,e,i)=>(i=t!=null?dt(mt(t)):{},bt(de(i,"default",{value:t,enumerable:true}),t)),ge=(t,e,i)=>xt(t,typeof e!="symbol"?e+"":e,i),St=_e((t,e)=>{(function(i,n){typeof t=="object"?e.exports=t=n():typeof define=="function"&&define.amd?define([],n):i.CryptoJS=n();})(t,function(){var i=i||(function(n,r){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 Le=="function")try{o=Le("crypto");}catch{}var l=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.")},g=Object.create||(function(){function u(){}return function(a){var b;return u.prototype=a,b=new u,u.prototype=null,b}})(),c={},p=c.lib={},s=p.Base=(function(){return {extend:function(u){var a=g(this);return u&&a.mixIn(u),(!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 u=this.extend();return u.init.apply(u,arguments),u},init:function(){},mixIn:function(u){for(var a in u)u.hasOwnProperty(a)&&(this[a]=u[a]);u.hasOwnProperty("toString")&&(this.toString=u.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),d=p.WordArray=s.extend({init:function(u,a){u=this.words=u||[],a!=r?this.sigBytes=a:this.sigBytes=u.length*4;},toString:function(u){return (u||y).stringify(this)},concat:function(u){var a=this.words,b=u.words,h=this.sigBytes,v=u.sigBytes;if(this.clamp(),h%4)for(var N=0;N<v;N++){var ce=b[N>>>2]>>>24-N%4*8&255;a[h+N>>>2]|=ce<<24-(h+N)%4*8;}else for(var I=0;I<v;I+=4)a[h+I>>>2]=b[I>>>2];return this.sigBytes+=v,this},clamp:function(){var u=this.words,a=this.sigBytes;u[a>>>2]&=4294967295<<32-a%4*8,u.length=n.ceil(a/4);},clone:function(){var u=s.clone.call(this);return u.words=this.words.slice(0),u},random:function(u){for(var a=[],b=0;b<u;b+=4)a.push(l());return new d.init(a,u)}}),f=c.enc={},y=f.Hex={stringify:function(u){for(var a=u.words,b=u.sigBytes,h=[],v=0;v<b;v++){var N=a[v>>>2]>>>24-v%4*8&255;h.push((N>>>4).toString(16)),h.push((N&15).toString(16));}return h.join("")},parse:function(u){for(var a=u.length,b=[],h=0;h<a;h+=2)b[h>>>3]|=parseInt(u.substr(h,2),16)<<24-h%8*4;return new d.init(b,a/2)}},T=f.Latin1={stringify:function(u){for(var a=u.words,b=u.sigBytes,h=[],v=0;v<b;v++){var N=a[v>>>2]>>>24-v%4*8&255;h.push(String.fromCharCode(N));}return h.join("")},parse:function(u){for(var a=u.length,b=[],h=0;h<a;h++)b[h>>>2]|=(u.charCodeAt(h)&255)<<24-h%4*8;return new d.init(b,a)}},x=f.Utf8={stringify:function(u){try{return decodeURIComponent(escape(T.stringify(u)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(u){return T.parse(unescape(encodeURIComponent(u)))}},m=p.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(u){typeof u=="string"&&(u=x.parse(u)),this._data.concat(u),this._nDataBytes+=u.sigBytes;},_process:function(u){var a,b=this._data,h=b.words,v=b.sigBytes,N=this.blockSize,ce=N*4,I=v/ce;u?I=n.ceil(I):I=n.max((I|0)-this._minBufferSize,0);var te=I*N,Ne=n.min(te*4,v);if(te){for(var ue=0;ue<te;ue+=N)this._doProcessBlock(h,ue);a=h.splice(0,te),b.sigBytes-=Ne;}return new d.init(a,Ne)},clone:function(){var u=s.clone.call(this);return u._data=this._data.clone(),u},_minBufferSize:0});p.Hasher=m.extend({cfg:s.extend(),init:function(u){this.cfg=this.cfg.extend(u),this.reset();},reset:function(){m.reset.call(this),this._doReset();},update:function(u){return this._append(u),this._process(),this},finalize:function(u){u&&this._append(u);var a=this._doFinalize();return a},blockSize:16,_createHelper:function(u){return function(a,b){return new u.init(b).finalize(a)}},_createHmacHelper:function(u){return function(a,b){return new V.HMAC.init(u,b).finalize(a)}}});var V=c.algo={};return c})(Math);return i});}),Pt=_e((t,e)=>{(function(i,n){typeof t=="object"?e.exports=t=n(St()):typeof define=="function"&&define.amd?define(["./core"],n):n(i.CryptoJS);})(t,function(i){return (function(){var n=i,r=n.lib,o=r.WordArray,l=r.Hasher,g=n.algo,c=[],p=g.SHA1=l.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(s,d){for(var f=this._hash.words,y=f[0],T=f[1],x=f[2],m=f[3],V=f[4],u=0;u<80;u++){if(u<16)c[u]=s[d+u]|0;else {var a=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=a<<1|a>>>31;}var b=(y<<5|y>>>27)+V+c[u];u<20?b+=(T&x|~T&m)+1518500249:u<40?b+=(T^x^m)+1859775393:u<60?b+=(T&x|T&m|x&m)-1894007588:b+=(T^x^m)-899497514,V=m,m=x,x=T<<30|T>>>2,T=y,y=b;}f[0]=f[0]+y|0,f[1]=f[1]+T|0,f[2]=f[2]+x|0,f[3]=f[3]+m|0,f[4]=f[4]+V|0;},_doFinalize:function(){var s=this._data,d=s.words,f=this._nDataBytes*8,y=s.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(f/4294967296),d[(y+64>>>9<<4)+15]=f,s.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var s=l.clone.call(this);return s._hash=this._hash.clone(),s}});n.SHA1=l._createHelper(p),n.HmacSHA1=l._createHmacHelper(p);})(),i.SHA1});}),G;(t=>(t.log=(e,...i)=>console.log(`[Pixi\u2019VN Json] ${e}`,...i),t.warn=(e,...i)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...i),t.error=(e,...i)=>console.error(`[Pixi\u2019VN Json] ${e}`,...i),t.info=(e,...i)=>console.info(`[Pixi\u2019VN Json] ${e}`,...i)))(G||(G={}));async function he(t,e={}){let{operationStringConvert:i,skipEmptyDialogs:n}=e;if(!Array.isArray(t))if(typeof t=="object"||typeof t=="string")t=[t];else {G.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=t.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(g){G.error("Error parsing imported Pixi'VN JSON",g),l={};}return l}),o=(await Promise.all(r)).map(async l=>{let g=[];if(l.initialOperations){let c={};[...storage.storage.keys()].forEach((p,s)=>{c[p]=storage.storage.get(p);}),storage.startingStorage=c;}if(l.labels){let c=l.labels;for(let p in c)try{let s=c[p],d=new At(p,s,void 0,e);RegisteredLabels.add(d);}catch(s){G.error(`Error creating JSON label ${p}`,s);}}return Promise.all(g)});await Promise.all(o);}var Vt=vt(Pt()),je="___param___";function Ot(t){try{if(typeof t>"u")return t;let e=JSON.stringify(t);return JSON.parse(e)}catch(e){throw G.error("Error creating exportable element",t,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}async function De(t,e){let i=O.getLogichValue(t);if(i)switch(i.type){case "sound":O.soundOperation(i);break;case "assets":case "bundle":await O.loadAssets(i);break;case "image":await O.imageOperation(i);break;case "video":await O.videoOperation(i);break;case "imagecontainer":await O.imageContainerOperation(i);break;case "text":await O.textOperation(i);break;case "canvaselement":await O.canvasElementOperation(i);break;case "value":O.setStorageValue(i);break;case "operationtoconvert":if(e){let n="";i.values.forEach(o=>{if(typeof o=="string")n+=o;else {let l=O.getLogichValue(o);n+=`${l}`;}});let r=await e(n);r&&await De(r,e);}break;case "input":case "dialogue":O.narrationOperation(i);break;case "fade":case "move":case "rotate":case "zoom":O.tickerOperation(i);break;case "shake":await O.effectOperation(i);break;case "animate":case "animate-sequence":O.animateOperation(i);break}}var At=class extends LabelAbstract{constructor(t,e,i,n={}){i||(i={}),i.onLoadingLabel=async()=>{for(let r of e){let o;if(typeof r=="function"?o=r():o=r,o=O.getConditionalStep(o),o.operations){let l=o.operations.map(g=>O.loadAssets(g));await Promise.all(l);}}},super(t,i),ge(this,"_steps"),ge(this,"operationStringConvert"),ge(this,"skipEmptyDialogs",false),this._steps=e,this.operationStringConvert=n.operationStringConvert,this.skipEmptyDialogs=n.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let e=this._steps[t];return this.stepConverter(e)}getStepSha(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, Vt.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let i=[];t.forEach(n=>{if(typeof n=="string")i.push(n);else if(n&&typeof n=="object"){let r=O.getLogichValue(n);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=O.getLogichValue(r)||""),Array.isArray(r)?i=i.map(o=>`${o}`).concat(r):i.push(`${r}`)):i.push(`${n}`);}else i.push(`${n}`);}),e=i;}else {let i=O.getLogichValue(t)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=O.getLogichValue(i)||""),e=i;}return `${e}`}getDialogue(t){if(t==null)return;let e=O.getLogichValue(t);return e==null?"":typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:J.t(this.getDialogueText(e.text))}:J.t(this.getDialogueText(e))}getChoices(t){return O.getLogichValue(t)?.map(e=>O.getLogichValue(e)).filter(e=>e!==void 0)}stepConverter(t){return async e=>{let i=typeof t=="function"?t():t;i=Ot(i),i=O.getConditionalStep(i);let n=this.operationStringConvert?f=>this.operationStringConvert(f,i,e):void 0,{operations:r=[]}=i;for(let f of r)await De(f,n);let{labelToOpen:o=[]}=i,l=this.getChoices(i.choices),g=O.getLogichValue(i.glueEnabled),c=this.getDialogue(i.dialogue),p=[];Array.isArray(o)||(o=[o]),o.forEach(f=>{let y=O.getLogichValue(f);y&&p.push(y);});let s=O.getLogichValue(i.goNextStep),d=O.getLogichValue(i.end);if(l){let f=l.map(y=>{let T="";if(Array.isArray(y.text)){let x=[];y.text.forEach(m=>{if(typeof m=="string")x.push(J.t(m));else if(m&&typeof m=="object"){let V=O.getLogichValue(m);V&&!Array.isArray(V)&&typeof V=="object"&&(V=O.getLogichValue(V)||""),V&&(Array.isArray(V)?x=x.concat(J.t(V)):x.push(J.t(V)));}}),T=x;}else typeof y.text=="string"&&(T=J.t(y.text));return {label:y.label,text:T,props:y.props,type:y.type,oneTime:y.oneTime,onlyHaveNoChoice:y.onlyHaveNoChoice,autoSelect:y.autoSelect}});narration.choiceMenuOptions=f;}else narration.choiceMenuOptions=void 0;c!==void 0&&(narration.dialogue=c,this.skipEmptyDialogs&&typeof c=="string"&&(c===""||RegExp(/^\s+$/).test(c))&&(s=true)),g?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):g===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let f of p){let y=f.label;typeof y=="object"&&(y=O.getLogichValue(y)||"");let T=f.params?.map(x=>O.getLogichValue(x));e={...e,...f.props},f.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${je}${narration.openedLabels.length}`,T),await narration.callLabel(y,e)):(storage.setTempVariable(`${je}${narration.openedLabels.length}`,T),await narration.callLabel(y,e));}d==="game_end"?(narration.closeAllLabels(),await narration.goNext(e,{runNow:true})):d==="label_end"&&narration.closeCurrentLabel(),s&&await narration.goNext(e,{runNow:true});}}};var me="___param___";async function Qt(t){let e=O.getLogichValue(t);if(e)switch(e.type){case "assets":switch(e.operationType){case "load":await Assets.load(e.aliases);break;case "lazyload":Assets.backgroundLoad(e.aliases);break}break;case "bundle":switch(e.operationType){case "load":await Assets.loadBundle(e.aliases);break;case "lazyload":Assets.backgroundLoadBundle(e.aliases);break}break}}var R;(t=>(t.log=(e,...i)=>console.log(`[Pixi\u2019VN Json] ${e}`,...i),t.warn=(e,...i)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...i),t.error=(e,...i)=>console.error(`[Pixi\u2019VN Json] ${e}`,...i),t.info=(e,...i)=>console.info(`[Pixi\u2019VN Json] ${e}`,...i)))(R||(R={}));async function oe(t,e,i){switch(i.type){case "fade":await showWithFade(e.alias,t,i.props,i.priority);break;case "dissolve":await showWithDissolve(e.alias,t,i.props,i.priority);break;case "movein":case "moveout":await moveIn(e.alias,t,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(e.alias,t,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(e.alias,t,i.props,i.priority);break}}function Z(t){if(t.transition)switch(t.transition.type){case "fade":removeWithFade(t.alias,t.transition.props,t.transition.priority);break;case "dissolve":removeWithDissolve(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);}async function Xt(t){switch(t.operationType){case "show":if(t.transition){let i=new ImageSprite(t.props,t.url||t.alias);await oe(i,t,t.transition);}else await showImage(t.alias,t.url,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`Image with alias ${t.alias} not found.`);break;case "remove":Z(t);break}}async function Kt(t){switch(t.operationType){case "show":if(t.transition){let r=new VideoSprite(t.props,t.url||t.alias);await oe(r,t,t.transition);}else await showVideo(t.alias,t.url,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`Video with alias ${t.alias} not found.`);break;case "remove":Z(t);break;case "pause":let i=canvas.find(t.alias);i?i.paused=true:R.error(`Video with alias ${t.alias} not found.`);break;case "resume":let n=canvas.find(t.alias);n?n.paused=false:R.error(`Video with alias ${t.alias} not found.`);break}}async function Zt(t){switch(t.operationType){case "show":if(t.transition){let i=new ImageContainer(t.props,t.urls);await oe(i,t,t.transition);}else await showImageContainer(t.alias,t.urls,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`ImageContainer with alias ${t.alias} not found.`);break;case "remove":Z(t);break}}async function ei(t){switch(t.operationType){case "show":if(t.props=t.props||{},t.props.text=J.t(t.text),t.transition){let i=new Text(t.props);await oe(i,t,t.transition);}else showText(t.alias,t.text,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`Text with alias ${t.alias} not found.`);break;case "remove":Z(t);break}}async function ti(t){switch(t.operationType){case "edit":try{let e=canvas.find(t.alias);e?t.props&&(e.memory={...e.memory,...t.props}):R.error(`Canvas Element with alias ${t.alias} not found.`);}catch(e){R.error(`There was an error while trying to edit the canvas element with alias ${t.alias}.`,e);}break;case "remove":Z(t);break}}function ii(t){switch(t.type){case "fade":let e=new FadeAlphaTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,e);break;case "move":let i=new MoveTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,i);break;case "rotate":let n=new RotateTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,n);break;case "zoom":let r=new ZoomTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,r);break}}async function ri(t){switch(t.type){case "shake":await shakeEffect(t.alias,t.props,t.priority);break}}function ni(t){switch(t.type){case "animate":canvas.animate(t.alias,t.keyframes,t.options,t.priority);break;case "animate-sequence":canvas.animate(t.alias,t.sequence,t.options,t.priority);break}}function oi(t){switch(t.type){case "input":narration$1.requestInput({type:t.valueType},t.defaultValue);break;case "dialogue":narration$1.dialogue=void 0;break}}function ai(t){switch(t.operationType){case "play":sound.play(t.alias,t.props);break;case "stop":sound.stop(t.alias);break;case "pause":sound.pause(t.alias);break;case "resume":sound.resume(t.alias);break;case "volume":sound.volume(t.alias,t.value);break}}function si(t){try{if(typeof t>"u")return t;let e=JSON.stringify(t);return JSON.parse(e)}catch(e){throw R.error("Error creating exportable element",t,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function li(t){let e=w(t.value),i;switch(e&&typeof e=="object"&&"type"in e?i=w(e):i=e,t.storageType){case "flagStorage":storage.setFlag(t.key,t.value);break;case "storage":storage.setVariable(t.key,i);break;case "tempstorage":storage.setTempVariable(t.key,i);break;case "params":let n=storage.getVariable(`${me}${narration.openedLabels.length-1}`)||[];n&&n.length-1>=t.key&&(n[t.key]=i),storage.setTempVariable(`${me}${narration.openedLabels.length-1}`,n);break}}function w(t){let e=di(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return ci(e);case "arithmetic":case "arithmeticsingle":return pi(e);case "compare":case "valueCondition":case "union":return ui(e)}return e}function pi(t){let e=w(t.leftValue);switch(t.type){case "arithmetic":let i=w(t.rightValue);switch(t.operator){case "*":return e*i;case "/":return e/i;case "+":return e+i;case "-":return e-i;case "%":return e%i;case "POW":return Math.pow(e,i);case "RANDOM":return narration.getRandomNumber(e,i)}case "arithmeticsingle":switch(t.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function ci(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 storage.getFlag(t.key);case "label":return narration.getTimesLabelOpened(t.label);case "choice":return narration.getTimesChoiceMade(t.index);case "logic":return w(t.operation);case "params":let e=storage.getVariable(`${me}${narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];R.warn("getValue params not found");return}return t}function ui(t){if(!t)return false;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case "compare":let e=w(t.leftValue),i=w(t.rightValue);switch(t.operator){case "==":return e===i;case "!=":return e!==i;case "<":return e<i;case "<=":return e<=i;case ">":return e>i;case ">=":return e>=i;case "CONTAINS":return e.toString().includes(i.toString())}break;case "valueCondition":return !!w(t.value);case "union":return fi(t)}return !!t}function fi(t){if(t.unionType==="not")return !w(t.condition);let e=t.unionType==="and";for(let i=0;i<t.conditions.length;i++)if(e=w(t.conditions[i])||false,t.unionType==="and"){if(!e)return false}else if(e)return true;return e}function gi(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function di(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "resulttocombine":return hi(t);case "ifelse":return w(t.condition)?w(t.then):w(t.else);case "stepswitch":let e=w(t.elements)||[];if(e.length===0){R.error("getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case "random":let i=gi(0,e.length-1);return w(e[i]);case "loop":let n=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return n>e.length-1&&(n=n%e.length),w(e[n]);case "sequential":let r,o=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(r=w(e[e.length-1])),o>e.length-1?r:w(e[o]);case "sequentialrandom":let l=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:true});if(l==null&&t.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){R.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=g.usedRandomNumbers[`0-${e.length-1}`];return w(e[c[c.length-1]])}if(l==null){R.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return w(e[l])}}return t}function Te(t){if(t.conditionalStep){let e=si(w(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let i={...t,conditionalStep:void 0,...e};return Te(i)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return t}function hi(t){let e=t.firstItem,i=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(o=>{let l=w(o);i.push(l);});else {let o=w(r);i.push(o);}});let n=e?[e,...i]:i;if(n.length===0){R.warn("combinateResult toCheck.length === 0");return}if(typeof n[0]=="string")return J.t(n);if(typeof n[0]=="object"){let r=n,o,l=r.map((m,V)=>{m=Te(m);let u=w(m.dialogue)||"";return V===0?(o=w(m.glueEnabled)||false,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===false&&(u=`
1
+ import {a,c,b,e,d,f}from'./chunk-GMXDYDC6.mjs';import {RegisteredLabels,narration,LabelAbstract,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {storage,SYSTEM_RESERVED_STORAGE_KEYS}from'@drincs/pixi-vn/storage';import {canvas,VideoSprite,showVideo,ZoomTicker,RotateTicker,MoveTicker,FadeAlphaTicker,sound,Assets,narration as narration$1,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';var st=Object.defineProperty,lt=(t,e,i)=>e in t?st(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i,fe=(t,e,i)=>lt(t,typeof e!="symbol"?e+"":e,i),ie=class P{static t(e){return Array.isArray(e)?e.map(i=>P.translate(`${i}`)):P.translate(`${e}`)}static set beforeToTranslate(e){P._beforeToTranslate=e;}static set translate(e){P._translate=e;}static get translate(){return e=>{let i=e;return P._beforeToTranslate&&(i=P._beforeToTranslate(i)),i=P._translate(i),P._afterToTranslate&&(i=P._afterToTranslate(i)),i}}static set afterToTranslate(e){P._afterToTranslate=e;}static addKey(e,i,n){let r=n.defaultValue||"empty_string";typeof i=="string"&&(i=[i]),Array.isArray(i)&&i.forEach(o=>{e[o]===void 0&&(r==="empty_string"?e[o]="":r==="copy_key"&&(P._beforeToTranslate?e[o]=P._beforeToTranslate(o):e[o]=o));});}static getConditionalsThenElse(e,i=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&P.getConditionalsThenElse(e.then,i),e.else&&P.getConditionalsThenElse(e.else,i);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(n=>{P.getConditionalsThenElse(n,i);});else if(e.elements.type==="ifelse"){let n=[];P.getConditionalsThenElse(e.elements,n),n.forEach(r=>{i.push(...r);});}else if(e.elements.type==="stepswitch"){let n=[];P.getConditionalsThenElse(e.elements,n),n.forEach(r=>{i.push(...r);});}else P.getConditionalsThenElse(e.elements,i);}else e.type==="resulttocombine"?(e.firstItem&&P.getConditionalsThenElse(e.firstItem,i),e.secondConditionalItem&&e.secondConditionalItem.forEach(n=>{P.getConditionalsThenElse(n,i);})):i.push(e);else e&&i.push(e);return i}static generateJsonTranslation(e,i={},n={}){let{defaultValue:r="copy_key"}=n;return e.forEach(o=>{if(o.choices){let l=[];Array.isArray(o.choices)?l=[o.choices]:l=P.getConditionalsThenElse(o.choices),l.forEach(g=>g.forEach(c=>{if("type"in c){let p=[];c.type==="ifelse"||c.type==="stepswitch"?P.getConditionalsThenElse(c,p):p=[c],p.map(s=>P.getConditionalsThenElse(s.text)).forEach(s=>{Array.isArray(s)&&s.forEach(d=>{Array.isArray(d)?d.forEach(f=>{typeof f=="string"?P.addKey(i,f,{defaultValue:r}):P.getConditionalsThenElse(f).forEach(y=>{Array.isArray(y)?y.forEach(T=>{typeof T=="string"&&P.addKey(i,T,{defaultValue:r});}):typeof y=="string"&&P.addKey(i,y,{defaultValue:r});});}):typeof d=="string"&&P.addKey(i,d,{defaultValue:r});});});}}));}if(o.dialogue){let l=[];Array.isArray(o.dialogue)?l=[o.dialogue]:l=P.getConditionalsThenElse(o.dialogue),l.forEach(g=>{if(typeof g=="string")P.addKey(i,g,{defaultValue:r});else if("text"in g){let c=P.getConditionalsThenElse(g.text);typeof c=="string"&&(c=[c]),c.forEach(p=>{typeof p=="string"?P.addKey(i,p,{defaultValue:r}):P.getConditionalsThenElse(p).forEach(s=>{typeof s=="string"?P.addKey(i,s,{defaultValue:r}):Array.isArray(s)&&s.forEach(d=>{typeof d=="string"?P.addKey(i,d,{defaultValue:r}):P.getConditionalsThenElse(d).forEach(f=>{typeof f=="string"&&P.addKey(i,f,{defaultValue:r});});});});});}});}o.operations&&o.operations.forEach(l=>{switch(l.type){case "text":switch(l.operationType){case "show":P.addKey(i,l.text,{defaultValue:r});break}break}}),o.conditionalStep&&P.getConditionalsThenElse(o.conditionalStep).forEach(l=>{Array.isArray(l)?P.generateJsonTranslation(l,i,n):P.generateJsonTranslation([l],i,n);});}),i}};fe(ie,"_beforeToTranslate"),fe(ie,"_translate",t=>t),fe(ie,"_afterToTranslate");var pt=ie,J=pt;var ct=Object.defineProperty,ut=(t,e,i)=>e in t?ct(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i,j=(t,e,i)=>ut(t,typeof e!="symbol"?e+"":e,i),k;(t=>(t.log=(e,...i)=>console.log(`[Pixi\u2019VN Json] ${e}`,...i),t.warn=(e,...i)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...i),t.error=(e,...i)=>console.error(`[Pixi\u2019VN Json] ${e}`,...i),t.info=(e,...i)=>console.info(`[Pixi\u2019VN Json] ${e}`,...i)))(k||(k={}));var L=class E{static init(e){E._loadAssets=e.loadAssets,E._soundOperation=e.soundOperation,E._imageOperation=e.imageOperation,E._videoOperation=e.videoOperation,E._imageContainerOperation=e.imageContainerOperation,E._textOperation=e.textOperation,E._canvasElementOperation=e.canvasElementOperation,E._setStorageValue=e.setStorageValue,E._narrationOperation=e.narrationOperation,E._tickerOperation=e.tickerOperation,E._effectOperation=e.effectOperation,E._animateOperation=e.animateOperation,E._getLogichValue=e.getLogichValue,E._getConditionalStep=e.getConditionalStep;}static get loadAssets(){return E._loadAssets}static get soundOperation(){return E._soundOperation}static get imageOperation(){return E._imageOperation}static get videoOperation(){return E._videoOperation}static get textOperation(){return E._textOperation}static get imageContainerOperation(){return E._imageContainerOperation}static get canvasElementOperation(){return E._canvasElementOperation}static get setStorageValue(){return E._setStorageValue}static get narrationOperation(){return E._narrationOperation}static get tickerOperation(){return E._tickerOperation}static get effectOperation(){return E._effectOperation}static get animateOperation(){return E._animateOperation}static get getLogichValue(){return E._getLogichValue}static get getConditionalStep(){return E._getConditionalStep}};j(L,"_loadAssets",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_soundOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_imageOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_videoOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_imageContainerOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_textOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_canvasElementOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_setStorageValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_narrationOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_tickerOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_effectOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_animateOperation",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_getLogichValue",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),j(L,"_getConditionalStep",()=>{throw k.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var O=L;var dt=Object.create,de=Object.defineProperty,ht=Object.getOwnPropertyDescriptor,yt=Object.getOwnPropertyNames,mt=Object.getPrototypeOf,Tt=Object.prototype.hasOwnProperty,xt=(t,e,i)=>e in t?de(t,e,{enumerable:true,configurable:true,writable:true,value:i}):t[e]=i,Le=(t=>typeof a<"u"?a:typeof Proxy<"u"?new Proxy(t,{get:(e,i)=>(typeof a<"u"?a:e)[i]}):t)(function(t){if(typeof a<"u")return a.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')}),_e=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bt=(t,e,i,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of yt(e))!Tt.call(t,r)&&r!==i&&de(t,r,{get:()=>e[r],enumerable:!(n=ht(e,r))||n.enumerable});return t},vt=(t,e,i)=>(i=t!=null?dt(mt(t)):{},bt(de(i,"default",{value:t,enumerable:true}),t)),ge=(t,e,i)=>xt(t,typeof e!="symbol"?e+"":e,i),St=_e((t,e)=>{(function(i,n){typeof t=="object"?e.exports=t=n():typeof define=="function"&&define.amd?define([],n):i.CryptoJS=n();})(t,function(){var i=i||(function(n,r){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 Le=="function")try{o=Le("crypto");}catch{}var l=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.")},g=Object.create||(function(){function u(){}return function(a){var b;return u.prototype=a,b=new u,u.prototype=null,b}})(),c={},p=c.lib={},s=p.Base=(function(){return {extend:function(u){var a=g(this);return u&&a.mixIn(u),(!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 u=this.extend();return u.init.apply(u,arguments),u},init:function(){},mixIn:function(u){for(var a in u)u.hasOwnProperty(a)&&(this[a]=u[a]);u.hasOwnProperty("toString")&&(this.toString=u.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),d=p.WordArray=s.extend({init:function(u,a){u=this.words=u||[],a!=r?this.sigBytes=a:this.sigBytes=u.length*4;},toString:function(u){return (u||y).stringify(this)},concat:function(u){var a=this.words,b=u.words,h=this.sigBytes,v=u.sigBytes;if(this.clamp(),h%4)for(var N=0;N<v;N++){var ce=b[N>>>2]>>>24-N%4*8&255;a[h+N>>>2]|=ce<<24-(h+N)%4*8;}else for(var I=0;I<v;I+=4)a[h+I>>>2]=b[I>>>2];return this.sigBytes+=v,this},clamp:function(){var u=this.words,a=this.sigBytes;u[a>>>2]&=4294967295<<32-a%4*8,u.length=n.ceil(a/4);},clone:function(){var u=s.clone.call(this);return u.words=this.words.slice(0),u},random:function(u){for(var a=[],b=0;b<u;b+=4)a.push(l());return new d.init(a,u)}}),f=c.enc={},y=f.Hex={stringify:function(u){for(var a=u.words,b=u.sigBytes,h=[],v=0;v<b;v++){var N=a[v>>>2]>>>24-v%4*8&255;h.push((N>>>4).toString(16)),h.push((N&15).toString(16));}return h.join("")},parse:function(u){for(var a=u.length,b=[],h=0;h<a;h+=2)b[h>>>3]|=parseInt(u.substr(h,2),16)<<24-h%8*4;return new d.init(b,a/2)}},T=f.Latin1={stringify:function(u){for(var a=u.words,b=u.sigBytes,h=[],v=0;v<b;v++){var N=a[v>>>2]>>>24-v%4*8&255;h.push(String.fromCharCode(N));}return h.join("")},parse:function(u){for(var a=u.length,b=[],h=0;h<a;h++)b[h>>>2]|=(u.charCodeAt(h)&255)<<24-h%4*8;return new d.init(b,a)}},x=f.Utf8={stringify:function(u){try{return decodeURIComponent(escape(T.stringify(u)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(u){return T.parse(unescape(encodeURIComponent(u)))}},m=p.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new d.init,this._nDataBytes=0;},_append:function(u){typeof u=="string"&&(u=x.parse(u)),this._data.concat(u),this._nDataBytes+=u.sigBytes;},_process:function(u){var a,b=this._data,h=b.words,v=b.sigBytes,N=this.blockSize,ce=N*4,I=v/ce;u?I=n.ceil(I):I=n.max((I|0)-this._minBufferSize,0);var te=I*N,Ne=n.min(te*4,v);if(te){for(var ue=0;ue<te;ue+=N)this._doProcessBlock(h,ue);a=h.splice(0,te),b.sigBytes-=Ne;}return new d.init(a,Ne)},clone:function(){var u=s.clone.call(this);return u._data=this._data.clone(),u},_minBufferSize:0});p.Hasher=m.extend({cfg:s.extend(),init:function(u){this.cfg=this.cfg.extend(u),this.reset();},reset:function(){m.reset.call(this),this._doReset();},update:function(u){return this._append(u),this._process(),this},finalize:function(u){u&&this._append(u);var a=this._doFinalize();return a},blockSize:16,_createHelper:function(u){return function(a,b){return new u.init(b).finalize(a)}},_createHmacHelper:function(u){return function(a,b){return new V.HMAC.init(u,b).finalize(a)}}});var V=c.algo={};return c})(Math);return i});}),Pt=_e((t,e)=>{(function(i,n){typeof t=="object"?e.exports=t=n(St()):typeof define=="function"&&define.amd?define(["./core"],n):n(i.CryptoJS);})(t,function(i){return (function(){var n=i,r=n.lib,o=r.WordArray,l=r.Hasher,g=n.algo,c=[],p=g.SHA1=l.extend({_doReset:function(){this._hash=new o.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(s,d){for(var f=this._hash.words,y=f[0],T=f[1],x=f[2],m=f[3],V=f[4],u=0;u<80;u++){if(u<16)c[u]=s[d+u]|0;else {var a=c[u-3]^c[u-8]^c[u-14]^c[u-16];c[u]=a<<1|a>>>31;}var b=(y<<5|y>>>27)+V+c[u];u<20?b+=(T&x|~T&m)+1518500249:u<40?b+=(T^x^m)+1859775393:u<60?b+=(T&x|T&m|x&m)-1894007588:b+=(T^x^m)-899497514,V=m,m=x,x=T<<30|T>>>2,T=y,y=b;}f[0]=f[0]+y|0,f[1]=f[1]+T|0,f[2]=f[2]+x|0,f[3]=f[3]+m|0,f[4]=f[4]+V|0;},_doFinalize:function(){var s=this._data,d=s.words,f=this._nDataBytes*8,y=s.sigBytes*8;return d[y>>>5]|=128<<24-y%32,d[(y+64>>>9<<4)+14]=Math.floor(f/4294967296),d[(y+64>>>9<<4)+15]=f,s.sigBytes=d.length*4,this._process(),this._hash},clone:function(){var s=l.clone.call(this);return s._hash=this._hash.clone(),s}});n.SHA1=l._createHelper(p),n.HmacSHA1=l._createHmacHelper(p);})(),i.SHA1});}),G;(t=>(t.log=(e,...i)=>console.log(`[Pixi\u2019VN Json] ${e}`,...i),t.warn=(e,...i)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...i),t.error=(e,...i)=>console.error(`[Pixi\u2019VN Json] ${e}`,...i),t.info=(e,...i)=>console.info(`[Pixi\u2019VN Json] ${e}`,...i)))(G||(G={}));async function he(t,e={}){let{operationStringConvert:i,skipEmptyDialogs:n}=e;if(!Array.isArray(t))if(typeof t=="object"||typeof t=="string")t=[t];else {G.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=t.map(async l=>{if(typeof l=="string")try{l=JSON.parse(l);}catch(g){G.error("Error parsing imported Pixi'VN JSON",g),l={};}return l}),o=(await Promise.all(r)).map(async l=>{let g=[];if(l.initialOperations){let c={};[...storage.storage.keys()].forEach((p,s)=>{c[p]=storage.storage.get(p);}),storage.startingStorage=c;}if(l.labels){let c=l.labels;for(let p in c)try{let s=c[p],d=new At(p,s,void 0,e);RegisteredLabels.add(d);}catch(s){G.error(`Error creating JSON label ${p}`,s);}}return Promise.all(g)});await Promise.all(o);}var Vt=vt(Pt()),je="___param___";function Ot(t){try{if(typeof t>"u")return t;let e=JSON.stringify(t);return JSON.parse(e)}catch(e){throw G.error("Error creating exportable element",t,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}async function De(t,e){let i=O.getLogichValue(t);if(i)switch(i.type){case "sound":O.soundOperation(i);break;case "assets":case "bundle":await O.loadAssets(i);break;case "image":await O.imageOperation(i);break;case "video":await O.videoOperation(i);break;case "imagecontainer":await O.imageContainerOperation(i);break;case "text":await O.textOperation(i);break;case "canvaselement":await O.canvasElementOperation(i);break;case "value":O.setStorageValue(i);break;case "operationtoconvert":if(e){let n="";i.values.forEach(o=>{if(typeof o=="string")n+=o;else {let l=O.getLogichValue(o);n+=`${l}`;}});let r=await e(n);r&&await De(r,e);}break;case "input":case "dialogue":O.narrationOperation(i);break;case "fade":case "move":case "rotate":case "zoom":O.tickerOperation(i);break;case "shake":await O.effectOperation(i);break;case "animate":case "animate-sequence":O.animateOperation(i);break}}var At=class extends LabelAbstract{constructor(t,e,i,n={}){i||(i={}),i.onLoadingLabel=async()=>{for(let r of e){let o;if(typeof r=="function"?o=r():o=r,o=O.getConditionalStep(o),o.operations){let l=o.operations.map(g=>O.loadAssets(g));await Promise.all(l);}}},super(t,i),ge(this,"_steps"),ge(this,"operationStringConvert"),ge(this,"skipEmptyDialogs",false),this._steps=e,this.operationStringConvert=n.operationStringConvert,this.skipEmptyDialogs=n.skipEmptyDialogs||false;}get steps(){return this._steps.map(t=>this.stepConverter(t))}get stepCount(){return this._steps.length}getStepById(t){if(t<0||t>=this._steps.length)return;let e=this._steps[t];return this.stepConverter(e)}getStepSha(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, Vt.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let i=[];t.forEach(n=>{if(typeof n=="string")i.push(n);else if(n&&typeof n=="object"){let r=O.getLogichValue(n);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=O.getLogichValue(r)||""),Array.isArray(r)?i=i.map(o=>`${o}`).concat(r):i.push(`${r}`)):i.push(`${n}`);}else i.push(`${n}`);}),e=i;}else {let i=O.getLogichValue(t)||"";i&&!Array.isArray(i)&&typeof i=="object"&&(i=O.getLogichValue(i)||""),e=i;}return `${e}`}getDialogue(t){if(t==null)return;let e=O.getLogichValue(t);return e==null?"":typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:J.t(this.getDialogueText(e.text))}:J.t(this.getDialogueText(e))}getChoices(t){return O.getLogichValue(t)?.map(e=>O.getLogichValue(e)).filter(e=>e!==void 0)}stepConverter(t){return async e=>{let i=typeof t=="function"?t():t;i=Ot(i),i=O.getConditionalStep(i);let n=this.operationStringConvert?f=>this.operationStringConvert(f,i,e):void 0,{operations:r=[]}=i;for(let f of r)await De(f,n);let{labelToOpen:o=[]}=i,l=this.getChoices(i.choices),g=O.getLogichValue(i.glueEnabled),c=this.getDialogue(i.dialogue),p=[];Array.isArray(o)||(o=[o]),o.forEach(f=>{let y=O.getLogichValue(f);y&&p.push(y);});let s=O.getLogichValue(i.goNextStep),d=O.getLogichValue(i.end);if(l){let f=l.map(y=>{let T="";if(Array.isArray(y.text)){let x=[];y.text.forEach(m=>{if(typeof m=="string")x.push(J.t(m));else if(m&&typeof m=="object"){let V=O.getLogichValue(m);V&&!Array.isArray(V)&&typeof V=="object"&&(V=O.getLogichValue(V)||""),V&&(Array.isArray(V)?x=x.concat(J.t(V)):x.push(J.t(V)));}}),T=x;}else typeof y.text=="string"&&(T=J.t(y.text));return {label:y.label,text:T,props:y.props,type:y.type,oneTime:y.oneTime,onlyHaveNoChoice:y.onlyHaveNoChoice,autoSelect:y.autoSelect}});narration.choiceMenuOptions=f;}else narration.choiceMenuOptions=void 0;c!==void 0&&(narration.dialogue=c,this.skipEmptyDialogs&&typeof c=="string"&&(c===""||RegExp(/^\s+$/).test(c))&&(s=true)),g?storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):g===false&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let f of p){let y=f.label;typeof y=="object"&&(y=O.getLogichValue(y)||"");let T=f.params?.map(x=>O.getLogichValue(x));e={...e,...f.props},f.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${je}${narration.openedLabels.length}`,T),await narration.callLabel(y,e)):(storage.setTempVariable(`${je}${narration.openedLabels.length}`,T),await narration.callLabel(y,e));}d==="game_end"?(narration.closeAllLabels(),await narration.goNext(e,{runNow:true})):d==="label_end"&&narration.closeCurrentLabel(),s&&await narration.goNext(e,{runNow:true});}}};var me="___param___";async function Qt(t){let e=O.getLogichValue(t);if(e)switch(e.type){case "assets":switch(e.operationType){case "load":await Assets.load(e.aliases);break;case "lazyload":Assets.backgroundLoad(e.aliases);break}break;case "bundle":switch(e.operationType){case "load":await Assets.loadBundle(e.aliases);break;case "lazyload":Assets.backgroundLoadBundle(e.aliases);break}break}}var R;(t=>(t.log=(e,...i)=>console.log(`[Pixi\u2019VN Json] ${e}`,...i),t.warn=(e,...i)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...i),t.error=(e,...i)=>console.error(`[Pixi\u2019VN Json] ${e}`,...i),t.info=(e,...i)=>console.info(`[Pixi\u2019VN Json] ${e}`,...i)))(R||(R={}));async function oe(t,e,i){switch(i.type){case "fade":await showWithFade(e.alias,t,i.props,i.priority);break;case "dissolve":await showWithDissolve(e.alias,t,i.props,i.priority);break;case "movein":case "moveout":await moveIn(e.alias,t,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(e.alias,t,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(e.alias,t,i.props,i.priority);break}}function Z(t){if(t.transition)switch(t.transition.type){case "fade":removeWithFade(t.alias,t.transition.props,t.transition.priority);break;case "dissolve":removeWithDissolve(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);}async function Xt(t){switch(t.operationType){case "show":if(t.transition){let i=new ImageSprite(t.props,t.url||t.alias);await oe(i,t,t.transition);}else await showImage(t.alias,t.url,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`Image with alias ${t.alias} not found.`);break;case "remove":Z(t);break}}async function Kt(t){switch(t.operationType){case "show":if(t.transition){let r=new VideoSprite(t.props,t.url||t.alias);await oe(r,t,t.transition);}else await showVideo(t.alias,t.url,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`Video with alias ${t.alias} not found.`);break;case "remove":Z(t);break;case "pause":let i=canvas.find(t.alias);i?i.paused=true:R.error(`Video with alias ${t.alias} not found.`);break;case "resume":let n=canvas.find(t.alias);n?n.paused=false:R.error(`Video with alias ${t.alias} not found.`);break}}async function Zt(t){switch(t.operationType){case "show":if(t.transition){let i=new ImageContainer(t.props,t.urls);await oe(i,t,t.transition);}else await showImageContainer(t.alias,t.urls,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`ImageContainer with alias ${t.alias} not found.`);break;case "remove":Z(t);break}}async function ei(t){switch(t.operationType){case "show":if(t.props=t.props||{},t.props.text=J.t(t.text),t.transition){let i=new Text(t.props);await oe(i,t,t.transition);}else showText(t.alias,t.text,t.props);break;case "edit":let e=canvas.find(t.alias);e?t.props&&await e.setMemory({...e.memory,...t.props}):R.error(`Text with alias ${t.alias} not found.`);break;case "remove":Z(t);break}}async function ti(t){switch(t.operationType){case "edit":try{let e=canvas.find(t.alias);e?t.props&&(e.memory={...e.memory,...t.props}):R.error(`Canvas Element with alias ${t.alias} not found.`);}catch(e){R.error(`There was an error while trying to edit the canvas element with alias ${t.alias}.`,e);}break;case "remove":Z(t);break}}function ii(t){switch(t.type){case "fade":let e=new FadeAlphaTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,e);break;case "move":let i=new MoveTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,i);break;case "rotate":let n=new RotateTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,n);break;case "zoom":let r=new ZoomTicker(t.props,t.duration,t.priority);canvas.addTicker(t.alias,r);break}}async function ri(t){switch(t.type){case "shake":await shakeEffect(t.alias,t.props,t.priority);break}}function ni(t){switch(t.type){case "animate":canvas.animate(t.alias,t.keyframes,t.options,t.priority);break;case "animate-sequence":canvas.animate(t.alias,t.sequence,t.options,t.priority);break}}function oi(t){switch(t.type){case "input":narration$1.requestInput({type:t.valueType},t.defaultValue);break;case "dialogue":narration$1.dialogue=void 0;break}}function ai(t){switch(t.operationType){case "play":sound.play(t.alias,t.props);break;case "stop":sound.stop(t.alias);break;case "pause":sound.pause(t.alias);break;case "resume":sound.resume(t.alias);break;case "volume":sound.volume(t.alias,t.value);break}}function si(t){try{if(typeof t>"u")return t;let e=JSON.stringify(t);return JSON.parse(e)}catch(e){throw R.error("Error creating exportable element",t,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function li(t){let e=w(t.value),i;switch(e&&typeof e=="object"&&"type"in e?i=w(e):i=e,t.storageType){case "flagStorage":storage.setFlag(t.key,t.value);break;case "storage":storage.setVariable(t.key,i);break;case "tempstorage":storage.setTempVariable(t.key,i);break;case "params":let n=storage.getVariable(`${me}${narration.openedLabels.length-1}`)||[];n&&n.length-1>=t.key&&(n[t.key]=i),storage.setTempVariable(`${me}${narration.openedLabels.length-1}`,n);break}}function w(t){let e=di(t);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return ci(e);case "arithmetic":case "arithmeticsingle":return pi(e);case "compare":case "valueCondition":case "union":return ui(e)}return e}function pi(t){let e=w(t.leftValue);switch(t.type){case "arithmetic":let i=w(t.rightValue);switch(t.operator){case "*":return e*i;case "/":return e/i;case "+":return e+i;case "-":return e-i;case "%":return e%i;case "POW":return Math.pow(e,i);case "RANDOM":return narration.getRandomNumber(e,i)}case "arithmeticsingle":switch(t.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function ci(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 storage.getFlag(t.key);case "label":return narration.getTimesLabelOpened(t.label);case "choice":return narration.getTimesChoiceMade(t.index);case "logic":return w(t.operation);case "params":let e=storage.getVariable(`${me}${narration.openedLabels.length-1}`)||[];if(e&&e.length>t.key)return e[t.key];R.warn("getValue params not found");return}return t}function ui(t){if(!t)return false;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case "compare":let e=w(t.leftValue),i=w(t.rightValue);switch(t.operator){case "==":return e===i;case "!=":return e!==i;case "<":return e<i;case "<=":return e<=i;case ">":return e>i;case ">=":return e>=i;case "CONTAINS":return e.toString().includes(i.toString())}break;case "valueCondition":return !!w(t.value);case "union":return fi(t)}return !!t}function fi(t){if(t.unionType==="not")return !w(t.condition);let e=t.unionType==="and";for(let i=0;i<t.conditions.length;i++)if(e=w(t.conditions[i])||false,t.unionType==="and"){if(!e)return false}else if(e)return true;return e}function gi(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function di(t){if(Array.isArray(t)||!t)return t;if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "resulttocombine":return hi(t);case "ifelse":return w(t.condition)?w(t.then):w(t.else);case "stepswitch":let e=w(t.elements)||[];if(e.length===0){R.error("getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case "random":let i=gi(0,e.length-1);return w(e[i]);case "loop":let n=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return n>e.length-1&&(n=n%e.length),w(e[n]);case "sequential":let r,o=NarrationManagerStatic.getCurrentStepTimesCounter(t.nestedId)-1;return t.end=="lastItem"&&(r=w(e[e.length-1])),o>e.length-1?r:w(e[o]);case "sequentialrandom":let l=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:true});if(l==null&&t.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(t.nestedId);if(!g||!g?.usedRandomNumbers){R.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=g.usedRandomNumbers[`0-${e.length-1}`];return w(e[c[c.length-1]])}if(l==null){R.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return w(e[l])}}return t}function Te(t){if(t.conditionalStep){let e=si(w(t.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let i={...t,conditionalStep:void 0,...e};return Te(i)}else storage.getFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return t}function hi(t){let e=t.firstItem,i=[];t.secondConditionalItem?.forEach(r=>{if(Array.isArray(r))r.forEach(o=>{let l=w(o);i.push(l);});else {let o=w(r);i.push(o);}});let n=e?[e,...i]:i;if(n.length===0){R.warn("combinateResult toCheck.length === 0");return}if(typeof n[0]=="string")return J.t(n);if(typeof n[0]=="object"){let r=n,o,l=r.map((m,V)=>{m=Te(m);let u=w(m.dialogue)||"";return V===0?(o=w(m.glueEnabled)||false,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),o===false&&(u=`
2
2
 
3
3
  `+u),o=w(m.glueEnabled)||false,u)}),g=w(l[0]),c=typeof g=="object"&&"character"in g?g.character:void 0,p=l.flatMap(m=>{let V;m&&typeof m=="object"&&"text"in m?V=m.text:V=m;let u;return Array.isArray(V)?u=V.map(a=>{let b=w(a);return J.t(`${b}`)}):u=w(V)||"",J.t(u)}),s=r.find(m=>m.end),d=r.find(m=>m.choices),f=false,y=false;r.length>0&&(r[0].glueEnabled&&r[0].goNextStep&&r[0].dialogue===void 0&&storage.setFlag(SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),f=r[r.length-1].glueEnabled,y=r.reverse().find(m=>!(m.operations&&(!m.dialogue||!m.choices)))?.goNextStep);let T=r.find(m=>m.labelToOpen),x=[];return r.forEach(m=>{m.operations&&x.forEach(V=>{x.push(V);});}),{dialogue:c?{character:c,text:p}:p,end:s?.end,choices:d?.choices,glueEnabled:f,goNextStep:y,labelToOpen:T?.labelToOpen,operations:x}}}function xe(){O.init({animateOperation:ni,canvasElementOperation:ti,effectOperation:ri,imageContainerOperation:Zt,imageOperation:Xt,textOperation:ei,narrationOperation:oi,loadAssets:Qt,soundOperation:ai,tickerOperation:ii,videoOperation:Kt,setStorageValue:li,getLogichValue:w,getConditionalStep:Te});}var Ie="\xA7SPACE\xA7",$e="\xA7DOUBLE_QUOTES\xA7",Be="\xA7QUOTES\xA7",He="SPECIAL_\xA7QUOTES\xA7",ze="\xA7CURLY_BRACKETS1\xA7",Me="\xA7CURLY_BRACKETS2\xA7",yi=["add","play","pause","resume","remove","volume"],S=class S{static runCustomHashtagScript(e,i){return S._customHashtagScript(e,i,S.convertListStringToObj)}static set customHashtagScript(e){S._customHashtagScript=e;}static async generateOrRunOperationFromHashtagScript(e,i,n){try{e=e.replaceAll('\\"',$e),e=e.replaceAll("\\'",Be),e=e.replaceAll("\\`",He),e=e.replaceAll("\\{",ze),e=e.replaceAll("\\}",Me),e=e.replaceAll("{"," { "),e=e.replaceAll("}"," } "),e=e.replaceAll(ze,"{"),e=e.replaceAll(Me,"}");let r=[],o,l="";for(let s=0;s<e.length;s++){let d=e[s];d==='"'||d==="'"||d==="`"?o===void 0?(r.push(l),l="",o=d,l+=d):o===d?(o=void 0,l+=d,r.push(l),l=""):l+=d:l+=d;}l!==""&&r.push(l),r.forEach((s,d)=>{d%2===1&&(r[d]=s.replaceAll(" ",Ie));}),e=r.join(""),r=e.split(" ").filter(s=>s!==""),r=r.map(s=>s.replaceAll(Ie," ").replaceAll($e,'"').replaceAll(Be,"'").replaceAll(He,"`"));let g=S.runCustomHashtagScript(r,n);if(g===!0)return;if(typeof g=="string")return g.startsWith("#")&&(g=g.substring(1)),S.generateOrRunOperationFromHashtagScript(g,i,n);let c=r.length>1?S.removeExtraDoubleQuotes(r[1]):"",p=r.length>0?S.removeExtraDoubleQuotes(r[0]):"";switch(c){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return c==="video"&&(p==="pause"||p==="resume")?{type:"video",operationType:p,alias:S.removeExtraDoubleQuotes(r[2])}:S.getCanvasOperationFromComment(r,c);case "sound":return S.getSoundOperationFromComment(r);case "input":if(p==="request"){let s={type:"input",operationType:"request"};if(r.length>2)try{let d=r.slice(2),f=S.convertListStringToObj(d);"type"in f&&typeof f.type=="string"&&(s.valueType=f.type),"default"in f&&(s.defaultValue=f.default);}catch{}return s}break;case "assets":case "bundle":switch(p){case "load":case "lazyload":return {type:c,operationType:p,aliases:r.slice(2)}}break;default:if(c)switch(p){case "call":case "jump":i.labelToOpen={label:c,type:p},i.goNextStep=void 0;return;case "fade":case "move":case "rotate":case "zoom":case "shake":let s={};if(r.length>2)try{s=S.convertListStringToObj(r.slice(2));}catch{}if(p=="move"&&"x"in s&&"y"in s&&(s.destination={x:s.x,y:s.y,type:"pixel"},delete s.x,delete s.y),p=="move"&&"xAlign"in s&&"yAlign"in s&&(s.destination={x:s.xAlign,y:s.yAlign,type:"align"},delete s.xAlign,delete s.yAlign),p=="move"&&"xPercentage"in s&&"yPercentage"in s&&(s.destination={x:s.xPercentage,y:s.yPercentage,type:"percentage"},delete s.xPercentage,delete s.yPercentage),p=="move"&&!("destination"in s)){d.error("The move operation don't have a destination or destination is not valid",s);return}return {alias:c,type:p,props:s};case "animate":let f={},y={};if(r.length>2){let x=r.slice(2),m=[];if(x.includes("options")){let V=x.indexOf("options");m=x.slice(V+1),x=x.slice(0,V);}try{f=S.convertListStringToObj(x);}catch{}if(m.length>0)try{y=S.convertListStringToObj(m);}catch{}}return {alias:c,type:p,keyframes:f,options:y}}else switch(p){case "pause":return "dialogue"in i&&delete i.dialogue,"goNextStep"in i&&delete i.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":i.goNextStep=!0,i.glueEnabled=!1;return}}}catch(r){throw d.error("Error parsing ink hashtag-script",e),r}d.error("The operation is not valid",e);}static getCanvasOperationFromComment(e,i){let n=S.removeExtraDoubleQuotes(e[0]),r=S.removeExtraDoubleQuotes(e[2]),o=S.convertListStringToPropList(e.slice(3));switch(n){case "show":switch(i){case "image":case "video":return S.getImageOperationFromComment(i,r,o);case "imagecontainer":return S.getContainerOperationFromComment(i,r,o);case "text":return S.getTextOperationFromComment(i,r,o);case "canvaselement":default:d.error("This show operation is not valid for this type of element",i);}case "edit":return {type:i,operationType:"edit",alias:r,props:S.convertPropListStringToObj(o)};case "remove":let g={type:i,operationType:"remove",alias:r};if(o.length>1&&o[0]==="with"){let c=e[e.indexOf("with")+1],p=e.slice(e.indexOf("with")+2),s=S.getTransition(c,p);s!==void 0&&(g.transition=s);}return g;default:d.error("The operation type is not valid",n);}}static getImageOperationFromComment(e,i,n){let r,o;n.length%2===0?(r=i,o=n):(r=S.removeExtraDoubleQuotes(n[0]),o=S.convertListStringToPropList(n.slice(1)));let l={type:e,operationType:"show",alias:i,url:r};return S.setShowProps(l,o)}static getTextOperationFromComment(e,i,n){let r,o;n.length%2===0?(r=i,o=n):(r=S.removeExtraDoubleQuotes(n[0]),o=S.convertListStringToPropList(n.slice(1)));let l={type:e,operationType:"show",alias:i,text:r};return S.setShowProps(l,o)}static getContainerOperationFromComment(e,i,n){let r=[],o=n.findIndex(p=>p.startsWith("[")),l=n.findIndex(p=>p.endsWith("]"));if(o===-1||l===-1){d.error("Show imagecontainer must have a list of image ulrs",n);return}if(r=n.slice(o,l+1),r.length<2){d.error("Show imagecontainer must have a list of image ulrs",n);return}r[0]==="["?r.shift():r[0]=r[0].substring(1),r[r.length-1]==="]"?r.pop():r[r.length-1]=r[r.length-1].substring(0,r[r.length-1].length-1);let g={type:e,operationType:"show",alias:i,urls:r.map(p=>S.removeExtraDoubleQuotes(p))},c=S.convertListStringToPropList(n.slice(l+1));return S.setShowProps(g,c)}static getSoundOperationFromComment(e){let i=S.removeExtraDoubleQuotes(e[0]);if(!yi.includes(i))return;let n=S.removeExtraDoubleQuotes(e[2]);switch(i){case "play":let r={type:"sound",operationType:"play",alias:n};if(e.length>3){let p=S.getSoundPlayOptions(e.slice(3));p!==void 0&&(r.props=p);}return r;case "pause":case "resume":return {type:"sound",operationType:i,alias:n};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:n};case "volume":let g=parseFloat(e[3]);return {type:"sound",operationType:"volume",alias:n,value:g}}}static setShowProps(e,i){if(i.length>0){if(i.includes("with")&&i.length>i.indexOf("with")+1){let n=i[i.indexOf("with")+1],r=i.slice(i.indexOf("with")+2);i=i.slice(0,i.indexOf("with"));let o=S.getTransition(n,r);o!==void 0&&(e.transition=o);}if(i.length>0){let n=S.convertListStringToObj(i);e.props=n;}}return e}static getTransition(e,i){switch(e){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let n={type:e};if(i.length>0)try{let r=S.convertPropListStringToObj(i);n.props=r;}catch{}return n}static getSoundOption(e){try{return S.convertListStringToObj(e)}catch{return}}static getSoundPlayOptions(e){try{return S.convertListStringToObj(e)}catch{return}}static convertListStringToObj(e){let i=S.convertListStringToPropList(e);return S.convertPropListStringToObj(i)}static convertListStringToPropList(e){let i=[],n=0,r="";for(let o=0;o<e.length;o++){let l=e[o];l.startsWith("{")?(n++,r+=l):l.endsWith("}")&&n>0?(n--,r+=l,n===0&&(i.push(r),r="")):n>0?r+=l:i.push(l);}return i}static convertPropListStringToObj(e){if(e.length===0)return {};if(e.length%2!==0)throw d.error("The props list must have a pair number of elements",e),new Error("The props list must have a pair number of elements");let i="{";e.forEach((n,r)=>{if(r%2===0)i+=`"${n}": `;else {switch(n){case "null":case "undefined":case "true":case "false":i+=`${n}`;break;default:S.containExtraDoubleQuotes(n)?(n=S.removeExtraDoubleQuotes(n),i+=`"${n}"`):n.startsWith("{")&&n.endsWith("}")?i+=`${n}`:n.startsWith('"')&&n.endsWith('"')?i+=`${n}`:isNaN(parseFloat(n))?i+=`"${n}"`:i+=`${n}`;}r<e.length-1&&(i+=", ");}}),i+="}";try{return JSON.parse(i)}catch(n){throw d.error("Error parsing ink json",i),n}}static removeExtraDoubleQuotes(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("`")&&e.endsWith("`")?e.substring(1,e.length-1):e}static containExtraDoubleQuotes(e){return !!(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("`")&&e.endsWith("`"))}};c(S,"_customHashtagScript",e=>false);var B=S;function mi(t){B.customHashtagScript=t;}var Ee=b(e(),1);var ae="global decl",H="___external_value___";function ee(t,e){if(t.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(t)&&(t=t.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!t.startsWith(".")))return t.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(t)&&t.includes("g-")){let n=t.split("g-");return be(e)+"_|_"+"g-"+n[n.length-1]}let i=0;for(;new RegExp(/^\.\^.*$/).test(t);)i++,t=t.substring(2);if(i=i-1,new RegExp(/^\..*$/).test(t)&&e){let n=t.substring(1);return be(e,i)+"_|_"+n.replaceAll(".","_|_")}return t.replaceAll(".","_|_")||be(e,i).replaceAll(".","_|_")}function be(t,e=0){let i=t.split("_|_");for(;i.length>1&&e>0;)i.pop()?.includes("g-")&&e--,e--;return i.join("_|_")}var We="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function $(t){return t.startsWith("^")&&(t=t.substring(1)),t=t.replaceAll("\\\\",We),t=t.replaceAll("\\n",`
4
4
  `),t=t.replaceAll("\\t"," "),t=t.replaceAll(" "," "),t=t.replaceAll(We,"\\\\"),t}var Ge=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],Ue=["+","-","/","*","%","POW","RANDOM"],Ye=["INT","FLOOR","FLOAT"],qe=["==",">","<",">=","<=","!=","CONTAINS"];function Y(t,e,i){t=t.map(r=>{if(typeof r=="string"){if(r==="rnd")return "RANDOM";if(r==="?")return "CONTAINS"}return r});let n=[];return t.forEach(r=>{if(typeof r=="object"&&"CNT?"in r)if(new RegExp(/.*\.[0-9]\..*/).test(r["CNT?"])){let o=r["CNT?"].split("."),l=o.pop(),g=o.pop();if(g===void 0||l===void 0){d.error("Error parsing ink file: Conditional statement is not valid",t);return}let c=parseInt(g),p=o.join(".");if(p.includes("^.")){let d=p.split("."),f=d[d.length-1].replaceAll(".","_|_");d.pop(),p=d.join(".")+"."+f,l.includes("c-")&&(p=p+"_|_"+l);}else p=p.replaceAll(".","_|_");let s=ee(p,e);if(!s)return;n.push({type:"compare",leftValue:Qe(s),operator:">=",rightValue:{type:"value",value:c}});}else {let o=ee(r["CNT?"],e);if(!o)return;n.push(Qe(o));}else if(typeof r=="object"&&"VAR?"in r)n.push(q(r["VAR?"],i));else if(r==="&&"||r==="||"){if(n.length>=2){let o={type:"union",unionType:r==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(o);}}else if(r==="!")if(n.length===0)d.error("Error parsing ink file: Conditional statement is not valid",t);else {let o={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=o;}else if(r&&typeof r=="string"&&qe.includes(r))if(n.length<2)d.error("Error parsing ink file: Conditional statement is not valid",t);else {let o={type:"compare",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(o);}else if(r&&typeof r=="string"&&Ue.includes(r))if(n.length<2)d.error("Error parsing ink file: Conditional statement is not valid",t);else {let o={type:"arithmetic",operator:r,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(o);}else if(r&&typeof r=="string"&&Ye.includes(r)){let o={type:"arithmeticsingle",operator:r,leftValue:n[n.length-1]};n.pop(),n.push(o);}else r&&typeof r=="string"?r.startsWith("^")&&n.push($(r)):typeof r=="object"&&"^->"in r?r["^->"].includes("$r")||n.push(r["^->"]):n.push(r);}),n}function Qe(t){return {type:"value",storageType:"label",storageOperationType:"get",label:t}}function Xe(t,e,i){return Y(t,e,i)}function q(t,e,i="storage"){let n=e.indexOf(t);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:i,key:t}}function ve(t,e,i,n="storage"){let r=e.indexOf(t);return r>=0?{type:"value",storageType:"params",storageOperationType:"set",key:r,value:i}:{type:"value",storageOperationType:"set",storageType:n,key:t,value:i}}function Se(t,e){return e||t.includes("_|_")?"call":"jump"}function se(t,e){e&&(typeof e=="string"?e.startsWith("^")&&t.push($(e)):typeof e=="object"&&"type"in e&&e.type!=="value"&&t.push(e));}function Pe(t,e,i,n,r={}){let{isNewLine:o=true,isHashtagScript:l=false,isThreads:g=false}=r;return xi(t,e,i,n,{isNewLine:o,isHashtagScript:l,isThreads:g})}function xi(t,e,i,n,r){if(!e)return;let{isNewLine:o,isHashtagScript:l=false,isThreads:g}=r;if(l)Array.isArray(e)&&e.length>0&&t.push({operations:[{type:"operationtoconvert",values:e}],goNextStep:true});else if(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"){if(!o&&t.length>0){let c=t[t.length-1];!c.glueEnabled&&!c.operations&&(c.glueEnabled=true,c.labelToOpen||(c.goNextStep=true)),t[t.length-1]=c;}typeof e=="string"?t.push(bi($(e))):t.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")t.push({end:"game_end"});else if(e==="done")t.push({end:"label_end",goNextStep:true});else if(e=="<>")if(t.length>0){let c=t[t.length-1];c.glueEnabled=true,c.labelToOpen||(c.goNextStep=true),t[t.length-1]=c;}else t.push({glueEnabled:true,goNextStep:false});}else if(typeof e=="object"){if("type"in e&&e.type!=="value"){if(!o&&t.length>0){let c=t[t.length-1];!c.glueEnabled&&!c.operations&&(c.glueEnabled=true,c.labelToOpen||(c.goNextStep=true)),t[t.length-1]=c;}t.push({conditionalStep:e});}else if("->"in e){let c=o?void 0:true;if(!o&&t.length>0){let p=t[t.length-1];p.labelToOpen||(p.goNextStep=true),t[t.length-1]=p;}if(e.params&&e.params.length===0&&(e.params=void 0),e.var)t.push({labelToOpen:{label:q(e["->"],n),type:g?"call":"jump",params:e.params},glueEnabled:c});else {let p=ee(e["->"],i);if(!p)return;t.push({labelToOpen:{label:p,type:Se(p,g),params:e.params},glueEnabled:c});}}"type"in e&&e.type=="value"&&e.storageOperationType==="set"&&(typeof e.value=="string"&&e.value.startsWith("^")&&(e.value=$(e.value)),t.push({goNextStep:true,operations:[e]}));}}function bi(t){let e;if(t.includes(": ")){let i=t.split(": "),n=i[0],r=i.slice(1).join(": ");RegisteredCharacters.get(n)&&(e=n,t=r);}return e?{dialogue:{character:e,text:t}}:{dialogue:t}}function Ve(t,e,i,n=true,r=false){return vi(t,e,i,n,r)}function vi(t,e,i,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type=="value"&&e.storageOperationType==="get"?typeof e=="string"?t.push($(e)):t.push(e):typeof e=="object"&&"type"in e&&t.push(e));}function le(t,e,i){if(t.length===0){d.error("Error parsing ink file: Arithmetic statement is not valid",t);return}let n=Y(t,e,i);if(n.length===1){let r=n[0];return r&&typeof r=="object"&&"type"in r?{type:"value",storageType:"logic",storageOperationType:"get",operation:r}:r}}function Q(t,e,i,n="",r,o,l=void 0){let g=[],c="sequential",p=false,s=true;t.forEach(y=>{y==="%"&&(c="loop"),y==="seq"&&(c="random"),y==="MIN"&&(p=true);});let d=t[t.length-1];return Object.keys(d).forEach(y=>{let T=d[y];if(Array.isArray(T)&&T.length>3){T=T.slice(1,T.length-2);let x=[];z(T,n,r,x,e,e,i,X,l,true,o),x.length===1?g.push(x[0]):g.push({type:"resulttocombine",combine:"cross",secondConditionalItem:x});}else Array.isArray(T)&&T.length===3&&(s=false);}),c==="sequential"?{type:"stepswitch",elements:g,choiceType:c,end:s?"lastItem":void 0,nestedId:l}:p&&c==="random"?{type:"stepswitch",elements:g,choiceType:"sequentialrandom",end:s?"lastItem":void 0,nestedId:l}:{type:"stepswitch",elements:g,choiceType:c}}function Oe(t="",e=""){let i=Array.isArray(t)?t:[t],n=Array.isArray(e)?e:[e];return [...new Set([...i,...n])]}function X(t,e,i,n,r){if(t.length>0){let o={};Ke(t,o,r);for(let[l,g]of Object.entries(o)){let c=i+"_|_"+l,p={text:g.text.length===1?g.text[0]:g.text,label:c,props:{},type:Se(c,false),oneTime:g.onetime};g.text.length===0&&(p.onlyHaveNoChoice=true,p.autoSelect=true),p.oneTime===false&&delete p.oneTime;let s=Ae(p,g.conditions,r,i)||p,d$1=e[e.length-1];if(typeof d$1=="object"&&d$1&&"type"in d$1&&(d$1={conditionalStep:d$1}),e.length>0&&typeof d$1=="object"&&d$1&&"choices"in d$1&&d$1.choices){let f=d$1.choices;f&&Array.isArray(f)?f.push(s):d.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",g,f),d$1.choices=f.sort((y,T)=>{try{let x=y.label.split("."),m=x[x.length-1].replaceAll(".","_|_"),V=T.label.split("."),u=V[V.length-1].replaceAll(".","_|_");if(m.includes("c-")&&u.includes("c-")){let a=m.split("c-")[1],b=parseInt(a),h=u.split("c-")[1],v=parseInt(h);return b-v}}catch{}return 0});}else e.push({choices:[s]});g.preDialog&&(n.preDialog[c]={...g.preDialog});}}}function Ke(t,e,i,n){let r=[],o="",l="",g=false,c=[];for(let p=0;p<t.length;p++){let s=t[p];if(typeof s=="string")s.startsWith("^")?r.push($(s)):Ge.includes(s)&&c.push(s);else if(Array.isArray(s)&&s.includes("visit")){let d=Q(s,se,(f,y,T)=>{},n,{preDialog:{}},i);r.push(d);}else if(s&&typeof s=="object")if("*"in s&&typeof s["*"]&&typeof s["*"]=="string")s["*"].includes("c")&&(o="c"+s["*"].split("c")[1],s.flg&16&&(g=true));else if("s"in s&&s.s instanceof Array){let d=Ze(s.s),f=s.s.includes("<>");d&&(n&&e[n]?(e[n].preDialog={text:d,glue:f},e[n].text=Oe(d,e[n].text)):(r.push(d),l=d));}else "CNT?"in s&&c.push(s);else c.push(s);if(o){e[o]?e[o].text=Oe(r,e[o].text):e[o]={text:r,onetime:g,conditions:c},l&&(e[o].preDialog={text:l,glue:false});let d=t.slice(p+1);Ke(d,e,i,o);return}}}function Ze(t){for(let e of t)if(typeof e=="string"){if(e.startsWith("^"))return $(e)}else if(e instanceof Array){let i=Ze(e);if(i)return i}}function Ae(t,e,i,n,r){if(e.length===0)return;let o=Y(e,n,i);if(o.length===1){let l={type:"ifelse",condition:o[0],then:t,else:r};return l.else||delete l.else,l}else if(o.length>1){let l={type:"ifelse",condition:{type:"union",unionType:"and",conditions:o},then:t,else:r};return l.else||delete l.else,l}}function et(t,e,i,n,r,o,l=void 0){if(t.length===0){d.error("Error parsing ink file: Conditional statement is not valid",t);return}let g=[],c=[];if(t.forEach(d=>{Array.isArray(d)?c.push(d):typeof d=="string"&&d==="du"?r.du?g.push(r.du):r.du=g[g.length-1]:(typeof d!="string"||d!=="/ev")&&g.push(d);}),c.length===0){d.error("Error parsing ink file: Conditional statement is not valid",c);return}let p=we(c[0],e,i,n+"_|_"+"then",r,o,`${l||""}then`),s;return c.length===2?s=we(c[1],e,i,n+"_|_"+"else",r,o,`${l||""}else`):c.length>2&&(c.shift(),c.push("nop"),c=[{b:c}],s=we(c,e,i,n+"_|_"+"else",r,o,`${l||""}else`)),r.du=void 0,Ae(p,g,o,n,s)}function we(t,e,i,n,r,o,l=void 0){let g=[];for(let p of t)typeof p=="object"&&"b"in p&&(p.b=p.b.filter(s=>s!==null&&!(typeof s=="object"&&"->"in s&&new RegExp(/.*\.[0-9]/).test(s["->"]))),z(p.b,n,r,g,e,e,i,X,l,true,o));return g.length===1?g[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:g}}function z(t,e,i,n=[],r,o,l,g,c=void 0,p=true,s=[]){let d$1=false,f=[],y=false,T=false,x=false,m=[],V=[];if(i.preDialog[e]&&(p=false,r(n,"^"+i.preDialog[e].text,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),i.preDialog[e].glue&&r(n,"<>",e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),delete i.preDialog[e]),t.includes("visit")){let a=Q(t,o,l,e,i,s,c);a&&(!p&&n.length>0&&r(n,"<>",e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),r(n,a,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}));return}let u=t[0];if(u&&typeof u=="object"&&"temp="in u){for(;t[0]&&typeof t[0]=="object"&&"temp="in t[0];)s.push(t[0]["temp="]),t.shift();s=s.reverse();}if(t.forEach((a,b)=>{if(T){if(typeof a=="string"&&a=="/#"){let h=[];z(V,e,i,h,Ve,Ve,l,g,c,p),r(n,h,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),T=false,V=[];}else V.push(a);return}else if(d$1)if(Array.isArray(a))f.push(a);else if(a&&typeof a=="object")if("CNT?"in a)b>0&&t[b-1]=="ev"?(y=true,m.push(a)):y?m.push(a):(f.push(a),p=false);else if("VAR="in a||"temp="in a){let h=ve("VAR="in a?a["VAR="]:a["temp="],s,t[b-1],"VAR="in a?"storage":"tempstorage");if(h.value&&typeof h.value=="string"&&h.value=="/str"&&(h.value=t[b-2]),h.value&&typeof h.value=="object"&&"^->"in h.value&&(h.value=h.value["^->"]),f.length>1){let v=le(f,e,s);f=[],v&&typeof v=="object"&&"type"in v&&v.type=="value"&&"storageType"in v&&v.storageType=="logic"&&(h.value=v.operation);}(typeof h.key!="string"||!h.key.includes("$r"))&&(r(n,h,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),p=true);}else "VAR?"in a?f.push(a):"^->"in a&&(a["^->"].includes("$r")||f.push(a));else if(typeof a=="string"&&a=="/ev")y&&m.push(a),d$1=false,f.push(a);else if(typeof a=="string"&&a=="out"){if(f.length>0){let h=f[f.length-1];if(h&&typeof h=="object"&&"VAR?"in h){f.pop();let v=q(h["VAR?"],s,"storage");r(n,v,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x});}else {let v=[];for(;f.length>0&&f[f.length-1]!="/ev";)v.push(f.pop());v=v.reverse();let N=le(v,e,s);f=[],N&&typeof N=="object"&&"type"in N&&N.type=="value"&&"storageType"in N&&N.storageType=="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:N.operation,type:"value"},e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}):(r(n,"<>",e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),N=`^${N}`,r(n,N,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}));}p=false;}}else f.push(a);else if(typeof a=="string")if(a.startsWith("^"))r(n,a,e,s,{isNewLine:p,isHashtagScript:T,isThreads:x}),p=false;else if(a=="ev")d$1=true;else if(a==`
@@ -41,7 +41,7 @@ Error:${h}`);}return u!=null&&(l=new o(u,r,this._externalErrorHandler,this._root
41
41
  `))),this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),s},this.VariableDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="VAR")return null;this.Whitespace();let s=this.Expect(this.IdentifierWithMetadata,"variable name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)"),this.Whitespace();let u=this.Expect(this.Expression,"initial value for ");return u?(u instanceof Ee.NumberExpression||u instanceof ln.StringExpression||u instanceof za.DivertTarget||u instanceof Ya.VariableReference||u instanceof $l.List||this.Error("initial value for a variable must be a number, constant, list or divert target"),this.Parse(this.ListElementDefinitionSeparator)!==null?this.Error("Unexpected ','. If you're trying to declare a new list, use the LIST keyword, not VAR"):u instanceof ln.StringExpression&&(u.isSingleString||this.Error("Constant strings cannot contain any logic.")),new Xa.VariableAssignment({assignedExpression:u,isGlobalDeclaration:true,variableIdentifier:s})):null},this.ListDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!="LIST")return null;this.Whitespace();let s=this.Expect(this.IdentifierWithMetadata,"list name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of the list definition"),this.Whitespace();let l=this.Expect(this.ListDefinition,"list item names");return l?(l.identifier=new un.Identifier(s.name),new Xa.VariableAssignment({variableIdentifier:s,listDef:l})):null},this.ListDefinition=()=>{this.AnyWhitespace();let r=this.SeparatedList(this.ListElementDefinition,this.ListElementDefinitionSeparator);return r===null?null:new If.ListDefinition(r)},this.ListElementDefinitionSeparator=()=>(this.AnyWhitespace(),this.ParseString(",")===null?null:(this.AnyWhitespace(),",")),this.ListElementDefinition=()=>{let r=this.ParseString("(")!==null,s=r;this.Whitespace();let l=this.Parse(this.IdentifierWithMetadata);if(l===null)return null;this.Whitespace(),r&&this.ParseString(")")!=null&&(s=false,this.Whitespace());let u=null;if(this.ParseString("=")!==null){this.Whitespace();let h=this.Expect(this.ExpressionInt,"value to be assigned to list item");h!==null&&(u=h.value),s&&(this.Whitespace(),this.ParseString(")")!==null&&(s=false));}return s&&this.Error("Expected closing ')'"),new Af.ListElementDefinition(l,r,u)},this.ConstDeclaration=()=>{if(this.Whitespace(),this.Parse(this.Identifier)!=="CONST")return null;this.Whitespace();let s=this.Expect(this.IdentifierWithMetadata,"constant name");this.Whitespace(),this.Expect(this.String("="),"the '=' for an assignment of a value, e.g. '= 5' (initial values are mandatory)"),this.Whitespace();let l=this.Expect(this.Expression,"initial value for ");return l instanceof Ee.NumberExpression||l instanceof za.DivertTarget||l instanceof ln.StringExpression?l instanceof ln.StringExpression&&(l.isSingleString||this.Error("Constant strings cannot contain any logic.")):this.Error("initial value for a constant must be a number or divert target"),new _f.ConstantDeclaration(s,l)},this.InlineLogicOrGlueOrStartTag=()=>this.OneOf([this.InlineLogic,this.Glue,this.StartTag]),this.Glue=()=>this.ParseString("<>")!==null?new Of.Glue(new xf.Glue):null,this.InlineLogic=()=>{if(this.ParseString("{")===null)return null;let r=this.parsingStringExpression,s=this.tagActive;this.Whitespace();let l=this.Expect(this.InnerLogic,"some kind of logic, conditional or sequence within braces: { ... }");if(l===null)return this.parsingStringExpression=r,null;this.DisallowIncrement(l);let u=(0, Mt.asOrNull)(l,rt.ContentList);return u||(u=new rt.ContentList(l)),this.Whitespace(),this.Expect(this.String("}"),"closing brace '}' for inline logic"),this.parsingStringExpression=r,s||this.EndTagIfNecessary(u),u},this.InnerLogic=()=>{this.Whitespace();let r=this.ParseObject(this.SequenceTypeAnnotation);if(r!==null){let u=this.Expect(this.InnerSequenceObjects,"sequence elements (for cycle/stoping etc)");return u===null?null:new Hl.Sequence(u,r)}let s=this.Parse(this.ConditionExpression);if(s)return this.Expect(()=>this.InnerConditionalContent(s),"conditional content following query");let l=[this.InnerConditionalContent,this.InnerSequence,this.InnerExpression];for(let u of l){let h=this.BeginRule(),c=this.ParseObject(u);if(c)if(this.Peek(this.Spaced(this.String("}")))===null)this.FailRule(h);else return this.SucceedRule(h,c);else this.FailRule(h);}return null},this.InnerExpression=()=>{let r=this.Parse(this.Expression);return r&&(r.outputWhenComplete=true),r},this.IdentifierWithMetadata=()=>{let r=this.Identifier();return r===null?null:new un.Identifier(r)},this.Identifier=()=>{let r=this.ParseCharactersFromCharSet(this.identifierCharSet);if(r===null)return null;let s=true;for(let l of r)if(!(l>="0"&&l<="9")){s=false;break}return s?null:r},this._sequenceTypeSymbols=new j.CharacterSet("!&~$"),this.InnerSequence=()=>{this.Whitespace();let r=q.SequenceType.Stopping,s=this.Parse(this.SequenceTypeAnnotation);s!==null&&(r=s);let l=this.Parse(this.InnerSequenceObjects);return l===null||l.length<=1?null:new Hl.Sequence(l,r)},this.SequenceTypeAnnotation=()=>{let r=this.Parse(this.SequenceTypeSymbolAnnotation);if(r===null&&(r=this.Parse(this.SequenceTypeWordAnnotation)),r===null)return null;switch(r){case q.SequenceType.Once:case q.SequenceType.Cycle:case q.SequenceType.Stopping:case q.SequenceType.Shuffle:case q.SequenceType.Shuffle|q.SequenceType.Stopping:case q.SequenceType.Shuffle|q.SequenceType.Once:break;default:return this.Error(`Sequence type combination not supported: ${r}`),q.SequenceType.Stopping}return r},this.SequenceTypeSymbolAnnotation=()=>{this._sequenceTypeSymbols===null&&(this._sequenceTypeSymbols=new j.CharacterSet("!&~$ "));let r=0,s=this.ParseCharactersFromCharSet(this._sequenceTypeSymbols);if(s===null)return null;for(let l of s)switch(l){case "!":r|=q.SequenceType.Once;break;case "&":r|=q.SequenceType.Cycle;break;case "~":r|=q.SequenceType.Shuffle;break;case "$":r|=q.SequenceType.Stopping;break}return r===0?null:r},this.SequenceTypeWordAnnotation=()=>{let r=this.Interleave(this.SequenceTypeSingleWord,this.Exclude(this.Whitespace));if(r===null||r.length===0||this.ParseString(":")===null)return null;let s=0;for(let l of r)s|=l;return s},this.SequenceTypeSingleWord=()=>{let r=null,s=this.Parse(this.IdentifierWithMetadata);if(s!==null)switch(s.name){case "once":r=q.SequenceType.Once;break;case "cycle":r=q.SequenceType.Cycle;break;case "shuffle":r=q.SequenceType.Shuffle;break;case "stopping":r=q.SequenceType.Stopping;break}return r===null?null:r},this.InnerSequenceObjects=()=>{let r=this.Parse(this.Newline)!==null,s=null;return r?s=this.Parse(this.InnerMultilineSequenceObjects):s=this.Parse(this.InnerInlineSequenceObjects),s},this.InnerInlineSequenceObjects=()=>{let r=this.Interleave(this.Optional(this.MixedTextAndLogic),this.String("|"),null,false);if(r===null)return null;let s=[],l=false;for(let u of r)if(u==="|")l||s.push(new rt.ContentList),l=false;else {let h=u;h===null?this.Error(`Expected content, but got ${u} (this is an ink compiler bug!)`):s.push(new rt.ContentList(h)),l=true;}return l||s.push(new rt.ContentList),s},this.InnerMultilineSequenceObjects=()=>{this.MultilineWhitespace();let r=this.OneOrMore(this.SingleMultilineSequenceElement);return r===null?null:r},this.SingleMultilineSequenceElement=()=>{if(this.Whitespace(),this.ParseString("->")!==null||this.ParseString("-")===null)return null;this.Whitespace();let r=this.StatementsAtLevel(Y.StatementLevel.InnerBlock);return r===null?this.MultilineWhitespace():r.unshift(new It.Text(`
42
42
  `)),new rt.ContentList(r)},this._statementRulesAtLevel=[],this._statementBreakRulesAtLevel=[],this.StatementsAtLevel=r=>(r===Y.StatementLevel.InnerBlock&&this.Parse(this.GatherDashes)!==null&&this.Error("You can't use a gather (the dashes) within the { curly braces } context. For multi-line sequences and conditions, you should only use one dash."),this.Interleave(this.Optional(this.MultilineWhitespace),()=>this.StatementAtLevel(r),()=>this.StatementsBreakForLevel(r))),this.StatementAtLevel=r=>{let s=this._statementRulesAtLevel[r],l=this.OneOf(s);return r===Y.StatementLevel.Top&&l instanceof Kl.ReturnType&&this.Error("should not have return statement outside of a knot"),l},this.StatementsBreakForLevel=r=>{this.Whitespace();let s=this._statementBreakRulesAtLevel[r],l=this.OneOf(s);return l===null?null:l},this.GenerateStatementLevelRules=()=>{let r=Object.values(Y.StatementLevel);this._statementRulesAtLevel="f".repeat(r.length).split("f").map(()=>[]),this._statementBreakRulesAtLevel="f".repeat(r.length).split("f").map(()=>[]);for(let s of r){let l=[],u=[];l.push(this.Line(this.MultiDivert)),s>=Y.StatementLevel.Top&&l.push(this.KnotDefinition),l.push(this.Line(this.Choice)),l.push(this.Line(this.AuthorWarning)),s>Y.StatementLevel.InnerBlock&&l.push(this.Gather),s>=Y.StatementLevel.Knot&&l.push(this.StitchDefinition),l.push(this.Line(this.ListDeclaration)),l.push(this.Line(this.VariableDeclaration)),l.push(this.Line(this.ConstDeclaration)),l.push(this.Line(this.ExternalDeclaration)),l.push(this.Line(this.IncludeStatement)),l.push(this.LogicLine),l.push(this.LineOfMixedTextAndLogic),s<=Y.StatementLevel.Knot&&u.push(this.KnotDeclaration),s<=Y.StatementLevel.Stitch&&u.push(this.StitchDeclaration),s<=Y.StatementLevel.InnerBlock&&(u.push(this.ParseDashNotArrow),u.push(this.String("}"))),this._statementRulesAtLevel[s]=l,this._statementBreakRulesAtLevel[s]=u;}},this.SkipToNextLine=()=>(this.ParseUntilCharactersFromString(`
43
43
  \r`),this.ParseNewline(),Nt.ParseSuccess),this.Line=r=>()=>{let s=this.ParseObject(r);return s===null?null:(this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),s)},this.StartTag=()=>{if(this.Whitespace(),this.ParseString("#")===null)return null;this.parsingStringExpression&&this.Error("Tags aren't allowed inside of strings. Please use \\# if you want a hash symbol.");let r=null;if(this.tagActive){let s=new rt.ContentList;s.AddContent(new be.Tag(false)),s.AddContent(new be.Tag(true)),r=s;}else r=new be.Tag(true);return this.tagActive=true,this.Whitespace(),r},this._inlineWhitespaceChars=new j.CharacterSet(" "),this.EndOfLine=()=>this.OneOf([this.Newline,this.EndOfFile]),this.Newline=()=>(this.Whitespace(),this.ParseNewline()!==null?Nt.ParseSuccess:null),this.EndOfFile=()=>(this.Whitespace(),this.endOfInput?Nt.ParseSuccess:null),this.MultilineWhitespace=()=>{let r=this.OneOrMore(this.Newline);return r===null?null:r.length>=1?Nt.ParseSuccess:null},this.Whitespace=()=>this.ParseCharactersFromCharSet(this._inlineWhitespaceChars)!==null?Nt.ParseSuccess:null,this.Spaced=r=>()=>{this.Whitespace();let s=this.ParseObject(r);return s===null?null:(this.Whitespace(),s)},this.AnyWhitespace=()=>{let r=false;for(;this.OneOf([this.Whitespace,this.MultilineWhitespace])!==null;)r=true;return r?Nt.ParseSuccess:null},this.MultiSpaced=r=>()=>{this.AnyWhitespace();let s=this.ParseObject(r);return s===null?null:(this.AnyWhitespace(),s)},this._filename=null,this._externalErrorHandler=null,this._fileHandler=null,this._filename=e,this.RegisterExpressionOperators(),this.GenerateStatementLevelRules(),this.errorHandler=this.OnStringParserError,this._externalErrorHandler=n,a===null?this._fileHandler=new Wf.DefaultFileHandler:this._fileHandler=a,i===null){if(this._rootParser=this,this._openFilenames=[],this._filename!==null){let r=this.fileHandler.ResolveInkFilename(this._filename);this._openFilenames.push(r);}}else this._rootParser=i;}PreProcessInputString(t){return new Sf.CommentEliminator(t).Process()}get parsingStringExpression(){return this.GetFlag(Number(Nr.CustomFlags.ParsingString))}set parsingStringExpression(t){this.SetFlag(Number(Nr.CustomFlags.ParsingString),t);}get tagActive(){return this.GetFlag(Number(Nr.CustomFlags.TagActive))}set tagActive(t){this.SetFlag(Number(Nr.CustomFlags.TagActive),t);}get identifierCharSet(){return this._identifierCharSet===null&&((this._identifierCharSet=new j.CharacterSet).AddRange("A","Z").AddRange("a","z").AddRange("0","9").Add("_"),this.ExtendIdentifierCharacterRanges(this._identifierCharSet)),this._identifierCharSet}EndTagIfNecessary(t){this.tagActive&&(t!=null&&(t instanceof rt.ContentList?t.AddContent(new be.Tag(false)):t.push(new be.Tag(false))),this.tagActive=false);}};Fr.InkParser=x;x.LatinBasic=pt.CharacterRange.Define("A","z",new j.CharacterSet().AddRange("[","`"));x.LatinExtendedA=pt.CharacterRange.Define("\u0100","\u017F");x.LatinExtendedB=pt.CharacterRange.Define("\u0180","\u024F");x.Greek=pt.CharacterRange.Define("\u0370","\u03FF",new j.CharacterSet().AddRange("\u0378","\u0385").AddCharacters("\u0374\u0375\u0378\u0387\u038B\u038D\u03A2"));x.Cyrillic=pt.CharacterRange.Define("\u0400","\u04FF",new j.CharacterSet().AddRange("\u0482","\u0489"));x.Armenian=pt.CharacterRange.Define("\u0530","\u058F",new j.CharacterSet().AddCharacters("\u0530").AddRange("\u0557","\u0560").AddRange("\u0588","\u058E"));x.Hebrew=pt.CharacterRange.Define("\u0590","\u05FF",new j.CharacterSet);x.Arabic=pt.CharacterRange.Define("\u0600","\u06FF",new j.CharacterSet);x.Korean=pt.CharacterRange.Define("\uAC00","\uD7AF",new j.CharacterSet);x.Latin1Supplement=pt.CharacterRange.Define("\x80","\xFF",new j.CharacterSet);x.Chinese=pt.CharacterRange.Define("\u4E00","\u9FFF",new j.CharacterSet);x.ListAllCharacterRanges=()=>[x.LatinBasic,x.LatinExtendedA,x.LatinExtendedB,x.Arabic,x.Armenian,x.Cyrillic,x.Greek,x.Hebrew,x.Korean,x.Latin1Supplement,x.Chinese];});var Yl=d(kr=>{Object.defineProperty(kr,"__esModule",{value:true});kr.GenerateStoryStats=void 0;var Df=ue(),Lf=fe(),qf=Me(),jf=ma(),Mf=_a(),Bf=Wt();function Gf(o){let t=o.FindAll(Bf.Text)(),e=0;for(let l of t){let u=0,h=true;for(let c of l.text)c==" "||c==" "||c==`
44
- `||c=="\r"?h=true:h&&(u++,h=false);e+=u;}let n=o.FindAll(jf.Knot)(),i=o.FindAll(Mf.Stitch)(),a=o.FindAll(Df.Choice)(),r=o.FindAll(qf.Gather)(l=>l.debugMetadata!=null),s=o.FindAll(Lf.Divert)();return {words:e,knots:n.length,functions:n.filter(l=>l.isFunction).length,stitches:i.length,gathers:r.length,diverts:s.length-1,choices:a.length}}kr.GenerateStoryStats=Gf;});var Zl=d(Rr=>{Object.defineProperty(Rr,"__esModule",{value:true});Rr.JsonFileHandler=void 0;var Qa=class{constructor(t){this.fileHierarchy=t,this.ResolveInkFilename=e=>{if(Object.keys(this.fileHierarchy).includes(e))return e;throw new Error(`Cannot locate ${e}. Are you trying a relative import ? This is not yet implemented.`)},this.LoadInkFileContents=e=>{if(Object.keys(this.fileHierarchy).includes(e))return this.fileHierarchy[e];throw new Error(`Cannot open ${e}.`)};}};Rr.JsonFileHandler=Qa;});var tu=d(K=>{Object.defineProperty(K,"__esModule",{value:true});K.Compiler=K.Story=K.InkList=K.JsonFileHandler=K.StatementLevel=K.InkParser=K.CompilerOptions=void 0;var $f=Dr(),Uf=lo(),to=we(),Kf=Za(),Hf=I(),Jf=P(),zf=Yl(),Xf=Dr();Object.defineProperty(K,"CompilerOptions",{enumerable:true,get:function(){return Xf.CompilerOptions}});var Yf=Za();Object.defineProperty(K,"InkParser",{enumerable:true,get:function(){return Yf.InkParser}});var Zf=Sa();Object.defineProperty(K,"StatementLevel",{enumerable:true,get:function(){return Zf.StatementLevel}});var Qf=Zl();Object.defineProperty(K,"JsonFileHandler",{enumerable:true,get:function(){return Qf.JsonFileHandler}});var Ql=Ye();Object.defineProperty(K,"InkList",{enumerable:true,get:function(){return Ql.InkList}});Object.defineProperty(K,"Story",{enumerable:true,get:function(){return Ql.Story}});var eo=class{get errors(){return this._errors}get warnings(){return this._warnings}get authorMessages(){return this._authorMessages}get inputString(){return this._inputString}get options(){return this._options}get parsedStory(){if(!this._parsedStory)throw new Error;return this._parsedStory}get runtimeStory(){if(!this._runtimeStory)throw new Error("Compilation failed.");return this._runtimeStory}get parser(){if(!this._parser)throw new Error;return this._parser}get debugSourceRanges(){return this._debugSourceRanges}constructor(t,e=null){this._errors=[],this._warnings=[],this._authorMessages=[],this._parsedStory=null,this._runtimeStory=null,this._parser=null,this._debugSourceRanges=[],this.Compile=()=>(this._parser=new Kf.InkParser(this.inputString,this.options.sourceFilename||null,this.OnError,null,this.options.fileHandler),this._parsedStory=this.parser.ParseStory(),this.errors.length===0?(this.parsedStory.countAllVisits=this.options.countAllVisits,this._runtimeStory=this.parsedStory.ExportRuntime(this.OnError)):this._runtimeStory=null,this.runtimeStory),this.RetrieveDebugSourceForLatestContent=()=>{var n;for(let i of this.runtimeStory.state.outputStream){let a=(0, Jf.asOrNull)(i,Hf.StringValue);if(a!==null){let r=new Uf.DebugSourceRange(((n=a.value)===null||n===void 0?void 0:n.length)||0,a.debugMetadata,a.value||"unknown");this.debugSourceRanges.push(r);}}},this.GenerateStats=()=>this._parsedStory===null?null:(0, zf.GenerateStoryStats)(this._parsedStory),this.DebugMetadataForContentAtOffset=n=>{let i=0,a=null;for(let r of this.debugSourceRanges){if(r.debugMetadata!==null&&(a=r.debugMetadata),n>=i&&n<i+r.length)return a;i+=r.length;}return null},this.OnError=(n,i)=>{switch(i){case to.ErrorType.Author:this._authorMessages.push(n);break;case to.ErrorType.Warning:this._warnings.push(n);break;case to.ErrorType.Error:this._errors.push(n);break}this.options.errorHandler!==null&&this.options.errorHandler(n,i);},this._inputString=t,this._options=e||new $f.CompilerOptions;}};K.Compiler=eo;});var dn;(i=>(i.log=(a,...r)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...r),i.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...r),i.error=(a,...r)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...r),i.info=(a,...r)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...r)))(dn||(dn={}));var eu=ao(tu(),1),nu=ao(we(),1);function no(o,t=[],e=[]){let n=[];try{return {json:new eu.Compiler(o,{errorHandler:(s,l)=>{n.push({message:s,type:l});},countAllVisits:!0,fileHandler:null,pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:t,initialVarsToRemove:e}}catch(i){let a=n.find(r=>r.type===nu.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let r=a.message.match(/Divert target not found: '-> (\w+)'/);if(r&&r[1]){let s=r[1],l=`
44
+ `||c=="\r"?h=true:h&&(u++,h=false);e+=u;}let n=o.FindAll(jf.Knot)(),i=o.FindAll(Mf.Stitch)(),a=o.FindAll(Df.Choice)(),r=o.FindAll(qf.Gather)(l=>l.debugMetadata!=null),s=o.FindAll(Lf.Divert)();return {words:e,knots:n.length,functions:n.filter(l=>l.isFunction).length,stitches:i.length,gathers:r.length,diverts:s.length-1,choices:a.length}}kr.GenerateStoryStats=Gf;});var Zl=d(Rr=>{Object.defineProperty(Rr,"__esModule",{value:true});Rr.JsonFileHandler=void 0;var Qa=class{constructor(t){this.fileHierarchy=t,this.ResolveInkFilename=e=>{if(Object.keys(this.fileHierarchy).includes(e))return e;throw new Error(`Cannot locate ${e}. Are you trying a relative import ? This is not yet implemented.`)},this.LoadInkFileContents=e=>{if(Object.keys(this.fileHierarchy).includes(e))return this.fileHierarchy[e];throw new Error(`Cannot open ${e}.`)};}};Rr.JsonFileHandler=Qa;});var tu=d(K=>{Object.defineProperty(K,"__esModule",{value:true});K.Compiler=K.Story=K.InkList=K.JsonFileHandler=K.StatementLevel=K.InkParser=K.CompilerOptions=void 0;var $f=Dr(),Uf=lo(),to=we(),Kf=Za(),Hf=I(),Jf=P(),zf=Yl(),Xf=Dr();Object.defineProperty(K,"CompilerOptions",{enumerable:true,get:function(){return Xf.CompilerOptions}});var Yf=Za();Object.defineProperty(K,"InkParser",{enumerable:true,get:function(){return Yf.InkParser}});var Zf=Sa();Object.defineProperty(K,"StatementLevel",{enumerable:true,get:function(){return Zf.StatementLevel}});var Qf=Zl();Object.defineProperty(K,"JsonFileHandler",{enumerable:true,get:function(){return Qf.JsonFileHandler}});var Ql=Ye();Object.defineProperty(K,"InkList",{enumerable:true,get:function(){return Ql.InkList}});Object.defineProperty(K,"Story",{enumerable:true,get:function(){return Ql.Story}});var eo=class{get errors(){return this._errors}get warnings(){return this._warnings}get authorMessages(){return this._authorMessages}get inputString(){return this._inputString}get options(){return this._options}get parsedStory(){if(!this._parsedStory)throw new Error;return this._parsedStory}get runtimeStory(){if(!this._runtimeStory)throw new Error("Compilation failed.");return this._runtimeStory}get parser(){if(!this._parser)throw new Error;return this._parser}get debugSourceRanges(){return this._debugSourceRanges}constructor(t,e=null){this._errors=[],this._warnings=[],this._authorMessages=[],this._parsedStory=null,this._runtimeStory=null,this._parser=null,this._debugSourceRanges=[],this.Compile=()=>(this._parser=new Kf.InkParser(this.inputString,this.options.sourceFilename||null,this.OnError,null,this.options.fileHandler),this._parsedStory=this.parser.ParseStory(),this.errors.length===0?(this.parsedStory.countAllVisits=this.options.countAllVisits,this._runtimeStory=this.parsedStory.ExportRuntime(this.OnError)):this._runtimeStory=null,this.runtimeStory),this.RetrieveDebugSourceForLatestContent=()=>{var n;for(let i of this.runtimeStory.state.outputStream){let a=(0, Jf.asOrNull)(i,Hf.StringValue);if(a!==null){let r=new Uf.DebugSourceRange(((n=a.value)===null||n===void 0?void 0:n.length)||0,a.debugMetadata,a.value||"unknown");this.debugSourceRanges.push(r);}}},this.GenerateStats=()=>this._parsedStory===null?null:(0, zf.GenerateStoryStats)(this._parsedStory),this.DebugMetadataForContentAtOffset=n=>{let i=0,a=null;for(let r of this.debugSourceRanges){if(r.debugMetadata!==null&&(a=r.debugMetadata),n>=i&&n<i+r.length)return a;i+=r.length;}return null},this.OnError=(n,i)=>{switch(i){case to.ErrorType.Author:this._authorMessages.push(n);break;case to.ErrorType.Warning:this._warnings.push(n);break;case to.ErrorType.Error:this._errors.push(n);break}this.options.errorHandler!==null&&this.options.errorHandler(n,i);},this._inputString=t,this._options=e||new $f.CompilerOptions;}};K.Compiler=eo;});var dn;(i=>(i.log=(a,...r)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...r),i.warn=(a,...r)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...r),i.error=(a,...r)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...r),i.info=(a,...r)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...r)))(dn||(dn={}));var eu=ao(tu(),1),nu=ao(we(),1);function no(o,t=[],e=[]){let n=[];try{return {json:new eu.Compiler(o,{errorHandler:(s,l)=>{n.push({message:s,type:l});},countAllVisits:!0,fileHandler:{ResolveInkFilename:s=>s,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:t,initialVarsToRemove:e}}catch(i){let a=n.find(r=>r.type===nu.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let r=a.message.match(/Divert target not found: '-> (\w+)'/);if(r&&r[1]){let s=r[1],l=`
45
45
 
46
46
  === ${s} ===
47
47
 
package/dist/index.cjs CHANGED
@@ -43,7 +43,7 @@ Error:${h}`);}return u!=null&&(l=new r(u,s,this._externalErrorHandler,this._root
43
43
  \r`),this.ParseNewline(),Ue.ParseSuccess),this.Line=s=>()=>{let o=this.ParseObject(s);return o===null?null:(this.Expect(this.EndOfLine,"end of line",this.SkipToNextLine),o)},this.StartTag=()=>{if(this.Whitespace(),this.ParseString("#")===null)return null;this.parsingStringExpression&&this.Error("Tags aren't allowed inside of strings. Please use \\# if you want a hash symbol.");let s=null;if(this.tagActive){let o=new Se.ContentList;o.AddContent(new Kt.Tag(false)),o.AddContent(new Kt.Tag(true)),s=o;}else s=new Kt.Tag(true);return this.tagActive=true,this.Whitespace(),s},this._inlineWhitespaceChars=new ee.CharacterSet(" "),this.EndOfLine=()=>this.OneOf([this.Newline,this.EndOfFile]),this.Newline=()=>(this.Whitespace(),this.ParseNewline()!==null?Ue.ParseSuccess:null),this.EndOfFile=()=>(this.Whitespace(),this.endOfInput?Ue.ParseSuccess:null),this.MultilineWhitespace=()=>{let s=this.OneOrMore(this.Newline);return s===null?null:s.length>=1?Ue.ParseSuccess:null},this.Whitespace=()=>this.ParseCharactersFromCharSet(this._inlineWhitespaceChars)!==null?Ue.ParseSuccess:null,this.Spaced=s=>()=>{this.Whitespace();let o=this.ParseObject(s);return o===null?null:(this.Whitespace(),o)},this.AnyWhitespace=()=>{let s=false;for(;this.OneOf([this.Whitespace,this.MultilineWhitespace])!==null;)s=true;return s?Ue.ParseSuccess:null},this.MultiSpaced=s=>()=>{this.AnyWhitespace();let o=this.ParseObject(s);return o===null?null:(this.AnyWhitespace(),o)},this._filename=null,this._externalErrorHandler=null,this._fileHandler=null,this._filename=t,this.RegisterExpressionOperators(),this.GenerateStatementLevelRules(),this.errorHandler=this.OnStringParserError,this._externalErrorHandler=n,a===null?this._fileHandler=new bm.DefaultFileHandler:this._fileHandler=a,i===null){if(this._rootParser=this,this._openFilenames=[],this._filename!==null){let s=this.fileHandler.ResolveInkFilename(this._filename);this._openFilenames.push(s);}}else this._rootParser=i;}PreProcessInputString(e){return new rm.CommentEliminator(e).Process()}get parsingStringExpression(){return this.GetFlag(Number(cs.CustomFlags.ParsingString))}set parsingStringExpression(e){this.SetFlag(Number(cs.CustomFlags.ParsingString),e);}get tagActive(){return this.GetFlag(Number(cs.CustomFlags.TagActive))}set tagActive(e){this.SetFlag(Number(cs.CustomFlags.TagActive),e);}get identifierCharSet(){return this._identifierCharSet===null&&((this._identifierCharSet=new ee.CharacterSet).AddRange("A","Z").AddRange("a","z").AddRange("0","9").Add("_"),this.ExtendIdentifierCharacterRanges(this._identifierCharSet)),this._identifierCharSet}EndTagIfNecessary(e){this.tagActive&&(e!=null&&(e instanceof Se.ContentList?e.AddContent(new Kt.Tag(false)):e.push(new Kt.Tag(false))),this.tagActive=false);}};ps.InkParser=M;M.LatinBasic=Fe.CharacterRange.Define("A","z",new ee.CharacterSet().AddRange("[","`"));M.LatinExtendedA=Fe.CharacterRange.Define("\u0100","\u017F");M.LatinExtendedB=Fe.CharacterRange.Define("\u0180","\u024F");M.Greek=Fe.CharacterRange.Define("\u0370","\u03FF",new ee.CharacterSet().AddRange("\u0378","\u0385").AddCharacters("\u0374\u0375\u0378\u0387\u038B\u038D\u03A2"));M.Cyrillic=Fe.CharacterRange.Define("\u0400","\u04FF",new ee.CharacterSet().AddRange("\u0482","\u0489"));M.Armenian=Fe.CharacterRange.Define("\u0530","\u058F",new ee.CharacterSet().AddCharacters("\u0530").AddRange("\u0557","\u0560").AddRange("\u0588","\u058E"));M.Hebrew=Fe.CharacterRange.Define("\u0590","\u05FF",new ee.CharacterSet);M.Arabic=Fe.CharacterRange.Define("\u0600","\u06FF",new ee.CharacterSet);M.Korean=Fe.CharacterRange.Define("\uAC00","\uD7AF",new ee.CharacterSet);M.Latin1Supplement=Fe.CharacterRange.Define("\x80","\xFF",new ee.CharacterSet);M.Chinese=Fe.CharacterRange.Define("\u4E00","\u9FFF",new ee.CharacterSet);M.ListAllCharacterRanges=()=>[M.LatinBasic,M.LatinExtendedA,M.LatinExtendedB,M.Arabic,M.Armenian,M.Cyrillic,M.Greek,M.Hebrew,M.Korean,M.Latin1Supplement,M.Chinese];});var ch=v(gs=>{Object.defineProperty(gs,"__esModule",{value:true});gs.GenerateStoryStats=void 0;var _m=Rt(),Em=jt(),wm=yn(),xm=uo(),Tm=mo(),Pm=tt();function Om(r){let e=r.FindAll(Pm.Text)(),t=0;for(let l of e){let u=0,h=true;for(let c of l.text)c==" "||c==" "||c==`
44
44
  `||c=="\r"?h=true:h&&(u++,h=false);t+=u;}let n=r.FindAll(xm.Knot)(),i=r.FindAll(Tm.Stitch)(),a=r.FindAll(_m.Choice)(),s=r.FindAll(wm.Gather)(l=>l.debugMetadata!=null),o=r.FindAll(Em.Divert)();return {words:t,knots:n.length,functions:n.filter(l=>l.isFunction).length,stitches:i.length,gathers:s.length,diverts:o.length-1,choices:a.length}}gs.GenerateStoryStats=Om;});var dh=v(ms=>{Object.defineProperty(ms,"__esModule",{value:true});ms.JsonFileHandler=void 0;var Ko=class{constructor(e){this.fileHierarchy=e,this.ResolveInkFilename=t=>{if(Object.keys(this.fileHierarchy).includes(t))return t;throw new Error(`Cannot locate ${t}. Are you trying a relative import ? This is not yet implemented.`)},this.LoadInkFileContents=t=>{if(Object.keys(this.fileHierarchy).includes(t))return this.fileHierarchy[t];throw new Error(`Cannot open ${t}.`)};}};ms.JsonFileHandler=Ko;});var ph=v(le=>{Object.defineProperty(le,"__esModule",{value:true});le.Compiler=le.Story=le.InkList=le.JsonFileHandler=le.StatementLevel=le.InkParser=le.CompilerOptions=void 0;var Nm=Is(),Am=El(),zo=xt(),Im=Uo(),Vm=J(),Fm=W(),km=ch(),Rm=Is();Object.defineProperty(le,"CompilerOptions",{enumerable:true,get:function(){return Rm.CompilerOptions}});var Lm=Uo();Object.defineProperty(le,"InkParser",{enumerable:true,get:function(){return Lm.InkParser}});var Dm=po();Object.defineProperty(le,"StatementLevel",{enumerable:true,get:function(){return Dm.StatementLevel}});var Wm=dh();Object.defineProperty(le,"JsonFileHandler",{enumerable:true,get:function(){return Wm.JsonFileHandler}});var fh=Nn();Object.defineProperty(le,"InkList",{enumerable:true,get:function(){return fh.InkList}});Object.defineProperty(le,"Story",{enumerable:true,get:function(){return fh.Story}});var Xo=class{get errors(){return this._errors}get warnings(){return this._warnings}get authorMessages(){return this._authorMessages}get inputString(){return this._inputString}get options(){return this._options}get parsedStory(){if(!this._parsedStory)throw new Error;return this._parsedStory}get runtimeStory(){if(!this._runtimeStory)throw new Error("Compilation failed.");return this._runtimeStory}get parser(){if(!this._parser)throw new Error;return this._parser}get debugSourceRanges(){return this._debugSourceRanges}constructor(e,t=null){this._errors=[],this._warnings=[],this._authorMessages=[],this._parsedStory=null,this._runtimeStory=null,this._parser=null,this._debugSourceRanges=[],this.Compile=()=>(this._parser=new Im.InkParser(this.inputString,this.options.sourceFilename||null,this.OnError,null,this.options.fileHandler),this._parsedStory=this.parser.ParseStory(),this.errors.length===0?(this.parsedStory.countAllVisits=this.options.countAllVisits,this._runtimeStory=this.parsedStory.ExportRuntime(this.OnError)):this._runtimeStory=null,this.runtimeStory),this.RetrieveDebugSourceForLatestContent=()=>{var n;for(let i of this.runtimeStory.state.outputStream){let a=(0, Fm.asOrNull)(i,Vm.StringValue);if(a!==null){let s=new Am.DebugSourceRange(((n=a.value)===null||n===void 0?void 0:n.length)||0,a.debugMetadata,a.value||"unknown");this.debugSourceRanges.push(s);}}},this.GenerateStats=()=>this._parsedStory===null?null:(0, km.GenerateStoryStats)(this._parsedStory),this.DebugMetadataForContentAtOffset=n=>{let i=0,a=null;for(let s of this.debugSourceRanges){if(s.debugMetadata!==null&&(a=s.debugMetadata),n>=i&&n<i+s.length)return a;i+=s.length;}return null},this.OnError=(n,i)=>{switch(i){case zo.ErrorType.Author:this._authorMessages.push(n);break;case zo.ErrorType.Warning:this._warnings.push(n);break;case zo.ErrorType.Error:this._errors.push(n);break}this.options.errorHandler!==null&&this.options.errorHandler(n,i);},this._inputString=e,this._options=t||new Nm.CompilerOptions;}};le.Compiler=Xo;});var Wh=Object.defineProperty,jh=(r,e,t)=>e in r?Wh(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,_s=(r,e,t)=>jh(r,typeof e!="symbol"?e+"":e,t),Jn=class O{static t(e){return Array.isArray(e)?e.map(t=>O.translate(`${t}`)):O.translate(`${e}`)}static set beforeToTranslate(e){O._beforeToTranslate=e;}static set translate(e){O._translate=e;}static get translate(){return e=>{let t=e;return O._beforeToTranslate&&(t=O._beforeToTranslate(t)),t=O._translate(t),O._afterToTranslate&&(t=O._afterToTranslate(t)),t}}static set afterToTranslate(e){O._afterToTranslate=e;}static addKey(e,t,n){let i=n.defaultValue||"empty_string";typeof t=="string"&&(t=[t]),Array.isArray(t)&&t.forEach(a=>{e[a]===void 0&&(i==="empty_string"?e[a]="":i==="copy_key"&&(O._beforeToTranslate?e[a]=O._beforeToTranslate(a):e[a]=a));});}static getConditionalsThenElse(e,t=[]){if(typeof e=="object"&&e&&"type"in e)if(e.type==="ifelse")e.then&&O.getConditionalsThenElse(e.then,t),e.else&&O.getConditionalsThenElse(e.else,t);else if(e.type==="stepswitch"){if(e.elements)if(Array.isArray(e.elements))e.elements.forEach(n=>{O.getConditionalsThenElse(n,t);});else if(e.elements.type==="ifelse"){let n=[];O.getConditionalsThenElse(e.elements,n),n.forEach(i=>{t.push(...i);});}else if(e.elements.type==="stepswitch"){let n=[];O.getConditionalsThenElse(e.elements,n),n.forEach(i=>{t.push(...i);});}else O.getConditionalsThenElse(e.elements,t);}else e.type==="resulttocombine"?(e.firstItem&&O.getConditionalsThenElse(e.firstItem,t),e.secondConditionalItem&&e.secondConditionalItem.forEach(n=>{O.getConditionalsThenElse(n,t);})):t.push(e);else e&&t.push(e);return t}static generateJsonTranslation(e,t={},n={}){let{defaultValue:i="copy_key"}=n;return e.forEach(a=>{if(a.choices){let s=[];Array.isArray(a.choices)?s=[a.choices]:s=O.getConditionalsThenElse(a.choices),s.forEach(o=>o.forEach(l=>{if("type"in l){let u=[];l.type==="ifelse"||l.type==="stepswitch"?O.getConditionalsThenElse(l,u):u=[l],u.map(h=>O.getConditionalsThenElse(h.text)).forEach(h=>{Array.isArray(h)&&h.forEach(c=>{Array.isArray(c)?c.forEach(d=>{typeof d=="string"?O.addKey(t,d,{defaultValue:i}):O.getConditionalsThenElse(d).forEach(p=>{Array.isArray(p)?p.forEach(C=>{typeof C=="string"&&O.addKey(t,C,{defaultValue:i});}):typeof p=="string"&&O.addKey(t,p,{defaultValue:i});});}):typeof c=="string"&&O.addKey(t,c,{defaultValue:i});});});}}));}if(a.dialogue){let s=[];Array.isArray(a.dialogue)?s=[a.dialogue]:s=O.getConditionalsThenElse(a.dialogue),s.forEach(o=>{if(typeof o=="string")O.addKey(t,o,{defaultValue:i});else if("text"in o){let l=O.getConditionalsThenElse(o.text);typeof l=="string"&&(l=[l]),l.forEach(u=>{typeof u=="string"?O.addKey(t,u,{defaultValue:i}):O.getConditionalsThenElse(u).forEach(h=>{typeof h=="string"?O.addKey(t,h,{defaultValue:i}):Array.isArray(h)&&h.forEach(c=>{typeof c=="string"?O.addKey(t,c,{defaultValue:i}):O.getConditionalsThenElse(c).forEach(d=>{typeof d=="string"&&O.addKey(t,d,{defaultValue:i});});});});});}});}a.operations&&a.operations.forEach(s=>{switch(s.type){case "text":switch(s.operationType){case "show":O.addKey(t,s.text,{defaultValue:i});break}break}}),a.conditionalStep&&O.getConditionalsThenElse(a.conditionalStep).forEach(s=>{Array.isArray(s)?O.generateJsonTranslation(s,t,n):O.generateJsonTranslation([s],t,n);});}),t}};_s(Jn,"_beforeToTranslate"),_s(Jn,"_translate",r=>r),_s(Jn,"_afterToTranslate");var qh=Jn,X=qh;var Mh=Object.defineProperty,Bh=(r,e,t)=>e in r?Mh(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,de=(r,e,t)=>Bh(r,typeof e!="symbol"?e+"":e,t),ne;(r=>(r.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),r.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),r.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),r.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(ne||(ne={}));var ue=class L{static init(e){L._loadAssets=e.loadAssets,L._soundOperation=e.soundOperation,L._imageOperation=e.imageOperation,L._videoOperation=e.videoOperation,L._imageContainerOperation=e.imageContainerOperation,L._textOperation=e.textOperation,L._canvasElementOperation=e.canvasElementOperation,L._setStorageValue=e.setStorageValue,L._narrationOperation=e.narrationOperation,L._tickerOperation=e.tickerOperation,L._effectOperation=e.effectOperation,L._animateOperation=e.animateOperation,L._getLogichValue=e.getLogichValue,L._getConditionalStep=e.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 textOperation(){return L._textOperation}static get imageContainerOperation(){return L._imageContainerOperation}static get canvasElementOperation(){return L._canvasElementOperation}static get setStorageValue(){return L._setStorageValue}static get narrationOperation(){return L._narrationOperation}static get tickerOperation(){return L._tickerOperation}static get effectOperation(){return L._effectOperation}static get animateOperation(){return L._animateOperation}static get getLogichValue(){return L._getLogichValue}static get getConditionalStep(){return L._getConditionalStep}};de(ue,"_loadAssets",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_soundOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_imageOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_videoOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_imageContainerOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_textOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_canvasElementOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_setStorageValue",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_narrationOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_tickerOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_effectOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_animateOperation",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_getLogichValue",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")}),de(ue,"_getConditionalStep",()=>{throw ne.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new Error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")});var I=ue;var $h=Object.create,ws=Object.defineProperty,Hh=Object.getOwnPropertyDescriptor,Uh=Object.getOwnPropertyNames,Kh=Object.getPrototypeOf,zh=Object.prototype.hasOwnProperty,Xh=(r,e,t)=>e in r?ws(r,e,{enumerable:true,configurable:true,writable:true,value:t}):r[e]=t,cl=(r=>typeof lt<"u"?lt:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof lt<"u"?lt:e)[t]}):r)(function(r){if(typeof lt<"u")return lt.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')}),fl=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Yh=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Uh(e))!zh.call(r,i)&&i!==t&&ws(r,i,{get:()=>e[i],enumerable:!(n=Hh(e,i))||n.enumerable});return r},Qh=(r,e,t)=>(t=r!=null?$h(Kh(r)):{},Yh(ws(t,"default",{value:r,enumerable:true}),r)),Es=(r,e,t)=>Xh(r,typeof e!="symbol"?e+"":e,t),Zh=fl((r,e)=>{(function(t,n){typeof r=="object"?e.exports=r=n():typeof define=="function"&&define.amd?define([],n):t.CryptoJS=n();})(r,function(){var t=t||(function(n,i){var a;if(typeof window<"u"&&window.crypto&&(a=window.crypto),typeof self<"u"&&self.crypto&&(a=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(a=globalThis.crypto),!a&&typeof window<"u"&&window.msCrypto&&(a=window.msCrypto),!a&&typeof global<"u"&&global.crypto&&(a=global.crypto),!a&&typeof cl=="function")try{a=cl("crypto");}catch{}var s=function(){if(a){if(typeof a.getRandomValues=="function")try{return a.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof a.randomBytes=="function")try{return a.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function g(){}return function(f){var w;return g.prototype=f,w=new g,g.prototype=null,w}})(),l={},u=l.lib={},h=u.Base=(function(){return {extend:function(g){var f=o(this);return g&&f.mixIn(g),(!f.hasOwnProperty("init")||this.init===f.init)&&(f.init=function(){f.$super.init.apply(this,arguments);}),f.init.prototype=f,f.$super=this,f},create:function(){var g=this.extend();return g.init.apply(g,arguments),g},init:function(){},mixIn:function(g){for(var f in g)g.hasOwnProperty(f)&&(this[f]=g[f]);g.hasOwnProperty("toString")&&(this.toString=g.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),c=u.WordArray=h.extend({init:function(g,f){g=this.words=g||[],f!=i?this.sigBytes=f:this.sigBytes=g.length*4;},toString:function(g){return (g||p).stringify(this)},concat:function(g){var f=this.words,w=g.words,m=this.sigBytes,b=g.sigBytes;if(this.clamp(),m%4)for(var P=0;P<b;P++){var _e=w[P>>>2]>>>24-P%4*8&255;f[m+P>>>2]|=_e<<24-(m+P)%4*8;}else for(var q=0;q<b;q+=4)f[m+q>>>2]=w[q>>>2];return this.sigBytes+=b,this},clamp:function(){var g=this.words,f=this.sigBytes;g[f>>>2]&=4294967295<<32-f%4*8,g.length=n.ceil(f/4);},clone:function(){var g=h.clone.call(this);return g.words=this.words.slice(0),g},random:function(g){for(var f=[],w=0;w<g;w+=4)f.push(s());return new c.init(f,g)}}),d=l.enc={},p=d.Hex={stringify:function(g){for(var f=g.words,w=g.sigBytes,m=[],b=0;b<w;b++){var P=f[b>>>2]>>>24-b%4*8&255;m.push((P>>>4).toString(16)),m.push((P&15).toString(16));}return m.join("")},parse:function(g){for(var f=g.length,w=[],m=0;m<f;m+=2)w[m>>>3]|=parseInt(g.substr(m,2),16)<<24-m%8*4;return new c.init(w,f/2)}},C=d.Latin1={stringify:function(g){for(var f=g.words,w=g.sigBytes,m=[],b=0;b<w;b++){var P=f[b>>>2]>>>24-b%4*8&255;m.push(String.fromCharCode(P));}return m.join("")},parse:function(g){for(var f=g.length,w=[],m=0;m<f;m++)w[m>>>2]|=(g.charCodeAt(m)&255)<<24-m%4*8;return new c.init(w,f)}},y=d.Utf8={stringify:function(g){try{return decodeURIComponent(escape(C.stringify(g)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(g){return C.parse(unescape(encodeURIComponent(g)))}},S=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new c.init,this._nDataBytes=0;},_append:function(g){typeof g=="string"&&(g=y.parse(g)),this._data.concat(g),this._nDataBytes+=g.sigBytes;},_process:function(g){var f,w=this._data,m=w.words,b=w.sigBytes,P=this.blockSize,_e=P*4,q=b/_e;g?q=n.ceil(q):q=n.max((q|0)-this._minBufferSize,0);var H=q*P,Ee=n.min(H*4,b);if(H){for(var _t=0;_t<H;_t+=P)this._doProcessBlock(m,_t);f=m.splice(0,H),w.sigBytes-=Ee;}return new c.init(f,Ee)},clone:function(){var g=h.clone.call(this);return g._data=this._data.clone(),g},_minBufferSize:0});u.Hasher=S.extend({cfg:h.extend(),init:function(g){this.cfg=this.cfg.extend(g),this.reset();},reset:function(){S.reset.call(this),this._doReset();},update:function(g){return this._append(g),this._process(),this},finalize:function(g){g&&this._append(g);var f=this._doFinalize();return f},blockSize:16,_createHelper:function(g){return function(f,w){return new g.init(w).finalize(f)}},_createHmacHelper:function(g){return function(f,w){return new _.HMAC.init(g,w).finalize(f)}}});var _=l.algo={};return l})(Math);return t});}),ec=fl((r,e)=>{(function(t,n){typeof r=="object"?e.exports=r=n(Zh()):typeof define=="function"&&define.amd?define(["./core"],n):n(t.CryptoJS);})(r,function(t){return (function(){var n=t,i=n.lib,a=i.WordArray,s=i.Hasher,o=n.algo,l=[],u=o.SHA1=s.extend({_doReset:function(){this._hash=new a.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,c){for(var d=this._hash.words,p=d[0],C=d[1],y=d[2],S=d[3],_=d[4],g=0;g<80;g++){if(g<16)l[g]=h[c+g]|0;else {var f=l[g-3]^l[g-8]^l[g-14]^l[g-16];l[g]=f<<1|f>>>31;}var w=(p<<5|p>>>27)+_+l[g];g<20?w+=(C&y|~C&S)+1518500249:g<40?w+=(C^y^S)+1859775393:g<60?w+=(C&y|C&S|y&S)-1894007588:w+=(C^y^S)-899497514,_=S,S=y,y=C<<30|C>>>2,C=p,p=w;}d[0]=d[0]+p|0,d[1]=d[1]+C|0,d[2]=d[2]+y|0,d[3]=d[3]+S|0,d[4]=d[4]+_|0;},_doFinalize:function(){var h=this._data,c=h.words,d=this._nDataBytes*8,p=h.sigBytes*8;return c[p>>>5]|=128<<24-p%32,c[(p+64>>>9<<4)+14]=Math.floor(d/4294967296),c[(p+64>>>9<<4)+15]=d,h.sigBytes=c.length*4,this._process(),this._hash},clone:function(){var h=s.clone.call(this);return h._hash=this._hash.clone(),h}});n.SHA1=s._createHelper(u),n.HmacSHA1=s._createHmacHelper(u);})(),t.SHA1});}),Et;(r=>(r.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),r.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),r.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),r.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(Et||(Et={}));async function xs(r,e={}){let{operationStringConvert:t,skipEmptyDialogs:n}=e;if(!Array.isArray(r))if(typeof r=="object"||typeof r=="string")r=[r];else {Et.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let i=r.map(async s=>{if(typeof s=="string")try{s=JSON.parse(s);}catch(o){Et.error("Error parsing imported Pixi'VN JSON",o),s={};}return s}),a=(await Promise.all(i)).map(async s=>{let o=[];if(s.initialOperations){let l={};[...storage.storage.storage.keys()].forEach((u,h)=>{l[u]=storage.storage.storage.get(u);}),storage.storage.startingStorage=l;}if(s.labels){let l=s.labels;for(let u in l)try{let h=l[u],c=new ic(u,h,void 0,e);narration.RegisteredLabels.add(c);}catch(h){Et.error(`Error creating JSON label ${u}`,h);}}return Promise.all(o)});await Promise.all(a);}var tc=Qh(ec()),dl="___param___";function nc(r){try{if(typeof r>"u")return r;let e=JSON.stringify(r);return JSON.parse(e)}catch(e){throw Et.error("Error creating exportable element",r,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}async function pl(r,e){let t=I.getLogichValue(r);if(t)switch(t.type){case "sound":I.soundOperation(t);break;case "assets":case "bundle":await I.loadAssets(t);break;case "image":await I.imageOperation(t);break;case "video":await I.videoOperation(t);break;case "imagecontainer":await I.imageContainerOperation(t);break;case "text":await I.textOperation(t);break;case "canvaselement":await I.canvasElementOperation(t);break;case "value":I.setStorageValue(t);break;case "operationtoconvert":if(e){let n="";t.values.forEach(a=>{if(typeof a=="string")n+=a;else {let s=I.getLogichValue(a);n+=`${s}`;}});let i=await e(n);i&&await pl(i,e);}break;case "input":case "dialogue":I.narrationOperation(t);break;case "fade":case "move":case "rotate":case "zoom":I.tickerOperation(t);break;case "shake":await I.effectOperation(t);break;case "animate":case "animate-sequence":I.animateOperation(t);break}}var ic=class extends narration.LabelAbstract{constructor(r,e,t,n={}){t||(t={}),t.onLoadingLabel=async()=>{for(let i of e){let a;if(typeof i=="function"?a=i():a=i,a=I.getConditionalStep(a),a.operations){let s=a.operations.map(o=>I.loadAssets(o));await Promise.all(s);}}},super(r,t),Es(this,"_steps"),Es(this,"operationStringConvert"),Es(this,"skipEmptyDialogs",false),this._steps=e,this.operationStringConvert=n.operationStringConvert,this.skipEmptyDialogs=n.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let e=this._steps[r];return this.stepConverter(e)}getStepSha(r){if(r<0||r>=this.steps.length)return;let e=this._steps[r];return (0, tc.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(r){let e="";if(Array.isArray(r)){let t=[];r.forEach(n=>{if(typeof n=="string")t.push(n);else if(n&&typeof n=="object"){let i=I.getLogichValue(n);i?(i&&!Array.isArray(i)&&typeof i=="object"&&(i=I.getLogichValue(i)||""),Array.isArray(i)?t=t.map(a=>`${a}`).concat(i):t.push(`${i}`)):t.push(`${n}`);}else t.push(`${n}`);}),e=t;}else {let t=I.getLogichValue(r)||"";t&&!Array.isArray(t)&&typeof t=="object"&&(t=I.getLogichValue(t)||""),e=t;}return `${e}`}getDialogue(r){if(r==null)return;let e=I.getLogichValue(r);return e==null?"":typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:X.t(this.getDialogueText(e.text))}:X.t(this.getDialogueText(e))}getChoices(r){return I.getLogichValue(r)?.map(e=>I.getLogichValue(e)).filter(e=>e!==void 0)}stepConverter(r){return async e=>{let t=typeof r=="function"?r():r;t=nc(t),t=I.getConditionalStep(t);let n=this.operationStringConvert?d=>this.operationStringConvert(d,t,e):void 0,{operations:i=[]}=t;for(let d of i)await pl(d,n);let{labelToOpen:a=[]}=t,s=this.getChoices(t.choices),o=I.getLogichValue(t.glueEnabled),l=this.getDialogue(t.dialogue),u=[];Array.isArray(a)||(a=[a]),a.forEach(d=>{let p=I.getLogichValue(d);p&&u.push(p);});let h=I.getLogichValue(t.goNextStep),c=I.getLogichValue(t.end);if(s){let d=s.map(p=>{let C="";if(Array.isArray(p.text)){let y=[];p.text.forEach(S=>{if(typeof S=="string")y.push(X.t(S));else if(S&&typeof S=="object"){let _=I.getLogichValue(S);_&&!Array.isArray(_)&&typeof _=="object"&&(_=I.getLogichValue(_)||""),_&&(Array.isArray(_)?y=y.concat(X.t(_)):y.push(X.t(_)));}}),C=y;}else typeof p.text=="string"&&(C=X.t(p.text));return {label:p.label,text:C,props:p.props,type:p.type,oneTime:p.oneTime,onlyHaveNoChoice:p.onlyHaveNoChoice,autoSelect:p.autoSelect}});narration.narration.choiceMenuOptions=d;}else narration.narration.choiceMenuOptions=void 0;l!==void 0&&(narration.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=true)),o?storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true):o===false&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);for(let d of u){let p=d.label;typeof p=="object"&&(p=I.getLogichValue(p)||"");let C=d.params?.map(y=>I.getLogichValue(y));e={...e,...d.props},d.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${dl}${narration.narration.openedLabels.length}`,C),await narration.narration.callLabel(p,e)):(storage.storage.setTempVariable(`${dl}${narration.narration.openedLabels.length}`,C),await narration.narration.callLabel(p,e));}c==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.goNext(e,{runNow:true})):c==="label_end"&&narration.narration.closeCurrentLabel(),h&&await narration.narration.goNext(e,{runNow:true});}}};var Ps="___param___";async function Pc(r){let e=I.getLogichValue(r);if(e)switch(e.type){case "assets":switch(e.operationType){case "load":await pixiVn.Assets.load(e.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoad(e.aliases);break}break;case "bundle":switch(e.operationType){case "load":await pixiVn.Assets.loadBundle(e.aliases);break;case "lazyload":pixiVn.Assets.backgroundLoadBundle(e.aliases);break}break}}var ie;(r=>(r.log=(e,...t)=>console.log(`[Pixi\u2019VN Json] ${e}`,...t),r.warn=(e,...t)=>console.warn(`[Pixi\u2019VN Json] ${e}`,...t),r.error=(e,...t)=>console.error(`[Pixi\u2019VN Json] ${e}`,...t),r.info=(e,...t)=>console.info(`[Pixi\u2019VN Json] ${e}`,...t)))(ie||(ie={}));async function Un(r,e,t){switch(t.type){case "fade":await pixiVn.showWithFade(e.alias,r,t.props,t.priority);break;case "dissolve":await pixiVn.showWithDissolve(e.alias,r,t.props,t.priority);break;case "movein":case "moveout":await pixiVn.moveIn(e.alias,r,t.props,t.priority);break;case "zoomin":case "zoomout":await pixiVn.zoomIn(e.alias,r,t.props,t.priority);break;case "pushin":case "pushout":await pixiVn.pushIn(e.alias,r,t.props,t.priority);break}}function tn(r){if(r.transition)switch(r.transition.type){case "fade":pixiVn.removeWithFade(r.alias,r.transition.props,r.transition.priority);break;case "dissolve":pixiVn.removeWithDissolve(r.alias,r.transition.props,r.transition.priority);break;case "movein":case "moveout":pixiVn.moveOut(r.alias,r.transition.props,r.transition.priority);break;case "zoomin":case "zoomout":pixiVn.zoomOut(r.alias,r.transition.props,r.transition.priority);break;case "pushin":case "pushout":pixiVn.pushOut(r.alias,r.transition.props,r.transition.priority);break}else pixiVn.canvas.remove(r.alias);}async function Oc(r){switch(r.operationType){case "show":if(r.transition){let t=new pixiVn.ImageSprite(r.props,r.url||r.alias);await Un(t,r,r.transition);}else await pixiVn.showImage(r.alias,r.url,r.props);break;case "edit":let e=pixiVn.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):ie.error(`Image with alias ${r.alias} not found.`);break;case "remove":tn(r);break}}async function Nc(r){switch(r.operationType){case "show":if(r.transition){let i=new pixiVn.VideoSprite(r.props,r.url||r.alias);await Un(i,r,r.transition);}else await pixiVn.showVideo(r.alias,r.url,r.props);break;case "edit":let e=pixiVn.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):ie.error(`Video with alias ${r.alias} not found.`);break;case "remove":tn(r);break;case "pause":let t=pixiVn.canvas.find(r.alias);t?t.paused=true:ie.error(`Video with alias ${r.alias} not found.`);break;case "resume":let n=pixiVn.canvas.find(r.alias);n?n.paused=false:ie.error(`Video with alias ${r.alias} not found.`);break}}async function Ac(r){switch(r.operationType){case "show":if(r.transition){let t=new pixiVn.ImageContainer(r.props,r.urls);await Un(t,r,r.transition);}else await pixiVn.showImageContainer(r.alias,r.urls,r.props);break;case "edit":let e=pixiVn.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):ie.error(`ImageContainer with alias ${r.alias} not found.`);break;case "remove":tn(r);break}}async function Ic(r){switch(r.operationType){case "show":if(r.props=r.props||{},r.props.text=X.t(r.text),r.transition){let t=new pixiVn.Text(r.props);await Un(t,r,r.transition);}else pixiVn.showText(r.alias,r.text,r.props);break;case "edit":let e=pixiVn.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):ie.error(`Text with alias ${r.alias} not found.`);break;case "remove":tn(r);break}}async function Vc(r){switch(r.operationType){case "edit":try{let e=pixiVn.canvas.find(r.alias);e?r.props&&(e.memory={...e.memory,...r.props}):ie.error(`Canvas Element with alias ${r.alias} not found.`);}catch(e){ie.error(`There was an error while trying to edit the canvas element with alias ${r.alias}.`,e);}break;case "remove":tn(r);break}}function Fc(r){switch(r.type){case "fade":let e=new pixiVn.FadeAlphaTicker(r.props,r.duration,r.priority);pixiVn.canvas.addTicker(r.alias,e);break;case "move":let t=new pixiVn.MoveTicker(r.props,r.duration,r.priority);pixiVn.canvas.addTicker(r.alias,t);break;case "rotate":let n=new pixiVn.RotateTicker(r.props,r.duration,r.priority);pixiVn.canvas.addTicker(r.alias,n);break;case "zoom":let i=new pixiVn.ZoomTicker(r.props,r.duration,r.priority);pixiVn.canvas.addTicker(r.alias,i);break}}async function kc(r){switch(r.type){case "shake":await pixiVn.shakeEffect(r.alias,r.props,r.priority);break}}function Rc(r){switch(r.type){case "animate":pixiVn.canvas.animate(r.alias,r.keyframes,r.options,r.priority);break;case "animate-sequence":pixiVn.canvas.animate(r.alias,r.sequence,r.options,r.priority);break}}function Lc(r){switch(r.type){case "input":pixiVn.narration.requestInput({type:r.valueType},r.defaultValue);break;case "dialogue":pixiVn.narration.dialogue=void 0;break}}function Dc(r){switch(r.operationType){case "play":pixiVn.sound.play(r.alias,r.props);break;case "stop":pixiVn.sound.stop(r.alias);break;case "pause":pixiVn.sound.pause(r.alias);break;case "resume":pixiVn.sound.resume(r.alias);break;case "volume":pixiVn.sound.volume(r.alias,r.value);break}}function Wc(r){try{if(typeof r>"u")return r;let e=JSON.stringify(r);return JSON.parse(e)}catch(e){throw ie.error("Error creating exportable element",r,e),new Error("[Pixi\u2019VN] Error creating exportable element")}}function jc(r){let e=R(r.value),t;switch(e&&typeof e=="object"&&"type"in e?t=R(e):t=e,r.storageType){case "flagStorage":storage.storage.setFlag(r.key,r.value);break;case "storage":storage.storage.setVariable(r.key,t);break;case "tempstorage":storage.storage.setTempVariable(r.key,t);break;case "params":let n=storage.storage.getVariable(`${Ps}${narration.narration.openedLabels.length-1}`)||[];n&&n.length-1>=r.key&&(n[r.key]=t),storage.storage.setTempVariable(`${Ps}${narration.narration.openedLabels.length-1}`,n);break}}function R(r){let e=$c(r);if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "value":return Mc(e);case "arithmetic":case "arithmeticsingle":return qc(e);case "compare":case "valueCondition":case "union":return Bc(e)}return e}function qc(r){let e=R(r.leftValue);switch(r.type){case "arithmetic":let t=R(r.rightValue);switch(r.operator){case "*":return e*t;case "/":return e/t;case "+":return e+t;case "-":return e-t;case "%":return e%t;case "POW":return Math.pow(e,t);case "RANDOM":return narration.narration.getRandomNumber(e,t)}case "arithmeticsingle":switch(r.operator){case "INT":return parseInt(e);case "FLOOR":return Math.floor(e);case "FLOAT":return parseFloat(e)}break}}function Mc(r){if(r&&typeof r=="object"&&"type"in r&&r.type==="value"&&r.storageOperationType==="get")switch(r.storageType){case "storage":case "tempstorage":return storage.storage.getVariable(r.key);case "flagStorage":return storage.storage.getFlag(r.key);case "label":return narration.narration.getTimesLabelOpened(r.label);case "choice":return narration.narration.getTimesChoiceMade(r.index);case "logic":return R(r.operation);case "params":let e=storage.storage.getVariable(`${Ps}${narration.narration.openedLabels.length-1}`)||[];if(e&&e.length>r.key)return e[r.key];ie.warn("getValue params not found");return}return r}function Bc(r){if(!r)return false;if(typeof r!="object"||!("type"in r))return !!r;switch(r.type){case "compare":let e=R(r.leftValue),t=R(r.rightValue);switch(r.operator){case "==":return e===t;case "!=":return e!==t;case "<":return e<t;case "<=":return e<=t;case ">":return e>t;case ">=":return e>=t;case "CONTAINS":return e.toString().includes(t.toString())}break;case "valueCondition":return !!R(r.value);case "union":return Gc(r)}return !!r}function Gc(r){if(r.unionType==="not")return !R(r.condition);let e=r.unionType==="and";for(let t=0;t<r.conditions.length;t++)if(e=R(r.conditions[t])||false,r.unionType==="and"){if(!e)return false}else if(e)return true;return e}function Jc(r,e){return Math.floor(Math.random()*(e-r+1)+r)}function $c(r){if(Array.isArray(r)||!r)return r;if(r&&typeof r=="object"&&"type"in r)switch(r.type){case "resulttocombine":return Hc(r);case "ifelse":return R(r.condition)?R(r.then):R(r.else);case "stepswitch":let e=R(r.elements)||[];if(e.length===0){ie.error("getValueFromConditionalStatements elements.length === 0");return}switch(r.choiceType){case "random":let t=Jc(0,e.length-1);return R(e[t]);case "loop":let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(r.nestedId)-1;return n>e.length-1&&(n=n%e.length),R(e[n]);case "sequential":let i,a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(r.nestedId)-1;return r.end=="lastItem"&&(i=R(e[e.length-1])),a>e.length-1?i:R(e[a]);case "sequentialrandom":let s=narration.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:r.nestedId,onceOnly:true});if(s==null&&r.end=="lastItem"){let o=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(r.nestedId);if(!o||!o?.usedRandomNumbers){ie.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let l=o.usedRandomNumbers[`0-${e.length-1}`];return R(e[l[l.length-1]])}if(s==null){ie.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return R(e[s])}}return r}function Os(r){if(r.conditionalStep){let e=Wc(R(r.conditionalStep));if(e?.glueEnabled===void 0&&delete e?.glueEnabled,e?.goNextStep===void 0&&delete e?.goNextStep,e?.end===void 0&&delete e?.end,e?.choices===void 0&&delete e?.choices,e?.dialogue===void 0&&delete e?.dialogue,e?.labelToOpen===void 0&&delete e?.labelToOpen,e?.operations===void 0&&delete e?.operations,e){let t={...r,conditionalStep:void 0,...e};return Os(t)}else storage.storage.getFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,false);}return r}function Hc(r){let e=r.firstItem,t=[];r.secondConditionalItem?.forEach(i=>{if(Array.isArray(i))i.forEach(a=>{let s=R(a);t.push(s);});else {let a=R(i);t.push(a);}});let n=e?[e,...t]:t;if(n.length===0){ie.warn("combinateResult toCheck.length === 0");return}if(typeof n[0]=="string")return X.t(n);if(typeof n[0]=="object"){let i=n,a,s=i.map((S,_)=>{S=Os(S);let g=R(S.dialogue)||"";return _===0?(a=R(S.glueEnabled)||false,g):(typeof g=="object"&&"text"in g&&(g=g.character+": "+g.text),a===false&&(g=`
45
45
 
46
- `+g),a=R(S.glueEnabled)||false,g)}),o=R(s[0]),l=typeof o=="object"&&"character"in o?o.character:void 0,u=s.flatMap(S=>{let _;S&&typeof S=="object"&&"text"in S?_=S.text:_=S;let g;return Array.isArray(_)?g=_.map(f=>{let w=R(f);return X.t(`${w}`)}):g=R(_)||"",X.t(g)}),h=i.find(S=>S.end),c=i.find(S=>S.choices),d=false,p=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),d=i[i.length-1].glueEnabled,p=i.reverse().find(S=>!(S.operations&&(!S.dialogue||!S.choices)))?.goNextStep);let C=i.find(S=>S.labelToOpen),y=[];return i.forEach(S=>{S.operations&&y.forEach(_=>{y.push(_);});}),{dialogue:l?{character:l,text:u}:u,end:h?.end,choices:c?.choices,glueEnabled:d,goNextStep:p,labelToOpen:C?.labelToOpen,operations:y}}}function Ns(){I.init({animateOperation:Rc,canvasElementOperation:Vc,effectOperation:kc,imageContainerOperation:Ac,imageOperation:Oc,textOperation:Ic,narrationOperation:Lc,loadAssets:Pc,soundOperation:Dc,tickerOperation:Fc,videoOperation:Nc,setStorageValue:jc,getLogichValue:R,getConditionalStep:Os});}var V;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(V||(V={}));var ml="\xA7SPACE\xA7",Cl="\xA7DOUBLE_QUOTES\xA7",vl="\xA7QUOTES\xA7",yl="SPECIAL_\xA7QUOTES\xA7",Sl="\xA7CURLY_BRACKETS1\xA7",bl="\xA7CURLY_BRACKETS2\xA7",Uc=["add","play","pause","resume","remove","volume"],T=class T{static runCustomHashtagScript(e,t){return T._customHashtagScript(e,t,T.convertListStringToObj)}static set customHashtagScript(e){T._customHashtagScript=e;}static async generateOrRunOperationFromHashtagScript(e,t,n){try{e=e.replaceAll('\\"',Cl),e=e.replaceAll("\\'",vl),e=e.replaceAll("\\`",yl),e=e.replaceAll("\\{",Sl),e=e.replaceAll("\\}",bl),e=e.replaceAll("{"," { "),e=e.replaceAll("}"," } "),e=e.replaceAll(Sl,"{"),e=e.replaceAll(bl,"}");let i=[],a,s="";for(let h=0;h<e.length;h++){let c=e[h];c==='"'||c==="'"||c==="`"?a===void 0?(i.push(s),s="",a=c,s+=c):a===c?(a=void 0,s+=c,i.push(s),s=""):s+=c:s+=c;}s!==""&&i.push(s),i.forEach((h,c)=>{c%2===1&&(i[c]=h.replaceAll(" ",ml));}),e=i.join(""),i=e.split(" ").filter(h=>h!==""),i=i.map(h=>h.replaceAll(ml," ").replaceAll(Cl,'"').replaceAll(vl,"'").replaceAll(yl,"`"));let o=T.runCustomHashtagScript(i,n);if(o===!0)return;if(typeof o=="string")return o.startsWith("#")&&(o=o.substring(1)),T.generateOrRunOperationFromHashtagScript(o,t,n);let l=i.length>1?T.removeExtraDoubleQuotes(i[1]):"",u=i.length>0?T.removeExtraDoubleQuotes(i[0]):"";switch(l){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return l==="video"&&(u==="pause"||u==="resume")?{type:"video",operationType:u,alias:T.removeExtraDoubleQuotes(i[2])}:T.getCanvasOperationFromComment(i,l);case "sound":return T.getSoundOperationFromComment(i);case "input":if(u==="request"){let h={type:"input",operationType:"request"};if(i.length>2)try{let c=i.slice(2),d=T.convertListStringToObj(c);"type"in d&&typeof d.type=="string"&&(h.valueType=d.type),"default"in d&&(h.defaultValue=d.default);}catch{}return h}break;case "assets":case "bundle":switch(u){case "load":case "lazyload":return {type:l,operationType:u,aliases:i.slice(2)}}break;default:if(l)switch(u){case "call":case "jump":t.labelToOpen={label:l,type:u},t.goNextStep=void 0;return;case "fade":case "move":case "rotate":case "zoom":case "shake":let h={};if(i.length>2)try{h=T.convertListStringToObj(i.slice(2));}catch{}if(u=="move"&&"x"in h&&"y"in h&&(h.destination={x:h.x,y:h.y,type:"pixel"},delete h.x,delete h.y),u=="move"&&"xAlign"in h&&"yAlign"in h&&(h.destination={x:h.xAlign,y:h.yAlign,type:"align"},delete h.xAlign,delete h.yAlign),u=="move"&&"xPercentage"in h&&"yPercentage"in h&&(h.destination={x:h.xPercentage,y:h.yPercentage,type:"percentage"},delete h.xPercentage,delete h.yPercentage),u=="move"&&!("destination"in h)){V.error("The move operation don't have a destination or destination is not valid",h);return}return {alias:l,type:u,props:h};case "animate":let d={},p={};if(i.length>2){let y=i.slice(2),S=[];if(y.includes("options")){let _=y.indexOf("options");S=y.slice(_+1),y=y.slice(0,_);}try{d=T.convertListStringToObj(y);}catch{}if(S.length>0)try{p=T.convertListStringToObj(S);}catch{}}return {alias:l,type:u,keyframes:d,options:p}}else switch(u){case "pause":return "dialogue"in t&&delete t.dialogue,"goNextStep"in t&&delete t.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":t.goNextStep=!0,t.glueEnabled=!1;return}}}catch(i){throw V.error("Error parsing ink hashtag-script",e),i}V.error("The operation is not valid",e);}static getCanvasOperationFromComment(e,t){let n=T.removeExtraDoubleQuotes(e[0]),i=T.removeExtraDoubleQuotes(e[2]),a=T.convertListStringToPropList(e.slice(3));switch(n){case "show":switch(t){case "image":case "video":return T.getImageOperationFromComment(t,i,a);case "imagecontainer":return T.getContainerOperationFromComment(t,i,a);case "text":return T.getTextOperationFromComment(t,i,a);case "canvaselement":default:V.error("This show operation is not valid for this type of element",t);}case "edit":return {type:t,operationType:"edit",alias:i,props:T.convertPropListStringToObj(a)};case "remove":let o={type:t,operationType:"remove",alias:i};if(a.length>1&&a[0]==="with"){let l=e[e.indexOf("with")+1],u=e.slice(e.indexOf("with")+2),h=T.getTransition(l,u);h!==void 0&&(o.transition=h);}return o;default:V.error("The operation type is not valid",n);}}static getImageOperationFromComment(e,t,n){let i,a;n.length%2===0?(i=t,a=n):(i=T.removeExtraDoubleQuotes(n[0]),a=T.convertListStringToPropList(n.slice(1)));let s={type:e,operationType:"show",alias:t,url:i};return T.setShowProps(s,a)}static getTextOperationFromComment(e,t,n){let i,a;n.length%2===0?(i=t,a=n):(i=T.removeExtraDoubleQuotes(n[0]),a=T.convertListStringToPropList(n.slice(1)));let s={type:e,operationType:"show",alias:t,text:i};return T.setShowProps(s,a)}static getContainerOperationFromComment(e,t,n){let i=[],a=n.findIndex(u=>u.startsWith("[")),s=n.findIndex(u=>u.endsWith("]"));if(a===-1||s===-1){V.error("Show imagecontainer must have a list of image ulrs",n);return}if(i=n.slice(a,s+1),i.length<2){V.error("Show imagecontainer must have a list of image ulrs",n);return}i[0]==="["?i.shift():i[0]=i[0].substring(1),i[i.length-1]==="]"?i.pop():i[i.length-1]=i[i.length-1].substring(0,i[i.length-1].length-1);let o={type:e,operationType:"show",alias:t,urls:i.map(u=>T.removeExtraDoubleQuotes(u))},l=T.convertListStringToPropList(n.slice(s+1));return T.setShowProps(o,l)}static getSoundOperationFromComment(e){let t=T.removeExtraDoubleQuotes(e[0]);if(!Uc.includes(t))return;let n=T.removeExtraDoubleQuotes(e[2]);switch(t){case "play":let i={type:"sound",operationType:"play",alias:n};if(e.length>3){let u=T.getSoundPlayOptions(e.slice(3));u!==void 0&&(i.props=u);}return i;case "pause":case "resume":return {type:"sound",operationType:t,alias:n};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:n};case "volume":let o=parseFloat(e[3]);return {type:"sound",operationType:"volume",alias:n,value:o}}}static setShowProps(e,t){if(t.length>0){if(t.includes("with")&&t.length>t.indexOf("with")+1){let n=t[t.indexOf("with")+1],i=t.slice(t.indexOf("with")+2);t=t.slice(0,t.indexOf("with"));let a=T.getTransition(n,i);a!==void 0&&(e.transition=a);}if(t.length>0){let n=T.convertListStringToObj(t);e.props=n;}}return e}static getTransition(e,t){switch(e){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let n={type:e};if(t.length>0)try{let i=T.convertPropListStringToObj(t);n.props=i;}catch{}return n}static getSoundOption(e){try{return T.convertListStringToObj(e)}catch{return}}static getSoundPlayOptions(e){try{return T.convertListStringToObj(e)}catch{return}}static convertListStringToObj(e){let t=T.convertListStringToPropList(e);return T.convertPropListStringToObj(t)}static convertListStringToPropList(e){let t=[],n=0,i="";for(let a=0;a<e.length;a++){let s=e[a];s.startsWith("{")?(n++,i+=s):s.endsWith("}")&&n>0?(n--,i+=s,n===0&&(t.push(i),i="")):n>0?i+=s:t.push(s);}return t}static convertPropListStringToObj(e){if(e.length===0)return {};if(e.length%2!==0)throw V.error("The props list must have a pair number of elements",e),new Error("The props list must have a pair number of elements");let t="{";e.forEach((n,i)=>{if(i%2===0)t+=`"${n}": `;else {switch(n){case "null":case "undefined":case "true":case "false":t+=`${n}`;break;default:T.containExtraDoubleQuotes(n)?(n=T.removeExtraDoubleQuotes(n),t+=`"${n}"`):n.startsWith("{")&&n.endsWith("}")?t+=`${n}`:n.startsWith('"')&&n.endsWith('"')?t+=`${n}`:isNaN(parseFloat(n))?t+=`"${n}"`:t+=`${n}`;}i<e.length-1&&(t+=", ");}}),t+="}";try{return JSON.parse(t)}catch(n){throw V.error("Error parsing ink json",t),n}}static removeExtraDoubleQuotes(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("`")&&e.endsWith("`")?e.substring(1,e.length-1):e}static containExtraDoubleQuotes(e){return !!(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("`")&&e.endsWith("`"))}};ul(T,"_customHashtagScript",e=>false);var ze=T;function Kc(r){ze.customHashtagScript=r;}var sl=bs(xt());var zn="global decl",Xe="___external_value___";var gh=bs(ph()),mh=bs(xt());function Mn(r,e=[],t=[]){let n=[];try{return {json:new gh.Compiler(r,{errorHandler:(o,l)=>{n.push({message:o,type:l});},countAllVisits:!0,fileHandler:null,pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:e,initialVarsToRemove:t}}catch(i){let a=n.find(s=>s.type===mh.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let s=a.message.match(/Divert target not found: '-> (\w+)'/);if(s&&s[1]){let o=s[1],l=`
46
+ `+g),a=R(S.glueEnabled)||false,g)}),o=R(s[0]),l=typeof o=="object"&&"character"in o?o.character:void 0,u=s.flatMap(S=>{let _;S&&typeof S=="object"&&"text"in S?_=S.text:_=S;let g;return Array.isArray(_)?g=_.map(f=>{let w=R(f);return X.t(`${w}`)}):g=R(_)||"",X.t(g)}),h=i.find(S=>S.end),c=i.find(S=>S.choices),d=false,p=false;i.length>0&&(i[0].glueEnabled&&i[0].goNextStep&&i[0].dialogue===void 0&&storage.storage.setFlag(storage.SYSTEM_RESERVED_STORAGE_KEYS.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,true),d=i[i.length-1].glueEnabled,p=i.reverse().find(S=>!(S.operations&&(!S.dialogue||!S.choices)))?.goNextStep);let C=i.find(S=>S.labelToOpen),y=[];return i.forEach(S=>{S.operations&&y.forEach(_=>{y.push(_);});}),{dialogue:l?{character:l,text:u}:u,end:h?.end,choices:c?.choices,glueEnabled:d,goNextStep:p,labelToOpen:C?.labelToOpen,operations:y}}}function Ns(){I.init({animateOperation:Rc,canvasElementOperation:Vc,effectOperation:kc,imageContainerOperation:Ac,imageOperation:Oc,textOperation:Ic,narrationOperation:Lc,loadAssets:Pc,soundOperation:Dc,tickerOperation:Fc,videoOperation:Nc,setStorageValue:jc,getLogichValue:R,getConditionalStep:Os});}var V;(i=>(i.log=(a,...s)=>console.log(`[Pixi\u2019VN Ink] ${a}`,...s),i.warn=(a,...s)=>console.warn(`[Pixi\u2019VN Ink] ${a}`,...s),i.error=(a,...s)=>console.error(`[Pixi\u2019VN Ink] ${a}`,...s),i.info=(a,...s)=>console.info(`[Pixi\u2019VN Ink] ${a}`,...s)))(V||(V={}));var ml="\xA7SPACE\xA7",Cl="\xA7DOUBLE_QUOTES\xA7",vl="\xA7QUOTES\xA7",yl="SPECIAL_\xA7QUOTES\xA7",Sl="\xA7CURLY_BRACKETS1\xA7",bl="\xA7CURLY_BRACKETS2\xA7",Uc=["add","play","pause","resume","remove","volume"],T=class T{static runCustomHashtagScript(e,t){return T._customHashtagScript(e,t,T.convertListStringToObj)}static set customHashtagScript(e){T._customHashtagScript=e;}static async generateOrRunOperationFromHashtagScript(e,t,n){try{e=e.replaceAll('\\"',Cl),e=e.replaceAll("\\'",vl),e=e.replaceAll("\\`",yl),e=e.replaceAll("\\{",Sl),e=e.replaceAll("\\}",bl),e=e.replaceAll("{"," { "),e=e.replaceAll("}"," } "),e=e.replaceAll(Sl,"{"),e=e.replaceAll(bl,"}");let i=[],a,s="";for(let h=0;h<e.length;h++){let c=e[h];c==='"'||c==="'"||c==="`"?a===void 0?(i.push(s),s="",a=c,s+=c):a===c?(a=void 0,s+=c,i.push(s),s=""):s+=c:s+=c;}s!==""&&i.push(s),i.forEach((h,c)=>{c%2===1&&(i[c]=h.replaceAll(" ",ml));}),e=i.join(""),i=e.split(" ").filter(h=>h!==""),i=i.map(h=>h.replaceAll(ml," ").replaceAll(Cl,'"').replaceAll(vl,"'").replaceAll(yl,"`"));let o=T.runCustomHashtagScript(i,n);if(o===!0)return;if(typeof o=="string")return o.startsWith("#")&&(o=o.substring(1)),T.generateOrRunOperationFromHashtagScript(o,t,n);let l=i.length>1?T.removeExtraDoubleQuotes(i[1]):"",u=i.length>0?T.removeExtraDoubleQuotes(i[0]):"";switch(l){case "image":case "imagecontainer":case "canvaselement":case "video":case "text":return l==="video"&&(u==="pause"||u==="resume")?{type:"video",operationType:u,alias:T.removeExtraDoubleQuotes(i[2])}:T.getCanvasOperationFromComment(i,l);case "sound":return T.getSoundOperationFromComment(i);case "input":if(u==="request"){let h={type:"input",operationType:"request"};if(i.length>2)try{let c=i.slice(2),d=T.convertListStringToObj(c);"type"in d&&typeof d.type=="string"&&(h.valueType=d.type),"default"in d&&(h.defaultValue=d.default);}catch{}return h}break;case "assets":case "bundle":switch(u){case "load":case "lazyload":return {type:l,operationType:u,aliases:i.slice(2)}}break;default:if(l)switch(u){case "call":case "jump":t.labelToOpen={label:l,type:u},t.goNextStep=void 0;return;case "fade":case "move":case "rotate":case "zoom":case "shake":let h={};if(i.length>2)try{h=T.convertListStringToObj(i.slice(2));}catch{}if(u=="move"&&"x"in h&&"y"in h&&(h.destination={x:h.x,y:h.y,type:"pixel"},delete h.x,delete h.y),u=="move"&&"xAlign"in h&&"yAlign"in h&&(h.destination={x:h.xAlign,y:h.yAlign,type:"align"},delete h.xAlign,delete h.yAlign),u=="move"&&"xPercentage"in h&&"yPercentage"in h&&(h.destination={x:h.xPercentage,y:h.yPercentage,type:"percentage"},delete h.xPercentage,delete h.yPercentage),u=="move"&&!("destination"in h)){V.error("The move operation don't have a destination or destination is not valid",h);return}return {alias:l,type:u,props:h};case "animate":let d={},p={};if(i.length>2){let y=i.slice(2),S=[];if(y.includes("options")){let _=y.indexOf("options");S=y.slice(_+1),y=y.slice(0,_);}try{d=T.convertListStringToObj(y);}catch{}if(S.length>0)try{p=T.convertListStringToObj(S);}catch{}}return {alias:l,type:u,keyframes:d,options:p}}else switch(u){case "pause":return "dialogue"in t&&delete t.dialogue,"goNextStep"in t&&delete t.goNextStep,{type:"dialogue",operationType:"clean"};case "continue":t.goNextStep=!0,t.glueEnabled=!1;return}}}catch(i){throw V.error("Error parsing ink hashtag-script",e),i}V.error("The operation is not valid",e);}static getCanvasOperationFromComment(e,t){let n=T.removeExtraDoubleQuotes(e[0]),i=T.removeExtraDoubleQuotes(e[2]),a=T.convertListStringToPropList(e.slice(3));switch(n){case "show":switch(t){case "image":case "video":return T.getImageOperationFromComment(t,i,a);case "imagecontainer":return T.getContainerOperationFromComment(t,i,a);case "text":return T.getTextOperationFromComment(t,i,a);case "canvaselement":default:V.error("This show operation is not valid for this type of element",t);}case "edit":return {type:t,operationType:"edit",alias:i,props:T.convertPropListStringToObj(a)};case "remove":let o={type:t,operationType:"remove",alias:i};if(a.length>1&&a[0]==="with"){let l=e[e.indexOf("with")+1],u=e.slice(e.indexOf("with")+2),h=T.getTransition(l,u);h!==void 0&&(o.transition=h);}return o;default:V.error("The operation type is not valid",n);}}static getImageOperationFromComment(e,t,n){let i,a;n.length%2===0?(i=t,a=n):(i=T.removeExtraDoubleQuotes(n[0]),a=T.convertListStringToPropList(n.slice(1)));let s={type:e,operationType:"show",alias:t,url:i};return T.setShowProps(s,a)}static getTextOperationFromComment(e,t,n){let i,a;n.length%2===0?(i=t,a=n):(i=T.removeExtraDoubleQuotes(n[0]),a=T.convertListStringToPropList(n.slice(1)));let s={type:e,operationType:"show",alias:t,text:i};return T.setShowProps(s,a)}static getContainerOperationFromComment(e,t,n){let i=[],a=n.findIndex(u=>u.startsWith("[")),s=n.findIndex(u=>u.endsWith("]"));if(a===-1||s===-1){V.error("Show imagecontainer must have a list of image ulrs",n);return}if(i=n.slice(a,s+1),i.length<2){V.error("Show imagecontainer must have a list of image ulrs",n);return}i[0]==="["?i.shift():i[0]=i[0].substring(1),i[i.length-1]==="]"?i.pop():i[i.length-1]=i[i.length-1].substring(0,i[i.length-1].length-1);let o={type:e,operationType:"show",alias:t,urls:i.map(u=>T.removeExtraDoubleQuotes(u))},l=T.convertListStringToPropList(n.slice(s+1));return T.setShowProps(o,l)}static getSoundOperationFromComment(e){let t=T.removeExtraDoubleQuotes(e[0]);if(!Uc.includes(t))return;let n=T.removeExtraDoubleQuotes(e[2]);switch(t){case "play":let i={type:"sound",operationType:"play",alias:n};if(e.length>3){let u=T.getSoundPlayOptions(e.slice(3));u!==void 0&&(i.props=u);}return i;case "pause":case "resume":return {type:"sound",operationType:t,alias:n};case "stop":case "remove":return {type:"sound",operationType:"stop",alias:n};case "volume":let o=parseFloat(e[3]);return {type:"sound",operationType:"volume",alias:n,value:o}}}static setShowProps(e,t){if(t.length>0){if(t.includes("with")&&t.length>t.indexOf("with")+1){let n=t[t.indexOf("with")+1],i=t.slice(t.indexOf("with")+2);t=t.slice(0,t.indexOf("with"));let a=T.getTransition(n,i);a!==void 0&&(e.transition=a);}if(t.length>0){let n=T.convertListStringToObj(t);e.props=n;}}return e}static getTransition(e,t){switch(e){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let n={type:e};if(t.length>0)try{let i=T.convertPropListStringToObj(t);n.props=i;}catch{}return n}static getSoundOption(e){try{return T.convertListStringToObj(e)}catch{return}}static getSoundPlayOptions(e){try{return T.convertListStringToObj(e)}catch{return}}static convertListStringToObj(e){let t=T.convertListStringToPropList(e);return T.convertPropListStringToObj(t)}static convertListStringToPropList(e){let t=[],n=0,i="";for(let a=0;a<e.length;a++){let s=e[a];s.startsWith("{")?(n++,i+=s):s.endsWith("}")&&n>0?(n--,i+=s,n===0&&(t.push(i),i="")):n>0?i+=s:t.push(s);}return t}static convertPropListStringToObj(e){if(e.length===0)return {};if(e.length%2!==0)throw V.error("The props list must have a pair number of elements",e),new Error("The props list must have a pair number of elements");let t="{";e.forEach((n,i)=>{if(i%2===0)t+=`"${n}": `;else {switch(n){case "null":case "undefined":case "true":case "false":t+=`${n}`;break;default:T.containExtraDoubleQuotes(n)?(n=T.removeExtraDoubleQuotes(n),t+=`"${n}"`):n.startsWith("{")&&n.endsWith("}")?t+=`${n}`:n.startsWith('"')&&n.endsWith('"')?t+=`${n}`:isNaN(parseFloat(n))?t+=`"${n}"`:t+=`${n}`;}i<e.length-1&&(t+=", ");}}),t+="}";try{return JSON.parse(t)}catch(n){throw V.error("Error parsing ink json",t),n}}static removeExtraDoubleQuotes(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("`")&&e.endsWith("`")?e.substring(1,e.length-1):e}static containExtraDoubleQuotes(e){return !!(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")||e.startsWith("`")&&e.endsWith("`"))}};ul(T,"_customHashtagScript",e=>false);var ze=T;function Kc(r){ze.customHashtagScript=r;}var sl=bs(xt());var zn="global decl",Xe="___external_value___";var gh=bs(ph()),mh=bs(xt());function Mn(r,e=[],t=[]){let n=[];try{return {json:new gh.Compiler(r,{errorHandler:(o,l)=>{n.push({message:o,type:l});},countAllVisits:!0,fileHandler:{ResolveInkFilename:o=>o,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:n,labelToRemove:e,initialVarsToRemove:t}}catch(i){let a=n.find(s=>s.type===mh.ErrorType.Error);if(a){if(a.message.includes("Divert target not found")){let s=a.message.match(/Divert target not found: '-> (\w+)'/);if(s&&s[1]){let o=s[1],l=`
47
47
 
48
48
  === ${o} ===
49
49
 
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export{c as convertInkStoryToJson,b as convertInkText,b as convertInkToJson,i as generateJsonInkTranslation,d as importInkText,e as importJson,a as onInkHashtagScript,h as onInkTranslate,f as onReplaceTextAfterTranslation,g as onReplaceTextBeforeTranslation}from'./chunk-KEE2M64A.mjs';import'./chunk-NG6ODEEE.mjs';
1
+ export{c as convertInkStoryToJson,b as convertInkText,b as convertInkToJson,i as generateJsonInkTranslation,d as importInkText,e as importJson,a as onInkHashtagScript,h as onInkTranslate,f as onReplaceTextAfterTranslation,g as onReplaceTextBeforeTranslation}from'./chunk-46QHQPLY.mjs';import'./chunk-GMXDYDC6.mjs';