narrat 3.3.6 → 3.3.7
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/narrat.es.js +3 -3
- package/dist/narrat.es.js.map +1 -1
- package/dist/narrat.umd.js +3 -3
- package/dist/narrat.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/narrat.umd.js
CHANGED
|
@@ -172,7 +172,7 @@ Found in store "${P.$id}".`),p&&i&&n.hydrate&&n.hydrate(P.$state,p),c=!0,f=!0,P}
|
|
|
172
172
|
This will fail in production.`);s=Wh,s._s.has(r)||(i?Zx(r,t,o,s):o9(r,o,s),process.env.NODE_ENV!=="production"&&(a._pinia=s));const f=s._s.get(r);if(process.env.NODE_ENV!=="production"&&l){const u="__hot:"+r,d=i?Zx(u,t,o,s,!0):o9(u,ca({},o),s,!0);l._hotUpdate(d),delete s.state.value[u],s._s.delete(u)}if(process.env.NODE_ENV!=="production"&&Hg){const u=b.getCurrentInstance();if(u&&u.proxy&&!l){const d=u.proxy,h="_pStores"in d?d._pStores:d._pStores={};h[r]=f}}return f}return a.$id=r,a}function Qg(e,t){return Array.isArray(t)?t.reduce((n,r)=>(n[r]=function(){return e(this.$pinia)[r]},n),{}):Object.keys(t).reduce((n,r)=>(n[r]=function(){const o=e(this.$pinia),i=t[r];return typeof i=="function"?i.call(this,o):o[i]},n),{})}const i9=["music","ambiant","sound"],a9=Whe(i9),bo=co("audio",{state:()=>{const e=new Map;for(const t in a9)e.set(t,{channels:[],options:{volume:1}});return{modes:e,masterVolume:1}},actions:{stopAll(){this.modes.forEach(e=>{e.channels.forEach((t,n)=>{t&&(this.actuallyStopChannel(t),e.channels[n]=null)})})},async stopChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const{fadeOutTime:r}=E0(n.audio);if(this.setAudioChannel(e,t,null),da().options.musicFadeOutTime){const o=il(n.audio);o&&o.fade(o.volume(n.howlerId),0,r,n.howlerId),await xi(r)}this.actuallyStopChannel(n)},async pauseChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const r=il(n.audio);if(!r){Qt(`Could not find audio ${n.audio}`);return}r.pause(n.howlerId)},async playChannel(e,t,n){js.Howler.ctx.state==="suspended"&&(console.warn("Audio context is suspended :o"),js.Howler.ctx.resume());const r=this.getAudioChannel(e,n);if(e==="sound")return this.actuallyPlayChannel(e,n,t);r&&r.audio!==t?await this.changeChannel(e,t,n):r&&r.audio===t?await this.resumeChannel(e,n):await this.actuallyPlayChannel(e,n,t)},async resumeChannel(e,t){const n=this.getAudioChannel(e,t);if(!n)return;const r=il(n.audio);if(!r){Qt(`Could not find audio ${n.audio}`);return}r.play(n.howlerId)},async changeChannel(e,t,n){this.getAudioChannel(e,n)&&e!=="sound"&&await this.stopChannel(e,n),await this.actuallyPlayChannel(e,n,t)},actuallyStopChannel(e){jpe(e.audio,e.howlerId)},getAudioChannel(e,t){return this.modes.get(e).channels[t]||null},setAudioChannel(e,t,n){this.modes.get(e).channels[t]=n},async actuallyPlayChannel(e,t,n){const r=il(n);if(!r){Qt(`Could not find audio ${n}`);return}const{fadeInTime:o,fadeInDelay:i}=E0(n),a=this.audioVolume(e,n);if(e!=="sound"){const s=r.play();r.volume(0,s),r.pause(s),this.setAudioChannel(e,t,{audio:n,howlerId:s}),await xi(i);const l=this.getAudioChannel(e,t);l!==null&&l.audio===n&&(r.play(s),r.fade(0,a,o,s))}else if(e==="sound"){const s=r.play();r.volume(a,s),this.setAudioChannel(e,t,{audio:n,howlerId:s})}},reloadAudio(e){for(const t in e.modes){if(t==="sound")continue;const n=t;this.modes.get(n).options=sr(e.modes[n].options);for(const r in e.modes[n].channels){const o=e.modes[n].channels[r];o&&o.audio&&this.actuallyPlayChannel(n,Number(r),o.audio)}}},stopSound(e){const t=il(e);t&&t.stop()},generateSaveData(){const e={};for(const t in a9){const n=this.modes.get(t);e[t]={options:sr(n.options),channels:sr(n.channels).map(r=>r?{audio:r.audio}:{audio:null})}}return{modes:e,masterVolume:this.masterVolume}},loadSaveData(e){this.masterVolume=e.masterVolume},reset(){this.stopAll()},setModeVolume(e,t){const n=this.modes.get(e);n.options.volume=t;for(const r in n.channels){const o=n.channels[r];if(o){const i=il(o.audio);i&&i.volume(this.modeVolume(e),o.howlerId)}}},setMasterVolume(e){this.masterVolume=e,js.Howler.volume(e)},modeVolume(e){return this.masterVolume*this.modes.get(e).options.volume},audioVolume(e,t){var n;return this.modeVolume(e)*(((n=fV(t))==null?void 0:n.volume)??1)}}}),s9={};js.Howler.volume(.5);let e_={};async function xpe(e){di.log("Loading audio");const t=[];js.Howler.volume(e.options.volume);for(const n in e.files){const r=e.files[n];r.src||(r.src=r.path,r.path||console.error(`Audio config for ${n} doesn't have any \`src\` value to find the file`),console.warn("Using `path` for audio and musics is deprecated. Please replace `path` with `src` in your config file!")),t.push(_pe(n,e.files[n]))}return e.audioTriggers&&(e_=e.audioTriggers),Promise.all(t)}function ru(e){e_[e]&&bo().playChannel("sound",e_[e],0)}async function _pe(e,t){return new Promise((n,r)=>{di.log(`Loading audio ${t.src}`);const o=new js.Howl({...t,src:li(t.src)});o.load(),s9[e]=o,n()})}function jpe(e,t){const n=il(e);if(!n){su(`Could not find music ${e}`);return}n.stop(t)}function il(e){return s9[e]}function Spe(e){const t=il(e),{fadeInTime:n}=E0(e),r=t.play(),i=bo().audioVolume("music",e);return t.fade(0,i,n,r),r}async function Cpe(e,t){const n=il(e),{fadeOutTime:r}=E0(e);n.fade(n.volume(t),0,r,t),await xi(r),n.stop(t)}const Bf={};async function $pe(e){return Bf[e]?Bf[e]:l9(e,e)}async function Tpe(e){di.log("Loading images");let t=0,n=0;const r=[],o=async(a,s)=>{n++;const l=await l9(a,s);return t++,console.log(`Loaded ${t} / ${n} images`),l},i=(a,s)=>{r.push(o(a,s))};for(const a in e.images){const s=e.images[a];i(a,s)}for(const a in e.screens.screens){const s=e.screens.screens[a];if(s.background&&!e.images[s.background]&&!s.video&&i(s.background,s.background),s.buttons)for(const l in s.buttons){const c=s.buttons[l];typeof c=="object"&&c.background&&!e.images[c.background]&&i(c.background,c.background)}}return Promise.all(r)}async function l9(e,t){if(Bf[e])return Bf[e];const n=new Promise((r,o)=>{di.log(`Loading image ${e} at ${t}`);const i=new Image;i.onload=()=>{Bf[e]=i,di.log(`Loaded image ${e} successfully`),r(i)},i.onerror=a=>{Qt(`Failed to load image ${e} at ${t}`,a),o(a)},i.src=li(t)});return Bf[e]=n,n}function ou(){return`${Date.now()}-${Math.floor(Math.random()*1e11)}-${Math.floor(Math.random()*1e11)}`}const c9="3.2.3";function t_(){return`NARRAT_SAVE_${yt().saveFileName}`}const Epe="gameSave";let no;function al(){if(no)return no;if(!no){let e=null;try{let t=localStorage.getItem(t_());t||(t=localStorage.getItem(Epe)),t&&(localStorage.setItem(`${t_()}_BACKUP`,t),e=JSON.parse(t)),e&&typeof e=="object"&&e.slots&&e.slots[0]&&e.slots[0].id||(e=null,localStorage.clear())}catch(t){su(`Save file deleted because it was either broken or an outdated format: ${t}`)}e?no=e:no=f9()}return Ape(no),d9(no),Jh(),no}function Ope(){no=f9(),Jh()}function u9(){return{achievements:{achievements:{}},data:{}}}function Ape(e){e.version==="1.4.0"&&(e.globalSave=u9(),e.version="1.5.0"),e.version==="1.5.0"&&(e.version="2.16.0"),e.version==="2.16.0"&&(e.slots.forEach(t=>{t&&t.saveData&&(t.saveData.settings={baseSettings:{textSpeed:30,animateText:!0,fontSize:16},customSettings:{}})}),e.version="2.17.0"),e.version==="2.17.0"&&(e.slots.forEach(t=>{t&&t.saveData&&(t.saveData.config={gameCharacter:"game",playerCharacter:"player"})}),e.version="3.2.3")}function f9(){const e={version:c9,slots:[],globalSave:u9()};return d9(e),e}function d9(e){const t=yt().saves.slots??10;e.slots.length<1&&(e.slots[0]={slotType:"auto",id:ou(),saveData:null,slotNumber:0}),e.slots[0].slotType="auto";for(let n=1;n<t+1;n++)e.slots.length<=n&&(e.slots[n]={slotNumber:n,slotType:yt().saves.mode==="manual"?"manual":"auto",id:ou(),saveData:null})}function h9(e,t,n){const r=Npe(n);if(no.slots[r])no.slots[r].saveData=e;else{Qt(`Tried to save to slot ${n} but it doesn't exist`);return}no.globalSave=t,Jh()}function Mpe(e){no.lastSaveSlot=e}function Jh(){localStorage.setItem(t_(),JSON.stringify(no))}function Ppe(){const e=no.slots.find(t=>!t.saveData);return e?e.id:!1}function Npe(e){return no.slots.findIndex(t=>t.id===e)}function Qh(e){return no.slots.find(t=>t.id===e)}function n_(){return no.slots.find(e=>e.slotType==="auto")}function Ipe(e){const t=no.slots.findIndex(n=>n.id===e);no.slots[t].saveData=null,Jh()}function Dpe(e,t){const n=Qh(e);n&&n.saveData&&(n.saveData.metadata.name=t),Jh()}function Lpe(){return{saveDate:new Date().toISOString(),name:"New Save"}}const Yh=co("tooltips",{state:()=>({tooltip:null}),actions:{addCustomTooltip(e){e.title&&(e.title=Cs(e.title)),e.text=Cs(e.text),this.tooltip=e},addTooltip(e,t){const n=dV(e);n&&this.addCustomTooltip({title:n.title,text:n.description,x:(t==null?void 0:t.x)??window.screenX,y:(t==null?void 0:t.y)??window.screenY,width:nd().options.width})},deleteTooltip(){this.tooltip=null}}});function Yg(){return window}function Rpe(e){const t=nd().options.keywordsPrefix,n=new RegExp(`${t}(\\w*)`,"gi");return e=e.replace(n,Bpe),e}Yg().onTooltipEnter=(e,t)=>{const n={x:e.clientX,y:e.clientY-20};Yh().addTooltip(t,n)},Yg().onTooltipLeave=()=>{Yh().deleteTooltip()};function Bpe(e,t){const n=t.toLowerCase();return dV(n)?`<span class='highlighted-tooltip-keyword'
|
|
173
173
|
onmouseenter="onTooltipEnter(event, '${n}')"
|
|
174
174
|
onmouseleave="onTooltipLeave()">${t}</span>`:n}function Cs(e){const t=e.replace(/%{[^}]*}/g,n=>{const r=n.substr(2,n.length-3);return r_(r)});return Rpe(t)}function r_(e){const t=ad(),[n,r]=D0(t,e);return n[r]}const p9=/\$\$"/,Fpe=e=>typeof e=="string"&&e.search(p9)===0;function Vpe(e){let t=null;const n=[],r=/<[^>]*>/g;do t=r.exec(e),t&&n.push(t);while(t);return n}const Yn=co("dialog",{state:()=>({dialog:[],playMode:"normal"}),actions:{generateSaveData(){return{dialog:sr(this.dialog)}},loadSaveData(e){this.dialog=e.dialog},addDialog(e){this.dialog.push({...e,interactive:e.interactive??!1,id:ou(),text:Cs(e.text)}),this.dialog.length>200&&this.dialog.shift()},toggleAutoPlay(){this.playMode=this.playMode==="auto"?"normal":"auto"},toggleSkip(){this.playMode=this.playMode==="skip"?"normal":"skip"},clearDialog(){this.dialog.splice(0,this.dialog.length)},reset(){this.dialog=[],this.playMode="normal"}},getters:{currentDialog(){return this.dialog[this.dialog.length-1]}}});function zpe(e,t){return e-t*kp().options.extraPointsPerLevel}function m9(e,t){const{options:n}=kp();let r=e;n.showDifficultyWithoutModifiers||(r=zpe(e,t));const o=kp().options;let i=!1,a=0,s=o.difficultyText[0][1];for(;!i;)o.difficultyText.length>a&&r>=o.difficultyText[a][0]?s=o.difficultyText[a][1]:i=!0,a++;let l="";return n.showDifficultyText&&n.showDifficultyNumber?l=`${s} (${r})`:n.showDifficultyText?l=s:n.showDifficultyNumber&&(l=r.toString()),l}function qpe({skill:e,skillCheckId:t,value:n}){const r=Cr(),o=r.getSkillCheck(t),i=P0(e),a=r.skills[e].level,s=m9(n,a);let l=!0,c=`<span class='skill-check'>[<span class='skill-check-name'>${i.name}</span> - `;return o.happened?o.succeeded?c="":(l=!1,c+=` <span class='skill-check-difficulty'>${s}</span> - <span class='skill-check-failed'>FAILED</span>]</span>`):c+=` <span class='skill-check-difficulty'>${s}</span>]</span>`,{difficultyText:c,allowed:l}}function Upe(e,t){const n=Cr(),r=P0(t.skill),o=m9(t.difficulty,n.skills[t.skill].level);return`<span class='passive-skill-check skill-check'>[<span class='skill-check-name'>${r.name}</span> - <span class='skill-check-difficulty'>${o}</span> - ${e?'<span class="skill-check-success">Success</span>':'<span class="skill-check-failed">Failure</span>'}]</span>`}function Hpe(e){const{options:t}=kp(),n=Wpe(t,e),i=Cr().skills[e].level*t.extraPointsPerLevel;let a=n.reduce((s,l)=>s+l.unmodified,i);return t.finalRollIsHighest?(a=n.reduce((s,l)=>l.modified>s?l.modified:s,0),di.log(`[SKILL CHECK] Keeping only highest roll: ${a}`)):t.finalRollIsLowest&&(a=n.reduce((s,l)=>l.modified<s?l.modified:s,n[0].modified),di.log(`[SKILL CHECK] Keeping only lowest roll: ${a}`)),{roll:a,rolls:n}}function Wpe(e,t){const r=Cr().skills[t],o=r.level*e.extraPointsPerLevel;let{diceRange:i,diceCount:a}=e;e.extraDicePerLevel&&(a+=e.extraDicePerLevel*r.level);const s=[];for(let l=0;l<a;l++){const c=Kpe(i),f=c+o;di.log(`[SKILL CHECK] Roll ${l+1}/${a}: ${f}. (Base roll: ${c}, modifier: ${o} - Skill level: ${r.level})`),s.push({unmodified:c,modified:f})}return s}function Kpe(e){return Math.floor(Math.random()*e[1])+e[0]}function Gpe(e){const{skills:t}=Ka(),{roll:n,rolls:r}=Hpe(e.skill),o=t[e.skill];let i=!1;if(typeof e.winsNeeded=="number"){const a=r.reduce((s,l)=>(v9(l.modified,e.difficulty)&&s++,s),0);a>=e.winsNeeded&&(i=!0),di.log(`[SKILL CHECK ${o.name}] - Dice pool mode. ${e.winsNeeded} wins needed. Got ${a} successes.
|
|
175
|
-
(${e.id} - ${a}/${e.winsNeeded} - rolls: ${JSON.stringify(r.map(s=>s.modified))})`)}else i=v9(n,e.difficulty),di.log(`[SKILL CHECK ${o.name}]: ${i?"✅":"❌"}`,`(${e.id}) - ${n}/${e.difficulty}`);return ru(i?"onSkillCheckSuccess":"onSkillCheckFailure"),i}function v9(e,t){const{options:n}=kp();let r=e>=t;return n.successOnRollsBelowThreshold&&(r=e<=t),n.failOnRollsEqualToThreshold&&e===t&&(r=!1),r}var K={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.StandardType=e.ExtendedTypeBuilder=e.StandardTypeBuilder=e.TypeBuilder=e.TemplateLiteralDslParser=e.TemplateLiteralGenerator=e.TemplateLiteralFinite=e.TemplateLiteralParser=e.TemplateLiteralParserError=e.TemplateLiteralResolver=e.TemplateLiteralPattern=e.UnionResolver=e.KeyArrayResolver=e.KeyResolver=e.ObjectMap=e.IndexedAccessor=e.TypeClone=e.TypeExtends=e.TypeExtendsResult=e.ExtendsUndefined=e.TypeGuard=e.TypeGuardUnknownTypeError=e.FormatRegistry=e.TypeRegistry=e.PatternStringExact=e.PatternNumberExact=e.PatternBooleanExact=e.PatternString=e.PatternNumber=e.PatternBoolean=e.Kind=e.Hint=e.Modifier=void 0,e.Modifier=Symbol.for("TypeBox.Modifier"),e.Hint=Symbol.for("TypeBox.Hint"),e.Kind=Symbol.for("TypeBox.Kind"),e.PatternBoolean="(true|false)",e.PatternNumber="(0|[1-9][0-9]*)",e.PatternString="(.*)",e.PatternBooleanExact=`^${e.PatternBoolean}$`,e.PatternNumberExact=`^${e.PatternNumber}$`,e.PatternStringExact=`^${e.PatternString}$`;var t;(function(A){const x=new Map;function S(){return new Map(x)}A.Entries=S;function D(){return x.clear()}A.Clear=D;function B(H){return x.has(H)}A.Has=B;function $(H,q){x.set(H,q)}A.Set=$;function F(H){return x.get(H)}A.Get=F})(t||(e.TypeRegistry=t={}));var n;(function(A){const x=new Map;function S(){return new Map(x)}A.Entries=S;function D(){return x.clear()}A.Clear=D;function B(H){return x.has(H)}A.Has=B;function $(H,q){x.set(H,q)}A.Set=$;function F(H){return x.get(H)}A.Get=F})(n||(e.FormatRegistry=n={}));class r extends Error{constructor(x){super("TypeGuard: Unknown type"),this.schema=x}}e.TypeGuardUnknownTypeError=r;var o;(function(A){function x(te){return typeof te=="object"&&te!==null&&!Array.isArray(te)}function S(te){return typeof te=="object"&&te!==null&&Array.isArray(te)}function D(te){try{return new RegExp(te),!0}catch{return!1}}function B(te){if(typeof te!="string")return!1;for(let ke=0;ke<te.length;ke++){const dt=te.charCodeAt(ke);if(dt>=7&&dt<=13||dt===27||dt===127)return!1}return!0}function $(te){return L(te)||gn(te)}function F(te){return typeof te=="bigint"}function H(te){return typeof te=="string"}function q(te){return typeof te=="number"&&globalThis.Number.isFinite(te)}function U(te){return typeof te=="boolean"}function N(te){return te===void 0||te!==void 0&&F(te)}function M(te){return te===void 0||te!==void 0&&q(te)}function L(te){return te===void 0||te!==void 0&&U(te)}function I(te){return te===void 0||te!==void 0&&H(te)}function T(te){return te===void 0||te!==void 0&&H(te)&&B(te)&&D(te)}function O(te){return te===void 0||te!==void 0&&H(te)&&B(te)}function E(te){return te===void 0||gn(te)}function G(te){return ue(te)&&te[e.Kind]==="Any"&&I(te.$id)}A.TAny=G;function re(te){return ue(te)&&te[e.Kind]==="Array"&&te.type==="array"&&I(te.$id)&&gn(te.items)&&M(te.minItems)&&M(te.maxItems)&&L(te.uniqueItems)}A.TArray=re;function me(te){return ue(te)&&te[e.Kind]==="BigInt"&&te.type==="null"&&te.typeOf==="BigInt"&&I(te.$id)&&N(te.multipleOf)&&N(te.minimum)&&N(te.maximum)&&N(te.exclusiveMinimum)&&N(te.exclusiveMaximum)}A.TBigInt=me;function je(te){return ue(te)&&te[e.Kind]==="Boolean"&&te.type==="boolean"&&I(te.$id)}A.TBoolean=je;function Ee(te){if(!(ue(te)&&te[e.Kind]==="Constructor"&&te.type==="object"&&te.instanceOf==="Constructor"&&I(te.$id)&&S(te.parameters)&&gn(te.returns)))return!1;for(const ke of te.parameters)if(!gn(ke))return!1;return!0}A.TConstructor=Ee;function ve(te){return ue(te)&&te[e.Kind]==="Date"&&te.type==="object"&&te.instanceOf==="Date"&&I(te.$id)&&M(te.minimumTimestamp)&&M(te.maximumTimestamp)&&M(te.exclusiveMinimumTimestamp)&&M(te.exclusiveMaximumTimestamp)}A.TDate=ve;function Se(te){if(!(ue(te)&&te[e.Kind]==="Function"&&te.type==="object"&&te.instanceOf==="Function"&&I(te.$id)&&S(te.parameters)&&gn(te.returns)))return!1;for(const ke of te.parameters)if(!gn(ke))return!1;return!0}A.TFunction=Se;function ge(te){return ue(te)&&te[e.Kind]==="Integer"&&te.type==="integer"&&I(te.$id)&&M(te.multipleOf)&&M(te.minimum)&&M(te.maximum)&&M(te.exclusiveMinimum)&&M(te.exclusiveMaximum)}A.TInteger=ge;function Ie(te){if(!(ue(te)&&te[e.Kind]==="Intersect"&&S(te.allOf)&&I(te.type)&&(L(te.unevaluatedProperties)||E(te.unevaluatedProperties))&&I(te.$id))||"type"in te&&te.type!=="object")return!1;for(const ke of te.allOf)if(!gn(ke))return!1;return!0}A.TIntersect=Ie;function ue(te){return x(te)&&e.Kind in te&&typeof te[e.Kind]=="string"}A.TKind=ue;function We(te){return ue(te)&&te[e.Kind]==="Literal"&&I(te.$id)&&typeof te.const=="string"}A.TLiteralString=We;function ee(te){return ue(te)&&te[e.Kind]==="Literal"&&I(te.$id)&&typeof te.const=="number"}A.TLiteralNumber=ee;function Q(te){return ue(te)&&te[e.Kind]==="Literal"&&I(te.$id)&&typeof te.const=="boolean"}A.TLiteralBoolean=Q;function we(te){return We(te)||ee(te)||Q(te)}A.TLiteral=we;function Ne(te){return ue(te)&&te[e.Kind]==="Never"&&x(te.not)&&globalThis.Object.getOwnPropertyNames(te.not).length===0}A.TNever=Ne;function Ae(te){return ue(te)&&te[e.Kind]==="Not"&&gn(te.not)}A.TNot=Ae;function Ze(te){return ue(te)&&te[e.Kind]==="Null"&&te.type==="null"&&I(te.$id)}A.TNull=Ze;function be(te){return ue(te)&&te[e.Kind]==="Number"&&te.type==="number"&&I(te.$id)&&M(te.multipleOf)&&M(te.minimum)&&M(te.maximum)&&M(te.exclusiveMinimum)&&M(te.exclusiveMaximum)}A.TNumber=be;function De(te){if(!(ue(te)&&te[e.Kind]==="Object"&&te.type==="object"&&I(te.$id)&&x(te.properties)&&$(te.additionalProperties)&&M(te.minProperties)&&M(te.maxProperties)))return!1;for(const[ke,dt]of Object.entries(te.properties))if(!B(ke)||!gn(dt))return!1;return!0}A.TObject=De;function Fe(te){return ue(te)&&te[e.Kind]==="Promise"&&te.type==="object"&&te.instanceOf==="Promise"&&I(te.$id)&&gn(te.item)}A.TPromise=Fe;function Qe(te){if(!(ue(te)&&te[e.Kind]==="Record"&&te.type==="object"&&I(te.$id)&&$(te.additionalProperties)&&x(te.patternProperties)))return!1;const ke=Object.keys(te.patternProperties);return!(ke.length!==1||!D(ke[0])||!gn(te.patternProperties[ke[0]]))}A.TRecord=Qe;function He(te){return ue(te)&&te[e.Kind]==="Ref"&&I(te.$id)&&H(te.$ref)}A.TRef=He;function ct(te){return ue(te)&&te[e.Kind]==="String"&&te.type==="string"&&I(te.$id)&&M(te.minLength)&&M(te.maxLength)&&T(te.pattern)&&O(te.format)}A.TString=ct;function mt(te){return ue(te)&&te[e.Kind]==="Symbol"&&te.type==="null"&&te.typeOf==="Symbol"&&I(te.$id)}A.TSymbol=mt;function Ft(te){return ue(te)&&te[e.Kind]==="TemplateLiteral"&&te.type==="string"&&H(te.pattern)&&te.pattern[0]==="^"&&te.pattern[te.pattern.length-1]==="$"}A.TTemplateLiteral=Ft;function St(te){return ue(te)&&te[e.Kind]==="This"&&I(te.$id)&&H(te.$ref)}A.TThis=St;function En(te){if(!(ue(te)&&te[e.Kind]==="Tuple"&&te.type==="array"&&I(te.$id)&&q(te.minItems)&&q(te.maxItems)&&te.minItems===te.maxItems))return!1;if(te.items===void 0&&te.additionalItems===void 0&&te.minItems===0)return!0;if(!S(te.items))return!1;for(const ke of te.items)if(!gn(ke))return!1;return!0}A.TTuple=En;function It(te){return ue(te)&&te[e.Kind]==="Undefined"&&te.type==="null"&&te.typeOf==="Undefined"&&I(te.$id)}A.TUndefined=It;function sn(te){return fn(te)&&te.anyOf.every(ke=>We(ke)||ee(ke))}A.TUnionLiteral=sn;function fn(te){if(!(ue(te)&&te[e.Kind]==="Union"&&S(te.anyOf)&&I(te.$id)))return!1;for(const ke of te.anyOf)if(!gn(ke))return!1;return!0}A.TUnion=fn;function Kn(te){return ue(te)&&te[e.Kind]==="Uint8Array"&&te.type==="object"&&I(te.$id)&&te.instanceOf==="Uint8Array"&&M(te.minByteLength)&&M(te.maxByteLength)}A.TUint8Array=Kn;function kn(te){return ue(te)&&te[e.Kind]==="Unknown"&&I(te.$id)}A.TUnknown=kn;function Hn(te){return ue(te)&&te[e.Kind]==="Unsafe"}A.TUnsafe=Hn;function Wn(te){return ue(te)&&te[e.Kind]==="Void"&&te.type==="null"&&te.typeOf==="Void"&&I(te.$id)}A.TVoid=Wn;function On(te){return x(te)&&te[e.Modifier]==="ReadonlyOptional"}A.TReadonlyOptional=On;function An(te){return x(te)&&te[e.Modifier]==="Readonly"}A.TReadonly=An;function Gn(te){return x(te)&&te[e.Modifier]==="Optional"}A.TOptional=Gn;function gn(te){return typeof te=="object"&&(G(te)||re(te)||je(te)||me(te)||Ee(te)||ve(te)||Se(te)||ge(te)||Ie(te)||we(te)||Ne(te)||Ae(te)||Ze(te)||be(te)||De(te)||Fe(te)||Qe(te)||He(te)||ct(te)||mt(te)||Ft(te)||St(te)||En(te)||It(te)||fn(te)||Kn(te)||kn(te)||Hn(te)||Wn(te)||ue(te)&&t.Has(te[e.Kind]))}A.TSchema=gn})(o||(e.TypeGuard=o={}));var i;(function(A){function x(S){return S[e.Kind]==="Undefined"?!0:S[e.Kind]==="Not"?!x(S.not):S[e.Kind]==="Intersect"?S.allOf.every(B=>x(B)):S[e.Kind]==="Union"?S.anyOf.some(B=>x(B)):!1}A.Check=x})(i||(e.ExtendsUndefined=i={}));var a;(function(A){A[A.Union=0]="Union",A[A.True=1]="True",A[A.False=2]="False"})(a||(e.TypeExtendsResult=a={}));var s;(function(A){function x(V){return V===a.False?a.False:a.True}function S(V,_){return a.True}function D(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)&&_.anyOf.some(J=>o.TAny(J)||o.TUnknown(J))?a.True:o.TUnion(_)?a.Union:o.TUnknown(_)||o.TAny(_)?a.True:a.Union}function B(V,_){return o.TUnknown(V)?a.False:o.TAny(V)?a.Union:o.TNever(V)?a.True:a.False}function $(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)&&Qe(_)?a.True:o.TArray(_)?x(Y(V.items,_.items)):a.False}function F(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TBigInt(_)?a.True:a.False}function H(V,_){return o.TLiteral(V)&&typeof V.const=="boolean"||o.TBoolean(V)?a.True:a.False}function q(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TBoolean(_)?a.True:a.False}function U(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):!o.TConstructor(_)||V.parameters.length>_.parameters.length||!V.parameters.every((J,se)=>x(Y(_.parameters[se],J))===a.True)?a.False:x(Y(V.returns,_.returns))}function N(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TDate(_)?a.True:a.False}function M(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):!o.TFunction(_)||V.parameters.length>_.parameters.length||!V.parameters.every((J,se)=>x(Y(_.parameters[se],J))===a.True)?a.False:x(Y(V.returns,_.returns))}function L(V,_){return o.TLiteral(V)&&typeof V.const=="number"||o.TNumber(V)||o.TInteger(V)?a.True:a.False}function I(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function T(V,_){return _.allOf.every(J=>Y(V,J)===a.True)?a.True:a.False}function O(V,_){return V.allOf.some(J=>Y(J,_)===a.True)?a.True:a.False}function E(V){return typeof V.const=="string"}function G(V){return typeof V.const=="number"}function re(V){return typeof V.const=="boolean"}function me(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TString(_)?Kn(V):o.TNumber(_)?Ie(V):o.TInteger(_)?L(V):o.TBoolean(_)?H(V):o.TLiteral(_)&&_.const===V.const?a.True:a.False}function je(V,_){return a.False}function Ee(V,_){return a.True}function ve(V){let[_,J]=[V,0];for(;o.TNot(_);)_=_.not,J+=1;return J%2===0?_:e.Type.Unknown()}function Se(V,_){if(o.TNot(V))return Y(ve(V),_);if(o.TNot(_))return Y(V,ve(_));throw new Error("TypeExtends: Invalid fallthrough for Not")}function ge(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TNull(_)?a.True:a.False}function Ie(V,_){return o.TLiteral(V)&&G(V)||o.TNumber(V)||o.TInteger(V)?a.True:a.False}function ue(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function We(V,_){return globalThis.Object.keys(V.properties).length===_}function ee(V){return Qe(V)}function Q(V){return We(V,0)||We(V,1)&&"description"in V.properties&&o.TUnion(V.properties.description)&&V.properties.description.anyOf.length===2&&(o.TString(V.properties.description.anyOf[0])&&o.TUndefined(V.properties.description.anyOf[1])||o.TString(V.properties.description.anyOf[1])&&o.TUndefined(V.properties.description.anyOf[0]))}function we(V){return We(V,0)}function Ne(V){return We(V,0)}function Ae(V){return We(V,0)}function Ze(V){return We(V,0)}function be(V){return Qe(V)}function De(V){const _=e.Type.Number();return We(V,0)||We(V,1)&&"length"in V.properties&&x(Y(V.properties.length,_))===a.True}function Fe(V){return We(V,0)}function Qe(V){const _=e.Type.Number();return We(V,0)||We(V,1)&&"length"in V.properties&&x(Y(V.properties.length,_))===a.True}function He(V){const _=e.Type.Function([e.Type.Any()],e.Type.Any());return We(V,0)||We(V,1)&&"then"in V.properties&&x(Y(V.properties.then,_))===a.True}function ct(V,_){return Y(V,_)===a.False||o.TOptional(V)&&!o.TOptional(_)?a.False:a.True}function mt(V,_){return o.TUnknown(V)?a.False:o.TAny(V)?a.Union:o.TNever(V)||o.TLiteral(V)&&E(V)&&ee(_)||o.TLiteral(V)&&G(V)&&we(_)||o.TLiteral(V)&&re(V)&&Ne(_)||o.TSymbol(V)&&Q(_)||o.TBigInt(V)&&Ae(_)||o.TString(V)&&ee(_)||o.TSymbol(V)&&Q(_)||o.TNumber(V)&&we(_)||o.TInteger(V)&&we(_)||o.TBoolean(V)&&Ne(_)||o.TUint8Array(V)&&be(_)||o.TDate(V)&&Ze(_)||o.TConstructor(V)&&Fe(_)||o.TFunction(V)&&De(_)?a.True:o.TRecord(V)&&o.TString(En(V))?_[e.Hint]==="Record"?a.True:a.False:o.TRecord(V)&&o.TNumber(En(V))&&We(_,0)?a.True:a.False}function Ft(V,_){if(o.TIntersect(_))return T(V,_);if(o.TUnion(_))return ke(V,_);if(o.TUnknown(_))return Ct();if(o.TAny(_))return S();if(o.TRecord(_))return sn(V,_);if(!o.TObject(_))return a.False;for(const J of globalThis.Object.keys(_.properties))if(!(J in V.properties)||ct(V.properties[J],_.properties[J])===a.False)return a.False;return a.True}function St(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)&&He(_)?a.True:o.TPromise(_)?x(Y(V.item,_.item)):a.False}function En(V){if(e.PatternNumberExact in V.patternProperties)return e.Type.Number();if(e.PatternStringExact in V.patternProperties)return e.Type.String();throw Error("TypeExtends: Cannot get record key")}function It(V){if(e.PatternNumberExact in V.patternProperties)return V.patternProperties[e.PatternNumberExact];if(e.PatternStringExact in V.patternProperties)return V.patternProperties[e.PatternStringExact];throw Error("TypeExtends: Cannot get record value")}function sn(V,_){const J=En(_),se=It(_);if(o.TLiteral(V)&&E(V)&&o.TNumber(J)&&x(Y(V,se))===a.True)return a.True;if(o.TUint8Array(V)&&o.TNumber(J)||o.TString(V)&&o.TNumber(J)||o.TArray(V)&&o.TNumber(J))return Y(V,se);if(o.TObject(V)){for(const xe of globalThis.Object.keys(V.properties))if(ct(se,V.properties[xe])===a.False)return a.False;return a.True}return a.False}function fn(V,_){const J=It(V);return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?Y(J,It(_)):a.False}function Kn(V,_){return o.TLiteral(V)&&typeof V.const=="string"||o.TString(V)?a.True:a.False}function kn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TString(_)?a.True:a.False}function Hn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TSymbol(_)?a.True:a.False}function Wn(V,_){if(o.TTemplateLiteral(V))return Y(m.Resolve(V),_);if(o.TTemplateLiteral(_))return Y(V,m.Resolve(_));throw new Error("TypeExtends: Invalid fallthrough for TemplateLiteral")}function On(V,_){return o.TUnknown(V)?a.False:o.TAny(V)?a.Union:o.TNever(V)?a.True:a.False}function An(V,_){return o.TArray(_)&&V.items!==void 0&&V.items.every(J=>Y(J,_.items)===a.True)}function Gn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)&&Qe(_)||o.TArray(_)&&An(V,_)?a.True:!o.TTuple(_)||V.items===void 0&&_.items!==void 0||V.items!==void 0&&_.items===void 0?a.False:V.items===void 0&&_.items===void 0||V.items.every((J,se)=>Y(J,_.items[se])===a.True)?a.True:a.False}function gn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TUint8Array(_)?a.True:a.False}function te(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TVoid(_)?Me(V):o.TUndefined(_)?a.True:a.False}function ke(V,_){return _.anyOf.some(J=>Y(V,J)===a.True)?a.True:a.False}function dt(V,_){return V.anyOf.every(J=>Y(J,_)===a.True)?a.True:a.False}function Ct(V,_){return a.True}function cn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TAny(_)?S():o.TString(_)?Kn(V):o.TNumber(_)?Ie(V):o.TInteger(_)?L(V):o.TBoolean(_)?H(V):o.TArray(_)?B(V):o.TTuple(_)?On(V):o.TObject(_)?mt(V,_):o.TUnknown(_)?a.True:a.False}function Me(V,_){return o.TUndefined(V)||o.TUndefined(V)?a.True:a.False}function ut(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TVoid(_)?a.True:a.False}function Y(V,_){if(o.TTemplateLiteral(V)||o.TTemplateLiteral(_))return Wn(V,_);if(o.TNot(V)||o.TNot(_))return Se(V,_);if(o.TAny(V))return D(V,_);if(o.TArray(V))return $(V,_);if(o.TBigInt(V))return F(V,_);if(o.TBoolean(V))return q(V,_);if(o.TConstructor(V))return U(V,_);if(o.TDate(V))return N(V,_);if(o.TFunction(V))return M(V,_);if(o.TInteger(V))return I(V,_);if(o.TIntersect(V))return O(V,_);if(o.TLiteral(V))return me(V,_);if(o.TNever(V))return Ee();if(o.TNull(V))return ge(V,_);if(o.TNumber(V))return ue(V,_);if(o.TObject(V))return Ft(V,_);if(o.TRecord(V))return fn(V,_);if(o.TString(V))return kn(V,_);if(o.TSymbol(V))return Hn(V,_);if(o.TTuple(V))return Gn(V,_);if(o.TPromise(V))return St(V,_);if(o.TUint8Array(V))return gn(V,_);if(o.TUndefined(V))return te(V,_);if(o.TUnion(V))return dt(V,_);if(o.TUnknown(V))return cn(V,_);if(o.TVoid(V))return ut(V,_);throw Error(`TypeExtends: Unknown left type operand '${V[e.Kind]}'`)}function de(V,_){return Y(V,_)}A.Extends=de})(s||(e.TypeExtends=s={}));var l;(function(A){function x(H){return typeof H=="object"&&H!==null}function S(H){return globalThis.Array.isArray(H)}function D(H){return H.map(q=>$(q))}function B(H){const q=globalThis.Object.getOwnPropertyNames(H).reduce((N,M)=>({...N,[M]:$(H[M])}),{}),U=globalThis.Object.getOwnPropertySymbols(H).reduce((N,M)=>({...N,[M]:$(H[M])}),{});return{...q,...U}}function $(H){return S(H)?D(H):x(H)?B(H):H}function F(H,q){return{...$(H),...q}}A.Clone=F})(l||(e.TypeClone=l={}));var c;(function(A){function x(I){return I.map(T=>{const{[e.Modifier]:O,...E}=l.Clone(T,{});return E})}function S(I){return I.every(T=>o.TOptional(T))}function D(I){return I.some(T=>o.TOptional(T))}function B(I){return S(I.allOf)?e.Type.Optional(e.Type.Intersect(x(I.allOf))):I}function $(I){return D(I.anyOf)?e.Type.Optional(e.Type.Union(x(I.anyOf))):I}function F(I){return I[e.Kind]==="Intersect"?B(I):I[e.Kind]==="Union"?$(I):I}function H(I,T){const O=I.allOf.reduce((E,G)=>{const re=M(G,T);return re[e.Kind]==="Never"?E:[...E,re]},[]);return F(e.Type.Intersect(O))}function q(I,T){const O=I.anyOf.map(E=>M(E,T));return F(e.Type.Union(O))}function U(I,T){const O=I.properties[T];return O===void 0?e.Type.Never():e.Type.Union([O])}function N(I,T){const O=I.items;if(O===void 0)return e.Type.Never();const E=O[T];return E===void 0?e.Type.Never():E}function M(I,T){return I[e.Kind]==="Intersect"?H(I,T):I[e.Kind]==="Union"?q(I,T):I[e.Kind]==="Object"?U(I,T):I[e.Kind]==="Tuple"?N(I,T):e.Type.Never()}function L(I,T,O={}){const E=T.map(G=>M(I,G.toString()));return F(e.Type.Union(E,O))}A.Resolve=L})(c||(e.IndexedAccessor=c={}));var f;(function(A){function x(F,H){return e.Type.Intersect(F.allOf.map(q=>B(q,H)),{...F})}function S(F,H){return e.Type.Union(F.anyOf.map(q=>B(q,H)),{...F})}function D(F,H){return H(F)}function B(F,H){return F[e.Kind]==="Intersect"?x(F,H):F[e.Kind]==="Union"?S(F,H):F[e.Kind]==="Object"?D(F,H):F}function $(F,H,q){return{...B(l.Clone(F,{}),H),...q}}A.Map=$})(f||(e.ObjectMap=f={}));var u;(function(A){function x(U){return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U}function S(U,N){return U.allOf.reduce((M,L)=>[...M,...F(L,N)],[])}function D(U,N){const M=U.anyOf.map(L=>F(L,N));return[...M.reduce((L,I)=>I.map(T=>M.every(O=>O.includes(T))?L.add(T):L)[0],new Set)]}function B(U,N){return globalThis.Object.keys(U.properties)}function $(U,N){return N.includePatterns?globalThis.Object.keys(U.patternProperties):[]}function F(U,N){return o.TIntersect(U)?S(U,N):o.TUnion(U)?D(U,N):o.TObject(U)?B(U):o.TRecord(U)?$(U,N):[]}function H(U,N){return[...new Set(F(U,N))]}A.ResolveKeys=H;function q(U){return`^(${H(U,{includePatterns:!0}).map(L=>`(${x(L)})`).join("|")})$`}A.ResolvePattern=q})(u||(e.KeyResolver=u={}));var d;(function(A){function x(S){if(globalThis.Array.isArray(S))return S;if(o.TUnionLiteral(S))return S.anyOf.map(D=>D.const.toString());if(o.TLiteral(S))return[S.const];if(o.TTemplateLiteral(S)){const D=g.ParseExact(S.pattern);if(!y.Check(D))throw Error("KeyArrayResolver: Cannot resolve keys from infinite template expression");return[...w.Generate(D)]}return[]}A.Resolve=x})(d||(e.KeyArrayResolver=d={}));var h;(function(A){function*x(D){for(const B of D.anyOf)B[e.Kind]==="Union"?yield*x(B):yield B}function S(D){return e.Type.Union([...x(D)],{...D})}A.Resolve=S})(h||(e.UnionResolver=h={}));var p;(function(A){function x(B){return B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(B,$){if(o.TTemplateLiteral(B))return B.pattern.slice(1,B.pattern.length-1);if(o.TUnion(B))return`(${B.anyOf.map(H=>S(H,$)).join("|")})`;if(o.TNumber(B))return`${$}${e.PatternNumber}`;if(o.TInteger(B))return`${$}${e.PatternNumber}`;if(o.TBigInt(B))return`${$}${e.PatternNumber}`;if(o.TString(B))return`${$}${e.PatternString}`;if(o.TLiteral(B))return`${$}${x(B.const.toString())}`;if(o.TBoolean(B))return`${$}${e.PatternBoolean}`;throw o.TNever(B)?Error("TemplateLiteralPattern: TemplateLiteral cannot operate on types of TNever"):Error(`TemplateLiteralPattern: Unexpected Kind '${B[e.Kind]}'`)}function D(B){return`^${B.map($=>S($,"")).join("")}$`}A.Create=D})(p||(e.TemplateLiteralPattern=p={}));var m;(function(A){function x(S){const D=g.ParseExact(S.pattern);if(!y.Check(D))return e.Type.String();const B=[...w.Generate(D)].map($=>e.Type.Literal($));return e.Type.Union(B)}A.Resolve=x})(m||(e.TemplateLiteralResolver=m={}));class v extends Error{constructor(x){super(x)}}e.TemplateLiteralParserError=v;var g;(function(A){function x(I,T,O){return I[T]===O&&I.charCodeAt(T-1)!==92}function S(I,T){return x(I,T,"(")}function D(I,T){return x(I,T,")")}function B(I,T){return x(I,T,"|")}function $(I){if(!(S(I,0)&&D(I,I.length-1)))return!1;let T=0;for(let O=0;O<I.length;O++)if(S(I,O)&&(T+=1),D(I,O)&&(T-=1),T===0&&O!==I.length-1)return!1;return!0}function F(I){return I.slice(1,I.length-1)}function H(I){let T=0;for(let O=0;O<I.length;O++)if(S(I,O)&&(T+=1),D(I,O)&&(T-=1),B(I,O)&&T===0)return!0;return!1}function q(I){for(let T=0;T<I.length;T++)if(S(I,T))return!0;return!1}function U(I){let[T,O]=[0,0];const E=[];for(let re=0;re<I.length;re++)if(S(I,re)&&(T+=1),D(I,re)&&(T-=1),B(I,re)&&T===0){const me=I.slice(O,re);me.length>0&&E.push(M(me)),O=re+1}const G=I.slice(O);return G.length>0&&E.push(M(G)),E.length===0?{type:"const",const:""}:E.length===1?E[0]:{type:"or",expr:E}}function N(I){function T(G,re){if(!S(G,re))throw new v("TemplateLiteralParser: Index must point to open parens");let me=0;for(let je=re;je<G.length;je++)if(S(G,je)&&(me+=1),D(G,je)&&(me-=1),me===0)return[re,je];throw new v("TemplateLiteralParser: Unclosed group parens in expression")}function O(G,re){for(let me=re;me<G.length;me++)if(S(G,me))return[re,me];return[re,G.length]}const E=[];for(let G=0;G<I.length;G++)if(S(I,G)){const[re,me]=T(I,G),je=I.slice(re,me+1);E.push(M(je)),G=me}else{const[re,me]=O(I,G),je=I.slice(re,me);je.length>0&&E.push(M(je)),G=me-1}return E.length===0?{type:"const",const:""}:E.length===1?E[0]:{type:"and",expr:E}}function M(I){return $(I)?M(F(I)):H(I)?U(I):q(I)?N(I):{type:"const",const:I}}A.Parse=M;function L(I){return M(I.slice(1,I.length-1))}A.ParseExact=L})(g||(e.TemplateLiteralParser=g={}));var y;(function(A){function x($){return $.type==="or"&&$.expr.length===2&&$.expr[0].type==="const"&&$.expr[0].const==="0"&&$.expr[1].type==="const"&&$.expr[1].const==="[1-9][0-9]*"}function S($){return $.type==="or"&&$.expr.length===2&&$.expr[0].type==="const"&&$.expr[0].const==="true"&&$.expr[1].type==="const"&&$.expr[1].const==="false"}function D($){return $.type==="const"&&$.const===".*"}function B($){if(S($))return!0;if(x($)||D($))return!1;if($.type==="and")return $.expr.every(F=>B(F));if($.type==="or")return $.expr.every(F=>B(F));if($.type==="const")return!0;throw Error("TemplateLiteralFinite: Unknown expression type")}A.Check=B})(y||(e.TemplateLiteralFinite=y={}));var w;(function(A){function*x(F){if(F.length===1)return yield*F[0];for(const H of F[0])for(const q of x(F.slice(1)))yield`${H}${q}`}function*S(F){return yield*x(F.expr.map(H=>[...$(H)]))}function*D(F){for(const H of F.expr)yield*$(H)}function*B(F){return yield F.const}function*$(F){if(F.type==="and")return yield*S(F);if(F.type==="or")return yield*D(F);if(F.type==="const")return yield*B(F);throw Error("TemplateLiteralGenerator: Unknown expression")}A.Generate=$})(w||(e.TemplateLiteralGenerator=w={}));var k;(function(A){function*x($){const F=$.trim().replace(/"|'/g,"");if(F==="boolean")return yield e.Type.Boolean();if(F==="number")return yield e.Type.Number();if(F==="bigint")return yield e.Type.BigInt();if(F==="string")return yield e.Type.String();const H=F.split("|").map(q=>e.Type.Literal(q.trim()));return yield H.length===0?e.Type.Never():H.length===1?H[0]:e.Type.Union(H)}function*S($){if($[1]!=="{"){const F=e.Type.Literal("$"),H=D($.slice(1));return yield*[F,...H]}for(let F=2;F<$.length;F++)if($[F]==="}"){const H=x($.slice(2,F)),q=D($.slice(F+1));return yield*[...H,...q]}yield e.Type.Literal($)}function*D($){for(let F=0;F<$.length;F++)if($[F]==="$"){const H=e.Type.Literal($.slice(0,F)),q=S($.slice(F));return yield*[H,...q]}yield e.Type.Literal($)}function B($){return[...D($)]}A.Parse=B})(k||(e.TemplateLiteralDslParser=k={}));let C=0;class j{Create(x){return x}Strict(x){return JSON.parse(JSON.stringify(x))}}e.TypeBuilder=j;class P extends j{Optional(x){return{[e.Modifier]:"Optional",...l.Clone(x,{})}}ReadonlyOptional(x){return{[e.Modifier]:"ReadonlyOptional",...l.Clone(x,{})}}Readonly(x){return{[e.Modifier]:"Readonly",...x}}Any(x={}){return this.Create({...x,[e.Kind]:"Any"})}Array(x,S={}){return this.Create({...S,[e.Kind]:"Array",type:"array",items:l.Clone(x,{})})}Boolean(x={}){return this.Create({...x,[e.Kind]:"Boolean",type:"boolean"})}Composite(x,S){const D=e.Type.Intersect(x,{}),$=u.ResolveKeys(D,{includePatterns:!1}).reduce((F,H)=>({...F,[H]:e.Type.Index(D,[H])}),{});return e.Type.Object($,S)}Enum(x,S={}){const B=globalThis.Object.keys(x).filter($=>isNaN($)).map($=>x[$]).map($=>typeof $=="string"?{[e.Kind]:"Literal",type:"string",const:$}:{[e.Kind]:"Literal",type:"number",const:$});return this.Create({...S,[e.Kind]:"Union",anyOf:B})}Extends(x,S,D,B,$={}){switch(s.Extends(x,S)){case a.Union:return this.Union([l.Clone(D,$),l.Clone(B,$)]);case a.True:return l.Clone(D,$);case a.False:return l.Clone(B,$)}}Exclude(x,S,D={}){if(o.TTemplateLiteral(x))return this.Exclude(m.Resolve(x),S,D);if(o.TTemplateLiteral(S))return this.Exclude(x,m.Resolve(S),D);if(o.TUnion(x)){const B=x.anyOf.filter($=>s.Extends($,S)===a.False);return B.length===1?l.Clone(B[0],D):this.Union(B,D)}else return s.Extends(x,S)!==a.False?this.Never(D):l.Clone(x,D)}Extract(x,S,D={}){if(o.TTemplateLiteral(x))return this.Extract(m.Resolve(x),S,D);if(o.TTemplateLiteral(S))return this.Extract(x,m.Resolve(S),D);if(o.TUnion(x)){const B=x.anyOf.filter($=>s.Extends($,S)!==a.False);return B.length===1?l.Clone(B[0],D):this.Union(B,D)}else return s.Extends(x,S)!==a.False?l.Clone(x,D):this.Never(D)}Index(x,S,D={}){if(o.TArray(x)&&o.TNumber(S))return l.Clone(x.items,D);if(o.TTuple(x)&&o.TNumber(S)){const $=(x.items===void 0?[]:x.items).map(F=>l.Clone(F,{}));return this.Union($,D)}else{const B=d.Resolve(S),$=l.Clone(x,{});return c.Resolve($,B,D)}}Integer(x={}){return this.Create({...x,[e.Kind]:"Integer",type:"integer"})}Intersect(x,S={}){if(x.length===0)return e.Type.Never();if(x.length===1)return l.Clone(x[0],S);const D=x.every(F=>o.TObject(F)),B=x.map(F=>l.Clone(F,{})),$=o.TSchema(S.unevaluatedProperties)?{unevaluatedProperties:l.Clone(S.unevaluatedProperties,{})}:{};return S.unevaluatedProperties===!1||o.TSchema(S.unevaluatedProperties)||D?this.Create({...S,...$,[e.Kind]:"Intersect",type:"object",allOf:B}):this.Create({...S,...$,[e.Kind]:"Intersect",allOf:B})}KeyOf(x,S={}){if(o.TRecord(x)){const D=Object.getOwnPropertyNames(x.patternProperties)[0];if(D===e.PatternNumberExact)return this.Number(S);if(D===e.PatternStringExact)return this.String(S);throw Error("StandardTypeBuilder: Unable to resolve key type from Record key pattern")}else if(o.TTuple(x)){const B=(x.items===void 0?[]:x.items).map(($,F)=>e.Type.Literal(F));return this.Union(B,S)}else{if(o.TArray(x))return this.Number(S);{const D=u.ResolveKeys(x,{includePatterns:!1});if(D.length===0)return this.Never(S);const B=D.map($=>this.Literal($));return this.Union(B,S)}}}Literal(x,S={}){return this.Create({...S,[e.Kind]:"Literal",const:x,type:typeof x})}Never(x={}){return this.Create({...x,[e.Kind]:"Never",not:{}})}Not(x,S){return this.Create({...S,[e.Kind]:"Not",not:x})}Null(x={}){return this.Create({...x,[e.Kind]:"Null",type:"null"})}Number(x={}){return this.Create({...x,[e.Kind]:"Number",type:"number"})}Object(x,S={}){const D=globalThis.Object.getOwnPropertyNames(x),B=D.filter(q=>o.TOptional(x[q])||o.TReadonlyOptional(x[q])),$=D.filter(q=>!B.includes(q)),F=o.TSchema(S.additionalProperties)?{additionalProperties:l.Clone(S.additionalProperties,{})}:{},H=D.reduce((q,U)=>({...q,[U]:l.Clone(x[U],{})}),{});return $.length>0?this.Create({...S,...F,[e.Kind]:"Object",type:"object",properties:H,required:$}):this.Create({...S,...F,[e.Kind]:"Object",type:"object",properties:H})}Omit(x,S,D={}){const B=d.Resolve(S);return f.Map(l.Clone(x,{}),$=>{$.required&&($.required=$.required.filter(F=>!B.includes(F)),$.required.length===0&&delete $.required);for(const F of globalThis.Object.keys($.properties))B.includes(F)&&delete $.properties[F];return this.Create($)},D)}Partial(x,S={}){function D(B){switch(B[e.Modifier]){case"ReadonlyOptional":B[e.Modifier]="ReadonlyOptional";break;case"Readonly":B[e.Modifier]="ReadonlyOptional";break;case"Optional":B[e.Modifier]="Optional";break;default:B[e.Modifier]="Optional";break}}return f.Map(l.Clone(x,{}),B=>(delete B.required,globalThis.Object.keys(B.properties).forEach($=>D(B.properties[$])),B),S)}Pick(x,S,D={}){const B=d.Resolve(S);return f.Map(l.Clone(x,{}),$=>{$.required&&($.required=$.required.filter(F=>B.includes(F)),$.required.length===0&&delete $.required);for(const F of globalThis.Object.keys($.properties))B.includes(F)||delete $.properties[F];return this.Create($)},D)}Record(x,S,D={}){if(o.TTemplateLiteral(x)){const B=g.ParseExact(x.pattern);return y.Check(B)?this.Object([...w.Generate(B)].reduce(($,F)=>({...$,[F]:l.Clone(S,{})}),{}),D):this.Create({...D,[e.Kind]:"Record",type:"object",patternProperties:{[x.pattern]:l.Clone(S,{})}})}else if(o.TUnion(x)){const B=h.Resolve(x);if(o.TUnionLiteral(B)){const $=B.anyOf.reduce((F,H)=>({...F,[H.const]:l.Clone(S,{})}),{});return this.Object($,{...D,[e.Hint]:"Record"})}else throw Error("TypeBuilder: Record key of type union contains non-literal types")}else if(o.TLiteral(x)){if(typeof x.const=="string"||typeof x.const=="number")return this.Object({[x.const]:l.Clone(S,{})},D);throw Error("TypeBuilder: Record key of type literal is not of type string or number")}else if(o.TInteger(x)||o.TNumber(x)){const B=e.PatternNumberExact;return this.Create({...D,[e.Kind]:"Record",type:"object",patternProperties:{[B]:l.Clone(S,{})}})}else if(o.TString(x)){const B=x.pattern===void 0?e.PatternStringExact:x.pattern;return this.Create({...D,[e.Kind]:"Record",type:"object",patternProperties:{[B]:l.Clone(S,{})}})}else throw Error("StandardTypeBuilder: Record key is an invalid type")}Recursive(x,S={}){S.$id===void 0&&(S.$id=`T${C++}`);const D=x({[e.Kind]:"This",$ref:`${S.$id}`});return D.$id=S.$id,this.Create({...S,[e.Hint]:"Recursive",...D})}Ref(x,S={}){if(x.$id===void 0)throw Error("StandardTypeBuilder.Ref: Target type must specify an $id");return this.Create({...S,[e.Kind]:"Ref",$ref:x.$id})}Required(x,S={}){function D(B){switch(B[e.Modifier]){case"ReadonlyOptional":B[e.Modifier]="Readonly";break;case"Readonly":B[e.Modifier]="Readonly";break;case"Optional":delete B[e.Modifier];break;default:delete B[e.Modifier];break}}return f.Map(l.Clone(x,{}),B=>(B.required=globalThis.Object.keys(B.properties),globalThis.Object.keys(B.properties).forEach($=>D(B.properties[$])),B),S)}Rest(x){return o.TTuple(x)?x.items===void 0?[]:x.items.map(S=>l.Clone(S,{})):[l.Clone(x,{})]}String(x={}){return this.Create({...x,[e.Kind]:"String",type:"string"})}TemplateLiteral(x,S={}){const D=typeof x=="string"?p.Create(k.Parse(x)):p.Create(x);return this.Create({...S,[e.Kind]:"TemplateLiteral",type:"string",pattern:D})}Tuple(x,S={}){const[D,B,$]=[!1,x.length,x.length],F=x.map(q=>l.Clone(q,{})),H=x.length>0?{...S,[e.Kind]:"Tuple",type:"array",items:F,additionalItems:D,minItems:B,maxItems:$}:{...S,[e.Kind]:"Tuple",type:"array",minItems:B,maxItems:$};return this.Create(H)}Union(x,S={}){if(o.TTemplateLiteral(x))return m.Resolve(x);{const D=x;if(D.length===0)return this.Never(S);if(D.length===1)return this.Create(l.Clone(D[0],S));const B=D.map($=>l.Clone($,{}));return this.Create({...S,[e.Kind]:"Union",anyOf:B})}}Unknown(x={}){return this.Create({...x,[e.Kind]:"Unknown"})}Unsafe(x={}){return this.Create({...x,[e.Kind]:x[e.Kind]||"Unsafe"})}}e.StandardTypeBuilder=P;class R extends P{BigInt(x={}){return this.Create({...x,[e.Kind]:"BigInt",type:"null",typeOf:"BigInt"})}ConstructorParameters(x,S={}){return this.Tuple([...x.parameters],{...S})}Constructor(x,S,D){const B=l.Clone(S,{}),$=x.map(F=>l.Clone(F,{}));return this.Create({...D,[e.Kind]:"Constructor",type:"object",instanceOf:"Constructor",parameters:$,returns:B})}Date(x={}){return this.Create({...x,[e.Kind]:"Date",type:"object",instanceOf:"Date"})}Function(x,S,D){const B=l.Clone(S,{}),$=x.map(F=>l.Clone(F,{}));return this.Create({...D,[e.Kind]:"Function",type:"object",instanceOf:"Function",parameters:$,returns:B})}InstanceType(x,S={}){return l.Clone(x.returns,S)}Parameters(x,S={}){return this.Tuple(x.parameters,{...S})}Promise(x,S={}){return this.Create({...S,[e.Kind]:"Promise",type:"object",instanceOf:"Promise",item:l.Clone(x,{})})}RegEx(x,S={}){return this.Create({...S,[e.Kind]:"String",type:"string",pattern:x.source})}ReturnType(x,S={}){return l.Clone(x.returns,S)}Symbol(x){return this.Create({...x,[e.Kind]:"Symbol",type:"null",typeOf:"Symbol"})}Undefined(x={}){return this.Create({...x,[e.Kind]:"Undefined",type:"null",typeOf:"Undefined"})}Uint8Array(x={}){return this.Create({...x,[e.Kind]:"Uint8Array",type:"object",instanceOf:"Uint8Array"})}Void(x={}){return this.Create({...x,[e.Kind]:"Void",type:"null",typeOf:"Void"})}}e.ExtendedTypeBuilder=R,e.StandardType=new P,e.Type=new R})(K);const Jpe=K.Type.Object({src:K.Type.String(),path:K.Type.Optional(K.Type.String()),volume:K.Type.Optional(K.Type.Number()),rate:K.Type.Optional(K.Type.Number()),html5:K.Type.Optional(K.Type.Boolean()),fadeInTime:K.Type.Optional(K.Type.Number()),fadeInDelay:K.Type.Optional(K.Type.Number()),fadeOutTime:K.Type.Optional(K.Type.Number()),loop:K.Type.Optional(K.Type.Boolean())}),Qpe=K.Type.Record(K.Type.String(),Jpe),Ype=K.Type.Object({volume:K.Type.Optional(K.Type.Number()),defaultMusic:K.Type.Optional(K.Type.String()),musicFadeInTime:K.Type.Optional(K.Type.Number()),musicFadeOutTime:K.Type.Optional(K.Type.Number()),musicFadeInDelay:K.Type.Optional(K.Type.Number())}),Xpe=K.Type.Record(K.Type.String(),K.Type.String()),g9=K.Type.Object({files:Qpe,audioTriggers:Xpe,options:Ype}),y9={files:{},audioTriggers:{},options:{volume:1,musicFadeInTime:.5,musicFadeInDelay:.5,musicFadeOutTime:.5}},Zpe=K.Type.Object({name:K.Type.String(),description:K.Type.String(),icon:K.Type.String(),onUse:K.Type.Optional(K.Type.Object({action:K.Type.String(),label:K.Type.String()})),tag:K.Type.Optional(K.Type.String()),category:K.Type.Optional(K.Type.String()),showIfEmpty:K.Type.Optional(K.Type.Boolean())}),b9=K.Type.Object({id:K.Type.String(),title:K.Type.String()}),w9=K.Type.Record(K.Type.String(),Zpe);K.Type.Object({categories:K.Type.Array(b9),items:w9});const k9=K.Type.Object({categories:K.Type.Optional(K.Type.Array(b9)),items:K.Type.Optional(w9)}),x9={categories:[{id:"default",title:"Items"}],items:{}},eme=K.Type.Object({description:K.Type.String(),hidden:K.Type.Optional(K.Type.Boolean())}),tme=K.Type.Object({title:K.Type.String(),description:K.Type.String(),objectives:K.Type.Record(K.Type.String(),eme),category:K.Type.Optional(K.Type.String())}),nme=K.Type.Object({id:K.Type.String(),title:K.Type.String()}),rme=K.Type.Record(K.Type.String(),tme),_9=K.Type.Object({quests:rme,categories:K.Type.Array(nme)}),j9={quests:{},categories:[{id:"default",title:"Quests"}]},S9=K.Type.Object({enabled:K.Type.Boolean(),background:K.Type.Optional(K.Type.String()),text:K.Type.Optional(K.Type.String()),cssClass:K.Type.Optional(K.Type.String()),position:K.Type.Object({left:K.Type.Number(),top:K.Type.Number(),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())}),anchor:K.Type.Optional(K.Type.Object({x:K.Type.Number(),y:K.Type.Number()})),action:K.Type.Optional(K.Type.String()),actionType:K.Type.Optional(K.Type.String()),scriptClickable:K.Type.Optional(K.Type.Boolean()),tag:K.Type.Optional(K.Type.String())}),ome=K.Type.Record(K.Type.String(),S9),C9=K.Type.Object({buttons:ome,clickableDuringScriptsByDefault:K.Type.Optional(K.Type.Boolean())}),$9={buttons:{},clickableDuringScriptsByDefault:!1},ime=K.Type.Intersect([S9,K.Type.Object({id:K.Type.String()})]),ame=K.Type.Object({muted:K.Type.Optional(K.Type.Boolean()),loop:K.Type.Optional(K.Type.Boolean())}),sme=K.Type.Object({background:K.Type.String(),video:K.Type.Optional(ame),buttons:K.Type.Optional(K.Type.Array(K.Type.Union([K.Type.String(),ime])))}),T9=K.Type.Record(K.Type.String(),sme);K.Type.Object({screens:T9});const E9=K.Type.Object({screens:K.Type.Optional(T9)}),O9={screens:{}},lme=K.Type.Object({name:K.Type.String(),description:K.Type.String(),startingLevel:K.Type.Number(),hidden:K.Type.Optional(K.Type.Boolean()),icon:K.Type.String()}),A9=K.Type.Record(K.Type.String(),lme),M9=K.Type.Object({xpPerLevel:K.Type.Number(),notifyLevelUp:K.Type.Boolean()});K.Type.Object({skills:A9,skillOptions:M9});const P9=K.Type.Object({skills:K.Type.Optional(A9),skillOptions:K.Type.Optional(M9)}),N9={skills:{},skillOptions:{xpPerLevel:10,notifyLevelUp:!0}},Xg="###_--_~=:;_JUMP",o_="###_--_~=:;_RETURN",cme="###_--_~=:;_OK",Zg="###_--_~=:;_STOP";function ume(e){return e===Xg||e===o_||e===cme||e===Zg}const fme="3.3.6",dme=new Date("2023-10-08T08:54:23.296Z"),hme=400,e0=20,i_="@empty",I9={background:i_},pme=K.Type.Object({color:K.Type.Optional(K.Type.String()),boxCss:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.Any())),nameCss:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.Any())),textCss:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.Any()))}),mme=K.Type.Object({video:K.Type.String(),autoplay:K.Type.Optional(K.Type.Boolean()),loop:K.Type.Optional(K.Type.Boolean()),muted:K.Type.Optional(K.Type.Boolean()),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())}),vme=K.Type.Object({image:K.Type.String(),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())}),gme=K.Type.Union([K.Type.String(),mme,vme]),yme=K.Type.Object({sprites:K.Type.Optional(K.Type.Record(K.Type.String(),gme)),name:K.Type.String(),style:K.Type.Optional(pme)}),D9=K.Type.Object({config:K.Type.Object({imagesPath:K.Type.String(),playerCharacter:K.Type.Optional(K.Type.String()),gameCharacter:K.Type.Optional(K.Type.String())}),characters:K.Type.Record(K.Type.String(),yme)}),L9={config:{imagesPath:"",playerCharacter:"player",gameCharacter:"game"},characters:{}},bme=K.Type.Object({backgrounds:K.Type.Object({width:K.Type.Number(),height:K.Type.Number()}),dialogBottomPadding:K.Type.Union([K.Type.Number(),K.Type.String()]),minTextWidth:K.Type.Optional(K.Type.Number()),verticalLayoutThreshold:K.Type.Number(),defaultFontSize:K.Type.Optional(K.Type.Number()),portraits:K.Type.Object({width:K.Type.Number(),height:K.Type.Number(),offset:K.Type.Optional(K.Type.Object({landscape:K.Type.Optional(K.Type.Object({right:K.Type.Number(),bottom:K.Type.Number()})),portrait:K.Type.Optional(K.Type.Object({right:K.Type.Number(),bottom:K.Type.Number()}))}))})}),wme={backgrounds:{width:880,height:720},dialogBottomPadding:70,verticalLayoutThreshold:600,defaultFontSize:16,portraits:{width:100,height:100}},R9=K.Type.Object({options:K.Type.Object({delay:K.Type.Optional(K.Type.Number()),width:K.Type.Number(),keywordsPrefix:K.Type.String(),screenEdgesMinimumMargin:K.Type.Optional(K.Type.Number())}),tooltips:K.Type.Array(K.Type.Object({keywords:K.Type.Array(K.Type.String()),title:K.Type.String(),description:K.Type.String()}))}),B9={options:{delay:0,width:350,keywordsPrefix:"@@"},tooltips:[]},kme=K.Type.Object({name:K.Type.String(),description:K.Type.String(),icon:K.Type.String(),secret:K.Type.Optional(K.Type.Boolean()),category:K.Type.Optional(K.Type.String())}),F9=K.Type.Object({id:K.Type.String(),title:K.Type.String()}),V9=K.Type.Record(K.Type.String(),kme);K.Type.Object({defaultAchievementIcon:K.Type.String(),categories:K.Type.Array(F9),achievements:V9,notifyNewAchievements:K.Type.Boolean(),secretAchievements:K.Type.Optional(K.Type.Object({censorDescription:K.Type.Optional(K.Type.Boolean()),censorName:K.Type.Optional(K.Type.Boolean()),hideUntilObtained:K.Type.Optional(K.Type.Boolean())}))});const xme=K.Type.Object({categories:K.Type.Optional(K.Type.Array(F9)),achievements:K.Type.Optional(V9)}),z9={categories:[{id:"default",title:"Achievements"}],achievements:{},notifyNewAchievements:!0,defaultAchievementIcon:"img/achievements/trophy.png"},_me=K.Type.Object({diceRange:K.Type.Tuple([K.Type.Number(),K.Type.Number()]),diceCount:K.Type.Number(),difficultyText:K.Type.Array(K.Type.Tuple([K.Type.Number(),K.Type.String()])),extraPointsPerLevel:K.Type.Number(),extraDicePerLevel:K.Type.Optional(K.Type.Number()),successOnRollsBelowThreshold:K.Type.Boolean(),showDifficultyText:K.Type.Boolean(),showDifficultyNumber:K.Type.Boolean(),showDifficultyWithoutModifiers:K.Type.Boolean(),finalRollIsHighest:K.Type.Optional(K.Type.Boolean()),finalRollIsLowest:K.Type.Optional(K.Type.Boolean()),failOnRollsEqualToThreshold:K.Type.Optional(K.Type.Boolean())}),jme=K.Type.Object({skill:K.Type.String(),difficulty:K.Type.Number(),winsNeeded:K.Type.Optional(K.Type.Number()),hideAfterRoll:K.Type.Optional(K.Type.Boolean()),repeatable:K.Type.Optional(K.Type.Boolean())}),q9=K.Type.Object({options:_me,skillChecks:K.Type.Record(K.Type.String(),jme)}),U9={options:{diceRange:[1,6],extraPointsPerLevel:1,extraDicePerLevel:0,diceCount:2,successOnRollsBelowThreshold:!1,showDifficultyText:!0,showDifficultyNumber:!1,showDifficultyWithoutModifiers:!1,finalRollIsHighest:!1,finalRollIsLowest:!1,difficultyText:[[2,"Very Easy"],[4,"Easy"],[6,"Medium"],[8,"Hard"],[10,"Very Hard"],[11,"Extremely Hard"],[12,"Near Impossible"]]},skillChecks:{}},iu={baseAssetsPath:"",baseDataPath:"",gameTitle:"Narrat Game",saveFileName:"narrat save",images:{},layout:wme,settings:{},gameFlow:{},dialogPanel:{overlayMode:!0,rightOffset:100,bottomOffset:50,width:475,height:680,textSpeed:e0,animateText:!0,timeBetweenLines:100},splashScreens:{},screens:O9,buttons:$9,skills:N9,skillChecks:U9,scripts:[],audio:y9,notifications:{timeOnScreen:2.5,alsoPrintInDialogue:!1},tooltips:B9,hudStats:{},achievements:z9,items:x9,interactionTags:{default:{onlyInteractOutsideOfScripts:!0}},quests:j9,transitions:{},menuButtons:{},debugging:{showScriptFinishedMessage:!1},saves:{mode:"manual",slots:10},characters:L9};var Sme=function(t){return Cme(t)&&!$me(t)};function Cme(e){return!!e&&typeof e=="object"}function $me(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||Ome(e)}var Tme=typeof Symbol=="function"&&Symbol.for,Eme=Tme?Symbol.for("react.element"):60103;function Ome(e){return e.$$typeof===Eme}function Ame(e){return Array.isArray(e)?[]:{}}function Xh(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Ff(Ame(e),e,t):e}function Mme(e,t,n){return e.concat(t).map(function(r){return Xh(r,n)})}function Pme(e,t){if(!t.customMerge)return Ff;var n=t.customMerge(e);return typeof n=="function"?n:Ff}function Nme(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function H9(e){return Object.keys(e).concat(Nme(e))}function W9(e,t){try{return t in e}catch{return!1}}function Ime(e,t){return W9(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Dme(e,t,n){var r={};return n.isMergeableObject(e)&&H9(e).forEach(function(o){r[o]=Xh(e[o],n)}),H9(t).forEach(function(o){Ime(e,o)||(W9(e,o)&&n.isMergeableObject(t[o])?r[o]=Pme(o,n)(e[o],t[o],n):r[o]=Xh(t[o],n))}),r}function Ff(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Mme,n.isMergeableObject=n.isMergeableObject||Sme,n.cloneUnlessOtherwiseSpecified=Xh;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):Dme(e,t,n):Xh(t,n)}Ff.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return Ff(r,o,n)},{})};var Lme=Ff,Rme=Lme;const Zh=V2(Rme),ni=co("config",{state:()=>({config:iu}),actions:{async setConfig(e){this.config=e},extendConfig(e){this.config=Zh(this.config,e)},generateSaveData(){return{playerCharacter:this.playerCharacter,gameCharacter:this.gameCharacter}},loadSaveData(e){this.config.characters.config.playerCharacter=e.playerCharacter,this.config.characters.config.gameCharacter=e.gameCharacter}},getters:{playerCharacter(){return this.config.characters.config.playerCharacter??"player"},gameCharacter(){return this.config.characters.config.gameCharacter??"game"}}});function K9(e){const t=Cr(),n=t.getSkillCheck(e.id);if(n&&n.happened&&(n.succeeded||!e.repeatable))return n;const r=Gpe(e);return Q9(Upe(r,e)),r?t.passSkillCheck(e.id,e.hideAfterRoll):t.failSkillCheck(e.id,e.hideAfterRoll),t.getSkillCheck(e.id)}function Bme(e,t=[]){const n=e.options,r=e.staticOptions,o=!!n.condition;if(o)return r.success;if(!o){for(const[i,a]of r.elseifs.entries())if(t[i]===!0)return a.branch}if(!o&&r.failure)return r.failure}function G9(e){return typeof e=="object"}function J9(e){return typeof e=="string"&&e.search(/\$/)===0}function Q9(e){const t={speaker:ni().gameCharacter,text:e,interactive:!1};Yn().addDialog(t)}async function a_(e){Yn().addDialog(e)}function Fme(e,t){if(t<e.length)return e[t]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function Y9(e){return typeof e>"u"||e===null}function Vme(e){return typeof e=="object"&&e!==null}function zme(e){return Array.isArray(e)?e:Y9(e)?[]:[e]}function qme(e,t){var n,r,o,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)o=i[n],e[o]=t[o];return e}function Ume(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function Hme(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Wme=Y9,Kme=Vme,Gme=zme,Jme=Ume,Qme=Hme,Yme=qme,uo={isNothing:Wme,isObject:Kme,toArray:Gme,repeat:Jme,isNegativeZero:Qme,extend:Yme};function X9(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
|
|
175
|
+
(${e.id} - ${a}/${e.winsNeeded} - rolls: ${JSON.stringify(r.map(s=>s.modified))})`)}else i=v9(n,e.difficulty),di.log(`[SKILL CHECK ${o.name}]: ${i?"✅":"❌"}`,`(${e.id}) - ${n}/${e.difficulty}`);return ru(i?"onSkillCheckSuccess":"onSkillCheckFailure"),i}function v9(e,t){const{options:n}=kp();let r=e>=t;return n.successOnRollsBelowThreshold&&(r=e<=t),n.failOnRollsEqualToThreshold&&e===t&&(r=!1),r}var K={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Type=e.StandardType=e.ExtendedTypeBuilder=e.StandardTypeBuilder=e.TypeBuilder=e.TemplateLiteralDslParser=e.TemplateLiteralGenerator=e.TemplateLiteralFinite=e.TemplateLiteralParser=e.TemplateLiteralParserError=e.TemplateLiteralResolver=e.TemplateLiteralPattern=e.UnionResolver=e.KeyArrayResolver=e.KeyResolver=e.ObjectMap=e.IndexedAccessor=e.TypeClone=e.TypeExtends=e.TypeExtendsResult=e.ExtendsUndefined=e.TypeGuard=e.TypeGuardUnknownTypeError=e.FormatRegistry=e.TypeRegistry=e.PatternStringExact=e.PatternNumberExact=e.PatternBooleanExact=e.PatternString=e.PatternNumber=e.PatternBoolean=e.Kind=e.Hint=e.Modifier=void 0,e.Modifier=Symbol.for("TypeBox.Modifier"),e.Hint=Symbol.for("TypeBox.Hint"),e.Kind=Symbol.for("TypeBox.Kind"),e.PatternBoolean="(true|false)",e.PatternNumber="(0|[1-9][0-9]*)",e.PatternString="(.*)",e.PatternBooleanExact=`^${e.PatternBoolean}$`,e.PatternNumberExact=`^${e.PatternNumber}$`,e.PatternStringExact=`^${e.PatternString}$`;var t;(function(A){const x=new Map;function S(){return new Map(x)}A.Entries=S;function D(){return x.clear()}A.Clear=D;function B(H){return x.has(H)}A.Has=B;function $(H,q){x.set(H,q)}A.Set=$;function F(H){return x.get(H)}A.Get=F})(t||(e.TypeRegistry=t={}));var n;(function(A){const x=new Map;function S(){return new Map(x)}A.Entries=S;function D(){return x.clear()}A.Clear=D;function B(H){return x.has(H)}A.Has=B;function $(H,q){x.set(H,q)}A.Set=$;function F(H){return x.get(H)}A.Get=F})(n||(e.FormatRegistry=n={}));class r extends Error{constructor(x){super("TypeGuard: Unknown type"),this.schema=x}}e.TypeGuardUnknownTypeError=r;var o;(function(A){function x(te){return typeof te=="object"&&te!==null&&!Array.isArray(te)}function S(te){return typeof te=="object"&&te!==null&&Array.isArray(te)}function D(te){try{return new RegExp(te),!0}catch{return!1}}function B(te){if(typeof te!="string")return!1;for(let ke=0;ke<te.length;ke++){const dt=te.charCodeAt(ke);if(dt>=7&&dt<=13||dt===27||dt===127)return!1}return!0}function $(te){return L(te)||gn(te)}function F(te){return typeof te=="bigint"}function H(te){return typeof te=="string"}function q(te){return typeof te=="number"&&globalThis.Number.isFinite(te)}function U(te){return typeof te=="boolean"}function N(te){return te===void 0||te!==void 0&&F(te)}function M(te){return te===void 0||te!==void 0&&q(te)}function L(te){return te===void 0||te!==void 0&&U(te)}function I(te){return te===void 0||te!==void 0&&H(te)}function T(te){return te===void 0||te!==void 0&&H(te)&&B(te)&&D(te)}function O(te){return te===void 0||te!==void 0&&H(te)&&B(te)}function E(te){return te===void 0||gn(te)}function G(te){return ue(te)&&te[e.Kind]==="Any"&&I(te.$id)}A.TAny=G;function re(te){return ue(te)&&te[e.Kind]==="Array"&&te.type==="array"&&I(te.$id)&&gn(te.items)&&M(te.minItems)&&M(te.maxItems)&&L(te.uniqueItems)}A.TArray=re;function me(te){return ue(te)&&te[e.Kind]==="BigInt"&&te.type==="null"&&te.typeOf==="BigInt"&&I(te.$id)&&N(te.multipleOf)&&N(te.minimum)&&N(te.maximum)&&N(te.exclusiveMinimum)&&N(te.exclusiveMaximum)}A.TBigInt=me;function je(te){return ue(te)&&te[e.Kind]==="Boolean"&&te.type==="boolean"&&I(te.$id)}A.TBoolean=je;function Ee(te){if(!(ue(te)&&te[e.Kind]==="Constructor"&&te.type==="object"&&te.instanceOf==="Constructor"&&I(te.$id)&&S(te.parameters)&&gn(te.returns)))return!1;for(const ke of te.parameters)if(!gn(ke))return!1;return!0}A.TConstructor=Ee;function ve(te){return ue(te)&&te[e.Kind]==="Date"&&te.type==="object"&&te.instanceOf==="Date"&&I(te.$id)&&M(te.minimumTimestamp)&&M(te.maximumTimestamp)&&M(te.exclusiveMinimumTimestamp)&&M(te.exclusiveMaximumTimestamp)}A.TDate=ve;function Se(te){if(!(ue(te)&&te[e.Kind]==="Function"&&te.type==="object"&&te.instanceOf==="Function"&&I(te.$id)&&S(te.parameters)&&gn(te.returns)))return!1;for(const ke of te.parameters)if(!gn(ke))return!1;return!0}A.TFunction=Se;function ge(te){return ue(te)&&te[e.Kind]==="Integer"&&te.type==="integer"&&I(te.$id)&&M(te.multipleOf)&&M(te.minimum)&&M(te.maximum)&&M(te.exclusiveMinimum)&&M(te.exclusiveMaximum)}A.TInteger=ge;function Ie(te){if(!(ue(te)&&te[e.Kind]==="Intersect"&&S(te.allOf)&&I(te.type)&&(L(te.unevaluatedProperties)||E(te.unevaluatedProperties))&&I(te.$id))||"type"in te&&te.type!=="object")return!1;for(const ke of te.allOf)if(!gn(ke))return!1;return!0}A.TIntersect=Ie;function ue(te){return x(te)&&e.Kind in te&&typeof te[e.Kind]=="string"}A.TKind=ue;function We(te){return ue(te)&&te[e.Kind]==="Literal"&&I(te.$id)&&typeof te.const=="string"}A.TLiteralString=We;function ee(te){return ue(te)&&te[e.Kind]==="Literal"&&I(te.$id)&&typeof te.const=="number"}A.TLiteralNumber=ee;function Q(te){return ue(te)&&te[e.Kind]==="Literal"&&I(te.$id)&&typeof te.const=="boolean"}A.TLiteralBoolean=Q;function we(te){return We(te)||ee(te)||Q(te)}A.TLiteral=we;function Ne(te){return ue(te)&&te[e.Kind]==="Never"&&x(te.not)&&globalThis.Object.getOwnPropertyNames(te.not).length===0}A.TNever=Ne;function Ae(te){return ue(te)&&te[e.Kind]==="Not"&&gn(te.not)}A.TNot=Ae;function Ze(te){return ue(te)&&te[e.Kind]==="Null"&&te.type==="null"&&I(te.$id)}A.TNull=Ze;function be(te){return ue(te)&&te[e.Kind]==="Number"&&te.type==="number"&&I(te.$id)&&M(te.multipleOf)&&M(te.minimum)&&M(te.maximum)&&M(te.exclusiveMinimum)&&M(te.exclusiveMaximum)}A.TNumber=be;function De(te){if(!(ue(te)&&te[e.Kind]==="Object"&&te.type==="object"&&I(te.$id)&&x(te.properties)&&$(te.additionalProperties)&&M(te.minProperties)&&M(te.maxProperties)))return!1;for(const[ke,dt]of Object.entries(te.properties))if(!B(ke)||!gn(dt))return!1;return!0}A.TObject=De;function Fe(te){return ue(te)&&te[e.Kind]==="Promise"&&te.type==="object"&&te.instanceOf==="Promise"&&I(te.$id)&&gn(te.item)}A.TPromise=Fe;function Qe(te){if(!(ue(te)&&te[e.Kind]==="Record"&&te.type==="object"&&I(te.$id)&&$(te.additionalProperties)&&x(te.patternProperties)))return!1;const ke=Object.keys(te.patternProperties);return!(ke.length!==1||!D(ke[0])||!gn(te.patternProperties[ke[0]]))}A.TRecord=Qe;function He(te){return ue(te)&&te[e.Kind]==="Ref"&&I(te.$id)&&H(te.$ref)}A.TRef=He;function ct(te){return ue(te)&&te[e.Kind]==="String"&&te.type==="string"&&I(te.$id)&&M(te.minLength)&&M(te.maxLength)&&T(te.pattern)&&O(te.format)}A.TString=ct;function mt(te){return ue(te)&&te[e.Kind]==="Symbol"&&te.type==="null"&&te.typeOf==="Symbol"&&I(te.$id)}A.TSymbol=mt;function Ft(te){return ue(te)&&te[e.Kind]==="TemplateLiteral"&&te.type==="string"&&H(te.pattern)&&te.pattern[0]==="^"&&te.pattern[te.pattern.length-1]==="$"}A.TTemplateLiteral=Ft;function St(te){return ue(te)&&te[e.Kind]==="This"&&I(te.$id)&&H(te.$ref)}A.TThis=St;function En(te){if(!(ue(te)&&te[e.Kind]==="Tuple"&&te.type==="array"&&I(te.$id)&&q(te.minItems)&&q(te.maxItems)&&te.minItems===te.maxItems))return!1;if(te.items===void 0&&te.additionalItems===void 0&&te.minItems===0)return!0;if(!S(te.items))return!1;for(const ke of te.items)if(!gn(ke))return!1;return!0}A.TTuple=En;function It(te){return ue(te)&&te[e.Kind]==="Undefined"&&te.type==="null"&&te.typeOf==="Undefined"&&I(te.$id)}A.TUndefined=It;function sn(te){return fn(te)&&te.anyOf.every(ke=>We(ke)||ee(ke))}A.TUnionLiteral=sn;function fn(te){if(!(ue(te)&&te[e.Kind]==="Union"&&S(te.anyOf)&&I(te.$id)))return!1;for(const ke of te.anyOf)if(!gn(ke))return!1;return!0}A.TUnion=fn;function Kn(te){return ue(te)&&te[e.Kind]==="Uint8Array"&&te.type==="object"&&I(te.$id)&&te.instanceOf==="Uint8Array"&&M(te.minByteLength)&&M(te.maxByteLength)}A.TUint8Array=Kn;function kn(te){return ue(te)&&te[e.Kind]==="Unknown"&&I(te.$id)}A.TUnknown=kn;function Hn(te){return ue(te)&&te[e.Kind]==="Unsafe"}A.TUnsafe=Hn;function Wn(te){return ue(te)&&te[e.Kind]==="Void"&&te.type==="null"&&te.typeOf==="Void"&&I(te.$id)}A.TVoid=Wn;function On(te){return x(te)&&te[e.Modifier]==="ReadonlyOptional"}A.TReadonlyOptional=On;function An(te){return x(te)&&te[e.Modifier]==="Readonly"}A.TReadonly=An;function Gn(te){return x(te)&&te[e.Modifier]==="Optional"}A.TOptional=Gn;function gn(te){return typeof te=="object"&&(G(te)||re(te)||je(te)||me(te)||Ee(te)||ve(te)||Se(te)||ge(te)||Ie(te)||we(te)||Ne(te)||Ae(te)||Ze(te)||be(te)||De(te)||Fe(te)||Qe(te)||He(te)||ct(te)||mt(te)||Ft(te)||St(te)||En(te)||It(te)||fn(te)||Kn(te)||kn(te)||Hn(te)||Wn(te)||ue(te)&&t.Has(te[e.Kind]))}A.TSchema=gn})(o||(e.TypeGuard=o={}));var i;(function(A){function x(S){return S[e.Kind]==="Undefined"?!0:S[e.Kind]==="Not"?!x(S.not):S[e.Kind]==="Intersect"?S.allOf.every(B=>x(B)):S[e.Kind]==="Union"?S.anyOf.some(B=>x(B)):!1}A.Check=x})(i||(e.ExtendsUndefined=i={}));var a;(function(A){A[A.Union=0]="Union",A[A.True=1]="True",A[A.False=2]="False"})(a||(e.TypeExtendsResult=a={}));var s;(function(A){function x(V){return V===a.False?a.False:a.True}function S(V,_){return a.True}function D(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)&&_.anyOf.some(J=>o.TAny(J)||o.TUnknown(J))?a.True:o.TUnion(_)?a.Union:o.TUnknown(_)||o.TAny(_)?a.True:a.Union}function B(V,_){return o.TUnknown(V)?a.False:o.TAny(V)?a.Union:o.TNever(V)?a.True:a.False}function $(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)&&Qe(_)?a.True:o.TArray(_)?x(Y(V.items,_.items)):a.False}function F(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TBigInt(_)?a.True:a.False}function H(V,_){return o.TLiteral(V)&&typeof V.const=="boolean"||o.TBoolean(V)?a.True:a.False}function q(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TBoolean(_)?a.True:a.False}function U(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):!o.TConstructor(_)||V.parameters.length>_.parameters.length||!V.parameters.every((J,se)=>x(Y(_.parameters[se],J))===a.True)?a.False:x(Y(V.returns,_.returns))}function N(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TDate(_)?a.True:a.False}function M(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):!o.TFunction(_)||V.parameters.length>_.parameters.length||!V.parameters.every((J,se)=>x(Y(_.parameters[se],J))===a.True)?a.False:x(Y(V.returns,_.returns))}function L(V,_){return o.TLiteral(V)&&typeof V.const=="number"||o.TNumber(V)||o.TInteger(V)?a.True:a.False}function I(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function T(V,_){return _.allOf.every(J=>Y(V,J)===a.True)?a.True:a.False}function O(V,_){return V.allOf.some(J=>Y(J,_)===a.True)?a.True:a.False}function E(V){return typeof V.const=="string"}function G(V){return typeof V.const=="number"}function re(V){return typeof V.const=="boolean"}function me(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TString(_)?Kn(V):o.TNumber(_)?Ie(V):o.TInteger(_)?L(V):o.TBoolean(_)?H(V):o.TLiteral(_)&&_.const===V.const?a.True:a.False}function je(V,_){return a.False}function Ee(V,_){return a.True}function ve(V){let[_,J]=[V,0];for(;o.TNot(_);)_=_.not,J+=1;return J%2===0?_:e.Type.Unknown()}function Se(V,_){if(o.TNot(V))return Y(ve(V),_);if(o.TNot(_))return Y(V,ve(_));throw new Error("TypeExtends: Invalid fallthrough for Not")}function ge(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TNull(_)?a.True:a.False}function Ie(V,_){return o.TLiteral(V)&&G(V)||o.TNumber(V)||o.TInteger(V)?a.True:a.False}function ue(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TInteger(_)||o.TNumber(_)?a.True:a.False}function We(V,_){return globalThis.Object.keys(V.properties).length===_}function ee(V){return Qe(V)}function Q(V){return We(V,0)||We(V,1)&&"description"in V.properties&&o.TUnion(V.properties.description)&&V.properties.description.anyOf.length===2&&(o.TString(V.properties.description.anyOf[0])&&o.TUndefined(V.properties.description.anyOf[1])||o.TString(V.properties.description.anyOf[1])&&o.TUndefined(V.properties.description.anyOf[0]))}function we(V){return We(V,0)}function Ne(V){return We(V,0)}function Ae(V){return We(V,0)}function Ze(V){return We(V,0)}function be(V){return Qe(V)}function De(V){const _=e.Type.Number();return We(V,0)||We(V,1)&&"length"in V.properties&&x(Y(V.properties.length,_))===a.True}function Fe(V){return We(V,0)}function Qe(V){const _=e.Type.Number();return We(V,0)||We(V,1)&&"length"in V.properties&&x(Y(V.properties.length,_))===a.True}function He(V){const _=e.Type.Function([e.Type.Any()],e.Type.Any());return We(V,0)||We(V,1)&&"then"in V.properties&&x(Y(V.properties.then,_))===a.True}function ct(V,_){return Y(V,_)===a.False||o.TOptional(V)&&!o.TOptional(_)?a.False:a.True}function mt(V,_){return o.TUnknown(V)?a.False:o.TAny(V)?a.Union:o.TNever(V)||o.TLiteral(V)&&E(V)&&ee(_)||o.TLiteral(V)&&G(V)&&we(_)||o.TLiteral(V)&&re(V)&&Ne(_)||o.TSymbol(V)&&Q(_)||o.TBigInt(V)&&Ae(_)||o.TString(V)&&ee(_)||o.TSymbol(V)&&Q(_)||o.TNumber(V)&&we(_)||o.TInteger(V)&&we(_)||o.TBoolean(V)&&Ne(_)||o.TUint8Array(V)&&be(_)||o.TDate(V)&&Ze(_)||o.TConstructor(V)&&Fe(_)||o.TFunction(V)&&De(_)?a.True:o.TRecord(V)&&o.TString(En(V))?_[e.Hint]==="Record"?a.True:a.False:o.TRecord(V)&&o.TNumber(En(V))&&We(_,0)?a.True:a.False}function Ft(V,_){if(o.TIntersect(_))return T(V,_);if(o.TUnion(_))return ke(V,_);if(o.TUnknown(_))return Ct();if(o.TAny(_))return S();if(o.TRecord(_))return sn(V,_);if(!o.TObject(_))return a.False;for(const J of globalThis.Object.keys(_.properties))if(!(J in V.properties)||ct(V.properties[J],_.properties[J])===a.False)return a.False;return a.True}function St(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)&&He(_)?a.True:o.TPromise(_)?x(Y(V.item,_.item)):a.False}function En(V){if(e.PatternNumberExact in V.patternProperties)return e.Type.Number();if(e.PatternStringExact in V.patternProperties)return e.Type.String();throw Error("TypeExtends: Cannot get record key")}function It(V){if(e.PatternNumberExact in V.patternProperties)return V.patternProperties[e.PatternNumberExact];if(e.PatternStringExact in V.patternProperties)return V.patternProperties[e.PatternStringExact];throw Error("TypeExtends: Cannot get record value")}function sn(V,_){const J=En(_),se=It(_);if(o.TLiteral(V)&&E(V)&&o.TNumber(J)&&x(Y(V,se))===a.True)return a.True;if(o.TUint8Array(V)&&o.TNumber(J)||o.TString(V)&&o.TNumber(J)||o.TArray(V)&&o.TNumber(J))return Y(V,se);if(o.TObject(V)){for(const xe of globalThis.Object.keys(V.properties))if(ct(se,V.properties[xe])===a.False)return a.False;return a.True}return a.False}function fn(V,_){const J=It(V);return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?Y(J,It(_)):a.False}function Kn(V,_){return o.TLiteral(V)&&typeof V.const=="string"||o.TString(V)?a.True:a.False}function kn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TString(_)?a.True:a.False}function Hn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TSymbol(_)?a.True:a.False}function Wn(V,_){if(o.TTemplateLiteral(V))return Y(m.Resolve(V),_);if(o.TTemplateLiteral(_))return Y(V,m.Resolve(_));throw new Error("TypeExtends: Invalid fallthrough for TemplateLiteral")}function On(V,_){return o.TUnknown(V)?a.False:o.TAny(V)?a.Union:o.TNever(V)?a.True:a.False}function An(V,_){return o.TArray(_)&&V.items!==void 0&&V.items.every(J=>Y(J,_.items)===a.True)}function Gn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)&&Qe(_)||o.TArray(_)&&An(V,_)?a.True:!o.TTuple(_)||V.items===void 0&&_.items!==void 0||V.items!==void 0&&_.items===void 0?a.False:V.items===void 0&&_.items===void 0||V.items.every((J,se)=>Y(J,_.items[se])===a.True)?a.True:a.False}function gn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TUint8Array(_)?a.True:a.False}function te(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TNever(_)?je():o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TRecord(_)?sn(V,_):o.TVoid(_)?Me(V):o.TUndefined(_)?a.True:a.False}function ke(V,_){return _.anyOf.some(J=>Y(V,J)===a.True)?a.True:a.False}function dt(V,_){return V.anyOf.every(J=>Y(J,_)===a.True)?a.True:a.False}function Ct(V,_){return a.True}function cn(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TAny(_)?S():o.TString(_)?Kn(V):o.TNumber(_)?Ie(V):o.TInteger(_)?L(V):o.TBoolean(_)?H(V):o.TArray(_)?B(V):o.TTuple(_)?On(V):o.TObject(_)?mt(V,_):o.TUnknown(_)?a.True:a.False}function Me(V,_){return o.TUndefined(V)||o.TUndefined(V)?a.True:a.False}function ut(V,_){return o.TIntersect(_)?T(V,_):o.TUnion(_)?ke(V,_):o.TUnknown(_)?Ct():o.TAny(_)?S():o.TObject(_)?mt(V,_):o.TVoid(_)?a.True:a.False}function Y(V,_){if(o.TTemplateLiteral(V)||o.TTemplateLiteral(_))return Wn(V,_);if(o.TNot(V)||o.TNot(_))return Se(V,_);if(o.TAny(V))return D(V,_);if(o.TArray(V))return $(V,_);if(o.TBigInt(V))return F(V,_);if(o.TBoolean(V))return q(V,_);if(o.TConstructor(V))return U(V,_);if(o.TDate(V))return N(V,_);if(o.TFunction(V))return M(V,_);if(o.TInteger(V))return I(V,_);if(o.TIntersect(V))return O(V,_);if(o.TLiteral(V))return me(V,_);if(o.TNever(V))return Ee();if(o.TNull(V))return ge(V,_);if(o.TNumber(V))return ue(V,_);if(o.TObject(V))return Ft(V,_);if(o.TRecord(V))return fn(V,_);if(o.TString(V))return kn(V,_);if(o.TSymbol(V))return Hn(V,_);if(o.TTuple(V))return Gn(V,_);if(o.TPromise(V))return St(V,_);if(o.TUint8Array(V))return gn(V,_);if(o.TUndefined(V))return te(V,_);if(o.TUnion(V))return dt(V,_);if(o.TUnknown(V))return cn(V,_);if(o.TVoid(V))return ut(V,_);throw Error(`TypeExtends: Unknown left type operand '${V[e.Kind]}'`)}function de(V,_){return Y(V,_)}A.Extends=de})(s||(e.TypeExtends=s={}));var l;(function(A){function x(H){return typeof H=="object"&&H!==null}function S(H){return globalThis.Array.isArray(H)}function D(H){return H.map(q=>$(q))}function B(H){const q=globalThis.Object.getOwnPropertyNames(H).reduce((N,M)=>({...N,[M]:$(H[M])}),{}),U=globalThis.Object.getOwnPropertySymbols(H).reduce((N,M)=>({...N,[M]:$(H[M])}),{});return{...q,...U}}function $(H){return S(H)?D(H):x(H)?B(H):H}function F(H,q){return{...$(H),...q}}A.Clone=F})(l||(e.TypeClone=l={}));var c;(function(A){function x(I){return I.map(T=>{const{[e.Modifier]:O,...E}=l.Clone(T,{});return E})}function S(I){return I.every(T=>o.TOptional(T))}function D(I){return I.some(T=>o.TOptional(T))}function B(I){return S(I.allOf)?e.Type.Optional(e.Type.Intersect(x(I.allOf))):I}function $(I){return D(I.anyOf)?e.Type.Optional(e.Type.Union(x(I.anyOf))):I}function F(I){return I[e.Kind]==="Intersect"?B(I):I[e.Kind]==="Union"?$(I):I}function H(I,T){const O=I.allOf.reduce((E,G)=>{const re=M(G,T);return re[e.Kind]==="Never"?E:[...E,re]},[]);return F(e.Type.Intersect(O))}function q(I,T){const O=I.anyOf.map(E=>M(E,T));return F(e.Type.Union(O))}function U(I,T){const O=I.properties[T];return O===void 0?e.Type.Never():e.Type.Union([O])}function N(I,T){const O=I.items;if(O===void 0)return e.Type.Never();const E=O[T];return E===void 0?e.Type.Never():E}function M(I,T){return I[e.Kind]==="Intersect"?H(I,T):I[e.Kind]==="Union"?q(I,T):I[e.Kind]==="Object"?U(I,T):I[e.Kind]==="Tuple"?N(I,T):e.Type.Never()}function L(I,T,O={}){const E=T.map(G=>M(I,G.toString()));return F(e.Type.Union(E,O))}A.Resolve=L})(c||(e.IndexedAccessor=c={}));var f;(function(A){function x(F,H){return e.Type.Intersect(F.allOf.map(q=>B(q,H)),{...F})}function S(F,H){return e.Type.Union(F.anyOf.map(q=>B(q,H)),{...F})}function D(F,H){return H(F)}function B(F,H){return F[e.Kind]==="Intersect"?x(F,H):F[e.Kind]==="Union"?S(F,H):F[e.Kind]==="Object"?D(F,H):F}function $(F,H,q){return{...B(l.Clone(F,{}),H),...q}}A.Map=$})(f||(e.ObjectMap=f={}));var u;(function(A){function x(U){return U[0]==="^"&&U[U.length-1]==="$"?U.slice(1,U.length-1):U}function S(U,N){return U.allOf.reduce((M,L)=>[...M,...F(L,N)],[])}function D(U,N){const M=U.anyOf.map(L=>F(L,N));return[...M.reduce((L,I)=>I.map(T=>M.every(O=>O.includes(T))?L.add(T):L)[0],new Set)]}function B(U,N){return globalThis.Object.keys(U.properties)}function $(U,N){return N.includePatterns?globalThis.Object.keys(U.patternProperties):[]}function F(U,N){return o.TIntersect(U)?S(U,N):o.TUnion(U)?D(U,N):o.TObject(U)?B(U):o.TRecord(U)?$(U,N):[]}function H(U,N){return[...new Set(F(U,N))]}A.ResolveKeys=H;function q(U){return`^(${H(U,{includePatterns:!0}).map(L=>`(${x(L)})`).join("|")})$`}A.ResolvePattern=q})(u||(e.KeyResolver=u={}));var d;(function(A){function x(S){if(globalThis.Array.isArray(S))return S;if(o.TUnionLiteral(S))return S.anyOf.map(D=>D.const.toString());if(o.TLiteral(S))return[S.const];if(o.TTemplateLiteral(S)){const D=g.ParseExact(S.pattern);if(!y.Check(D))throw Error("KeyArrayResolver: Cannot resolve keys from infinite template expression");return[...w.Generate(D)]}return[]}A.Resolve=x})(d||(e.KeyArrayResolver=d={}));var h;(function(A){function*x(D){for(const B of D.anyOf)B[e.Kind]==="Union"?yield*x(B):yield B}function S(D){return e.Type.Union([...x(D)],{...D})}A.Resolve=S})(h||(e.UnionResolver=h={}));var p;(function(A){function x(B){return B.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function S(B,$){if(o.TTemplateLiteral(B))return B.pattern.slice(1,B.pattern.length-1);if(o.TUnion(B))return`(${B.anyOf.map(H=>S(H,$)).join("|")})`;if(o.TNumber(B))return`${$}${e.PatternNumber}`;if(o.TInteger(B))return`${$}${e.PatternNumber}`;if(o.TBigInt(B))return`${$}${e.PatternNumber}`;if(o.TString(B))return`${$}${e.PatternString}`;if(o.TLiteral(B))return`${$}${x(B.const.toString())}`;if(o.TBoolean(B))return`${$}${e.PatternBoolean}`;throw o.TNever(B)?Error("TemplateLiteralPattern: TemplateLiteral cannot operate on types of TNever"):Error(`TemplateLiteralPattern: Unexpected Kind '${B[e.Kind]}'`)}function D(B){return`^${B.map($=>S($,"")).join("")}$`}A.Create=D})(p||(e.TemplateLiteralPattern=p={}));var m;(function(A){function x(S){const D=g.ParseExact(S.pattern);if(!y.Check(D))return e.Type.String();const B=[...w.Generate(D)].map($=>e.Type.Literal($));return e.Type.Union(B)}A.Resolve=x})(m||(e.TemplateLiteralResolver=m={}));class v extends Error{constructor(x){super(x)}}e.TemplateLiteralParserError=v;var g;(function(A){function x(I,T,O){return I[T]===O&&I.charCodeAt(T-1)!==92}function S(I,T){return x(I,T,"(")}function D(I,T){return x(I,T,")")}function B(I,T){return x(I,T,"|")}function $(I){if(!(S(I,0)&&D(I,I.length-1)))return!1;let T=0;for(let O=0;O<I.length;O++)if(S(I,O)&&(T+=1),D(I,O)&&(T-=1),T===0&&O!==I.length-1)return!1;return!0}function F(I){return I.slice(1,I.length-1)}function H(I){let T=0;for(let O=0;O<I.length;O++)if(S(I,O)&&(T+=1),D(I,O)&&(T-=1),B(I,O)&&T===0)return!0;return!1}function q(I){for(let T=0;T<I.length;T++)if(S(I,T))return!0;return!1}function U(I){let[T,O]=[0,0];const E=[];for(let re=0;re<I.length;re++)if(S(I,re)&&(T+=1),D(I,re)&&(T-=1),B(I,re)&&T===0){const me=I.slice(O,re);me.length>0&&E.push(M(me)),O=re+1}const G=I.slice(O);return G.length>0&&E.push(M(G)),E.length===0?{type:"const",const:""}:E.length===1?E[0]:{type:"or",expr:E}}function N(I){function T(G,re){if(!S(G,re))throw new v("TemplateLiteralParser: Index must point to open parens");let me=0;for(let je=re;je<G.length;je++)if(S(G,je)&&(me+=1),D(G,je)&&(me-=1),me===0)return[re,je];throw new v("TemplateLiteralParser: Unclosed group parens in expression")}function O(G,re){for(let me=re;me<G.length;me++)if(S(G,me))return[re,me];return[re,G.length]}const E=[];for(let G=0;G<I.length;G++)if(S(I,G)){const[re,me]=T(I,G),je=I.slice(re,me+1);E.push(M(je)),G=me}else{const[re,me]=O(I,G),je=I.slice(re,me);je.length>0&&E.push(M(je)),G=me-1}return E.length===0?{type:"const",const:""}:E.length===1?E[0]:{type:"and",expr:E}}function M(I){return $(I)?M(F(I)):H(I)?U(I):q(I)?N(I):{type:"const",const:I}}A.Parse=M;function L(I){return M(I.slice(1,I.length-1))}A.ParseExact=L})(g||(e.TemplateLiteralParser=g={}));var y;(function(A){function x($){return $.type==="or"&&$.expr.length===2&&$.expr[0].type==="const"&&$.expr[0].const==="0"&&$.expr[1].type==="const"&&$.expr[1].const==="[1-9][0-9]*"}function S($){return $.type==="or"&&$.expr.length===2&&$.expr[0].type==="const"&&$.expr[0].const==="true"&&$.expr[1].type==="const"&&$.expr[1].const==="false"}function D($){return $.type==="const"&&$.const===".*"}function B($){if(S($))return!0;if(x($)||D($))return!1;if($.type==="and")return $.expr.every(F=>B(F));if($.type==="or")return $.expr.every(F=>B(F));if($.type==="const")return!0;throw Error("TemplateLiteralFinite: Unknown expression type")}A.Check=B})(y||(e.TemplateLiteralFinite=y={}));var w;(function(A){function*x(F){if(F.length===1)return yield*F[0];for(const H of F[0])for(const q of x(F.slice(1)))yield`${H}${q}`}function*S(F){return yield*x(F.expr.map(H=>[...$(H)]))}function*D(F){for(const H of F.expr)yield*$(H)}function*B(F){return yield F.const}function*$(F){if(F.type==="and")return yield*S(F);if(F.type==="or")return yield*D(F);if(F.type==="const")return yield*B(F);throw Error("TemplateLiteralGenerator: Unknown expression")}A.Generate=$})(w||(e.TemplateLiteralGenerator=w={}));var k;(function(A){function*x($){const F=$.trim().replace(/"|'/g,"");if(F==="boolean")return yield e.Type.Boolean();if(F==="number")return yield e.Type.Number();if(F==="bigint")return yield e.Type.BigInt();if(F==="string")return yield e.Type.String();const H=F.split("|").map(q=>e.Type.Literal(q.trim()));return yield H.length===0?e.Type.Never():H.length===1?H[0]:e.Type.Union(H)}function*S($){if($[1]!=="{"){const F=e.Type.Literal("$"),H=D($.slice(1));return yield*[F,...H]}for(let F=2;F<$.length;F++)if($[F]==="}"){const H=x($.slice(2,F)),q=D($.slice(F+1));return yield*[...H,...q]}yield e.Type.Literal($)}function*D($){for(let F=0;F<$.length;F++)if($[F]==="$"){const H=e.Type.Literal($.slice(0,F)),q=S($.slice(F));return yield*[H,...q]}yield e.Type.Literal($)}function B($){return[...D($)]}A.Parse=B})(k||(e.TemplateLiteralDslParser=k={}));let C=0;class j{Create(x){return x}Strict(x){return JSON.parse(JSON.stringify(x))}}e.TypeBuilder=j;class P extends j{Optional(x){return{[e.Modifier]:"Optional",...l.Clone(x,{})}}ReadonlyOptional(x){return{[e.Modifier]:"ReadonlyOptional",...l.Clone(x,{})}}Readonly(x){return{[e.Modifier]:"Readonly",...x}}Any(x={}){return this.Create({...x,[e.Kind]:"Any"})}Array(x,S={}){return this.Create({...S,[e.Kind]:"Array",type:"array",items:l.Clone(x,{})})}Boolean(x={}){return this.Create({...x,[e.Kind]:"Boolean",type:"boolean"})}Composite(x,S){const D=e.Type.Intersect(x,{}),$=u.ResolveKeys(D,{includePatterns:!1}).reduce((F,H)=>({...F,[H]:e.Type.Index(D,[H])}),{});return e.Type.Object($,S)}Enum(x,S={}){const B=globalThis.Object.keys(x).filter($=>isNaN($)).map($=>x[$]).map($=>typeof $=="string"?{[e.Kind]:"Literal",type:"string",const:$}:{[e.Kind]:"Literal",type:"number",const:$});return this.Create({...S,[e.Kind]:"Union",anyOf:B})}Extends(x,S,D,B,$={}){switch(s.Extends(x,S)){case a.Union:return this.Union([l.Clone(D,$),l.Clone(B,$)]);case a.True:return l.Clone(D,$);case a.False:return l.Clone(B,$)}}Exclude(x,S,D={}){if(o.TTemplateLiteral(x))return this.Exclude(m.Resolve(x),S,D);if(o.TTemplateLiteral(S))return this.Exclude(x,m.Resolve(S),D);if(o.TUnion(x)){const B=x.anyOf.filter($=>s.Extends($,S)===a.False);return B.length===1?l.Clone(B[0],D):this.Union(B,D)}else return s.Extends(x,S)!==a.False?this.Never(D):l.Clone(x,D)}Extract(x,S,D={}){if(o.TTemplateLiteral(x))return this.Extract(m.Resolve(x),S,D);if(o.TTemplateLiteral(S))return this.Extract(x,m.Resolve(S),D);if(o.TUnion(x)){const B=x.anyOf.filter($=>s.Extends($,S)!==a.False);return B.length===1?l.Clone(B[0],D):this.Union(B,D)}else return s.Extends(x,S)!==a.False?l.Clone(x,D):this.Never(D)}Index(x,S,D={}){if(o.TArray(x)&&o.TNumber(S))return l.Clone(x.items,D);if(o.TTuple(x)&&o.TNumber(S)){const $=(x.items===void 0?[]:x.items).map(F=>l.Clone(F,{}));return this.Union($,D)}else{const B=d.Resolve(S),$=l.Clone(x,{});return c.Resolve($,B,D)}}Integer(x={}){return this.Create({...x,[e.Kind]:"Integer",type:"integer"})}Intersect(x,S={}){if(x.length===0)return e.Type.Never();if(x.length===1)return l.Clone(x[0],S);const D=x.every(F=>o.TObject(F)),B=x.map(F=>l.Clone(F,{})),$=o.TSchema(S.unevaluatedProperties)?{unevaluatedProperties:l.Clone(S.unevaluatedProperties,{})}:{};return S.unevaluatedProperties===!1||o.TSchema(S.unevaluatedProperties)||D?this.Create({...S,...$,[e.Kind]:"Intersect",type:"object",allOf:B}):this.Create({...S,...$,[e.Kind]:"Intersect",allOf:B})}KeyOf(x,S={}){if(o.TRecord(x)){const D=Object.getOwnPropertyNames(x.patternProperties)[0];if(D===e.PatternNumberExact)return this.Number(S);if(D===e.PatternStringExact)return this.String(S);throw Error("StandardTypeBuilder: Unable to resolve key type from Record key pattern")}else if(o.TTuple(x)){const B=(x.items===void 0?[]:x.items).map(($,F)=>e.Type.Literal(F));return this.Union(B,S)}else{if(o.TArray(x))return this.Number(S);{const D=u.ResolveKeys(x,{includePatterns:!1});if(D.length===0)return this.Never(S);const B=D.map($=>this.Literal($));return this.Union(B,S)}}}Literal(x,S={}){return this.Create({...S,[e.Kind]:"Literal",const:x,type:typeof x})}Never(x={}){return this.Create({...x,[e.Kind]:"Never",not:{}})}Not(x,S){return this.Create({...S,[e.Kind]:"Not",not:x})}Null(x={}){return this.Create({...x,[e.Kind]:"Null",type:"null"})}Number(x={}){return this.Create({...x,[e.Kind]:"Number",type:"number"})}Object(x,S={}){const D=globalThis.Object.getOwnPropertyNames(x),B=D.filter(q=>o.TOptional(x[q])||o.TReadonlyOptional(x[q])),$=D.filter(q=>!B.includes(q)),F=o.TSchema(S.additionalProperties)?{additionalProperties:l.Clone(S.additionalProperties,{})}:{},H=D.reduce((q,U)=>({...q,[U]:l.Clone(x[U],{})}),{});return $.length>0?this.Create({...S,...F,[e.Kind]:"Object",type:"object",properties:H,required:$}):this.Create({...S,...F,[e.Kind]:"Object",type:"object",properties:H})}Omit(x,S,D={}){const B=d.Resolve(S);return f.Map(l.Clone(x,{}),$=>{$.required&&($.required=$.required.filter(F=>!B.includes(F)),$.required.length===0&&delete $.required);for(const F of globalThis.Object.keys($.properties))B.includes(F)&&delete $.properties[F];return this.Create($)},D)}Partial(x,S={}){function D(B){switch(B[e.Modifier]){case"ReadonlyOptional":B[e.Modifier]="ReadonlyOptional";break;case"Readonly":B[e.Modifier]="ReadonlyOptional";break;case"Optional":B[e.Modifier]="Optional";break;default:B[e.Modifier]="Optional";break}}return f.Map(l.Clone(x,{}),B=>(delete B.required,globalThis.Object.keys(B.properties).forEach($=>D(B.properties[$])),B),S)}Pick(x,S,D={}){const B=d.Resolve(S);return f.Map(l.Clone(x,{}),$=>{$.required&&($.required=$.required.filter(F=>B.includes(F)),$.required.length===0&&delete $.required);for(const F of globalThis.Object.keys($.properties))B.includes(F)||delete $.properties[F];return this.Create($)},D)}Record(x,S,D={}){if(o.TTemplateLiteral(x)){const B=g.ParseExact(x.pattern);return y.Check(B)?this.Object([...w.Generate(B)].reduce(($,F)=>({...$,[F]:l.Clone(S,{})}),{}),D):this.Create({...D,[e.Kind]:"Record",type:"object",patternProperties:{[x.pattern]:l.Clone(S,{})}})}else if(o.TUnion(x)){const B=h.Resolve(x);if(o.TUnionLiteral(B)){const $=B.anyOf.reduce((F,H)=>({...F,[H.const]:l.Clone(S,{})}),{});return this.Object($,{...D,[e.Hint]:"Record"})}else throw Error("TypeBuilder: Record key of type union contains non-literal types")}else if(o.TLiteral(x)){if(typeof x.const=="string"||typeof x.const=="number")return this.Object({[x.const]:l.Clone(S,{})},D);throw Error("TypeBuilder: Record key of type literal is not of type string or number")}else if(o.TInteger(x)||o.TNumber(x)){const B=e.PatternNumberExact;return this.Create({...D,[e.Kind]:"Record",type:"object",patternProperties:{[B]:l.Clone(S,{})}})}else if(o.TString(x)){const B=x.pattern===void 0?e.PatternStringExact:x.pattern;return this.Create({...D,[e.Kind]:"Record",type:"object",patternProperties:{[B]:l.Clone(S,{})}})}else throw Error("StandardTypeBuilder: Record key is an invalid type")}Recursive(x,S={}){S.$id===void 0&&(S.$id=`T${C++}`);const D=x({[e.Kind]:"This",$ref:`${S.$id}`});return D.$id=S.$id,this.Create({...S,[e.Hint]:"Recursive",...D})}Ref(x,S={}){if(x.$id===void 0)throw Error("StandardTypeBuilder.Ref: Target type must specify an $id");return this.Create({...S,[e.Kind]:"Ref",$ref:x.$id})}Required(x,S={}){function D(B){switch(B[e.Modifier]){case"ReadonlyOptional":B[e.Modifier]="Readonly";break;case"Readonly":B[e.Modifier]="Readonly";break;case"Optional":delete B[e.Modifier];break;default:delete B[e.Modifier];break}}return f.Map(l.Clone(x,{}),B=>(B.required=globalThis.Object.keys(B.properties),globalThis.Object.keys(B.properties).forEach($=>D(B.properties[$])),B),S)}Rest(x){return o.TTuple(x)?x.items===void 0?[]:x.items.map(S=>l.Clone(S,{})):[l.Clone(x,{})]}String(x={}){return this.Create({...x,[e.Kind]:"String",type:"string"})}TemplateLiteral(x,S={}){const D=typeof x=="string"?p.Create(k.Parse(x)):p.Create(x);return this.Create({...S,[e.Kind]:"TemplateLiteral",type:"string",pattern:D})}Tuple(x,S={}){const[D,B,$]=[!1,x.length,x.length],F=x.map(q=>l.Clone(q,{})),H=x.length>0?{...S,[e.Kind]:"Tuple",type:"array",items:F,additionalItems:D,minItems:B,maxItems:$}:{...S,[e.Kind]:"Tuple",type:"array",minItems:B,maxItems:$};return this.Create(H)}Union(x,S={}){if(o.TTemplateLiteral(x))return m.Resolve(x);{const D=x;if(D.length===0)return this.Never(S);if(D.length===1)return this.Create(l.Clone(D[0],S));const B=D.map($=>l.Clone($,{}));return this.Create({...S,[e.Kind]:"Union",anyOf:B})}}Unknown(x={}){return this.Create({...x,[e.Kind]:"Unknown"})}Unsafe(x={}){return this.Create({...x,[e.Kind]:x[e.Kind]||"Unsafe"})}}e.StandardTypeBuilder=P;class R extends P{BigInt(x={}){return this.Create({...x,[e.Kind]:"BigInt",type:"null",typeOf:"BigInt"})}ConstructorParameters(x,S={}){return this.Tuple([...x.parameters],{...S})}Constructor(x,S,D){const B=l.Clone(S,{}),$=x.map(F=>l.Clone(F,{}));return this.Create({...D,[e.Kind]:"Constructor",type:"object",instanceOf:"Constructor",parameters:$,returns:B})}Date(x={}){return this.Create({...x,[e.Kind]:"Date",type:"object",instanceOf:"Date"})}Function(x,S,D){const B=l.Clone(S,{}),$=x.map(F=>l.Clone(F,{}));return this.Create({...D,[e.Kind]:"Function",type:"object",instanceOf:"Function",parameters:$,returns:B})}InstanceType(x,S={}){return l.Clone(x.returns,S)}Parameters(x,S={}){return this.Tuple(x.parameters,{...S})}Promise(x,S={}){return this.Create({...S,[e.Kind]:"Promise",type:"object",instanceOf:"Promise",item:l.Clone(x,{})})}RegEx(x,S={}){return this.Create({...S,[e.Kind]:"String",type:"string",pattern:x.source})}ReturnType(x,S={}){return l.Clone(x.returns,S)}Symbol(x){return this.Create({...x,[e.Kind]:"Symbol",type:"null",typeOf:"Symbol"})}Undefined(x={}){return this.Create({...x,[e.Kind]:"Undefined",type:"null",typeOf:"Undefined"})}Uint8Array(x={}){return this.Create({...x,[e.Kind]:"Uint8Array",type:"object",instanceOf:"Uint8Array"})}Void(x={}){return this.Create({...x,[e.Kind]:"Void",type:"null",typeOf:"Void"})}}e.ExtendedTypeBuilder=R,e.StandardType=new P,e.Type=new R})(K);const Jpe=K.Type.Object({src:K.Type.String(),path:K.Type.Optional(K.Type.String()),volume:K.Type.Optional(K.Type.Number()),rate:K.Type.Optional(K.Type.Number()),html5:K.Type.Optional(K.Type.Boolean()),fadeInTime:K.Type.Optional(K.Type.Number()),fadeInDelay:K.Type.Optional(K.Type.Number()),fadeOutTime:K.Type.Optional(K.Type.Number()),loop:K.Type.Optional(K.Type.Boolean())}),Qpe=K.Type.Record(K.Type.String(),Jpe),Ype=K.Type.Object({volume:K.Type.Optional(K.Type.Number()),defaultMusic:K.Type.Optional(K.Type.String()),musicFadeInTime:K.Type.Optional(K.Type.Number()),musicFadeOutTime:K.Type.Optional(K.Type.Number()),musicFadeInDelay:K.Type.Optional(K.Type.Number())}),Xpe=K.Type.Record(K.Type.String(),K.Type.String()),g9=K.Type.Object({files:Qpe,audioTriggers:Xpe,options:Ype}),y9={files:{},audioTriggers:{},options:{volume:1,musicFadeInTime:.5,musicFadeInDelay:.5,musicFadeOutTime:.5}},Zpe=K.Type.Object({name:K.Type.String(),description:K.Type.String(),icon:K.Type.String(),onUse:K.Type.Optional(K.Type.Object({action:K.Type.String(),label:K.Type.String()})),tag:K.Type.Optional(K.Type.String()),category:K.Type.Optional(K.Type.String()),showIfEmpty:K.Type.Optional(K.Type.Boolean())}),b9=K.Type.Object({id:K.Type.String(),title:K.Type.String()}),w9=K.Type.Record(K.Type.String(),Zpe);K.Type.Object({categories:K.Type.Array(b9),items:w9});const k9=K.Type.Object({categories:K.Type.Optional(K.Type.Array(b9)),items:K.Type.Optional(w9)}),x9={categories:[{id:"default",title:"Items"}],items:{}},eme=K.Type.Object({description:K.Type.String(),hidden:K.Type.Optional(K.Type.Boolean())}),tme=K.Type.Object({title:K.Type.String(),description:K.Type.String(),objectives:K.Type.Record(K.Type.String(),eme),category:K.Type.Optional(K.Type.String())}),nme=K.Type.Object({id:K.Type.String(),title:K.Type.String()}),rme=K.Type.Record(K.Type.String(),tme),_9=K.Type.Object({quests:rme,categories:K.Type.Array(nme)}),j9={quests:{},categories:[{id:"default",title:"Quests"}]},S9=K.Type.Object({enabled:K.Type.Boolean(),background:K.Type.Optional(K.Type.String()),text:K.Type.Optional(K.Type.String()),cssClass:K.Type.Optional(K.Type.String()),position:K.Type.Object({left:K.Type.Number(),top:K.Type.Number(),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())}),anchor:K.Type.Optional(K.Type.Object({x:K.Type.Number(),y:K.Type.Number()})),action:K.Type.Optional(K.Type.String()),actionType:K.Type.Optional(K.Type.String()),scriptClickable:K.Type.Optional(K.Type.Boolean()),tag:K.Type.Optional(K.Type.String())}),ome=K.Type.Record(K.Type.String(),S9),C9=K.Type.Object({buttons:ome,clickableDuringScriptsByDefault:K.Type.Optional(K.Type.Boolean())}),$9={buttons:{},clickableDuringScriptsByDefault:!1},ime=K.Type.Intersect([S9,K.Type.Object({id:K.Type.String()})]),ame=K.Type.Object({muted:K.Type.Optional(K.Type.Boolean()),loop:K.Type.Optional(K.Type.Boolean())}),sme=K.Type.Object({background:K.Type.String(),video:K.Type.Optional(ame),buttons:K.Type.Optional(K.Type.Array(K.Type.Union([K.Type.String(),ime])))}),T9=K.Type.Record(K.Type.String(),sme);K.Type.Object({screens:T9});const E9=K.Type.Object({screens:K.Type.Optional(T9)}),O9={screens:{}},lme=K.Type.Object({name:K.Type.String(),description:K.Type.String(),startingLevel:K.Type.Number(),hidden:K.Type.Optional(K.Type.Boolean()),icon:K.Type.String()}),A9=K.Type.Record(K.Type.String(),lme),M9=K.Type.Object({xpPerLevel:K.Type.Number(),notifyLevelUp:K.Type.Boolean()});K.Type.Object({skills:A9,skillOptions:M9});const P9=K.Type.Object({skills:K.Type.Optional(A9),skillOptions:K.Type.Optional(M9)}),N9={skills:{},skillOptions:{xpPerLevel:10,notifyLevelUp:!0}},Xg="###_--_~=:;_JUMP",o_="###_--_~=:;_RETURN",cme="###_--_~=:;_OK",Zg="###_--_~=:;_STOP";function ume(e){return e===Xg||e===o_||e===cme||e===Zg}const fme="3.3.7",dme=new Date("2023-10-08T10:12:54.068Z"),hme=400,e0=20,i_="@empty",I9={background:i_},pme=K.Type.Object({color:K.Type.Optional(K.Type.String()),boxCss:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.Any())),nameCss:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.Any())),textCss:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.Any()))}),mme=K.Type.Object({video:K.Type.String(),autoplay:K.Type.Optional(K.Type.Boolean()),loop:K.Type.Optional(K.Type.Boolean()),muted:K.Type.Optional(K.Type.Boolean()),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())}),vme=K.Type.Object({image:K.Type.String(),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())}),gme=K.Type.Union([K.Type.String(),mme,vme]),yme=K.Type.Object({sprites:K.Type.Optional(K.Type.Record(K.Type.String(),gme)),name:K.Type.String(),style:K.Type.Optional(pme)}),D9=K.Type.Object({config:K.Type.Object({imagesPath:K.Type.String(),playerCharacter:K.Type.Optional(K.Type.String()),gameCharacter:K.Type.Optional(K.Type.String())}),characters:K.Type.Record(K.Type.String(),yme)}),L9={config:{imagesPath:"",playerCharacter:"player",gameCharacter:"game"},characters:{}},bme=K.Type.Object({backgrounds:K.Type.Object({width:K.Type.Number(),height:K.Type.Number()}),dialogBottomPadding:K.Type.Union([K.Type.Number(),K.Type.String()]),minTextWidth:K.Type.Optional(K.Type.Number()),verticalLayoutThreshold:K.Type.Number(),defaultFontSize:K.Type.Optional(K.Type.Number()),portraits:K.Type.Object({width:K.Type.Number(),height:K.Type.Number(),offset:K.Type.Optional(K.Type.Object({landscape:K.Type.Optional(K.Type.Object({right:K.Type.Number(),bottom:K.Type.Number()})),portrait:K.Type.Optional(K.Type.Object({right:K.Type.Number(),bottom:K.Type.Number()}))}))})}),wme={backgrounds:{width:880,height:720},dialogBottomPadding:70,verticalLayoutThreshold:600,defaultFontSize:16,portraits:{width:100,height:100}},R9=K.Type.Object({options:K.Type.Object({delay:K.Type.Optional(K.Type.Number()),width:K.Type.Number(),keywordsPrefix:K.Type.String(),screenEdgesMinimumMargin:K.Type.Optional(K.Type.Number())}),tooltips:K.Type.Array(K.Type.Object({keywords:K.Type.Array(K.Type.String()),title:K.Type.String(),description:K.Type.String()}))}),B9={options:{delay:0,width:350,keywordsPrefix:"@@"},tooltips:[]},kme=K.Type.Object({name:K.Type.String(),description:K.Type.String(),icon:K.Type.String(),secret:K.Type.Optional(K.Type.Boolean()),category:K.Type.Optional(K.Type.String())}),F9=K.Type.Object({id:K.Type.String(),title:K.Type.String()}),V9=K.Type.Record(K.Type.String(),kme);K.Type.Object({defaultAchievementIcon:K.Type.String(),categories:K.Type.Array(F9),achievements:V9,notifyNewAchievements:K.Type.Boolean(),secretAchievements:K.Type.Optional(K.Type.Object({censorDescription:K.Type.Optional(K.Type.Boolean()),censorName:K.Type.Optional(K.Type.Boolean()),hideUntilObtained:K.Type.Optional(K.Type.Boolean())}))});const xme=K.Type.Object({categories:K.Type.Optional(K.Type.Array(F9)),achievements:K.Type.Optional(V9)}),z9={categories:[{id:"default",title:"Achievements"}],achievements:{},notifyNewAchievements:!0,defaultAchievementIcon:"img/achievements/trophy.png"},_me=K.Type.Object({diceRange:K.Type.Tuple([K.Type.Number(),K.Type.Number()]),diceCount:K.Type.Number(),difficultyText:K.Type.Array(K.Type.Tuple([K.Type.Number(),K.Type.String()])),extraPointsPerLevel:K.Type.Number(),extraDicePerLevel:K.Type.Optional(K.Type.Number()),successOnRollsBelowThreshold:K.Type.Boolean(),showDifficultyText:K.Type.Boolean(),showDifficultyNumber:K.Type.Boolean(),showDifficultyWithoutModifiers:K.Type.Boolean(),finalRollIsHighest:K.Type.Optional(K.Type.Boolean()),finalRollIsLowest:K.Type.Optional(K.Type.Boolean()),failOnRollsEqualToThreshold:K.Type.Optional(K.Type.Boolean())}),jme=K.Type.Object({skill:K.Type.String(),difficulty:K.Type.Number(),winsNeeded:K.Type.Optional(K.Type.Number()),hideAfterRoll:K.Type.Optional(K.Type.Boolean()),repeatable:K.Type.Optional(K.Type.Boolean())}),q9=K.Type.Object({options:_me,skillChecks:K.Type.Record(K.Type.String(),jme)}),U9={options:{diceRange:[1,6],extraPointsPerLevel:1,extraDicePerLevel:0,diceCount:2,successOnRollsBelowThreshold:!1,showDifficultyText:!0,showDifficultyNumber:!1,showDifficultyWithoutModifiers:!1,finalRollIsHighest:!1,finalRollIsLowest:!1,difficultyText:[[2,"Very Easy"],[4,"Easy"],[6,"Medium"],[8,"Hard"],[10,"Very Hard"],[11,"Extremely Hard"],[12,"Near Impossible"]]},skillChecks:{}},iu={baseAssetsPath:"",baseDataPath:"",gameTitle:"Narrat Game",saveFileName:"narrat save",images:{},layout:wme,settings:{},gameFlow:{},dialogPanel:{overlayMode:!0,rightOffset:100,bottomOffset:50,width:475,height:680,textSpeed:e0,animateText:!0,timeBetweenLines:100},splashScreens:{},screens:O9,buttons:$9,skills:N9,skillChecks:U9,scripts:[],audio:y9,notifications:{timeOnScreen:2.5,alsoPrintInDialogue:!1},tooltips:B9,hudStats:{},achievements:z9,items:x9,interactionTags:{default:{onlyInteractOutsideOfScripts:!0}},quests:j9,transitions:{},menuButtons:{},debugging:{showScriptFinishedMessage:!1},saves:{mode:"manual",slots:10},characters:L9};var Sme=function(t){return Cme(t)&&!$me(t)};function Cme(e){return!!e&&typeof e=="object"}function $me(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||Ome(e)}var Tme=typeof Symbol=="function"&&Symbol.for,Eme=Tme?Symbol.for("react.element"):60103;function Ome(e){return e.$$typeof===Eme}function Ame(e){return Array.isArray(e)?[]:{}}function Xh(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Ff(Ame(e),e,t):e}function Mme(e,t,n){return e.concat(t).map(function(r){return Xh(r,n)})}function Pme(e,t){if(!t.customMerge)return Ff;var n=t.customMerge(e);return typeof n=="function"?n:Ff}function Nme(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function H9(e){return Object.keys(e).concat(Nme(e))}function W9(e,t){try{return t in e}catch{return!1}}function Ime(e,t){return W9(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function Dme(e,t,n){var r={};return n.isMergeableObject(e)&&H9(e).forEach(function(o){r[o]=Xh(e[o],n)}),H9(t).forEach(function(o){Ime(e,o)||(W9(e,o)&&n.isMergeableObject(t[o])?r[o]=Pme(o,n)(e[o],t[o],n):r[o]=Xh(t[o],n))}),r}function Ff(e,t,n){n=n||{},n.arrayMerge=n.arrayMerge||Mme,n.isMergeableObject=n.isMergeableObject||Sme,n.cloneUnlessOtherwiseSpecified=Xh;var r=Array.isArray(t),o=Array.isArray(e),i=r===o;return i?r?n.arrayMerge(e,t,n):Dme(e,t,n):Xh(t,n)}Ff.all=function(t,n){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(r,o){return Ff(r,o,n)},{})};var Lme=Ff,Rme=Lme;const Zh=V2(Rme),ni=co("config",{state:()=>({config:iu}),actions:{async setConfig(e){this.config=e},extendConfig(e){this.config=Zh(this.config,e)},generateSaveData(){return{playerCharacter:this.playerCharacter,gameCharacter:this.gameCharacter}},loadSaveData(e){this.config.characters.config.playerCharacter=e.playerCharacter,this.config.characters.config.gameCharacter=e.gameCharacter}},getters:{playerCharacter(){return this.config.characters.config.playerCharacter??"player"},gameCharacter(){return this.config.characters.config.gameCharacter??"game"}}});function K9(e){const t=Cr(),n=t.getSkillCheck(e.id);if(n&&n.happened&&(n.succeeded||!e.repeatable))return n;const r=Gpe(e);return Q9(Upe(r,e)),r?t.passSkillCheck(e.id,e.hideAfterRoll):t.failSkillCheck(e.id,e.hideAfterRoll),t.getSkillCheck(e.id)}function Bme(e,t=[]){const n=e.options,r=e.staticOptions,o=!!n.condition;if(o)return r.success;if(!o){for(const[i,a]of r.elseifs.entries())if(t[i]===!0)return a.branch}if(!o&&r.failure)return r.failure}function G9(e){return typeof e=="object"}function J9(e){return typeof e=="string"&&e.search(/\$/)===0}function Q9(e){const t={speaker:ni().gameCharacter,text:e,interactive:!1};Yn().addDialog(t)}async function a_(e){Yn().addDialog(e)}function Fme(e,t){if(t<e.length)return e[t]}/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */function Y9(e){return typeof e>"u"||e===null}function Vme(e){return typeof e=="object"&&e!==null}function zme(e){return Array.isArray(e)?e:Y9(e)?[]:[e]}function qme(e,t){var n,r,o,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)o=i[n],e[o]=t[o];return e}function Ume(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function Hme(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Wme=Y9,Kme=Vme,Gme=zme,Jme=Ume,Qme=Hme,Yme=qme,uo={isNothing:Wme,isObject:Kme,toArray:Gme,repeat:Jme,isNegativeZero:Qme,extend:Yme};function X9(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
|
|
176
176
|
|
|
177
177
|
`+e.mark.snippet),r+" "+n):r}function ep(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=X9(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}ep.prototype=Object.create(Error.prototype),ep.prototype.constructor=ep,ep.prototype.toString=function(t){return this.name+": "+X9(this,t)};var ri=ep;function s_(e,t,n,r,o){var i="",a="",s=Math.floor(o/2)-1;return r-t>s&&(i=" ... ",t=r-s+i.length),n-r>s&&(a=" ...",n=r+s-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function l_(e,t){return uo.repeat(" ",t-e.length)+e}function Xme(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],o=[],i,a=-1;i=n.exec(e.buffer);)o.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var s="",l,c,f=Math.min(e.line+t.linesAfter,o.length).toString().length,u=t.maxLength-(t.indent+f+3);for(l=1;l<=t.linesBefore&&!(a-l<0);l++)c=s_(e.buffer,r[a-l],o[a-l],e.position-(r[a]-r[a-l]),u),s=uo.repeat(" ",t.indent)+l_((e.line-l+1).toString(),f)+" | "+c.str+`
|
|
178
178
|
`+s;for(c=s_(e.buffer,r[a],o[a],e.position,u),s+=uo.repeat(" ",t.indent)+l_((e.line+1).toString(),f)+" | "+c.str+`
|
|
@@ -203,10 +203,10 @@ This will fail in production.`);s=Wh,s._s.has(r)||(i?Zx(r,t,o,s):o9(r,o,s),proce
|
|
|
203
203
|
`+e.slice(o,i),o=i+1),a=s;return l+=`
|
|
204
204
|
`,e.length-o>t&&a>o?l+=e.slice(o,a)+`
|
|
205
205
|
`+e.slice(a+1):l+=e.slice(o),l.slice(1)}function Rge(e){for(var t="",n=0,r,o=0;o<e.length;n>=65536?o+=2:o++)n=op(e,o),r=Uo[n],!r&&rp(n)?(t+=e[o],n>=65536&&(t+=e[o+1])):t+=r||Ege(n);return t}function Bge(e,t,n){var r="",o=e.tag,i,a,s;for(i=0,a=n.length;i<a;i+=1)s=n[i],e.replacer&&(s=e.replacer.call(n,String(i),s)),(sl(e,t,s,!1,!1)||typeof s>"u"&&sl(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=o,e.dump="["+r+"]"}function YB(e,t,n,r){var o="",i=e.tag,a,s,l;for(a=0,s=n.length;a<s;a+=1)l=n[a],e.replacer&&(l=e.replacer.call(n,String(a),l)),(sl(e,t+1,l,!0,!0,!1,!0)||typeof l>"u"&&sl(e,t+1,null,!0,!0,!1,!0))&&((!r||o!=="")&&(o+=g_(e,t)),e.dump&&tp===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=i,e.dump=o||"[]"}function Fge(e,t,n){var r="",o=e.tag,i=Object.keys(n),a,s,l,c,f;for(a=0,s=i.length;a<s;a+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),l=i[a],c=n[l],e.replacer&&(c=e.replacer.call(n,l,c)),sl(e,t,l,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),sl(e,t,c,!1,!1)&&(f+=e.dump,r+=f));e.tag=o,e.dump="{"+r+"}"}function Vge(e,t,n,r){var o="",i=e.tag,a=Object.keys(n),s,l,c,f,u,d;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new ri("sortKeys must be a boolean or a function");for(s=0,l=a.length;s<l;s+=1)d="",(!r||o!=="")&&(d+=g_(e,t)),c=a[s],f=n[c],e.replacer&&(f=e.replacer.call(n,c,f)),sl(e,t+1,c,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&tp===e.dump.charCodeAt(0)?d+="?":d+="? "),d+=e.dump,u&&(d+=g_(e,t)),sl(e,t+1,f,!0,u)&&(e.dump&&tp===e.dump.charCodeAt(0)?d+=":":d+=": ",d+=e.dump,o+=d));e.tag=i,e.dump=o||"{}"}function XB(e,t,n){var r,o,i,a,s,l;for(o=n?e.explicitTypes:e.implicitTypes,i=0,a=o.length;i<a;i+=1)if(s=o[i],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof t=="object"&&t instanceof s.instanceOf)&&(!s.predicate||s.predicate(t))){if(n?s.multi&&s.representName?e.tag=s.representName(t):e.tag=s.tag:e.tag="?",s.represent){if(l=e.styleMap[s.tag]||s.defaultStyle,NB.call(s.represent)==="[object Function]")r=s.represent(t,l);else if(IB.call(s.represent,l))r=s.represent[l](t,l);else throw new ri("!<"+s.tag+'> tag resolver accepts not "'+l+'" style');e.dump=r}return!0}return!1}function sl(e,t,n,r,o,i,a){e.tag=null,e.dump=n,XB(e,n,!1)||XB(e,n,!0);var s=NB.call(e.dump),l=r,c;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=s==="[object Object]"||s==="[object Array]",u,d;if(f&&(u=e.duplicates.indexOf(n),d=u!==-1),(e.tag!==null&&e.tag!=="?"||d||e.indent!==2&&t>0)&&(o=!1),d&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(f&&d&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),s==="[object Object]")r&&Object.keys(e.dump).length!==0?(Vge(e,t,e.dump,o),d&&(e.dump="&ref_"+u+e.dump)):(Fge(e,t,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if(s==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?YB(e,t-1,e.dump,o):YB(e,t,e.dump,o),d&&(e.dump="&ref_"+u+e.dump)):(Bge(e,t,e.dump),d&&(e.dump="&ref_"+u+" "+e.dump));else if(s==="[object String]")e.tag!=="?"&&Dge(e,e.dump,t,i,l);else{if(s==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new ri("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(c=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?c="!"+c:c.slice(0,18)==="tag:yaml.org,2002:"?c="!!"+c.slice(18):c="!<"+c+">",e.dump=c+" "+e.dump)}return!0}function zge(e,t){var n=[],r=[],o,i;for(b_(e,n,r),o=0,i=r.length;o<i;o+=1)t.duplicates.push(n[r[o]]);t.usedDuplicates=new Array(i)}function b_(e,t,n){var r,o,i;if(e!==null&&typeof e=="object")if(o=t.indexOf(e),o!==-1)n.indexOf(o)===-1&&n.push(o);else if(t.push(e),Array.isArray(e))for(o=0,i=e.length;o<i;o+=1)b_(e[o],t,n);else for(r=Object.keys(e),o=0,i=r.length;o<i;o+=1)b_(e[r[o]],t,n)}function qge(e,t){t=t||{};var n=new Age(t);n.noRefs||zge(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),sl(n,0,r,!0,!0)?n.dump+`
|
|
206
|
-
`:""}var Uge=qge,Hge={dump:Uge};function w_(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var Wge=Oo,Kge=eB,Gge=oB,Jge=cB,Qge=uB,Yge=f_,Xge=PB.load,Zge=PB.loadAll,e0e=Hge.dump,t0e=ri,n0e={binary:mB,float:lB,map:rB,null:iB,pairs:gB,set:yB,timestamp:hB,bool:aB,int:sB,merge:pB,omap:vB,seq:nB,str:tB},r0e=w_("safeLoad","load"),o0e=w_("safeLoadAll","loadAll"),i0e=w_("safeDump","dump"),a0e={Type:Wge,Schema:Kge,FAILSAFE_SCHEMA:Gge,JSON_SCHEMA:Jge,CORE_SCHEMA:Qge,DEFAULT_SCHEMA:Yge,load:Xge,loadAll:Zge,dump:e0e,YAMLException:t0e,types:n0e,safeLoad:r0e,safeLoadAll:o0e,safeDump:i0e};function s0(e){return new Promise((t,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?t(r.responseText):(Qt(`Failed to load file ${e}`,r.status),n(r.status))},r.open("GET",e),r.send()})}async function ip(e){try{const t=await s0(e);let n;if(e.endsWith(".json"))n=JSON.parse(t);else if(e.endsWith(".yaml"))n=a0e.load(t);else{const r=`Unsupported file type for data file ${e} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${e} is empty`);return n}catch(t){throw console.error(`Failed to load data file ${e}: ${t}`),t}}const s0e=(e,t)=>{const n={};for(const r in e)n[r]=t(e[r]);return n},ZB=(e,t)=>{for(const n in e){const r=e[n];t(r,n,e),typeof r=="object"&&r!==null&&ZB(r,t)}},l0={};function l0e(e){return l0[e]??{}}function eF(e,t,n){const r=l0e(e.transition),o=e.duration??r.duration??500,i=e.delay??r.delay??0;return{...e,resolve:n,duration:o,delay:i,oldScreen:t}}const oi=co("notifications",{state:()=>({notifications:[],enabled:!0}),actions:{async addNotification(e,t,n){if(!this.enabled)return;e=Cs(e);const r=`${Date.now()}-${Math.random()*1e4}`;this.notifications.push({id:r,text:e,description:t,icon:n}),yt().notifications.alsoPrintInDialogue&&Q9(`[NOTIFICATION] ${e}`),await xi(yt().notifications.timeOnScreen*1e3),this.deleteNotification(r)},deleteNotification(e){const t=this.findNotifications(e);t&&this.notifications.splice(this.notifications.indexOf(t),1)},findNotifications(e){return this.notifications.find(t=>t.id===e)},disableNotifications(){this.enabled=!1;for(const e in this.notifications)this.deleteNotification(e)},enableNotifications(){this.enabled=!0}}}),Xr=co("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:sr(this.items),interactionTags:sr(this.interactionTags)}},loadSaveData(e){this.items={...this.items,...e.items},this.interactionTags={...e.interactionTags}},setupItems(e){Object.keys(e).forEach(t=>{this.items[t]={amount:0,id:t}})},reset(e){this.$reset(),this.setupItems(e)},hasItem(e,t){var n;return t||(t=1),((n=this.items[e])==null?void 0:n.amount)>=t},getExistingItem(e){return this.items[e]},getItemAmount(e){var t;return((t=this.getExistingItem(e))==null?void 0:t.amount)||0},add(e){const t=this.getExistingItem(e.id);t?t.amount+=e.amount:this.items[e.id]={...e};const n=As(e.id).name,r=e.amount>1?`${n} x ${e.amount}`:n;oi().addNotification(`Received item: ${r}`)},enableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!1}},disableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!0}},onScriptStart(){const e=yt().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.disableInteraction(t)})},onScriptEnd(){const e=yt().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.enableInteraction(t)})},isInteractionTagBlocked(e){return e||(e="default"),this.interactionTags[e]?this.interactionTags[e].blockedInteraction:!1},remove(e){const t=this.getExistingItem(e.id);t&&(t.amount-=e.amount,oi().addNotification(`Lost item: ${As(e.id).name} x ${e.amount}`),t.amount<=0&&this.deleteItem(e.id))},deleteItem(e){this.getExistingItem(e)&&(this.items[e].amount=0)},canUseItem(e){var n;const t=As(e.id);return!!(t&&t.onUse&&!this.isInteractionTagBlocked(t.tag)&&!((n=Yn().currentDialog)!=null&&n.choices))}}}),Ri=co("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(e,t,n){return new Promise(r=>{const o=this.layers[t||0];let i;const a=(o==null?void 0:o.screen)??null;if(a===e){r();return}n&&(i=eF(n,a,r)),this.layers[t||0]={screen:e,transition:i},i||r()})},finishTransition(e){const t=this.layers[e];if(!t)Qt(`Tried to finish transition on layer ${e} but it doesn't exist`);else if(t.transition){const n=t.transition.resolve;delete t.transition,n()}},transitionScreen(e,t,n){return this.setScreen(e,n??0,t)},emptyLayer(e,t){return new Promise(n=>{const r=this.layers[e];if(!r){su(`Tried to empty layer ${e} but it doesn't exist`);return}if(t){const o=r.screen,i=eF(t,o,n);r.transition=i}r.screen=null,t||n()})},setButtons(e){const t=e.screens.screens,n=e.buttons.buttons;for(const r in n)this.buttons[r]={state:n[r].enabled};for(const r in t){const o=t[r];if(o.buttons)for(const[i,a]of o.buttons.entries())typeof a=="object"&&(n[a.id]=a,o.buttons[i]=a.id,this.buttons[a.id]={state:a.enabled})}},reset(e){this.$reset(),this.setButtons(e)},changeButton(e,t){if(!this.buttons[e]){Qt(`Tried to change button ${e} but it doesn't exist`);return}this.buttons[e].state=t},generateSaveData(){return{layers:sr(this.layers).filter(e=>e).map(e=>e.screen??null),buttons:sr(this.buttons)}},loadSaveData(e){this.layers=e.layers.map(t=>(t!==null&&typeof t!="string"&&(t=null),{screen:t})),this.buttons=Zh(this.buttons,e.buttons)},isButtonDisabled(e){const t=this.getButtonState(e);return t==="hidden"||t==="greyed"||t===!1},isButtonInteractible(e){const t=this.getButtonState(e);return t?t===!0:!1},isButtonClickable(e){if(!this.isButtonInteractible(e))return!1;const n=pu(e);return!!tF(n)},getButtonState(e){const t=pu(e),n=this.buttons[e],r=t.tag||"default",o=n.state;return o===!0&&Xr().isInteractionTagBlocked(r)?"greyed":o},clickOnButton(e){if(!this.isButtonClickable(e))return;const t=un(),n=pu(e);ru("onButtonClicked");const r=n.action;r&&(n.actionType==="run"?t.runLabelFunction(r):t.jumpToLabel(r))}},getters:{nonEmptyLayers(e){return e.layers.filter(t=>t)},isTransitioning(e){return e.layers.some(t=>t==null?void 0:t.transition)}}});function tF(e){if(!en().inScript)return!0;const t=A0().clickableDuringScriptsByDefault;if(t)return e.scriptClickable!==!1;if(!t)return e.scriptClickable===!0}const c0e=["screenObject","sprite"];function nF(e){return typeof e=="object"&&e!==null&&c0e.includes(e._entityType)}function u0e(e){return typeof e=="object"&&e!==null&&e._entityType==="sprite"}function f0e(e){if(e.includes(" ")){const t=e.split(" ");return{label:t[0],args:t.slice(1)}}else return{label:e}}const Ho=co("screenObjects",{state:()=>({tree:[],objectsList:{}}),actions:{addObject(e){e.parent?e.parent.children.push(e):this.tree.push(e),this.objectsList[e.id]=e},createObject(e){const t={_entityType:"screenObject",id:ou(),name:"Screen Object",tags:[],x:0,y:0,anchor:{x:0,y:0},width:1,height:1,opacity:1,scale:1,layer:0,children:[],...e};return this.addObject(t),t},destroyObject(e){let t=e;typeof t=="string"&&(t=this.getObject(t));for(let n=t.children.length-1;n>=0;n--)this.destroyObject(t.children[n]);if(t.parent){const n=t.parent,r=n.children.indexOf(t);r!==-1?n.children.splice(r,1):console.warn(`Could not find object ${t.id} in parent's children`)}else{const n=this.tree.indexOf(t);n!==-1?this.tree.splice(n,1):console.warn(`Object to destroy not found in store (${t.id})`)}delete this.objectsList[t.id]},createSprite(e){const t=this.createObject(e);return t._entityType="sprite",$pe(e.image).then(n=>{const r=this.getObject(t.id);r.width===1&&r.height===1&&(r.width=n.width,r.height=n.height)}),t},getObject(e){return this.objectsList[e]},isScreenObjectClickable(e){return tF(e)?!!e.onClick:!1},clickObject(e){if(this.isScreenObjectClickable(e)&&e.onClick){console.log("click",Date.now()),ru("onSpriteClicked");let t;if(typeof e.onClick=="string"){const n=f0e(e.onClick);t={label:n.label,args:n.args}}else t=e.onClick;t.method=t.method??e.clickMethod??"jump",t.args=t.args??[],t.method==="run"?un().runThenGoBackToPreviousDialog(t.label,...t.args):t.method==="jump"?un().jumpToLabel(t.label,...t.args):Qt(`Unknown sprite click method ${e.clickMethod}`)}},generateSaveData(){return{tree:sr(this.tree.map(e=>e.id)),objectsList:sr(s0e(this.objectsList,e=>this.screenObjectToSave(e)))}},loadSaveData(e){this.objectsList=this.loadAllObjects(e.objectsList),this.tree=e.tree.map(t=>this.objectsList[t])},reset(){this.$reset()},screenObjectToSave(e){return{...e,children:e.children.map(t=>t.id),parent:e.parent?e.parent.id:void 0}},loadAllObjects(e){for(const t of Object.values(e)){const n=t;n.parent=n.parent?e[n.parent]:void 0,n.children=n.children.map(r=>e[r])}return e},emptyLayer(e){for(let t=this.tree.length-1;t>=0;t--){const n=this.tree[t];n.layer===e&&this.destroyObject(n)}},emptyAllLayers(){for(let e=this.tree.length-1;e>=0;e--){const t=this.tree[e];this.destroyObject(t)}}}}),un=co("vm",{state:()=>({stack:[],data:{},globalData:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{vmSave:{lastLabel:this.lastLabel,data:S2(this.data,e=>nF(e)?{_entityType:e._entityType,id:e.id}:e)},globalData:sr(this.globalData)}},loadSaveData(e,t){this.lastLabel=e.lastLabel,this.data=e.data,this.findEntitiesInData(this.data)},findEntitiesInData(e){ZB(this.data,(t,n,r)=>{if(nF(t)){const o=Ho().getObject(t.id);o?r[n]=o:su(`Trying to reload sprite ${n} (${JSON.stringify(t)} - ${t.id}) but it does not exist.`)}})},setReturnValue(e){this.currentFrame.returnValue=e},waitForPlayerAnswer(e){this.commandsWaitingForPlayerAnswer.push(e)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(e,t){this.currentFrame&&(this.currentFrame.scope[e]=t)},async loadScripts(e){this.readGlobalData();const t=await this.loadConfigScriptFiles(e),n=en().options.scripts;this.addAllScripts([...t,...n])},async loadConfigScriptFiles(e){const t=[];for(const r of e)t.push(s0(N0(r)));return(await Promise.all(t)).map((r,o)=>({fileName:e[o],code:r,id:e[o]}))},addAllScripts(e){const t=Date.now();for(const r of e)wn.addNarratScript(r);const n=Date.now();di.log(`scripts parsed in ${n-t} ms`)},start(){this.setStack({currentIndex:0,branchData:{branch:wn.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:wn.script.main.branch},label:"main"})},setLastLabel(e){this.lastLabel=e},reset(){this.$reset(),this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:wn.script.main.branch},label:"main"})},readGlobalData(){this.globalData=al().globalSave.data},setScript(e){wn.script=e},overrideData(e){this.data=e},setStack(e){this.stack=[];const t=this.frameOptionsToFrame(e);this.lastLabel=e.label,this.stack.push(t)},frameOptionsToFrame(e){const t=e.branchData,n={...e,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:t,currentIndex:e.currentIndex}),e.scope&&(n.scope=e.scope),e.args&&e.branchData.args)for(const[r,o]of e.branchData.args.entries())e.args.length>r&&(n.scope[o]=e.args[r]);return n},addBlock(e,t){e.blocks.push(t)},async addAndRunBlock(e){const t=this.currentFrame;if(!t)throw new Error("No frame to add block to");return this.addBlock(t,e),await this.runBlock()},setData(e,t){const n=ad();vV(n,e,t)},addInstruction(e,t){const n=ad();gV(n,e,t)},addFrame(e){if(!e.label)if(this.currentFrame)e.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const t=this.frameOptionsToFrame(e);this.stack.push(t)},async addAndRunFrame(e){return await this.addFrame(e),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let t;for(;this.currentBlock;){const n=await this.runBlock();if(n===Xg||n===Zg)return this.cleanFrame(),n;if(n===o_)return this.cleanFrame()}return this.cleanFrame(),t},cleanFrame(){const e=this.currentFrame,{returnValue:t}=e;return this.stack.splice(this.stack.length-1,1),t},async runBlock(){const e=this.currentBlock;if(!e)throw new Error("Tried to run a block but there is no current block");let t;for(;this.currentLine;){if(t=await this.runLineOnly(),ume(t))return this.cleanBlock(),t;e.currentIndex++}return this.cleanBlock(),t},cleanBlock(){if(!this.currentFrame){Qt("Tried to clean a block but there is no current frame");return}if(!this.currentFrame.blocks){Qt("Tried to clean a block but there is no current block");return}this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let e=await this.runFrame();for(;e===Xg;){const t=this.jumpTarget;if(!t){Qt("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(t),await en().autoSaveGame({}),e=await this.runFrame()}e!==Zg&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(yt().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==yt().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(yt().gameFlow.labelToJumpOnScriptEnd);return}en().endingScript(),en().options.debug&&yt().debugging.showScriptFinishedMessage},async runLineOnly(){const e=this.currentLine;if(!e){Qt("There is no line of script to run.");return}return en().startingScript(),await lF(e)},async runLabelFunction(e,...t){const n=wn.script[e];if(!n){Qt(`Tried to run a label that doesn't exist: ${e}`);return}const r={currentIndex:0,branchData:n,label:e,args:t};return this.addAndRunFrame(r)},runCustomFrame(e){this.addAndRunFrame(e)},async jumpToLabel(e,...t){const n=wn.script[e];if(!n){Qt(`Label ${e} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}e!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(e),this.setStack({currentIndex:0,branchData:n,args:t,label:e}),this.runGame()},async runThenGoBackToPreviousDialog(e,...t){const n=Yn(),r=n.dialog[n.dialog.length-1],o=en().inScript,i=await this.runLabelFunction(e,...t);return o?n.dialog.push(r):en().endingScript(),i}},getters:{currentFrame(e){return e.stack[e.stack.length-1]},scope(){var e;return((e=this.currentFrame)==null?void 0:e.scope)??{}},currentBlock(){const e=this.currentFrame;return e?e.blocks[e.blocks.length-1]:void 0},currentLine(){const e=this.currentBlock;if(e&&e.branchData.branch.length>e.currentIndex)return e.branchData.branch[e.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}}),Bi=co("settings",{state:()=>({baseSettings:{textSpeed:30,animateText:!0,fontSize:16},settingsSchema:{textSpeed:{type:"number",defaultValue:30,minValue:1,maxValue:100,step:5,name:"Text Speed",description:"The speed at which text plays."},animateText:{type:"boolean",defaultValue:!0,name:"Animate Text",description:"Whether or not text should animate."},fontSize:{type:"integer",defaultValue:16,minValue:8,maxValue:64,step:1,name:"Font Size",description:"The base font size for the game."}},customSettings:{},customSettingsSchema:{}}),actions:{reset(e){this.$reset(),this.setupSettings(e)},getSetting(e){if(typeof this.baseSettings[e]<"u")return this.baseSettings[e];if(typeof this.customSettings[e]<"u")return this.customSettings[e];Qt(`Setting ${e} does not exist.`)},getSettingSchema(e){if(typeof this.settingsSchema[e]<"u")return this.settingsSchema[e];if(typeof this.customSettingsSchema[e]<"u")return this.customSettingsSchema[e];Qt(`Setting ${e} does not exist.`)},getAllSettingSchemas(){return{...this.settingsSchema,...this.customSettingsSchema}},setSetting(e,t){typeof this.baseSettings[e]<"u"?this.baseSettings[e]=t:typeof this.customSettings[e]<"u"?this.customSettings[e]=t:Qt(`Setting ${e} does not exist.`),e==="fontSize"&&document.documentElement.style.setProperty("font-size",`${t}px`),e==="textSpeed"&&(ni().config.dialogPanel.textSpeed=t),e==="animateText"&&(ni().config.dialogPanel.animateText=t)},setupSettings(e){var t;if(this.setSetting("textSpeed",e.dialogPanel.textSpeed??e0),this.setSetting("animateText",e.dialogPanel.animateText??!0),this.setSetting("fontSize",e.layout.defaultFontSize??16),(t=e.settings)!=null&&t.customSettings)for(const n in e.settings.customSettings)this.addCustomSetting(n,e.settings.customSettings[n])},addCustomSetting(e,t){this.customSettings[e]=t.defaultValue,this.customSettingsSchema[e]=t},generateSaveData(){return{baseSettings:sr(this.baseSettings),customSettings:sr(this.customSettings)}},loadSaveData(e){for(const t in e.baseSettings)this.setSetting(t,e.baseSettings[t]);for(const t in e.customSettings)typeof this.customSettings[t]<"u"&&this.setSetting(t,e.customSettings[t])}}}),rF=new Sp;rF.setupDebugger(!1);const ua=rF.logger;function d0e(e){return h0e((t,n,r)=>T0e(t,n,r),e.code,e.fileName)}function h0e(e,t,n){const r={fileName:n,currentLine:0,error:(a,s)=>e(r,a,s),processCommandsFunction:k_,indentSize:0};r.indentSize=x0e(r,t);const o=b0e(r,t);r.currentLine=0,ua.log(o);const i={};for(const a of o){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const l=a.code.replace(":","").split(/ +/g),c=l[0],f=l.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),i[c]={branch:k_(r,a.branch,void 0),args:f}}return i}function k_(e,t,n){const r=e.currentLine;if(!t){let a=0;return n&&(a=n.line),e.error(a,"Processing of command failed because the current branch has no lines inside"),[]}const o={processCommandsFunction:k_,parserContext:e,lines:t,currentLine:0,line:t[0]},i=[];for(;o.currentLine<t.length;){const a=t[o.currentLine];o.line=a;const s=x_(e,a,a.expression),l=wn.commands[s.command.operator];let c=l==null?void 0:l.parser;c||(c=wn.commands.text.parser),ua.log(wn.commands.text);const{newLine:f}=c(o,s);o.currentLine=f,e.currentLine=r+f,i.push(s)}return i}function x_(e,t,n){ua.log(n),typeof n[0]!="string"&&e.error(t.line,"Expression operator should be a string");const r={code:t.code,fileName:e.fileName,line:t.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>p0e(e,t,a)),options:{}}},o=n[0];if(!wn.commands[o]){const a=["else","success","failure"];!Fpe(o)&&!a.includes(o)&&e.error(t.line,`Unknown command ${o}`)}return r}function p0e(e,t,n){return Array.isArray(n)?x_(e,t,n):n}function m0e(e){return e==="true"?!0:e==="false"?!1:e==="undefined"?void 0:e===null?null:isNaN(Number(e))?e:Number(e)}function v0e(e,t){t.charAt(t.length-1)===":"&&(t=t.substr(0,t.length-1));const n=g0e(t),[r]=iF(e,n);return r}function g0e(e){const t=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=t.exec(e))!=null;)n.push(r);let o=0,i=[];for(const a of n){const s=a.index;if(s>o){const c=e.substr(o,s-o),f=oF(c);i=[...i,...f]}const l=a[0].replace(/\\/g,"");i.push(`$$"${l.substring(1,l.length-1)}`),o=s+a[0].length}return i=[...i,...oF(e.substr(o))],i.push(")"),i}function oF(e){e=e.replace(/: *$/g,"");let t=e.split(" ").filter(n=>n);return t=t.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(o=>o&&o),[]),t.map(n=>m0e(n))}function iF(e,t){ua.log("===============");let n=[],r=0,o=aF(t)+r,i=__(t)+r;for(ua.log(`Parsing expression: ${t}`),ua.log(`Parenthesis start index: ${o} - end: ${i}`);o!==-1&&i>o;){n=[...n,...t.slice(r,o)];const l=t.slice(o+1);ua.log(`Found a sub expression. Before: ${n} - After: ${l}`),r=o;const[c,f]=iF(e,l),u=r+f;n.push(c),r=u+1;const d=t.slice(r);ua.log(`Sub expression came back: ${c} - rest of string: ${d}`),o=aF(d),o!==-1&&(o+=r),i=__(d),i!==-1&&(i+=r)}i!==-1&&ua.log("Found parenthesis end before new opening parenthesis, close this expression");const a=__(t.slice(r))+r;if(a===-1)return e.error(e.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=t.slice(r,a);return ua.log(`End of expression: ${a} - ${s}`),ua.log("==================="),n=[...n,...s],y0e(e,n),[n,a+1]}function y0e(e,t){t.length<1&&e.error(e.currentLine,"Expression is empty")}function aF(e){return e.findIndex(t=>t==="(")}function __(e){return e.findIndex(t=>t===")")}function b0e(e,t){const n=t.split(/\r?\n|$/).map(o=>{const i=o.search(/ *\/\//g);return i!==-1?o.substr(0,i):o});return sF(e,n,0,0).lines}function sF(e,t,n,r){let o=!0,i=n;const a=[];for(;o&&!(i>=t.length);){let s=t[i];if(s.search(/^\s*$/)!==-1)i++;else{const l=k0e(e,s);if(s=s.substring(l*e.indentSize),w0e(e,l,i),l<r)o=!1;else if(l>r){(a.length===0||l-r!==1)&&e.error(i,"Wrong double indentation");const c=sF(e,t,i,l);a[a.length-1].branch=c.lines,i=c.endLine}else{const c=v0e(e,s),f={code:s,indentation:l,line:i,expression:c};a.push(f),i++,e.currentLine=i}}}return{lines:a,endLine:i}}function w0e(e,t,n){t%1!==0&&e.error(n,`Indentation level of ${t} incorrect. Expected indentation of ${e.indentSize} spaces for this file.`)}function k0e(e,t){return t.search(/[^ ]/)/e.indentSize}function x0e(e,t){const n=/\n( *)/,r=t.match(n);return!r||r.length<2?(e.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(ua.log(r),r[1].length)}class _0e{constructor(){hr(this,"plugins",[]);hr(this,"pinia");hr(this,"script",{});hr(this,"scripts",[]);hr(this,"commands",{})}addCommand(t){this.commands[t.keyword]=t}addPlugin(t){if(this.plugins.push(t),t.customCommands)for(const n of t.customCommands)this.addCommand(n)}callHook(t,...n){for(const r of this.plugins)typeof r[t]=="function"&&r[t](...n)}addNarratScript(t){const n=d0e(t);this.script={...this.script,...n},this.scripts.push(t)}customStores(){const t=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)t.push([r,n.customStores[r](this.pinia)]);return t}addCustomSettings(){for(const t of this.plugins)if(t.customSettings)for(const n in t.customSettings)Bi().addCustomSetting(n,t.customSettings[n])}}const wn=new _0e;async function lF(e,t){var r;const n=un();try{return await c0(e,t)}catch(o){console.error(o),console.error(e),Qt(`Narrat script runtime error at <span class="error-filename">${e.fileName}:${e.line+1}</span>
|
|
206
|
+
`:""}var Uge=qge,Hge={dump:Uge};function w_(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var Wge=Oo,Kge=eB,Gge=oB,Jge=cB,Qge=uB,Yge=f_,Xge=PB.load,Zge=PB.loadAll,e0e=Hge.dump,t0e=ri,n0e={binary:mB,float:lB,map:rB,null:iB,pairs:gB,set:yB,timestamp:hB,bool:aB,int:sB,merge:pB,omap:vB,seq:nB,str:tB},r0e=w_("safeLoad","load"),o0e=w_("safeLoadAll","loadAll"),i0e=w_("safeDump","dump"),a0e={Type:Wge,Schema:Kge,FAILSAFE_SCHEMA:Gge,JSON_SCHEMA:Jge,CORE_SCHEMA:Qge,DEFAULT_SCHEMA:Yge,load:Xge,loadAll:Zge,dump:e0e,YAMLException:t0e,types:n0e,safeLoad:r0e,safeLoadAll:o0e,safeDump:i0e};function s0(e){return new Promise((t,n)=>{const r=new XMLHttpRequest;r.onload=function(){r.status>=200&&r.status<300?t(r.responseText):(Qt(`Failed to load file ${e}`,r.status),n(r.status))},r.open("GET",e),r.send()})}async function ip(e){try{const t=await s0(e);let n;if(e.endsWith(".json"))n=JSON.parse(t);else if(e.endsWith(".yaml"))n=a0e.load(t);else{const r=`Unsupported file type for data file ${e} (must be .json or .yaml)`;throw new Error(r)}if(!n)throw new Error(`Data loaded from ${e} is empty`);return n}catch(t){throw console.error(`Failed to load data file ${e}: ${t}`),t}}const s0e=(e,t)=>{const n={};for(const r in e)n[r]=t(e[r]);return n},ZB=(e,t)=>{for(const n in e){const r=e[n];t(r,n,e),typeof r=="object"&&r!==null&&ZB(r,t)}},l0={};function l0e(e){return l0[e]??{}}function eF(e,t,n){const r=l0e(e.transition),o=e.duration??r.duration??500,i=e.delay??r.delay??0;return{...e,resolve:n,duration:o,delay:i,oldScreen:t}}const oi=co("notifications",{state:()=>({notifications:[],enabled:!0}),actions:{async addNotification(e,t,n){if(!this.enabled)return;e=Cs(e);const r=`${Date.now()}-${Math.random()*1e4}`;this.notifications.push({id:r,text:e,description:t,icon:n}),yt().notifications.alsoPrintInDialogue&&Q9(`[NOTIFICATION] ${e}`),await xi(yt().notifications.timeOnScreen*1e3),this.deleteNotification(r)},deleteNotification(e){const t=this.findNotifications(e);t&&this.notifications.splice(this.notifications.indexOf(t),1)},findNotifications(e){return this.notifications.find(t=>t.id===e)},disableNotifications(){this.enabled=!1;for(const e in this.notifications)this.deleteNotification(e)},enableNotifications(){this.enabled=!0}}}),Xr=co("inventory",{state:()=>({items:{},interactionTags:{}}),actions:{generateSaveData(){return{items:sr(this.items),interactionTags:sr(this.interactionTags)}},loadSaveData(e){this.items={...this.items,...e.items},this.interactionTags={...e.interactionTags}},setupItems(e){Object.keys(e).forEach(t=>{this.items[t]={amount:0,id:t}})},reset(e){this.$reset(),this.setupItems(e)},hasItem(e,t){var n;return t||(t=1),((n=this.items[e])==null?void 0:n.amount)>=t},getExistingItem(e){return this.items[e]},getItemAmount(e){var t;return((t=this.getExistingItem(e))==null?void 0:t.amount)||0},add(e){const t=this.getExistingItem(e.id);t?t.amount+=e.amount:this.items[e.id]={...e};const n=As(e.id).name,r=e.amount>1?`${n} x ${e.amount}`:n;oi().addNotification(`Received item: ${r}`)},enableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!1}},disableInteraction(e){e||(e="default"),this.interactionTags[e]={blockedInteraction:!0}},onScriptStart(){const e=yt().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.disableInteraction(t)})},onScriptEnd(){const e=yt().interactionTags;Object.keys(e).forEach(t=>{e[t].onlyInteractOutsideOfScripts&&this.enableInteraction(t)})},isInteractionTagBlocked(e){return e||(e="default"),this.interactionTags[e]?this.interactionTags[e].blockedInteraction:!1},remove(e){const t=this.getExistingItem(e.id);t&&(t.amount-=e.amount,oi().addNotification(`Lost item: ${As(e.id).name} x ${e.amount}`),t.amount<=0&&this.deleteItem(e.id))},deleteItem(e){this.getExistingItem(e)&&(this.items[e].amount=0)},canUseItem(e){var n;const t=As(e.id);return!!(t&&t.onUse&&!this.isInteractionTagBlocked(t.tag)&&!((n=Yn().currentDialog)!=null&&n.choices))}}}),Ri=co("screens",{state:()=>({layers:[{screen:"default"}],buttons:{}}),actions:{setScreen(e,t,n){return new Promise(r=>{const o=this.layers[t||0];let i;const a=(o==null?void 0:o.screen)??null;if(a===e){r();return}n&&(i=eF(n,a,r)),this.layers[t||0]={screen:e,transition:i},i||r()})},finishTransition(e){const t=this.layers[e];if(!t)Qt(`Tried to finish transition on layer ${e} but it doesn't exist`);else if(t.transition){const n=t.transition.resolve;delete t.transition,n()}},transitionScreen(e,t,n){return this.setScreen(e,n??0,t)},emptyLayer(e,t){return new Promise(n=>{const r=this.layers[e];if(!r){su(`Tried to empty layer ${e} but it doesn't exist`);return}if(t){const o=r.screen,i=eF(t,o,n);r.transition=i}r.screen="@empty",t||n()})},setButtons(e){const t=e.screens.screens,n=e.buttons.buttons;for(const r in n)this.buttons[r]={state:n[r].enabled};for(const r in t){const o=t[r];if(o.buttons)for(const[i,a]of o.buttons.entries())typeof a=="object"&&(n[a.id]=a,o.buttons[i]=a.id,this.buttons[a.id]={state:a.enabled})}},reset(e){this.$reset(),this.setButtons(e)},changeButton(e,t){if(!this.buttons[e]){Qt(`Tried to change button ${e} but it doesn't exist`);return}this.buttons[e].state=t},generateSaveData(){return{layers:sr(this.layers).filter(e=>e).map(e=>e.screen??null),buttons:sr(this.buttons)}},loadSaveData(e){this.layers=e.layers.map(t=>(t!==null&&typeof t!="string"&&(t=null),{screen:t})),this.buttons=Zh(this.buttons,e.buttons)},isButtonDisabled(e){const t=this.getButtonState(e);return t==="hidden"||t==="greyed"||t===!1},isButtonInteractible(e){const t=this.getButtonState(e);return t?t===!0:!1},isButtonClickable(e){if(!this.isButtonInteractible(e))return!1;const n=pu(e);return!!tF(n)},getButtonState(e){const t=pu(e),n=this.buttons[e],r=t.tag||"default",o=n.state;return o===!0&&Xr().isInteractionTagBlocked(r)?"greyed":o},clickOnButton(e){if(!this.isButtonClickable(e))return;const t=un(),n=pu(e);ru("onButtonClicked");const r=n.action;r&&(n.actionType==="run"?t.runLabelFunction(r):t.jumpToLabel(r))}},getters:{nonEmptyLayers(e){return e.layers.filter(t=>t)},isTransitioning(e){return e.layers.some(t=>t==null?void 0:t.transition)}}});function tF(e){if(!en().inScript)return!0;const t=A0().clickableDuringScriptsByDefault;if(t)return e.scriptClickable!==!1;if(!t)return e.scriptClickable===!0}const c0e=["screenObject","sprite"];function nF(e){return typeof e=="object"&&e!==null&&c0e.includes(e._entityType)}function u0e(e){return typeof e=="object"&&e!==null&&e._entityType==="sprite"}function f0e(e){if(e.includes(" ")){const t=e.split(" ");return{label:t[0],args:t.slice(1)}}else return{label:e}}const Ho=co("screenObjects",{state:()=>({tree:[],objectsList:{}}),actions:{addObject(e){e.parent?e.parent.children.push(e):this.tree.push(e),this.objectsList[e.id]=e},createObject(e){const t={_entityType:"screenObject",id:ou(),name:"Screen Object",tags:[],x:0,y:0,anchor:{x:0,y:0},width:1,height:1,opacity:1,scale:1,layer:0,children:[],...e};return this.addObject(t),t},destroyObject(e){let t=e;typeof t=="string"&&(t=this.getObject(t));for(let n=t.children.length-1;n>=0;n--)this.destroyObject(t.children[n]);if(t.parent){const n=t.parent,r=n.children.indexOf(t);r!==-1?n.children.splice(r,1):console.warn(`Could not find object ${t.id} in parent's children`)}else{const n=this.tree.indexOf(t);n!==-1?this.tree.splice(n,1):console.warn(`Object to destroy not found in store (${t.id})`)}delete this.objectsList[t.id]},createSprite(e){const t=this.createObject(e);return t._entityType="sprite",$pe(e.image).then(n=>{const r=this.getObject(t.id);r.width===1&&r.height===1&&(r.width=n.width,r.height=n.height)}),t},getObject(e){return this.objectsList[e]},isScreenObjectClickable(e){return tF(e)?!!e.onClick:!1},clickObject(e){if(this.isScreenObjectClickable(e)&&e.onClick){console.log("click",Date.now()),ru("onSpriteClicked");let t;if(typeof e.onClick=="string"){const n=f0e(e.onClick);t={label:n.label,args:n.args}}else t=e.onClick;t.method=t.method??e.clickMethod??"jump",t.args=t.args??[],t.method==="run"?un().runThenGoBackToPreviousDialog(t.label,...t.args):t.method==="jump"?un().jumpToLabel(t.label,...t.args):Qt(`Unknown sprite click method ${e.clickMethod}`)}},generateSaveData(){return{tree:sr(this.tree.map(e=>e.id)),objectsList:sr(s0e(this.objectsList,e=>this.screenObjectToSave(e)))}},loadSaveData(e){this.objectsList=this.loadAllObjects(e.objectsList),this.tree=e.tree.map(t=>this.objectsList[t])},reset(){this.$reset()},screenObjectToSave(e){return{...e,children:e.children.map(t=>t.id),parent:e.parent?e.parent.id:void 0}},loadAllObjects(e){for(const t of Object.values(e)){const n=t;n.parent=n.parent?e[n.parent]:void 0,n.children=n.children.map(r=>e[r])}return e},emptyLayer(e){for(let t=this.tree.length-1;t>=0;t--){const n=this.tree[t];n.layer===e&&this.destroyObject(n)}},emptyAllLayers(){for(let e=this.tree.length-1;e>=0;e--){const t=this.tree[e];this.destroyObject(t)}}}}),un=co("vm",{state:()=>({stack:[],data:{},globalData:{},lastLabel:"main",script:{},labelStack:["main"],commandsWaitingForPlayerAnswer:[],hasJumped:!1}),actions:{generateSaveData(){return{vmSave:{lastLabel:this.lastLabel,data:S2(this.data,e=>nF(e)?{_entityType:e._entityType,id:e.id}:e)},globalData:sr(this.globalData)}},loadSaveData(e,t){this.lastLabel=e.lastLabel,this.data=e.data,this.findEntitiesInData(this.data)},findEntitiesInData(e){ZB(this.data,(t,n,r)=>{if(nF(t)){const o=Ho().getObject(t.id);o?r[n]=o:su(`Trying to reload sprite ${n} (${JSON.stringify(t)} - ${t.id}) but it does not exist.`)}})},setReturnValue(e){this.currentFrame.returnValue=e},waitForPlayerAnswer(e){this.commandsWaitingForPlayerAnswer.push(e)},popAnswerQueue(){return this.commandsWaitingForPlayerAnswer.pop()},addScopedVariable(e,t){this.currentFrame&&(this.currentFrame.scope[e]=t)},async loadScripts(e){this.readGlobalData();const t=await this.loadConfigScriptFiles(e),n=en().options.scripts;this.addAllScripts([...t,...n])},async loadConfigScriptFiles(e){const t=[];for(const r of e)t.push(s0(N0(r)));return(await Promise.all(t)).map((r,o)=>({fileName:e[o],code:r,id:e[o]}))},addAllScripts(e){const t=Date.now();for(const r of e)wn.addNarratScript(r);const n=Date.now();di.log(`scripts parsed in ${n-t} ms`)},start(){this.setStack({currentIndex:0,branchData:{branch:wn.script.main.branch},label:"main"}),this.setStack({currentIndex:0,branchData:{branch:wn.script.main.branch},label:"main"})},setLastLabel(e){this.lastLabel=e},reset(){this.$reset(),this.stack=[],this.data={},this.hasJumped=!0,this.setStack({currentIndex:0,branchData:{branch:wn.script.main.branch},label:"main"})},readGlobalData(){this.globalData=al().globalSave.data},setScript(e){wn.script=e},overrideData(e){this.data=e},setStack(e){this.stack=[];const t=this.frameOptionsToFrame(e);this.lastLabel=e.label,this.stack.push(t)},frameOptionsToFrame(e){const t=e.branchData,n={...e,blocks:[],scope:{},returnValue:null};if(this.addBlock(n,{branchData:t,currentIndex:e.currentIndex}),e.scope&&(n.scope=e.scope),e.args&&e.branchData.args)for(const[r,o]of e.branchData.args.entries())e.args.length>r&&(n.scope[o]=e.args[r]);return n},addBlock(e,t){e.blocks.push(t)},async addAndRunBlock(e){const t=this.currentFrame;if(!t)throw new Error("No frame to add block to");return this.addBlock(t,e),await this.runBlock()},setData(e,t){const n=ad();vV(n,e,t)},addInstruction(e,t){const n=ad();gV(n,e,t)},addFrame(e){if(!e.label)if(this.currentFrame)e.label=this.currentFrame.label;else throw new Error("Tried to add a new frame but no label was passed and there is no current frame label");const t=this.frameOptionsToFrame(e);this.stack.push(t)},async addAndRunFrame(e){return await this.addFrame(e),await this.runFrame()},async runFrame(){if(!this.currentFrame)throw new Error("Tried to run a frame but there is no current frame");let t;for(;this.currentBlock;){const n=await this.runBlock();if(n===Xg||n===Zg)return this.cleanFrame(),n;if(n===o_)return this.cleanFrame()}return this.cleanFrame(),t},cleanFrame(){const e=this.currentFrame,{returnValue:t}=e;return this.stack.splice(this.stack.length-1,1),t},async runBlock(){const e=this.currentBlock;if(!e)throw new Error("Tried to run a block but there is no current block");let t;for(;this.currentLine;){if(t=await this.runLineOnly(),ume(t))return this.cleanBlock(),t;e.currentIndex++}return this.cleanBlock(),t},cleanBlock(){if(!this.currentFrame){Qt("Tried to clean a block but there is no current frame");return}if(!this.currentFrame.blocks){Qt("Tried to clean a block but there is no current block");return}this.currentFrame.blocks.splice(this.currentFrame.blocks.length-1,1)},async runGame(){let e=await this.runFrame();for(;e===Xg;){const t=this.jumpTarget;if(!t){Qt("Tried to jump but no target was set");return}this.hasJumped=!0,this.setStack(t),await en().autoSaveGame({}),e=await this.runFrame()}e!==Zg&&this.stack.length===0&&this.reachedEndOfScript()},async nextLineOnly(){return this.stack.length===0||this.isBlockFinished()?!1:(this.currentBlock.currentIndex++,!0)},isBlockFinished(){return!this.currentBlock||this.currentBlock&&this.currentBlock.currentIndex>=this.currentBlock.branchData.branch.length},reachedEndOfScript(){if(yt().gameFlow.labelToJumpOnScriptEnd&&this.lastLabel!==yt().gameFlow.labelToJumpOnScriptEnd){this.jumpToLabel(yt().gameFlow.labelToJumpOnScriptEnd);return}en().endingScript(),en().options.debug&&yt().debugging.showScriptFinishedMessage},async runLineOnly(){const e=this.currentLine;if(!e){Qt("There is no line of script to run.");return}return en().startingScript(),await lF(e)},async runLabelFunction(e,...t){const n=wn.script[e];if(!n){Qt(`Tried to run a label that doesn't exist: ${e}`);return}const r={currentIndex:0,branchData:n,label:e,args:t};return this.addAndRunFrame(r)},runCustomFrame(e){this.addAndRunFrame(e)},async jumpToLabel(e,...t){const n=wn.script[e];if(!n){Qt(`Label ${e} doesn't exist. Is the file with this label added in the list of script files to load in the config?`);return}e!==this.lastLabel&&(this.hasJumped=!0),this.setLastLabel(e),this.setStack({currentIndex:0,branchData:n,args:t,label:e}),this.runGame()},async runThenGoBackToPreviousDialog(e,...t){const n=Yn(),r=n.dialog[n.dialog.length-1],o=en().inScript,i=await this.runLabelFunction(e,...t);return o?n.dialog.push(r):en().endingScript(),i}},getters:{currentFrame(e){return e.stack[e.stack.length-1]},scope(){var e;return((e=this.currentFrame)==null?void 0:e.scope)??{}},currentBlock(){const e=this.currentFrame;return e?e.blocks[e.blocks.length-1]:void 0},currentLine(){const e=this.currentBlock;if(e&&e.branchData.branch.length>e.currentIndex)return e.branchData.branch[e.currentIndex]},commandWaitingForAnswer(){if(this.commandsWaitingForPlayerAnswer.length>0)return this.commandsWaitingForPlayerAnswer[0]}}}),Bi=co("settings",{state:()=>({baseSettings:{textSpeed:30,animateText:!0,fontSize:16},settingsSchema:{textSpeed:{type:"number",defaultValue:30,minValue:1,maxValue:100,step:5,name:"Text Speed",description:"The speed at which text plays."},animateText:{type:"boolean",defaultValue:!0,name:"Animate Text",description:"Whether or not text should animate."},fontSize:{type:"integer",defaultValue:16,minValue:8,maxValue:64,step:1,name:"Font Size",description:"The base font size for the game."}},customSettings:{},customSettingsSchema:{}}),actions:{reset(e){this.$reset(),this.setupSettings(e)},getSetting(e){if(typeof this.baseSettings[e]<"u")return this.baseSettings[e];if(typeof this.customSettings[e]<"u")return this.customSettings[e];Qt(`Setting ${e} does not exist.`)},getSettingSchema(e){if(typeof this.settingsSchema[e]<"u")return this.settingsSchema[e];if(typeof this.customSettingsSchema[e]<"u")return this.customSettingsSchema[e];Qt(`Setting ${e} does not exist.`)},getAllSettingSchemas(){return{...this.settingsSchema,...this.customSettingsSchema}},setSetting(e,t){typeof this.baseSettings[e]<"u"?this.baseSettings[e]=t:typeof this.customSettings[e]<"u"?this.customSettings[e]=t:Qt(`Setting ${e} does not exist.`),e==="fontSize"&&document.documentElement.style.setProperty("font-size",`${t}px`),e==="textSpeed"&&(ni().config.dialogPanel.textSpeed=t),e==="animateText"&&(ni().config.dialogPanel.animateText=t)},setupSettings(e){var t;if(this.setSetting("textSpeed",e.dialogPanel.textSpeed??e0),this.setSetting("animateText",e.dialogPanel.animateText??!0),this.setSetting("fontSize",e.layout.defaultFontSize??16),(t=e.settings)!=null&&t.customSettings)for(const n in e.settings.customSettings)this.addCustomSetting(n,e.settings.customSettings[n])},addCustomSetting(e,t){this.customSettings[e]=t.defaultValue,this.customSettingsSchema[e]=t},generateSaveData(){return{baseSettings:sr(this.baseSettings),customSettings:sr(this.customSettings)}},loadSaveData(e){for(const t in e.baseSettings)this.setSetting(t,e.baseSettings[t]);for(const t in e.customSettings)typeof this.customSettings[t]<"u"&&this.setSetting(t,e.customSettings[t])}}}),rF=new Sp;rF.setupDebugger(!1);const ua=rF.logger;function d0e(e){return h0e((t,n,r)=>T0e(t,n,r),e.code,e.fileName)}function h0e(e,t,n){const r={fileName:n,currentLine:0,error:(a,s)=>e(r,a,s),processCommandsFunction:k_,indentSize:0};r.indentSize=x0e(r,t);const o=b0e(r,t);r.currentLine=0,ua.log(o);const i={};for(const a of o){a.code.search(":")===-1&&r.error(a.line,"First indentation level should only be used to specify labels");const l=a.code.replace(":","").split(/ +/g),c=l[0],f=l.slice(1);a.branch||r.error(a.line,"This line should have a branch but doesn't"),i[c]={branch:k_(r,a.branch,void 0),args:f}}return i}function k_(e,t,n){const r=e.currentLine;if(!t){let a=0;return n&&(a=n.line),e.error(a,"Processing of command failed because the current branch has no lines inside"),[]}const o={processCommandsFunction:k_,parserContext:e,lines:t,currentLine:0,line:t[0]},i=[];for(;o.currentLine<t.length;){const a=t[o.currentLine];o.line=a;const s=x_(e,a,a.expression),l=wn.commands[s.command.operator];let c=l==null?void 0:l.parser;c||(c=wn.commands.text.parser),ua.log(wn.commands.text);const{newLine:f}=c(o,s);o.currentLine=f,e.currentLine=r+f,i.push(s)}return i}function x_(e,t,n){ua.log(n),typeof n[0]!="string"&&e.error(t.line,"Expression operator should be a string");const r={code:t.code,fileName:e.fileName,line:t.line,command:{staticOptions:{},commandType:n[0],operator:n[0],args:n.slice(1).map(a=>p0e(e,t,a)),options:{}}},o=n[0];if(!wn.commands[o]){const a=["else","success","failure"];!Fpe(o)&&!a.includes(o)&&e.error(t.line,`Unknown command ${o}`)}return r}function p0e(e,t,n){return Array.isArray(n)?x_(e,t,n):n}function m0e(e){return e==="true"?!0:e==="false"?!1:e==="undefined"?void 0:e===null?null:isNaN(Number(e))?e:Number(e)}function v0e(e,t){t.charAt(t.length-1)===":"&&(t=t.substr(0,t.length-1));const n=g0e(t),[r]=iF(e,n);return r}function g0e(e){const t=/(["'])(?:\\\1|.)*?\1/g,n=[];let r;for(;(r=t.exec(e))!=null;)n.push(r);let o=0,i=[];for(const a of n){const s=a.index;if(s>o){const c=e.substr(o,s-o),f=oF(c);i=[...i,...f]}const l=a[0].replace(/\\/g,"");i.push(`$$"${l.substring(1,l.length-1)}`),o=s+a[0].length}return i=[...i,...oF(e.substr(o))],i.push(")"),i}function oF(e){e=e.replace(/: *$/g,"");let t=e.split(" ").filter(n=>n);return t=t.reduce((n,r)=>[...n,...r.split(/(\(|\))/g)].filter(o=>o&&o),[]),t.map(n=>m0e(n))}function iF(e,t){ua.log("===============");let n=[],r=0,o=aF(t)+r,i=__(t)+r;for(ua.log(`Parsing expression: ${t}`),ua.log(`Parenthesis start index: ${o} - end: ${i}`);o!==-1&&i>o;){n=[...n,...t.slice(r,o)];const l=t.slice(o+1);ua.log(`Found a sub expression. Before: ${n} - After: ${l}`),r=o;const[c,f]=iF(e,l),u=r+f;n.push(c),r=u+1;const d=t.slice(r);ua.log(`Sub expression came back: ${c} - rest of string: ${d}`),o=aF(d),o!==-1&&(o+=r),i=__(d),i!==-1&&(i+=r)}i!==-1&&ua.log("Found parenthesis end before new opening parenthesis, close this expression");const a=__(t.slice(r))+r;if(a===-1)return e.error(e.currentLine,'Expression is not closed (missing ")" closing parenthesis)'),[n,a];const s=t.slice(r,a);return ua.log(`End of expression: ${a} - ${s}`),ua.log("==================="),n=[...n,...s],y0e(e,n),[n,a+1]}function y0e(e,t){t.length<1&&e.error(e.currentLine,"Expression is empty")}function aF(e){return e.findIndex(t=>t==="(")}function __(e){return e.findIndex(t=>t===")")}function b0e(e,t){const n=t.split(/\r?\n|$/).map(o=>{const i=o.search(/ *\/\//g);return i!==-1?o.substr(0,i):o});return sF(e,n,0,0).lines}function sF(e,t,n,r){let o=!0,i=n;const a=[];for(;o&&!(i>=t.length);){let s=t[i];if(s.search(/^\s*$/)!==-1)i++;else{const l=k0e(e,s);if(s=s.substring(l*e.indentSize),w0e(e,l,i),l<r)o=!1;else if(l>r){(a.length===0||l-r!==1)&&e.error(i,"Wrong double indentation");const c=sF(e,t,i,l);a[a.length-1].branch=c.lines,i=c.endLine}else{const c=v0e(e,s),f={code:s,indentation:l,line:i,expression:c};a.push(f),i++,e.currentLine=i}}}return{lines:a,endLine:i}}function w0e(e,t,n){t%1!==0&&e.error(n,`Indentation level of ${t} incorrect. Expected indentation of ${e.indentSize} spaces for this file.`)}function k0e(e,t){return t.search(/[^ ]/)/e.indentSize}function x0e(e,t){const n=/\n( *)/,r=t.match(n);return!r||r.length<2?(e.error(0,"Can't detect indentation level. Make sure you indent with at least 2 spaces and consistently"),0):(ua.log(r),r[1].length)}class _0e{constructor(){hr(this,"plugins",[]);hr(this,"pinia");hr(this,"script",{});hr(this,"scripts",[]);hr(this,"commands",{})}addCommand(t){this.commands[t.keyword]=t}addPlugin(t){if(this.plugins.push(t),t.customCommands)for(const n of t.customCommands)this.addCommand(n)}callHook(t,...n){for(const r of this.plugins)typeof r[t]=="function"&&r[t](...n)}addNarratScript(t){const n=d0e(t);this.script={...this.script,...n},this.scripts.push(t)}customStores(){const t=[];for(const n of this.plugins)if(n.customStores)for(const r in n.customStores)t.push([r,n.customStores[r](this.pinia)]);return t}addCustomSettings(){for(const t of this.plugins)if(t.customSettings)for(const n in t.customSettings)Bi().addCustomSetting(n,t.customSettings[n])}}const wn=new _0e;async function lF(e,t){var r;const n=un();try{return await c0(e,t)}catch(o){console.error(o),console.error(e),Qt(`Narrat script runtime error at <span class="error-filename">${e.fileName}:${e.line+1}</span>
|
|
207
207
|
<b>${o}</b>
|
|
208
208
|
Script: ${e.code}
|
|
209
|
-
Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function j0e(e,t){const n=e.command,r=wn.commands[n.commandType];if(r){const o={args:[],options:{},operator:n.operator,staticOptions:n.staticOptions,code:e.code,commandType:n.commandType,fileName:e.fileName,line:e.line},i=r.argTypes;o.options={};for(const[a,s]of n.args.entries()){let l;if(G9(s))l=await c0(s,t);else if(typeof s=="string")if(s.search(p9)===0)l=Cs(s.substring(3));else if(J9(s)){const c=ad(),f=gwe(c,s);if(f){const[u,d]=f;l=u[d]}else l=s}else l=s;else l=s;if(o.args.push(l),Array.isArray(i)&&i.length>a){const c=i[a];l!==null&&(o.options[c.name]=l)}}return o}else throw new Error(`${n.commandType} is not a valid command`)}async function c0(e,t){const n=await j0e(e,t),r=wn.commands[n.commandType];if(r)return await r.run(n,t);throw new Error(`${n.commandType} is not a valid command`)}async function S0e(e){ru("onPlayerAnswered");const t=un(),n=t.popAnswerQueue(),r=t.currentLine;try{if(n){const o=wn.commands[n.commandType];if(o)return await o.processPlayerAnswer(n,e)}}catch(o){console.error(o),Qt(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${o}`)}}const za=co("hud",{state:()=>({hudStats:{}}),actions:{setupHudStats(e){for(const t in e)this.hudStats[t]={value:e[t].startingValue}},reset(e){this.$reset(),this.setupHudStats(e)},setStat(e,t){this.hudStats[e].value=t},addStat(e,t){this.hudStats[e].value+=t},getStat(e){return this.hudStats[e]},getStatValue(e){return this.hudStats[e].value},generateSaveData(){return{hudStats:sr(this.hudStats)}},loadSaveData(e){this.hudStats=Zh(this.hudStats,e.hudStats)}}}),Ao=co("quests",{state:()=>({quests:{}}),actions:{getQuest(e){const t=this.quests[e];if(t)return t;{const n=`Quest ${e} doesn't exist!`;throw Qt(n),new Error(n)}},getObjective(e,t){const n=this.getQuest(e);if(!n){const i=`Quest ${e} doesn't exist!`;throw Qt(i),new Error(i)}const r=n.objectives[t];if(r)return r;const o=`Objective ${t} doesn't exist in quest ${e}!`;throw Qt(o),new Error(o)},setupQuests(e){const t=e.quests;for(const n of Object.keys(t)){const r=t[n];this.quests[n]={id:n,state:"hidden",objectives:{}};for(const o of Object.keys(r.objectives)){const i=r.objectives[o];this.quests[n].objectives[o]={id:o,state:i.hidden?"hidden":"unlocked"}}}},reset(e){this.$reset(),this.setupQuests(e)},startQuest(e){const t=this.getQuest(e);t?(t.state="unlocked",oi().addNotification(`Started quest: ${cc(e).title}`)):Qt(`Quest ${e} doesn't exist!`)},startObjective(e,t){const n=this.getObjective(e,t);n?(n.state="unlocked",oi().addNotification(`New quest objective: ${_p(e,t).description}`)):Qt(`Objective ${t} doesn't exist in quest ${e}!`)},completeObjective(e,t){const n=this.getObjective(e,t);n?(n.state="completed",oi().addNotification(`Completed quest objective: ${_p(e,t).description}`)):Qt(`Objective ${t} doesn't exist in quest ${e}!`)},completeQuest(e,t){const n=this.getQuest(e);n?(n.state="completed",n.ending=t,oi().addNotification(`Completed quest: ${cc(e).title}`)):Qt(`Quest ${e} doesn't exist!`)},isQuestCompleted(e){const t=this.getQuest(e);return t?t.state==="completed":!1},isObjectiveCompleted(e,t){const n=this.getObjective(e,t);return n?n.state==="completed":!1},isQuestStarted(e){const t=this.getQuest(e);return t&&t.state==="unlocked"},isObjectiveStarted(e,t){return this.getObjective(e,t).state==="unlocked"},removeQuest(e){delete this.quests[e]},generateSaveData(){return{quests:sr(this.quests)}},loadSaveData(e){this.quests=e.quests}}});function j_(e,t,n,r){const o=e/n,i=t/r;return Math.min(o,i)}const ii=co("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal"}),actions:{updateScreenSize(e,t){this.screenHeight=t,this.screenWidth=e,e<yt().layout.verticalLayoutThreshold?(this.layoutMode="vertical",document.querySelector("html").style.fontSize=`${Bi().baseSettings.fontSize}px`??"40px"):(this.layoutMode="horizontal",document.querySelector("html").style.fontSize=`${Bi().baseSettings.fontSize}px`??"16px")}},getters:{gameScaleRatio(e){return j_(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(e){return!!(yt().dialogPanel.overlayMode&&e.layoutMode==="horizontal")},gameWidth(){const e=yt();return this.layoutMode==="vertical"||this.overlayMode?e.layout.backgrounds.width:e.layout.backgrounds.width+I0()},gameHeight(){const e=yt();return this.layoutMode==="vertical",e.layout.backgrounds.height},dialogWidth(){return this.layoutMode==="vertical"?this.viewportWidth:I0()},dialogHeight(){return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:yt().dialogPanel.height??this.gameHeight},actualGameHeight(){let e=this.gameHeight;return this.layoutMode==="vertical"&&(e=this.screenHeight/this.gameScaleRatio),e},viewportRatio(e){if(this.layoutMode==="vertical"){const t=yt().layout.backgrounds;return e.screenWidth/t.width}return 1},viewportHeight(e){return yt().layout.backgrounds.height*this.viewportRatio},viewportWidth(e){return yt().layout.backgrounds.width*this.viewportRatio},showDialog(e){const t=en().inScript;return Ri().isTransitioning?!1:!this.overlayMode||this.layoutMode==="vertical"?!0:t}}});class S_{constructor(){hr(this,"listeners",{})}on(t,n){return this.listeners[t]||this.addEventToMap(t),this.listeners[t].add(n),n}off(t,n){return this.listeners[t]&&this.listeners[t].delete(n),n}once(t,n){const r=(...o)=>{this.off(t,r),n(...o)};return this.on(t,r)}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(t=>{delete this.listeners[t]})}addEventToMap(t){this.listeners[t]=new Set}}const ai=co("menu",{state:()=>({menus:{},activeMenu:!1}),getters:{showSkills(){return Object.entries(Ka().skills).length>0},showInventory(){return Object.entries(xp().items).length>0},showQuests(){return Object.entries(td().quests).length>0},showAchievements(){return Object.entries(id().achievements).length>0},menuTabsToShow(e){return e.menus.menu.tabs.map(t=>{const n=yt().menuButtons[t.id]||{};return{...t,...n}}).filter(t=>t.condition?t.condition():!0)},menu(e){return e.activeMenu?e.menus[e.activeMenu]:void 0},tab(){if(this.menu)return this.menu.tabs[this.menu.activeTab]}},actions:{setup(){},addMenu(e,t){this.menus[e]={...t,id:e}},addMenuOption(e,t){this.menus[e]||(this.menus[e]={id:e,label:e,tabs:[],activeTab:0}),this.menus[e].tabs.push(t)},setActiveTab(e){this.menu&&(this.menu.activeTab=e)},openMenu(e){this.activeMenu=e},closeMenu(){this.activeMenu=!1},toggleMenu(){this.activeMenu?this.activeMenu=!1:this.activeMenu="menu"}}}),ll=co("achievements",{state:()=>({achievements:{}}),actions:{generateSaveData(){return{achievements:sr(this.achievements)}},loadSaveData(e){this.achievements={...this.achievements,...sr(e.achievements)}},setupAchievements(e){Object.keys(e).forEach(t=>{this.achievements[t]={id:t,unlocked:!1}})},reset(e){this.$reset(),this.setupAchievements(e)},hasAchievement(e){var t;return((t=this.achievements[e])==null?void 0:t.unlocked)??!1},getExistingAchievement(e){return this.achievements[e]},unlock(e){const t=this.getExistingAchievement(e);if(!t){Qt(`Tried to unlock achievement ${e} but it doesn't exist`);return}if(!t.unlocked){const n=new Date().toISOString();t.unlocked=!0,t.unlockTime=n}if(id().notifyNewAchievements){const n=j2(e);oi().addNotification(`New Achievement: ${n.name}`,n.description,n.icon)}}}});function C0e(){return{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1,scripts:[]}}class $0e extends S_{}const en=co("main",{state:()=>({ready:!1,playing:!1,errors:[],playTime:{start:0,previousPlaytime:0},saveSlot:"",flowState:"engine-splash",paused:!1,debugMode:!0,options:{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1,scripts:[]},loading:{step:"Loading",percentage:.1,loaded:!1},alerts:[],saving:null,listener:new $0e,inScript:!1}),actions:{async setup(){const t=yt().scripts;bo().setMasterVolume(da().options.volume??1),await un().loadScripts(t),ai().setup();for(const[,n]of wn.customStores())if(n.setup){const r=n.setup();Khe(r)&&await r}wn.addCustomSettings(),this.resetAllStores()},async engineLoading(){const e=Tpe(yt()),t=xpe(da());if(wn.plugins){const n=[];for(const r of wn.plugins)r.loadingPromises&&n.push(Promise.all(r.loadingPromises));n.length>0&&(this.loading.step="Plugins",this.loading.percentage=.3,await Promise.all(n))}this.loading.step="Images",await e,this.loading.percentage=.7,this.loading.step="Audio",await t,wn.callHook("onAssetsLoaded"),this.loading.percentage=.95,this.loading.step="Starting...",await this.setup(),wn.callHook("onGameSetup"),this.loading.loaded=!0,this.listener.emit("gameLoaded")},async alert(e,t){return new Promise(n=>{this.alerts.push({title:e,text:t,resolver:n,id:ou()})})},closeAlert(e){const t=this.alerts.findIndex(n=>n.id===e);t!==-1&&(this.alerts[t].resolver(),this.alerts.splice(t,1))},startingScript(){Xr().onScriptStart(),this.inScript=!0},endingScript(){Xr().onScriptEnd(),this.inScript=!1},startMachine(){bo().stopAll(),ru("onPressStart"),un().start(),this.ready=!0,this.startPlaying(),wn.callHook("onGameStart"),this.setFlowState("playing")},setSaveSlot(e){this.saveSlot=e,Mpe(e)},async startGame(e){if(yt().saves.mode==="manual"){const t=n_();t&&(e=t.id)}this.setSaveSlot(e),this.loadGlobalData(),this.startMachine(),un().runGame()},async loadGame(e,t){if(yt().saves.mode==="manual"){const n=n_();n&&(t=n.id)}if(this.setSaveSlot(t),this.startMachine(),e.saveData){this.setLoadedData(e.saveData),bo().reloadAudio(e.saveData.audio);const n=un(),r=yt().saves.runOnReload;typeof r=="string"&&await un().runLabelFunction(r),n.jumpToLabel(e.saveData.vm.lastLabel)}},manualSave({saveName:e,withPrompt:t}){return new Promise(n=>{un().hasJumped?this.saving={name:e,withPrompt:t,resolver:n}:n()})},resetGlobalSave(){un().globalData={},al().globalSave.data={},this.autoSaveGame({})},finishManualSave(e,t){var n;if(!this.saving){Qt("Trying to save but there is no saving request!");return}if(!t||!e){this.saving.resolver(),this.saving=null;return}if(this.saveData){const r=this.saveData.saveSlot;h9({...r,main:{...r.main,playTime:gu(this.playTime.start,this.playTime.previousPlaytime)},metadata:{...r.metadata,name:((n=this.saving)==null?void 0:n.name)??"Manual Save",saveDate:new Date().toISOString()}},this.saveData.global,e.slotId),this.alert("Success","Game saved!")}else Qt("There was no data to save!");this.saving.resolver(),this.saving=null},playerAnswered(e){S0e(e)},menuReturn(){this.reset(),this.setFlowState("menu")},createError(e){this.errors.push({text:e,type:"error"})},createWarning(e){this.errors.push({text:e,type:"warning"})},clearErrors(){this.errors=[]},setFlowState(e){this.flowState=e},pause(){this.paused=!0},unpause(){this.paused=!1},setOptions(e){this.options=e},startPlaying(){this.playing=!0,this.playTime.start=Date.now()},reset(){this.ready=!1,this.errors=[],this.paused=!1,un().reset(),bo().reset(),this.resetAllStores(),this.playing=!1,this.ready=!0,wn.plugins.forEach(e=>{e.reset&&e.reset()})},resetAllStores(){const e=Ri(),t=yt();Ho().reset(),e.reset(t),Cr().reset(Ka()),za().setupHudStats(t.hudStats),Xr().reset(xp().items),ll().reset(id().achievements),Ao().reset(td()),Bi().reset(yt()),Yn().reset(),wn.customStores().forEach(([l,c])=>{c.reset&&c.reset()})},generateSaveData(){return{playTime:gu(this.playTime.start,this.playTime.previousPlaytime)}},loadSaveData(e){this.playTime.previousPlaytime=e.playTime},autoSaveGame({slotId:e,name:t}){const n=e??this.saveSlot,r=Qh(n),o=Lpe();r&&r.saveData?o.name=r.saveData.metadata.name:o.name=t??"Auto Save",yt().saves.mode==="manual"&&(o.name="Auto Save");const i=Ri(),a=Cr(),s=Yn(),l=un(),c=en(),f=za(),u=bo(),d=Xr(),h=l.generateSaveData(),p=ll(),m={version:c9,screen:i.generateSaveData(),skills:a.generateSaveData(),dialog:s.generateSaveData(),vm:h.vmSave,main:c.generateSaveData(),hud:f.generateSaveData(),audio:u.generateSaveData(),inventory:d.generateSaveData(),quests:Ao().generateSaveData(),metadata:o,settings:Bi().generateSaveData(),screenObjects:Ho().generateSaveData(),config:ni().generateSaveData()};wn.plugins.forEach(g=>{g.save&&(m[g.pluginId]=g.save())}),wn.customStores().forEach(([g,y])=>{if(y.save){const w=y.save();w&&(m[g]=w)}});const v=al().globalSave;v.data=h.globalData,v.achievements=p.generateSaveData(),this.saveData={saveSlot:m,global:v},h9(m,v,this.saveSlot)},loadGlobalData(){const e=al().globalSave;ll().loadSaveData(e.achievements)},setLoadedData(e){const t=Ri(),n=Cr(),r=Yn(),o=un(),i=en(),a=za(),s=bo(),l=Xr();this.loadGlobalData(),Ho().loadSaveData(e.screenObjects),ni().loadSaveData(e.config),t.loadSaveData(e.screen),n.loadSaveData(e.skills),r.loadSaveData(e.dialog),o.loadSaveData(e.vm,al().globalSave),i.loadSaveData(e.main),a.loadSaveData(e.hud),s.loadSaveData(e.audio),l.loadSaveData(e.inventory),Bi().loadSaveData(e.settings),Ao().loadSaveData(e.quests),wn.plugins.forEach(c=>{c.load&&e[c.pluginId]&&c.load(e[c.pluginId])}),wn.customStores().forEach(([c,f])=>{f.load&&f.load(e[c])})},getAllStates(){return{main:this,screens:Ri(),skills:Cr(),dialog:Yn(),vm:un(),hud:za(),audio:bo(),rendering:ii(),notifications:oi(),inventory:Xr(),quests:Ao(),sprites:Ho(),settings:Bi()}},overrideStates(e){const t=this.getAllStates();for(const n in e){const r=e[n];Object.assign(t[n],r)}},exitGame(){window.close()}},getters:{isInGame(e){return e.flowState==="playing"},totalPlayTime(e){return gu(e.playTime.start,e.playTime.previousPlaytime)},sessionPlayTime(e){return gu(e.playTime.start,0)}}});function T0e(e,t,n){console.error(`Parser error: ${e.fileName}:${e.currentLine}`,n);const r=`[Parser Error] in <span class="error-filename">${e.fileName}:${t+1}</span> - <b>${n}</b>`;Qt(r)}function Qt(e,...t){const n=en();console.error(e,...t),e=e.replace(/[\r\n]/g,`
|
|
209
|
+
Label: ${((r=n.currentFrame)==null?void 0:r.label)||"none"}`)}}async function j0e(e,t){const n=e.command,r=wn.commands[n.commandType];if(r){const o={args:[],options:{},operator:n.operator,staticOptions:n.staticOptions,code:e.code,commandType:n.commandType,fileName:e.fileName,line:e.line},i=r.argTypes;o.options={};for(const[a,s]of n.args.entries()){let l;if(G9(s))l=await c0(s,t);else if(typeof s=="string")if(s.search(p9)===0)l=Cs(s.substring(3));else if(J9(s)){const c=ad(),f=gwe(c,s);if(f){const[u,d]=f;l=u[d]}else l=s}else l=s;else l=s;if(o.args.push(l),Array.isArray(i)&&i.length>a){const c=i[a];l!==null&&(o.options[c.name]=l)}}return o}else throw new Error(`${n.commandType} is not a valid command`)}async function c0(e,t){const n=await j0e(e,t),r=wn.commands[n.commandType];if(r)return await r.run(n,t);throw new Error(`${n.commandType} is not a valid command`)}async function S0e(e){ru("onPlayerAnswered");const t=un(),n=t.popAnswerQueue(),r=t.currentLine;try{if(n){const o=wn.commands[n.commandType];if(o)return await o.processPlayerAnswer(n,e)}}catch(o){console.error(o),Qt(`Error after player answer at ${r.fileName}:${r.line+1} (${r.code}<br /> - Error: ${o}`)}}const za=co("hud",{state:()=>({hudStats:{}}),actions:{setupHudStats(e){for(const t in e)this.hudStats[t]={value:e[t].startingValue}},reset(e){this.$reset(),this.setupHudStats(e)},setStat(e,t){this.hudStats[e].value=t},addStat(e,t){this.hudStats[e].value+=t},getStat(e){return this.hudStats[e]},getStatValue(e){return this.hudStats[e].value},generateSaveData(){return{hudStats:sr(this.hudStats)}},loadSaveData(e){this.hudStats=Zh(this.hudStats,e.hudStats)}}}),Ao=co("quests",{state:()=>({quests:{}}),actions:{getQuest(e){const t=this.quests[e];if(t)return t;{const n=`Quest ${e} doesn't exist!`;throw Qt(n),new Error(n)}},getObjective(e,t){const n=this.getQuest(e);if(!n){const i=`Quest ${e} doesn't exist!`;throw Qt(i),new Error(i)}const r=n.objectives[t];if(r)return r;const o=`Objective ${t} doesn't exist in quest ${e}!`;throw Qt(o),new Error(o)},setupQuests(e){const t=e.quests;for(const n of Object.keys(t)){const r=t[n];this.quests[n]={id:n,state:"hidden",objectives:{}};for(const o of Object.keys(r.objectives)){const i=r.objectives[o];this.quests[n].objectives[o]={id:o,state:i.hidden?"hidden":"unlocked"}}}},reset(e){this.$reset(),this.setupQuests(e)},startQuest(e){const t=this.getQuest(e);t?(t.state="unlocked",oi().addNotification(`Started quest: ${cc(e).title}`)):Qt(`Quest ${e} doesn't exist!`)},startObjective(e,t){const n=this.getObjective(e,t);n?(n.state="unlocked",oi().addNotification(`New quest objective: ${_p(e,t).description}`)):Qt(`Objective ${t} doesn't exist in quest ${e}!`)},completeObjective(e,t){const n=this.getObjective(e,t);n?(n.state="completed",oi().addNotification(`Completed quest objective: ${_p(e,t).description}`)):Qt(`Objective ${t} doesn't exist in quest ${e}!`)},completeQuest(e,t){const n=this.getQuest(e);n?(n.state="completed",n.ending=t,oi().addNotification(`Completed quest: ${cc(e).title}`)):Qt(`Quest ${e} doesn't exist!`)},isQuestCompleted(e){const t=this.getQuest(e);return t?t.state==="completed":!1},isObjectiveCompleted(e,t){const n=this.getObjective(e,t);return n?n.state==="completed":!1},isQuestStarted(e){const t=this.getQuest(e);return t&&t.state==="unlocked"},isObjectiveStarted(e,t){return this.getObjective(e,t).state==="unlocked"},removeQuest(e){delete this.quests[e]},generateSaveData(){return{quests:sr(this.quests)}},loadSaveData(e){this.quests=e.quests}}});function j_(e,t,n,r){const o=e/n,i=t/r;return Math.min(o,i)}const ii=co("rendering",{state:()=>({screenHeight:window.innerHeight,screenWidth:window.innerWidth,layoutMode:"horizontal"}),actions:{updateScreenSize(e,t){this.screenHeight=t,this.screenWidth=e,e<yt().layout.verticalLayoutThreshold?(this.layoutMode="vertical",document.querySelector("html").style.fontSize=`${Bi().baseSettings.fontSize}px`??"40px"):(this.layoutMode="horizontal",document.querySelector("html").style.fontSize=`${Bi().baseSettings.fontSize}px`??"16px")}},getters:{gameScaleRatio(e){return j_(this.screenWidth,this.screenHeight,this.gameWidth,this.gameHeight)},overlayMode(e){return!!(yt().dialogPanel.overlayMode&&e.layoutMode==="horizontal")},gameWidth(){const e=yt();return this.layoutMode==="vertical"||this.overlayMode?e.layout.backgrounds.width:e.layout.backgrounds.width+I0()},gameHeight(){const e=yt();return this.layoutMode==="vertical",e.layout.backgrounds.height},dialogWidth(){return this.layoutMode==="vertical"?this.viewportWidth:I0()},dialogHeight(){return this.layoutMode==="vertical"?this.actualGameHeight-this.gameHeight:yt().dialogPanel.height??this.gameHeight},actualGameHeight(){let e=this.gameHeight;return this.layoutMode==="vertical"&&(e=this.screenHeight/this.gameScaleRatio),e},viewportRatio(e){if(this.layoutMode==="vertical"){const t=yt().layout.backgrounds;return e.screenWidth/t.width}return 1},viewportHeight(e){return yt().layout.backgrounds.height*this.viewportRatio},viewportWidth(e){return yt().layout.backgrounds.width*this.viewportRatio},showDialog(e){const t=en().inScript;return!this.overlayMode||this.layoutMode==="vertical"?!0:Ri().isTransitioning?!1:t}}});class S_{constructor(){hr(this,"listeners",{})}on(t,n){return this.listeners[t]||this.addEventToMap(t),this.listeners[t].add(n),n}off(t,n){return this.listeners[t]&&this.listeners[t].delete(n),n}once(t,n){const r=(...o)=>{this.off(t,r),n(...o)};return this.on(t,r)}emit(t,...n){this.listeners[t]&&this.listeners[t].forEach(r=>r(...n))}clear(){Object.keys(this.listeners).forEach(t=>{delete this.listeners[t]})}addEventToMap(t){this.listeners[t]=new Set}}const ai=co("menu",{state:()=>({menus:{},activeMenu:!1}),getters:{showSkills(){return Object.entries(Ka().skills).length>0},showInventory(){return Object.entries(xp().items).length>0},showQuests(){return Object.entries(td().quests).length>0},showAchievements(){return Object.entries(id().achievements).length>0},menuTabsToShow(e){return e.menus.menu.tabs.map(t=>{const n=yt().menuButtons[t.id]||{};return{...t,...n}}).filter(t=>t.condition?t.condition():!0)},menu(e){return e.activeMenu?e.menus[e.activeMenu]:void 0},tab(){if(this.menu)return this.menu.tabs[this.menu.activeTab]}},actions:{setup(){},addMenu(e,t){this.menus[e]={...t,id:e}},addMenuOption(e,t){this.menus[e]||(this.menus[e]={id:e,label:e,tabs:[],activeTab:0}),this.menus[e].tabs.push(t)},setActiveTab(e){this.menu&&(this.menu.activeTab=e)},openMenu(e){this.activeMenu=e},closeMenu(){this.activeMenu=!1},toggleMenu(){this.activeMenu?this.activeMenu=!1:this.activeMenu="menu"}}}),ll=co("achievements",{state:()=>({achievements:{}}),actions:{generateSaveData(){return{achievements:sr(this.achievements)}},loadSaveData(e){this.achievements={...this.achievements,...sr(e.achievements)}},setupAchievements(e){Object.keys(e).forEach(t=>{this.achievements[t]={id:t,unlocked:!1}})},reset(e){this.$reset(),this.setupAchievements(e)},hasAchievement(e){var t;return((t=this.achievements[e])==null?void 0:t.unlocked)??!1},getExistingAchievement(e){return this.achievements[e]},unlock(e){const t=this.getExistingAchievement(e);if(!t){Qt(`Tried to unlock achievement ${e} but it doesn't exist`);return}if(!t.unlocked){const n=new Date().toISOString();t.unlocked=!0,t.unlockTime=n}if(id().notifyNewAchievements){const n=j2(e);oi().addNotification(`New Achievement: ${n.name}`,n.description,n.icon)}}}});function C0e(){return{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1,scripts:[]}}class $0e extends S_{}const en=co("main",{state:()=>({ready:!1,playing:!1,errors:[],playTime:{start:0,previousPlaytime:0},saveSlot:"",flowState:"engine-splash",paused:!1,debugMode:!0,options:{baseAssetsPath:"",baseDataPath:"",configPath:"data/config.json",logging:!1,debug:!1,scripts:[]},loading:{step:"Loading",percentage:.1,loaded:!1},alerts:[],saving:null,listener:new $0e,inScript:!1}),actions:{async setup(){const t=yt().scripts;bo().setMasterVolume(da().options.volume??1),await un().loadScripts(t),ai().setup();for(const[,n]of wn.customStores())if(n.setup){const r=n.setup();Khe(r)&&await r}wn.addCustomSettings(),this.resetAllStores()},async engineLoading(){const e=Tpe(yt()),t=xpe(da());if(wn.plugins){const n=[];for(const r of wn.plugins)r.loadingPromises&&n.push(Promise.all(r.loadingPromises));n.length>0&&(this.loading.step="Plugins",this.loading.percentage=.3,await Promise.all(n))}this.loading.step="Images",await e,this.loading.percentage=.7,this.loading.step="Audio",await t,wn.callHook("onAssetsLoaded"),this.loading.percentage=.95,this.loading.step="Starting...",await this.setup(),wn.callHook("onGameSetup"),this.loading.loaded=!0,this.listener.emit("gameLoaded")},async alert(e,t){return new Promise(n=>{this.alerts.push({title:e,text:t,resolver:n,id:ou()})})},closeAlert(e){const t=this.alerts.findIndex(n=>n.id===e);t!==-1&&(this.alerts[t].resolver(),this.alerts.splice(t,1))},startingScript(){Xr().onScriptStart(),this.inScript=!0},endingScript(){Xr().onScriptEnd(),this.inScript=!1},startMachine(){bo().stopAll(),ru("onPressStart"),un().start(),this.ready=!0,this.startPlaying(),wn.callHook("onGameStart"),this.setFlowState("playing")},setSaveSlot(e){this.saveSlot=e,Mpe(e)},async startGame(e){if(yt().saves.mode==="manual"){const t=n_();t&&(e=t.id)}this.setSaveSlot(e),this.loadGlobalData(),this.startMachine(),un().runGame()},async loadGame(e,t){if(yt().saves.mode==="manual"){const n=n_();n&&(t=n.id)}if(this.setSaveSlot(t),this.startMachine(),e.saveData){this.setLoadedData(e.saveData),bo().reloadAudio(e.saveData.audio);const n=un(),r=yt().saves.runOnReload;typeof r=="string"&&await un().runLabelFunction(r),n.jumpToLabel(e.saveData.vm.lastLabel)}},manualSave({saveName:e,withPrompt:t}){return new Promise(n=>{un().hasJumped?this.saving={name:e,withPrompt:t,resolver:n}:n()})},resetGlobalSave(){un().globalData={},al().globalSave.data={},this.autoSaveGame({})},finishManualSave(e,t){var n;if(!this.saving){Qt("Trying to save but there is no saving request!");return}if(!t||!e){this.saving.resolver(),this.saving=null;return}if(this.saveData){const r=this.saveData.saveSlot;h9({...r,main:{...r.main,playTime:gu(this.playTime.start,this.playTime.previousPlaytime)},metadata:{...r.metadata,name:((n=this.saving)==null?void 0:n.name)??"Manual Save",saveDate:new Date().toISOString()}},this.saveData.global,e.slotId),this.alert("Success","Game saved!")}else Qt("There was no data to save!");this.saving.resolver(),this.saving=null},playerAnswered(e){S0e(e)},menuReturn(){this.reset(),this.setFlowState("menu")},createError(e){this.errors.push({text:e,type:"error"})},createWarning(e){this.errors.push({text:e,type:"warning"})},clearErrors(){this.errors=[]},setFlowState(e){this.flowState=e},pause(){this.paused=!0},unpause(){this.paused=!1},setOptions(e){this.options=e},startPlaying(){this.playing=!0,this.playTime.start=Date.now()},reset(){this.ready=!1,this.errors=[],this.paused=!1,un().reset(),bo().reset(),this.resetAllStores(),this.playing=!1,this.ready=!0,wn.plugins.forEach(e=>{e.reset&&e.reset()})},resetAllStores(){const e=Ri(),t=yt();Ho().reset(),e.reset(t),Cr().reset(Ka()),za().setupHudStats(t.hudStats),Xr().reset(xp().items),ll().reset(id().achievements),Ao().reset(td()),Bi().reset(yt()),Yn().reset(),wn.customStores().forEach(([l,c])=>{c.reset&&c.reset()})},generateSaveData(){return{playTime:gu(this.playTime.start,this.playTime.previousPlaytime)}},loadSaveData(e){this.playTime.previousPlaytime=e.playTime},autoSaveGame({slotId:e,name:t}){const n=e??this.saveSlot,r=Qh(n),o=Lpe();r&&r.saveData?o.name=r.saveData.metadata.name:o.name=t??"Auto Save",yt().saves.mode==="manual"&&(o.name="Auto Save");const i=Ri(),a=Cr(),s=Yn(),l=un(),c=en(),f=za(),u=bo(),d=Xr(),h=l.generateSaveData(),p=ll(),m={version:c9,screen:i.generateSaveData(),skills:a.generateSaveData(),dialog:s.generateSaveData(),vm:h.vmSave,main:c.generateSaveData(),hud:f.generateSaveData(),audio:u.generateSaveData(),inventory:d.generateSaveData(),quests:Ao().generateSaveData(),metadata:o,settings:Bi().generateSaveData(),screenObjects:Ho().generateSaveData(),config:ni().generateSaveData()};wn.plugins.forEach(g=>{g.save&&(m[g.pluginId]=g.save())}),wn.customStores().forEach(([g,y])=>{if(y.save){const w=y.save();w&&(m[g]=w)}});const v=al().globalSave;v.data=h.globalData,v.achievements=p.generateSaveData(),this.saveData={saveSlot:m,global:v},h9(m,v,this.saveSlot)},loadGlobalData(){const e=al().globalSave;ll().loadSaveData(e.achievements)},setLoadedData(e){const t=Ri(),n=Cr(),r=Yn(),o=un(),i=en(),a=za(),s=bo(),l=Xr();this.loadGlobalData(),Ho().loadSaveData(e.screenObjects),ni().loadSaveData(e.config),t.loadSaveData(e.screen),n.loadSaveData(e.skills),r.loadSaveData(e.dialog),o.loadSaveData(e.vm,al().globalSave),i.loadSaveData(e.main),a.loadSaveData(e.hud),s.loadSaveData(e.audio),l.loadSaveData(e.inventory),Bi().loadSaveData(e.settings),Ao().loadSaveData(e.quests),wn.plugins.forEach(c=>{c.load&&e[c.pluginId]&&c.load(e[c.pluginId])}),wn.customStores().forEach(([c,f])=>{f.load&&f.load(e[c])})},getAllStates(){return{main:this,screens:Ri(),skills:Cr(),dialog:Yn(),vm:un(),hud:za(),audio:bo(),rendering:ii(),notifications:oi(),inventory:Xr(),quests:Ao(),sprites:Ho(),settings:Bi()}},overrideStates(e){const t=this.getAllStates();for(const n in e){const r=e[n];Object.assign(t[n],r)}},exitGame(){window.close()}},getters:{isInGame(e){return e.flowState==="playing"},totalPlayTime(e){return gu(e.playTime.start,e.playTime.previousPlaytime)},sessionPlayTime(e){return gu(e.playTime.start,0)}}});function T0e(e,t,n){console.error(`Parser error: ${e.fileName}:${e.currentLine}`,n);const r=`[Parser Error] in <span class="error-filename">${e.fileName}:${t+1}</span> - <b>${n}</b>`;Qt(r)}function Qt(e,...t){const n=en();console.error(e,...t),e=e.replace(/[\r\n]/g,`
|
|
210
210
|
<br />`),n.createError(`❌ ${e}`)}function su(e,...t){const n=en();console.warn(e,...t),e=e.replace(/[\r\n]/g,`
|
|
211
211
|
<br />`),n.createWarning(`⚠️ ${e}`)}const E0e=K.Type.Optional(K.Type.Object({animateText:K.Type.Optional(K.Type.Boolean()),textSpeed:K.Type.Optional(K.Type.Number()),timeBetweenLines:K.Type.Optional(K.Type.Number()),overlayMode:K.Type.Optional(K.Type.Boolean()),rightOffset:K.Type.Optional(K.Type.Number()),bottomOffset:K.Type.Optional(K.Type.Number()),width:K.Type.Optional(K.Type.Number()),height:K.Type.Optional(K.Type.Number())})),O0e=K.Type.Object({engineSplashScreen:K.Type.Optional(K.Type.Object({skip:K.Type.Optional(K.Type.Boolean()),fadeDuration:K.Type.Optional(K.Type.Number()),timeBeforeFadeout:K.Type.Optional(K.Type.Number()),overrideText:K.Type.Optional(K.Type.String()),overrideLogo:K.Type.Optional(K.Type.String())})),gameSplashScreen:K.Type.Optional(K.Type.Object({startButtonText:K.Type.Optional(K.Type.String())}))}),A0e=K.Type.Object({timeOnScreen:K.Type.Number(),alsoPrintInDialogue:K.Type.Optional(K.Type.Boolean())}),M0e=K.Type.Object({name:K.Type.String(),icon:K.Type.String(),startingValue:K.Type.Number(),maxValue:K.Type.Optional(K.Type.Number()),minValue:K.Type.Optional(K.Type.Number())}),P0e=K.Type.Record(K.Type.String(),M0e),N0e=K.Type.Record(K.Type.String(),K.Type.Object({onlyInteractOutsideOfScripts:K.Type.Optional(K.Type.Boolean())})),I0e=K.Type.Object({delay:K.Type.Optional(K.Type.Number()),duration:K.Type.Optional(K.Type.Number())}),D0e=K.Type.Record(K.Type.String(),I0e),L0e=K.Type.Object({text:K.Type.String(),cssClass:K.Type.Optional(K.Type.String())}),R0e=K.Type.Record(K.Type.String(),L0e),B0e=K.Type.Object({showScriptFinishedMessage:K.Type.Optional(K.Type.Boolean())}),F0e=K.Type.Object({mode:K.Type.String(),slots:K.Type.Number(),runOnReload:K.Type.Optional(K.Type.String())}),cF=K.Type.Array(K.Type.String()),V0e=[],u0=K.Type.Object({name:K.Type.String(),description:K.Type.Optional(K.Type.String())}),z0e=K.Type.Intersect([u0,K.Type.Object({type:K.Type.Literal("number"),defaultValue:K.Type.Number(),step:K.Type.Number(),minValue:K.Type.Number(),maxValue:K.Type.Number()})]),q0e=K.Type.Intersect([u0,K.Type.Object({type:K.Type.Literal("integer"),defaultValue:K.Type.Number(),step:K.Type.Number(),minValue:K.Type.Number(),maxValue:K.Type.Number()})]),U0e=K.Type.Intersect([u0,K.Type.Object({type:K.Type.Literal("boolean"),defaultValue:K.Type.Boolean()})]),H0e=K.Type.Intersect([u0,K.Type.Object({type:K.Type.Literal("string"),defaultValue:K.Type.String()})]),W0e=K.Type.Union([z0e,q0e,U0e,H0e]);function K0e(e){return e.type==="number"}function uF(e){return e.type==="integer"}function G0e(e){return e.type==="boolean"}function J0e(e){return e.type==="string"}const Q0e=K.Type.Object({customSettings:K.Type.Optional(K.Type.Record(K.Type.String(),W0e))}),C_=K.Type.Object({baseAssetsPath:K.Type.Optional(K.Type.String()),baseDataPath:K.Type.Optional(K.Type.String()),gameTitle:K.Type.String(),saveFileName:K.Type.String(),images:K.Type.Optional(K.Type.Record(K.Type.String(),K.Type.String())),layout:bme,settings:K.Type.Optional(Q0e),gameFlow:K.Type.Optional(K.Type.Object({labelToJumpOnScriptEnd:K.Type.Optional(K.Type.String())})),dialogPanel:K.Type.Optional(E0e),splashScreens:K.Type.Optional(O0e),screens:K.Type.Union([K.Type.String(),E9]),buttons:K.Type.Optional(K.Type.Union([K.Type.String(),C9])),skills:K.Type.Optional(K.Type.Union([K.Type.String(),P9])),skillChecks:K.Type.Optional(K.Type.Union([K.Type.String(),q9])),scripts:K.Type.Optional(K.Type.Union([K.Type.String(),cF])),audio:K.Type.Union([K.Type.String(),g9]),notifications:K.Type.Optional(A0e),tooltips:K.Type.Optional(K.Type.Union([K.Type.String(),R9])),hudStats:P0e,items:K.Type.Optional(K.Type.Union([K.Type.String(),k9])),achievements:K.Type.Optional(K.Type.String()),interactionTags:K.Type.Optional(N0e),quests:K.Type.Optional(K.Type.Union([K.Type.String(),_9])),transitions:K.Type.Optional(D0e),menuButtons:K.Type.Optional(R0e),debugging:K.Type.Optional(B0e),saves:K.Type.Optional(F0e),characters:K.Type.Union([K.Type.String(),D9])});var $_={exports:{}},fF={},qa={},Wf={},ap={},Fn={},sp={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class n extends t{constructor(y){if(super(),!e.IDENTIFIER.test(y))throw new Error("CodeGen: name must be a valid identifier");this.str=y}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=n;class r extends t{constructor(y){super(),this._items=typeof y=="string"?[y]:y}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const y=this._items[0];return y===""||y==='""'}get str(){var y;return(y=this._str)!==null&&y!==void 0?y:this._str=this._items.reduce((w,k)=>`${w}${k}`,"")}get names(){var y;return(y=this._names)!==null&&y!==void 0?y:this._names=this._items.reduce((w,k)=>(k instanceof n&&(w[k.str]=(w[k.str]||0)+1),w),{})}}e._Code=r,e.nil=new r("");function o(g,...y){const w=[g[0]];let k=0;for(;k<y.length;)s(w,y[k]),w.push(g[++k]);return new r(w)}e._=o;const i=new r("+");function a(g,...y){const w=[h(g[0])];let k=0;for(;k<y.length;)w.push(i),s(w,y[k]),w.push(i,h(g[++k]));return l(w),new r(w)}e.str=a;function s(g,y){y instanceof r?g.push(...y._items):y instanceof n?g.push(y):g.push(u(y))}e.addCodeArg=s;function l(g){let y=1;for(;y<g.length-1;){if(g[y]===i){const w=c(g[y-1],g[y+1]);if(w!==void 0){g.splice(y-1,3,w);continue}g[y++]="+"}y++}}function c(g,y){if(y==='""')return g;if(g==='""')return y;if(typeof g=="string")return y instanceof n||g[g.length-1]!=='"'?void 0:typeof y!="string"?`${g.slice(0,-1)}${y}"`:y[0]==='"'?g.slice(0,-1)+y.slice(1):void 0;if(typeof y=="string"&&y[0]==='"'&&!(g instanceof n))return`"${g}${y.slice(1)}`}function f(g,y){return y.emptyStr()?g:g.emptyStr()?y:a`${g}${y}`}e.strConcat=f;function u(g){return typeof g=="number"||typeof g=="boolean"||g===null?g:h(Array.isArray(g)?g.join(","):g)}function d(g){return new r(h(g))}e.stringify=d;function h(g){return JSON.stringify(g).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=h;function p(g){return typeof g=="string"&&e.IDENTIFIER.test(g)?new r(`.${g}`):o`[${g}]`}e.getProperty=p;function m(g){if(typeof g=="string"&&e.IDENTIFIER.test(g))return new r(`${g}`);throw new Error(`CodeGen: invalid export name: ${g}, use explicit $id name mapping`)}e.getEsmExportName=m;function v(g){return new r(g.toString())}e.regexpCode=v})(sp);var T_={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=sp;class n extends Error{constructor(c){super(`CodeGen: "code" for ${c} not defined`),this.value=c.value}}var r;(function(l){l[l.Started=0]="Started",l[l.Completed=1]="Completed"})(r=e.UsedValueState||(e.UsedValueState={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class o{constructor({prefixes:c,parent:f}={}){this._names={},this._prefixes=c,this._parent=f}toName(c){return c instanceof t.Name?c:this.name(c)}name(c){return new t.Name(this._newName(c))}_newName(c){const f=this._names[c]||this._nameGroup(c);return`${c}${f.index++}`}_nameGroup(c){var f,u;if(!((u=(f=this._parent)===null||f===void 0?void 0:f._prefixes)===null||u===void 0)&&u.has(c)||this._prefixes&&!this._prefixes.has(c))throw new Error(`CodeGen: prefix "${c}" is not allowed in this scope`);return this._names[c]={prefix:c,index:0}}}e.Scope=o;class i extends t.Name{constructor(c,f){super(f),this.prefix=c}setValue(c,{property:f,itemIndex:u}){this.value=c,this.scopePath=(0,t._)`.${new t.Name(f)}[${u}]`}}e.ValueScopeName=i;const a=(0,t._)`\n`;class s extends o{constructor(c){super(c),this._values={},this._scope=c.scope,this.opts={...c,_n:c.lines?a:t.nil}}get(){return this._scope}name(c){return new i(c,this._newName(c))}value(c,f){var u;if(f.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const d=this.toName(c),{prefix:h}=d,p=(u=f.key)!==null&&u!==void 0?u:f.ref;let m=this._values[h];if(m){const y=m.get(p);if(y)return y}else m=this._values[h]=new Map;m.set(p,d);const v=this._scope[h]||(this._scope[h]=[]),g=v.length;return v[g]=f.ref,d.setValue(f,{property:h,itemIndex:g}),d}getValue(c,f){const u=this._values[c];if(u)return u.get(f)}scopeRefs(c,f=this._values){return this._reduceValues(f,u=>{if(u.scopePath===void 0)throw new Error(`CodeGen: name "${u}" has no value`);return(0,t._)`${c}${u.scopePath}`})}scopeCode(c=this._values,f,u){return this._reduceValues(c,d=>{if(d.value===void 0)throw new Error(`CodeGen: name "${d}" has no value`);return d.value.code},f,u)}_reduceValues(c,f,u={},d){let h=t.nil;for(const p in c){const m=c[p];if(!m)continue;const v=u[p]=u[p]||new Map;m.forEach(g=>{if(v.has(g))return;v.set(g,r.Started);let y=f(g);if(y){const w=this.opts.es5?e.varKinds.var:e.varKinds.const;h=(0,t._)`${h}${w} ${g} = ${y};${this.opts._n}`}else if(y=d==null?void 0:d(g))h=(0,t._)`${h}${y}${this.opts._n}`;else throw new n(g);v.set(g,r.Completed)})}return h}}e.ValueScope=s})(T_),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=sp,n=T_;var r=sp;Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return r.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return r.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return r.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}});var o=T_;Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class i{optimizeNodes(){return this}optimizeNames(O,E){return this}}class a extends i{constructor(O,E,G){super(),this.varKind=O,this.name=E,this.rhs=G}render({es5:O,_n:E}){const G=O?n.varKinds.var:this.varKind,re=this.rhs===void 0?"":` = ${this.rhs}`;return`${G} ${this.name}${re};`+E}optimizeNames(O,E){if(O[this.name.str])return this.rhs&&(this.rhs=$(this.rhs,O,E)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class s extends i{constructor(O,E,G){super(),this.lhs=O,this.rhs=E,this.sideEffects=G}render({_n:O}){return`${this.lhs} = ${this.rhs};`+O}optimizeNames(O,E){if(!(this.lhs instanceof t.Name&&!O[this.lhs.str]&&!this.sideEffects))return this.rhs=$(this.rhs,O,E),this}get names(){const O=this.lhs instanceof t.Name?{}:{...this.lhs.names};return B(O,this.rhs)}}class l extends s{constructor(O,E,G,re){super(O,G,re),this.op=E}render({_n:O}){return`${this.lhs} ${this.op}= ${this.rhs};`+O}}class c extends i{constructor(O){super(),this.label=O,this.names={}}render({_n:O}){return`${this.label}:`+O}}class f extends i{constructor(O){super(),this.label=O,this.names={}}render({_n:O}){return`break${this.label?` ${this.label}`:""};`+O}}class u extends i{constructor(O){super(),this.error=O}render({_n:O}){return`throw ${this.error};`+O}get names(){return this.error.names}}class d extends i{constructor(O){super(),this.code=O}render({_n:O}){return`${this.code};`+O}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(O,E){return this.code=$(this.code,O,E),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class h extends i{constructor(O=[]){super(),this.nodes=O}render(O){return this.nodes.reduce((E,G)=>E+G.render(O),"")}optimizeNodes(){const{nodes:O}=this;let E=O.length;for(;E--;){const G=O[E].optimizeNodes();Array.isArray(G)?O.splice(E,1,...G):G?O[E]=G:O.splice(E,1)}return O.length>0?this:void 0}optimizeNames(O,E){const{nodes:G}=this;let re=G.length;for(;re--;){const me=G[re];me.optimizeNames(O,E)||(F(O,me.names),G.splice(re,1))}return G.length>0?this:void 0}get names(){return this.nodes.reduce((O,E)=>D(O,E.names),{})}}class p extends h{render(O){return"{"+O._n+super.render(O)+"}"+O._n}}class m extends h{}class v extends p{}v.kind="else";class g extends p{constructor(O,E){super(E),this.condition=O}render(O){let E=`if(${this.condition})`+super.render(O);return this.else&&(E+="else "+this.else.render(O)),E}optimizeNodes(){super.optimizeNodes();const O=this.condition;if(O===!0)return this.nodes;let E=this.else;if(E){const G=E.optimizeNodes();E=this.else=Array.isArray(G)?new v(G):G}if(E)return O===!1?E instanceof g?E:E.nodes:this.nodes.length?this:new g(H(O),E instanceof g?[E]:E.nodes);if(!(O===!1||!this.nodes.length))return this}optimizeNames(O,E){var G;if(this.else=(G=this.else)===null||G===void 0?void 0:G.optimizeNames(O,E),!!(super.optimizeNames(O,E)||this.else))return this.condition=$(this.condition,O,E),this}get names(){const O=super.names;return B(O,this.condition),this.else&&D(O,this.else.names),O}}g.kind="if";class y extends p{}y.kind="for";class w extends y{constructor(O){super(),this.iteration=O}render(O){return`for(${this.iteration})`+super.render(O)}optimizeNames(O,E){if(super.optimizeNames(O,E))return this.iteration=$(this.iteration,O,E),this}get names(){return D(super.names,this.iteration.names)}}class k extends y{constructor(O,E,G,re){super(),this.varKind=O,this.name=E,this.from=G,this.to=re}render(O){const E=O.es5?n.varKinds.var:this.varKind,{name:G,from:re,to:me}=this;return`for(${E} ${G}=${re}; ${G}<${me}; ${G}++)`+super.render(O)}get names(){const O=B(super.names,this.from);return B(O,this.to)}}class C extends y{constructor(O,E,G,re){super(),this.loop=O,this.varKind=E,this.name=G,this.iterable=re}render(O){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(O)}optimizeNames(O,E){if(super.optimizeNames(O,E))return this.iterable=$(this.iterable,O,E),this}get names(){return D(super.names,this.iterable.names)}}class j extends p{constructor(O,E,G){super(),this.name=O,this.args=E,this.async=G}render(O){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(O)}}j.kind="func";class P extends h{render(O){return"return "+super.render(O)}}P.kind="return";class R extends p{render(O){let E="try"+super.render(O);return this.catch&&(E+=this.catch.render(O)),this.finally&&(E+=this.finally.render(O)),E}optimizeNodes(){var O,E;return super.optimizeNodes(),(O=this.catch)===null||O===void 0||O.optimizeNodes(),(E=this.finally)===null||E===void 0||E.optimizeNodes(),this}optimizeNames(O,E){var G,re;return super.optimizeNames(O,E),(G=this.catch)===null||G===void 0||G.optimizeNames(O,E),(re=this.finally)===null||re===void 0||re.optimizeNames(O,E),this}get names(){const O=super.names;return this.catch&&D(O,this.catch.names),this.finally&&D(O,this.finally.names),O}}class A extends p{constructor(O){super(),this.error=O}render(O){return`catch(${this.error})`+super.render(O)}}A.kind="catch";class x extends p{render(O){return"finally"+super.render(O)}}x.kind="finally";class S{constructor(O,E={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...E,_n:E.lines?`
|
|
212
212
|
`:""},this._extScope=O,this._scope=new n.Scope({parent:O}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(O){return this._scope.name(O)}scopeName(O){return this._extScope.name(O)}scopeValue(O,E){const G=this._extScope.value(O,E);return(this._values[G.prefix]||(this._values[G.prefix]=new Set)).add(G),G}getScopeValue(O,E){return this._extScope.getValue(O,E)}scopeRefs(O){return this._extScope.scopeRefs(O,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(O,E,G,re){const me=this._scope.toName(E);return G!==void 0&&re&&(this._constants[me.str]=G),this._leafNode(new a(O,me,G)),me}const(O,E,G){return this._def(n.varKinds.const,O,E,G)}let(O,E,G){return this._def(n.varKinds.let,O,E,G)}var(O,E,G){return this._def(n.varKinds.var,O,E,G)}assign(O,E,G){return this._leafNode(new s(O,E,G))}add(O,E){return this._leafNode(new l(O,e.operators.ADD,E))}code(O){return typeof O=="function"?O():O!==t.nil&&this._leafNode(new d(O)),this}object(...O){const E=["{"];for(const[G,re]of O)E.length>1&&E.push(","),E.push(G),(G!==re||this.opts.es5)&&(E.push(":"),(0,t.addCodeArg)(E,re));return E.push("}"),new t._Code(E)}if(O,E,G){if(this._blockNode(new g(O)),E&&G)this.code(E).else().code(G).endIf();else if(E)this.code(E).endIf();else if(G)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(O){return this._elseNode(new g(O))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(g,v)}_for(O,E){return this._blockNode(O),E&&this.code(E).endFor(),this}for(O,E){return this._for(new w(O),E)}forRange(O,E,G,re,me=this.opts.es5?n.varKinds.var:n.varKinds.let){const je=this._scope.toName(O);return this._for(new k(me,je,E,G),()=>re(je))}forOf(O,E,G,re=n.varKinds.const){const me=this._scope.toName(O);if(this.opts.es5){const je=E instanceof t.Name?E:this.var("_arr",E);return this.forRange("_i",0,(0,t._)`${je}.length`,Ee=>{this.var(me,(0,t._)`${je}[${Ee}]`),G(me)})}return this._for(new C("of",re,me,E),()=>G(me))}forIn(O,E,G,re=this.opts.es5?n.varKinds.var:n.varKinds.const){if(this.opts.ownProperties)return this.forOf(O,(0,t._)`Object.keys(${E})`,G);const me=this._scope.toName(O);return this._for(new C("in",re,me,E),()=>G(me))}endFor(){return this._endBlockNode(y)}label(O){return this._leafNode(new c(O))}break(O){return this._leafNode(new f(O))}return(O){const E=new P;if(this._blockNode(E),this.code(O),E.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(P)}try(O,E,G){if(!E&&!G)throw new Error('CodeGen: "try" without "catch" and "finally"');const re=new R;if(this._blockNode(re),this.code(O),E){const me=this.name("e");this._currNode=re.catch=new A(me),E(me)}return G&&(this._currNode=re.finally=new x,this.code(G)),this._endBlockNode(A,x)}throw(O){return this._leafNode(new u(O))}block(O,E){return this._blockStarts.push(this._nodes.length),O&&this.code(O).endBlock(E),this}endBlock(O){const E=this._blockStarts.pop();if(E===void 0)throw new Error("CodeGen: not in self-balancing block");const G=this._nodes.length-E;if(G<0||O!==void 0&&G!==O)throw new Error(`CodeGen: wrong number of nodes: ${G} vs ${O} expected`);return this._nodes.length=E,this}func(O,E=t.nil,G,re){return this._blockNode(new j(O,E,G)),re&&this.code(re).endFunc(),this}endFunc(){return this._endBlockNode(j)}optimize(O=1){for(;O-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(O){return this._currNode.nodes.push(O),this}_blockNode(O){this._currNode.nodes.push(O),this._nodes.push(O)}_endBlockNode(O,E){const G=this._currNode;if(G instanceof O||E&&G instanceof E)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${E?`${O.kind}/${E.kind}`:O.kind}"`)}_elseNode(O){const E=this._currNode;if(!(E instanceof g))throw new Error('CodeGen: "else" without "if"');return this._currNode=E.else=O,this}get _root(){return this._nodes[0]}get _currNode(){const O=this._nodes;return O[O.length-1]}set _currNode(O){const E=this._nodes;E[E.length-1]=O}}e.CodeGen=S;function D(T,O){for(const E in O)T[E]=(T[E]||0)+(O[E]||0);return T}function B(T,O){return O instanceof t._CodeOrName?D(T,O.names):T}function $(T,O,E){if(T instanceof t.Name)return G(T);if(!re(T))return T;return new t._Code(T._items.reduce((me,je)=>(je instanceof t.Name&&(je=G(je)),je instanceof t._Code?me.push(...je._items):me.push(je),me),[]));function G(me){const je=E[me.str];return je===void 0||O[me.str]!==1?me:(delete O[me.str],je)}function re(me){return me instanceof t._Code&&me._items.some(je=>je instanceof t.Name&&O[je.str]===1&&E[je.str]!==void 0)}}function F(T,O){for(const E in O)T[E]=(T[E]||0)-(O[E]||0)}function H(T){return typeof T=="boolean"||typeof T=="number"||T===null?!T:(0,t._)`!${I(T)}`}e.not=H;const q=L(e.operators.AND);function U(...T){return T.reduce(q)}e.and=U;const N=L(e.operators.OR);function M(...T){return T.reduce(N)}e.or=M;function L(T){return(O,E)=>O===t.nil?E:E===t.nil?O:(0,t._)`${I(O)} ${T} ${I(E)}`}function I(T){return T instanceof t.Name?T:(0,t._)`(${T})`}}(Fn);var Xn={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;const t=Fn,n=sp;function r(j){const P={};for(const R of j)P[R]=!0;return P}e.toHash=r;function o(j,P){return typeof P=="boolean"?P:Object.keys(P).length===0?!0:(i(j,P),!a(P,j.self.RULES.all))}e.alwaysValidSchema=o;function i(j,P=j.schema){const{opts:R,self:A}=j;if(!R.strictSchema||typeof P=="boolean")return;const x=A.RULES.keywords;for(const S in P)x[S]||C(j,`unknown keyword: "${S}"`)}e.checkUnknownRules=i;function a(j,P){if(typeof j=="boolean")return!j;for(const R in j)if(P[R])return!0;return!1}e.schemaHasRules=a;function s(j,P){if(typeof j=="boolean")return!j;for(const R in j)if(R!=="$ref"&&P.all[R])return!0;return!1}e.schemaHasRulesButRef=s;function l({topSchemaRef:j,schemaPath:P},R,A,x){if(!x){if(typeof R=="number"||typeof R=="boolean")return R;if(typeof R=="string")return(0,t._)`${R}`}return(0,t._)`${j}${P}${(0,t.getProperty)(A)}`}e.schemaRefOrVal=l;function c(j){return d(decodeURIComponent(j))}e.unescapeFragment=c;function f(j){return encodeURIComponent(u(j))}e.escapeFragment=f;function u(j){return typeof j=="number"?`${j}`:j.replace(/~/g,"~0").replace(/\//g,"~1")}e.escapeJsonPointer=u;function d(j){return j.replace(/~1/g,"/").replace(/~0/g,"~")}e.unescapeJsonPointer=d;function h(j,P){if(Array.isArray(j))for(const R of j)P(R);else P(j)}e.eachItem=h;function p({mergeNames:j,mergeToName:P,mergeValues:R,resultToName:A}){return(x,S,D,B)=>{const $=D===void 0?S:D instanceof t.Name?(S instanceof t.Name?j(x,S,D):P(x,S,D),D):S instanceof t.Name?(P(x,D,S),S):R(S,D);return B===t.Name&&!($ instanceof t.Name)?A(x,$):$}}e.mergeEvaluated={props:p({mergeNames:(j,P,R)=>j.if((0,t._)`${R} !== true && ${P} !== undefined`,()=>{j.if((0,t._)`${P} === true`,()=>j.assign(R,!0),()=>j.assign(R,(0,t._)`${R} || {}`).code((0,t._)`Object.assign(${R}, ${P})`))}),mergeToName:(j,P,R)=>j.if((0,t._)`${R} !== true`,()=>{P===!0?j.assign(R,!0):(j.assign(R,(0,t._)`${R} || {}`),v(j,R,P))}),mergeValues:(j,P)=>j===!0?!0:{...j,...P},resultToName:m}),items:p({mergeNames:(j,P,R)=>j.if((0,t._)`${R} !== true && ${P} !== undefined`,()=>j.assign(R,(0,t._)`${P} === true ? true : ${R} > ${P} ? ${R} : ${P}`)),mergeToName:(j,P,R)=>j.if((0,t._)`${R} !== true`,()=>j.assign(R,P===!0?!0:(0,t._)`${R} > ${P} ? ${R} : ${P}`)),mergeValues:(j,P)=>j===!0?!0:Math.max(j,P),resultToName:(j,P)=>j.var("items",P)})};function m(j,P){if(P===!0)return j.var("props",!0);const R=j.var("props",(0,t._)`{}`);return P!==void 0&&v(j,R,P),R}e.evaluatedPropsToName=m;function v(j,P,R){Object.keys(R).forEach(A=>j.assign((0,t._)`${P}${(0,t.getProperty)(A)}`,!0))}e.setEvaluated=v;const g={};function y(j,P){return j.scopeValue("func",{ref:P,code:g[P.code]||(g[P.code]=new n._Code(P.code))})}e.useFunc=y;var w;(function(j){j[j.Num=0]="Num",j[j.Str=1]="Str"})(w=e.Type||(e.Type={}));function k(j,P,R){if(j instanceof t.Name){const A=P===w.Num;return R?A?(0,t._)`"[" + ${j} + "]"`:(0,t._)`"['" + ${j} + "']"`:A?(0,t._)`"/" + ${j}`:(0,t._)`"/" + ${j}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return R?(0,t.getProperty)(j).toString():"/"+u(j)}e.getErrorPath=k;function C(j,P,R=j.opts.strictSchema){if(R){if(P=`strict mode: ${P}`,R===!0)throw new Error(P);j.self.logger.warn(P)}}e.checkStrictMode=C})(Xn);var Ts={};Object.defineProperty(Ts,"__esModule",{value:!0});const Wo=Fn,Y0e={data:new Wo.Name("data"),valCxt:new Wo.Name("valCxt"),instancePath:new Wo.Name("instancePath"),parentData:new Wo.Name("parentData"),parentDataProperty:new Wo.Name("parentDataProperty"),rootData:new Wo.Name("rootData"),dynamicAnchors:new Wo.Name("dynamicAnchors"),vErrors:new Wo.Name("vErrors"),errors:new Wo.Name("errors"),this:new Wo.Name("this"),self:new Wo.Name("self"),scope:new Wo.Name("scope"),json:new Wo.Name("json"),jsonPos:new Wo.Name("jsonPos"),jsonLen:new Wo.Name("jsonLen"),jsonPart:new Wo.Name("jsonPart")};Ts.default=Y0e,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=Fn,n=Xn,r=Ts;e.keywordError={message:({keyword:v})=>(0,t.str)`must pass "${v}" keyword validation`},e.keyword$DataError={message:({keyword:v,schemaType:g})=>g?(0,t.str)`"${v}" keyword must be ${g} ($data)`:(0,t.str)`"${v}" keyword is invalid ($data)`};function o(v,g=e.keywordError,y,w){const{it:k}=v,{gen:C,compositeRule:j,allErrors:P}=k,R=u(v,g,y);w??(j||P)?l(C,R):c(k,(0,t._)`[${R}]`)}e.reportError=o;function i(v,g=e.keywordError,y){const{it:w}=v,{gen:k,compositeRule:C,allErrors:j}=w,P=u(v,g,y);l(k,P),C||j||c(w,r.default.vErrors)}e.reportExtraError=i;function a(v,g){v.assign(r.default.errors,g),v.if((0,t._)`${r.default.vErrors} !== null`,()=>v.if(g,()=>v.assign((0,t._)`${r.default.vErrors}.length`,g),()=>v.assign(r.default.vErrors,null)))}e.resetErrorsCount=a;function s({gen:v,keyword:g,schemaValue:y,data:w,errsCount:k,it:C}){if(k===void 0)throw new Error("ajv implementation error");const j=v.name("err");v.forRange("i",k,r.default.errors,P=>{v.const(j,(0,t._)`${r.default.vErrors}[${P}]`),v.if((0,t._)`${j}.instancePath === undefined`,()=>v.assign((0,t._)`${j}.instancePath`,(0,t.strConcat)(r.default.instancePath,C.errorPath))),v.assign((0,t._)`${j}.schemaPath`,(0,t.str)`${C.errSchemaPath}/${g}`),C.opts.verbose&&(v.assign((0,t._)`${j}.schema`,y),v.assign((0,t._)`${j}.data`,w))})}e.extendErrors=s;function l(v,g){const y=v.const("err",g);v.if((0,t._)`${r.default.vErrors} === null`,()=>v.assign(r.default.vErrors,(0,t._)`[${y}]`),(0,t._)`${r.default.vErrors}.push(${y})`),v.code((0,t._)`${r.default.errors}++`)}function c(v,g){const{gen:y,validateName:w,schemaEnv:k}=v;k.$async?y.throw((0,t._)`new ${v.ValidationError}(${g})`):(y.assign((0,t._)`${w}.errors`,g),y.return(!1))}const f={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function u(v,g,y){const{createErrors:w}=v.it;return w===!1?(0,t._)`{}`:d(v,g,y)}function d(v,g,y={}){const{gen:w,it:k}=v,C=[h(k,y),p(v,y)];return m(v,g,C),w.object(...C)}function h({errorPath:v},{instancePath:g}){const y=g?(0,t.str)`${v}${(0,n.getErrorPath)(g,n.Type.Str)}`:v;return[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,y)]}function p({keyword:v,it:{errSchemaPath:g}},{schemaPath:y,parentSchema:w}){let k=w?g:(0,t.str)`${g}/${v}`;return y&&(k=(0,t.str)`${k}${(0,n.getErrorPath)(y,n.Type.Str)}`),[f.schemaPath,k]}function m(v,{params:g,message:y},w){const{keyword:k,data:C,schemaValue:j,it:P}=v,{opts:R,propertyName:A,topSchemaRef:x,schemaPath:S}=P;w.push([f.keyword,k],[f.params,typeof g=="function"?g(v):g||(0,t._)`{}`]),R.messages&&w.push([f.message,typeof y=="function"?y(v):y]),R.verbose&&w.push([f.schema,j],[f.parentSchema,(0,t._)`${x}${S}`],[r.default.data,C]),A&&w.push([f.propertyName,A])}}(ap),Object.defineProperty(Wf,"__esModule",{value:!0}),Wf.boolOrEmptySchema=Wf.topBoolOrEmptySchema=void 0;const X0e=ap,Z0e=Fn,eye=Ts,tye={message:"boolean schema is false"};function nye(e){const{gen:t,schema:n,validateName:r}=e;n===!1?dF(e,!1):typeof n=="object"&&n.$async===!0?t.return(eye.default.data):(t.assign((0,Z0e._)`${r}.errors`,null),t.return(!0))}Wf.topBoolOrEmptySchema=nye;function rye(e,t){const{gen:n,schema:r}=e;r===!1?(n.var(t,!1),dF(e)):n.var(t,!0)}Wf.boolOrEmptySchema=rye;function dF(e,t){const{gen:n,data:r}=e,o={gen:n,keyword:"false schema",data:r,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,X0e.reportError)(o,tye,void 0,t)}var lp={},lu={};Object.defineProperty(lu,"__esModule",{value:!0}),lu.getRules=lu.isJSONType=void 0;const oye=["string","number","integer","boolean","null","object","array"],iye=new Set(oye);function aye(e){return typeof e=="string"&&iye.has(e)}lu.isJSONType=aye;function sye(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}lu.getRules=sye;var cl={};Object.defineProperty(cl,"__esModule",{value:!0}),cl.shouldUseRule=cl.shouldUseGroup=cl.schemaHasRulesForType=void 0;function lye({schema:e,self:t},n){const r=t.RULES.types[n];return r&&r!==!0&&hF(e,r)}cl.schemaHasRulesForType=lye;function hF(e,t){return t.rules.some(n=>pF(e,n))}cl.shouldUseGroup=hF;function pF(e,t){var n;return e[t.keyword]!==void 0||((n=t.definition.implements)===null||n===void 0?void 0:n.some(r=>e[r]!==void 0))}cl.shouldUseRule=pF,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;const t=lu,n=cl,r=ap,o=Fn,i=Xn;var a;(function(w){w[w.Correct=0]="Correct",w[w.Wrong=1]="Wrong"})(a=e.DataType||(e.DataType={}));function s(w){const k=l(w.type);if(k.includes("null")){if(w.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!k.length&&w.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');w.nullable===!0&&k.push("null")}return k}e.getSchemaTypes=s;function l(w){const k=Array.isArray(w)?w:w?[w]:[];if(k.every(t.isJSONType))return k;throw new Error("type must be JSONType or JSONType[]: "+k.join(","))}e.getJSONTypes=l;function c(w,k){const{gen:C,data:j,opts:P}=w,R=u(k,P.coerceTypes),A=k.length>0&&!(R.length===0&&k.length===1&&(0,n.schemaHasRulesForType)(w,k[0]));if(A){const x=m(k,j,P.strictNumbers,a.Wrong);C.if(x,()=>{R.length?d(w,k,R):g(w)})}return A}e.coerceAndCheckDataType=c;const f=new Set(["string","number","integer","boolean","null"]);function u(w,k){return k?w.filter(C=>f.has(C)||k==="array"&&C==="array"):[]}function d(w,k,C){const{gen:j,data:P,opts:R}=w,A=j.let("dataType",(0,o._)`typeof ${P}`),x=j.let("coerced",(0,o._)`undefined`);R.coerceTypes==="array"&&j.if((0,o._)`${A} == 'object' && Array.isArray(${P}) && ${P}.length == 1`,()=>j.assign(P,(0,o._)`${P}[0]`).assign(A,(0,o._)`typeof ${P}`).if(m(k,P,R.strictNumbers),()=>j.assign(x,P))),j.if((0,o._)`${x} !== undefined`);for(const D of C)(f.has(D)||D==="array"&&R.coerceTypes==="array")&&S(D);j.else(),g(w),j.endIf(),j.if((0,o._)`${x} !== undefined`,()=>{j.assign(P,x),h(w,x)});function S(D){switch(D){case"string":j.elseIf((0,o._)`${A} == "number" || ${A} == "boolean"`).assign(x,(0,o._)`"" + ${P}`).elseIf((0,o._)`${P} === null`).assign(x,(0,o._)`""`);return;case"number":j.elseIf((0,o._)`${A} == "boolean" || ${P} === null
|