@drincs/pixi-vn-ink 1.1.0 → 1.1.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.
package/dist/mapper.mjs CHANGED
@@ -13,4 +13,4 @@ import {ZodType}from'zod';import {PIXIVNJSON_SCHEMA_URL,PixiVNJsonComparationOpe
13
13
  `+n+F+`,
14
14
  `+T+"]";}return a.pop(),n=T,b}},eu={parse:qe,stringify:Ke},uu=eu,de=uu;var Oe="\xA7SPACE\xA7",Ne="\xA7DOUBLE_QUOTES\xA7",we="\xA7QUOTES\xA7",Re="SPECIAL_\xA7QUOTES\xA7",ke="\xA7CURLY_BRACKETS1\xA7",tu="\xA7INK_VAR\xA7",Je="\xA7CURLY_BRACKETS2\xA7",ee;(b=>{let e=[],u=[];async function i(t,F){for(let l=0;l<e.length;l++)try{let{validation:g}=e[l].opts;if(g instanceof RegExp){if(!g.test(t.join(" ")))continue}else if(g instanceof ZodType&&!g.safeParse(t).success)continue;let E=await e[l].fn(t,F,f);if(E===!0||typeof E=="string")return E}catch{}return false}function r(t,F={name:"custom-command",validation:/^/}){e.unshift({fn:t,opts:F});}b.add=r;function a(){return [...u.map(t=>t.opts),...e.map(t=>t.opts)]}b.info=a;function n(t,F){u.unshift({fn:t,opts:F});}b.addMapper=n;function o(){e.length=0;}b.clear=o;function c(){u.length=0;}b.clearMappers=c;async function C(t,F,l){try{let g=s(t),E=await i(g,l);return E===!0?void 0:typeof E=="string"?(E.startsWith("#")&&(E=E.substring(1)),await b.run(E,F,l)):D(g,F)}catch(g){throw P.error("Error parsing ink hashtag-command",t),g}}b.run=C;function s(t,F){if(t=t.replaceAll('\\"',Ne),t=t.replaceAll("\\'",we),t=t.replaceAll("\\`",Re),t=t.replaceAll("\\{",ke),t=t.replaceAll("\\}",Je),F?.mergeInkVariables){let x;do x=t,t=t.replace(/\{[^{}:]*\}/g,tu);while(t!==x)}t=t.replaceAll("{"," { "),t=t.replaceAll("}"," } "),t=t.replaceAll(ke,"{"),t=t.replaceAll(Je,"}");let l=[],g,E="";for(let x=0;x<t.length;x++){let R=t[x];R==='"'||R==="'"||R==="`"?g===void 0?(l.push(E),E="",g=R,E+=R):g===R?(g=void 0,E+=R,l.push(E),E=""):E+=R:E+=R;}return E!==""&&l.push(E),l.forEach((x,R)=>{R%2===1&&(l[R]=x.replaceAll(" ",Oe));}),t=l.join(""),l=t.split(" ").filter(x=>x!==""),l=l.map(x=>x.replaceAll(Oe," ").replaceAll(Ne,'"').replaceAll(we,"'").replaceAll(Re,"`")),l=A(l),l=l.map(x=>x.startsWith('"')&&x.endsWith('"')||x.startsWith("'")&&x.endsWith("'")||x.startsWith("`")&&x.endsWith("`")?x.slice(1,-1):x),l}b.convertTagTolist=s;function D(t,F,l){for(let g of u){let{validation:E}=g.opts,x=false;if(E instanceof RegExp?x=E.test(t.join(" ")):E instanceof ZodType&&(x=E.safeParse(t).success),x)return g.fn(t,F)}l?.silent||P.error("The operation is not valid",t);}b.convertOperation=D;function f(t){return d(t)}b.convertListStringToObj=f;function d(t){if(t.length===0)return {};if(t.length%2!==0)throw P.error("The props list must have a pair number of elements",t),new Error("The props list must have a pair number of elements");let F="{";t.forEach((l,g)=>{if(g%2===0)F+=`"${l}": `;else {switch(l){case "null":case "undefined":case "true":case "false":F+=`${l}`;break;default:y(l)?(l=h(l),F+=`"${l}"`):l.startsWith("{")&&l.endsWith("}")?F+=`${l}`:l.startsWith('"')&&l.endsWith('"')?F+=`${l}`:Number.isNaN(parseFloat(l))?F+=`"${l}"`:F+=`${l}`;}g<t.length-1&&(F+=", ");}}),F+="}";try{return de.parse(F)}catch(l){throw P.error("Error parsing ink json",F),l}}function h(t){return t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")||t.startsWith("`")&&t.endsWith("`")?t.substring(1,t.length-1):t}function y(t){return !!(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")||t.startsWith("`")&&t.endsWith("`"))}function A(t){return T(t).tokens}b.mergeJsonBlocks=A;function T(t){let F=[],l=false;for(let g=0;g<t.length;g++){let E=t[g];if(E!=="{"){F.push(E);continue}let x=m(t,g);if(x===-1){F.push(E);continue}let R=T(t.slice(g+1,x)),Te=["{",...R.tokens,"}"],ve=Te.join(" ");if(!R.hasInvalidMatchedBlock)try{de.parse(ve),F.push(ve),g=x;continue}catch{}l=true,F.push(...Te),g=x;}return {tokens:F,hasInvalidMatchedBlock:l}}function m(t,F){let l=0;for(let g=F;g<t.length;g++)if(t[g]==="{")l++;else if(t[g]==="}"&&(l--,l===0))return g;return -1}})(ee||={});var Me=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],Le=["+","-","/","*","%","POW","RANDOM","L^"],_e=["INT","FLOOR","FLOAT"];function Y(e,u){if(e.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(e)&&(e=e.split(".").filter(a=>!a.match(/^[0-9]+$/)).join("."),!e.startsWith(".")))return e.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(e)&&e.includes("g-")){let r=e.split("g-");return Ce(u)+"_|_"+"g-"+r[r.length-1]}let i=0;for(;new RegExp(/^\.\^.*$/).test(e);)i++,e=e.substring(2);if(i=i-1,new RegExp(/^\..*$/).test(e)&&u){let r=e.substring(1);return Ce(u,i)+"_|_"+r.replaceAll(".","_|_")}return e.replaceAll(".","_|_")||Ce(u,i).replaceAll(".","_|_")}function Ce(e,u=0){let i=e.split("_|_");for(;i.length>1&&u>0;)i.pop()?.includes("g-")&&u--,u--;return i.join("_|_")}var je="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function L(e){return e.startsWith("^")&&(e=e.substring(1)),e=e.replaceAll("\\\\",je),e=e.replaceAll("\\n",`
15
15
  `),e=e.replaceAll("\\t"," "),e=e.replaceAll(" "," "),e=e.replaceAll(je,"\\\\"),e}function W(e,u,i,r){let{functions:a}=r;e=e.map(o=>{if(typeof o=="string")switch(o){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return o});let n=[];return e.forEach(o=>{if(typeof o=="string")switch(o){case "&&":case "||":if(n.length>=2){let c={type:"union",unionType:o==="&&"?"and":"or",conditions:[n[n.length-2],n[n.length-1]]};n.pop(),n.pop(),n.push(c);}break;case "!":if(n.length===0)P.error("Error parsing ink file: Conditional statement is not valid",e);else {let c={type:"union",unionType:"not",condition:n[n.length-1]};n[n.length-1]=c;}break;case "!?":if(n.length>1){let c={type:"union",unionType:"not",condition:{type:"compare",operator:"CONTAINS",leftValue:n[n.length-2],rightValue:n[n.length-1]}};n.pop(),n.pop(),n.push(c);}else P.error("Error parsing ink file: Conditional statement is not valid",e);break;default:if(PixiVNJsonComparationOperators.includes(o))if(n.length<2)P.error("Error parsing ink file: Conditional statement is not valid",e);else {let c={type:"compare",operator:o,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(c);}else if(Le.includes(o))if(n.length<2)P.error("Error parsing ink file: Conditional statement is not valid",e);else {o==="L^"&&(o="INTERSECTION");let c={type:"arithmetic",operator:o,rightValue:n[n.length-1],leftValue:n[n.length-2]};n.pop(),n.pop(),n.push(c);}else if(_e.includes(o)){let c={type:"arithmeticsingle",operator:o,leftValue:n[n.length-1]};n.pop(),n.push(c);}else o.startsWith("^")&&n.push(L(o));}else if(typeof o=="object"&&"CNT?"in o)if(new RegExp(/.*\.[0-9]\..*/).test(o["CNT?"])){let c=o["CNT?"].split("."),C=c.pop(),s=c.pop();if(s===void 0||C===void 0){P.error("Error parsing ink file: Conditional statement is not valid",e);return}let D=Number(s),f=c.join(".");if(f.includes("^.")){let h=f.split("."),y=h[h.length-1].replaceAll(".","_|_");h.pop(),f=`${h.join(".")}.${y}`,C.includes("c-")&&(f=f+"_|_"+C);}else f=f.replaceAll(".","_|_");let d=Y(f,u);if(!d)return;n.push({type:"compare",leftValue:Ae(d),operator:">=",rightValue:{type:"value",value:D}});}else {let c=Y(o["CNT?"],u);if(!c)return;n.push(Ae(c));}else if(typeof o=="object"&&"VAR?"in o)n.push(G({key:o["VAR?"],defaultType:"storage"},i));else if(typeof o=="object"&&"f()"in o){let c=o["f()"],C=a.find(D=>D.name===c);if(!C){P.error(`Error parsing ink file: Function ${c} is not defined`,e);return}let s=[];for(let D=0;D<C.args;D++)n.length!==0&&s.push(n.pop());n.push({type:"function",functionName:c,args:s.reverse()});}else if(typeof o=="object"&&"^->"in o)o["^->"].includes("$r")||n.push(o["^->"]);else if(typeof o=="object"&&"list"in o){let c=Object.values(o.list).map(C=>C);n.push(c);}else n.push(o);}),n}function ge(e,u,i,r){return W(e,u,i,r)}function G(e,u,i){let{key:r,defaultType:a}=e,n=u.indexOf(r);return n>=0?{type:"value",storageType:"params",storageOperationType:"get",key:n}:{type:"value",storageOperationType:"get",storageType:a,key:r}}function ue(e,u,i){let{key:r,value:a,defaultType:n,artmeticValue:o}=e,c=u.indexOf(r);if(c>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:c,value:a}];if(o){if(typeof a=="object"&&"list"in a){let C=Object.values(a.list).map(s=>s);return [{type:"value",storageOperationType:"set",storageType:n,key:r,value:C}]}return [{type:"value",storageOperationType:"set",storageType:n,key:r,value:a}]}else if(typeof a=="object"){if("list"in a&&typeof a.list=="object"){if("origins"in a&&Array.isArray(a.origins)&&a.origins.length>0)return a.origins.reduce(C=>(C.push({type:"value",storageOperationType:"set",storageType:n,key:r,value:Object.values(i.enums[r])}),Object.entries(i.enums[r]).forEach(([s,D])=>{C.push({type:"value",storageOperationType:"set",storageType:n,key:`${r}.${s}`,value:D});}),C),[]);{let C=new Set,s=Object.entries(a.list).reduce((D,[f,d])=>{let[h,y]=f.split(".");return D.push({type:"value",storageOperationType:"set",storageType:n,key:y,value:d}),C.add(h),D},[]);return C.forEach(D=>{s.push({type:"value",storageOperationType:"set",storageType:n,key:D,value:Object.values(i.enums[D])});}),r in i.enums?Object.entries(i.enums[r]).forEach(([D,f])=>{s.push({type:"value",storageOperationType:"set",storageType:n,key:`${r}.${D}`,value:f});}):s.push({type:"value",storageOperationType:"set",storageType:n,key:r,value:Object.values(a.list)}),s}}else if(typeof a=="object"&&"VAR?"in a){if(typeof a["VAR?"]=="string"&&a["VAR?"].includes(".")){let[C,s]=a["VAR?"].split(".");if(C in i.enums&&s in i.enums[C])return [{type:"value",storageOperationType:"set",storageType:n,key:r,value:i.enums[C][s]}]}return [{type:"value",storageOperationType:"set",storageType:n,key:r,value:G({key:a["VAR?"],defaultType:"storage"},u)}]}}return [{type:"value",storageOperationType:"set",storageType:n,key:r,value:a}]}function Ae(e){return {type:"value",storageType:"label",storageOperationType:"get",label:e}}function Fe(e,u){return u||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(e)?"call":"jump"}function se(e,u){if(u){if(typeof u=="string")u.startsWith("^")&&e.push(L(u));else if(typeof u=="object"&&"type"in u)switch(u.type){case "value":case "function":console.warn("Warning: trying to add a value or function operation as text. This is likely a mistake, so it will be ignored.");break;default:e.push(u);}}}function he(e,u,i,r,a,n={}){let{isNewLine:o=true,isHashtagScript:c=false,isThreads:C=false}=n;return ru(e,u,i,r,a,{isNewLine:o,isHashtagScript:c,isThreads:C})}function ru(e,u,i,r,a,n){if(!u)return;let{isNewLine:o,isHashtagScript:c=false,isThreads:C}=n;if(c){if(Array.isArray(u)&&u.length>0){let s={goNextStep:true},D=[];try{if(u.length===1&&typeof u[0]=="string"&&!u[0].match(xe)){let f=u[0],d=ee.convertTagTolist(f),h=ee.convertOperation(d,s,{silent:!0});h&&(h.$origin=f,D.push(h));}}catch{}D.length===0&&D.push({type:"operationtoconvert",values:u}),e.push({...s,operations:D});}}else if(typeof u=="string"&&u.startsWith("^")||u&&typeof u=="object"&&"type"in u&&u.type==="value"&&u.storageOperationType==="get"){if(!o&&e.length>0){let s=e[e.length-1];!s.glueEnabled&&!s.operations&&!s.labelToOpen&&(s.glueEnabled=true,s.labelToOpen||(s.goNextStep=true)),e[e.length-1]=s;}typeof u=="string"?e.push(su(L(u),r.characterIds)):e.push({dialogue:u});}else if(typeof u=="string"){if(u==="end")e.push({end:"game_end"});else if(u==="done")e.push({end:"label_end",goNextStep:true});else if(u==="<>")if(e.length>0){let s=e[e.length-1];s.glueEnabled=true,s.labelToOpen||(s.goNextStep=true),e[e.length-1]=s;}else e.push({glueEnabled:true,goNextStep:false});}else if(typeof u=="object"){if("type"in u)switch(u.type){case "value":u.storageOperationType==="set"?(typeof u.value=="string"&&u.value.startsWith("^")&&(u.value=L(u.value)),e.push({goNextStep:true,operations:[u]})):console.warn("Warning: trying to add a value get operation as step. This is likely a mistake, so it will be ignored.");break;case "function":e.push({goNextStep:true,operations:[u]});break;default:if(!o&&e.length>0){let s=e[e.length-1];!s.glueEnabled&&!s.operations&&(s.glueEnabled=true,s.labelToOpen||(s.goNextStep=true)),e[e.length-1]=s;}e.push({conditionalStep:u});}else if("->"in u){let s=o?void 0:true;if(s&&i.includes("c-")&&e.length>0&&e[e.length-1]?.dialogue===void 0&&(s=void 0),!o&&e.length>0){let D=e[e.length-1];D.labelToOpen||(D.goNextStep=true),e[e.length-1]=D;}if(u.params&&u.params.length===0&&delete u.params,u.var)e.push({labelToOpen:{label:G({key:u["->"],defaultType:"storage"},a),type:C?"call":"jump",params:u.params},glueEnabled:s});else {let D=Y(u["->"],i);if(!D)return;e.push({labelToOpen:{label:D,type:Fe(D,C),params:u.params},glueEnabled:s});}}else if("->t->"in u){let s=o?void 0:true;if(s&&i.includes("c-")&&e.length>0&&e[e.length-1]?.dialogue===void 0&&(s=void 0),!o&&e.length>0){let f=e[e.length-1];f.labelToOpen||(f.goNextStep=true),e[e.length-1]=f;}u.params&&u.params.length===0&&delete u.params;let D=Y(u["->t->"],i);if(!D)return;e.push({labelToOpen:{label:D,type:"call",params:u.params},glueEnabled:s});}}}function su(e,u){let i;if(e.includes(": ")){let r=e.split(": "),a=r[0],n=r.slice(1).join(": ");(u?.has(a)||RegisteredCharacters.has(a))&&(i=a,e=n);}return i?{dialogue:{character:i,text:e}}:{dialogue:e}}function Ee(e,u,i,r=true,a=false){return ou(e,u,i,r,a)}function ou(e,u,i,r,a=false){u&&(typeof u=="string"&&u.startsWith("^")||u&&typeof u=="object"&&"type"in u&&u.type==="value"&&u.storageOperationType==="get"?typeof u=="string"?e.push(L(u)):e.push(u):typeof u=="object"&&"type"in u&&e.push(u));}function oe(e,u,i,r){if(e.length===0){P.error("Error parsing ink file: Arithmetic statement is not valid",e);return}let a=W(e,u,i,r);if(a.length===1){let n=a[0];return n&&typeof n=="object"&&"type"in n?{type:"value",storageType:"logic",storageOperationType:"get",operation:n}:n}}function Q(e,u,i,r="",a,n,o=void 0){let c=[],C="sequential",s=false,D=true;e.forEach(h=>{h==="%"&&(C="loop"),h==="seq"&&(C="random"),h==="MIN"&&(s=true);});let f=e[e.length-1];return Object.keys(f).forEach(h=>{let y=f[h];if(Array.isArray(y)&&y.length>3){y=y.slice(1,y.length-2);let A=[];$(y,r,a,A,u,u,i,X,o,true,n),A.length===1?c.push(A[0]):c.push({type:"resulttocombine",combine:"cross",secondConditionalItem:A});}else Array.isArray(y)&&y.length===3&&(D=false);}),C==="sequential"?{type:"stepswitch",elements:c,choiceType:C,end:D?"lastItem":void 0,nestedId:o}:s&&C==="random"?{type:"stepswitch",elements:c,choiceType:"sequentialrandom",end:D?"lastItem":void 0,nestedId:o}:{type:"stepswitch",elements:c,choiceType:C}}function $(e,u,i,r=[],a,n,o,c,C=void 0,s=true,D=[]){let f=false,d=[],h=false,y=false,A=false,T=[],m=[];if(i.preDialog[u]&&(s=false,a(r,`^${i.preDialog[u].text}`,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),i.preDialog[u].glue&&a(r,"<>",u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),delete i.preDialog[u]),e.includes("visit")){let t=Q(e,n,o,u,i,D,C);t&&(!s&&r.length>0&&a(r,"<>",u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}));return}let b=e[0];if(b&&typeof b=="object"&&"temp="in b){for(;e[0]&&typeof e[0]=="object"&&"temp="in e[0];)D.push(e[0]["temp="]),e.shift();D=D.reverse();}if(e.forEach((t,F)=>{if(y){if(typeof t=="string"&&t==="/#"){let l=[];$(m,u,i,l,Ee,Ee,o,c,C,s),a(r,l,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),y=false,m=[];}else m.push(t);return}else if(f)if(Array.isArray(t))d.push(t);else if(t&&typeof t=="object")"CNT?"in t?F>0&&e[F-1]==="ev"?(h=true,T.push(t)):h?T.push(t):(d.push(t),s=false):"VAR="in t||"temp="in t?ue({key:"VAR="in t?t["VAR="]:t["temp="],value:e[F-1],defaultType:"VAR="in t?"storage":"tempstorage"},D,i).forEach(g=>{if(g.value&&typeof g.value=="string"&&g.value==="/str"&&(g.value=e[F-2]),g.value&&typeof g.value=="object"&&"^->"in g.value&&(g.value=g.value["^->"]),d.length>1){let E=oe(d,u,D,i);d=[],E&&typeof E=="object"&&"type"in E&&E.type==="value"&&"storageType"in E&&E.storageType==="logic"&&(g.value=E.operation);}(typeof g.key!="string"||!g.key.includes("$r"))&&(a(r,g,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=true);}):"VAR?"in t?d.push(t):"^->"in t?t["^->"].includes("$r")||d.push(t):("f()"in t||"list"in t&&typeof t.list=="object")&&d.push(t);else switch(t){case "/ev":h&&T.push(t),f=false,d.push(t);break;case "out":if(d.length>0){let l=d[d.length-1];if(l&&typeof l=="object"&&"VAR?"in l){d.pop();let g=G({key:l["VAR?"],defaultType:"storage"},D);a(r,g,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A});}else {let g=[];for(;d.length>0&&d[d.length-1]!=="/ev";)g.push(d.pop());g=g.reverse();let E=oe(g,u,D,i);d=[],E&&typeof E=="object"&&"type"in E&&E.type==="value"&&"storageType"in E&&E.storageType==="logic"?a(r,{storageOperationType:"get",storageType:"logic",operation:E.operation,type:"value"},u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}):(a(r,"<>",u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),E=`^${E}`,a(r,E,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}));}s=false;}break;case "pop":{let l=d[d.length-1];if(l&&typeof l=="object"&&"f()"in l){let g=[];for(;d.length>0&&d[d.length-1]!=="/ev";)g.push(d.pop());g=g.reverse();let E=W(g,u,D,i);d=[],E.forEach(x=>{x&&typeof x=="object"&&"type"in x&&x.type==="function"?a(r,x,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}):P.warn("Unhandled case: value is not a function",x);}),s=false;}else d.push(t);return}default:d.push(t);}else if(typeof t=="string")if(t.startsWith("^"))a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;else if(t==="ev")f=true;else if(t===`
16
- `)s=true;else if(t==="done"||t==="end")a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;else if(t==="<>")a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;else if(t==="nop"&&h){let l=Ie(T,n,o,u,i,D,C);l&&a(r,l,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),h=false,T=[];}else t==="#"?y=true:t==="thread"&&(A=true);else if(Array.isArray(t))if(h)T.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){d.pop();let l=[],g=[];for(;d.length>0&&d[d.length-1]!=="/ev";)l.push(d.pop());T=[...T,...l.reverse()],h=true,g.push(t.pop()),g.push(t.pop()),T=[...T,...t],T.push(g);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let l=t.pop();if(!l){P.error("Error parsing ink file: el is undefined");return}let g=l["#n"];delete l["#n"],t.push(l),a(r,{"->":u?u+"_|_"+g:g},u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),o({[g]:t},u,i);}else $(t,u,i,r,a,n,o,c,C,s,D);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let l=[];d.length>0&&(l=ge(["ev",...d],u,D,i)),t.params=l,a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;}else if("->t->"in t&&typeof t["->t->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->t->"])){let l=[];d.length>0&&(l=ge(["ev",...d],u,D,i)),t.params=l,a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(d.push(t),s=false);else if("s"in t&&Array.isArray(t.s))d.push(t),s=false;else if("CNT?"in t)d.push(t),s=false;else if("VAR="in t||"temp="in t){let l="VAR="in t?t["VAR="]:t["temp="],g,E=[];if(l!=="$r"){for(d.pop(),d[d.length-1]==="/ev"&&d.pop();d.length>0&&d[d.length-1]!=="/ev";)E.push(d.pop());E=E.reverse(),g=oe(E,u,D,i),d=[],ue({key:l,value:g,defaultType:"VAR="in t?"storage":"tempstorage",artmeticValue:true},D,i).forEach(R=>{(R.value!==void 0||R.value!==null)&&a(r,R,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A});}),s=false;}}else o(t,u,i);}),c(d,r,u,i,D),u.includes("_|_")&&r.length===2){let t=r[0],F=r[1];t&&F&&typeof t=="object"&&"dialogue"in t&&typeof F=="object"&&"labelToOpen"in F&&t.dialogue===" "&&F.labelToOpen&&(r.shift(),delete F.glueEnabled,r[0]=F);}}function me(e,u,i,r,a,n){if(u.length===0)return;let o=W(u,r,i,a);if(o.length===1){let c={type:"ifelse",condition:o[0],then:e,else:n};return c.else||delete c.else,c}else if(o.length>1){let c={type:"ifelse",condition:{type:"union",unionType:"and",conditions:o},then:e,else:n};return c.else||delete c.else,c}}function Ie(e,u,i,r,a,n,o=void 0){if(e.length===0){P.error("Error parsing ink file: Conditional statement is not valid",e);return}let c=[],C=[];if(e.forEach(f=>{Array.isArray(f)?C.push(f):typeof f=="string"&&f==="du"?a.du?c.push(a.du):a.du=c[c.length-1]:(typeof f!="string"||f!=="/ev")&&c.push(f);}),C.length===0){P.error("Error parsing ink file: Conditional statement is not valid",C);return}let s=ye(C[0],u,i,`${r}${"_|_"}then`,a,n,`${o||""}then`),D;return C.length===2?D=ye(C[1],u,i,`${r}${"_|_"}else`,a,n,`${o||""}else`):C.length>2?(C.shift(),C.push("nop"),C=[{b:C}],D=ye(C,u,i,`${r}${"_|_"}else`,a,n,`${o||""}else`)):D=void 0,a.du=void 0,me(s,c,n,r,a,D)}function ye(e,u,i,r,a,n,o=void 0){let c=[];for(let s of e)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(D=>D!==null&&!(typeof D=="object"&&"->"in D&&new RegExp(/.*\.[0-9]/).test(D["->"]))),$(s.b,r,a,c,u,u,i,X,o,true,n));return c.length===1?c[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:c}}function Be(e="",u=""){let i=Array.isArray(e)?e:[e],r=Array.isArray(u)?u:[u];return [...new Set([...i,...r])]}function X(e,u,i,r,a){if(e.length>0){let n={};He(e,n,a,r);for(let[o,c]of Object.entries(n)){let C=i+"_|_"+o,s={text:c.text.length===1?c.text[0]:c.text,label:C,props:{},type:Fe(C,false),oneTime:c.onetime};c.text.length===0&&(s.onlyHaveNoChoice=true,s.autoSelect=true),s.oneTime===false&&delete s.oneTime;let D=me(s,c.conditions,a,i,r)||s,f=u[u.length-1];if(typeof f=="object"&&f&&"type"in f&&(f={conditionalStep:f}),u.length>0&&typeof f=="object"&&f&&"choices"in f&&f.choices){let d=f.choices;d&&Array.isArray(d)?d.push(D):P.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",c,d),f.choices=d.sort((h,y)=>{try{let A=h.label.split("."),T=A[A.length-1].replaceAll(".","_|_"),m=y.label.split("."),b=m[m.length-1].replaceAll(".","_|_");if(T.includes("c-")&&b.includes("c-")){let t=T.split("c-")[1],F=Number(t),l=b.split("c-")[1],g=Number(l);return F-g}}catch{}return 0});}else u.push({choices:[D]});c.preDialog&&(r.preDialog[C]={...c.preDialog});}}}function He(e,u,i,r,a){let n=[],o="",c="",C=false,s=[];for(let D=0;D<e.length;D++){let f=e[D];if(typeof f=="string")f.startsWith("^")?n.push(L(f)):Me.includes(f)&&s.push(f);else if(Array.isArray(f)&&f.includes("visit")){let d=Q(f,se,(h,y,A)=>{},a,r,i);n.push(d);}else if(f&&typeof f=="object")if("*"in f&&typeof f["*"]&&typeof f["*"]=="string")f["*"].includes("c")&&(o=`c${f["*"].split("c")[1]}`,f.flg&16&&(C=true));else if("s"in f&&Array.isArray(f.s)){let d=We(f.s),h=f.s.includes("<>");d&&(a&&u[a]?(u[a].preDialog={text:d,glue:h},u[a].text=Be(d,u[a].text)):(n.push(d),c=d));}else ("CNT?"in f||"VAR?"in f)&&s.push(f);else s.push(f);if(o){u[o]?u[o].text=Be(n,u[o].text):u[o]={text:n,onetime:C,conditions:s},c&&(u[o].preDialog={text:c,glue:false});let d=e.slice(D+1);He(d,u,i,r,o);return}}}function We(e){for(let u of e)if(typeof u=="string"){if(u.startsWith("^"))return L(u)}else if(Array.isArray(u)){let i=We(u);if(i)return i}}var pu;(a=>{function e(n,o={}){let{labelToRemove:c=[],initialVarsToRemove:C=[],enums:s={},functions:D=[],preDialog:f={},characterIds:d}=o,h={$schema:PIXIVNJSON_SCHEMA_URL};if(h.labels=u(n.root,{labelToRemove:c,initialVarsToRemove:C,enums:s,functions:D,preDialog:f,characterIds:d}),h.labels&&te in h.labels){let y=h.labels[te];delete h.labels[te],y.forEach(A=>{A.operations&&(h.initialOperations=h.initialOperations?[...h.initialOperations,...A.operations]:[...A.operations]);});}if(h.labels&&z in h.labels){let y=h.labels[z];delete h.labels[z],y.forEach(A=>{A.operations&&(h.initialOperations=h.initialOperations?[...h.initialOperations,...A.operations]:[...A.operations]);});}return c.forEach(y=>{h.labels&&y in h.labels&&delete h.labels[y];}),C.forEach(y=>{h.initialOperations&&(h.initialOperations=h.initialOperations.filter(A=>!(A.type==="value"&&A.key===y)));}),h}a.inkToJson=e;function u(n,o){try{let c={};return i(n,c,o),c}catch(c){P.error("Error parsing ink file",c);}}function i(n,o,c){for(let C of n)if(C)if(Array.isArray(C))if(C.includes("visit")){let s=Q(C,se,(D,f,d)=>{},"",c,[]);s&&(c.externalSwitch=s);}else i(C,o,c);else typeof C=="object"&&(C&&"VAR="in C&&c.externalSwitch&&(o[z]||(o[z]=[]),o[z].push({operations:ue({defaultType:"storage",key:C["VAR="],value:c.externalSwitch},[],c)})),r(C,o,"",c));}function r(n,o,c="",C){if(n!==null){for(let[s,D]of Object.entries(n))if(Array.isArray(D)){let f=[],d={},h=(c?c+"_|_":"")+s;$(D,h,C,f,he,he,(y,A,T)=>{r(y,d,A,T);},X);for(let[y,A]of Object.entries(d))o[y]=A;f.length>0&&(o[h]=f);}}}})(pu||={});export{pu as InkMapper};
16
+ `)s=true;else if(t==="done"||t==="end")a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;else if(t==="<>")a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;else if(t==="nop"&&h){let l=Ie(T,n,o,u,i,D,C);l&&a(r,l,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),h=false,T=[];}else t==="#"?y=true:t==="thread"&&(A=true);else if(Array.isArray(t))if(h)T.push(t);else if(t.length>1&&typeof t[t.length-2]=="object"&&t[t.length-2]&&"c"in t[t.length-2]&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"b"in t[t.length-1]){d.pop();let l=[],g=[];for(;d.length>0&&d[d.length-1]!=="/ev";)l.push(d.pop());T=[...T,...l.reverse()],h=true,g.push(t.pop()),g.push(t.pop()),T=[...T,...t],T.push(g);}else if(t.length>1&&typeof t[t.length-1]=="object"&&t[t.length-1]&&"#n"in t[t.length-1]){let l=t.pop();if(!l){P.error("Error parsing ink file: el is undefined");return}let g=l["#n"];delete l["#n"],t.push(l),a(r,{"->":u?u+"_|_"+g:g},u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),o({[g]:t},u,i);}else $(t,u,i,r,a,n,o,c,C,s,D);else if(t&&typeof t=="object")if("->"in t&&typeof t["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->"])){let l=[];d.length>0&&(l=ge(["ev",...d],u,D,i)),t.params=l,a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;}else if("->t->"in t&&typeof t["->t->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(t["->t->"])){let l=[];d.length>0&&(l=ge(["ev",...d],u,D,i)),t.params=l,a(r,t,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A}),s=false;}else if("*"in t&&typeof t["*"]=="string")t["*"].includes("c")&&(d.push(t),s=false);else if("s"in t&&Array.isArray(t.s))d.push(t),s=false;else if("CNT?"in t)d.push(t),s=false;else if("VAR="in t||"temp="in t){let l="VAR="in t?t["VAR="]:t["temp="],g,E=[];if(l!=="$r"){for(d.pop(),d[d.length-1]==="/ev"&&d.pop();d.length>0&&d[d.length-1]!=="/ev";)E.push(d.pop());E=E.reverse(),g=oe(E,u,D,i),d=[],ue({key:l,value:g,defaultType:"VAR="in t?"storage":"tempstorage",artmeticValue:true},D,i).forEach(R=>{(R.value!==void 0||R.value!==null)&&a(r,R,u,i,D,{isNewLine:s,isHashtagScript:y,isThreads:A});}),s=false;}}else o(t,u,i);}),c(d,r,u,i,D),u.includes("_|_")&&r.length===2){let t=r[0],F=r[1];t&&F&&typeof t=="object"&&"dialogue"in t&&typeof F=="object"&&"labelToOpen"in F&&t.dialogue===" "&&F.labelToOpen&&(r.shift(),delete F.glueEnabled,r[0]=F);}}function me(e,u,i,r,a,n){if(u.length===0)return;let o=W(u,r,i,a);if(o.length===1){let c={type:"ifelse",condition:o[0],then:e,else:n};return c.else||delete c.else,c}else if(o.length>1){let c={type:"ifelse",condition:{type:"union",unionType:"and",conditions:o},then:e,else:n};return c.else||delete c.else,c}}function Ie(e,u,i,r,a,n,o=void 0){if(e.length===0){P.error("Error parsing ink file: Conditional statement is not valid",e);return}let c=[],C=[];if(e.forEach(f=>{Array.isArray(f)?C.push(f):typeof f=="string"&&f==="du"?a.du?c.push(a.du):a.du=c[c.length-1]:(typeof f!="string"||f!=="/ev")&&c.push(f);}),C.length===0){P.error("Error parsing ink file: Conditional statement is not valid",C);return}let s=ye(C[0],u,i,`${r}${"_|_"}then`,a,n,`${o||""}then`),D;return C.length===2?D=ye(C[1],u,i,`${r}${"_|_"}else`,a,n,`${o||""}else`):C.length>2?(C.shift(),C.push("nop"),C=[{b:C}],D=ye(C,u,i,r,a,n,`${o||""}else`)):D=void 0,a.du=void 0,me(s,c,n,r,a,D)}function ye(e,u,i,r,a,n,o=void 0){let c=[];for(let s of e)typeof s=="object"&&"b"in s&&(s.b=s.b.filter(D=>D!==null&&!(typeof D=="object"&&"->"in D&&new RegExp(/.*\.[0-9]/).test(D["->"]))),$(s.b,r,a,c,u,u,i,X,o,true,n));return c.length===1?c[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:c}}function Be(e="",u=""){let i=Array.isArray(e)?e:[e],r=Array.isArray(u)?u:[u];return [...new Set([...i,...r])]}function X(e,u,i,r,a){if(e.length>0){let n={};He(e,n,a,r);for(let[o,c]of Object.entries(n)){let C=i+"_|_"+o,s={text:c.text.length===1?c.text[0]:c.text,label:C,props:{},type:Fe(C,false),oneTime:c.onetime};c.text.length===0&&(s.onlyHaveNoChoice=true,s.autoSelect=true),s.oneTime===false&&delete s.oneTime;let D=me(s,c.conditions,a,i,r)||s,f=u[u.length-1];if(typeof f=="object"&&f&&"type"in f&&(f={conditionalStep:f}),u.length>0&&typeof f=="object"&&f&&"choices"in f&&f.choices){let d=f.choices;d&&Array.isArray(d)?d.push(D):P.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",c,d),f.choices=d.sort((h,y)=>{try{let A=h.label.split("."),T=A[A.length-1].replaceAll(".","_|_"),m=y.label.split("."),b=m[m.length-1].replaceAll(".","_|_");if(T.includes("c-")&&b.includes("c-")){let t=T.split("c-")[1],F=Number(t),l=b.split("c-")[1],g=Number(l);return F-g}}catch{}return 0});}else u.push({choices:[D]});c.preDialog&&(r.preDialog[C]={...c.preDialog});}}}function He(e,u,i,r,a){let n=[],o="",c="",C=false,s=[];for(let D=0;D<e.length;D++){let f=e[D];if(typeof f=="string")f.startsWith("^")?n.push(L(f)):Me.includes(f)&&s.push(f);else if(Array.isArray(f)&&f.includes("visit")){let d=Q(f,se,(h,y,A)=>{},a,r,i);n.push(d);}else if(f&&typeof f=="object")if("*"in f&&typeof f["*"]&&typeof f["*"]=="string")f["*"].includes("c")&&(o=`c${f["*"].split("c")[1]}`,f.flg&16&&(C=true));else if("s"in f&&Array.isArray(f.s)){let d=We(f.s),h=f.s.includes("<>");d&&(a&&u[a]?(u[a].preDialog={text:d,glue:h},u[a].text=Be(d,u[a].text)):(n.push(d),c=d));}else ("CNT?"in f||"VAR?"in f)&&s.push(f);else s.push(f);if(o){u[o]?u[o].text=Be(n,u[o].text):u[o]={text:n,onetime:C,conditions:s},c&&(u[o].preDialog={text:c,glue:false});let d=e.slice(D+1);He(d,u,i,r,o);return}}}function We(e){for(let u of e)if(typeof u=="string"){if(u.startsWith("^"))return L(u)}else if(Array.isArray(u)){let i=We(u);if(i)return i}}var pu;(a=>{function e(n,o={}){let{labelToRemove:c=[],initialVarsToRemove:C=[],enums:s={},functions:D=[],preDialog:f={},characterIds:d}=o,h={$schema:PIXIVNJSON_SCHEMA_URL};if(h.labels=u(n.root,{labelToRemove:c,initialVarsToRemove:C,enums:s,functions:D,preDialog:f,characterIds:d}),h.labels&&te in h.labels){let y=h.labels[te];delete h.labels[te],y.forEach(A=>{A.operations&&(h.initialOperations=h.initialOperations?[...h.initialOperations,...A.operations]:[...A.operations]);});}if(h.labels&&z in h.labels){let y=h.labels[z];delete h.labels[z],y.forEach(A=>{A.operations&&(h.initialOperations=h.initialOperations?[...h.initialOperations,...A.operations]:[...A.operations]);});}return c.forEach(y=>{h.labels&&y in h.labels&&delete h.labels[y];}),C.forEach(y=>{h.initialOperations&&(h.initialOperations=h.initialOperations.filter(A=>!(A.type==="value"&&A.key===y)));}),h}a.inkToJson=e;function u(n,o){try{let c={};return i(n,c,o),c}catch(c){P.error("Error parsing ink file",c);}}function i(n,o,c){for(let C of n)if(C)if(Array.isArray(C))if(C.includes("visit")){let s=Q(C,se,(D,f,d)=>{},"",c,[]);s&&(c.externalSwitch=s);}else i(C,o,c);else typeof C=="object"&&(C&&"VAR="in C&&c.externalSwitch&&(o[z]||(o[z]=[]),o[z].push({operations:ue({defaultType:"storage",key:C["VAR="],value:c.externalSwitch},[],c)})),r(C,o,"",c));}function r(n,o,c="",C){if(n!==null){for(let[s,D]of Object.entries(n))if(Array.isArray(D)){let f=[],d={},h=(c?c+"_|_":"")+s;$(D,h,C,f,he,he,(y,A,T)=>{r(y,d,A,T);},X);for(let[y,A]of Object.entries(d))o[y]=A;f.length>0&&(o[h]=f);}}}})(pu||={});export{pu as InkMapper};
@@ -56,9 +56,9 @@ Error:${h}`);}return u!=null&&(l=new r(u,s,this._externalErrorHandler,this._root
56
56
  `+a+S+`,
57
57
  `+b+"]";}return i.pop(),a=b,y}},$c={parse:Lc,stringify:Gc},Jc=$c,En=Jc;var Ml="\xA7SPACE\xA7",Gl="\xA7DOUBLE_QUOTES\xA7",$l="\xA7QUOTES\xA7",Jl="SPECIAL_\xA7QUOTES\xA7",Hl="\xA7CURLY_BRACKETS1\xA7",Hc="\xA7INK_VAR\xA7",zl="\xA7CURLY_BRACKETS2\xA7",Je;(y=>{let r=[],e=[];async function t(d,S){for(let m=0;m<r.length;m++)try{let{validation:v}=r[m].opts;if(v instanceof RegExp){if(!v.test(d.join(" ")))continue}else if(v instanceof zod.ZodType&&!v.safeParse(d).success)continue;let x=await r[m].fn(d,S,c);if(x===!0||typeof x=="string")return x}catch{}return false}function n(d,S={name:"custom-command",validation:/^/}){r.unshift({fn:d,opts:S});}y.add=n;function i(){return [...e.map(d=>d.opts),...r.map(d=>d.opts)]}y.info=i;function a(d,S){e.unshift({fn:d,opts:S});}y.addMapper=a;function s(){r.length=0;}y.clear=s;function o(){e.length=0;}y.clearMappers=o;async function l(d,S,m){try{let v=u(d),x=await t(v,m);return x===!0?void 0:typeof x=="string"?(x.startsWith("#")&&(x=x.substring(1)),await y.run(x,S,m)):h(v,S)}catch(v){throw L.error("Error parsing ink hashtag-command",d),v}}y.run=l;function u(d,S){if(d=d.replaceAll('\\"',Gl),d=d.replaceAll("\\'",$l),d=d.replaceAll("\\`",Jl),d=d.replaceAll("\\{",Hl),d=d.replaceAll("\\}",zl),S?.mergeInkVariables){let O;do O=d,d=d.replace(/\{[^{}:]*\}/g,Hc);while(d!==O)}d=d.replaceAll("{"," { "),d=d.replaceAll("}"," } "),d=d.replaceAll(Hl,"{"),d=d.replaceAll(zl,"}");let m=[],v,x="";for(let O=0;O<d.length;O++){let P=d[O];P==='"'||P==="'"||P==="`"?v===void 0?(m.push(x),x="",v=P,x+=P):v===P?(v=void 0,x+=P,m.push(x),x=""):x+=P:x+=P;}return x!==""&&m.push(x),m.forEach((O,P)=>{P%2===1&&(m[P]=O.replaceAll(" ",Ml));}),d=m.join(""),m=d.split(" ").filter(O=>O!==""),m=m.map(O=>O.replaceAll(Ml," ").replaceAll(Gl,'"').replaceAll($l,"'").replaceAll(Jl,"`")),m=g(m),m=m.map(O=>O.startsWith('"')&&O.endsWith('"')||O.startsWith("'")&&O.endsWith("'")||O.startsWith("`")&&O.endsWith("`")?O.slice(1,-1):O),m}y.convertTagTolist=u;function h(d,S,m){for(let v of e){let{validation:x}=v.opts,O=false;if(x instanceof RegExp?O=x.test(d.join(" ")):x instanceof zod.ZodType&&(O=x.safeParse(d).success),O)return v.fn(d,S)}m?.silent||L.error("The operation is not valid",d);}y.convertOperation=h;function c(d){return p(d)}y.convertListStringToObj=c;function p(d){if(d.length===0)return {};if(d.length%2!==0)throw L.error("The props list must have a pair number of elements",d),new Error("The props list must have a pair number of elements");let S="{";d.forEach((m,v)=>{if(v%2===0)S+=`"${m}": `;else {switch(m){case "null":case "undefined":case "true":case "false":S+=`${m}`;break;default:C(m)?(m=f(m),S+=`"${m}"`):m.startsWith("{")&&m.endsWith("}")?S+=`${m}`:m.startsWith('"')&&m.endsWith('"')?S+=`${m}`:Number.isNaN(parseFloat(m))?S+=`"${m}"`:S+=`${m}`;}v<d.length-1&&(S+=", ");}}),S+="}";try{return En.parse(S)}catch(m){throw L.error("Error parsing ink json",S),m}}function f(d){return d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'")||d.startsWith("`")&&d.endsWith("`")?d.substring(1,d.length-1):d}function C(d){return !!(d.startsWith('"')&&d.endsWith('"')||d.startsWith("'")&&d.endsWith("'")||d.startsWith("`")&&d.endsWith("`"))}function g(d){return b(d).tokens}y.mergeJsonBlocks=g;function b(d){let S=[],m=false;for(let v=0;v<d.length;v++){let x=d[v];if(x!=="{"){S.push(x);continue}let O=E(d,v);if(O===-1){S.push(x);continue}let P=b(d.slice(v+1,O)),Y=["{",...P.tokens,"}"],ge=Y.join(" ");if(!P.hasInvalidMatchedBlock)try{En.parse(ge),S.push(ge),v=O;continue}catch{}m=true,S.push(...Y),v=O;}return {tokens:S,hasInvalidMatchedBlock:m}}function E(d,S){let m=0;for(let v=S;v<d.length;v++)if(d[v]==="{")m++;else if(d[v]==="}"&&(m--,m===0))return v;return -1}})(Je||={});var Ee;(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)))(Ee||={});var w=class j{static init(e){e.loadAssets&&(j._loadAssets=e.loadAssets),e.soundOperation&&(j._soundOperation=e.soundOperation),e.imageOperation&&(j._imageOperation=e.imageOperation),e.videoOperation&&(j._videoOperation=e.videoOperation),e.imageContainerOperation&&(j._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(j._textOperation=e.textOperation),e.canvasElementOperation&&(j._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(j._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(j._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(j._narrationOperation=e.narrationOperation),e.effectOperation&&(j._effectOperation=e.effectOperation),e.animateOperation&&(j._animateOperation=e.animateOperation),e.getLogichValue&&(j._getLogichValue=e.getLogichValue),e.getConditionalStep&&(j._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return j._loadAssets}static _soundOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return j._soundOperation}static _imageOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return j._imageOperation}static _videoOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return j._videoOperation}static _imageContainerOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return j._imageContainerOperation}static _textOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return j._textOperation}static _canvasElementOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return j._canvasElementOperation}static _setStorageValue=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return j._setStorageValue}static _setInitialStorageValue=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return j._setInitialStorageValue}static _narrationOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return j._narrationOperation}static _effectOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return j._effectOperation}static _animateOperation=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return j._animateOperation}static _getLogichValue=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return j._getLogichValue}static _getConditionalStep=()=>{throw Ee.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return j._getConditionalStep}};var Gt;(r=>{r.options={replaceRegex:/\[([^\]]+)\]/};let e=[];function t(u,h){e.unshift({fn:u,opts:h});}r.add=t;function n(u){let h=e.findIndex(c=>c.fn===u);h!==-1&&e.splice(h,1);}r.remove=n;function i(){return e.map(u=>u.opts)}r.info=i;function a(u,h){let c=e.filter(p=>(p.opts.type??"after-translation")===h.type);for(let p of c)u=l(u,p.fn,p.opts.validation);return u}r.replace=a;function s(u){let h=e.filter(c=>c.opts.i18nInterpolation);for(let c of h)u=o(u,c.fn,c.opts);return u}r.runI18nPreStep=s;function o(u,h,c){let{validation:p}=c,f=new RegExp(r.options.replaceRegex.source,"g"),C=[...u.matchAll(f)],g=new Set,b=[];for(let E of C)g.has(E[1])||(g.add(E[1]),b.push(E[1]));for(let E of b){if(p==="characterId"){if(!characters.RegisteredCharacters.has(E))continue}else if(p!=="all"){if(p instanceof RegExp){if(!p.test(E))continue}else if(p instanceof zod.ZodType&&!p.safeParse(E).success)continue}h(E)!==void 0&&(u.includes(`{{[${E}]}}`)||(u=u.replaceAll(`[${E}]`,`{{[${E}]}}`)));}return u}function l(u,h,c){let p=new RegExp(r.options.replaceRegex.source,"g"),f=[...u.matchAll(p)],C=new Set,g=[];for(let b of f)C.has(b[1])||(C.add(b[1]),g.push(b[1]));for(let b of g){if(c==="characterId"){if(!characters.RegisteredCharacters.has(b))continue}else if(c!=="all"){if(c instanceof RegExp){if(!c.test(b))continue}else if(c instanceof zod.ZodType&&!c.safeParse(b).success)continue}let E=h(b);E!==void 0&&(u=u.replaceAll(`[${b}]`,E));}return u}})(Gt||={});function zc(r,e={}){let t="";return r.values.forEach(n=>{if(typeof n=="string")t+=n;else {let i=w.getLogichValue(n,e);t+=`${i}`;}}),t}var Xl;(r=>{let e=l=>l;function t(l){return Array.isArray(l)?l.map(u=>n(`${u}`)):n(`${l}`)}r.t=t;function n(l){let u=l;return r.beforeToTranslate&&(u=(0, r.beforeToTranslate)(u)),u=Gt.replace(u,{type:"before-translation"}),u=e(u),r.afterToTranslate&&(u=(0, r.afterToTranslate)(u)),u=Gt.replace(u,{type:"after-translation"}),u}r.translate=n;function i(l){e=l;}r.setTranslate=i;function a(l,u,h){let{defaultValue:c="empty_string"}=h;typeof u=="string"&&(u=[u]),Array.isArray(u)&&u.forEach(p=>{let f=p;if(r.beforeToTranslate&&(f=(0, r.beforeToTranslate)(f)),c==="empty_string")l[f]===void 0&&(l[f]="");else if(c==="copy_key"){let C=p;r.beforeToTranslate&&(C=(0, r.beforeToTranslate)(C));let g=Gt.runI18nPreStep(C);g=Gt.replace(g,{type:"before-translation"}),l[f]=g;}});}function s(l,u=[]){if(typeof l=="object"&&l&&"type"in l)if(l.type==="ifelse")l.then&&s(l.then,u),l.else&&s(l.else,u);else if(l.type==="stepswitch"){if(l.elements)if(Array.isArray(l.elements))l.elements.forEach(h=>{s(h,u);});else if(l.elements.type==="ifelse"){let h=[];s(l.elements,h),h.forEach(c=>{u.push(...c);});}else if(l.elements.type==="stepswitch"){let h=[];s(l.elements,h),h.forEach(c=>{u.push(...c);});}else s(l.elements,u);}else l.type==="resulttocombine"?(l.firstItem&&s(l.firstItem,u),l.secondConditionalItem&&l.secondConditionalItem.forEach(h=>{s(h,u);})):u.push(l);else l&&u.push(l);return u}async function o(l,u={},h={}){let{defaultValue:c="copy_key",operationStringConvert:p}=h,f=l.map(async C=>{if(C.choices){let g=[];Array.isArray(C.choices)?g=[C.choices]:g=s(C.choices),g.forEach(b=>{b.forEach(E=>{if("type"in E){let y=[];E.type==="ifelse"||E.type==="stepswitch"?s(E,y):y=[E],y.map(d=>s(d.text)).forEach(d=>{Array.isArray(d)&&d.forEach(S=>{Array.isArray(S)?S.forEach(m=>{typeof m=="string"?a(u,m,{defaultValue:c}):s(m).forEach(v=>{Array.isArray(v)?v.forEach(x=>{typeof x=="string"&&a(u,x,{defaultValue:c});}):typeof v=="string"&&a(u,v,{defaultValue:c});});}):typeof S=="string"&&a(u,S,{defaultValue:c});});});}});});}if(C.dialogue){let g=[];Array.isArray(C.dialogue)?g=[C.dialogue]:g=s(C.dialogue),g.forEach(b=>{if(typeof b=="string")a(u,b,{defaultValue:c});else if("text"in b){let E=s(b.text);typeof E=="string"&&(E=[E]),E.forEach(y=>{typeof y=="string"?a(u,y,{defaultValue:c}):s(y).forEach(d=>{typeof d=="string"?a(u,d,{defaultValue:c}):Array.isArray(d)&&d.forEach(S=>{typeof S=="string"?a(u,S,{defaultValue:c}):s(S).forEach(m=>{typeof m=="string"&&a(u,m,{defaultValue:c});});});});});}});}if(C.operations)for(let g of C.operations){if(g.type==="operationtoconvert"&&p){let b=zc(g),E=await p(b,C,{});if(!E)return;g=E;}g.type==="text"&&g.operationType==="show"&&a(u,g.text,{defaultValue:c});}C.conditionalStep&&s(C.conditionalStep).forEach(g=>{Array.isArray(g)?o(g,u,h):o([g],u,h);});});return await Promise.all(f),u}r.generateJsonTranslation=o;})(Xl||={});var Ne=Xl;async function Yl(r){let e=w.getLogichValue(r,{});if(e)switch(e.type){case "assets":switch(e.operationType){case "load":await canvas.Assets.load(e.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(e.aliases);break}break;case "bundle":switch(e.operationType){case "load":await canvas.Assets.loadBundle(e.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(e.aliases);break}break}}var W;(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)))(W||={});async function mi(r,e,t){switch(t.type){case "fade":await canvas.showWithFade(e.alias,r,t.props,t.priority);break;case "dissolve":await canvas.showWithDissolve(e.alias,r,t.props,t.priority);break;case "movein":case "moveout":await canvas.moveIn(e.alias,r,t.props,t.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(e.alias,r,t.props,t.priority);break;case "pushin":case "pushout":await canvas.pushIn(e.alias,r,t.props,t.priority);break}}function Dn(r){if(r.transition)switch(r.transition.type){case "fade":canvas.removeWithFade(r.alias,r.transition.props,r.transition.priority);break;case "dissolve":canvas.removeWithDissolve(r.alias,r.transition.props,r.transition.priority);break;case "movein":case "moveout":canvas.moveOut(r.alias,r.transition.props,r.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(r.alias,r.transition.props,r.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(r.alias,r.transition.props,r.transition.priority);break}else canvas.canvas.remove(r.alias);}async function Ql(r){switch(r.operationType){case "show":if(r.transition){let e=new canvas.ImageSprite(r.props,r.url||r.alias);await mi(e,r,r.transition);}else await canvas.showImage(r.alias,r.url,r.props);break;case "edit":{let e=canvas.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):W.error(`Image with alias ${r.alias} not found.`);break}case "remove":Dn(r);break}}async function Zl(r){switch(r.operationType){case "show":if(r.transition){let e=new canvas.VideoSprite(r.props,r.url||r.alias);await mi(e,r,r.transition);}else await canvas.showVideo(r.alias,r.url,r.props);break;case "edit":{let e=canvas.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):W.error(`Video with alias ${r.alias} not found.`);break}case "remove":Dn(r);break;case "pause":case "resume":{let e=canvas.canvas.find(r.alias);e?e.paused=r.operationType==="pause":W.error(`Video with alias ${r.alias} not found.`);break}}}async function eu(r){switch(r.operationType){case "show":if(r.transition){let e=new canvas.ImageContainer(r.props,r.urls);await mi(e,r,r.transition);}else await canvas.showImageContainer(r.alias,r.urls,r.props);break;case "edit":{let e=canvas.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):W.error(`ImageContainer with alias ${r.alias} not found.`);break}case "remove":Dn(r);break}}async function tu(r){switch(r.operationType){case "show":if(r.props=r.props||{},r.props.text=Ne.t(r.text),r.transition){let e=new canvas.Text(r.props);await mi(e,r,r.transition);}else canvas.showText(r.alias,r.text,r.props);break;case "edit":{let e=canvas.canvas.find(r.alias);e?r.props&&await e.setMemory({...e.memory,...r.props}):W.error(`Text with alias ${r.alias} not found.`);break}case "remove":Dn(r);break}}async function nu(r){switch(r.operationType){case "edit":try{let e=canvas.canvas.find(r.alias);e?r.props&&e.setMemory({...e.memory,...r.props}):W.error(`Canvas Element with alias ${r.alias} not found.`);}catch(e){W.error(`There was an error while trying to edit the canvas element with alias ${r.alias}.`,e);}break;case "remove":Dn(r);break}}async function iu(r){r.type==="shake"&&await canvas.shakeEffect(r.alias,r.props,r.priority);}function ru(r){switch(r.type){case "animate":canvas.canvas.animate(r.alias,r.keyframes,r.options,r.priority);break;case "animate-sequence":canvas.canvas.animate(r.alias,r.sequence,r.options,r.priority);break}}function su(r){switch(r.type){case "input":narration.narration.requestInput({type:r.valueType},r.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function au(r){switch(r.operationType){case "play":r.url?sound.sound.play(r.alias,r.url,r.props):sound.sound.play(r.alias,r.props);break;case "stop":switch(r.type){case "sound":sound.sound.stop(r.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(r.type){case "sound":sound.sound.pause(r.alias);break;case "channel":sound.sound.findChannel(r.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(r.type){case "sound":sound.sound.resume(r.alias);break;case "channel":sound.sound.findChannel(r.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(r.props).forEach(([e,t])=>{let n=sound.sound.find(r.alias);n&&(e==="volume"?n.volume.value=t:n.paused=t);});break}}var Ys="___param___",fd=class q{static init(e){e.loadAssets&&(q._loadAssets=e.loadAssets),e.soundOperation&&(q._soundOperation=e.soundOperation),e.imageOperation&&(q._imageOperation=e.imageOperation),e.videoOperation&&(q._videoOperation=e.videoOperation),e.imageContainerOperation&&(q._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(q._textOperation=e.textOperation),e.canvasElementOperation&&(q._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(q._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(q._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(q._narrationOperation=e.narrationOperation),e.effectOperation&&(q._effectOperation=e.effectOperation),e.animateOperation&&(q._animateOperation=e.animateOperation),e.getLogichValue&&(q._getLogichValue=e.getLogichValue),e.getConditionalStep&&(q._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return q._loadAssets}static _soundOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return q._soundOperation}static _imageOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return q._imageOperation}static _videoOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return q._videoOperation}static _imageContainerOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return q._imageContainerOperation}static _textOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return q._textOperation}static _canvasElementOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return q._canvasElementOperation}static _setStorageValue=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return q._setStorageValue}static _setInitialStorageValue=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return q._setInitialStorageValue}static _narrationOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return q._narrationOperation}static _effectOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return q._effectOperation}static _animateOperation=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return q._animateOperation}static _getLogichValue=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return q._getLogichValue}static _getConditionalStep=()=>{throw W.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return q._getConditionalStep}};function md(r,e){if(e&&typeof e=="object"&&typeof r.functionName=="string"&&r.functionName in e){let t=e[r.functionName];if(typeof t=="function"){let n=r.args.map(i=>fd.getLogichValue(i,e));return t(...n)}else W.warn(`getLogichValue function ${r.functionName} not found in props`);}}function ou(r,e){let t=w.getLogichValue(r,e);return t&&typeof t=="object"&&"type"in t?w.getLogichValue(t,e):t}function lu(r,e={}){let t=ou(r.value,e);switch(r.storageType){case "flagStorage":storage.storage.setFlag(r.key,r.value);break;case "storage":storage.storage.set(r.key,t);break;case "tempstorage":storage.storage.setTempVariable(r.key,t);break;case "params":{let n=storage.storage.get(`${Ys}${narration.narration.openedLabels.length-1}`)||[];n.length>r.key&&(n[r.key]=t),storage.storage.setTempVariable(`${Ys}${narration.narration.openedLabels.length-1}`,n);break}}}function uu(r,e={}){let t=ou(r.value,e);switch(r.storageType){case "storage":case "tempstorage":storage.storage.default={[r.key]:t};break}}function hu(r,e={}){let t=cu(r,e);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case "value":return Cd(t,e);case "arithmetic":case "arithmeticsingle":return gd(t,e);case "compare":case "union":return yd(t,e);case "function":return md(t,e)}return t}function gd(r,e){let t=w.getLogichValue(r.leftValue,e);switch(r.type){case "arithmetic":{let n=w.getLogichValue(r.rightValue,e);switch(r.operator){case "*":return t*n;case "/":return t/n;case "+":return typeof t=="string"||typeof n=="string"?`${t}${n}`:Array.isArray(t)&&Array.isArray(n)?[...t,...n]:Array.isArray(t)?[...t,n]:Array.isArray(n)?[t,...n]:t+n;case "-":if(Array.isArray(t)&&Array.isArray(n))return t.filter(i=>!n.includes(i));if(Array.isArray(t))return t.filter(i=>i!==n);if(Array.isArray(n)){W.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return t-n;case "%":return t%n;case "POW":return t**n;case "RANDOM":return narration.narration.getRandomNumber(t,n);case "INTERSECTION":if(Array.isArray(t)&&Array.isArray(n))return t.filter(i=>n.includes(i));W.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:W.warn("getValueFromArithmeticOperations unknown operator",r);return}}case "arithmeticsingle":switch(r.operator){case "INT":return Number(t);case "FLOOR":return Math.floor(t)}break}}function Cd(r,e){if(r&&typeof r=="object"&&"type"in r&&r.type==="value"&&r.storageOperationType==="get")switch(r.storageType){case "storage":case "tempstorage":return r.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(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 w.getLogichValue(r.operation,e);case "params":{let t=storage.storage.get(`${Ys}${narration.narration.openedLabels.length-1}`)||[];if(t&&t.length>r.key)return t[r.key];W.warn("getValue params not found");return}}return r}function yd(r,e){if(!r)return false;if(typeof r!="object"||!("type"in r))return !!r;switch(r.type){case "compare":{let t=w.getLogichValue(r.leftValue,e),n=w.getLogichValue(r.rightValue,e);switch(r.operator){case "==":return Array.isArray(t)&&Array.isArray(n)?t.length===n.length&&t.every(i=>n.includes(i)):t===n;case "!=":return Array.isArray(t)&&Array.isArray(n)?t.length!==n.length||!t.every(i=>n.includes(i)):t!==n;case "<":return typeof t=="string"&&typeof n=="string"?t.localeCompare(n)<0:Array.isArray(t)&&Array.isArray(n)?t.length<n.length:t<n;case "<=":return typeof t=="string"&&typeof n=="string"?t.localeCompare(n)<=0:Array.isArray(t)&&Array.isArray(n)?t.length<=n.length:t<=n;case ">":return typeof t=="string"&&typeof n=="string"?t.localeCompare(n)>0:Array.isArray(t)&&Array.isArray(n)?t.length>n.length:t>n;case ">=":return typeof t=="string"&&typeof n=="string"?t.localeCompare(n)>=0:Array.isArray(t)&&Array.isArray(n)?t.length>=n.length:t>=n;case "CONTAINS":return Array.isArray(t)&&Array.isArray(n)?n.every(i=>t.includes(i)):Array.isArray(t)?t.includes(n):t.toString().includes(n.toString())}break}case "value":{let t=w.getLogichValue(r,e);return Array.isArray(t)?t.length>0:t&&typeof t=="object"?Object.keys(t).length>0:!!t}case "union":return vd(r,e)}return !!r}function vd(r,e){if(r.unionType==="not"){let n=hu(r.condition,e);return Array.isArray(n)?n.length===0:n&&typeof n=="object"?Object.keys(n).length===0:!n}let t=n=>w.getLogichValue(n,e)||false;return r.unionType==="and"?r.conditions.every(t):r.conditions.some(t)}function Sd(r,e){return Math.floor(Math.random()*(e-r+1)+r)}function cu(r,e={}){if(Array.isArray(r)||!r)return r;if(r&&typeof r=="object"&&"type"in r)switch(r.type){case "resulttocombine":return Ed(r,e);case "ifelse":return w.getLogichValue(r.condition,e)?w.getLogichValue(r.then,e):w.getLogichValue(r.else,e);case "stepswitch":{let t=w.getLogichValue(r.elements,e)||[];if(t.length===0){W.error("getValueFromConditionalStatements elements.length === 0");return}switch(r.choiceType){case "random":{let n=Sd(0,t.length-1);return w.getLogichValue(t[n],e)}case "loop":{let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(r.nestedId)-1;return n>t.length-1?(n=n%t.length,w.getLogichValue(t[n],e)):w.getLogichValue(t[n],e)}case "sequential":{let n,i=narration.NarrationManagerStatic.getCurrentStepTimesCounter(r.nestedId)-1;return r.end==="lastItem"&&(n=w.getLogichValue(t[t.length-1],e)),i>t.length-1?n:w.getLogichValue(t[i],e)}case "sequentialrandom":{let n=narration.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:r.nestedId,onceOnly:true});if(n===void 0&&r.end==="lastItem"){let i=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(r.nestedId);if(!i?.usedRandomNumbers){W.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let a=i.usedRandomNumbers[`0-${t.length-1}`];return w.getLogichValue(t[a[a.length-1]],e)}if(n===void 0){W.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return w.getLogichValue(t[n],e)}}}}return r}function gi(r,e={}){if(r.conditionalStep){let t=pixiVn.createExportableElement(w.getLogichValue(r.conditionalStep,e));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operations===void 0&&delete t?.operations,t){let n={...r,conditionalStep:void 0,...t};return gi(n,e)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return r}function Ed(r,e){let t=r.firstItem,n=(r.secondConditionalItem??[]).flatMap(a=>Array.isArray(a)?a.map(s=>w.getLogichValue(s,e)):[w.getLogichValue(a,e)]),i=t?[t,...n]:n;if(i.length===0){W.warn("combinateResult toCheck.length === 0");return}if(typeof i[0]=="string")return Ne.t(i);if(typeof i[0]=="object"){let a=i,s,o=false,l=a.map((y,d)=>{y=gi(y,e);let S=w.getLogichValue(y.dialogue,e)||"";return d===0?(s=w.getLogichValue(y.glueEnabled,e)||false,S):(typeof S=="object"&&"text"in S&&(S=`${S.character}: ${S.text}`),s===false&&o&&(S=`
58
58
 
59
- ${S}`),S&&(o=true),s=w.getLogichValue(y.glueEnabled,e)||false,S)}),u=w.getLogichValue(l[0],e),h=typeof u=="object"&&"character"in u?u.character:void 0,c=l.flatMap(y=>{let d;y&&typeof y=="object"&&"text"in y?d=y.text:d=y;let S;return Array.isArray(d)?S=d.map(m=>{let v=w.getLogichValue(m,e);return Ne.t(`${v}`)}):S=w.getLogichValue(d,e)||"",Ne.t(S)}),p=a.find(y=>y.end),f=a.find(y=>y.choices),C=false,g=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&(narration.narration.dialogGlue=true),C=a[a.length-1].glueEnabled,g=a.reverse().find(y=>!(y.operations&&(!y.dialogue||!y.choices)))?.goNextStep);let b=a.find(y=>y.labelToOpen),E=[];return a.forEach(y=>{y.operations&&(E=[...E,...y.operations]);}),{dialogue:h?{character:h,text:c}:c,end:p?.end,choices:f?.choices,glueEnabled:C,goNextStep:g,labelToOpen:b?.labelToOpen,operations:E}}}var Ci;(r=>{let e=new Set;function t(a){e.add(a);}r.add=t;function n(){e.clear();}r.clear=n;function i(a,s={}){let o=h=>hu(h,s)??void 0,l=cu(a,s);if(e.size===0)return o(l);let u=o;for(let h of e){let c=u;u=p=>h(p,c)??void 0;}return u(l)}r.getLogichValue=i;})(Ci||={});var xd=Object.create,gu=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,_d=Object.getOwnPropertyNames,Od=Object.getPrototypeOf,Td=Object.prototype.hasOwnProperty,pu=(r=>typeof xt<"u"?xt:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof xt<"u"?xt:e)[t]}):r)(function(r){if(typeof xt<"u")return xt.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')}),Cu=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Pd=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _d(e))!Td.call(r,i)&&i!==t&&gu(r,i,{get:()=>e[i],enumerable:!(n=wd(e,i))||n.enumerable});return r},Fd=(r,e,t)=>(t=r!=null?xd(Od(r)):{},Pd(gu(t,"default",{value:r,enumerable:true}),r)),Nd=Cu((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 pu=="function")try{a=pu("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 y(){}return function(d){var S;return y.prototype=d,S=new y,y.prototype=null,S}})(),l={},u=l.lib={},h=u.Base=(function(){return {extend:function(y){var d=o(this);return y&&d.mixIn(y),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var y=this.extend();return y.init.apply(y,arguments),y},init:function(){},mixIn:function(y){for(var d in y)y.hasOwnProperty(d)&&(this[d]=y[d]);y.hasOwnProperty("toString")&&(this.toString=y.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),c=u.WordArray=h.extend({init:function(y,d){y=this.words=y||[],d!=i?this.sigBytes=d:this.sigBytes=y.length*4;},toString:function(y){return (y||f).stringify(this)},concat:function(y){var d=this.words,S=y.words,m=this.sigBytes,v=y.sigBytes;if(this.clamp(),m%4)for(var x=0;x<v;x++){var O=S[x>>>2]>>>24-x%4*8&255;d[m+x>>>2]|=O<<24-(m+x)%4*8;}else for(var P=0;P<v;P+=4)d[m+P>>>2]=S[P>>>2];return this.sigBytes+=v,this},clamp:function(){var y=this.words,d=this.sigBytes;y[d>>>2]&=4294967295<<32-d%4*8,y.length=n.ceil(d/4);},clone:function(){var y=h.clone.call(this);return y.words=this.words.slice(0),y},random:function(y){for(var d=[],S=0;S<y;S+=4)d.push(s());return new c.init(d,y)}}),p=l.enc={},f=p.Hex={stringify:function(y){for(var d=y.words,S=y.sigBytes,m=[],v=0;v<S;v++){var x=d[v>>>2]>>>24-v%4*8&255;m.push((x>>>4).toString(16)),m.push((x&15).toString(16));}return m.join("")},parse:function(y){for(var d=y.length,S=[],m=0;m<d;m+=2)S[m>>>3]|=parseInt(y.substr(m,2),16)<<24-m%8*4;return new c.init(S,d/2)}},C=p.Latin1={stringify:function(y){for(var d=y.words,S=y.sigBytes,m=[],v=0;v<S;v++){var x=d[v>>>2]>>>24-v%4*8&255;m.push(String.fromCharCode(x));}return m.join("")},parse:function(y){for(var d=y.length,S=[],m=0;m<d;m++)S[m>>>2]|=(y.charCodeAt(m)&255)<<24-m%4*8;return new c.init(S,d)}},g=p.Utf8={stringify:function(y){try{return decodeURIComponent(escape(C.stringify(y)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(y){return C.parse(unescape(encodeURIComponent(y)))}},b=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new c.init,this._nDataBytes=0;},_append:function(y){typeof y=="string"&&(y=g.parse(y)),this._data.concat(y),this._nDataBytes+=y.sigBytes;},_process:function(y){var d,S=this._data,m=S.words,v=S.sigBytes,x=this.blockSize,O=x*4,P=v/O;y?P=n.ceil(P):P=n.max((P|0)-this._minBufferSize,0);var Y=P*x,ge=n.min(Y*4,v);if(Y){for(var Mt=0;Mt<Y;Mt+=x)this._doProcessBlock(m,Mt);d=m.splice(0,Y),S.sigBytes-=ge;}return new c.init(d,ge)},clone:function(){var y=h.clone.call(this);return y._data=this._data.clone(),y},_minBufferSize:0});u.Hasher=b.extend({cfg:h.extend(),init:function(y){this.cfg=this.cfg.extend(y),this.reset();},reset:function(){b.reset.call(this),this._doReset();},update:function(y){return this._append(y),this._process(),this},finalize:function(y){y&&this._append(y);var d=this._doFinalize();return d},blockSize:16,_createHelper:function(y){return function(d,S){return new y.init(S).finalize(d)}},_createHmacHelper:function(y){return function(d,S){return new E.HMAC.init(y,S).finalize(d)}}});var E=l.algo={};return l})(Math);return t});}),Id=Cu((r,e)=>{(function(t,n){typeof r=="object"?e.exports=r=n(Nd()):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 p=this._hash.words,f=p[0],C=p[1],g=p[2],b=p[3],E=p[4],y=0;y<80;y++){if(y<16)l[y]=h[c+y]|0;else {var d=l[y-3]^l[y-8]^l[y-14]^l[y-16];l[y]=d<<1|d>>>31;}var S=(f<<5|f>>>27)+E+l[y];y<20?S+=(C&g|~C&b)+1518500249:y<40?S+=(C^g^b)+1859775393:y<60?S+=(C&g|C&b|g&b)-1894007588:S+=(C^g^b)-899497514,E=b,b=g,g=C<<30|C>>>2,C=f,f=S;}p[0]=p[0]+f|0,p[1]=p[1]+C|0,p[2]=p[2]+g|0,p[3]=p[3]+b|0,p[4]=p[4]+E|0;},_doFinalize:function(){var h=this._data,c=h.words,p=this._nDataBytes*8,f=h.sigBytes*8;return c[f>>>5]|=128<<24-f%32,c[(f+64>>>9<<4)+14]=Math.floor(p/4294967296),c[(f+64>>>9<<4)+15]=p,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});}),fu="___param___",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||={});var Vd=class M{static init(e){e.loadAssets&&(M._loadAssets=e.loadAssets),e.soundOperation&&(M._soundOperation=e.soundOperation),e.imageOperation&&(M._imageOperation=e.imageOperation),e.videoOperation&&(M._videoOperation=e.videoOperation),e.imageContainerOperation&&(M._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(M._textOperation=e.textOperation),e.canvasElementOperation&&(M._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(M._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(M._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(M._narrationOperation=e.narrationOperation),e.effectOperation&&(M._effectOperation=e.effectOperation),e.animateOperation&&(M._animateOperation=e.animateOperation),e.getLogichValue&&(M._getLogichValue=e.getLogichValue),e.getConditionalStep&&(M._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return M._loadAssets}static _soundOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return M._soundOperation}static _imageOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return M._imageOperation}static _videoOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return M._videoOperation}static _imageContainerOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return M._imageContainerOperation}static _textOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return M._textOperation}static _canvasElementOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return M._canvasElementOperation}static _setStorageValue=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return M._setStorageValue}static _setInitialStorageValue=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return M._setInitialStorageValue}static _narrationOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return M._narrationOperation}static _effectOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return M._effectOperation}static _animateOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return M._animateOperation}static _getLogichValue=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return M._getLogichValue}static _getConditionalStep=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return M._getConditionalStep}};function kd(r,e){if(e&&typeof e=="object"&&typeof r.functionName=="string"&&r.functionName in e){let t=e[r.functionName];if(typeof t=="function"){let n=r.args.map(i=>Vd.getLogichValue(i,e));return t(...n)}else ie.warn(`getLogichValue function ${r.functionName} not found in props`);}}function Rd(r,e={}){let t="";return r.values.forEach(n=>{if(typeof n=="string")t+=n;else {let i=w.getLogichValue(n,e);t+=`${i}`;}}),t}async function yu(r,e,t){let n=w.getLogichValue(r,e);if(n)switch(n.type){case "sound":w.soundOperation(n);break;case "assets":case "bundle":await w.loadAssets(n);break;case "image":await w.imageOperation(n);break;case "video":await w.videoOperation(n);break;case "imagecontainer":await w.imageContainerOperation(n);break;case "text":await w.textOperation(n);break;case "canvaselement":await w.canvasElementOperation(n);break;case "value":w.setStorageValue(n,e);break;case "operationtoconvert":if(t){let i=Rd(n,e),a=await t(i);a&&await yu(a,e,t);}break;case "input":case "dialogue":w.narrationOperation(n);break;case "shake":await w.effectOperation(n);break;case "animate":case "animate-sequence":w.animateOperation(n);break;case "function":await kd(n,e);break}}function mu(r){let e=w.getLogichValue(r,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&w.setInitialStorageValue(e);}var Ld=Fd(Id()),Bd=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=w.getConditionalStep(a),a.operations)try{let s=a.operations.map(o=>w.loadAssets(o));await Promise.all(s);}catch(s){ie.error("The operation in the onLoadingLabel function of the label has an error:",s);}}},super(r,t),this._steps=e,this.operationStringConvert=n.operationStringConvert,this.skipEmptyDialogs=n.skipEmptyDialogs||false;}_steps;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)}operationStringConvert;skipEmptyDialogs=false;getStepSha(r){if(r<0||r>=this.steps.length)return;let e=this._steps[r];return (0, Ld.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(r,e){let t="";if(Array.isArray(r)){let n=[];r.forEach(i=>{if(typeof i=="string")n.push(i);else if(i&&typeof i=="object"){let a=w.getLogichValue(i,e);a?(a&&!Array.isArray(a)&&typeof a=="object"&&(a=w.getLogichValue(a,e)||""),Array.isArray(a)?n=n.map(s=>`${s}`).concat(a):n.push(`${a}`)):n.push(`${i}`);}else n.push(`${i}`);}),t=n;}else {let n=w.getLogichValue(r,e);n&&!Array.isArray(n)&&typeof n=="object"&&(n=w.getLogichValue(n,e)),n&&Array.isArray(n)?t=n.map(i=>`${i}`):t=`${n}`;}return t}getDialogue(r,e){if(r==null)return;let t=w.getLogichValue(r,e);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:Ne.t(this.getDialogueText(t.text,e))}:Ne.t(this.getDialogueText(t,e))}getChoices(r,e){return w.getLogichValue(r,e)?.map(t=>w.getLogichValue(t,e)).filter(t=>t!==void 0)}stepConverter(r){return async e=>{let t=typeof r=="function"?r():r;t=pixiVn.createExportableElement(t),t=w.getConditionalStep(t,e);let n=this.operationStringConvert?p=>this.operationStringConvert(p,t,e):void 0,{operations:i=[]}=t;for(let p of i)await yu(p,e,n);let{labelToOpen:a=[]}=t,s=this.getChoices(t.choices,e),o=w.getLogichValue(t.glueEnabled,e),l=this.getDialogue(t.dialogue,e),u=[];Array.isArray(a)||(a=[a]),a.forEach(p=>{let f=w.getLogichValue(p,e);f&&u.push(f);});let h=w.getLogichValue(t.goNextStep,e),c=w.getLogichValue(t.end,e);if(s){let p=s.map(f=>{let C="";if(Array.isArray(f.text)){let g=[];f.text.forEach(b=>{if(typeof b=="string")g.push(Ne.t(b));else if(b&&typeof b=="object"){let E=w.getLogichValue(b,e);E&&!Array.isArray(E)&&typeof E=="object"&&(E=w.getLogichValue(E,e)||""),E&&(Array.isArray(E)?g=g.concat(Ne.t(E)):g.push(Ne.t(E)));}}),C=g;}else typeof f.text=="string"&&(C=Ne.t(f.text));return {label:f.label,text:C,props:f.props,type:f.type,oneTime:f.oneTime,onlyHaveNoChoice:f.onlyHaveNoChoice,autoSelect:f.autoSelect}});narration.narration.choices=p;}else narration.narration.choices=void 0;l!==void 0&&(narration.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=true)),o?narration.narration.dialogGlue=true:o===false&&(narration.narration.dialogGlue=false);for(let p of u){let f=p.label;typeof f=="object"&&(f=w.getLogichValue(f,e)||"");let C=p.params?.map(g=>w.getLogichValue(g,e));e={...e,...p.props},p.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${fu}${narration.narration.openedLabels.length}`,C),await narration.narration.call(f,e)):(storage.storage.setTempVariable(`${fu}${narration.narration.openedLabels.length}`,C),await narration.narration.call(f,e));}c==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(e,{runNow:true})):c==="label_end"&&narration.narration.closeCurrentLabel(),h&&await narration.narration.continue(e,{runNow:true});}}};async function Qs(r,e={}){if(!Array.isArray(r))if(typeof r=="object"||typeof r=="string")r=[r];else {ie.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let t=r.map(a=>{if(typeof a=="string")try{return JSON.parse(a)}catch(s){return ie.error("Error parsing imported Pixi'VN JSON",s),{}}return a}),n=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)s.type==="value"&&(typeof s.value!="object"||!s.value||!("type"in s.value))&&mu(s);return Promise.resolve()});await Promise.all(n);let i=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)(s.type!=="value"||s.type==="value"&&typeof s.value=="object"&&s.value&&"type"in s.value)&&mu(s);if(a.labels){let s=a.labels;for(let o in s)try{let l=s[o],u=new Bd(o,l,void 0,e);narration.RegisteredLabels.add(u);}catch(l){ie.error(`Error creating JSON label ${o}`,l);}}return Promise.resolve()});await Promise.all(i);}var Wd={version:"1.13.10"};var vu=`https://pixi-vn.com/schemas/${Wd.version}/schema.json`,Su=["==","!=","<","<=",">",">=","CONTAINS"];function Zs(){w.init({animateOperation:ru,canvasElementOperation:nu,effectOperation:iu,imageContainerOperation:eu,imageOperation:Ql,textOperation:tu,narrationOperation:su,loadAssets:Yl,soundOperation:au,videoOperation:Zl,setStorageValue:lu,setInitialStorageValue:uu,getLogichValue:Ci.getLogichValue,getConditionalStep:gi});}var yi="global decl",Ot="___external_value___",Eu=/\[([^\]]+)\]/;var Du=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],bu=["+","-","/","*","%","POW","RANDOM","L^"],Au=["INT","FLOOR","FLOAT"];function $t(r,e){if(r.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(r)&&(r=r.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!r.startsWith(".")))return r.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(r)&&r.includes("g-")){let n=r.split("g-");return ea(e)+"_|_"+"g-"+n[n.length-1]}let t=0;for(;new RegExp(/^\.\^.*$/).test(r);)t++,r=r.substring(2);if(t=t-1,new RegExp(/^\..*$/).test(r)&&e){let n=r.substring(1);return ea(e,t)+"_|_"+n.replaceAll(".","_|_")}return r.replaceAll(".","_|_")||ea(e,t).replaceAll(".","_|_")}function ea(r,e=0){let t=r.split("_|_");for(;t.length>1&&e>0;)t.pop()?.includes("g-")&&e--,e--;return t.join("_|_")}var xu="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function He(r){return r.startsWith("^")&&(r=r.substring(1)),r=r.replaceAll("\\\\",xu),r=r.replaceAll("\\n",`
59
+ ${S}`),S&&(o=true),s=w.getLogichValue(y.glueEnabled,e)||false,S)}),u=w.getLogichValue(l[0],e),h=typeof u=="object"&&"character"in u?u.character:void 0,c=l.flatMap(y=>{let d;y&&typeof y=="object"&&"text"in y?d=y.text:d=y;let S;return Array.isArray(d)?S=d.map(m=>{let v=w.getLogichValue(m,e);return Ne.t(`${v}`)}):S=w.getLogichValue(d,e)||"",Ne.t(S)}),p=a.find(y=>y.end),f=a.find(y=>y.choices),C=false,g=false;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&(narration.narration.dialogGlue=true),C=a[a.length-1].glueEnabled,g=a.reverse().find(y=>!(y.operations&&(!y.dialogue||!y.choices)))?.goNextStep);let b=a.find(y=>y.labelToOpen),E=[];return a.forEach(y=>{y.operations&&(E=[...E,...y.operations]);}),{dialogue:h?{character:h,text:c}:c,end:p?.end,choices:f?.choices,glueEnabled:C,goNextStep:g,labelToOpen:b?.labelToOpen,operations:E}}}var Ci;(r=>{let e=new Set;function t(a){e.add(a);}r.add=t;function n(){e.clear();}r.clear=n;function i(a,s={}){let o=h=>hu(h,s)??void 0,l=cu(a,s);if(e.size===0)return o(l);let u=o;for(let h of e){let c=u;u=p=>h(p,c)??void 0;}return u(l)}r.getLogichValue=i;})(Ci||={});var xd=Object.create,gu=Object.defineProperty,wd=Object.getOwnPropertyDescriptor,_d=Object.getOwnPropertyNames,Od=Object.getPrototypeOf,Td=Object.prototype.hasOwnProperty,pu=(r=>typeof xt<"u"?xt:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof xt<"u"?xt:e)[t]}):r)(function(r){if(typeof xt<"u")return xt.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')}),Cu=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Pd=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of _d(e))!Td.call(r,i)&&i!==t&&gu(r,i,{get:()=>e[i],enumerable:!(n=wd(e,i))||n.enumerable});return r},Fd=(r,e,t)=>(t=r!=null?xd(Od(r)):{},Pd(gu(t,"default",{value:r,enumerable:true}),r)),Nd=Cu((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 pu=="function")try{a=pu("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 y(){}return function(d){var S;return y.prototype=d,S=new y,y.prototype=null,S}})(),l={},u=l.lib={},h=u.Base=(function(){return {extend:function(y){var d=o(this);return y&&d.mixIn(y),(!d.hasOwnProperty("init")||this.init===d.init)&&(d.init=function(){d.$super.init.apply(this,arguments);}),d.init.prototype=d,d.$super=this,d},create:function(){var y=this.extend();return y.init.apply(y,arguments),y},init:function(){},mixIn:function(y){for(var d in y)y.hasOwnProperty(d)&&(this[d]=y[d]);y.hasOwnProperty("toString")&&(this.toString=y.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),c=u.WordArray=h.extend({init:function(y,d){y=this.words=y||[],d!=i?this.sigBytes=d:this.sigBytes=y.length*4;},toString:function(y){return (y||f).stringify(this)},concat:function(y){var d=this.words,S=y.words,m=this.sigBytes,v=y.sigBytes;if(this.clamp(),m%4)for(var x=0;x<v;x++){var O=S[x>>>2]>>>24-x%4*8&255;d[m+x>>>2]|=O<<24-(m+x)%4*8;}else for(var P=0;P<v;P+=4)d[m+P>>>2]=S[P>>>2];return this.sigBytes+=v,this},clamp:function(){var y=this.words,d=this.sigBytes;y[d>>>2]&=4294967295<<32-d%4*8,y.length=n.ceil(d/4);},clone:function(){var y=h.clone.call(this);return y.words=this.words.slice(0),y},random:function(y){for(var d=[],S=0;S<y;S+=4)d.push(s());return new c.init(d,y)}}),p=l.enc={},f=p.Hex={stringify:function(y){for(var d=y.words,S=y.sigBytes,m=[],v=0;v<S;v++){var x=d[v>>>2]>>>24-v%4*8&255;m.push((x>>>4).toString(16)),m.push((x&15).toString(16));}return m.join("")},parse:function(y){for(var d=y.length,S=[],m=0;m<d;m+=2)S[m>>>3]|=parseInt(y.substr(m,2),16)<<24-m%8*4;return new c.init(S,d/2)}},C=p.Latin1={stringify:function(y){for(var d=y.words,S=y.sigBytes,m=[],v=0;v<S;v++){var x=d[v>>>2]>>>24-v%4*8&255;m.push(String.fromCharCode(x));}return m.join("")},parse:function(y){for(var d=y.length,S=[],m=0;m<d;m++)S[m>>>2]|=(y.charCodeAt(m)&255)<<24-m%4*8;return new c.init(S,d)}},g=p.Utf8={stringify:function(y){try{return decodeURIComponent(escape(C.stringify(y)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(y){return C.parse(unescape(encodeURIComponent(y)))}},b=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new c.init,this._nDataBytes=0;},_append:function(y){typeof y=="string"&&(y=g.parse(y)),this._data.concat(y),this._nDataBytes+=y.sigBytes;},_process:function(y){var d,S=this._data,m=S.words,v=S.sigBytes,x=this.blockSize,O=x*4,P=v/O;y?P=n.ceil(P):P=n.max((P|0)-this._minBufferSize,0);var Y=P*x,ge=n.min(Y*4,v);if(Y){for(var Mt=0;Mt<Y;Mt+=x)this._doProcessBlock(m,Mt);d=m.splice(0,Y),S.sigBytes-=ge;}return new c.init(d,ge)},clone:function(){var y=h.clone.call(this);return y._data=this._data.clone(),y},_minBufferSize:0});u.Hasher=b.extend({cfg:h.extend(),init:function(y){this.cfg=this.cfg.extend(y),this.reset();},reset:function(){b.reset.call(this),this._doReset();},update:function(y){return this._append(y),this._process(),this},finalize:function(y){y&&this._append(y);var d=this._doFinalize();return d},blockSize:16,_createHelper:function(y){return function(d,S){return new y.init(S).finalize(d)}},_createHmacHelper:function(y){return function(d,S){return new E.HMAC.init(y,S).finalize(d)}}});var E=l.algo={};return l})(Math);return t});}),Id=Cu((r,e)=>{(function(t,n){typeof r=="object"?e.exports=r=n(Nd()):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 p=this._hash.words,f=p[0],C=p[1],g=p[2],b=p[3],E=p[4],y=0;y<80;y++){if(y<16)l[y]=h[c+y]|0;else {var d=l[y-3]^l[y-8]^l[y-14]^l[y-16];l[y]=d<<1|d>>>31;}var S=(f<<5|f>>>27)+E+l[y];y<20?S+=(C&g|~C&b)+1518500249:y<40?S+=(C^g^b)+1859775393:y<60?S+=(C&g|C&b|g&b)-1894007588:S+=(C^g^b)-899497514,E=b,b=g,g=C<<30|C>>>2,C=f,f=S;}p[0]=p[0]+f|0,p[1]=p[1]+C|0,p[2]=p[2]+g|0,p[3]=p[3]+b|0,p[4]=p[4]+E|0;},_doFinalize:function(){var h=this._data,c=h.words,p=this._nDataBytes*8,f=h.sigBytes*8;return c[f>>>5]|=128<<24-f%32,c[(f+64>>>9<<4)+14]=Math.floor(p/4294967296),c[(f+64>>>9<<4)+15]=p,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});}),fu="___param___",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||={});var Vd=class M{static init(e){e.loadAssets&&(M._loadAssets=e.loadAssets),e.soundOperation&&(M._soundOperation=e.soundOperation),e.imageOperation&&(M._imageOperation=e.imageOperation),e.videoOperation&&(M._videoOperation=e.videoOperation),e.imageContainerOperation&&(M._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(M._textOperation=e.textOperation),e.canvasElementOperation&&(M._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(M._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(M._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(M._narrationOperation=e.narrationOperation),e.effectOperation&&(M._effectOperation=e.effectOperation),e.animateOperation&&(M._animateOperation=e.animateOperation),e.getLogichValue&&(M._getLogichValue=e.getLogichValue),e.getConditionalStep&&(M._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return M._loadAssets}static _soundOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return M._soundOperation}static _imageOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return M._imageOperation}static _videoOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return M._videoOperation}static _imageContainerOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return M._imageContainerOperation}static _textOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return M._textOperation}static _canvasElementOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return M._canvasElementOperation}static _setStorageValue=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return M._setStorageValue}static _setInitialStorageValue=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return M._setInitialStorageValue}static _narrationOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return M._narrationOperation}static _effectOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return M._effectOperation}static _animateOperation=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return M._animateOperation}static _getLogichValue=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return M._getLogichValue}static _getConditionalStep=()=>{throw ie.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return M._getConditionalStep}};function kd(r,e){if(e&&typeof e=="object"&&typeof r.functionName=="string"&&r.functionName in e){let t=e[r.functionName];if(typeof t=="function"){let n=r.args.map(i=>Vd.getLogichValue(i,e));return t(...n)}else ie.warn(`getLogichValue function ${r.functionName} not found in props`);}}function Rd(r,e={}){let t="";return r.values.forEach(n=>{if(typeof n=="string")t+=n;else {let i=w.getLogichValue(n,e);t+=`${i}`;}}),t}async function yu(r,e,t){let n=w.getLogichValue(r,e);if(n)switch(n.type){case "sound":w.soundOperation(n);break;case "assets":case "bundle":await w.loadAssets(n);break;case "image":await w.imageOperation(n);break;case "video":await w.videoOperation(n);break;case "imagecontainer":await w.imageContainerOperation(n);break;case "text":await w.textOperation(n);break;case "canvaselement":await w.canvasElementOperation(n);break;case "value":w.setStorageValue(n,e);break;case "operationtoconvert":if(t){let i=Rd(n,e),a=await t(i);a&&await yu(a,e,t);}break;case "input":case "dialogue":w.narrationOperation(n);break;case "shake":await w.effectOperation(n);break;case "animate":case "animate-sequence":w.animateOperation(n);break;case "function":await kd(n,e);break}}function mu(r){let e=w.getLogichValue(r,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&w.setInitialStorageValue(e);}var Ld=Fd(Id()),Bd=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=w.getConditionalStep(a),a.operations)try{let s=a.operations.map(o=>w.loadAssets(o));await Promise.all(s);}catch(s){ie.error("The operation in the onLoadingLabel function of the label has an error:",s);}}},super(r,t),this._steps=e,this.operationStringConvert=n.operationStringConvert,this.skipEmptyDialogs=n.skipEmptyDialogs||false;}_steps;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)}operationStringConvert;skipEmptyDialogs=false;getStepSha(r){if(r<0||r>=this.steps.length)return;let e=this._steps[r];return (0, Ld.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(r,e){let t="";if(Array.isArray(r)){let n=[];r.forEach(i=>{if(typeof i=="string")n.push(i);else if(i&&typeof i=="object"){let a=w.getLogichValue(i,e);a?(a&&!Array.isArray(a)&&typeof a=="object"&&(a=w.getLogichValue(a,e)||""),Array.isArray(a)?n=n.map(s=>`${s}`).concat(a):n.push(`${a}`)):n.push(`${i}`);}else n.push(`${i}`);}),t=n;}else {let n=w.getLogichValue(r,e);n&&!Array.isArray(n)&&typeof n=="object"&&(n=w.getLogichValue(n,e)),n&&Array.isArray(n)?t=n.map(i=>`${i}`):t=`${n}`;}return t}getDialogue(r,e){if(r==null)return;let t=w.getLogichValue(r,e);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:Ne.t(this.getDialogueText(t.text,e))}:Ne.t(this.getDialogueText(t,e))}getChoices(r,e){return w.getLogichValue(r,e)?.map(t=>w.getLogichValue(t,e)).filter(t=>t!==void 0)}stepConverter(r){return async e=>{let t=typeof r=="function"?r():r;t=pixiVn.createExportableElement(t),t=w.getConditionalStep(t,e);let n=this.operationStringConvert?p=>this.operationStringConvert(p,t,e):void 0,{operations:i=[]}=t;for(let p of i)await yu(p,e,n);let{labelToOpen:a=[]}=t,s=this.getChoices(t.choices,e),o=w.getLogichValue(t.glueEnabled,e),l=this.getDialogue(t.dialogue,e),u=[];Array.isArray(a)||(a=[a]),a.forEach(p=>{let f=w.getLogichValue(p,e);f&&u.push(f);});let h=w.getLogichValue(t.goNextStep,e),c=w.getLogichValue(t.end,e);if(s){let p=s.map(f=>{let C="";if(Array.isArray(f.text)){let g=[];f.text.forEach(b=>{if(typeof b=="string")g.push(Ne.t(b));else if(b&&typeof b=="object"){let E=w.getLogichValue(b,e);E&&!Array.isArray(E)&&typeof E=="object"&&(E=w.getLogichValue(E,e)||""),E&&(Array.isArray(E)?g=g.concat(Ne.t(E)):g.push(Ne.t(E)));}}),C=g;}else typeof f.text=="string"&&(C=Ne.t(f.text));return {label:f.label,text:C,props:f.props,type:f.type,oneTime:f.oneTime,onlyHaveNoChoice:f.onlyHaveNoChoice,autoSelect:f.autoSelect}});narration.narration.choices=p;}else narration.narration.choices=void 0;l!==void 0&&(narration.narration.dialogue=l,this.skipEmptyDialogs&&typeof l=="string"&&(l===""||RegExp(/^\s+$/).test(l))&&(h=true)),o?narration.narration.dialogGlue=true:o===false&&(narration.narration.dialogGlue=false);for(let p of u){let f=p.label;typeof f=="object"&&(f=w.getLogichValue(f,e)||"");let C=p.params?.map(g=>w.getLogichValue(g,e));e={...e,...p.props},p.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${fu}${narration.narration.openedLabels.length}`,C),await narration.narration.call(f,e)):(storage.storage.setTempVariable(`${fu}${narration.narration.openedLabels.length}`,C),await narration.narration.call(f,e));}c==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(e,{runNow:true})):c==="label_end"&&narration.narration.closeCurrentLabel(),h&&await narration.narration.continue(e,{runNow:true});}}};async function Qs(r,e={}){if(!Array.isArray(r))if(typeof r=="object"||typeof r=="string")r=[r];else {ie.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let t=r.map(a=>{if(typeof a=="string")try{return JSON.parse(a)}catch(s){return ie.error("Error parsing imported Pixi'VN JSON",s),{}}return a}),n=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)s.type==="value"&&(typeof s.value!="object"||!s.value||!("type"in s.value))&&mu(s);return Promise.resolve()});await Promise.all(n);let i=t.map(async a=>{if(a.initialOperations)for(let s of a.initialOperations)(s.type!=="value"||s.type==="value"&&typeof s.value=="object"&&s.value&&"type"in s.value)&&mu(s);if(a.labels){let s=a.labels;for(let o in s)try{let l=s[o],u=new Bd(o,l,void 0,e);narration.RegisteredLabels.add(u);}catch(l){ie.error(`Error creating JSON label ${o}`,l);}}return Promise.resolve()});await Promise.all(i);}var Wd={version:"1.13.12"};var vu=`https://pixi-vn.com/schemas/${Wd.version}/schema.json`,Su=["==","!=","<","<=",">",">=","CONTAINS"];function Zs(){w.init({animateOperation:ru,canvasElementOperation:nu,effectOperation:iu,imageContainerOperation:eu,imageOperation:Ql,textOperation:tu,narrationOperation:su,loadAssets:Yl,soundOperation:au,videoOperation:Zl,setStorageValue:lu,setInitialStorageValue:uu,getLogichValue:Ci.getLogichValue,getConditionalStep:gi});}var yi="global decl",Ot="___external_value___",Eu=/\[([^\]]+)\]/;var Du=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],bu=["+","-","/","*","%","POW","RANDOM","L^"],Au=["INT","FLOOR","FLOAT"];function $t(r,e){if(r.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(r)&&(r=r.split(".").filter(i=>!i.match(/^[0-9]+$/)).join("."),!r.startsWith(".")))return r.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(r)&&r.includes("g-")){let n=r.split("g-");return ea(e)+"_|_"+"g-"+n[n.length-1]}let t=0;for(;new RegExp(/^\.\^.*$/).test(r);)t++,r=r.substring(2);if(t=t-1,new RegExp(/^\..*$/).test(r)&&e){let n=r.substring(1);return ea(e,t)+"_|_"+n.replaceAll(".","_|_")}return r.replaceAll(".","_|_")||ea(e,t).replaceAll(".","_|_")}function ea(r,e=0){let t=r.split("_|_");for(;t.length>1&&e>0;)t.pop()?.includes("g-")&&e--,e--;return t.join("_|_")}var xu="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function He(r){return r.startsWith("^")&&(r=r.substring(1)),r=r.replaceAll("\\\\",xu),r=r.replaceAll("\\n",`
60
60
  `),r=r.replaceAll("\\t"," "),r=r.replaceAll(" "," "),r=r.replaceAll(xu,"\\\\"),r}function pt(r,e,t,n){let{functions:i}=n;r=r.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return r.forEach(s=>{if(typeof s=="string")switch(s){case "&&":case "||":if(a.length>=2){let o={type:"union",unionType:s==="&&"?"and":"or",conditions:[a[a.length-2],a[a.length-1]]};a.pop(),a.pop(),a.push(o);}break;case "!":if(a.length===0)L.error("Error parsing ink file: Conditional statement is not valid",r);else {let o={type:"union",unionType:"not",condition:a[a.length-1]};a[a.length-1]=o;}break;case "!?":if(a.length>1){let o={type:"union",unionType:"not",condition:{type:"compare",operator:"CONTAINS",leftValue:a[a.length-2],rightValue:a[a.length-1]}};a.pop(),a.pop(),a.push(o);}else L.error("Error parsing ink file: Conditional statement is not valid",r);break;default:if(Su.includes(s))if(a.length<2)L.error("Error parsing ink file: Conditional statement is not valid",r);else {let o={type:"compare",operator:s,rightValue:a[a.length-1],leftValue:a[a.length-2]};a.pop(),a.pop(),a.push(o);}else if(bu.includes(s))if(a.length<2)L.error("Error parsing ink file: Conditional statement is not valid",r);else {s==="L^"&&(s="INTERSECTION");let o={type:"arithmetic",operator:s,rightValue:a[a.length-1],leftValue:a[a.length-2]};a.pop(),a.pop(),a.push(o);}else if(Au.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(He(s));}else if(typeof s=="object"&&"CNT?"in s)if(new RegExp(/.*\.[0-9]\..*/).test(s["CNT?"])){let o=s["CNT?"].split("."),l=o.pop(),u=o.pop();if(u===void 0||l===void 0){L.error("Error parsing ink file: Conditional statement is not valid",r);return}let h=Number(u),c=o.join(".");if(c.includes("^.")){let f=c.split("."),C=f[f.length-1].replaceAll(".","_|_");f.pop(),c=`${f.join(".")}.${C}`,l.includes("c-")&&(c=c+"_|_"+l);}else c=c.replaceAll(".","_|_");let p=$t(c,e);if(!p)return;a.push({type:"compare",leftValue:ta(p),operator:">=",rightValue:{type:"value",value:h}});}else {let o=$t(s["CNT?"],e);if(!o)return;a.push(ta(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(Tt({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],l=i.find(h=>h.name===o);if(!l){L.error(`Error parsing ink file: Function ${o} is not defined`,r);return}let u=[];for(let h=0;h<l.args;h++)a.length!==0&&u.push(a.pop());a.push({type:"function",functionName:o,args:u.reverse()});}else if(typeof s=="object"&&"^->"in s)s["^->"].includes("$r")||a.push(s["^->"]);else if(typeof s=="object"&&"list"in s){let o=Object.values(s.list).map(l=>l);a.push(o);}else a.push(s);}),a}function na(r,e,t,n){return pt(r,e,t,n)}function Tt(r,e,t){let{key:n,defaultType:i}=r,a=e.indexOf(n);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:i,key:n}}function bn(r,e,t){let{key:n,value:i,defaultType:a,artmeticValue:s}=r,o=e.indexOf(n);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:i}];if(s){if(typeof i=="object"&&"list"in i){let l=Object.values(i.list).map(u=>u);return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:l}]}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:i}]}else if(typeof i=="object"){if("list"in i&&typeof i.list=="object"){if("origins"in i&&Array.isArray(i.origins)&&i.origins.length>0)return i.origins.reduce(l=>(l.push({type:"value",storageOperationType:"set",storageType:a,key:n,value:Object.values(t.enums[n])}),Object.entries(t.enums[n]).forEach(([u,h])=>{l.push({type:"value",storageOperationType:"set",storageType:a,key:`${n}.${u}`,value:h});}),l),[]);{let l=new Set,u=Object.entries(i.list).reduce((h,[c,p])=>{let[f,C]=c.split(".");return h.push({type:"value",storageOperationType:"set",storageType:a,key:C,value:p}),l.add(f),h},[]);return l.forEach(h=>{u.push({type:"value",storageOperationType:"set",storageType:a,key:h,value:Object.values(t.enums[h])});}),n in t.enums?Object.entries(t.enums[n]).forEach(([h,c])=>{u.push({type:"value",storageOperationType:"set",storageType:a,key:`${n}.${h}`,value:c});}):u.push({type:"value",storageOperationType:"set",storageType:a,key:n,value:Object.values(i.list)}),u}}else if(typeof i=="object"&&"VAR?"in i){if(typeof i["VAR?"]=="string"&&i["VAR?"].includes(".")){let[l,u]=i["VAR?"].split(".");if(l in t.enums&&u in t.enums[l])return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:t.enums[l][u]}]}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:Tt({key:i["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:i}]}function ta(r){return {type:"value",storageType:"label",storageOperationType:"get",label:r}}function ia(r,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(r)?"call":"jump"}function vi(r,e){if(e){if(typeof e=="string")e.startsWith("^")&&r.push(He(e));else if(typeof e=="object"&&"type"in e)switch(e.type){case "value":case "function":console.warn("Warning: trying to add a value or function operation as text. This is likely a mistake, so it will be ignored.");break;default:r.push(e);}}}function ra(r,e,t,n,i,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:l=false}=a;return qd(r,e,t,n,i,{isNewLine:s,isHashtagScript:o,isThreads:l})}function qd(r,e,t,n,i,a){if(!e)return;let{isNewLine:s,isHashtagScript:o=false,isThreads:l}=a;if(o){if(Array.isArray(e)&&e.length>0){let u={goNextStep:true},h=[];try{if(e.length===1&&typeof e[0]=="string"&&!e[0].match(Eu)){let c=e[0],p=Je.convertTagTolist(c),f=Je.convertOperation(p,u,{silent:!0});f&&(f.$origin=c,h.push(f));}}catch{}h.length===0&&h.push({type:"operationtoconvert",values:e}),r.push({...u,operations:h});}}else if(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"){if(!s&&r.length>0){let u=r[r.length-1];!u.glueEnabled&&!u.operations&&!u.labelToOpen&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),r[r.length-1]=u;}typeof e=="string"?r.push(Md(He(e),n.characterIds)):r.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")r.push({end:"game_end"});else if(e==="done")r.push({end:"label_end",goNextStep:true});else if(e==="<>")if(r.length>0){let u=r[r.length-1];u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true),r[r.length-1]=u;}else r.push({glueEnabled:true,goNextStep:false});}else if(typeof e=="object"){if("type"in e)switch(e.type){case "value":e.storageOperationType==="set"?(typeof e.value=="string"&&e.value.startsWith("^")&&(e.value=He(e.value)),r.push({goNextStep:true,operations:[e]})):console.warn("Warning: trying to add a value get operation as step. This is likely a mistake, so it will be ignored.");break;case "function":r.push({goNextStep:true,operations:[e]});break;default:if(!s&&r.length>0){let u=r[r.length-1];!u.glueEnabled&&!u.operations&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),r[r.length-1]=u;}r.push({conditionalStep:e});}else if("->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&r.length>0&&r[r.length-1]?.dialogue===void 0&&(u=void 0),!s&&r.length>0){let h=r[r.length-1];h.labelToOpen||(h.goNextStep=true),r[r.length-1]=h;}if(e.params&&e.params.length===0&&delete e.params,e.var)r.push({labelToOpen:{label:Tt({key:e["->"],defaultType:"storage"},i),type:l?"call":"jump",params:e.params},glueEnabled:u});else {let h=$t(e["->"],t);if(!h)return;r.push({labelToOpen:{label:h,type:ia(h,l),params:e.params},glueEnabled:u});}}else if("->t->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&r.length>0&&r[r.length-1]?.dialogue===void 0&&(u=void 0),!s&&r.length>0){let c=r[r.length-1];c.labelToOpen||(c.goNextStep=true),r[r.length-1]=c;}e.params&&e.params.length===0&&delete e.params;let h=$t(e["->t->"],t);if(!h)return;r.push({labelToOpen:{label:h,type:"call",params:e.params},glueEnabled:u});}}}function Md(r,e){let t;if(r.includes(": ")){let n=r.split(": "),i=n[0],a=n.slice(1).join(": ");(e?.has(i)||characters.RegisteredCharacters.has(i))&&(t=i,r=a);}return t?{dialogue:{character:t,text:r}}:{dialogue:r}}function sa(r,e,t,n=true,i=false){return Gd(r,e,t,n,i)}function Gd(r,e,t,n,i=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?r.push(He(e)):r.push(e):typeof e=="object"&&"type"in e&&r.push(e));}function Si(r,e,t,n){if(r.length===0){L.error("Error parsing ink file: Arithmetic statement is not valid",r);return}let i=pt(r,e,t,n);if(i.length===1){let a=i[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function Jt(r,e,t,n="",i,a,s=void 0){let o=[],l="sequential",u=false,h=true;r.forEach(f=>{f==="%"&&(l="loop"),f==="seq"&&(l="random"),f==="MIN"&&(u=true);});let c=r[r.length-1];return Object.keys(c).forEach(f=>{let C=c[f];if(Array.isArray(C)&&C.length>3){C=C.slice(1,C.length-2);let g=[];ft(C,n,i,g,e,e,t,Ht,s,true,a),g.length===1?o.push(g[0]):o.push({type:"resulttocombine",combine:"cross",secondConditionalItem:g});}else Array.isArray(C)&&C.length===3&&(h=false);}),l==="sequential"?{type:"stepswitch",elements:o,choiceType:l,end:h?"lastItem":void 0,nestedId:s}:u&&l==="random"?{type:"stepswitch",elements:o,choiceType:"sequentialrandom",end:h?"lastItem":void 0,nestedId:s}:{type:"stepswitch",elements:o,choiceType:l}}function ft(r,e,t,n=[],i,a,s,o,l=void 0,u=true,h=[]){let c=false,p=[],f=false,C=false,g=false,b=[],E=[];if(t.preDialog[e]&&(u=false,i(n,`^${t.preDialog[e].text}`,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),t.preDialog[e].glue&&i(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),delete t.preDialog[e]),r.includes("visit")){let d=Jt(r,a,s,e,t,h,l);d&&(!u&&n.length>0&&i(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}));return}let y=r[0];if(y&&typeof y=="object"&&"temp="in y){for(;r[0]&&typeof r[0]=="object"&&"temp="in r[0];)h.push(r[0]["temp="]),r.shift();h=h.reverse();}if(r.forEach((d,S)=>{if(C){if(typeof d=="string"&&d==="/#"){let m=[];ft(E,e,t,m,sa,sa,s,o,l,u),i(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),C=false,E=[];}else E.push(d);return}else if(c)if(Array.isArray(d))p.push(d);else if(d&&typeof d=="object")"CNT?"in d?S>0&&r[S-1]==="ev"?(f=true,b.push(d)):f?b.push(d):(p.push(d),u=false):"VAR="in d||"temp="in d?bn({key:"VAR="in d?d["VAR="]:d["temp="],value:r[S-1],defaultType:"VAR="in d?"storage":"tempstorage"},h,t).forEach(v=>{if(v.value&&typeof v.value=="string"&&v.value==="/str"&&(v.value=r[S-2]),v.value&&typeof v.value=="object"&&"^->"in v.value&&(v.value=v.value["^->"]),p.length>1){let x=Si(p,e,h,t);p=[],x&&typeof x=="object"&&"type"in x&&x.type==="value"&&"storageType"in x&&x.storageType==="logic"&&(v.value=x.operation);}(typeof v.key!="string"||!v.key.includes("$r"))&&(i(n,v,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=true);}):"VAR?"in d?p.push(d):"^->"in d?d["^->"].includes("$r")||p.push(d):("f()"in d||"list"in d&&typeof d.list=="object")&&p.push(d);else switch(d){case "/ev":f&&b.push(d),c=false,p.push(d);break;case "out":if(p.length>0){let m=p[p.length-1];if(m&&typeof m=="object"&&"VAR?"in m){p.pop();let v=Tt({key:m["VAR?"],defaultType:"storage"},h);i(n,v,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}else {let v=[];for(;p.length>0&&p[p.length-1]!=="/ev";)v.push(p.pop());v=v.reverse();let x=Si(v,e,h,t);p=[],x&&typeof x=="object"&&"type"in x&&x.type==="value"&&"storageType"in x&&x.storageType==="logic"?i(n,{storageOperationType:"get",storageType:"logic",operation:x.operation,type:"value"},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):(i(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),x=`^${x}`,i(n,x,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}));}u=false;}break;case "pop":{let m=p[p.length-1];if(m&&typeof m=="object"&&"f()"in m){let v=[];for(;p.length>0&&p[p.length-1]!=="/ev";)v.push(p.pop());v=v.reverse();let x=pt(v,e,h,t);p=[],x.forEach(O=>{O&&typeof O=="object"&&"type"in O&&O.type==="function"?i(n,O,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):L.warn("Unhandled case: value is not a function",O);}),u=false;}else p.push(d);return}default:p.push(d);}else if(typeof d=="string")if(d.startsWith("^"))i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="ev")c=true;else if(d===`
61
- `)u=true;else if(d==="done"||d==="end")i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="<>")i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="nop"&&f){let m=wu(b,a,s,e,t,h,l);m&&i(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),f=false,b=[];}else d==="#"?C=true:d==="thread"&&(g=true);else if(Array.isArray(d))if(f)b.push(d);else if(d.length>1&&typeof d[d.length-2]=="object"&&d[d.length-2]&&"c"in d[d.length-2]&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"b"in d[d.length-1]){p.pop();let m=[],v=[];for(;p.length>0&&p[p.length-1]!=="/ev";)m.push(p.pop());b=[...b,...m.reverse()],f=true,v.push(d.pop()),v.push(d.pop()),b=[...b,...d],b.push(v);}else if(d.length>1&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"#n"in d[d.length-1]){let m=d.pop();if(!m){L.error("Error parsing ink file: el is undefined");return}let v=m["#n"];delete m["#n"],d.push(m),i(n,{"->":e?e+"_|_"+v:v},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),s({[v]:d},e,t);}else ft(d,e,t,n,i,a,s,o,l,u,h);else if(d&&typeof d=="object")if("->"in d&&typeof d["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->"])){let m=[];p.length>0&&(m=na(["ev",...p],e,h,t)),d.params=m,i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;}else if("->t->"in d&&typeof d["->t->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->t->"])){let m=[];p.length>0&&(m=na(["ev",...p],e,h,t)),d.params=m,i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;}else if("*"in d&&typeof d["*"]=="string")d["*"].includes("c")&&(p.push(d),u=false);else if("s"in d&&Array.isArray(d.s))p.push(d),u=false;else if("CNT?"in d)p.push(d),u=false;else if("VAR="in d||"temp="in d){let m="VAR="in d?d["VAR="]:d["temp="],v,x=[];if(m!=="$r"){for(p.pop(),p[p.length-1]==="/ev"&&p.pop();p.length>0&&p[p.length-1]!=="/ev";)x.push(p.pop());x=x.reverse(),v=Si(x,e,h,t),p=[],bn({key:m,value:v,defaultType:"VAR="in d?"storage":"tempstorage",artmeticValue:true},h,t).forEach(P=>{(P.value!==void 0||P.value!==null)&&i(n,P,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}),u=false;}}else s(d,e,t);}),o(p,n,e,t,h),e.includes("_|_")&&n.length===2){let d=n[0],S=n[1];d&&S&&typeof d=="object"&&"dialogue"in d&&typeof S=="object"&&"labelToOpen"in S&&d.dialogue===" "&&S.labelToOpen&&(n.shift(),delete S.glueEnabled,n[0]=S);}}function oa(r,e,t,n,i,a){if(e.length===0)return;let s=pt(e,n,t,i);if(s.length===1){let o={type:"ifelse",condition:s[0],then:r,else:a};return o.else||delete o.else,o}else if(s.length>1){let o={type:"ifelse",condition:{type:"union",unionType:"and",conditions:s},then:r,else:a};return o.else||delete o.else,o}}function wu(r,e,t,n,i,a,s=void 0){if(r.length===0){L.error("Error parsing ink file: Conditional statement is not valid",r);return}let o=[],l=[];if(r.forEach(c=>{Array.isArray(c)?l.push(c):typeof c=="string"&&c==="du"?i.du?o.push(i.du):i.du=o[o.length-1]:(typeof c!="string"||c!=="/ev")&&o.push(c);}),l.length===0){L.error("Error parsing ink file: Conditional statement is not valid",l);return}let u=aa(l[0],e,t,`${n}${"_|_"}then`,i,a,`${s||""}then`),h;return l.length===2?h=aa(l[1],e,t,`${n}${"_|_"}else`,i,a,`${s||""}else`):l.length>2?(l.shift(),l.push("nop"),l=[{b:l}],h=aa(l,e,t,`${n}${"_|_"}else`,i,a,`${s||""}else`)):h=void 0,i.du=void 0,oa(u,o,a,n,i,h)}function aa(r,e,t,n,i,a,s=void 0){let o=[];for(let u of r)typeof u=="object"&&"b"in u&&(u.b=u.b.filter(h=>h!==null&&!(typeof h=="object"&&"->"in h&&new RegExp(/.*\.[0-9]/).test(h["->"]))),ft(u.b,n,i,o,e,e,t,Ht,s,true,a));return o.length===1?o[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:o}}function la(r="",e=""){let t=Array.isArray(r)?r:[r],n=Array.isArray(e)?e:[e];return [...new Set([...t,...n])]}function Ht(r,e,t,n,i){if(r.length>0){let a={};_u(r,a,i,n);for(let[s,o]of Object.entries(a)){let l=t+"_|_"+s,u={text:o.text.length===1?o.text[0]:o.text,label:l,props:{},type:ia(l,false),oneTime:o.onetime};o.text.length===0&&(u.onlyHaveNoChoice=true,u.autoSelect=true),u.oneTime===false&&delete u.oneTime;let h=oa(u,o.conditions,i,t,n)||u,c=e[e.length-1];if(typeof c=="object"&&c&&"type"in c&&(c={conditionalStep:c}),e.length>0&&typeof c=="object"&&c&&"choices"in c&&c.choices){let p=c.choices;p&&Array.isArray(p)?p.push(h):L.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",o,p),c.choices=p.sort((f,C)=>{try{let g=f.label.split("."),b=g[g.length-1].replaceAll(".","_|_"),E=C.label.split("."),y=E[E.length-1].replaceAll(".","_|_");if(b.includes("c-")&&y.includes("c-")){let d=b.split("c-")[1],S=Number(d),m=y.split("c-")[1],v=Number(m);return S-v}}catch{}return 0});}else e.push({choices:[h]});o.preDialog&&(n.preDialog[l]={...o.preDialog});}}}function _u(r,e,t,n,i){let a=[],s="",o="",l=false,u=[];for(let h=0;h<r.length;h++){let c=r[h];if(typeof c=="string")c.startsWith("^")?a.push(He(c)):Du.includes(c)&&u.push(c);else if(Array.isArray(c)&&c.includes("visit")){let p=Jt(c,vi,(f,C,g)=>{},i,n,t);a.push(p);}else if(c&&typeof c=="object")if("*"in c&&typeof c["*"]&&typeof c["*"]=="string")c["*"].includes("c")&&(s=`c${c["*"].split("c")[1]}`,c.flg&16&&(l=true));else if("s"in c&&Array.isArray(c.s)){let p=Ou(c.s),f=c.s.includes("<>");p&&(i&&e[i]?(e[i].preDialog={text:p,glue:f},e[i].text=la(p,e[i].text)):(a.push(p),o=p));}else ("CNT?"in c||"VAR?"in c)&&u.push(c);else u.push(c);if(s){e[s]?e[s].text=la(a,e[s].text):e[s]={text:a,onetime:l,conditions:u},o&&(e[s].preDialog={text:o,glue:false});let p=r.slice(h+1);_u(p,e,t,n,s);return}}}function Ou(r){for(let e of r)if(typeof e=="string"){if(e.startsWith("^"))return He(e)}else if(Array.isArray(e)){let t=Ou(e);if(t)return t}}var ua;(i=>{function r(a,s={}){let{labelToRemove:o=[],initialVarsToRemove:l=[],enums:u={},functions:h=[],preDialog:c={},characterIds:p}=s,f={$schema:vu};if(f.labels=e(a.root,{labelToRemove:o,initialVarsToRemove:l,enums:u,functions:h,preDialog:c,characterIds:p}),f.labels&&yi in f.labels){let C=f.labels[yi];delete f.labels[yi],C.forEach(g=>{g.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...g.operations]:[...g.operations]);});}if(f.labels&&Ot in f.labels){let C=f.labels[Ot];delete f.labels[Ot],C.forEach(g=>{g.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...g.operations]:[...g.operations]);});}return o.forEach(C=>{f.labels&&C in f.labels&&delete f.labels[C];}),l.forEach(C=>{f.initialOperations&&(f.initialOperations=f.initialOperations.filter(g=>!(g.type==="value"&&g.key===C)));}),f}i.inkToJson=r;function e(a,s){try{let o={};return t(a,o,s),o}catch(o){L.error("Error parsing ink file",o);}}function t(a,s,o){for(let l of a)if(l)if(Array.isArray(l))if(l.includes("visit")){let u=Jt(l,vi,(h,c,p)=>{},"",o,[]);u&&(o.externalSwitch=u);}else t(l,s,o);else typeof l=="object"&&(l&&"VAR="in l&&o.externalSwitch&&(s[Ot]||(s[Ot]=[]),s[Ot].push({operations:bn({defaultType:"storage",key:l["VAR="],value:o.externalSwitch},[],o)})),n(l,s,"",o));}function n(a,s,o="",l){if(a!==null){for(let[u,h]of Object.entries(a))if(Array.isArray(h)){let c=[],p={},f=(o?o+"_|_":"")+u;ft(h,f,l,c,ra,ra,(C,g,b)=>{n(C,p,g,b);},Ht);for(let[C,g]of Object.entries(p))s[C]=g;c.length>0&&(s[f]=c);}}}})(ua||={});var bc=$s(Ec()),Ac=$s(zt()),VC=/(?:^|<>)\s*#\s*([^\r\n]+)/g,kC=/^=+[ \t]+(?:function[ \t]+)?(\w+)/gm,RC=new Set(["DONE","END"]),LC="_|_",Dc=new Map;function xc(r,e){let t=JSON.stringify([e,r]),n=Dc.get(t);if(n)return n;let i=new RegExp(r,e);return Dc.set(t,i),i}function li(r,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(s=>li(r,s));let i=t.oneOf;if(Array.isArray(i))return i.some(s=>li(r,s));let a=t.allOf;if(Array.isArray(a))return a.every(s=>li(r,s));if(typeof t.const=="string")return r===t.const;if(Array.isArray(t.enum))return t.enum.some(s=>typeof s=="string"&&s===r);if(t.type!=="string"||typeof t.minLength=="number"&&r.length<t.minLength||typeof t.maxLength=="number"&&r.length>t.maxLength)return false;if(typeof t.pattern=="string")try{if(!xc(t.pattern,"").test(r))return !1}catch{return false}return true}function Gs(r,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(o=>Gs(r,o));let i=t.oneOf;if(Array.isArray(i))return i.some(o=>Gs(r,o));let a=t.allOf;if(Array.isArray(a))return a.every(o=>Gs(r,o));if(t.type!=="array"||typeof t.minItems=="number"&&r.length<t.minItems||typeof t.maxItems=="number"&&r.length>t.maxItems)return false;let s=Array.isArray(t.prefixItems)?t.prefixItems:[];if(r.length<s.length)return false;for(let o=0;o<s.length;o++)if(!li(r[o],s[o]))return false;return r.length===s.length?true:t.items===false||typeof t.items>"u"?false:t.items===true?true:r.slice(s.length).every(o=>li(o,t.items))}function BC(r,e){if(e.type==="regexp")try{let t=xc(e.source,e.flags);return t.lastIndex=0,t.test(r.join(" "))}catch{return false}return e.type==="literal"?r.join(" ")===e.value:Gs(r,e.schema)}function WC(r){let e=r.split(/\r?\n/),t=[];for(let n=0;n<e.length;n++){let i=e[n];for(let a of i.matchAll(VC)){let s=(a[1]??"").trim();if(!s)continue;let o=Je.convertTagTolist(s,{mergeInkVariables:true});o.length!==0&&t.push({line:n+1,command:s,tokens:o});}}return t}var Fl;(i=>{function r(a,s={labelToRemove:[],initialVarsToRemove:[],functions:[],enums:{}}){let o=[];try{return {json:new bc.Compiler(a,{errorHandler:(c,p)=>{let f=c.replace(/^[A-Z]+: line \d+: ?/,""),C=c.match(/line (\d+)/);o.push({message:f,type:p,line:C?Number(C[1]):-1});},countAllVisits:!0,fileHandler:{ResolveInkFilename:c=>c,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:o}}catch{let u=false,h={...s,textSource:a};return e(o,()=>{u=true;},h),u?r(h.textSource,s):{issues:o}}}i.compile=r;function e(a,s,o){let{functions:l,initialVarsToRemove:u,labelToRemove:h}=o,c=a.find(p=>p.type===Ac.ErrorType.Error);if(c){if(c.message.includes("Divert target not found")){let p=c.message.match(/Divert target not found: '-> (\w+)'/);if(p?.[1]){let f=p[1],C=`
61
+ `)u=true;else if(d==="done"||d==="end")i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="<>")i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="nop"&&f){let m=wu(b,a,s,e,t,h,l);m&&i(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),f=false,b=[];}else d==="#"?C=true:d==="thread"&&(g=true);else if(Array.isArray(d))if(f)b.push(d);else if(d.length>1&&typeof d[d.length-2]=="object"&&d[d.length-2]&&"c"in d[d.length-2]&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"b"in d[d.length-1]){p.pop();let m=[],v=[];for(;p.length>0&&p[p.length-1]!=="/ev";)m.push(p.pop());b=[...b,...m.reverse()],f=true,v.push(d.pop()),v.push(d.pop()),b=[...b,...d],b.push(v);}else if(d.length>1&&typeof d[d.length-1]=="object"&&d[d.length-1]&&"#n"in d[d.length-1]){let m=d.pop();if(!m){L.error("Error parsing ink file: el is undefined");return}let v=m["#n"];delete m["#n"],d.push(m),i(n,{"->":e?e+"_|_"+v:v},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),s({[v]:d},e,t);}else ft(d,e,t,n,i,a,s,o,l,u,h);else if(d&&typeof d=="object")if("->"in d&&typeof d["->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->"])){let m=[];p.length>0&&(m=na(["ev",...p],e,h,t)),d.params=m,i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;}else if("->t->"in d&&typeof d["->t->"]=="string"&&!new RegExp(/^\.\^\.\^\.\d\.s$/).test(d["->t->"])){let m=[];p.length>0&&(m=na(["ev",...p],e,h,t)),d.params=m,i(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;}else if("*"in d&&typeof d["*"]=="string")d["*"].includes("c")&&(p.push(d),u=false);else if("s"in d&&Array.isArray(d.s))p.push(d),u=false;else if("CNT?"in d)p.push(d),u=false;else if("VAR="in d||"temp="in d){let m="VAR="in d?d["VAR="]:d["temp="],v,x=[];if(m!=="$r"){for(p.pop(),p[p.length-1]==="/ev"&&p.pop();p.length>0&&p[p.length-1]!=="/ev";)x.push(p.pop());x=x.reverse(),v=Si(x,e,h,t),p=[],bn({key:m,value:v,defaultType:"VAR="in d?"storage":"tempstorage",artmeticValue:true},h,t).forEach(P=>{(P.value!==void 0||P.value!==null)&&i(n,P,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}),u=false;}}else s(d,e,t);}),o(p,n,e,t,h),e.includes("_|_")&&n.length===2){let d=n[0],S=n[1];d&&S&&typeof d=="object"&&"dialogue"in d&&typeof S=="object"&&"labelToOpen"in S&&d.dialogue===" "&&S.labelToOpen&&(n.shift(),delete S.glueEnabled,n[0]=S);}}function oa(r,e,t,n,i,a){if(e.length===0)return;let s=pt(e,n,t,i);if(s.length===1){let o={type:"ifelse",condition:s[0],then:r,else:a};return o.else||delete o.else,o}else if(s.length>1){let o={type:"ifelse",condition:{type:"union",unionType:"and",conditions:s},then:r,else:a};return o.else||delete o.else,o}}function wu(r,e,t,n,i,a,s=void 0){if(r.length===0){L.error("Error parsing ink file: Conditional statement is not valid",r);return}let o=[],l=[];if(r.forEach(c=>{Array.isArray(c)?l.push(c):typeof c=="string"&&c==="du"?i.du?o.push(i.du):i.du=o[o.length-1]:(typeof c!="string"||c!=="/ev")&&o.push(c);}),l.length===0){L.error("Error parsing ink file: Conditional statement is not valid",l);return}let u=aa(l[0],e,t,`${n}${"_|_"}then`,i,a,`${s||""}then`),h;return l.length===2?h=aa(l[1],e,t,`${n}${"_|_"}else`,i,a,`${s||""}else`):l.length>2?(l.shift(),l.push("nop"),l=[{b:l}],h=aa(l,e,t,n,i,a,`${s||""}else`)):h=void 0,i.du=void 0,oa(u,o,a,n,i,h)}function aa(r,e,t,n,i,a,s=void 0){let o=[];for(let u of r)typeof u=="object"&&"b"in u&&(u.b=u.b.filter(h=>h!==null&&!(typeof h=="object"&&"->"in h&&new RegExp(/.*\.[0-9]/).test(h["->"]))),ft(u.b,n,i,o,e,e,t,Ht,s,true,a));return o.length===1?o[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:o}}function la(r="",e=""){let t=Array.isArray(r)?r:[r],n=Array.isArray(e)?e:[e];return [...new Set([...t,...n])]}function Ht(r,e,t,n,i){if(r.length>0){let a={};_u(r,a,i,n);for(let[s,o]of Object.entries(a)){let l=t+"_|_"+s,u={text:o.text.length===1?o.text[0]:o.text,label:l,props:{},type:ia(l,false),oneTime:o.onetime};o.text.length===0&&(u.onlyHaveNoChoice=true,u.autoSelect=true),u.oneTime===false&&delete u.oneTime;let h=oa(u,o.conditions,i,t,n)||u,c=e[e.length-1];if(typeof c=="object"&&c&&"type"in c&&(c={conditionalStep:c}),e.length>0&&typeof c=="object"&&c&&"choices"in c&&c.choices){let p=c.choices;p&&Array.isArray(p)?p.push(h):L.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",o,p),c.choices=p.sort((f,C)=>{try{let g=f.label.split("."),b=g[g.length-1].replaceAll(".","_|_"),E=C.label.split("."),y=E[E.length-1].replaceAll(".","_|_");if(b.includes("c-")&&y.includes("c-")){let d=b.split("c-")[1],S=Number(d),m=y.split("c-")[1],v=Number(m);return S-v}}catch{}return 0});}else e.push({choices:[h]});o.preDialog&&(n.preDialog[l]={...o.preDialog});}}}function _u(r,e,t,n,i){let a=[],s="",o="",l=false,u=[];for(let h=0;h<r.length;h++){let c=r[h];if(typeof c=="string")c.startsWith("^")?a.push(He(c)):Du.includes(c)&&u.push(c);else if(Array.isArray(c)&&c.includes("visit")){let p=Jt(c,vi,(f,C,g)=>{},i,n,t);a.push(p);}else if(c&&typeof c=="object")if("*"in c&&typeof c["*"]&&typeof c["*"]=="string")c["*"].includes("c")&&(s=`c${c["*"].split("c")[1]}`,c.flg&16&&(l=true));else if("s"in c&&Array.isArray(c.s)){let p=Ou(c.s),f=c.s.includes("<>");p&&(i&&e[i]?(e[i].preDialog={text:p,glue:f},e[i].text=la(p,e[i].text)):(a.push(p),o=p));}else ("CNT?"in c||"VAR?"in c)&&u.push(c);else u.push(c);if(s){e[s]?e[s].text=la(a,e[s].text):e[s]={text:a,onetime:l,conditions:u},o&&(e[s].preDialog={text:o,glue:false});let p=r.slice(h+1);_u(p,e,t,n,s);return}}}function Ou(r){for(let e of r)if(typeof e=="string"){if(e.startsWith("^"))return He(e)}else if(Array.isArray(e)){let t=Ou(e);if(t)return t}}var ua;(i=>{function r(a,s={}){let{labelToRemove:o=[],initialVarsToRemove:l=[],enums:u={},functions:h=[],preDialog:c={},characterIds:p}=s,f={$schema:vu};if(f.labels=e(a.root,{labelToRemove:o,initialVarsToRemove:l,enums:u,functions:h,preDialog:c,characterIds:p}),f.labels&&yi in f.labels){let C=f.labels[yi];delete f.labels[yi],C.forEach(g=>{g.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...g.operations]:[...g.operations]);});}if(f.labels&&Ot in f.labels){let C=f.labels[Ot];delete f.labels[Ot],C.forEach(g=>{g.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...g.operations]:[...g.operations]);});}return o.forEach(C=>{f.labels&&C in f.labels&&delete f.labels[C];}),l.forEach(C=>{f.initialOperations&&(f.initialOperations=f.initialOperations.filter(g=>!(g.type==="value"&&g.key===C)));}),f}i.inkToJson=r;function e(a,s){try{let o={};return t(a,o,s),o}catch(o){L.error("Error parsing ink file",o);}}function t(a,s,o){for(let l of a)if(l)if(Array.isArray(l))if(l.includes("visit")){let u=Jt(l,vi,(h,c,p)=>{},"",o,[]);u&&(o.externalSwitch=u);}else t(l,s,o);else typeof l=="object"&&(l&&"VAR="in l&&o.externalSwitch&&(s[Ot]||(s[Ot]=[]),s[Ot].push({operations:bn({defaultType:"storage",key:l["VAR="],value:o.externalSwitch},[],o)})),n(l,s,"",o));}function n(a,s,o="",l){if(a!==null){for(let[u,h]of Object.entries(a))if(Array.isArray(h)){let c=[],p={},f=(o?o+"_|_":"")+u;ft(h,f,l,c,ra,ra,(C,g,b)=>{n(C,p,g,b);},Ht);for(let[C,g]of Object.entries(p))s[C]=g;c.length>0&&(s[f]=c);}}}})(ua||={});var bc=$s(Ec()),Ac=$s(zt()),VC=/(?:^|<>)\s*#\s*([^\r\n]+)/g,kC=/^=+[ \t]+(?:function[ \t]+)?(\w+)/gm,RC=new Set(["DONE","END"]),LC="_|_",Dc=new Map;function xc(r,e){let t=JSON.stringify([e,r]),n=Dc.get(t);if(n)return n;let i=new RegExp(r,e);return Dc.set(t,i),i}function li(r,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(s=>li(r,s));let i=t.oneOf;if(Array.isArray(i))return i.some(s=>li(r,s));let a=t.allOf;if(Array.isArray(a))return a.every(s=>li(r,s));if(typeof t.const=="string")return r===t.const;if(Array.isArray(t.enum))return t.enum.some(s=>typeof s=="string"&&s===r);if(t.type!=="string"||typeof t.minLength=="number"&&r.length<t.minLength||typeof t.maxLength=="number"&&r.length>t.maxLength)return false;if(typeof t.pattern=="string")try{if(!xc(t.pattern,"").test(r))return !1}catch{return false}return true}function Gs(r,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(o=>Gs(r,o));let i=t.oneOf;if(Array.isArray(i))return i.some(o=>Gs(r,o));let a=t.allOf;if(Array.isArray(a))return a.every(o=>Gs(r,o));if(t.type!=="array"||typeof t.minItems=="number"&&r.length<t.minItems||typeof t.maxItems=="number"&&r.length>t.maxItems)return false;let s=Array.isArray(t.prefixItems)?t.prefixItems:[];if(r.length<s.length)return false;for(let o=0;o<s.length;o++)if(!li(r[o],s[o]))return false;return r.length===s.length?true:t.items===false||typeof t.items>"u"?false:t.items===true?true:r.slice(s.length).every(o=>li(o,t.items))}function BC(r,e){if(e.type==="regexp")try{let t=xc(e.source,e.flags);return t.lastIndex=0,t.test(r.join(" "))}catch{return false}return e.type==="literal"?r.join(" ")===e.value:Gs(r,e.schema)}function WC(r){let e=r.split(/\r?\n/),t=[];for(let n=0;n<e.length;n++){let i=e[n];for(let a of i.matchAll(VC)){let s=(a[1]??"").trim();if(!s)continue;let o=Je.convertTagTolist(s,{mergeInkVariables:true});o.length!==0&&t.push({line:n+1,command:s,tokens:o});}}return t}var Fl;(i=>{function r(a,s={labelToRemove:[],initialVarsToRemove:[],functions:[],enums:{}}){let o=[];try{return {json:new bc.Compiler(a,{errorHandler:(c,p)=>{let f=c.replace(/^[A-Z]+: line \d+: ?/,""),C=c.match(/line (\d+)/);o.push({message:f,type:p,line:C?Number(C[1]):-1});},countAllVisits:!0,fileHandler:{ResolveInkFilename:c=>c,LoadInkFileContents:()=>""},pluginNames:[],sourceFilename:null}).Compile().ToJson()||"",issues:o}}catch{let u=false,h={...s,textSource:a};return e(o,()=>{u=true;},h),u?r(h.textSource,s):{issues:o}}}i.compile=r;function e(a,s,o){let{functions:l,initialVarsToRemove:u,labelToRemove:h}=o,c=a.find(p=>p.type===Ac.ErrorType.Error);if(c){if(c.message.includes("Divert target not found")){let p=c.message.match(/Divert target not found: '-> (\w+)'/);if(p?.[1]){let f=p[1],C=`
62
62
 
63
63
  === ${f} ===
64
64
 
@@ -1 +1 @@
1
- import {b,a}from'./chunk-34RMBLNJ.mjs';import'./chunk-LJ7DXYK6.mjs';import {inkJsons}from'virtual:pixi-vn-ink';async function m(n,t,p={}){let s={importJson:async r=>{await b(r);},importInkText:r=>a(r,{characters:p.characters})},e=n&&typeof n=="object"&&"inkJson"in n?n.inkJson:void 0;if(e&&e.length>0){await s.importJson(e);return}let a$1=n&&typeof n=="object"&&"inkText"in n?n.inkText:typeof n=="string"?n:void 0;typeof a$1=="string"&&await s.importInkText(a$1);}async function k(n={}){inkJsons&&inkJsons.length>0&&await b(inkJsons),import.meta.hot&&(import.meta.hot.on("ink-updated",async t=>{await m(t,void 0,n);}),import.meta.hot.on("ink-error-cleared",()=>{document.querySelectorAll("vite-error-overlay").forEach(t=>{t.close();});}));}export{k as setupInkHmrListener};
1
+ import {b,a}from'./chunk-HE25JM4E.mjs';import'./chunk-54QJQIS3.mjs';import {inkJsons}from'virtual:pixi-vn-ink';async function m(n,t,p={}){let s={importJson:async r=>{await b(r);},importInkText:r=>a(r,{characters:p.characters})},e=n&&typeof n=="object"&&"inkJson"in n?n.inkJson:void 0;if(e&&e.length>0){await s.importJson(e);return}let a$1=n&&typeof n=="object"&&"inkText"in n?n.inkText:typeof n=="string"?n:void 0;typeof a$1=="string"&&await s.importInkText(a$1);}async function k(n={}){inkJsons&&inkJsons.length>0&&await b(inkJsons),import.meta.hot&&(import.meta.hot.on("ink-updated",async t=>{await m(t,void 0,n);}),import.meta.hot.on("ink-error-cleared",()=>{document.querySelectorAll("vite-error-overlay").forEach(t=>{t.close();});}));}export{k as setupInkHmrListener};