@drincs/pixi-vn-ink 1.0.8 → 1.0.10
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/{chunk-BH57FV3S.mjs → chunk-3K2SER36.mjs} +2 -2
- package/dist/{chunk-K5FMIB6Z.mjs → chunk-WU3FPOE2.mjs} +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.mjs +1 -1
- package/dist/mapper.cjs +5 -5
- package/dist/mapper.mjs +5 -5
- package/dist/parser.cjs +8 -8
- package/dist/parser.mjs +8 -8
- package/dist/vite-listener.cjs +3 -3
- package/dist/vite-listener.mjs +1 -1
- package/dist/vite.cjs +48 -48
- package/dist/vite.mjs +5 -5
- package/package.json +1 -1
|
@@ -56,7 +56,7 @@ ${E}`),E&&(o=true),s=_.getLogichValue(y.glueEnabled,e)||false,E)}),u=_.getLogich
|
|
|
56
56
|
`+A+"}";}}return r.pop(),a=A,d}function f(g){if(g.length===0)return c(g);let A=String.fromCodePoint(g.codePointAt(0));if(!ne.isIdStartChar(A))return c(g);for(let D=A.length;D<g.length;D++)if(!ne.isIdContinueChar(String.fromCodePoint(g.codePointAt(D))))return c(g);return g}function C(g){if(r.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");r.push(g);let A=a;a=a+l;let D=[];for(let d=0;d<g.length;d++){let E=h(String(d),g);D.push(E!==void 0?E:"null");}let y;if(D.length===0)y="[]";else if(l==="")y="["+D.join(",")+"]";else {let d=`,
|
|
57
57
|
`+a,E=D.join(d);y=`[
|
|
58
58
|
`+a+E+`,
|
|
59
|
-
`+A+"]";}return r.pop(),a=A,y}},Bd={parse:Fd,stringify:Ld},Wd=Bd,An=Wd;var Cu="\xA7SPACE\xA7",yu="\xA7DOUBLE_QUOTES\xA7",vu="\xA7QUOTES\xA7",Su="SPECIAL_\xA7QUOTES\xA7",Eu="\xA7CURLY_BRACKETS1\xA7",jd="\xA7INK_VAR\xA7",Du="\xA7CURLY_BRACKETS2\xA7",O;(y=>{let i=[],e=[];async function t(d,E){for(let m=0;m<i.length;m++)try{let{validation:S}=i[m].opts;if(S instanceof RegExp){if(!S.test(d.join(" ")))continue}else if(S instanceof ZodType&&!S.safeParse(d).success)continue;let x=await i[m].fn(d,E,c);if(x===!0||typeof x=="string")return x}catch{}return false}function n(d,E={name:"custom-command",validation:/^/}){i.unshift({fn:d,opts:E});}y.add=n;function r(){return [...e.map(d=>d.opts),...i.map(d=>d.opts)]}y.info=r;function a(d,E){e.unshift({fn:d,opts:E});}y.addMapper=a;function s(){i.length=0;}y.clear=s;function o(){e.length=0;}y.clearMappers=o;async function l(d,E,m){try{let S=u(d),x=await t(S,m);return x===!0?void 0:typeof x=="string"?(x.startsWith("#")&&(x=x.substring(1)),await y.run(x,E,m)):h(S,E)}catch(S){throw W.error("Error parsing ink hashtag-command",d),S}}y.run=l;function u(d,E){if(d=d.replaceAll('\\"',yu),d=d.replaceAll("\\'",vu),d=d.replaceAll("\\`",Su),d=d.replaceAll("\\{",Eu),d=d.replaceAll("\\}",Du),E?.mergeInkVariables){let P;do P=d,d=d.replace(/\{[^{}:]*\}/g,jd);while(d!==P)}d=d.replaceAll("{"," { "),d=d.replaceAll("}"," } "),d=d.replaceAll(Eu,"{"),d=d.replaceAll(Du,"}");let m=[],S,x="";for(let P=0;P<d.length;P++){let N=d[P];N==='"'||N==="'"||N==="`"?S===void 0?(m.push(x),x="",S=N,x+=N):S===N?(S=void 0,x+=N,m.push(x),x=""):x+=N:x+=N;}return x!==""&&m.push(x),m.forEach((P,N)=>{N%2===1&&(m[N]=P.replaceAll(" ",Cu));}),d=m.join(""),m=d.split(" ").filter(P=>P!==""),m=m.map(P=>P.replaceAll(Cu," ").replaceAll(yu,'"').replaceAll(vu,"'").replaceAll(Su,"`")),m=g(m),m=m.map(P=>P.startsWith('"')&&P.endsWith('"')||P.startsWith("'")&&P.endsWith("'")||P.startsWith("`")&&P.endsWith("`")?P.slice(1,-1):P),m}y.convertTagTolist=u;function h(d,E){for(let
|
|
59
|
+
`+A+"]";}return r.pop(),a=A,y}},Bd={parse:Fd,stringify:Ld},Wd=Bd,An=Wd;var Cu="\xA7SPACE\xA7",yu="\xA7DOUBLE_QUOTES\xA7",vu="\xA7QUOTES\xA7",Su="SPECIAL_\xA7QUOTES\xA7",Eu="\xA7CURLY_BRACKETS1\xA7",jd="\xA7INK_VAR\xA7",Du="\xA7CURLY_BRACKETS2\xA7",O;(y=>{let i=[],e=[];async function t(d,E){for(let m=0;m<i.length;m++)try{let{validation:S}=i[m].opts;if(S instanceof RegExp){if(!S.test(d.join(" ")))continue}else if(S instanceof ZodType&&!S.safeParse(d).success)continue;let x=await i[m].fn(d,E,c);if(x===!0||typeof x=="string")return x}catch{}return false}function n(d,E={name:"custom-command",validation:/^/}){i.unshift({fn:d,opts:E});}y.add=n;function r(){return [...e.map(d=>d.opts),...i.map(d=>d.opts)]}y.info=r;function a(d,E){e.unshift({fn:d,opts:E});}y.addMapper=a;function s(){i.length=0;}y.clear=s;function o(){e.length=0;}y.clearMappers=o;async function l(d,E,m){try{let S=u(d),x=await t(S,m);return x===!0?void 0:typeof x=="string"?(x.startsWith("#")&&(x=x.substring(1)),await y.run(x,E,m)):h(S,E)}catch(S){throw W.error("Error parsing ink hashtag-command",d),S}}y.run=l;function u(d,E){if(d=d.replaceAll('\\"',yu),d=d.replaceAll("\\'",vu),d=d.replaceAll("\\`",Su),d=d.replaceAll("\\{",Eu),d=d.replaceAll("\\}",Du),E?.mergeInkVariables){let P;do P=d,d=d.replace(/\{[^{}:]*\}/g,jd);while(d!==P)}d=d.replaceAll("{"," { "),d=d.replaceAll("}"," } "),d=d.replaceAll(Eu,"{"),d=d.replaceAll(Du,"}");let m=[],S,x="";for(let P=0;P<d.length;P++){let N=d[P];N==='"'||N==="'"||N==="`"?S===void 0?(m.push(x),x="",S=N,x+=N):S===N?(S=void 0,x+=N,m.push(x),x=""):x+=N:x+=N;}return x!==""&&m.push(x),m.forEach((P,N)=>{N%2===1&&(m[N]=P.replaceAll(" ",Cu));}),d=m.join(""),m=d.split(" ").filter(P=>P!==""),m=m.map(P=>P.replaceAll(Cu," ").replaceAll(yu,'"').replaceAll(vu,"'").replaceAll(Su,"`")),m=g(m),m=m.map(P=>P.startsWith('"')&&P.endsWith('"')||P.startsWith("'")&&P.endsWith("'")||P.startsWith("`")&&P.endsWith("`")?P.slice(1,-1):P),m}y.convertTagTolist=u;function h(d,E,m){for(let S of e){let{validation:x}=S.opts,P=false;if(x instanceof RegExp?P=x.test(d.join(" ")):x instanceof ZodType&&(P=x.safeParse(d).success),P)return S.fn(d,E)}m?.silent||W.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 W.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 E="{";d.forEach((m,S)=>{if(S%2===0)E+=`"${m}": `;else {switch(m){case "null":case "undefined":case "true":case "false":E+=`${m}`;break;default:C(m)?(m=f(m),E+=`"${m}"`):m.startsWith("{")&&m.endsWith("}")?E+=`${m}`:m.startsWith('"')&&m.endsWith('"')?E+=`${m}`:Number.isNaN(parseFloat(m))?E+=`"${m}"`:E+=`${m}`;}S<d.length-1&&(E+=", ");}}),E+="}";try{return An.parse(E)}catch(m){throw W.error("Error parsing ink json",E),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 A(d).tokens}y.mergeJsonBlocks=g;function A(d){let E=[],m=false;for(let S=0;S<d.length;S++){let x=d[S];if(x!=="{"){E.push(x);continue}let P=D(d,S);if(P===-1){E.push(x);continue}let N=A(d.slice(S+1,P)),Z=["{",...N.tokens,"}"],ye=Z.join(" ");if(!N.hasInvalidMatchedBlock)try{An.parse(ye),E.push(ye),S=P;continue}catch{}m=true,E.push(...Z),S=P;}return {tokens:E,hasInvalidMatchedBlock:m}}function D(d,E){let m=0;for(let S=E;S<d.length;S++)if(d[S]==="{")m++;else if(d[S]==="}"&&(m--,m===0))return S;return -1}})(O||={});function qd(i){O.add(i);}O.addMapper((i,e)=>{e.labelToOpen={label:i[1],type:"call"},e.goNextStep=void 0;},{name:"Call",description:"Calls the label specified by the second token, then returns to the current position.\n\n```ink\n# call label_name\n```",validation:v.tuple([v.literal("call"),v.string()])});O.addMapper((i,e)=>{e.labelToOpen={label:i[1],type:"jump"},e.goNextStep=void 0;},{name:"Jump",description:"Jumps to the label specified by the second token without returning.\n\n```ink\n# jump label_name\n```",validation:v.tuple([v.literal("jump"),v.string()])});O.addMapper((i,e)=>("dialogue"in e&&delete e.dialogue,"goNextStep"in e&&delete e.goNextStep,{type:"dialogue",operationType:"clean"}),{name:"Pause",description:"Clears the current dialogue and waits for user input before advancing.\n\n```ink\n# pause\n```",validation:v.tuple([v.literal("pause")])});O.addMapper((i,e)=>{e.goNextStep=true,e.glueEnabled=false;},{name:"Continue",description:"Forces the story to proceed to the next step automatically.\n\n```ink\n# continue\n```",validation:v.tuple([v.literal("continue")])});O.addMapper(i=>({type:"video",operationType:i[0],alias:i[2]}),{name:"Pause/Resume video",description:"Pauses or resumes a video canvas element identified by its alias.\n\n```ink\n# pause video <alias>\n# resume video <alias>\n```",validation:v.tuple([v.enum(["pause","resume"]),v.literal("video"),v.string()])});O.addMapper(i=>({type:i[1],operationType:i[0],aliases:i.slice(2)}),{name:"Load assets/bundle",description:`Loads (eagerly or lazily) a set of asset or bundle aliases.
|
|
60
60
|
|
|
61
61
|
\`\`\`ink
|
|
62
62
|
# load assets <alias...>
|
|
@@ -64,7 +64,7 @@ ${E}`),E&&(o=true),s=_.getLogichValue(y.glueEnabled,e)||false,E)}),u=_.getLogich
|
|
|
64
64
|
# load bundle <alias...>
|
|
65
65
|
# lazyload bundle <alias...>
|
|
66
66
|
\`\`\``,validation:v.tuple([v.enum(["load","lazyload"]),v.enum(["assets","bundle"])]).rest(v.string())});O.addMapper(i=>({type:"all",operationType:i[0]}),{name:"Pause/Resume/Stop all sounds",description:"Pauses, resumes, or stops all active sounds at once.\n\n```ink\n# pause all sounds\n# resume all sounds\n# stop all sounds\n```",validation:v.tuple([v.enum(["pause","resume","stop"]),v.literal("all"),v.enum(["sounds","sound"])])});O.addMapper(i=>({type:"sound",operationType:"pause",alias:i[2]}),{name:"Pause sound",description:"Pauses the sound identified by its alias.\n\n```ink\n# pause sound <alias>\n```",validation:v.tuple([v.literal("pause"),v.literal("sound"),v.string()])});O.addMapper(i=>({type:"channel",operationType:"pause",alias:i[2]}),{name:"Pause channel",description:"Pauses the audio channel identified by its alias.\n\n```ink\n# pause channel <alias>\n```",validation:v.tuple([v.literal("pause"),v.literal("channel"),v.string()])});O.addMapper(i=>({type:"sound",operationType:"resume",alias:i[2]}),{name:"Resume sound",description:"Resumes the sound identified by its alias.\n\n```ink\n# resume sound <alias>\n```",validation:v.tuple([v.literal("resume"),v.literal("sound"),v.string()])});O.addMapper(i=>({type:"channel",operationType:"resume",alias:i[2]}),{name:"Resume channel",description:"Resumes the audio channel identified by its alias.\n\n```ink\n# resume channel <alias>\n```",validation:v.tuple([v.literal("resume"),v.literal("channel"),v.string()])});O.addMapper(i=>({type:"sound",operationType:"stop",alias:i[2]}),{name:"Stop sound",description:"Stops the sound identified by its alias.\n\n```ink\n# stop sound <alias>\n```",validation:v.tuple([v.literal("stop"),v.literal("sound"),v.string()])});O.addMapper(i=>({type:"sound",operationType:"stop",alias:i[2]}),{name:"Remove sound",description:"Removes (stops) the sound identified by its alias.\n\n```ink\n# remove sound <alias>\n```",deprecated:true,validation:v.tuple([v.literal("remove"),v.literal("sound"),v.string()])});O.addMapper(i=>({type:"sound",operationType:"edit",alias:i[2],props:O.convertListStringToObj(i.slice(3))}),{name:"Edit sound",description:"Edits the properties of a sound identified by its alias.\n\n```ink\n# edit sound <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("edit"),v.literal("sound"),v.string()]).rest(v.string()).refine(i=>(i.length-3)%2===0)});O.addMapper(i=>{let e=i[2],t={type:"sound",operationType:"play",alias:e,url:e};return i.length>3&&(t.props=O.convertListStringToObj(i.slice(3))),t},{name:"Play sound",description:"Plays a sound using its alias as the URL, with optional key/value properties.\n\n```ink\n# play sound <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("play"),v.literal("sound"),v.string()]).rest(v.string()).refine(i=>(i.length-3)%2===0)});O.addMapper(i=>{let e=i[2],t=i[3],n={type:"sound",operationType:"play",alias:e,url:t};return i.length>4&&(n.props=O.convertListStringToObj(i.slice(4))),n},{name:"Play sound with source",description:"Plays a sound with an explicit source URL and optional key/value properties.\n \n```ink\n# play sound <alias> <source> [<key> <value> \u2026]\n```\n",validation:v.tuple([v.literal("play"),v.literal("sound"),v.string()]).rest(v.string()).refine(i=>i.length>3&&(i.length-3)%2!==0)});function ze(i){let e=[],t=0,n="";for(let r of i)r.startsWith("{")?(t++,n+=r):r.endsWith("}")&&t>0?(t--,n+=r,t===0&&(e.push(n),n="")):t>0?n+=r:e.push(r);return e}function Ei(i,e){switch(i){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let t={type:i};if(e.length>0)try{t.props=O.convertListStringToObj(e);}catch{}return t}function bu(i,e,t){let n,r;t.length%2===0?(n=e,r=t):(n=t[0],r=t.slice(1));let a={type:i,operationType:"show",alias:e,url:n};if(r.length>0){if(r.includes("with")&&r.length>r.indexOf("with")+1){let s=r[r.indexOf("with")+1],o=r.slice(r.indexOf("with")+2);r=r.slice(0,r.indexOf("with"));let l=Ei(s,o);l!==void 0&&(a.transition=l);}r.length>0&&(a.props=O.convertListStringToObj(r));}return a}function Md(i,e){let t,n;e.length%2===0?(t=i,n=e):(t=e[0],n=e.slice(1));let r={type:"text",operationType:"show",alias:i,text:t};if(n.length>0){if(n.includes("with")&&n.length>n.indexOf("with")+1){let a=n[n.indexOf("with")+1],s=n.slice(n.indexOf("with")+2);n=n.slice(0,n.indexOf("with"));let o=Ei(a,s);o!==void 0&&(r.transition=o);}n.length>0&&(r.props=O.convertListStringToObj(n));}return r}function wn(i,e,t){let n={type:i,operationType:"remove",alias:e};if(t.includes("with")&&t.length>t.indexOf("with")+1){let r=t[t.indexOf("with")+1],a=t.slice(t.indexOf("with")+2),s=Ei(r,a);s!==void 0&&(n.transition=s);}return n}function na(i,e){let t=l=>l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'")||l.startsWith("`")&&l.endsWith("`")?l.substring(1,l.length-1):l,n=[],r=e.findIndex(l=>l.startsWith("[")),a=e.findIndex(l=>l.endsWith("]"));if(r===-1||a===-1){W.error("Show imagecontainer must have a list of image ulrs",e);return}if(n=e.slice(r,a+1),n.length<2){W.error("Show imagecontainer must have a list of image ulrs",e);return}n[0]==="["?n.shift():n[0]=n[0].substring(1),n[n.length-1]==="]"?n.pop():n[n.length-1]=n[n.length-1].substring(0,n[n.length-1].length-1);let s={type:"imagecontainer",operationType:"show",alias:i,urls:n.map(l=>t(l))},o=e.slice(a+1);if(o.length>0){if(o.includes("with")&&o.length>o.indexOf("with")+1){let l=o[o.indexOf("with")+1],u=o.slice(o.indexOf("with")+2);o=o.slice(0,o.indexOf("with"));let h=Ei(l,u);h!==void 0&&(s.transition=h);}o.length>0&&(s.props=O.convertListStringToObj(o));}return s}function ia(i){let e=i.slice(3),t=e.findIndex(s=>s.startsWith("[")),n=e.findIndex(s=>s.endsWith("]"));if(t===-1||n===-1||n<t)return;let r=e.slice(n+1),a=r.indexOf("with");return a===-1?{beforeWith:r,afterWith:[]}:{beforeWith:r.slice(0,a),afterWith:r.slice(a+1)}}O.addMapper(i=>({alias:i[1],type:"shake",props:O.convertListStringToObj(i.slice(2))}),{name:"Shake",description:"Applies shake effect to a canvas alias with optional key/value parameters.\n\n```ink\n# shake <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("shake"),v.string()]).rest(v.string()).refine(i=>(i.length-2)%2===0)});O.addMapper(i=>{let e=i.slice(2),t=e,n=[];if(e.includes("options")){let a=e.indexOf("options");t=e.slice(0,a),n=e.slice(a+1);}return {alias:i[1],type:"animate",keyframes:O.convertListStringToObj(t),options:O.convertListStringToObj(n)}},{name:"Animate",description:"Animates a canvas alias with keyframes and optional options section, both in key/value pairs.\n\n```ink\n# animate <alias> [<key> <value> \u2026] [options <key> <value> \u2026]\n```",validation:v.tuple([v.literal("animate"),v.string()]).rest(v.string()).refine(i=>{let e=i.slice(2),t=e.indexOf("options");if(t===-1)return e.length%2===0;if(e.lastIndexOf("options")!==t)return false;let n=e.slice(0,t),r=e.slice(t+1);return n.length%2===0&&r.length%2===0})});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return bu("image",e,t)},{name:"Show image",description:"Shows an image canvas element with optional source URL, key/value properties, and transition effect.\n\n```ink\n# show image <alias> [<source>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("show"),v.literal("image"),v.string()]).rest(v.string())});O.addMapper(i=>na(i[2],ze(i.slice(3))),{name:"Show imagecontainer",description:"Shows an image-container canvas element with a list of image URLs and optional key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("show"),v.literal("imagecontainer"),v.string()]).rest(v.string()).refine(i=>{let e=ia(i);return e===void 0?false:e.afterWith.length===0&&e.beforeWith.length%2===0})});O.addMapper(i=>na(i[2],ze(i.slice(3))),{name:"Show imagecontainer with transition",description:"Shows an image-container canvas element with a list of image URLs, optional properties, and a transition effect.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout\n```",validation:v.tuple([v.literal("show"),v.literal("imagecontainer"),v.string()]).rest(v.string()).refine(i=>{let e=ia(i);return e===void 0?false:e.afterWith.length===1&&e.beforeWith.length%2===0})});O.addMapper(i=>na(i[2],ze(i.slice(3))),{name:"Show imagecontainer with transition and props",description:"Shows an image-container canvas element with a list of image URLs, optional properties, a transition effect, and transition key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout <key> <value> \u2026\n```",validation:v.tuple([v.literal("show"),v.literal("imagecontainer"),v.string()]).rest(v.string()).refine(i=>{let e=ia(i);return e===void 0?false:e.afterWith.length>1&&(e.afterWith.length-1)%2===0&&e.beforeWith.length%2===0})});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return bu("video",e,t)},{name:"Show video",description:"Shows a video canvas element with optional source URL, key/value properties, and transition effect.\n\n```ink\n# show video <alias> [<source>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("show"),v.literal("video"),v.string()]).rest(v.string())});O.addMapper(i=>{let e=i[2];return Md(e,i.slice(3))},{name:"Show text",description:"Shows a text canvas element with optional text content, key/value properties, and transition effect.\n\n```ink\n# show text <alias> [<text>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("show"),v.literal("text"),v.string()]).rest(v.string())});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("image",e,t)},{name:"Remove image",description:"Removes an image canvas element with an optional transition effect.\n\n```ink\n# remove image <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("remove"),v.literal("image"),v.string()]).rest(v.string())});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("video",e,t)},{name:"Remove video",description:"Removes a video canvas element with an optional transition effect.\n\n```ink\n# remove video <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("remove"),v.literal("video"),v.string()]).rest(v.string())});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("canvaselement",e,t)},{name:"Remove canvas element",description:"Removes a canvas element with an optional transition effect.\n\n```ink\n# remove canvaselement <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("remove"),v.literal("canvaselement"),v.string()]).rest(v.string())});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("text",e,t)},{name:"Remove text",description:"Removes a text canvas element with an optional transition effect.\n\n```ink\n# remove text <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("remove"),v.literal("text"),v.string()]).rest(v.string())});O.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("imagecontainer",e,t)},{name:"Remove imagecontainer",description:"Removes an image-container canvas element with an optional transition effect.\n\n```ink\n# remove imagecontainer <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v.tuple([v.literal("remove"),v.literal("imagecontainer"),v.string()]).rest(v.string())});O.addMapper(i=>({type:"image",operationType:"edit",alias:i[2],props:O.convertListStringToObj(i.slice(3))}),{name:"Edit image",description:"Edits the properties of an image canvas element identified by its alias.\n\n```ink\n# edit image <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("edit"),v.literal("image"),v.string()]).rest(v.string())});O.addMapper(i=>({type:"imagecontainer",operationType:"edit",alias:i[2],props:O.convertListStringToObj(i.slice(3))}),{name:"Edit imagecontainer",description:"Edits the properties of an image-container canvas element identified by its alias.\n\n```ink\n# edit imagecontainer <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("edit"),v.literal("imagecontainer"),v.string()]).rest(v.string())});O.addMapper(i=>({type:"canvaselement",operationType:"edit",alias:i[2],props:O.convertListStringToObj(i.slice(3))}),{name:"Edit canvas element",description:"Edits the properties of a canvas element identified by its alias.\n\n```ink\n# edit canvaselement <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("edit"),v.literal("canvaselement"),v.string()]).rest(v.string())});O.addMapper(i=>({type:"video",operationType:"edit",alias:i[2],props:O.convertListStringToObj(i.slice(3))}),{name:"Edit video",description:"Edits the properties of a video canvas element identified by its alias.\n\n```ink\n# edit video <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("edit"),v.literal("video"),v.string()]).rest(v.string())});O.addMapper(i=>({type:"text",operationType:"edit",alias:i[2],props:O.convertListStringToObj(i.slice(3))}),{name:"Edit text",description:"Edits the properties of a text canvas element identified by its alias.\n\n```ink\n# edit text <alias> [<key> <value> \u2026]\n```",validation:v.tuple([v.literal("edit"),v.literal("text"),v.string()]).rest(v.string())});O.addMapper(i=>({type:"input",operationType:"request"}),{name:"Request input",description:"Requests player input without any additional constraints.\n\n```ink\n# request input\n```",validation:v.tuple([v.literal("request"),v.literal("input")])});O.addMapper(i=>{let e={type:"input",operationType:"request"};try{let t=O.convertListStringToObj(i.slice(2));"type"in t&&typeof t.type=="string"&&(e.valueType=t.type),"default"in t&&(e.defaultValue=t.default);}catch{}return e},{name:"Request input with params",description:"Requests player input with optional key/value parameters (e.g. type, default).\n\n```ink\n# request input <key> <value> [<key> <value> \u2026]\n# request input type number default 18\n```",validation:v.tuple([v.literal("request"),v.literal("input")]).rest(v.string()).refine(i=>i.length>2&&(i.length-2)%2===0)});var Di="global decl",Pt="___external_value___",Au=/\[([^\]]+)\]/;var wu=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],xu=["+","-","/","*","%","POW","RANDOM","L^"],_u=["INT","FLOOR","FLOAT"];function Ht(i,e){if(i.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return ra(e)+"_|_"+"g-"+n[n.length-1]}let t=0;for(;new RegExp(/^\.\^.*$/).test(i);)t++,i=i.substring(2);if(t=t-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return ra(e,t)+"_|_"+n.replaceAll(".","_|_")}return i.replaceAll(".","_|_")||ra(e,t).replaceAll(".","_|_")}function ra(i,e=0){let t=i.split("_|_");for(;t.length>1&&e>0;)t.pop()?.includes("g-")&&e--,e--;return t.join("_|_")}var Ou="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function Ue(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",Ou),i=i.replaceAll("\\n",`
|
|
67
|
-
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(Ou,"\\\\"),i}function mt(i,e,t,n){let{functions:r}=n;i=i.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return i.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)W.error("Error parsing ink file: Conditional statement is not valid",i);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 W.error("Error parsing ink file: Conditional statement is not valid",i);break;default:if(du.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(xu.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(_u.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(Ue(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){W.error("Error parsing ink file: Conditional statement is not valid",i);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=Ht(c,e);if(!p)return;a.push({type:"compare",leftValue:sa(p),operator:">=",rightValue:{type:"value",value:h}});}else {let o=Ht(s["CNT?"],e);if(!o)return;a.push(sa(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(Ft({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],l=r.find(h=>h.name===o);if(!l){W.error(`Error parsing ink file: Function ${o} is not defined`,i);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 aa(i,e,t,n){return mt(i,e,t,n)}function Ft(i,e,t){let{key:n,defaultType:r}=i,a=e.indexOf(n);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:r,key:n}}function xn(i,e,t){let{key:n,value:r,defaultType:a,artmeticValue:s}=i,o=e.indexOf(n);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:r}];if(s){if(typeof r=="object"&&"list"in r){let l=Object.values(r.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:r}]}else if(typeof r=="object"){if("list"in r&&typeof r.list=="object"){if("origins"in r&&Array.isArray(r.origins)&&r.origins.length>0)return r.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(r.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(r.list)}),u}}else if(typeof r=="object"&&"VAR?"in r){if(typeof r["VAR?"]=="string"&&r["VAR?"].includes(".")){let[l,u]=r["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:Ft({key:r["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:r}]}function sa(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function oa(i,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(i)?"call":"jump"}function bi(i,e){if(e){if(typeof e=="string")e.startsWith("^")&&i.push(Ue(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:i.push(e);}}}function la(i,e,t,n,r,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:l=false}=a;return $d(i,e,t,n,r,{isNewLine:s,isHashtagScript:o,isThreads:l})}function $d(i,e,t,n,r,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(Au)){let c=e[0],p=O.convertTagTolist(c),f=O.convertOperation(p,u);f&&(f.$origin=c,h.push(f));}}catch{}h.length===0&&h.push({type:"operationtoconvert",values:e}),i.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&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&!u.labelToOpen&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}typeof e=="string"?i.push(Jd(Ue(e),n.characterIds)):i.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")i.push({end:"game_end"});else if(e==="done")i.push({end:"label_end",goNextStep:true});else if(e==="<>")if(i.length>0){let u=i[i.length-1];u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true),i[i.length-1]=u;}else i.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=Ue(e.value)),i.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":i.push({goNextStep:true,operations:[e]});break;default:if(!s&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}i.push({conditionalStep:e});}else if("->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let h=i[i.length-1];h.labelToOpen||(h.goNextStep=true),i[i.length-1]=h;}if(e.params&&e.params.length===0&&delete e.params,e.var)i.push({labelToOpen:{label:Ft({key:e["->"],defaultType:"storage"},r),type:l?"call":"jump",params:e.params},glueEnabled:u});else {let h=Ht(e["->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:oa(h,l),params:e.params},glueEnabled:u});}}else if("->t->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let c=i[i.length-1];c.labelToOpen||(c.goNextStep=true),i[i.length-1]=c;}e.params&&e.params.length===0&&delete e.params;let h=Ht(e["->t->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:"call",params:e.params},glueEnabled:u});}}}function Jd(i,e){let t;if(i.includes(": ")){let n=i.split(": "),r=n[0],a=n.slice(1).join(": ");(e?.has(r)||RegisteredCharacters.has(r))&&(t=r,i=a);}return t?{dialogue:{character:t,text:i}}:{dialogue:i}}function ua(i,e,t,n=true,r=false){return Hd(i,e,t,n,r)}function Hd(i,e,t,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(Ue(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function Ai(i,e,t,n){if(i.length===0){W.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let r=mt(i,e,t,n);if(r.length===1){let a=r[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function zt(i,e,t,n="",r,a,s=void 0){let o=[],l="sequential",u=false,h=true;i.forEach(f=>{f==="%"&&(l="loop"),f==="seq"&&(l="random"),f==="MIN"&&(u=true);});let c=i[i.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=[];gt(C,n,r,g,e,e,t,Ut,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 gt(i,e,t,n=[],r,a,s,o,l=void 0,u=true,h=[]){let c=false,p=[],f=false,C=false,g=false,A=[],D=[];if(t.preDialog[e]&&(u=false,r(n,`^${t.preDialog[e].text}`,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),t.preDialog[e].glue&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),delete t.preDialog[e]),i.includes("visit")){let d=zt(i,a,s,e,t,h,l);d&&(!u&&n.length>0&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}));return}let y=i[0];if(y&&typeof y=="object"&&"temp="in y){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)h.push(i[0]["temp="]),i.shift();h=h.reverse();}if(i.forEach((d,E)=>{if(C){if(typeof d=="string"&&d==="/#"){let m=[];gt(D,e,t,m,ua,ua,s,o,l,u),r(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),C=false,D=[];}else D.push(d);return}else if(c)if(Array.isArray(d))p.push(d);else if(d&&typeof d=="object")"CNT?"in d?E>0&&i[E-1]==="ev"?(f=true,A.push(d)):f?A.push(d):(p.push(d),u=false):"VAR="in d||"temp="in d?xn({key:"VAR="in d?d["VAR="]:d["temp="],value:i[E-1],defaultType:"VAR="in d?"storage":"tempstorage"},h,t).forEach(S=>{if(S.value&&typeof S.value=="string"&&S.value==="/str"&&(S.value=i[E-2]),S.value&&typeof S.value=="object"&&"^->"in S.value&&(S.value=S.value["^->"]),p.length>1){let x=Ai(p,e,h,t);p=[],x&&typeof x=="object"&&"type"in x&&x.type==="value"&&"storageType"in x&&x.storageType==="logic"&&(S.value=x.operation);}(typeof S.key!="string"||!S.key.includes("$r"))&&(r(n,S,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&&A.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 S=Ft({key:m["VAR?"],defaultType:"storage"},h);r(n,S,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}else {let S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let x=Ai(S,e,h,t);p=[],x&&typeof x=="object"&&"type"in x&&x.type==="value"&&"storageType"in x&&x.storageType==="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:x.operation,type:"value"},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):(r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),x=`^${x}`,r(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 S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let x=mt(S,e,h,t);p=[],x.forEach(P=>{P&&typeof P=="object"&&"type"in P&&P.type==="function"?r(n,P,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):W.warn("Unhandled case: value is not a function",P);}),u=false;}else p.push(d);return}default:p.push(d);}else if(typeof d=="string")if(d.startsWith("^"))r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="ev")c=true;else if(d===`
|
|
67
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(Ou,"\\\\"),i}function mt(i,e,t,n){let{functions:r}=n;i=i.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return i.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)W.error("Error parsing ink file: Conditional statement is not valid",i);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 W.error("Error parsing ink file: Conditional statement is not valid",i);break;default:if(du.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(xu.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(_u.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(Ue(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){W.error("Error parsing ink file: Conditional statement is not valid",i);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=Ht(c,e);if(!p)return;a.push({type:"compare",leftValue:sa(p),operator:">=",rightValue:{type:"value",value:h}});}else {let o=Ht(s["CNT?"],e);if(!o)return;a.push(sa(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(Ft({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],l=r.find(h=>h.name===o);if(!l){W.error(`Error parsing ink file: Function ${o} is not defined`,i);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 aa(i,e,t,n){return mt(i,e,t,n)}function Ft(i,e,t){let{key:n,defaultType:r}=i,a=e.indexOf(n);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:r,key:n}}function xn(i,e,t){let{key:n,value:r,defaultType:a,artmeticValue:s}=i,o=e.indexOf(n);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:r}];if(s){if(typeof r=="object"&&"list"in r){let l=Object.values(r.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:r}]}else if(typeof r=="object"){if("list"in r&&typeof r.list=="object"){if("origins"in r&&Array.isArray(r.origins)&&r.origins.length>0)return r.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(r.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(r.list)}),u}}else if(typeof r=="object"&&"VAR?"in r){if(typeof r["VAR?"]=="string"&&r["VAR?"].includes(".")){let[l,u]=r["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:Ft({key:r["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:r}]}function sa(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function oa(i,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(i)?"call":"jump"}function bi(i,e){if(e){if(typeof e=="string")e.startsWith("^")&&i.push(Ue(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:i.push(e);}}}function la(i,e,t,n,r,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:l=false}=a;return $d(i,e,t,n,r,{isNewLine:s,isHashtagScript:o,isThreads:l})}function $d(i,e,t,n,r,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(Au)){let c=e[0],p=O.convertTagTolist(c),f=O.convertOperation(p,u,{silent:!0});f&&(f.$origin=c,h.push(f));}}catch{}h.length===0&&h.push({type:"operationtoconvert",values:e}),i.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&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&!u.labelToOpen&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}typeof e=="string"?i.push(Jd(Ue(e),n.characterIds)):i.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")i.push({end:"game_end"});else if(e==="done")i.push({end:"label_end",goNextStep:true});else if(e==="<>")if(i.length>0){let u=i[i.length-1];u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true),i[i.length-1]=u;}else i.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=Ue(e.value)),i.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":i.push({goNextStep:true,operations:[e]});break;default:if(!s&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}i.push({conditionalStep:e});}else if("->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let h=i[i.length-1];h.labelToOpen||(h.goNextStep=true),i[i.length-1]=h;}if(e.params&&e.params.length===0&&delete e.params,e.var)i.push({labelToOpen:{label:Ft({key:e["->"],defaultType:"storage"},r),type:l?"call":"jump",params:e.params},glueEnabled:u});else {let h=Ht(e["->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:oa(h,l),params:e.params},glueEnabled:u});}}else if("->t->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let c=i[i.length-1];c.labelToOpen||(c.goNextStep=true),i[i.length-1]=c;}e.params&&e.params.length===0&&delete e.params;let h=Ht(e["->t->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:"call",params:e.params},glueEnabled:u});}}}function Jd(i,e){let t;if(i.includes(": ")){let n=i.split(": "),r=n[0],a=n.slice(1).join(": ");(e?.has(r)||RegisteredCharacters.has(r))&&(t=r,i=a);}return t?{dialogue:{character:t,text:i}}:{dialogue:i}}function ua(i,e,t,n=true,r=false){return Hd(i,e,t,n,r)}function Hd(i,e,t,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(Ue(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function Ai(i,e,t,n){if(i.length===0){W.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let r=mt(i,e,t,n);if(r.length===1){let a=r[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function zt(i,e,t,n="",r,a,s=void 0){let o=[],l="sequential",u=false,h=true;i.forEach(f=>{f==="%"&&(l="loop"),f==="seq"&&(l="random"),f==="MIN"&&(u=true);});let c=i[i.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=[];gt(C,n,r,g,e,e,t,Ut,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 gt(i,e,t,n=[],r,a,s,o,l=void 0,u=true,h=[]){let c=false,p=[],f=false,C=false,g=false,A=[],D=[];if(t.preDialog[e]&&(u=false,r(n,`^${t.preDialog[e].text}`,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),t.preDialog[e].glue&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),delete t.preDialog[e]),i.includes("visit")){let d=zt(i,a,s,e,t,h,l);d&&(!u&&n.length>0&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}));return}let y=i[0];if(y&&typeof y=="object"&&"temp="in y){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)h.push(i[0]["temp="]),i.shift();h=h.reverse();}if(i.forEach((d,E)=>{if(C){if(typeof d=="string"&&d==="/#"){let m=[];gt(D,e,t,m,ua,ua,s,o,l,u),r(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),C=false,D=[];}else D.push(d);return}else if(c)if(Array.isArray(d))p.push(d);else if(d&&typeof d=="object")"CNT?"in d?E>0&&i[E-1]==="ev"?(f=true,A.push(d)):f?A.push(d):(p.push(d),u=false):"VAR="in d||"temp="in d?xn({key:"VAR="in d?d["VAR="]:d["temp="],value:i[E-1],defaultType:"VAR="in d?"storage":"tempstorage"},h,t).forEach(S=>{if(S.value&&typeof S.value=="string"&&S.value==="/str"&&(S.value=i[E-2]),S.value&&typeof S.value=="object"&&"^->"in S.value&&(S.value=S.value["^->"]),p.length>1){let x=Ai(p,e,h,t);p=[],x&&typeof x=="object"&&"type"in x&&x.type==="value"&&"storageType"in x&&x.storageType==="logic"&&(S.value=x.operation);}(typeof S.key!="string"||!S.key.includes("$r"))&&(r(n,S,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&&A.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 S=Ft({key:m["VAR?"],defaultType:"storage"},h);r(n,S,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}else {let S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let x=Ai(S,e,h,t);p=[],x&&typeof x=="object"&&"type"in x&&x.type==="value"&&"storageType"in x&&x.storageType==="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:x.operation,type:"value"},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):(r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),x=`^${x}`,r(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 S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let x=mt(S,e,h,t);p=[],x.forEach(P=>{P&&typeof P=="object"&&"type"in P&&P.type==="function"?r(n,P,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):W.warn("Unhandled case: value is not a function",P);}),u=false;}else p.push(d);return}default:p.push(d);}else if(typeof d=="string")if(d.startsWith("^"))r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="ev")c=true;else if(d===`
|
|
68
68
|
`)u=true;else if(d==="done"||d==="end")r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="<>")r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="nop"&&f){let m=Tu(A,a,s,e,t,h,l);m&&r(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),f=false,A=[];}else d==="#"?C=true:d==="thread"&&(g=true);else if(Array.isArray(d))if(f)A.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=[],S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)m.push(p.pop());A=[...A,...m.reverse()],f=true,S.push(d.pop()),S.push(d.pop()),A=[...A,...d],A.push(S);}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){W.error("Error parsing ink file: el is undefined");return}let S=m["#n"];delete m["#n"],d.push(m),r(n,{"->":e?e+"_|_"+S:S},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),s({[S]:d},e,t);}else gt(d,e,t,n,r,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=aa(["ev",...p],e,h,t)),d.params=m,r(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=aa(["ev",...p],e,h,t)),d.params=m,r(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="],S,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(),S=Ai(x,e,h,t),p=[],xn({key:m,value:S,defaultType:"VAR="in d?"storage":"tempstorage",artmeticValue:true},h,t).forEach(N=>{(N.value!==void 0||N.value!==null)&&r(n,N,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],E=n[1];d&&E&&typeof d=="object"&&"dialogue"in d&&typeof E=="object"&&"labelToOpen"in E&&d.dialogue===" "&&E.labelToOpen&&(n.shift(),delete E.glueEnabled,n[0]=E);}}function ca(i,e,t,n,r,a){if(e.length===0)return;let s=mt(e,n,t,r);if(s.length===1){let o={type:"ifelse",condition:s[0],then:i,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:i,else:a};return o.else||delete o.else,o}}function Tu(i,e,t,n,r,a,s=void 0){if(i.length===0){W.error("Error parsing ink file: Conditional statement is not valid",i);return}let o=[],l=[];if(i.forEach(c=>{Array.isArray(c)?l.push(c):typeof c=="string"&&c==="du"?r.du?o.push(r.du):r.du=o[o.length-1]:(typeof c!="string"||c!=="/ev")&&o.push(c);}),l.length===0){W.error("Error parsing ink file: Conditional statement is not valid",l);return}let u=ha(l[0],e,t,`${n}${"_|_"}then`,r,a,`${s||""}then`),h;return l.length===2?h=ha(l[1],e,t,`${n}${"_|_"}else`,r,a,`${s||""}else`):l.length>2?(l.shift(),l.push("nop"),l=[{b:l}],h=ha(l,e,t,`${n}${"_|_"}else`,r,a,`${s||""}else`)):h=void 0,r.du=void 0,ca(u,o,a,n,r,h)}function ha(i,e,t,n,r,a,s=void 0){let o=[];for(let u of i)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["->"]))),gt(u.b,n,r,o,e,e,t,Ut,s,true,a));return o.length===1?o[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:o}}function da(i="",e=""){let t=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...t,...n])]}function Ut(i,e,t,n,r){if(i.length>0){let a={};Pu(i,a,r,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:oa(l,false),oneTime:o.onetime};o.text.length===0&&(u.onlyHaveNoChoice=true,u.autoSelect=true),u.oneTime===false&&delete u.oneTime;let h=ca(u,o.conditions,r,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):W.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",o,p),c.choices=p.sort((f,C)=>{try{let g=f.label.split("."),A=g[g.length-1].replaceAll(".","_|_"),D=C.label.split("."),y=D[D.length-1].replaceAll(".","_|_");if(A.includes("c-")&&y.includes("c-")){let d=A.split("c-")[1],E=Number(d),m=y.split("c-")[1],S=Number(m);return E-S}}catch{}return 0});}else e.push({choices:[h]});o.preDialog&&(n.preDialog[l]={...o.preDialog});}}}function Pu(i,e,t,n,r){let a=[],s="",o="",l=false,u=[];for(let h=0;h<i.length;h++){let c=i[h];if(typeof c=="string")c.startsWith("^")?a.push(Ue(c)):wu.includes(c)&&u.push(c);else if(Array.isArray(c)&&c.includes("visit")){let p=zt(c,bi,(f,C,g)=>{},r,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=Fu(c.s),f=c.s.includes("<>");p&&(r&&e[r]?(e[r].preDialog={text:p,glue:f},e[r].text=da(p,e[r].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=da(a,e[s].text):e[s]={text:a,onetime:l,conditions:u},o&&(e[s].preDialog={text:o,glue:false});let p=i.slice(h+1);Pu(p,e,t,n,s);return}}}function Fu(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return Ue(e)}else if(Array.isArray(e)){let t=Fu(e);if(t)return t}}var pa;(r=>{function i(a,s={}){let{labelToRemove:o=[],initialVarsToRemove:l=[],enums:u={},functions:h=[],preDialog:c={},characterIds:p}=s,f={$schema:cu};if(f.labels=e(a.root,{labelToRemove:o,initialVarsToRemove:l,enums:u,functions:h,preDialog:c,characterIds:p}),f.labels&&Di in f.labels){let C=f.labels[Di];delete f.labels[Di],C.forEach(g=>{g.operations&&(f.initialOperations=f.initialOperations?[...f.initialOperations,...g.operations]:[...g.operations]);});}if(f.labels&&Pt in f.labels){let C=f.labels[Pt];delete f.labels[Pt],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}r.inkToJson=i;function e(a,s){try{let o={};return t(a,o,s),o}catch(o){W.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=zt(l,bi,(h,c,p)=>{},"",o,[]);u&&(o.externalSwitch=u);}else t(l,s,o);else typeof l=="object"&&(l&&"VAR="in l&&o.externalSwitch&&(s[Pt]||(s[Pt]=[]),s[Pt].push({operations:xn({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;gt(h,f,l,c,la,la,(C,g,A)=>{n(C,p,g,A);},Ut);for(let[C,g]of Object.entries(p))s[C]=g;c.length>0&&(s[f]=c);}}}})(pa||={});var xc=Us(Ac(),1),_c=Us(Kt(),1),LC=/(?:^|<>)\s*#\s*([^\r\n]+)/g,BC=/^=+[ \t]+(?:function[ \t]+)?(\w+)/gm,WC=new Set(["DONE","END"]),jC="_|_",wc=new Map;function Oc(i,e){let t=JSON.stringify([e,i]),n=wc.get(t);if(n)return n;let r=new RegExp(i,e);return wc.set(t,r),r}function ci(i,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(s=>ci(i,s));let r=t.oneOf;if(Array.isArray(r))return r.some(s=>ci(i,s));let a=t.allOf;if(Array.isArray(a))return a.every(s=>ci(i,s));if(typeof t.const=="string")return i===t.const;if(Array.isArray(t.enum))return t.enum.some(s=>typeof s=="string"&&s===i);if(t.type!=="string"||typeof t.minLength=="number"&&i.length<t.minLength||typeof t.maxLength=="number"&&i.length>t.maxLength)return false;if(typeof t.pattern=="string")try{if(!Oc(t.pattern,"").test(i))return !1}catch{return false}return true}function zs(i,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(o=>zs(i,o));let r=t.oneOf;if(Array.isArray(r))return r.some(o=>zs(i,o));let a=t.allOf;if(Array.isArray(a))return a.every(o=>zs(i,o));if(t.type!=="array"||typeof t.minItems=="number"&&i.length<t.minItems||typeof t.maxItems=="number"&&i.length>t.maxItems)return false;let s=Array.isArray(t.prefixItems)?t.prefixItems:[];if(i.length<s.length)return false;for(let o=0;o<s.length;o++)if(!ci(i[o],s[o]))return false;return i.length===s.length?true:t.items===false||typeof t.items>"u"?false:t.items===true?true:i.slice(s.length).every(o=>ci(o,t.items))}function qC(i,e){if(e.type==="regexp")try{let t=Oc(e.source,e.flags);return t.lastIndex=0,t.test(i.join(" "))}catch{return false}return e.type==="literal"?i.join(" ")===e.value:zs(i,e.schema)}function MC(i){let e=i.split(/\r?\n/),t=[];for(let n=0;n<e.length;n++){let r=e[n];for(let a of r.matchAll(LC)){let s=(a[1]??"").trim();if(!s)continue;let o=O.convertTagTolist(s,{mergeInkVariables:true});o.length!==0&&t.push({line:n+1,command:s,tokens:o});}}return t}var kl;(r=>{function i(a,s={labelToRemove:[],initialVarsToRemove:[],functions:[],enums:{}}){let o=[];try{return {json:new xc.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?i(h.textSource,s):{issues:o}}}r.compile=i;function e(a,s,o){let{functions:l,initialVarsToRemove:u,labelToRemove:h}=o,c=a.find(p=>p.type===_c.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=`
|
|
69
69
|
|
|
70
70
|
=== ${f} ===
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import {g,m,f as f$1,i}from'./chunk-
|
|
1
|
+
import {g,m,f as f$1,i}from'./chunk-3K2SER36.mjs';async function f(r,s={}){Array.isArray(r)||(r=[r]),g();let p={functions:[],enums:{},characters:s.characters},m$1=r.map(async a=>{let n=m(a,p);return n&&await f$1(n,{operationStringConvert:i.run,skipEmptyDialogs:true}),a});return await Promise.all(m$1)}async function h(r){return g(),await f$1(r,{operationStringConvert:i.run,skipEmptyDialogs:true})}export{f as a,h as b};
|
package/dist/index.cjs
CHANGED
|
@@ -56,7 +56,7 @@ ${E}`),E&&(o=true),s=_.getLogichValue(y.glueEnabled,e)||false,E)}),u=_.getLogich
|
|
|
56
56
|
`+A+"}";}}return r.pop(),a=A,d}function f(g){if(g.length===0)return c(g);let A=String.fromCodePoint(g.codePointAt(0));if(!ne.isIdStartChar(A))return c(g);for(let D=A.length;D<g.length;D++)if(!ne.isIdContinueChar(String.fromCodePoint(g.codePointAt(D))))return c(g);return g}function C(g){if(r.indexOf(g)>=0)throw TypeError("Converting circular structure to JSON5");r.push(g);let A=a;a=a+l;let D=[];for(let d=0;d<g.length;d++){let E=h(String(d),g);D.push(E!==void 0?E:"null");}let y;if(D.length===0)y="[]";else if(l==="")y="["+D.join(",")+"]";else {let d=`,
|
|
57
57
|
`+a,E=D.join(d);y=`[
|
|
58
58
|
`+a+E+`,
|
|
59
|
-
`+A+"]";}return r.pop(),a=A,y}},$d={parse:Ld,stringify:Gd},Jd=$d,xn=Jd;var Du="\xA7SPACE\xA7",bu="\xA7DOUBLE_QUOTES\xA7",Au="\xA7QUOTES\xA7",xu="SPECIAL_\xA7QUOTES\xA7",wu="\xA7CURLY_BRACKETS1\xA7",Hd="\xA7INK_VAR\xA7",_u="\xA7CURLY_BRACKETS2\xA7";exports.HashtagCommands=void 0;(y=>{let i=[],e=[];async function t(d,E){for(let m=0;m<i.length;m++)try{let{validation:S}=i[m].opts;if(S instanceof RegExp){if(!S.test(d.join(" ")))continue}else if(S instanceof v.ZodType&&!S.safeParse(d).success)continue;let w=await i[m].fn(d,E,c);if(w===!0||typeof w=="string")return w}catch{}return false}function n(d,E={name:"custom-command",validation:/^/}){i.unshift({fn:d,opts:E});}y.add=n;function r(){return [...e.map(d=>d.opts),...i.map(d=>d.opts)]}y.info=r;function a(d,E){e.unshift({fn:d,opts:E});}y.addMapper=a;function s(){i.length=0;}y.clear=s;function o(){e.length=0;}y.clearMappers=o;async function l(d,E,m){try{let S=u(d),w=await t(S,m);return w===!0?void 0:typeof w=="string"?(w.startsWith("#")&&(w=w.substring(1)),await y.run(w,E,m)):h(S,E)}catch(S){throw W.error("Error parsing ink hashtag-command",d),S}}y.run=l;function u(d,E){if(d=d.replaceAll('\\"',bu),d=d.replaceAll("\\'",Au),d=d.replaceAll("\\`",xu),d=d.replaceAll("\\{",wu),d=d.replaceAll("\\}",_u),E?.mergeInkVariables){let P;do P=d,d=d.replace(/\{[^{}:]*\}/g,Hd);while(d!==P)}d=d.replaceAll("{"," { "),d=d.replaceAll("}"," } "),d=d.replaceAll(wu,"{"),d=d.replaceAll(_u,"}");let m=[],S,w="";for(let P=0;P<d.length;P++){let N=d[P];N==='"'||N==="'"||N==="`"?S===void 0?(m.push(w),w="",S=N,w+=N):S===N?(S=void 0,w+=N,m.push(w),w=""):w+=N:w+=N;}return w!==""&&m.push(w),m.forEach((P,N)=>{N%2===1&&(m[N]=P.replaceAll(" ",Du));}),d=m.join(""),m=d.split(" ").filter(P=>P!==""),m=m.map(P=>P.replaceAll(Du," ").replaceAll(bu,'"').replaceAll(Au,"'").replaceAll(xu,"`")),m=g(m),m=m.map(P=>P.startsWith('"')&&P.endsWith('"')||P.startsWith("'")&&P.endsWith("'")||P.startsWith("`")&&P.endsWith("`")?P.slice(1,-1):P),m}y.convertTagTolist=u;function h(d,E){for(let
|
|
59
|
+
`+A+"]";}return r.pop(),a=A,y}},$d={parse:Ld,stringify:Gd},Jd=$d,xn=Jd;var Du="\xA7SPACE\xA7",bu="\xA7DOUBLE_QUOTES\xA7",Au="\xA7QUOTES\xA7",xu="SPECIAL_\xA7QUOTES\xA7",wu="\xA7CURLY_BRACKETS1\xA7",Hd="\xA7INK_VAR\xA7",_u="\xA7CURLY_BRACKETS2\xA7";exports.HashtagCommands=void 0;(y=>{let i=[],e=[];async function t(d,E){for(let m=0;m<i.length;m++)try{let{validation:S}=i[m].opts;if(S instanceof RegExp){if(!S.test(d.join(" ")))continue}else if(S instanceof v.ZodType&&!S.safeParse(d).success)continue;let w=await i[m].fn(d,E,c);if(w===!0||typeof w=="string")return w}catch{}return false}function n(d,E={name:"custom-command",validation:/^/}){i.unshift({fn:d,opts:E});}y.add=n;function r(){return [...e.map(d=>d.opts),...i.map(d=>d.opts)]}y.info=r;function a(d,E){e.unshift({fn:d,opts:E});}y.addMapper=a;function s(){i.length=0;}y.clear=s;function o(){e.length=0;}y.clearMappers=o;async function l(d,E,m){try{let S=u(d),w=await t(S,m);return w===!0?void 0:typeof w=="string"?(w.startsWith("#")&&(w=w.substring(1)),await y.run(w,E,m)):h(S,E)}catch(S){throw W.error("Error parsing ink hashtag-command",d),S}}y.run=l;function u(d,E){if(d=d.replaceAll('\\"',bu),d=d.replaceAll("\\'",Au),d=d.replaceAll("\\`",xu),d=d.replaceAll("\\{",wu),d=d.replaceAll("\\}",_u),E?.mergeInkVariables){let P;do P=d,d=d.replace(/\{[^{}:]*\}/g,Hd);while(d!==P)}d=d.replaceAll("{"," { "),d=d.replaceAll("}"," } "),d=d.replaceAll(wu,"{"),d=d.replaceAll(_u,"}");let m=[],S,w="";for(let P=0;P<d.length;P++){let N=d[P];N==='"'||N==="'"||N==="`"?S===void 0?(m.push(w),w="",S=N,w+=N):S===N?(S=void 0,w+=N,m.push(w),w=""):w+=N:w+=N;}return w!==""&&m.push(w),m.forEach((P,N)=>{N%2===1&&(m[N]=P.replaceAll(" ",Du));}),d=m.join(""),m=d.split(" ").filter(P=>P!==""),m=m.map(P=>P.replaceAll(Du," ").replaceAll(bu,'"').replaceAll(Au,"'").replaceAll(xu,"`")),m=g(m),m=m.map(P=>P.startsWith('"')&&P.endsWith('"')||P.startsWith("'")&&P.endsWith("'")||P.startsWith("`")&&P.endsWith("`")?P.slice(1,-1):P),m}y.convertTagTolist=u;function h(d,E,m){for(let S of e){let{validation:w}=S.opts,P=false;if(w instanceof RegExp?P=w.test(d.join(" ")):w instanceof v.ZodType&&(P=w.safeParse(d).success),P)return S.fn(d,E)}m?.silent||W.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 W.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 E="{";d.forEach((m,S)=>{if(S%2===0)E+=`"${m}": `;else {switch(m){case "null":case "undefined":case "true":case "false":E+=`${m}`;break;default:C(m)?(m=f(m),E+=`"${m}"`):m.startsWith("{")&&m.endsWith("}")?E+=`${m}`:m.startsWith('"')&&m.endsWith('"')?E+=`${m}`:Number.isNaN(parseFloat(m))?E+=`"${m}"`:E+=`${m}`;}S<d.length-1&&(E+=", ");}}),E+="}";try{return xn.parse(E)}catch(m){throw W.error("Error parsing ink json",E),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 A(d).tokens}y.mergeJsonBlocks=g;function A(d){let E=[],m=false;for(let S=0;S<d.length;S++){let w=d[S];if(w!=="{"){E.push(w);continue}let P=D(d,S);if(P===-1){E.push(w);continue}let N=A(d.slice(S+1,P)),Z=["{",...N.tokens,"}"],ve=Z.join(" ");if(!N.hasInvalidMatchedBlock)try{xn.parse(ve),E.push(ve),S=P;continue}catch{}m=true,E.push(...Z),S=P;}return {tokens:E,hasInvalidMatchedBlock:m}}function D(d,E){let m=0;for(let S=E;S<d.length;S++)if(d[S]==="{")m++;else if(d[S]==="}"&&(m--,m===0))return S;return -1}})(exports.HashtagCommands||={});function zd(i){exports.HashtagCommands.add(i);}exports.HashtagCommands.addMapper((i,e)=>{e.labelToOpen={label:i[1],type:"call"},e.goNextStep=void 0;},{name:"Call",description:"Calls the label specified by the second token, then returns to the current position.\n\n```ink\n# call label_name\n```",validation:v__default.default.tuple([v__default.default.literal("call"),v__default.default.string()])});exports.HashtagCommands.addMapper((i,e)=>{e.labelToOpen={label:i[1],type:"jump"},e.goNextStep=void 0;},{name:"Jump",description:"Jumps to the label specified by the second token without returning.\n\n```ink\n# jump label_name\n```",validation:v__default.default.tuple([v__default.default.literal("jump"),v__default.default.string()])});exports.HashtagCommands.addMapper((i,e)=>("dialogue"in e&&delete e.dialogue,"goNextStep"in e&&delete e.goNextStep,{type:"dialogue",operationType:"clean"}),{name:"Pause",description:"Clears the current dialogue and waits for user input before advancing.\n\n```ink\n# pause\n```",validation:v__default.default.tuple([v__default.default.literal("pause")])});exports.HashtagCommands.addMapper((i,e)=>{e.goNextStep=true,e.glueEnabled=false;},{name:"Continue",description:"Forces the story to proceed to the next step automatically.\n\n```ink\n# continue\n```",validation:v__default.default.tuple([v__default.default.literal("continue")])});exports.HashtagCommands.addMapper(i=>({type:"video",operationType:i[0],alias:i[2]}),{name:"Pause/Resume video",description:"Pauses or resumes a video canvas element identified by its alias.\n\n```ink\n# pause video <alias>\n# resume video <alias>\n```",validation:v__default.default.tuple([v__default.default.enum(["pause","resume"]),v__default.default.literal("video"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:i[1],operationType:i[0],aliases:i.slice(2)}),{name:"Load assets/bundle",description:`Loads (eagerly or lazily) a set of asset or bundle aliases.
|
|
60
60
|
|
|
61
61
|
\`\`\`ink
|
|
62
62
|
# load assets <alias...>
|
|
@@ -64,7 +64,7 @@ ${E}`),E&&(o=true),s=_.getLogichValue(y.glueEnabled,e)||false,E)}),u=_.getLogich
|
|
|
64
64
|
# load bundle <alias...>
|
|
65
65
|
# lazyload bundle <alias...>
|
|
66
66
|
\`\`\``,validation:v__default.default.tuple([v__default.default.enum(["load","lazyload"]),v__default.default.enum(["assets","bundle"])]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"all",operationType:i[0]}),{name:"Pause/Resume/Stop all sounds",description:"Pauses, resumes, or stops all active sounds at once.\n\n```ink\n# pause all sounds\n# resume all sounds\n# stop all sounds\n```",validation:v__default.default.tuple([v__default.default.enum(["pause","resume","stop"]),v__default.default.literal("all"),v__default.default.enum(["sounds","sound"])])});exports.HashtagCommands.addMapper(i=>({type:"sound",operationType:"pause",alias:i[2]}),{name:"Pause sound",description:"Pauses the sound identified by its alias.\n\n```ink\n# pause sound <alias>\n```",validation:v__default.default.tuple([v__default.default.literal("pause"),v__default.default.literal("sound"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:"channel",operationType:"pause",alias:i[2]}),{name:"Pause channel",description:"Pauses the audio channel identified by its alias.\n\n```ink\n# pause channel <alias>\n```",validation:v__default.default.tuple([v__default.default.literal("pause"),v__default.default.literal("channel"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:"sound",operationType:"resume",alias:i[2]}),{name:"Resume sound",description:"Resumes the sound identified by its alias.\n\n```ink\n# resume sound <alias>\n```",validation:v__default.default.tuple([v__default.default.literal("resume"),v__default.default.literal("sound"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:"channel",operationType:"resume",alias:i[2]}),{name:"Resume channel",description:"Resumes the audio channel identified by its alias.\n\n```ink\n# resume channel <alias>\n```",validation:v__default.default.tuple([v__default.default.literal("resume"),v__default.default.literal("channel"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:"sound",operationType:"stop",alias:i[2]}),{name:"Stop sound",description:"Stops the sound identified by its alias.\n\n```ink\n# stop sound <alias>\n```",validation:v__default.default.tuple([v__default.default.literal("stop"),v__default.default.literal("sound"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:"sound",operationType:"stop",alias:i[2]}),{name:"Remove sound",description:"Removes (stops) the sound identified by its alias.\n\n```ink\n# remove sound <alias>\n```",deprecated:true,validation:v__default.default.tuple([v__default.default.literal("remove"),v__default.default.literal("sound"),v__default.default.string()])});exports.HashtagCommands.addMapper(i=>({type:"sound",operationType:"edit",alias:i[2],props:exports.HashtagCommands.convertListStringToObj(i.slice(3))}),{name:"Edit sound",description:"Edits the properties of a sound identified by its alias.\n\n```ink\n# edit sound <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("edit"),v__default.default.literal("sound"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>(i.length-3)%2===0)});exports.HashtagCommands.addMapper(i=>{let e=i[2],t={type:"sound",operationType:"play",alias:e,url:e};return i.length>3&&(t.props=exports.HashtagCommands.convertListStringToObj(i.slice(3))),t},{name:"Play sound",description:"Plays a sound using its alias as the URL, with optional key/value properties.\n\n```ink\n# play sound <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("play"),v__default.default.literal("sound"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>(i.length-3)%2===0)});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=i[3],n={type:"sound",operationType:"play",alias:e,url:t};return i.length>4&&(n.props=exports.HashtagCommands.convertListStringToObj(i.slice(4))),n},{name:"Play sound with source",description:"Plays a sound with an explicit source URL and optional key/value properties.\n \n```ink\n# play sound <alias> <source> [<key> <value> \u2026]\n```\n",validation:v__default.default.tuple([v__default.default.literal("play"),v__default.default.literal("sound"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>i.length>3&&(i.length-3)%2!==0)});function ze(i){let e=[],t=0,n="";for(let r of i)r.startsWith("{")?(t++,n+=r):r.endsWith("}")&&t>0?(t--,n+=r,t===0&&(e.push(n),n="")):t>0?n+=r:e.push(r);return e}function bi(i,e){switch(i){case "dissolve":case "fade":case "movein":case "moveout":case "zoomin":case "zoomout":case "pushin":case "pushout":break;default:return}let t={type:i};if(e.length>0)try{t.props=exports.HashtagCommands.convertListStringToObj(e);}catch{}return t}function Tu(i,e,t){let n,r;t.length%2===0?(n=e,r=t):(n=t[0],r=t.slice(1));let a={type:i,operationType:"show",alias:e,url:n};if(r.length>0){if(r.includes("with")&&r.length>r.indexOf("with")+1){let s=r[r.indexOf("with")+1],o=r.slice(r.indexOf("with")+2);r=r.slice(0,r.indexOf("with"));let l=bi(s,o);l!==void 0&&(a.transition=l);}r.length>0&&(a.props=exports.HashtagCommands.convertListStringToObj(r));}return a}function Ud(i,e){let t,n;e.length%2===0?(t=i,n=e):(t=e[0],n=e.slice(1));let r={type:"text",operationType:"show",alias:i,text:t};if(n.length>0){if(n.includes("with")&&n.length>n.indexOf("with")+1){let a=n[n.indexOf("with")+1],s=n.slice(n.indexOf("with")+2);n=n.slice(0,n.indexOf("with"));let o=bi(a,s);o!==void 0&&(r.transition=o);}n.length>0&&(r.props=exports.HashtagCommands.convertListStringToObj(n));}return r}function wn(i,e,t){let n={type:i,operationType:"remove",alias:e};if(t.includes("with")&&t.length>t.indexOf("with")+1){let r=t[t.indexOf("with")+1],a=t.slice(t.indexOf("with")+2),s=bi(r,a);s!==void 0&&(n.transition=s);}return n}function aa(i,e){let t=l=>l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'")||l.startsWith("`")&&l.endsWith("`")?l.substring(1,l.length-1):l,n=[],r=e.findIndex(l=>l.startsWith("[")),a=e.findIndex(l=>l.endsWith("]"));if(r===-1||a===-1){W.error("Show imagecontainer must have a list of image ulrs",e);return}if(n=e.slice(r,a+1),n.length<2){W.error("Show imagecontainer must have a list of image ulrs",e);return}n[0]==="["?n.shift():n[0]=n[0].substring(1),n[n.length-1]==="]"?n.pop():n[n.length-1]=n[n.length-1].substring(0,n[n.length-1].length-1);let s={type:"imagecontainer",operationType:"show",alias:i,urls:n.map(l=>t(l))},o=e.slice(a+1);if(o.length>0){if(o.includes("with")&&o.length>o.indexOf("with")+1){let l=o[o.indexOf("with")+1],u=o.slice(o.indexOf("with")+2);o=o.slice(0,o.indexOf("with"));let h=bi(l,u);h!==void 0&&(s.transition=h);}o.length>0&&(s.props=exports.HashtagCommands.convertListStringToObj(o));}return s}function oa(i){let e=i.slice(3),t=e.findIndex(s=>s.startsWith("[")),n=e.findIndex(s=>s.endsWith("]"));if(t===-1||n===-1||n<t)return;let r=e.slice(n+1),a=r.indexOf("with");return a===-1?{beforeWith:r,afterWith:[]}:{beforeWith:r.slice(0,a),afterWith:r.slice(a+1)}}exports.HashtagCommands.addMapper(i=>({alias:i[1],type:"shake",props:exports.HashtagCommands.convertListStringToObj(i.slice(2))}),{name:"Shake",description:"Applies shake effect to a canvas alias with optional key/value parameters.\n\n```ink\n# shake <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("shake"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>(i.length-2)%2===0)});exports.HashtagCommands.addMapper(i=>{let e=i.slice(2),t=e,n=[];if(e.includes("options")){let a=e.indexOf("options");t=e.slice(0,a),n=e.slice(a+1);}return {alias:i[1],type:"animate",keyframes:exports.HashtagCommands.convertListStringToObj(t),options:exports.HashtagCommands.convertListStringToObj(n)}},{name:"Animate",description:"Animates a canvas alias with keyframes and optional options section, both in key/value pairs.\n\n```ink\n# animate <alias> [<key> <value> \u2026] [options <key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("animate"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>{let e=i.slice(2),t=e.indexOf("options");if(t===-1)return e.length%2===0;if(e.lastIndexOf("options")!==t)return false;let n=e.slice(0,t),r=e.slice(t+1);return n.length%2===0&&r.length%2===0})});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return Tu("image",e,t)},{name:"Show image",description:"Shows an image canvas element with optional source URL, key/value properties, and transition effect.\n\n```ink\n# show image <alias> [<source>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("show"),v__default.default.literal("image"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>aa(i[2],ze(i.slice(3))),{name:"Show imagecontainer",description:"Shows an image-container canvas element with a list of image URLs and optional key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("show"),v__default.default.literal("imagecontainer"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>{let e=oa(i);return e===void 0?false:e.afterWith.length===0&&e.beforeWith.length%2===0})});exports.HashtagCommands.addMapper(i=>aa(i[2],ze(i.slice(3))),{name:"Show imagecontainer with transition",description:"Shows an image-container canvas element with a list of image URLs, optional properties, and a transition effect.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout\n```",validation:v__default.default.tuple([v__default.default.literal("show"),v__default.default.literal("imagecontainer"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>{let e=oa(i);return e===void 0?false:e.afterWith.length===1&&e.beforeWith.length%2===0})});exports.HashtagCommands.addMapper(i=>aa(i[2],ze(i.slice(3))),{name:"Show imagecontainer with transition and props",description:"Shows an image-container canvas element with a list of image URLs, optional properties, a transition effect, and transition key/value properties.\n\n```ink\n# show imagecontainer <alias> [ <url1> <url2> \u2026 ] [<key> <value> \u2026] with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout <key> <value> \u2026\n```",validation:v__default.default.tuple([v__default.default.literal("show"),v__default.default.literal("imagecontainer"),v__default.default.string()]).rest(v__default.default.string()).refine(i=>{let e=oa(i);return e===void 0?false:e.afterWith.length>1&&(e.afterWith.length-1)%2===0&&e.beforeWith.length%2===0})});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return Tu("video",e,t)},{name:"Show video",description:"Shows a video canvas element with optional source URL, key/value properties, and transition effect.\n\n```ink\n# show video <alias> [<source>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("show"),v__default.default.literal("video"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>{let e=i[2];return Ud(e,i.slice(3))},{name:"Show text",description:"Shows a text canvas element with optional text content, key/value properties, and transition effect.\n\n```ink\n# show text <alias> [<text>] [<key> <value> \u2026] [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("show"),v__default.default.literal("text"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("image",e,t)},{name:"Remove image",description:"Removes an image canvas element with an optional transition effect.\n\n```ink\n# remove image <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("remove"),v__default.default.literal("image"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("video",e,t)},{name:"Remove video",description:"Removes a video canvas element with an optional transition effect.\n\n```ink\n# remove video <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("remove"),v__default.default.literal("video"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("canvaselement",e,t)},{name:"Remove canvas element",description:"Removes a canvas element with an optional transition effect.\n\n```ink\n# remove canvaselement <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("remove"),v__default.default.literal("canvaselement"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("text",e,t)},{name:"Remove text",description:"Removes a text canvas element with an optional transition effect.\n\n```ink\n# remove text <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("remove"),v__default.default.literal("text"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>{let e=i[2],t=ze(i.slice(3));return wn("imagecontainer",e,t)},{name:"Remove imagecontainer",description:"Removes an image-container canvas element with an optional transition effect.\n\n```ink\n# remove imagecontainer <alias> [with dissolve|fade|movein|moveout|zoomin|zoomout|pushin|pushout [<key> <value> \u2026]]\n```",validation:v__default.default.tuple([v__default.default.literal("remove"),v__default.default.literal("imagecontainer"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"image",operationType:"edit",alias:i[2],props:exports.HashtagCommands.convertListStringToObj(i.slice(3))}),{name:"Edit image",description:"Edits the properties of an image canvas element identified by its alias.\n\n```ink\n# edit image <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("edit"),v__default.default.literal("image"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"imagecontainer",operationType:"edit",alias:i[2],props:exports.HashtagCommands.convertListStringToObj(i.slice(3))}),{name:"Edit imagecontainer",description:"Edits the properties of an image-container canvas element identified by its alias.\n\n```ink\n# edit imagecontainer <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("edit"),v__default.default.literal("imagecontainer"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"canvaselement",operationType:"edit",alias:i[2],props:exports.HashtagCommands.convertListStringToObj(i.slice(3))}),{name:"Edit canvas element",description:"Edits the properties of a canvas element identified by its alias.\n\n```ink\n# edit canvaselement <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("edit"),v__default.default.literal("canvaselement"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"video",operationType:"edit",alias:i[2],props:exports.HashtagCommands.convertListStringToObj(i.slice(3))}),{name:"Edit video",description:"Edits the properties of a video canvas element identified by its alias.\n\n```ink\n# edit video <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("edit"),v__default.default.literal("video"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"text",operationType:"edit",alias:i[2],props:exports.HashtagCommands.convertListStringToObj(i.slice(3))}),{name:"Edit text",description:"Edits the properties of a text canvas element identified by its alias.\n\n```ink\n# edit text <alias> [<key> <value> \u2026]\n```",validation:v__default.default.tuple([v__default.default.literal("edit"),v__default.default.literal("text"),v__default.default.string()]).rest(v__default.default.string())});exports.HashtagCommands.addMapper(i=>({type:"input",operationType:"request"}),{name:"Request input",description:"Requests player input without any additional constraints.\n\n```ink\n# request input\n```",validation:v__default.default.tuple([v__default.default.literal("request"),v__default.default.literal("input")])});exports.HashtagCommands.addMapper(i=>{let e={type:"input",operationType:"request"};try{let t=exports.HashtagCommands.convertListStringToObj(i.slice(2));"type"in t&&typeof t.type=="string"&&(e.valueType=t.type),"default"in t&&(e.defaultValue=t.default);}catch{}return e},{name:"Request input with params",description:"Requests player input with optional key/value parameters (e.g. type, default).\n\n```ink\n# request input <key> <value> [<key> <value> \u2026]\n# request input type number default 18\n```",validation:v__default.default.tuple([v__default.default.literal("request"),v__default.default.literal("input")]).rest(v__default.default.string()).refine(i=>i.length>2&&(i.length-2)%2===0)});function Kd(i){oe.translate=i;}async function Xd(i,e={},t={}){let n=[];return i.labels&&Object.values(i.labels).forEach(r=>{n=n.concat(r);}),await oe.generateJsonTranslation(n,e,{...t,operationStringConvert:exports.HashtagCommands.run})}var Ou=["+","-","/","*","%","_","==",">","<",">=","<=","!=","!","&&","||","MIN","MAX"],Pu=["+","-","/","*","%","POW","RANDOM","L^"],Fu=["INT","FLOOR","FLOAT"];function Ht(i,e){if(i.endsWith(".s"))return;if(new RegExp(/.*\.[0-9]+\..*$/).test(i)&&(i=i.split(".").filter(r=>!r.match(/^[0-9]+$/)).join("."),!i.startsWith(".")))return i.replaceAll(".","_|_");if(!new RegExp(/^\.\^.*$/).test(i)&&i.includes("g-")){let n=i.split("g-");return la(e)+"_|_"+"g-"+n[n.length-1]}let t=0;for(;new RegExp(/^\.\^.*$/).test(i);)t++,i=i.substring(2);if(t=t-1,new RegExp(/^\..*$/).test(i)&&e){let n=i.substring(1);return la(e,t)+"_|_"+n.replaceAll(".","_|_")}return i.replaceAll(".","_|_")||la(e,t).replaceAll(".","_|_")}function la(i,e=0){let t=i.split("_|_");for(;t.length>1&&e>0;)t.pop()?.includes("g-")&&e--,e--;return t.join("_|_")}var Nu="\xA7DOUBLE_SLASH_CONVERTOR\xA7";function Ue(i){return i.startsWith("^")&&(i=i.substring(1)),i=i.replaceAll("\\\\",Nu),i=i.replaceAll("\\n",`
|
|
67
|
-
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(Nu,"\\\\"),i}function mt(i,e,t,n){let{functions:r}=n;i=i.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return i.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)W.error("Error parsing ink file: Conditional statement is not valid",i);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 W.error("Error parsing ink file: Conditional statement is not valid",i);break;default:if(gu.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(Pu.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(Fu.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(Ue(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){W.error("Error parsing ink file: Conditional statement is not valid",i);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=Ht(c,e);if(!p)return;a.push({type:"compare",leftValue:ua(p),operator:">=",rightValue:{type:"value",value:h}});}else {let o=Ht(s["CNT?"],e);if(!o)return;a.push(ua(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(Ft({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],l=r.find(h=>h.name===o);if(!l){W.error(`Error parsing ink file: Function ${o} is not defined`,i);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 ha(i,e,t,n){return mt(i,e,t,n)}function Ft(i,e,t){let{key:n,defaultType:r}=i,a=e.indexOf(n);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:r,key:n}}function _n(i,e,t){let{key:n,value:r,defaultType:a,artmeticValue:s}=i,o=e.indexOf(n);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:r}];if(s){if(typeof r=="object"&&"list"in r){let l=Object.values(r.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:r}]}else if(typeof r=="object"){if("list"in r&&typeof r.list=="object"){if("origins"in r&&Array.isArray(r.origins)&&r.origins.length>0)return r.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(r.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(r.list)}),u}}else if(typeof r=="object"&&"VAR?"in r){if(typeof r["VAR?"]=="string"&&r["VAR?"].includes(".")){let[l,u]=r["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:Ft({key:r["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:r}]}function ua(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function ca(i,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(i)?"call":"jump"}function Ai(i,e){if(e){if(typeof e=="string")e.startsWith("^")&&i.push(Ue(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:i.push(e);}}}function da(i,e,t,n,r,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:l=false}=a;return Qd(i,e,t,n,r,{isNewLine:s,isHashtagScript:o,isThreads:l})}function Qd(i,e,t,n,r,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(vi)){let c=e[0],p=exports.HashtagCommands.convertTagTolist(c),f=exports.HashtagCommands.convertOperation(p,u);f&&(f.$origin=c,h.push(f));}}catch{}h.length===0&&h.push({type:"operationtoconvert",values:e}),i.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&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&!u.labelToOpen&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}typeof e=="string"?i.push(Zd(Ue(e),n.characterIds)):i.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")i.push({end:"game_end"});else if(e==="done")i.push({end:"label_end",goNextStep:true});else if(e==="<>")if(i.length>0){let u=i[i.length-1];u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true),i[i.length-1]=u;}else i.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=Ue(e.value)),i.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":i.push({goNextStep:true,operations:[e]});break;default:if(!s&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}i.push({conditionalStep:e});}else if("->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let h=i[i.length-1];h.labelToOpen||(h.goNextStep=true),i[i.length-1]=h;}if(e.params&&e.params.length===0&&delete e.params,e.var)i.push({labelToOpen:{label:Ft({key:e["->"],defaultType:"storage"},r),type:l?"call":"jump",params:e.params},glueEnabled:u});else {let h=Ht(e["->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:ca(h,l),params:e.params},glueEnabled:u});}}else if("->t->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let c=i[i.length-1];c.labelToOpen||(c.goNextStep=true),i[i.length-1]=c;}e.params&&e.params.length===0&&delete e.params;let h=Ht(e["->t->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:"call",params:e.params},glueEnabled:u});}}}function Zd(i,e){let t;if(i.includes(": ")){let n=i.split(": "),r=n[0],a=n.slice(1).join(": ");(e?.has(r)||characters.RegisteredCharacters.has(r))&&(t=r,i=a);}return t?{dialogue:{character:t,text:i}}:{dialogue:i}}function pa(i,e,t,n=true,r=false){return ep(i,e,t,n,r)}function ep(i,e,t,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(Ue(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function xi(i,e,t,n){if(i.length===0){W.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let r=mt(i,e,t,n);if(r.length===1){let a=r[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function zt(i,e,t,n="",r,a,s=void 0){let o=[],l="sequential",u=false,h=true;i.forEach(f=>{f==="%"&&(l="loop"),f==="seq"&&(l="random"),f==="MIN"&&(u=true);});let c=i[i.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=[];gt(C,n,r,g,e,e,t,Ut,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 gt(i,e,t,n=[],r,a,s,o,l=void 0,u=true,h=[]){let c=false,p=[],f=false,C=false,g=false,A=[],D=[];if(t.preDialog[e]&&(u=false,r(n,`^${t.preDialog[e].text}`,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),t.preDialog[e].glue&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),delete t.preDialog[e]),i.includes("visit")){let d=zt(i,a,s,e,t,h,l);d&&(!u&&n.length>0&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}));return}let y=i[0];if(y&&typeof y=="object"&&"temp="in y){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)h.push(i[0]["temp="]),i.shift();h=h.reverse();}if(i.forEach((d,E)=>{if(C){if(typeof d=="string"&&d==="/#"){let m=[];gt(D,e,t,m,pa,pa,s,o,l,u),r(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),C=false,D=[];}else D.push(d);return}else if(c)if(Array.isArray(d))p.push(d);else if(d&&typeof d=="object")"CNT?"in d?E>0&&i[E-1]==="ev"?(f=true,A.push(d)):f?A.push(d):(p.push(d),u=false):"VAR="in d||"temp="in d?_n({key:"VAR="in d?d["VAR="]:d["temp="],value:i[E-1],defaultType:"VAR="in d?"storage":"tempstorage"},h,t).forEach(S=>{if(S.value&&typeof S.value=="string"&&S.value==="/str"&&(S.value=i[E-2]),S.value&&typeof S.value=="object"&&"^->"in S.value&&(S.value=S.value["^->"]),p.length>1){let w=xi(p,e,h,t);p=[],w&&typeof w=="object"&&"type"in w&&w.type==="value"&&"storageType"in w&&w.storageType==="logic"&&(S.value=w.operation);}(typeof S.key!="string"||!S.key.includes("$r"))&&(r(n,S,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&&A.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 S=Ft({key:m["VAR?"],defaultType:"storage"},h);r(n,S,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}else {let S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let w=xi(S,e,h,t);p=[],w&&typeof w=="object"&&"type"in w&&w.type==="value"&&"storageType"in w&&w.storageType==="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:w.operation,type:"value"},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):(r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),w=`^${w}`,r(n,w,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 S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let w=mt(S,e,h,t);p=[],w.forEach(P=>{P&&typeof P=="object"&&"type"in P&&P.type==="function"?r(n,P,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):W.warn("Unhandled case: value is not a function",P);}),u=false;}else p.push(d);return}default:p.push(d);}else if(typeof d=="string")if(d.startsWith("^"))r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="ev")c=true;else if(d===`
|
|
67
|
+
`),i=i.replaceAll("\\t"," "),i=i.replaceAll(" "," "),i=i.replaceAll(Nu,"\\\\"),i}function mt(i,e,t,n){let{functions:r}=n;i=i.map(s=>{if(typeof s=="string")switch(s){case "rnd":return "RANDOM";case "?":return "CONTAINS"}return s});let a=[];return i.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)W.error("Error parsing ink file: Conditional statement is not valid",i);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 W.error("Error parsing ink file: Conditional statement is not valid",i);break;default:if(gu.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(Pu.includes(s))if(a.length<2)W.error("Error parsing ink file: Conditional statement is not valid",i);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(Fu.includes(s)){let o={type:"arithmeticsingle",operator:s,leftValue:a[a.length-1]};a.pop(),a.push(o);}else s.startsWith("^")&&a.push(Ue(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){W.error("Error parsing ink file: Conditional statement is not valid",i);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=Ht(c,e);if(!p)return;a.push({type:"compare",leftValue:ua(p),operator:">=",rightValue:{type:"value",value:h}});}else {let o=Ht(s["CNT?"],e);if(!o)return;a.push(ua(o));}else if(typeof s=="object"&&"VAR?"in s)a.push(Ft({key:s["VAR?"],defaultType:"storage"},t));else if(typeof s=="object"&&"f()"in s){let o=s["f()"],l=r.find(h=>h.name===o);if(!l){W.error(`Error parsing ink file: Function ${o} is not defined`,i);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 ha(i,e,t,n){return mt(i,e,t,n)}function Ft(i,e,t){let{key:n,defaultType:r}=i,a=e.indexOf(n);return a>=0?{type:"value",storageType:"params",storageOperationType:"get",key:a}:{type:"value",storageOperationType:"get",storageType:r,key:n}}function _n(i,e,t){let{key:n,value:r,defaultType:a,artmeticValue:s}=i,o=e.indexOf(n);if(o>=0)return [{type:"value",storageType:"params",storageOperationType:"set",key:o,value:r}];if(s){if(typeof r=="object"&&"list"in r){let l=Object.values(r.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:r}]}else if(typeof r=="object"){if("list"in r&&typeof r.list=="object"){if("origins"in r&&Array.isArray(r.origins)&&r.origins.length>0)return r.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(r.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(r.list)}),u}}else if(typeof r=="object"&&"VAR?"in r){if(typeof r["VAR?"]=="string"&&r["VAR?"].includes(".")){let[l,u]=r["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:Ft({key:r["VAR?"],defaultType:"storage"},e)}]}}return [{type:"value",storageOperationType:"set",storageType:a,key:n,value:r}]}function ua(i){return {type:"value",storageType:"label",storageOperationType:"get",label:i}}function ca(i,e){return e||new RegExp(`${"_|_".replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c-\\d+$`).test(i)?"call":"jump"}function Ai(i,e){if(e){if(typeof e=="string")e.startsWith("^")&&i.push(Ue(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:i.push(e);}}}function da(i,e,t,n,r,a={}){let{isNewLine:s=true,isHashtagScript:o=false,isThreads:l=false}=a;return Qd(i,e,t,n,r,{isNewLine:s,isHashtagScript:o,isThreads:l})}function Qd(i,e,t,n,r,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(vi)){let c=e[0],p=exports.HashtagCommands.convertTagTolist(c),f=exports.HashtagCommands.convertOperation(p,u,{silent:!0});f&&(f.$origin=c,h.push(f));}}catch{}h.length===0&&h.push({type:"operationtoconvert",values:e}),i.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&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&!u.labelToOpen&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}typeof e=="string"?i.push(Zd(Ue(e),n.characterIds)):i.push({dialogue:e});}else if(typeof e=="string"){if(e==="end")i.push({end:"game_end"});else if(e==="done")i.push({end:"label_end",goNextStep:true});else if(e==="<>")if(i.length>0){let u=i[i.length-1];u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true),i[i.length-1]=u;}else i.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=Ue(e.value)),i.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":i.push({goNextStep:true,operations:[e]});break;default:if(!s&&i.length>0){let u=i[i.length-1];!u.glueEnabled&&!u.operations&&(u.glueEnabled=true,u.labelToOpen||(u.goNextStep=true)),i[i.length-1]=u;}i.push({conditionalStep:e});}else if("->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let h=i[i.length-1];h.labelToOpen||(h.goNextStep=true),i[i.length-1]=h;}if(e.params&&e.params.length===0&&delete e.params,e.var)i.push({labelToOpen:{label:Ft({key:e["->"],defaultType:"storage"},r),type:l?"call":"jump",params:e.params},glueEnabled:u});else {let h=Ht(e["->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:ca(h,l),params:e.params},glueEnabled:u});}}else if("->t->"in e){let u=s?void 0:true;if(u&&t.includes("c-")&&i.length>0&&i[i.length-1]?.dialogue===void 0&&(u=void 0),!s&&i.length>0){let c=i[i.length-1];c.labelToOpen||(c.goNextStep=true),i[i.length-1]=c;}e.params&&e.params.length===0&&delete e.params;let h=Ht(e["->t->"],t);if(!h)return;i.push({labelToOpen:{label:h,type:"call",params:e.params},glueEnabled:u});}}}function Zd(i,e){let t;if(i.includes(": ")){let n=i.split(": "),r=n[0],a=n.slice(1).join(": ");(e?.has(r)||characters.RegisteredCharacters.has(r))&&(t=r,i=a);}return t?{dialogue:{character:t,text:i}}:{dialogue:i}}function pa(i,e,t,n=true,r=false){return ep(i,e,t,n,r)}function ep(i,e,t,n,r=false){e&&(typeof e=="string"&&e.startsWith("^")||e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get"?typeof e=="string"?i.push(Ue(e)):i.push(e):typeof e=="object"&&"type"in e&&i.push(e));}function xi(i,e,t,n){if(i.length===0){W.error("Error parsing ink file: Arithmetic statement is not valid",i);return}let r=mt(i,e,t,n);if(r.length===1){let a=r[0];return a&&typeof a=="object"&&"type"in a?{type:"value",storageType:"logic",storageOperationType:"get",operation:a}:a}}function zt(i,e,t,n="",r,a,s=void 0){let o=[],l="sequential",u=false,h=true;i.forEach(f=>{f==="%"&&(l="loop"),f==="seq"&&(l="random"),f==="MIN"&&(u=true);});let c=i[i.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=[];gt(C,n,r,g,e,e,t,Ut,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 gt(i,e,t,n=[],r,a,s,o,l=void 0,u=true,h=[]){let c=false,p=[],f=false,C=false,g=false,A=[],D=[];if(t.preDialog[e]&&(u=false,r(n,`^${t.preDialog[e].text}`,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),t.preDialog[e].glue&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),delete t.preDialog[e]),i.includes("visit")){let d=zt(i,a,s,e,t,h,l);d&&(!u&&n.length>0&&r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}));return}let y=i[0];if(y&&typeof y=="object"&&"temp="in y){for(;i[0]&&typeof i[0]=="object"&&"temp="in i[0];)h.push(i[0]["temp="]),i.shift();h=h.reverse();}if(i.forEach((d,E)=>{if(C){if(typeof d=="string"&&d==="/#"){let m=[];gt(D,e,t,m,pa,pa,s,o,l,u),r(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),C=false,D=[];}else D.push(d);return}else if(c)if(Array.isArray(d))p.push(d);else if(d&&typeof d=="object")"CNT?"in d?E>0&&i[E-1]==="ev"?(f=true,A.push(d)):f?A.push(d):(p.push(d),u=false):"VAR="in d||"temp="in d?_n({key:"VAR="in d?d["VAR="]:d["temp="],value:i[E-1],defaultType:"VAR="in d?"storage":"tempstorage"},h,t).forEach(S=>{if(S.value&&typeof S.value=="string"&&S.value==="/str"&&(S.value=i[E-2]),S.value&&typeof S.value=="object"&&"^->"in S.value&&(S.value=S.value["^->"]),p.length>1){let w=xi(p,e,h,t);p=[],w&&typeof w=="object"&&"type"in w&&w.type==="value"&&"storageType"in w&&w.storageType==="logic"&&(S.value=w.operation);}(typeof S.key!="string"||!S.key.includes("$r"))&&(r(n,S,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&&A.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 S=Ft({key:m["VAR?"],defaultType:"storage"},h);r(n,S,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g});}else {let S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let w=xi(S,e,h,t);p=[],w&&typeof w=="object"&&"type"in w&&w.type==="value"&&"storageType"in w&&w.storageType==="logic"?r(n,{storageOperationType:"get",storageType:"logic",operation:w.operation,type:"value"},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):(r(n,"<>",e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),w=`^${w}`,r(n,w,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 S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)S.push(p.pop());S=S.reverse();let w=mt(S,e,h,t);p=[],w.forEach(P=>{P&&typeof P=="object"&&"type"in P&&P.type==="function"?r(n,P,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}):W.warn("Unhandled case: value is not a function",P);}),u=false;}else p.push(d);return}default:p.push(d);}else if(typeof d=="string")if(d.startsWith("^"))r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="ev")c=true;else if(d===`
|
|
68
68
|
`)u=true;else if(d==="done"||d==="end")r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="<>")r(n,d,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),u=false;else if(d==="nop"&&f){let m=Iu(A,a,s,e,t,h,l);m&&r(n,m,e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),f=false,A=[];}else d==="#"?C=true:d==="thread"&&(g=true);else if(Array.isArray(d))if(f)A.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=[],S=[];for(;p.length>0&&p[p.length-1]!=="/ev";)m.push(p.pop());A=[...A,...m.reverse()],f=true,S.push(d.pop()),S.push(d.pop()),A=[...A,...d],A.push(S);}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){W.error("Error parsing ink file: el is undefined");return}let S=m["#n"];delete m["#n"],d.push(m),r(n,{"->":e?e+"_|_"+S:S},e,t,h,{isNewLine:u,isHashtagScript:C,isThreads:g}),s({[S]:d},e,t);}else gt(d,e,t,n,r,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=ha(["ev",...p],e,h,t)),d.params=m,r(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=ha(["ev",...p],e,h,t)),d.params=m,r(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="],S,w=[];if(m!=="$r"){for(p.pop(),p[p.length-1]==="/ev"&&p.pop();p.length>0&&p[p.length-1]!=="/ev";)w.push(p.pop());w=w.reverse(),S=xi(w,e,h,t),p=[],_n({key:m,value:S,defaultType:"VAR="in d?"storage":"tempstorage",artmeticValue:true},h,t).forEach(N=>{(N.value!==void 0||N.value!==null)&&r(n,N,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],E=n[1];d&&E&&typeof d=="object"&&"dialogue"in d&&typeof E=="object"&&"labelToOpen"in E&&d.dialogue===" "&&E.labelToOpen&&(n.shift(),delete E.glueEnabled,n[0]=E);}}function ma(i,e,t,n,r,a){if(e.length===0)return;let s=mt(e,n,t,r);if(s.length===1){let o={type:"ifelse",condition:s[0],then:i,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:i,else:a};return o.else||delete o.else,o}}function Iu(i,e,t,n,r,a,s=void 0){if(i.length===0){W.error("Error parsing ink file: Conditional statement is not valid",i);return}let o=[],l=[];if(i.forEach(c=>{Array.isArray(c)?l.push(c):typeof c=="string"&&c==="du"?r.du?o.push(r.du):r.du=o[o.length-1]:(typeof c!="string"||c!=="/ev")&&o.push(c);}),l.length===0){W.error("Error parsing ink file: Conditional statement is not valid",l);return}let u=fa(l[0],e,t,`${n}${"_|_"}then`,r,a,`${s||""}then`),h;return l.length===2?h=fa(l[1],e,t,`${n}${"_|_"}else`,r,a,`${s||""}else`):l.length>2?(l.shift(),l.push("nop"),l=[{b:l}],h=fa(l,e,t,`${n}${"_|_"}else`,r,a,`${s||""}else`)):h=void 0,r.du=void 0,ma(u,o,a,n,r,h)}function fa(i,e,t,n,r,a,s=void 0){let o=[];for(let u of i)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["->"]))),gt(u.b,n,r,o,e,e,t,Ut,s,true,a));return o.length===1?o[0]:{type:"resulttocombine",combine:"cross",secondConditionalItem:o}}function ga(i="",e=""){let t=Array.isArray(i)?i:[i],n=Array.isArray(e)?e:[e];return [...new Set([...t,...n])]}function Ut(i,e,t,n,r){if(i.length>0){let a={};Vu(i,a,r,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:ca(l,false),oneTime:o.onetime};o.text.length===0&&(u.onlyHaveNoChoice=true,u.autoSelect=true),u.oneTime===false&&delete u.oneTime;let h=ma(u,o.conditions,r,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):W.error("Unhandled case: choices is PixiVNJsonConditionalStatements<PixiVNJsonChoices> | undefined",o,p),c.choices=p.sort((f,C)=>{try{let g=f.label.split("."),A=g[g.length-1].replaceAll(".","_|_"),D=C.label.split("."),y=D[D.length-1].replaceAll(".","_|_");if(A.includes("c-")&&y.includes("c-")){let d=A.split("c-")[1],E=Number(d),m=y.split("c-")[1],S=Number(m);return E-S}}catch{}return 0});}else e.push({choices:[h]});o.preDialog&&(n.preDialog[l]={...o.preDialog});}}}function Vu(i,e,t,n,r){let a=[],s="",o="",l=false,u=[];for(let h=0;h<i.length;h++){let c=i[h];if(typeof c=="string")c.startsWith("^")?a.push(Ue(c)):Ou.includes(c)&&u.push(c);else if(Array.isArray(c)&&c.includes("visit")){let p=zt(c,Ai,(f,C,g)=>{},r,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=ku(c.s),f=c.s.includes("<>");p&&(r&&e[r]?(e[r].preDialog={text:p,glue:f},e[r].text=ga(p,e[r].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=ga(a,e[s].text):e[s]={text:a,onetime:l,conditions:u},o&&(e[s].preDialog={text:o,glue:false});let p=i.slice(h+1);Vu(p,e,t,n,s);return}}}function ku(i){for(let e of i)if(typeof e=="string"){if(e.startsWith("^"))return Ue(e)}else if(Array.isArray(e)){let t=ku(e);if(t)return t}}var Ca;(r=>{function i(a,s={}){let{labelToRemove:o=[],initialVarsToRemove:l=[],enums:u={},functions:h=[],preDialog:c={},characterIds:p}=s,f={$schema:mu};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&&Tt in f.labels){let C=f.labels[Tt];delete f.labels[Tt],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}r.inkToJson=i;function e(a,s){try{let o={};return t(a,o,s),o}catch(o){W.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=zt(l,Ai,(h,c,p)=>{},"",o,[]);u&&(o.externalSwitch=u);}else t(l,s,o);else typeof l=="object"&&(l&&"VAR="in l&&o.externalSwitch&&(s[Tt]||(s[Tt]=[]),s[Tt].push({operations:_n({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;gt(h,f,l,c,da,da,(C,g,A)=>{n(C,p,g,A);},Ut);for(let[C,g]of Object.entries(p))s[C]=g;c.length>0&&(s[f]=c);}}}})(Ca||={});var Pc=Xs(Tc()),Fc=Xs(Kt()),JC=/(?:^|<>)\s*#\s*([^\r\n]+)/g,HC=/^=+[ \t]+(?:function[ \t]+)?(\w+)/gm,zC=new Set(["DONE","END"]),UC="_|_",Oc=new Map;function Nc(i,e){let t=JSON.stringify([e,i]),n=Oc.get(t);if(n)return n;let r=new RegExp(i,e);return Oc.set(t,r),r}function di(i,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(s=>di(i,s));let r=t.oneOf;if(Array.isArray(r))return r.some(s=>di(i,s));let a=t.allOf;if(Array.isArray(a))return a.every(s=>di(i,s));if(typeof t.const=="string")return i===t.const;if(Array.isArray(t.enum))return t.enum.some(s=>typeof s=="string"&&s===i);if(t.type!=="string"||typeof t.minLength=="number"&&i.length<t.minLength||typeof t.maxLength=="number"&&i.length>t.maxLength)return false;if(typeof t.pattern=="string")try{if(!Nc(t.pattern,"").test(i))return !1}catch{return false}return true}function Us(i,e){if(!e||typeof e!="object")return false;let t=e,n=t.anyOf;if(Array.isArray(n))return n.some(o=>Us(i,o));let r=t.oneOf;if(Array.isArray(r))return r.some(o=>Us(i,o));let a=t.allOf;if(Array.isArray(a))return a.every(o=>Us(i,o));if(t.type!=="array"||typeof t.minItems=="number"&&i.length<t.minItems||typeof t.maxItems=="number"&&i.length>t.maxItems)return false;let s=Array.isArray(t.prefixItems)?t.prefixItems:[];if(i.length<s.length)return false;for(let o=0;o<s.length;o++)if(!di(i[o],s[o]))return false;return i.length===s.length?true:t.items===false||typeof t.items>"u"?false:t.items===true?true:i.slice(s.length).every(o=>di(o,t.items))}function KC(i,e){if(e.type==="regexp")try{let t=Nc(e.source,e.flags);return t.lastIndex=0,t.test(i.join(" "))}catch{return false}return e.type==="literal"?i.join(" ")===e.value:Us(i,e.schema)}function XC(i){let e=i.split(/\r?\n/),t=[];for(let n=0;n<e.length;n++){let r=e[n];for(let a of r.matchAll(JC)){let s=(a[1]??"").trim();if(!s)continue;let o=exports.HashtagCommands.convertTagTolist(s,{mergeInkVariables:true});o.length!==0&&t.push({line:n+1,command:s,tokens:o});}}return t}var Wl;(r=>{function i(a,s={labelToRemove:[],initialVarsToRemove:[],functions:[],enums:{}}){let o=[];try{return {json:new Pc.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?i(h.textSource,s):{issues:o}}}r.compile=i;function e(a,s,o){let{functions:l,initialVarsToRemove:u,labelToRemove:h}=o,c=a.find(p=>p.type===Fc.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=`
|
|
69
69
|
|
|
70
70
|
=== ${f} ===
|
package/dist/index.d.cts
CHANGED
|
@@ -304,7 +304,19 @@ declare namespace HashtagCommands {
|
|
|
304
304
|
function convertTagTolist(tag: string, options?: {
|
|
305
305
|
mergeInkVariables?: boolean;
|
|
306
306
|
}): string[];
|
|
307
|
-
function convertOperation(list: string[], step: PixiVNJsonLabelStep$1
|
|
307
|
+
function convertOperation(list: string[], step: PixiVNJsonLabelStep$1, options?: {
|
|
308
|
+
/**
|
|
309
|
+
* When `true`, suppresses the "The operation is not valid" error log on a mapper
|
|
310
|
+
* miss. Callers that only speculatively probe the built-in `.addMapper()` table —
|
|
311
|
+
* e.g. to decide whether a hashtag script can be resolved eagerly at parse time,
|
|
312
|
+
* before falling back to a deferred `operationtoconvert` step that will later be
|
|
313
|
+
* resolved through the full {@link run} pipeline (custom `.add()` handlers included)
|
|
314
|
+
* — should pass `silent: true`. Otherwise every hashtag command registered only via
|
|
315
|
+
* `.add()` (never a mapper) would log a false "not valid" error on every parse, even
|
|
316
|
+
* though it resolves correctly once `run()` reaches it.
|
|
317
|
+
*/
|
|
318
|
+
silent?: boolean;
|
|
319
|
+
}): PixiVNJsonOperation$1 | undefined;
|
|
308
320
|
/**
|
|
309
321
|
* For example:
|
|
310
322
|
* Into Ink text:
|
package/dist/index.d.ts
CHANGED
|
@@ -304,7 +304,19 @@ declare namespace HashtagCommands {
|
|
|
304
304
|
function convertTagTolist(tag: string, options?: {
|
|
305
305
|
mergeInkVariables?: boolean;
|
|
306
306
|
}): string[];
|
|
307
|
-
function convertOperation(list: string[], step: PixiVNJsonLabelStep$1
|
|
307
|
+
function convertOperation(list: string[], step: PixiVNJsonLabelStep$1, options?: {
|
|
308
|
+
/**
|
|
309
|
+
* When `true`, suppresses the "The operation is not valid" error log on a mapper
|
|
310
|
+
* miss. Callers that only speculatively probe the built-in `.addMapper()` table —
|
|
311
|
+
* e.g. to decide whether a hashtag script can be resolved eagerly at parse time,
|
|
312
|
+
* before falling back to a deferred `operationtoconvert` step that will later be
|
|
313
|
+
* resolved through the full {@link run} pipeline (custom `.add()` handlers included)
|
|
314
|
+
* — should pass `silent: true`. Otherwise every hashtag command registered only via
|
|
315
|
+
* `.add()` (never a mapper) would log a false "not valid" error on every parse, even
|
|
316
|
+
* though it resolves correctly once `run()` reaches it.
|
|
317
|
+
*/
|
|
318
|
+
silent?: boolean;
|
|
319
|
+
}): PixiVNJsonOperation$1 | undefined;
|
|
308
320
|
/**
|
|
309
321
|
* For example:
|
|
310
322
|
* Into Ink text:
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{a as importInkText,b as importJson}from'./chunk-
|
|
1
|
+
export{a as importInkText,b as importJson}from'./chunk-WU3FPOE2.mjs';import {d,h as h$1,i}from'./chunk-3K2SER36.mjs';export{i as HashtagCommands,c as TextReplaces,e as VariableGetter,m as convertInkText,m as convertInkToJson,j as onInkHashtagScript}from'./chunk-3K2SER36.mjs';function k(e){d.afterToTranslate=n=>T(n,e);}function y(e){d.beforeToTranslate=n=>T(n,e);}function T(e,n){let s=new RegExp(h$1.source,"g"),t=new Set,o=true;for(;o;){o=false;let x=[...e.matchAll(s)],i=new Set;for(let l of x){let a=l[1];if(i.has(a)||t.has(a))continue;i.add(a);let p=n(a);p!==void 0?(e=e.replaceAll(l[0],p),o=true):t.add(a);}}return e}function b(e){d.translate=e;}async function h(e,n={},s={}){let t=[];return e.labels&&Object.values(e.labels).forEach(o=>{t=t.concat(o);}),await d.generateJsonTranslation(t,n,{...s,operationStringConvert:i.run})}export{h as generateJsonInkTranslation,b as onInkTranslate,k as onReplaceTextAfterTranslation,y as onReplaceTextBeforeTranslation};
|