route-engine-js 1.46.0 → 1.46.1
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/RouteEngine.js +7 -7
- package/package.json +1 -1
package/dist/RouteEngine.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var $m=Object.defineProperty;var _m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),jm=(e,t)=>{for(var n in t)$m(e,n,{get:t[n],enumerable:!0})};var uf=_m(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});function cf(e){let t=e.length,n=0,o=0,a;for(;o<t;)n++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<t&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return n}Fa.default=cf;cf.code='require("ajv/dist/runtime/ucs2length").default'});var Il=Symbol.for("immer-nothing"),yl=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state");function Ye(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var dt=Object.getPrototypeOf;function Pe(e){return!!e&&!!e[Le]}function Xr(e){return e?vl(e)||Array.isArray(e)||!!e[yl]||!!e.constructor?.[yl]||Tn(e)||Ln(e):!1}var Nm=Object.prototype.constructor.toString();function vl(e){if(!e||typeof e!="object")return!1;let t=dt(e);if(t===null)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Nm}function Nn(e){return Pe(e)||Ye(15,e),e[Le].base_}function $n(e,t){Dn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function Dn(e){let t=e[Le];return t?t.type_:Array.isArray(e)?1:Tn(e)?2:Ln(e)?3:0}function Li(e,t){return Dn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function kl(e,t,n){let o=Dn(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function Dm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Tn(e){return e instanceof Map}function Ln(e){return e instanceof Set}function zr(e){return e.copy_||e.base_}function Mi(e,t){if(Tn(e))return new Map(e);if(Ln(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=vl(e);if(t===!0||t==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Le];let a=Reflect.ownKeys(o);for(let r=0;r<a.length;r++){let s=a[r],i=o[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(dt(e),o)}else{let o=dt(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Ui(e,t=!1){return Mn(e)||Pe(e)||!Xr(e)||(Dn(e)>1&&(e.set=e.add=e.clear=e.delete=Tm),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Ui(o,!0))),e}function Tm(){Ye(2)}function Mn(e){return Object.isFrozen(e)}var Lm={};function Gr(e){let t=Lm[e];return t||Ye(0,e),t}var Dt;function Al(){return Dt}function Mm(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hl(e,t){t&&(Gr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Vi(e){qi(e),e.drafts_.forEach(Vm),e.drafts_=null}function qi(e){e===Dt&&(Dt=e.parent_)}function gl(e){return Dt=Mm(Dt,e)}function Vm(e){let t=e[Le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function bl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Le].modified_&&(Vi(t),Ye(4)),Xr(e)&&(e=_n(t,e),t.parent_||jn(t,e)),t.patches_&&Gr("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=_n(t,n,[]),Vi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Il?e:void 0}function _n(e,t,n){if(Mn(t))return t;let o=t[Le];if(!o)return $n(t,(a,r)=>wl(e,o,t,a,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return jn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,r=a,s=!1;o.type_===3&&(r=new Set(a),a.clear(),s=!0),$n(r,(i,l)=>wl(e,o,a,i,l,n,s)),jn(e,a,!1),n&&e.patches_&&Gr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function wl(e,t,n,o,a,r,s){if(Pe(a)){let i=r&&t&&t.type_!==3&&!Li(t.assigned_,o)?r.concat(o):void 0,l=_n(e,a,i);if(kl(n,o,l),Pe(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Xr(a)&&!Mn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;_n(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&jn(e,a)}}function jn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ui(t,n)}function qm(e,t){let n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Al(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=Yi;n&&(a=[o],r=Tt);let{revoke:s,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=s,i}var Yi={get(e,t){if(t===Le)return e;let n=zr(e);if(!Li(n,t))return Fm(e,n,t);let o=n[t];return e.finalized_||!Xr(o)?o:o===Di(e.base_,t)?(Ti(e),e.copy_[t]=Bi(o,e)):o},has(e,t){return t in zr(e)},ownKeys(e){return Reflect.ownKeys(zr(e))},set(e,t,n){let o=Pl(zr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=Di(zr(e),t),r=a?.[Le];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Dm(n,a)&&(n!==void 0||Li(e.base_,t)))return!0;Ti(e),Fi(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Di(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ti(e),Fi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=zr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){Ye(11)},getPrototypeOf(e){return dt(e.base_)},setPrototypeOf(){Ye(12)}},Tt={};$n(Yi,(e,t)=>{Tt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Tt.deleteProperty=function(e,t){return Tt.set.call(this,e,t,void 0)};Tt.set=function(e,t,n){return Yi.set.call(this,e[0],t,n,e[0])};function Di(e,t){let n=e[Le];return(n?zr(n):e)[t]}function Fm(e,t,n){let o=Pl(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Pl(e,t){if(!(t in e))return;let n=dt(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=dt(n)}}function Fi(e){e.modified_||(e.modified_=!0,e.parent_&&Fi(e.parent_))}function Ti(e){e.copy_||(e.copy_=Mi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Bm=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){let r=n;n=t;let s=this;return function(l=r,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Ye(6),o!==void 0&&typeof o!="function"&&Ye(7);let a;if(Xr(t)){let r=gl(this),s=Bi(t,void 0),i=!0;try{a=n(s),i=!1}finally{i?Vi(r):qi(r)}return hl(r,o),bl(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===Il&&(a=void 0),this.autoFreeze_&&Ui(a,!0),o){let r=[],s=[];Gr("Patches").generateReplacementPatches_(t,a,r,s),o(r,s)}return a}else Ye(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,l=>t(l,...i));let o,a;return[this.produce(t,n,(s,i)=>{o=s,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Xr(e)||Ye(8),Pe(e)&&(e=Pr(e));let t=gl(this),n=Bi(e,void 0);return n[Le].isManual_=!0,qi(t),n}finishDraft(e,t){let n=e&&e[Le];(!n||!n.isManual_)&&Ye(9);let{scope_:o}=n;return hl(o,t),bl(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));let o=Gr("Patches").applyPatches_;return Pe(e)?o(e,t):this.produce(e,a=>o(a,t))}};function Bi(e,t){let n=Tn(e)?Gr("MapSet").proxyMap_(e,t):Ln(e)?Gr("MapSet").proxySet_(e,t):qm(e,t);return(t?t.scope_:Al()).drafts_.push(n),n}function Pr(e){return Pe(e)||Ye(10,e),El(e)}function El(e){if(!Xr(e)||Mn(e))return e;let t=e[Le],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Mi(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Mi(e,!0);return $n(n,(o,a)=>{kl(n,o,El(a))}),t&&(t.finalized_=!1),n}var Ve=new Bm,Vn=Ve.produce,Hk=Ve.produceWithPatches.bind(Ve),Kk=Ve.setAutoFreeze.bind(Ve),Wk=Ve.setUseStrictShallowCopy.bind(Ve),Jk=Ve.applyPatches.bind(Ve),Qk=Ve.createDraft.bind(Ve),Zk=Ve.finishDraft.bind(Ve);var x={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},mt={NOT:0};var T=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ne=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var zi=e=>{if(!e||e.trim()==="")throw new T("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new T(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let n of t)if(e.trim().endsWith(n))throw new T(`Incomplete comparison expression - missing right operand (got: '${e}')`)},xl=e=>{if(e.trim().endsWith(" in"))throw new T(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new T(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new T(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of o){if(!a)throw new T(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new T(`Invalid loop syntax (got: '$for ${e}')`)}};var Sl=(e,t,n=!1)=>{if(t===null)return new Ne(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ne(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return n?new Ne(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ne(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Ol=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ne(`Unknown function '${e}' (${n})`)};var Um=(e,t,n={})=>{let o={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(o=n.functions||{},a=n.partials||{}):typeof n=="object"&&(o=n));let s=se(e,{functions:o,partials:a},t,{});return s===void 0?{}:s},se=(e,t,n,o)=>{let a=t.functions||t;if(e.var&&!e.type)return ke(e.var,n,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ke(e.path,n,o);if(e.type===x.INTERPOLATION)return zm(e.parts,t,n,o);switch(e.type){case x.FUNCTION:return Cl(e,t,n,o);case x.BINARY:return $l(e,t,n,o);case x.UNARY:return _l(e,t,n,o);case x.CONDITIONAL:return Gm(e,t,n,o);case x.LOOP:return Qm(e,t,n,o);case x.OBJECT:return ey(e,t,n,o);case x.ARRAY:return ry(e,t,n,o);case x.PARTIAL:return ty(e,t,n,o);case x.PATH_REFERENCE:return ny(e,t,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Rl=new Map,Ym=e=>{let t=[],n="",o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")n&&(t.push({type:"property",value:n}),n=""),o=!0;else if(r==="]"){if(o&&n){let s=n.trim();if(/^\d+$/.test(s))t.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let i=s.slice(1,-1);t.push({type:"property",value:i})}else t.push({type:"property",value:s});n=""}o=!1}else n+=r}return n&&t.push({type:"property",value:n}),t},ke=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let o=Rl.get(e);if(!o){let r=[],s="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,s+=c):c==="]"?(i--,s+=c):c==="."&&i===0?s&&(r.push(s),s=""):s+=c}s&&r.push(s),o=[];for(let l of r){let c=Ym(l.trim());o.push(...c)}Rl.set(e,o)}let a=t;for(let r=0;r<o.length;r++){let s=o[r];if(s.type==="property"&&s.value in n){a=n[s.value];continue}if(a==null)return;(s.type==="property"||s.type==="index")&&(a=a[s.value])}return a},zm=(e,t,n,o)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=se(r,t,n,o);a.push(s!=null?String(s):"")}return a.join("")},Cl=(e,t,n,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Ol(e.name,a);let s=e.args.map(i=>se(i,t,n,o));return r(...s)},Er=(e,t,n,o)=>{if(e.var&&!e.type)return ke(e.var,n,o);switch(e.type){case x.VARIABLE:return ke(e.path,n,o);case x.LITERAL:return e.value;case x.BINARY:return $l(e,t,n,o);case x.UNARY:return _l(e,t,n,o);case x.FUNCTION:return Cl(e,t,n,o);default:return se(e,t,n,o)}},$l=(e,t,n,o)=>{if(e.op===ee.AND||e.op===ee.OR){let s=Er(e.left,t,n,o),i=Er(e.right,t,n,o);switch(e.op){case ee.AND:return s&&i;case ee.OR:return s||i}}let a=se(e.left,t,n,o),r=se(e.right,t,n,o);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},_l=(e,t,n,o)=>{let a=e.op===mt.NOT?Er(e.operand,t,n,o):se(e.operand,t,n,o);if(e.op===mt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Xm=(e,t,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ke(a.path,n,o)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?se(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ke(d.path,n,o);p.push(f!=null?String(f):"")}else{let f=se(d,t,n,o);p.push(f!=null?String(f):"")}i[c]=p.join("")}else i[c]=se(u,t,n,o)}return i}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?se(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ke(d.path,n,o);p.push(f!=null?String(f):"")}else{let f=se(d,t,n,o);p.push(f!=null?String(f):"")}i[c]=p.join("")}else i[c]=se(u,t,n,o)}return i}}}return null},Gm=(e,t,n,o)=>{let a=Xm(e,t,n,o);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let s=e.conditions[r];if(s===null||Er(s,t,n,o))return se(e.bodies[r],t,n,o)}return jl},Hm=(e,t)=>{let n=e.body,o=e.itemVar;if(n.type===x.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===x.VARIABLE){let a=n.conditions[0].path,r=n.bodies[0];if(a.startsWith(o+".")){let s=a.substring(o.length+1);if(r.type===x.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let i=[];for(let l=0;l<t.length;l++){let c=t[l];if(c[s]){let u={};for(let p of r.properties){let d=p.key,f=p.value;if(f.type===x.LITERAL)u[d]=f.value;else if(f.type===x.VARIABLE){let m=f.path;if(m===o)u[d]=c;else if(m.startsWith(o+".")){let h=m.substring(o.length+1);u[d]=c[h]}else return null}else if(f.type===x.INTERPOLATION){let m=[],h=!0;for(let g of f.parts)if(typeof g=="string")m.push(g);else if(g.type===x.VARIABLE){let y=g.path;if(y===o)m.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),b=c[w];m.push(b!=null?String(b):"")}else{h=!1;break}}else{h=!1;break}if(!h)return null;u[d]=m.join("")}else return null}i.push(u)}}return i}}}return null},Km=(e,t)=>{let n=e.body,o=e.itemVar,a=Hm(e,t);if(a!==null)return a;if(n.type===x.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let i of n.properties)if(i.parsedKey)return null;let r=[],s=!0;for(let i of n.properties){let l=i.key,c=i.value;if(c.type===x.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===x.VARIABLE){let u=c.path;if(u===o)r.push({key:l,type:"item"});else if(u.startsWith(o+".")){let p=u.substring(o.length+1);if(!p.includes(".")&&!p.includes("["))r.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(c.type===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===o)r.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let d=p.substring(o.length+1);if(!d.includes(".")&&!d.includes("["))r.push({key:l,type:"prop_string",prop:d});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let i=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let d=c[p.prop];u[p.key]=d!=null?String(d):""}i[l]=u}return i}}return null},Wm=(e,t,n,o,a)=>{let r=[],s=e.body;if(s.type===x.OBJECT&&s.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},d={...o,[i]:u,...l&&{[l]:c}};d.__paths__||(d.__paths__=o.__paths__||{});let f=e.iterable.path||"";if(o&&o.__paths__&&f){let m=f.split("."),h=m[0];h in o.__paths__&&(f=o.__paths__[h],m.length>1&&(f+="."+m.slice(1).join(".")))}d.__paths__={...d.__paths__,[i]:`${f}[${c}]`,...l&&{[l]:c}};for(let m of s.properties){let h=m.parsedKey?se(m.parsedKey,t,n,d):m.key,g=m.value;if(g.type===x.LITERAL)p[h]=g.value;else if(g.type===x.VARIABLE){let y=g.path;if(y===i)p[h]=u;else if(y===l)p[h]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[h]=u[w]:p[h]=ke(y,n,{...o,[i]:u,...l&&{[l]:c}})}else p[h]=ke(y,n,{...o,[i]:u,...l&&{[l]:c}})}else if(g.type===x.INTERPOLATION){let y=[];for(let w of g.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let b=w.path,A;if(b===i)A=u;else if(b===l)A=c;else if(b.startsWith(i+".")){let k=b.substring(i.length+1);!k.includes(".")&&!k.includes("[")?A=u[k]:A=ke(b,n,{...o,[i]:u,...l&&{[l]:c}})}else A=ke(b,n,{...o,[i]:u,...l&&{[l]:c}});y.push(A!=null?String(A):"")}else{let b={...o,[i]:u,...l&&{[l]:c}},A=se(w,t,n,b);y.push(A!=null?String(A):"")}p[h]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[h]=se(g,t,n,y)}}r.push(p)}return r}return null},Jm=(e,t,n)=>{let o=e.body;if(o.type===x.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let r=o.properties[0].value;if(r.type===x.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===x.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===x.OBJECT&&s.properties.length===2){let i=s.properties[0],l=s.properties[1];if(i.key==="id"&&i.value.type===x.VARIABLE&&i.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let d={id:p.id};p.highlighted?(d.highlight=!0,d.message=`This item is highlighted: ${p.name}`):(d.highlight=!1,d.message=p.name),c.push(d)}}return c}}}}return null},Qm=(e,t,n,o)=>{let a=se(e.iterable,t,n,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let d=e.iterable.args.map(f=>f.type===x.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===x.VARIABLE?f.path:f.type===x.FUNCTION?`${f.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${d})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Sl(p,a,u)}if(!e.indexVar){let c=Jm(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=Km(e,a);if(c!==null)return c}let r=Wm(e,t,n,o,a);if(r!==null)return r;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let c=i.split("."),u=c[0];u in o.__paths__&&(i=o.__paths__[u],c.length>1&&(i+="."+c.slice(1).join(".")))}let l=!1;e.body.type===x.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===x.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...o,[e.itemVar]:a[c],[e.indexVar]:c}:{...o,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=o.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${i}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=se(e.body,t,n,u);if(Array.isArray(p)&&p.length===1&&!l){let d=p[0];s.push(d===void 0?{}:d)}else s.push(p===void 0?{}:p)}return s},Zm=(e,t,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?se(a.parsedKey,t,n,o):a.key,s=a.value;if(s.type===x.OBJECT&&s.properties.length<=10&&!s.whenCondition){let i={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?se(u.parsedKey,t,n,o):u.key,d=u.value;if(d.type===x.LITERAL)l[p]=d.value;else if(d.type===x.VARIABLE)l[p]=ke(d.path,n,o);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let h=ke(m.path,n,o);f.push(h!=null?String(h):"")}else{c=!1;break}if(!c)break;l[p]=f.join("")}else if(d.type===x.OBJECT&&d.properties.length<=5){let f={};for(let m of d.properties){let h=m.key,g=m.value;if(g.type===x.LITERAL)f[h]=g.value;else if(g.type===x.VARIABLE)f[h]=ke(g.path,n,o);else if(g.type===x.INTERPOLATION){let y=[];for(let w of g.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let b=ke(w.path,n,o);y.push(b!=null?String(b):"")}else{c=!1;break}if(!c)break;f[h]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=f}else{c=!1;break}}if(c)return i[r]=l,i}}return null},ey=(e,t,n,o)=>{let a=t.functions||t;if(e.whenCondition&&!Er(e.whenCondition,a,n,o))return;let r=Zm(e,t,n,o);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?se(u.parsedKey,t,n,o):u.key,d=u.value;if(d.type===x.LITERAL)c[p]=d.value;else if(d.type===x.VARIABLE)c[p]=ke(d.path,n,o);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let h=ke(m.path,n,o);f.push(h!=null?String(h):"")}else{let h=se(m,t,n,o);f.push(h!=null?String(h):"")}c[p]=f.join("")}else c[p]=se(d,t,n,o)}return c}let s={},i=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=se(c.value,t,n,o);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return se(c.value,t,n,o)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(d=>d.key.startsWith("$for "));if(p){let d=se(p.value,t,n,o);d!==void 0&&(s[c.key]=d)}else{let d=se(c.value,t,n,o);d!==void 0&&(s[c.key]=d)}}else{let p=c.parsedKey?se(c.parsedKey,t,n,o):c.key,d=se(c.value,t,n,o);d!==void 0&&(s[p]=d)}}return s},jl={},ry=(e,t,n,o)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let s=se(r,t,n,o);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=se(r,t,n,o);s!==jl&&s!==void 0&&a.push(s)}return a},ty=(e,t,n,o)=>{let{name:a,data:r,whenCondition:s}=e,i=t.partials||{},l=t.functions||t;if(s&&!Er(s,l,n,o))return;if(!i[a])throw new Ne(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new Ne(`Circular partial reference detected: ${a}`);let u=i[a],p=n,d={...o,_partialStack:[...c,a]};if(o){p={...n};for(let f of Object.keys(o))f.startsWith("_")||(p[f]=o[f])}if(r){let f=se(r,t,n,o);p={...p,...f}}return se(u,t,p,d)},ny=(e,t,n,o)=>{let{path:a}=e,r=a.split("."),s=r[0],i=r.slice(1);if(!o||!(s in o))throw new Ne(`Path reference '#{${a}}' refers to '${s}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(s in o.__paths__))throw new Ne(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[s];if(typeof l=="number"){if(i.length>0)throw new Ne(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Xi=Um;var sy=/\$\{([^}]*)\}/g,iy=/#\{([^}]*)\}/g,Dl=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,r=oy(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},oy=(e,t={})=>e.trim()?ay(e).map(o=>ly(o.trim(),t)):[],ay=e=>{let t=[],n="",o=0,a=!1,r="";for(let s=0;s<e.length;s++){let i=e[s],l=s>0?e[s-1]:"";!a&&(i==='"'||i==="'")?(a=!0,r=i,n+=i):a&&i===r&&l!=="\\"?(a=!1,r="",n+=i):!a&&i==="("?(o++,n+=i):!a&&i===")"?(o--,n+=i):!a&&i===","&&o===0?(t.push(n),n=""):n+=i}return n&&t.push(n),t},ly=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:x.LITERAL,value:parseFloat(e)};if(e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};let n=Dl(e,t);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,s=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Hr(o.substring(c),i);if(u===-1)break;let p=c+u;p>r&&(r=p,s={op:i,type:l}),c=p+i.length}}if(r!==-1)try{return Ee(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Tl=/^\w+\(.*\)$/,cy=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,uy=e=>{if(!(!e||e.trim()===""||Tl.test(e))&&cy.test(e))throw e.includes("?")&&e.includes(":")?new T(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new T(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new T(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Nl=e=>{let t=e.trim();if(Tl.test(t))throw new T(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new T(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new T(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new T(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new T(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},Lt=(e,t={})=>{let n=e.trim();uy(n);let o=Dl(n,t);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let r of n)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:n}},Gi=(e,t={})=>{let n=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(n=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),n=n.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),n=n.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(sy)],r=[...n.matchAll(iy)],s=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:x.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&o.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?Lt(c[1],t):Nl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:n};throw p}}let i=[],l=0;for(let{match:c,type:u}of s){let[p,d]=c,f=c.index;if(f>l){let m=n.substring(l,f);for(let h=0;h<o.length;h++)m=m.replace(`__ESCAPED_${h}__`,o[h]);m&&i.push(m)}try{let m;u==="variable"?m=Lt(d.trim(),t):m=Nl(d.trim()),i.push(m)}catch(m){if(m.message==="Invalid array index syntax")i.push(p);else throw m}l=f+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);c&&i.push(c)}return{type:x.INTERPOLATION,parts:i}};var Wi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Vl=e=>Object.keys(e),$e=e=>e.join("."),xr=(e,t,n)=>{let o=Vl(e).filter(a=>!t.has(a));if(o.length>0)throw new T(`Unexpected key '${o[0]}' in condition JSON at '${$e(n)}'`)},Sr=(e,t)=>typeof e=="string"?Gi(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?fy(e,t):dy(e,t):{type:x.LITERAL,value:e},py=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new T("$each value must be a non-empty string");let o=t.trim();if(o==="")throw new T("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new T("Empty $each body not allowed");if(n.$partial!==void 0)throw new T("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},fy=(e,t)=>{let n=[],o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(r.$each!==void 0)try{let l=py(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=Ml(c[0],l[c[0]],t,!0);n.push(u),o=!0;continue}}catch(l){throw l instanceof T?l:new T(l.message)}let i=Object.keys(r);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Ml(i[0],r[i[0]],t);n.push(l),o=!0;continue}}let s=Sr(r,t);n.push(s),(s.type===x.FUNCTION||s.type===x.CONDITIONAL||s.type===x.LOOP||s.type===x.PARTIAL||s.type===x.OBJECT&&!s.fast||s.type===x.ARRAY&&!s.fast)&&(o=!0)}return{type:x.ARRAY,items:n,fast:!o}},dy=(e,t)=>{let n=[],o=!1,a=null,r=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new T("$partial value must be a string");if(e.$partial.trim()==="")throw new T("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let w of l)if(y===w||y.startsWith(w+" ")||y.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new T(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...d}=e,f={},m=!1;for(let[y,w]of Object.entries(d)){let b=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(b=y.slice(1)),f[b]=w,m=!0}let h=null;if(m&&(h=Sr(f,t),h.type===x.OBJECT)){let y=!1;for(let w of h.properties)if(w.value.type===x.VARIABLE||w.value.type===x.INTERPOLATION||w.value.type===x.FUNCTION||w.value.type===x.CONDITIONAL||w.value.type===x.OBJECT&&!w.value.fast||w.value.type===x.ARRAY&&!w.value.fast){y=!0;break}y&&(h.fast=!1)}let g={type:x.PARTIAL,name:u,data:h};return p!==void 0&&(g.whenCondition=Ll(p,t)),g}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new T("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new T("Missing condition expression after '$when'");a=Ll(c,t),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new T("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<r.length;){let[l,c]=r[s];if(l==="$when"){s++;continue}if(l==="$each")throw new T("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=my(r,s,t);n.push({key:l,value:u.node}),o=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new T(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new T(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new T("Missing condition expression after '$if'");{let u=Sr(c,t);(u.type===x.FUNCTION||u.type===x.CONDITIONAL||u.type===x.PARTIAL||u.type===x.OBJECT&&!u.fast||u.type===x.ARRAY&&!u.fast)&&(o=!0);let p=Gi(l,t),d={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(d.parsedKey=p),n.push(d),s++}}}let i={type:x.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},my=(e,t,n={})=>{let o=[],a=[],r=t,[s,i]=e[r],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new T(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());zi(c);let u=Ee(c,n);for(o.push(u),a.push(Sr(i,n)),r++;r<e.length;){let[p,d]=e[r],f=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(f=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p==="$else"||p==="$else:")&&(f=!0,m=null),f){if(m===null)o.push(null);else{zi(m);let h=Ee(m,n);o.push(h)}if(a.push(Sr(d,n)),r++,m===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Hi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},Ki={all:ee.AND,any:ee.OR},yy=new Set(["var","literal","call","not",...Object.keys(Hi),...Object.keys(Ki)]),hy=(e,t,n)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${$e(n)}' requires an array`);if(e.length!==2)throw new T(`Condition JSON operator '${t}' at '${$e(n)}' requires exactly 2 operands`);return e},gy=(e,t,n,o,a)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${$e(a)}' requires an array`);if(e.length===0)throw new T(`Condition JSON operator '${t}' at '${$e(a)}' requires at least 1 condition`);return e.map((s,i)=>Me(s,o,[...a,i])).reduce((s,i)=>({type:x.BINARY,op:n,left:s,right:i}))},by=(e,t,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],xr(e,new Set(["call","args"]),n);else if(Wi(e.call))o=e.call.name,a=e.call.args??[],xr(e,new Set(["call"]),n),xr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new T(`Condition JSON call at '${$e(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new T(`Condition JSON call at '${$e(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new T(`Invalid condition JSON function name '${o}' at '${$e(n)}'`);if(!Array.isArray(a))throw new T(`Condition JSON call '${o}' at '${$e(n)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,s)=>Me(r,t,[...n,"args",s]))}},Me=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new T(`Condition JSON array at '${$e(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Wi(e))throw new T(`Invalid condition JSON value at '${$e(n)}'`);let o=Vl(e);if(o.length===0)throw new T(`Condition JSON object at '${$e(n)}' must contain an operator`);let a=o.filter(s=>yy.has(s));if(a.length===0)throw new T(`Unknown condition JSON operator '${o[0]}' at '${$e(n)}'`);if(a.length>1)throw new T(`Condition JSON at '${$e(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(xr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new T(`Condition JSON var at '${$e(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return xr(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return by(e,t,n);if(r==="not")return xr(e,new Set(["not"]),n),{type:x.UNARY,op:mt.NOT,operand:Me(e.not,t,[...n,"not"])};if(r in Ki)return xr(e,new Set([r]),n),gy(e[r],r,Ki[r],t,[...n,r]);if(r in Hi){xr(e,new Set([r]),n);let s=hy(e[r],r,[...n,r]);return{type:x.BINARY,op:Hi[r],left:Me(s[0],t,[...n,r,0]),right:Me(s[1],t,[...n,r,1])}}throw new T(`Unknown condition JSON operator '${r}' at '${$e(n)}'`)},Ll=(e,t={})=>{if(e==null)throw new T("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression after '$when'");return Ee(e,t)}return Wi(e)||Array.isArray(e)?Me(e,t):{type:x.LITERAL,value:e}},Ee=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let d=0;d<c.length;d++)if(c[d]==="("?u++:c[d]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Ee(c,t)}let n=Hr(e,"||");if(n!==-1)return{type:x.BINARY,op:ee.OR,left:Ee(e.substring(0,n).trim(),t),right:Ee(e.substring(n+2).trim(),t)};let o=Hr(e,"&&");if(o!==-1)return{type:x.BINARY,op:ee.AND,left:Ee(e.substring(0,o).trim(),t),right:Ee(e.substring(o+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Hr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Ee(e.substring(0,p).trim(),t),right:Ee(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,i=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let d=Hr(e.substring(p),c);if(d===-1)break;let f=p+d;f>r&&(r=f,s={op:c,type:u}),p=f+c.length}}if(r!==-1&&s)return{type:x.BINARY,op:s.type,left:Ee(e.substring(0,r).trim(),t),right:Ee(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Hr(e,c)!==-1)throw new T(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:mt.NOT,operand:Ee(e.substring(1).trim(),t)}:ql(e,t)},Hr=(e,t)=>{let n=0,o=0;for(;o<=e.length-t.length;){if(e[o]==="(")n++;else if(e[o]===")")n--;else if(n===0&&e.substring(o,o+t.length)===t)return o;o++}return-1},wy=e=>{if(e=e.trim(),e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:x.LITERAL,value:""};if(e==="{}")return{type:x.LITERAL,value:{}};if(e==="[]")return{type:x.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:x.LITERAL,value:t}:{type:x.VARIABLE,path:e}},ql=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return Lt(n,t);let a=wy(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return Lt(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Iy=(e,t=!1)=>{let n=t?"$each":"$for";try{xl(e)}catch(o){if(o instanceof T&&t){let a=o.message.replace(/\$for/g,"$each");throw new T(a.replace("Parse Error: ",""))}throw o}},Ml=(e,t,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let g=o?"$each":"$for";throw new T(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=r[1],i=r[2].trim();Iy(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new T(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${i}')`)}let c=l[1].trim(),u=l[2].trim(),p,d=null;if(c.includes(",")){let g=c.split(",").map(y=>y.trim());if(g.length!==2)throw new T(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=g[0],d=g[1]}else p=c;let f=["this","undefined","null","true","false"];if(f.includes(p))throw new T(`Reserved variable name: ${p}`);if(d&&f.includes(d))throw new T(`Reserved variable name: ${d}`);let m=ql(u,n),h=Sr(t,n);return{type:x.LOOP,itemVar:p,indexVar:d,iterable:m,body:h,flatten:s!=="nested"}};var vy=(e,t={})=>{let{functions:n={}}=t;return Sr(e,n)},qn=vy;var Mt={};jm(Mt,{now:()=>ky});var ky=()=>Date.now();var Ay=(e,t,n={})=>{let{functions:o={},partials:a={}}=n,r={...Mt,...o},s=qn(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=qn(c,{functions:r});return Xi(s,t,{functions:r,partials:i})},Kr=Ay;var Py=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Ey=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,xy=(e,t)=>{if(Py(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression");return Ee(e,t)}return Me(e,t)},Sy=(e,t={},n={})=>{let o=Ey(n),a={...Mt,...o},r=xy(e,a);return!!Er(r,{functions:a,partials:{}},t,{})},Ji=Sy;var oo=Symbol("runStoreTransaction"),ro="__routeEngineConditionComparison",Fn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",Or=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Fn(e,t)&&e>t,gte:(e,t)=>Fn(e,t)&&e>=t,lt:(e,t)=>Fn(e,t)&&e<t,lte:(e,t)=>Fn(e,t)&&e<=t}),Hl=Object.freeze(Object.fromEntries(Object.keys(Or).map(e=>[e,`${ro}${e}`]))),Oy=Object.freeze(Object.fromEntries(Object.entries(Hl).map(([e,t])=>[t,Or[e]]))),Fl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Ry=e=>{if(typeof e?.call=="string")return e.call;if(e?.call!==null&&typeof e?.call=="object"&&!Array.isArray(e.call))return e.call.name},Bn=e=>{if(Array.isArray(e))return e.map(Bn);if(e===null||typeof e!="object"||Fl(e,"literal")||Fl(e,"var"))return e;if(Ry(e)?.startsWith(ro))throw new Error(`Condition function names beginning with "${ro}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,r=Hl[o];if(r)return{call:r,args:a.map(Bn)}}return Object.fromEntries(n.map(([o,a])=>[o,Bn(a)]))},qt=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Ji(Bn(e),t,{functions:Oy})},Cy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Kl=(e,t,n={})=>{let o={},a={},{transformSelectorFirstArgument:r=h=>h,transformActionFirstArgument:s=h=>h,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},d=0,f=(h,g)=>!u||!c?h:Vn(h,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[h,g]of Object.entries(t))h!=="createInitialState"&&(h.startsWith("select")?o[h]=(...y)=>g(r(p.state,p.transactionalMetadata),...y):a[h]=(...y)=>{let w,b=p,A=Vn(p,k=>{let E=g(s(k.state,k.transactionalMetadata),...y);w=E!==void 0&&!Pe(E)?E:void 0,u&&l&&l({actionName:h,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});return d===0&&(A=f(A,b)),p=A,w});let m=h=>{if(typeof h!="function")throw new Error("Store transaction requires a callback");let g=p,y=d===0;d+=1;let w;try{w=h()}catch(b){throw d-=1,p=g,b}if(d-=1,y)try{p=f(p,g)}catch(b){throw p=g,b}return w};return{...o,...a,[oo]:m}},Xn=(e,t)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return Vn(o,r=>{a.forEach(s=>{t.forEach(i=>{i(r,s)})})})};var $y=(e,t)=>{if(e.default!==void 0)return e.default;let n=["number","boolean","string","object"];if(!n.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},Q=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),to=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},Ae=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),_y=new Set(["pageSize","groups"]),jy=new Set(["id","variants"]),Ny=new Set(["id","imageId"]),Dy=new Set(["pageSize","tracks"]),Ty=new Set(["id","soundId","title","artist","album","description","coverImageId"]),Ly=new Set(["pageSize","replays"]),My=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Wr=(e,t,n)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},yt=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Ft=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!Ae(t))throw new Error("resources.imageGallery must be an object");if(Wr(t,_y,"resources.imageGallery"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[o,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);if(Wr(a,jy,r),yt(a.id,`${r}.id`),n.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(n.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let s=new Set;for(let[i,l]of a.variants.entries()){let c=`${r}.variants[${i}]`;if(!Ae(l))throw new Error(`${c} must be an object`);if(Wr(l,Ny,c),yt(l.id,`${c}.id`),yt(l.imageId,`${c}.imageId`),s.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(s.add(l.id),!Q(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Bt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!Ae(t))throw new Error("resources.musicRoom must be an object");if(Wr(t,Dy,"resources.musicRoom"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[o,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);Wr(a,Ty,r);for(let l of["id","soundId","title"])yt(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&yt(a[l],`${r}.${l}`);if(n.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);n.add(a.id);let s=e?.resources?.sounds?.[a.soundId];if(!Q(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Ae(s))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(s.playbackRate!==void 0&&(typeof s.playbackRate!="number"||!Number.isFinite(s.playbackRate)||s.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let i=s.startAt??0;if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new Error(`Music room sound "${a.soundId}" startAt must be a finite non-negative number`);if(s.endAt!==void 0&&s.endAt!==null&&(typeof s.endAt!="number"||!Number.isFinite(s.endAt)||s.endAt<=i))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!Q(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Vy=(e,t,n)=>{let o=Array.isArray(n)?"array":typeof n;switch(t.type){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},Ut=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!Ae(t))throw new Error("resources.sceneReplay must be an object");if(Wr(t,Ly,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},o=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!Ae(r))throw new Error(`${s} must be an object`);Wr(r,My,s);for(let u of["sceneId","title","thumbnailImageId"])yt(r[u],`${s}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!Q(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let i=n[r.sceneId];if(!i)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=i.initialSectionId,c=i.sections?.[l];if(!c)throw new Error(`Scene replay scene "${r.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${r.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(r.initialVariables!==void 0){if(!Ae(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let d=e?.resources?.variables?.[u];if(!d)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(_e(d))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(d.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(d.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);Vy(u,d,p)}}}},Wl=e=>{let t=Pe(e)?Pr(e):e;return structuredClone(t)},qy=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!Q(t,"nameVariableId"))return;let o=t.nameVariableId,a=n?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Gn=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0;if(t?.name!==void 0)return t.name;if(n!==void 0)return n;let s=qy({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},_e=e=>Q(e,"computed"),ao=(e,t)=>{switch(e?.type){case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);default:return!1}},Yt=(e={},t={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?o:!_e(s)&&(!n||n.includes(s.scope))&&ao(s,r)})),Xe=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),Fy=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Xe(t,n)}let a="";for(let r=1;r<e.length-1;r+=1){let s=e[r];if(s!=="\\"){if(s.charCodeAt(0)<32)throw Xe(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Xe(t,n);let i=e[r];if(i==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Xe(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!Q(l,i))throw Xe(t,n);a+=l[i]}return a},Jl=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Xe(e,t);let n=[],o=0,a=()=>{let s=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(s,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw Xe(e,t);n.push(i)},r=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let s=e[o];if(/\d/.test(s??"")){let u=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(u,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw Xe(e,t);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Xe(e,t);let i=s,l=o;o+=1;let c=!1;for(;o<e.length;){let u=e[o];if(c)c=!1;else if(u==="\\")c=!0;else if(u===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw Xe(e,t);o+=1,n.push(Fy(p,e,t));return}o+=1}if(c||o>=e.length)throw Xe(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Xe(e,t)}return n},Qi=(e,t)=>{let n=e;for(let o of t){if(n==null||!Q(n,o))return;n=n[o]}return n},Ql=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Jl(e),[o,a,...r]=n;if(o==="variables"){if(!a)return t.variables;let s=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return Qi(s,r)}return o==="runtime"?Qi(t.runtime,n.slice(1)):Qi(t,n)},Zl=(e,t,n)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&t.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},no=(e,t)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(t.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},By=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Je=(e,t,n,o)=>(Zl(e,t,o),t.map(a=>zn(a,n))),ze=(e,t,n,o)=>{let a=Je(e,t,n,o);return a.forEach(r=>By(e,r)),a},Uy=(e,t,n)=>{switch(e){case"var":return Ql(t,n);case"add":{let[o,a]=ze(e,t,n,2);return o+a}case"sub":{let[o,a]=ze(e,t,n,2);return o-a}case"mul":{let[o,a]=ze(e,t,n,2);return o*a}case"div":{let[o,a]=ze(e,t,n,2);return o/a}case"mod":{let[o,a]=ze(e,t,n,2);return o%a}case"neg":{let[o]=ze(e,t,n,1);return-o}case"round":{let[o]=ze(e,t,n,1);return Math.round(o)}case"floor":{let[o]=ze(e,t,n,1);return Math.floor(o)}case"ceil":{let[o]=ze(e,t,n,1);return Math.ceil(o)}case"min":{let[o,a]=ze(e,t,n,2);return Math.min(o,a)}case"max":{let[o,a]=ze(e,t,n,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=ze(e,t,n,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=Je(e,t,n,2);return Or.eq(o,a)}case"neq":{let[o,a]=Je(e,t,n,2);return Or.neq(o,a)}case"gt":{let[o,a]=Je(e,t,n,2);return Or.gt(o,a)}case"gte":{let[o,a]=Je(e,t,n,2);return Or.gte(o,a)}case"lt":{let[o,a]=Je(e,t,n,2);return Or.lt(o,a)}case"lte":{let[o,a]=Je(e,t,n,2);return Or.lte(o,a)}case"in":{let[o,a]=Je(e,t,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return no(e,t),t.every(o=>!!zn(o,n));case"or":case"any":return no(e,t),t.some(o=>!!zn(o,n));case"not":{let[o]=Je(e,t,n,1);return!o}case"length":{let[o]=Je(e,t,n,1);return typeof o=="string"||Array.isArray(o)?o.length:Ae(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Je(e,t,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return Wl(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},zn=(e,t={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let n=Object.entries(e);if(n.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=n;return Uy(o,a,t)},so=(e,t)=>{if(e===null||typeof e!="object"||Q(e,"literal"))return e;if(Q(e,"var"))return{literal:Ql(e.var,t)};if(Q(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([n,o])=>[n,Array.isArray(o)?o.map(a=>so(a,t)):so(o,t)]))},Yy=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),qt(so(e,t))},ec=(e,t)=>{if(!Ae(e))throw new Error(`${t} must be an object`);let n=Q(e,"expr"),o=Q(e,"value");if(n===o)throw new Error(`${t} must contain exactly one of expr or value`)},Zi=(e,t,n)=>(ec(e,t),Q(e,"value")?Wl(e.value):zn(e.expr,n)),zy=(e,t={},n="unknown")=>{if(!Ae(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=Q(e,"expr"),a=Q(e,"value");if(Q(e,"branches")){if(o||a)throw new Error(`Computed variable "${n}" cannot combine branches with expr or value`);if(!Array.isArray(e.branches))throw new Error(`Computed variable "${n}" branches must be an array`);if(e.branches.length===0)throw new Error(`Computed variable "${n}" branches must not be empty`);if(!Ae(e.default))throw new Error(`Computed variable "${n}" requires default`);for(let s=0;s<e.branches.length;s+=1){let i=e.branches[s];if(!Ae(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!Q(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Yy(i.when,t))return Zi(i,`Computed variable "${n}" branch ${s}`,t)}return Zi(e.default,`Computed variable "${n}" default`,t)}if(o===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return Zi(e,`Computed variable "${n}"`,t)},rc=(e,t,n)=>{switch(t){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(n)?"array":typeof n}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(n)?"array":typeof n}`);return;case"string":if(typeof n!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(n)?"array":typeof n}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof n}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},Xy=Object.freeze({add:2,sub:2,mul:2,div:2,mod:2,neg:1,round:1,floor:1,ceil:1,min:2,max:2,clamp:3,eq:2,neq:2,gt:2,gte:2,lt:2,lte:2,in:2,not:1,length:1,includes:2}),Gy=new Set(["and","or","all","any"]),Hy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Ky=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Wy=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Jy=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),tc=new WeakMap,Bl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Un=(e,t,n)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},Qy=(e,t,n,o)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${n}`)},nc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,i,...l]=Jl(e,r);if(s!=="variables"&&s!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${r} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!Q(n,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=n[i];return _e(c)&&o.add(i),l.length===0?c?.type:void 0},sc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Bl(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let r=Object.entries(e);if(r.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,i]]=r;if(s==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return nc(i,{variableId:t,variableConfigs:n,dependencies:o,path:a})}if(s==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Bl(i)}let l=Xy[s];if(l===void 0&&!Gy.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?no(s,i):Zl(s,i,l);let c=i.map((u,p)=>sc(u,{variableId:t,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(Ky.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Hy.has(s))return"number";if(Wy.has(s))return"boolean"},Zy=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Me(e)}catch(s){throw new Error(`Computed variable "${t}" ${a} is invalid: ${s.message}`,{cause:s})}let r=(s,i)=>{if(s===null||typeof s!="object"||Q(s,"literal"))return;if(Q(s,"var")){nc(s.var,{variableId:t,variableConfigs:n,dependencies:o,path:i});return}if(Q(s,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(Q(s,"not")){r(s.not,`${i}.not`);return}let l=Object.keys(s).find(c=>Jy.has(c));s[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},eo=(e,{variableId:t,variableConfig:n,variableConfigs:o,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(ec(e,`Computed variable "${t}" ${r}`),Un(e,s,r),Q(e,"value")){rc(t,n.type,e.value);return}let i=sc(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});Qy(t,n.type,i,`${r}.expr`)},eh=(e,t,n)=>{let o=t.computed;if(!Ae(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=Q(o,"expr"),s=Q(o,"value");if(Q(o,"branches")){if(Un(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||s)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(o.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(o.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!Ae(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Ae(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Un(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!Q(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Zy(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),eo(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),eo(o.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Un(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return eo(o,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Jr=(e={})=>{if(!Ae(e))throw new Error("Variable configs must be an object");if(Q(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(Q(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(_e(s)){if(!Ae(s))throw new Error(`Computed variable "${r}" must be an object`);if(!Q(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!Q(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(Q(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(zt(s.scope,r),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${r}`);t.set(r,eh(r,s,e))}});let n=new Set,o=[];t.forEach((r,s)=>{if(n.has(s))return;let i=[{variableId:s,dependencies:[...t.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),n.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let d=[...i.slice(p).map(({variableId:f})=>f),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${d}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return tc.set(e,a),a},ht=({variables:e={},runtime:t={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=tc.get(n)??Jr(n),r=Yt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>_e(g)).map(([g])=>g),i=Object.create(null),l=[],c=new Map(a.map((g,y)=>[g,y])),u=-1,p=!1,d=g=>{if(Q(i,g))return i[g];let y=n[g];if(!_e(y))return Q(r,g)?r[g]:void 0;let w=l.indexOf(g);if(w>=0){let b=[...l.slice(w),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=zy(y.computed,h,g);return rc(g,y.type,b),to(i,g,b),b}finally{l.pop()}},f=g=>{if(Q(i,g))return i[g];let y=n[g];if(!_e(y))return Q(r,g)?r[g]:void 0;let w=c.get(g);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let b=u+1;b<=w;b+=1)d(a[b]),u=b}finally{p=!1}return i[g]}return d(g)},m=new Proxy({},{get:(g,y)=>{if(typeof y=="string")return f(y)},has:(g,y)=>typeof y=="string"&&(Q(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(g,y)=>{if(!(typeof y!="string"||!Q(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),h={variables:m,runtime:t,resolveVariable:f};return o?(s.forEach(g=>{f(g)}),{...r,...i}):m},rh=({variables:e={},runtime:t={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return Jr(a),ht({variables:e,runtime:t,variableConfigs:a,eager:!0})},Hn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(_e(a))return;let r=$y(a,o);a.scope==="context"?to(t,o,r):to(n,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},zt=(e,t)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${n.join(", ")}`)},Xt=(e,t,n)=>{let o={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=o[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(o).flat().includes(t))throw new Error(`Unknown operation: ${t}`);if(!a.includes(t))throw new Error(`Operation "${t}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},th=2,Ul=12,ic=(e=th)=>{if(!Number.isInteger(e)||e<0||e>Ul)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Ul}.`);return e},nh=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},Yn=e=>typeof e=="number"&&Number.isFinite(e),Kn=(e,t,n,o,a={})=>{if(e==="number"){if(t==="set"&&!Yn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!Yn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!Yn(n))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(t==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);ic(a.roundTo)}}},Wn=(e,t,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!Yn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=s=>{let i=a(s,void 0,"value");if(i===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return i};switch(t){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return nh(a(e,0,"current value")/r(n),ic(o.roundTo));case"increment":return a(e,0,"current value")+a(n,1,"value");case"decrement":return a(e,0,"current value")-a(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var lo=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),r={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:Cy[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(n.getHours()),mm:o(n.getMinutes()),ss:o(n.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>r[s])},sh=(e,t)=>{let n=r=>r?.ui,o=n(e),a=n(t);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:t}:a&&o?{changeType:"update",data:t}:null},Vt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,ih=(e,t)=>{let n=e?.character?.sprite,o=t?.character?.sprite,a=Vt(n)?n:void 0,r=Vt(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},Yl=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[n]!==void 0&&(t[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(t[n]=e[n]);return t},zl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Xl=(e,t)=>t&&!e?{changeType:"add",data:t}:e&&!t?{changeType:"delete",data:e}:e&&t&&JSON.stringify(e)!==JSON.stringify(t)?{changeType:"update",data:t}:null,oh=(e,t)=>{let n={},o=Xl(Yl(e),Yl(t)),a=Xl(zl(e),zl(t));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},co=(e={},t={})=>{let n={},o=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)n[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(d=>d.applyMode==="persistent");!o.includes(l)&&(l!=="sfx"||p)&&(n[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},r=oh(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=sh(e.dialogue,t.dialogue);s&&(n.dialogue=s);let i=ih(e.dialogue,t.dialogue);return i&&(n.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},uo=(e={})=>{let t=structuredClone(e);if(t.sfx){let a=Array.isArray(t.sfx.channels)?t.sfx.channels.filter(r=>r.applyMode==="persistent"):[];a.length>0?t.sfx={channels:a}:delete t.sfx}t.background&&(t.background.animations?.playback?.continuity!=="persistent"&&delete t.background.animations,!t.background.resourceId&&!t.background.colorId&&delete t.background);let n=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};n("layout"),n("choice"),n("form"),n("screen"),t.dialogue?.ui&&(delete t.dialogue.ui.animations,Object.keys(t.dialogue.ui).length===0&&delete t.dialogue.ui,Object.keys(t.dialogue).length===0&&delete t.dialogue),t.dialogue?.character?.sprite&&(delete t.dialogue.character.sprite.animations,Object.keys(t.dialogue.character.sprite).length===0&&delete t.dialogue.character.sprite,Object.keys(t.dialogue.character).length===0&&delete t.dialogue.character,Object.keys(t.dialogue).length===0&&delete t.dialogue);let o=(a,r)=>{let s=t[a]?.items;Array.isArray(s)&&(t[a].items=s.map(i=>{let l={...i};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return o("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),o("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),t},ah=(e,t)=>{if(!e||!t)return;let n=e;for(let o of t.split(".")){if(n==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),o))return;n=n[o]}return n},Gl=e=>e!==null&&typeof e=="object"?structuredClone(e):e,lh=(e,t,n)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(t??{},n)?t[n]:void 0;if(e===n){if(o==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return Gl(o)}if(!e.startsWith(`${n}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${n}".`);let a=e.slice(n.length+1),r=ah(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return Gl(r)},ch={conditional:new Set(["branches"]),updateProjectData:new Set(["projectData"]),showConfirmDialog:new Set(["confirmActions","cancelActions"]),form:new Set(["submitActions","cancelActions"]),submitForm:new Set(["actions"]),cancelForm:new Set(["actions"])},uh=(e,t)=>{let n=e[e.length-1];return n?ch[n]?.has(t)===!0:!1},io=(e,t,n=[])=>Array.isArray(e)?e.map(o=>io(o,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,uh(n,o)?a:io(a,t,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?lh(e,t,"_event"):Kr(e,t):e,Gt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return io(e,t)};var ph=11102230246251565e-32,oc=128,ac=1e3,lc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ht=(e,t,n)=>{let o=Object.keys(e).find(a=>!t.has(a));if(o!==void 0)throw new Error(`${n}.${o} is not supported`)},Jn=(e,t)=>{if(!lc(e))throw new Error(`${t} must be an object`)},Qn=(e,t,{min:n,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},fh=(e,t,{min:n,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},po=e=>{let t=structuredClone(e),n=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(n),Object.freeze(o)),o);return n(t)},dh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),cc=e=>{let t=e??dh();if(!lc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=t.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},mh=(e,t)=>{let n=4294967296-4294967296%t;for(let o=0;o<oc;o+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${oc} rejected samples`)},yh=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},hh=(e,t)=>{if(Ht(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let n=Qn(e.min,"random.distribution.min"),a=Qn(e.max,"random.distribution.max")-n+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return po({type:"integer",value:a===1?n:n+mh(t,a)})},gh=(e,t)=>{if(Ht(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>ac)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let n=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(Jn(c,p),Ht(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Jn(c.actions,`${p}.actions`),{weight:fh(c.weight,`${p}.weight`,{min:0})}}),o=Math.max(...n.map(({weight:c})=>c));if(o<=0)throw new Error("random weighted total weight must be positive");let a=n.map(c=>({...c,weight:c.weight/o})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(n[u].weight>0&&(c.weight===0||c.weight/r<=ph))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=yh(t)*r,i=0,l=a.findLastIndex(({weight:c})=>c>0);for(let c=0;c<a.length;c+=1){let u=a[c];if(i+=u.weight,s<i){l=c;break}}return po({type:"weighted",outcomeIndex:l})},uc=(e,{randomSource:t})=>{Jn(e,"random.distribution");let o={integer:hh,weighted:gh}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},Zn=(e,t)=>{if(Jn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Ht(e,new Set(["type","value"]),"random result"),Qn(e.value,"random result.value");else if(t==="weighted")Ht(e,new Set(["type","outcomeIndex"]),"random result"),Qn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:ac-1});else throw new Error(`unsupported recorded random result type: ${t}`);return po(e)};var Qr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),dc=Object.freeze([Qr("cleanup",["clearPendingEffects","cleanAll"]),Qr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Qr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Qr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Qr("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),Qr("persistence",["saveSlot"]),Qr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),gt=new Map;dc.forEach(e=>{e.actions.forEach(t=>{if(gt.has(t))throw new Error(`duplicate action execution key: ${t}`);gt.set(t,gt.size)})});var bh=new Set(dc.find(({name:e})=>e==="navigation").actions),pc=gt.get("saveSlot")-.5,fc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",wh=(e,t)=>e<t?-1:e>t?1:0,es=e=>Object.entries(e).sort((t,n)=>{let o=fc(...t),a=fc(...n),r=gt.get(o),s=gt.get(a),i=r??pc,l=s??pc;return i!==l?i-l:r!==void 0&&s!==void 0?0:wh(o,a)}),rs=e=>bh.has(e),ts=e=>{let t=e.map(([n])=>n).filter(rs);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var Ih=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Rr=(...e)=>e.map(Ih).join(":");var Cr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Kt=Object.freeze({volume:100,pan:0,playbackRate:1}),ns=["volume","pan","playbackRate"],vh=["src","startAt","endAt","startDelayMs"],mc=(e,t)=>{if(!e)return null;let n=e.children??[];if(n.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return n[0]},bc=(e,t)=>e?.id===t?.id&&vh.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),wc=(e,t)=>JSON.stringify(e)===JSON.stringify(t),kh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),mo=e=>Math.max(-1,Math.min(1,e)),yo=({bgm:e,resources:t,renderedSound:n,property:o})=>{let a=e?.sounds?.find(({id:s})=>Rr("bgm",s)===n?.id),r=t.sounds?.[a?.resourceId];return a?.[o]??r?.[o]??Kt[o]},Ah=({property:e,value:t,relative:n,bgm:o,resources:a,renderedSound:r})=>{if(!o||!r)return t;if(e==="volume"){let s=yo({bgm:o,resources:a,renderedSound:r,property:e});return t*s/100}if(e==="pan"&&!n){let s=yo({bgm:o,resources:a,renderedSound:r,property:e});return mo(t+s)}return t},Ph=({authoredInitialValue:e,authoredKeyframes:t,baselineBgm:n,compiledKeyframes:o,bgm:a,resources:r,renderedSound:s})=>{if(!a||!s)return o;let i=yo({bgm:a,resources:r,renderedSound:s,property:"pan"}),l=e??n?.pan??Kt.pan;return o.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let d=Cr(p,"startValue")?l+p.startValue:l,f=d+p.value,{relative:m,...h}=c;return l=f,{...h,...Cr(p,"startValue")?{startValue:mo(d+i)}:{},value:mo(f+i)}})},Ic=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},Eh=(e,t)=>({...Cr(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),vc=({property:e,authored:t,speed:n,propertyPath:o,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${o}.keyframes] The final keyframe must use an absolute finite numeric value.`);let s={keyframes:t.keyframes.map(i=>{let l=Eh(i,n),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),Cr(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return Cr(t,"initialValue")&&(s.initialValue=a({property:e,value:t.initialValue,relative:!1})),s},fo=({authored:e,bgm:t,baselineBgm:n=t,property:o,propertyPath:a,renderedSound:r,resources:s,speed:i})=>{let l=vc({property:o,authored:e,speed:i,propertyPath:a,normalizeValue:({value:c,relative:u})=>Ah({property:o,value:c,relative:u,bgm:t,resources:s,renderedSound:r})});return o==="pan"&&(l.keyframes=Ph({authoredInitialValue:e.initialValue,authoredKeyframes:e.keyframes,baselineBgm:n,compiledKeyframes:l.keyframes,bgm:t,resources:s,renderedSound:r})),l},yc=({actionPath:e,compiled:t,property:n,propertyPath:o,renderedSound:a})=>{let r=a[n]??Kt[n],s=t.keyframes.at(-1);if(!kh(s.value,r))throw new Error(`[${e}.audioEffects]
|
|
3
|
-
[${o}.keyframes] The final keyframe value must match the persistent BGM ${n} value.`);s.value=r},
|
|
1
|
+
var Tm=Object.defineProperty;var Lm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mm=(e,t)=>{for(var n in t)Tm(e,n,{get:t[n],enumerable:!0})};var mf=Lm(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});function df(e){let t=e.length,n=0,o=0,a;for(;o<t;)n++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<t&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return n}Ya.default=df;df.code='require("ajv/dist/runtime/ucs2length").default'});var Al=Symbol.for("immer-nothing"),bl=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state");function Ye(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var dt=Object.getPrototypeOf;function Pe(e){return!!e&&!!e[Le]}function Gr(e){return e?Pl(e)||Array.isArray(e)||!!e[bl]||!!e.constructor?.[bl]||Tn(e)||Ln(e):!1}var Vm=Object.prototype.constructor.toString();function Pl(e){if(!e||typeof e!="object")return!1;let t=dt(e);if(t===null)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Vm}function Nn(e){return Pe(e)||Ye(15,e),e[Le].base_}function $n(e,t){Dn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function Dn(e){let t=e[Le];return t?t.type_:Array.isArray(e)?1:Tn(e)?2:Ln(e)?3:0}function Vi(e,t){return Dn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function El(e,t,n){let o=Dn(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function qm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Tn(e){return e instanceof Map}function Ln(e){return e instanceof Set}function Xr(e){return e.copy_||e.base_}function qi(e,t){if(Tn(e))return new Map(e);if(Ln(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Pl(e);if(t===!0||t==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Le];let a=Reflect.ownKeys(o);for(let r=0;r<a.length;r++){let s=a[r],i=o[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(dt(e),o)}else{let o=dt(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function zi(e,t=!1){return Mn(e)||Pe(e)||!Gr(e)||(Dn(e)>1&&(e.set=e.add=e.clear=e.delete=Fm),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>zi(o,!0))),e}function Fm(){Ye(2)}function Mn(e){return Object.isFrozen(e)}var Bm={};function Hr(e){let t=Bm[e];return t||Ye(0,e),t}var Tt;function xl(){return Tt}function Um(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function wl(e,t){t&&(Hr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Fi(e){Bi(e),e.drafts_.forEach(Ym),e.drafts_=null}function Bi(e){e===Tt&&(Tt=e.parent_)}function Il(e){return Tt=Um(Tt,e)}function Ym(e){let t=e[Le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function vl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Le].modified_&&(Fi(t),Ye(4)),Gr(e)&&(e=_n(t,e),t.parent_||jn(t,e)),t.patches_&&Hr("Patches").generateReplacementPatches_(n[Le].base_,e,t.patches_,t.inversePatches_)):e=_n(t,n,[]),Fi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Al?e:void 0}function _n(e,t,n){if(Mn(t))return t;let o=t[Le];if(!o)return $n(t,(a,r)=>kl(e,o,t,a,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return jn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,r=a,s=!1;o.type_===3&&(r=new Set(a),a.clear(),s=!0),$n(r,(i,l)=>kl(e,o,a,i,l,n,s)),jn(e,a,!1),n&&e.patches_&&Hr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function kl(e,t,n,o,a,r,s){if(Pe(a)){let i=r&&t&&t.type_!==3&&!Vi(t.assigned_,o)?r.concat(o):void 0,l=_n(e,a,i);if(El(n,o,l),Pe(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Gr(a)&&!Mn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;_n(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&jn(e,a)}}function jn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&zi(t,n)}function zm(e,t){let n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:xl(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=Xi;n&&(a=[o],r=Lt);let{revoke:s,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=s,i}var Xi={get(e,t){if(t===Le)return e;let n=Xr(e);if(!Vi(n,t))return Xm(e,n,t);let o=n[t];return e.finalized_||!Gr(o)?o:o===Li(e.base_,t)?(Mi(e),e.copy_[t]=Yi(o,e)):o},has(e,t){return t in Xr(e)},ownKeys(e){return Reflect.ownKeys(Xr(e))},set(e,t,n){let o=Sl(Xr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=Li(Xr(e),t),r=a?.[Le];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(qm(n,a)&&(n!==void 0||Vi(e.base_,t)))return!0;Mi(e),Ui(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Li(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mi(e),Ui(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Xr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){Ye(11)},getPrototypeOf(e){return dt(e.base_)},setPrototypeOf(){Ye(12)}},Lt={};$n(Xi,(e,t)=>{Lt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Lt.deleteProperty=function(e,t){return Lt.set.call(this,e,t,void 0)};Lt.set=function(e,t,n){return Xi.set.call(this,e[0],t,n,e[0])};function Li(e,t){let n=e[Le];return(n?Xr(n):e)[t]}function Xm(e,t,n){let o=Sl(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Sl(e,t){if(!(t in e))return;let n=dt(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=dt(n)}}function Ui(e){e.modified_||(e.modified_=!0,e.parent_&&Ui(e.parent_))}function Mi(e){e.copy_||(e.copy_=qi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Gm=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){let r=n;n=t;let s=this;return function(l=r,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Ye(6),o!==void 0&&typeof o!="function"&&Ye(7);let a;if(Gr(t)){let r=Il(this),s=Yi(t,void 0),i=!0;try{a=n(s),i=!1}finally{i?Fi(r):Bi(r)}return wl(r,o),vl(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===Al&&(a=void 0),this.autoFreeze_&&zi(a,!0),o){let r=[],s=[];Hr("Patches").generateReplacementPatches_(t,a,r,s),o(r,s)}return a}else Ye(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,l=>t(l,...i));let o,a;return[this.produce(t,n,(s,i)=>{o=s,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Gr(e)||Ye(8),Pe(e)&&(e=Er(e));let t=Il(this),n=Yi(e,void 0);return n[Le].isManual_=!0,Bi(t),n}finishDraft(e,t){let n=e&&e[Le];(!n||!n.isManual_)&&Ye(9);let{scope_:o}=n;return wl(o,t),vl(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));let o=Hr("Patches").applyPatches_;return Pe(e)?o(e,t):this.produce(e,a=>o(a,t))}};function Yi(e,t){let n=Tn(e)?Hr("MapSet").proxyMap_(e,t):Ln(e)?Hr("MapSet").proxySet_(e,t):zm(e,t);return(t?t.scope_:xl()).drafts_.push(n),n}function Er(e){return Pe(e)||Ye(10,e),Ol(e)}function Ol(e){if(!Gr(e)||Mn(e))return e;let t=e[Le],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=qi(e,t.scope_.immer_.useStrictShallowCopy_)}else n=qi(e,!0);return $n(n,(o,a)=>{El(n,o,Ol(a))}),t&&(t.finalized_=!1),n}var Ve=new Gm,Vn=Ve.produce,Zk=Ve.produceWithPatches.bind(Ve),eA=Ve.setAutoFreeze.bind(Ve),rA=Ve.setUseStrictShallowCopy.bind(Ve),tA=Ve.applyPatches.bind(Ve),nA=Ve.createDraft.bind(Ve),sA=Ve.finishDraft.bind(Ve);var x={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},mt={NOT:0};var T=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ne=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Gi=e=>{if(!e||e.trim()==="")throw new T("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new T(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let n of t)if(e.trim().endsWith(n))throw new T(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Rl=e=>{if(e.trim().endsWith(" in"))throw new T(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new T(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new T(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of o){if(!a)throw new T(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new T(`Invalid loop syntax (got: '$for ${e}')`)}};var Cl=(e,t,n=!1)=>{if(t===null)return new Ne(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ne(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return n?new Ne(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ne(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},$l=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ne(`Unknown function '${e}' (${n})`)};var Hm=(e,t,n={})=>{let o={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(o=n.functions||{},a=n.partials||{}):typeof n=="object"&&(o=n));let s=se(e,{functions:o,partials:a},t,{});return s===void 0?{}:s},se=(e,t,n,o)=>{let a=t.functions||t;if(e.var&&!e.type)return ke(e.var,n,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ke(e.path,n,o);if(e.type===x.INTERPOLATION)return Wm(e.parts,t,n,o);switch(e.type){case x.FUNCTION:return jl(e,t,n,o);case x.BINARY:return Nl(e,t,n,o);case x.UNARY:return Dl(e,t,n,o);case x.CONDITIONAL:return Qm(e,t,n,o);case x.LOOP:return ny(e,t,n,o);case x.OBJECT:return iy(e,t,n,o);case x.ARRAY:return oy(e,t,n,o);case x.PARTIAL:return ay(e,t,n,o);case x.PATH_REFERENCE:return ly(e,t,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},_l=new Map,Km=e=>{let t=[],n="",o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")n&&(t.push({type:"property",value:n}),n=""),o=!0;else if(r==="]"){if(o&&n){let s=n.trim();if(/^\d+$/.test(s))t.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let i=s.slice(1,-1);t.push({type:"property",value:i})}else t.push({type:"property",value:s});n=""}o=!1}else n+=r}return n&&t.push({type:"property",value:n}),t},ke=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let o=_l.get(e);if(!o){let r=[],s="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,s+=c):c==="]"?(i--,s+=c):c==="."&&i===0?s&&(r.push(s),s=""):s+=c}s&&r.push(s),o=[];for(let l of r){let c=Km(l.trim());o.push(...c)}_l.set(e,o)}let a=t;for(let r=0;r<o.length;r++){let s=o[r];if(s.type==="property"&&s.value in n){a=n[s.value];continue}if(a==null)return;(s.type==="property"||s.type==="index")&&(a=a[s.value])}return a},Wm=(e,t,n,o)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=se(r,t,n,o);a.push(s!=null?String(s):"")}return a.join("")},jl=(e,t,n,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw $l(e.name,a);let s=e.args.map(i=>se(i,t,n,o));return r(...s)},xr=(e,t,n,o)=>{if(e.var&&!e.type)return ke(e.var,n,o);switch(e.type){case x.VARIABLE:return ke(e.path,n,o);case x.LITERAL:return e.value;case x.BINARY:return Nl(e,t,n,o);case x.UNARY:return Dl(e,t,n,o);case x.FUNCTION:return jl(e,t,n,o);default:return se(e,t,n,o)}},Nl=(e,t,n,o)=>{if(e.op===ee.AND||e.op===ee.OR){let s=xr(e.left,t,n,o),i=xr(e.right,t,n,o);switch(e.op){case ee.AND:return s&&i;case ee.OR:return s||i}}let a=se(e.left,t,n,o),r=se(e.right,t,n,o);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Dl=(e,t,n,o)=>{let a=e.op===mt.NOT?xr(e.operand,t,n,o):se(e.operand,t,n,o);if(e.op===mt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Jm=(e,t,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ke(a.path,n,o)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?se(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let d=ke(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=se(m,t,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=se(u,t,n,o)}return i}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?se(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let d=ke(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=se(m,t,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=se(u,t,n,o)}return i}}}return null},Qm=(e,t,n,o)=>{let a=Jm(e,t,n,o);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let s=e.conditions[r];if(s===null||xr(s,t,n,o))return se(e.bodies[r],t,n,o)}return Tl},Zm=(e,t)=>{let n=e.body,o=e.itemVar;if(n.type===x.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===x.VARIABLE){let a=n.conditions[0].path,r=n.bodies[0];if(a.startsWith(o+".")){let s=a.substring(o.length+1);if(r.type===x.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let i=[];for(let l=0;l<t.length;l++){let c=t[l];if(c[s]){let u={};for(let p of r.properties){let m=p.key,d=p.value;if(d.type===x.LITERAL)u[m]=d.value;else if(d.type===x.VARIABLE){let f=d.path;if(f===o)u[m]=c;else if(f.startsWith(o+".")){let h=f.substring(o.length+1);u[m]=c[h]}else return null}else if(d.type===x.INTERPOLATION){let f=[],h=!0;for(let b of d.parts)if(typeof b=="string")f.push(b);else if(b.type===x.VARIABLE){let y=b.path;if(y===o)f.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),g=c[w];f.push(g!=null?String(g):"")}else{h=!1;break}}else{h=!1;break}if(!h)return null;u[m]=f.join("")}else return null}i.push(u)}}return i}}}return null},ey=(e,t)=>{let n=e.body,o=e.itemVar,a=Zm(e,t);if(a!==null)return a;if(n.type===x.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let i of n.properties)if(i.parsedKey)return null;let r=[],s=!0;for(let i of n.properties){let l=i.key,c=i.value;if(c.type===x.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===x.VARIABLE){let u=c.path;if(u===o)r.push({key:l,type:"item"});else if(u.startsWith(o+".")){let p=u.substring(o.length+1);if(!p.includes(".")&&!p.includes("["))r.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(c.type===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===o)r.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let m=p.substring(o.length+1);if(!m.includes(".")&&!m.includes("["))r.push({key:l,type:"prop_string",prop:m});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let i=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}i[l]=u}return i}}return null},ry=(e,t,n,o,a)=>{let r=[],s=e.body;if(s.type===x.OBJECT&&s.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...o,[i]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let f=d.split("."),h=f[0];h in o.__paths__&&(d=o.__paths__[h],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[i]:`${d}[${c}]`,...l&&{[l]:c}};for(let f of s.properties){let h=f.parsedKey?se(f.parsedKey,t,n,m):f.key,b=f.value;if(b.type===x.LITERAL)p[h]=b.value;else if(b.type===x.VARIABLE){let y=b.path;if(y===i)p[h]=u;else if(y===l)p[h]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[h]=u[w]:p[h]=ke(y,n,{...o,[i]:u,...l&&{[l]:c}})}else p[h]=ke(y,n,{...o,[i]:u,...l&&{[l]:c}})}else if(b.type===x.INTERPOLATION){let y=[];for(let w of b.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=w.path,A;if(g===i)A=u;else if(g===l)A=c;else if(g.startsWith(i+".")){let k=g.substring(i.length+1);!k.includes(".")&&!k.includes("[")?A=u[k]:A=ke(g,n,{...o,[i]:u,...l&&{[l]:c}})}else A=ke(g,n,{...o,[i]:u,...l&&{[l]:c}});y.push(A!=null?String(A):"")}else{let g={...o,[i]:u,...l&&{[l]:c}},A=se(w,t,n,g);y.push(A!=null?String(A):"")}p[h]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[h]=se(b,t,n,y)}}r.push(p)}return r}return null},ty=(e,t,n)=>{let o=e.body;if(o.type===x.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let r=o.properties[0].value;if(r.type===x.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===x.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===x.OBJECT&&s.properties.length===2){let i=s.properties[0],l=s.properties[1];if(i.key==="id"&&i.value.type===x.VARIABLE&&i.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},ny=(e,t,n,o)=>{let a=se(e.iterable,t,n,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===x.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===x.VARIABLE?d.path:d.type===x.FUNCTION?`${d.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Cl(p,a,u)}if(!e.indexVar){let c=ty(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=ey(e,a);if(c!==null)return c}let r=ry(e,t,n,o,a);if(r!==null)return r;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let c=i.split("."),u=c[0];u in o.__paths__&&(i=o.__paths__[u],c.length>1&&(i+="."+c.slice(1).join(".")))}let l=!1;e.body.type===x.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===x.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...o,[e.itemVar]:a[c],[e.indexVar]:c}:{...o,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=o.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${i}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=se(e.body,t,n,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];s.push(m===void 0?{}:m)}else s.push(p===void 0?{}:p)}return s},sy=(e,t,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?se(a.parsedKey,t,n,o):a.key,s=a.value;if(s.type===x.OBJECT&&s.properties.length<=10&&!s.whenCondition){let i={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?se(u.parsedKey,t,n,o):u.key,m=u.value;if(m.type===x.LITERAL)l[p]=m.value;else if(m.type===x.VARIABLE)l[p]=ke(m.path,n,o);else if(m.type===x.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===x.VARIABLE){let h=ke(f.path,n,o);d.push(h!=null?String(h):"")}else{c=!1;break}if(!c)break;l[p]=d.join("")}else if(m.type===x.OBJECT&&m.properties.length<=5){let d={};for(let f of m.properties){let h=f.key,b=f.value;if(b.type===x.LITERAL)d[h]=b.value;else if(b.type===x.VARIABLE)d[h]=ke(b.path,n,o);else if(b.type===x.INTERPOLATION){let y=[];for(let w of b.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=ke(w.path,n,o);y.push(g!=null?String(g):"")}else{c=!1;break}if(!c)break;d[h]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=d}else{c=!1;break}}if(c)return i[r]=l,i}}return null},iy=(e,t,n,o)=>{let a=t.functions||t;if(e.whenCondition&&!xr(e.whenCondition,a,n,o))return;let r=sy(e,t,n,o);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?se(u.parsedKey,t,n,o):u.key,m=u.value;if(m.type===x.LITERAL)c[p]=m.value;else if(m.type===x.VARIABLE)c[p]=ke(m.path,n,o);else if(m.type===x.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===x.VARIABLE){let h=ke(f.path,n,o);d.push(h!=null?String(h):"")}else{let h=se(f,t,n,o);d.push(h!=null?String(h):"")}c[p]=d.join("")}else c[p]=se(m,t,n,o)}return c}let s={},i=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=se(c.value,t,n,o);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return se(c.value,t,n,o)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(m=>m.key.startsWith("$for "));if(p){let m=se(p.value,t,n,o);m!==void 0&&(s[c.key]=m)}else{let m=se(c.value,t,n,o);m!==void 0&&(s[c.key]=m)}}else{let p=c.parsedKey?se(c.parsedKey,t,n,o):c.key,m=se(c.value,t,n,o);m!==void 0&&(s[p]=m)}}return s},Tl={},oy=(e,t,n,o)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let s=se(r,t,n,o);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=se(r,t,n,o);s!==Tl&&s!==void 0&&a.push(s)}return a},ay=(e,t,n,o)=>{let{name:a,data:r,whenCondition:s}=e,i=t.partials||{},l=t.functions||t;if(s&&!xr(s,l,n,o))return;if(!i[a])throw new Ne(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new Ne(`Circular partial reference detected: ${a}`);let u=i[a],p=n,m={...o,_partialStack:[...c,a]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(r){let d=se(r,t,n,o);p={...p,...d}}return se(u,t,p,m)},ly=(e,t,n,o)=>{let{path:a}=e,r=a.split("."),s=r[0],i=r.slice(1);if(!o||!(s in o))throw new Ne(`Path reference '#{${a}}' refers to '${s}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(s in o.__paths__))throw new Ne(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[s];if(typeof l=="number"){if(i.length>0)throw new Ne(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Hi=Hm;var cy=/\$\{([^}]*)\}/g,uy=/#\{([^}]*)\}/g,Ml=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,r=py(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},py=(e,t={})=>e.trim()?fy(e).map(o=>dy(o.trim(),t)):[],fy=e=>{let t=[],n="",o=0,a=!1,r="";for(let s=0;s<e.length;s++){let i=e[s],l=s>0?e[s-1]:"";!a&&(i==='"'||i==="'")?(a=!0,r=i,n+=i):a&&i===r&&l!=="\\"?(a=!1,r="",n+=i):!a&&i==="("?(o++,n+=i):!a&&i===")"?(o--,n+=i):!a&&i===","&&o===0?(t.push(n),n=""):n+=i}return n&&t.push(n),t},dy=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:x.LITERAL,value:parseFloat(e)};if(e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};let n=Ml(e,t);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,s=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Kr(o.substring(c),i);if(u===-1)break;let p=c+u;p>r&&(r=p,s={op:i,type:l}),c=p+i.length}}if(r!==-1)try{return Ee(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Vl=/^\w+\(.*\)$/,my=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,yy=e=>{if(!(!e||e.trim()===""||Vl.test(e))&&my.test(e))throw e.includes("?")&&e.includes(":")?new T(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new T(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new T(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ll=e=>{let t=e.trim();if(Vl.test(t))throw new T(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new T(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new T(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new T(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new T(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},Mt=(e,t={})=>{let n=e.trim();yy(n);let o=Ml(n,t);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let r of n)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:n}},Ki=(e,t={})=>{let n=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(n=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),n=n.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),n=n.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(cy)],r=[...n.matchAll(uy)],s=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:x.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&o.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?Mt(c[1],t):Ll(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:n};throw p}}let i=[],l=0;for(let{match:c,type:u}of s){let[p,m]=c,d=c.index;if(d>l){let f=n.substring(l,d);for(let h=0;h<o.length;h++)f=f.replace(`__ESCAPED_${h}__`,o[h]);f&&i.push(f)}try{let f;u==="variable"?f=Mt(m.trim(),t):f=Ll(m.trim()),i.push(f)}catch(f){if(f.message==="Invalid array index syntax")i.push(p);else throw f}l=d+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);c&&i.push(c)}return{type:x.INTERPOLATION,parts:i}};var Qi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Bl=e=>Object.keys(e),$e=e=>e.join("."),Sr=(e,t,n)=>{let o=Bl(e).filter(a=>!t.has(a));if(o.length>0)throw new T(`Unexpected key '${o[0]}' in condition JSON at '${$e(n)}'`)},Or=(e,t)=>typeof e=="string"?Ki(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?gy(e,t):by(e,t):{type:x.LITERAL,value:e},hy=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new T("$each value must be a non-empty string");let o=t.trim();if(o==="")throw new T("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new T("Empty $each body not allowed");if(n.$partial!==void 0)throw new T("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},gy=(e,t)=>{let n=[],o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(r.$each!==void 0)try{let l=hy(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=Fl(c[0],l[c[0]],t,!0);n.push(u),o=!0;continue}}catch(l){throw l instanceof T?l:new T(l.message)}let i=Object.keys(r);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Fl(i[0],r[i[0]],t);n.push(l),o=!0;continue}}let s=Or(r,t);n.push(s),(s.type===x.FUNCTION||s.type===x.CONDITIONAL||s.type===x.LOOP||s.type===x.PARTIAL||s.type===x.OBJECT&&!s.fast||s.type===x.ARRAY&&!s.fast)&&(o=!0)}return{type:x.ARRAY,items:n,fast:!o}},by=(e,t)=>{let n=[],o=!1,a=null,r=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new T("$partial value must be a string");if(e.$partial.trim()==="")throw new T("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let w of l)if(y===w||y.startsWith(w+" ")||y.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new T(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,d={},f=!1;for(let[y,w]of Object.entries(m)){let g=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(g=y.slice(1)),d[g]=w,f=!0}let h=null;if(f&&(h=Or(d,t),h.type===x.OBJECT)){let y=!1;for(let w of h.properties)if(w.value.type===x.VARIABLE||w.value.type===x.INTERPOLATION||w.value.type===x.FUNCTION||w.value.type===x.CONDITIONAL||w.value.type===x.OBJECT&&!w.value.fast||w.value.type===x.ARRAY&&!w.value.fast){y=!0;break}y&&(h.fast=!1)}let b={type:x.PARTIAL,name:u,data:h};return p!==void 0&&(b.whenCondition=ql(p,t)),b}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new T("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new T("Missing condition expression after '$when'");a=ql(c,t),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new T("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<r.length;){let[l,c]=r[s];if(l==="$when"){s++;continue}if(l==="$each")throw new T("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=wy(r,s,t);n.push({key:l,value:u.node}),o=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new T(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new T(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new T("Missing condition expression after '$if'");{let u=Or(c,t);(u.type===x.FUNCTION||u.type===x.CONDITIONAL||u.type===x.PARTIAL||u.type===x.OBJECT&&!u.fast||u.type===x.ARRAY&&!u.fast)&&(o=!0);let p=Ki(l,t),m={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let i={type:x.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},wy=(e,t,n={})=>{let o=[],a=[],r=t,[s,i]=e[r],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new T(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Gi(c);let u=Ee(c,n);for(o.push(u),a.push(Or(i,n)),r++;r<e.length;){let[p,m]=e[r],d=!1,f;if(l?p.startsWith(`$elif#${l} `)?(f=p.substring(`$elif#${l} `.length),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,f=null):p.startsWith("$elif ")?(f=p.substring(6),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,f=null),d){if(f===null)o.push(null);else{Gi(f);let h=Ee(f,n);o.push(h)}if(a.push(Or(m,n)),r++,f===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Wi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},Ji={all:ee.AND,any:ee.OR},Iy=new Set(["var","literal","call","not",...Object.keys(Wi),...Object.keys(Ji)]),vy=(e,t,n)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${$e(n)}' requires an array`);if(e.length!==2)throw new T(`Condition JSON operator '${t}' at '${$e(n)}' requires exactly 2 operands`);return e},ky=(e,t,n,o,a)=>{if(!Array.isArray(e))throw new T(`Condition JSON operator '${t}' at '${$e(a)}' requires an array`);if(e.length===0)throw new T(`Condition JSON operator '${t}' at '${$e(a)}' requires at least 1 condition`);return e.map((s,i)=>Me(s,o,[...a,i])).reduce((s,i)=>({type:x.BINARY,op:n,left:s,right:i}))},Ay=(e,t,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],Sr(e,new Set(["call","args"]),n);else if(Qi(e.call))o=e.call.name,a=e.call.args??[],Sr(e,new Set(["call"]),n),Sr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new T(`Condition JSON call at '${$e(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new T(`Condition JSON call at '${$e(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new T(`Invalid condition JSON function name '${o}' at '${$e(n)}'`);if(!Array.isArray(a))throw new T(`Condition JSON call '${o}' at '${$e(n)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,s)=>Me(r,t,[...n,"args",s]))}},Me=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new T(`Condition JSON array at '${$e(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Qi(e))throw new T(`Invalid condition JSON value at '${$e(n)}'`);let o=Bl(e);if(o.length===0)throw new T(`Condition JSON object at '${$e(n)}' must contain an operator`);let a=o.filter(s=>Iy.has(s));if(a.length===0)throw new T(`Unknown condition JSON operator '${o[0]}' at '${$e(n)}'`);if(a.length>1)throw new T(`Condition JSON at '${$e(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(Sr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new T(`Condition JSON var at '${$e(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return Sr(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return Ay(e,t,n);if(r==="not")return Sr(e,new Set(["not"]),n),{type:x.UNARY,op:mt.NOT,operand:Me(e.not,t,[...n,"not"])};if(r in Ji)return Sr(e,new Set([r]),n),ky(e[r],r,Ji[r],t,[...n,r]);if(r in Wi){Sr(e,new Set([r]),n);let s=vy(e[r],r,[...n,r]);return{type:x.BINARY,op:Wi[r],left:Me(s[0],t,[...n,r,0]),right:Me(s[1],t,[...n,r,1])}}throw new T(`Unknown condition JSON operator '${r}' at '${$e(n)}'`)},ql=(e,t={})=>{if(e==null)throw new T("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression after '$when'");return Ee(e,t)}return Qi(e)||Array.isArray(e)?Me(e,t):{type:x.LITERAL,value:e}},Ee=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Ee(c,t)}let n=Kr(e,"||");if(n!==-1)return{type:x.BINARY,op:ee.OR,left:Ee(e.substring(0,n).trim(),t),right:Ee(e.substring(n+2).trim(),t)};let o=Kr(e,"&&");if(o!==-1)return{type:x.BINARY,op:ee.AND,left:Ee(e.substring(0,o).trim(),t),right:Ee(e.substring(o+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Kr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Ee(e.substring(0,p).trim(),t),right:Ee(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,i=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let m=Kr(e.substring(p),c);if(m===-1)break;let d=p+m;d>r&&(r=d,s={op:c,type:u}),p=d+c.length}}if(r!==-1&&s)return{type:x.BINARY,op:s.type,left:Ee(e.substring(0,r).trim(),t),right:Ee(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Kr(e,c)!==-1)throw new T(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:mt.NOT,operand:Ee(e.substring(1).trim(),t)}:Ul(e,t)},Kr=(e,t)=>{let n=0,o=0;for(;o<=e.length-t.length;){if(e[o]==="(")n++;else if(e[o]===")")n--;else if(n===0&&e.substring(o,o+t.length)===t)return o;o++}return-1},Py=e=>{if(e=e.trim(),e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:x.LITERAL,value:""};if(e==="{}")return{type:x.LITERAL,value:{}};if(e==="[]")return{type:x.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:x.LITERAL,value:t}:{type:x.VARIABLE,path:e}},Ul=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return Mt(n,t);let a=Py(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return Mt(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Ey=(e,t=!1)=>{let n=t?"$each":"$for";try{Rl(e)}catch(o){if(o instanceof T&&t){let a=o.message.replace(/\$for/g,"$each");throw new T(a.replace("Parse Error: ",""))}throw o}},Fl=(e,t,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let b=o?"$each":"$for";throw new T(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let s=r[1],i=r[2].trim();Ey(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let b=o?"$each":"$for";throw new T(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${i}')`)}let c=l[1].trim(),u=l[2].trim(),p,m=null;if(c.includes(",")){let b=c.split(",").map(y=>y.trim());if(b.length!==2)throw new T(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=b[0],m=b[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new T(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new T(`Reserved variable name: ${m}`);let f=Ul(u,n),h=Or(t,n);return{type:x.LOOP,itemVar:p,indexVar:m,iterable:f,body:h,flatten:s!=="nested"}};var xy=(e,t={})=>{let{functions:n={}}=t;return Or(e,n)},qn=xy;var Vt={};Mm(Vt,{now:()=>Sy});var Sy=()=>Date.now();var Oy=(e,t,n={})=>{let{functions:o={},partials:a={}}=n,r={...Vt,...o},s=qn(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=qn(c,{functions:r});return Hi(s,t,{functions:r,partials:i})},Wr=Oy;var Ry=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Cy=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,$y=(e,t)=>{if(Ry(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new T("Empty condition expression");return Ee(e,t)}return Me(e,t)},_y=(e,t={},n={})=>{let o=Cy(n),a={...Vt,...o},r=$y(e,a);return!!xr(r,{functions:a,partials:{}},t,{})},Zi=_y;var lo=Symbol("runStoreTransaction"),no="__routeEngineConditionComparison",Fn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",Rr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Fn(e,t)&&e>t,gte:(e,t)=>Fn(e,t)&&e>=t,lt:(e,t)=>Fn(e,t)&&e<t,lte:(e,t)=>Fn(e,t)&&e<=t}),Jl=Object.freeze(Object.fromEntries(Object.keys(Rr).map(e=>[e,`${no}${e}`]))),jy=Object.freeze(Object.fromEntries(Object.entries(Jl).map(([e,t])=>[t,Rr[e]]))),Yl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Ny=e=>{if(typeof e?.call=="string")return e.call;if(e?.call!==null&&typeof e?.call=="object"&&!Array.isArray(e.call))return e.call.name},Bn=e=>{if(Array.isArray(e))return e.map(Bn);if(e===null||typeof e!="object"||Yl(e,"literal")||Yl(e,"var"))return e;if(Ny(e)?.startsWith(no))throw new Error(`Condition function names beginning with "${no}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,r=Jl[o];if(r)return{call:r,args:a.map(Bn)}}return Object.fromEntries(n.map(([o,a])=>[o,Bn(a)]))},Ft=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Zi(Bn(e),t,{functions:jy})},Dy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ql=(e,t,n={})=>{let o={},a={},{transformSelectorFirstArgument:r=h=>h,transformActionFirstArgument:s=h=>h,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},m=0,d=(h,b)=>!u||!c?h:Vn(h,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});for(let[h,b]of Object.entries(t))h!=="createInitialState"&&(h.startsWith("select")?o[h]=(...y)=>b(r(p.state,p.transactionalMetadata),...y):a[h]=(...y)=>{let w,g=p,A=Vn(p,k=>{let E=b(s(k.state,k.transactionalMetadata),...y);w=E!==void 0&&!Pe(E)?E:void 0,u&&l&&l({actionName:h,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});return m===0&&(A=d(A,g)),p=A,w});let f=h=>{if(typeof h!="function")throw new Error("Store transaction requires a callback");let b=p,y=m===0;m+=1;let w;try{w=h()}catch(g){throw m-=1,p=b,g}if(m-=1,y)try{p=d(p,b)}catch(g){throw p=b,g}return w};return{...o,...a,[lo]:f}},Xn=(e,t)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return Vn(o,r=>{a.forEach(s=>{t.forEach(i=>{i(r,s)})})})};var Ty=(e,t)=>{if(e.default!==void 0)return e.default;let n=["number","boolean","string","object"];if(!n.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},Q=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),so=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},Ae=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ly=new Set(["pageSize","groups"]),My=new Set(["id","variants"]),Vy=new Set(["id","imageId"]),qy=new Set(["pageSize","tracks"]),Fy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),By=new Set(["pageSize","replays"]),Uy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Jr=(e,t,n)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},yt=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Bt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!Ae(t))throw new Error("resources.imageGallery must be an object");if(Jr(t,Ly,"resources.imageGallery"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[o,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);if(Jr(a,My,r),yt(a.id,`${r}.id`),n.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(n.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let s=new Set;for(let[i,l]of a.variants.entries()){let c=`${r}.variants[${i}]`;if(!Ae(l))throw new Error(`${c} must be an object`);if(Jr(l,Vy,c),yt(l.id,`${c}.id`),yt(l.imageId,`${c}.imageId`),s.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(s.add(l.id),!Q(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Ut=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!Ae(t))throw new Error("resources.musicRoom must be an object");if(Jr(t,qy,"resources.musicRoom"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[o,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);Jr(a,Fy,r);for(let l of["id","soundId","title"])yt(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&yt(a[l],`${r}.${l}`);if(n.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);n.add(a.id);let s=e?.resources?.sounds?.[a.soundId];if(!Q(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Ae(s))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(s.playbackRate!==void 0&&(typeof s.playbackRate!="number"||!Number.isFinite(s.playbackRate)||s.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let i=s.startAt??0;if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new Error(`Music room sound "${a.soundId}" startAt must be a finite non-negative number`);if(s.endAt!==void 0&&s.endAt!==null&&(typeof s.endAt!="number"||!Number.isFinite(s.endAt)||s.endAt<=i))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!Q(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Yy=(e,t,n)=>{let o=Array.isArray(n)?"array":typeof n;switch(t.type){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},Yt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!Ae(t))throw new Error("resources.sceneReplay must be an object");if(Jr(t,By,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},o=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!Ae(r))throw new Error(`${s} must be an object`);Jr(r,Uy,s);for(let u of["sceneId","title","thumbnailImageId"])yt(r[u],`${s}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!Q(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let i=n[r.sceneId];if(!i)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=i.initialSectionId,c=i.sections?.[l];if(!c)throw new Error(`Scene replay scene "${r.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${r.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(r.initialVariables!==void 0){if(!Ae(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let m=e?.resources?.variables?.[u];if(!m)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(_e(m))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);Yy(u,m,p)}}}},Zl=e=>{let t=Pe(e)?Er(e):e;return structuredClone(t)},zy=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!Q(t,"nameVariableId"))return;let o=t.nameVariableId,a=n?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Gn=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0;if(t?.name!==void 0)return t.name;if(n!==void 0)return n;let s=zy({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},_e=e=>Q(e,"computed"),co=(e,t)=>{switch(e?.type){case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);default:return!1}},zt=(e={},t={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?o:!_e(s)&&(!n||n.includes(s.scope))&&co(s,r)})),Xe=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),Xy=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Xe(t,n)}let a="";for(let r=1;r<e.length-1;r+=1){let s=e[r];if(s!=="\\"){if(s.charCodeAt(0)<32)throw Xe(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Xe(t,n);let i=e[r];if(i==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Xe(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
+
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!Q(l,i))throw Xe(t,n);a+=l[i]}return a},ec=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Xe(e,t);let n=[],o=0,a=()=>{let s=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(s,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw Xe(e,t);n.push(i)},r=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let s=e[o];if(/\d/.test(s??"")){let u=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(u,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw Xe(e,t);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Xe(e,t);let i=s,l=o;o+=1;let c=!1;for(;o<e.length;){let u=e[o];if(c)c=!1;else if(u==="\\")c=!0;else if(u===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw Xe(e,t);o+=1,n.push(Xy(p,e,t));return}o+=1}if(c||o>=e.length)throw Xe(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Xe(e,t)}return n},eo=(e,t)=>{let n=e;for(let o of t){if(n==null||!Q(n,o))return;n=n[o]}return n},rc=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=ec(e),[o,a,...r]=n;if(o==="variables"){if(!a)return t.variables;let s=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return eo(s,r)}return o==="runtime"?eo(t.runtime,n.slice(1)):eo(t,n)},tc=(e,t,n)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&t.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},io=(e,t)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(t.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},Gy=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Je=(e,t,n,o)=>(tc(e,t,o),t.map(a=>zn(a,n))),ze=(e,t,n,o)=>{let a=Je(e,t,n,o);return a.forEach(r=>Gy(e,r)),a},Hy=(e,t,n)=>{switch(e){case"var":return rc(t,n);case"add":{let[o,a]=ze(e,t,n,2);return o+a}case"sub":{let[o,a]=ze(e,t,n,2);return o-a}case"mul":{let[o,a]=ze(e,t,n,2);return o*a}case"div":{let[o,a]=ze(e,t,n,2);return o/a}case"mod":{let[o,a]=ze(e,t,n,2);return o%a}case"neg":{let[o]=ze(e,t,n,1);return-o}case"round":{let[o]=ze(e,t,n,1);return Math.round(o)}case"floor":{let[o]=ze(e,t,n,1);return Math.floor(o)}case"ceil":{let[o]=ze(e,t,n,1);return Math.ceil(o)}case"min":{let[o,a]=ze(e,t,n,2);return Math.min(o,a)}case"max":{let[o,a]=ze(e,t,n,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=ze(e,t,n,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=Je(e,t,n,2);return Rr.eq(o,a)}case"neq":{let[o,a]=Je(e,t,n,2);return Rr.neq(o,a)}case"gt":{let[o,a]=Je(e,t,n,2);return Rr.gt(o,a)}case"gte":{let[o,a]=Je(e,t,n,2);return Rr.gte(o,a)}case"lt":{let[o,a]=Je(e,t,n,2);return Rr.lt(o,a)}case"lte":{let[o,a]=Je(e,t,n,2);return Rr.lte(o,a)}case"in":{let[o,a]=Je(e,t,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return io(e,t),t.every(o=>!!zn(o,n));case"or":case"any":return io(e,t),t.some(o=>!!zn(o,n));case"not":{let[o]=Je(e,t,n,1);return!o}case"length":{let[o]=Je(e,t,n,1);return typeof o=="string"||Array.isArray(o)?o.length:Ae(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Je(e,t,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return Zl(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},zn=(e,t={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let n=Object.entries(e);if(n.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=n;return Hy(o,a,t)},oo=(e,t)=>{if(e===null||typeof e!="object"||Q(e,"literal"))return e;if(Q(e,"var"))return{literal:rc(e.var,t)};if(Q(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([n,o])=>[n,Array.isArray(o)?o.map(a=>oo(a,t)):oo(o,t)]))},Ky=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Ft(oo(e,t))},nc=(e,t)=>{if(!Ae(e))throw new Error(`${t} must be an object`);let n=Q(e,"expr"),o=Q(e,"value");if(n===o)throw new Error(`${t} must contain exactly one of expr or value`)},ro=(e,t,n)=>(nc(e,t),Q(e,"value")?Zl(e.value):zn(e.expr,n)),Wy=(e,t={},n="unknown")=>{if(!Ae(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=Q(e,"expr"),a=Q(e,"value");if(Q(e,"branches")){if(o||a)throw new Error(`Computed variable "${n}" cannot combine branches with expr or value`);if(!Array.isArray(e.branches))throw new Error(`Computed variable "${n}" branches must be an array`);if(e.branches.length===0)throw new Error(`Computed variable "${n}" branches must not be empty`);if(!Ae(e.default))throw new Error(`Computed variable "${n}" requires default`);for(let s=0;s<e.branches.length;s+=1){let i=e.branches[s];if(!Ae(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!Q(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Ky(i.when,t))return ro(i,`Computed variable "${n}" branch ${s}`,t)}return ro(e.default,`Computed variable "${n}" default`,t)}if(o===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return ro(e,`Computed variable "${n}"`,t)},sc=(e,t,n)=>{switch(t){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(n)?"array":typeof n}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(n)?"array":typeof n}`);return;case"string":if(typeof n!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(n)?"array":typeof n}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof n}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},Jy=Object.freeze({add:2,sub:2,mul:2,div:2,mod:2,neg:1,round:1,floor:1,ceil:1,min:2,max:2,clamp:3,eq:2,neq:2,gt:2,gte:2,lt:2,lte:2,in:2,not:1,length:1,includes:2}),Qy=new Set(["and","or","all","any"]),Zy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),eh=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),rh=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),th=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),ic=new WeakMap,zl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Un=(e,t,n)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},nh=(e,t,n,o)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${n}`)},oc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,i,...l]=ec(e,r);if(s!=="variables"&&s!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${r} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!Q(n,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=n[i];return _e(c)&&o.add(i),l.length===0?c?.type:void 0},ac=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return zl(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let r=Object.entries(e);if(r.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,i]]=r;if(s==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return oc(i,{variableId:t,variableConfigs:n,dependencies:o,path:a})}if(s==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return zl(i)}let l=Jy[s];if(l===void 0&&!Qy.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?io(s,i):tc(s,i,l);let c=i.map((u,p)=>ac(u,{variableId:t,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(eh.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Zy.has(s))return"number";if(rh.has(s))return"boolean"},sh=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Me(e)}catch(s){throw new Error(`Computed variable "${t}" ${a} is invalid: ${s.message}`,{cause:s})}let r=(s,i)=>{if(s===null||typeof s!="object"||Q(s,"literal"))return;if(Q(s,"var")){oc(s.var,{variableId:t,variableConfigs:n,dependencies:o,path:i});return}if(Q(s,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(Q(s,"not")){r(s.not,`${i}.not`);return}let l=Object.keys(s).find(c=>th.has(c));s[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},to=(e,{variableId:t,variableConfig:n,variableConfigs:o,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(nc(e,`Computed variable "${t}" ${r}`),Un(e,s,r),Q(e,"value")){sc(t,n.type,e.value);return}let i=ac(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});nh(t,n.type,i,`${r}.expr`)},ih=(e,t,n)=>{let o=t.computed;if(!Ae(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=Q(o,"expr"),s=Q(o,"value");if(Q(o,"branches")){if(Un(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||s)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(o.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(o.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!Ae(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Ae(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Un(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!Q(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);sh(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),to(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),to(o.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Un(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return to(o,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Qr=(e={})=>{if(!Ae(e))throw new Error("Variable configs must be an object");if(Q(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(Q(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(_e(s)){if(!Ae(s))throw new Error(`Computed variable "${r}" must be an object`);if(!Q(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!Q(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(Q(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Xt(s.scope,r),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${r}`);t.set(r,ih(r,s,e))}});let n=new Set,o=[];t.forEach((r,s)=>{if(n.has(s))return;let i=[{variableId:s,dependencies:[...t.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),n.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...i.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return ic.set(e,a),a},ht=({variables:e={},runtime:t={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=ic.get(n)??Qr(n),r=zt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,b])=>_e(b)).map(([b])=>b),i=Object.create(null),l=[],c=new Map(a.map((b,y)=>[b,y])),u=-1,p=!1,m=b=>{if(Q(i,b))return i[b];let y=n[b];if(!_e(y))return Q(r,b)?r[b]:void 0;let w=l.indexOf(b);if(w>=0){let g=[...l.slice(w),b].join(" -> ");throw new Error(`Computed variable cycle detected: ${g}`)}l.push(b);try{let g=Wy(y.computed,h,b);return sc(b,y.type,g),so(i,b,g),g}finally{l.pop()}},d=b=>{if(Q(i,b))return i[b];let y=n[b];if(!_e(y))return Q(r,b)?r[b]:void 0;let w=c.get(b);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let g=u+1;g<=w;g+=1)m(a[g]),u=g}finally{p=!1}return i[b]}return m(b)},f=new Proxy({},{get:(b,y)=>{if(typeof y=="string")return d(y)},has:(b,y)=>typeof y=="string"&&(Q(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(b,y)=>{if(!(typeof y!="string"||!Q(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),h={variables:f,runtime:t,resolveVariable:d};return o?(s.forEach(b=>{d(b)}),{...r,...i}):f},oh=({variables:e={},runtime:t={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return Qr(a),ht({variables:e,runtime:t,variableConfigs:a,eager:!0})},Hn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(_e(a))return;let r=Ty(a,o);a.scope==="context"?so(t,o,r):so(n,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},Xt=(e,t)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${n.join(", ")}`)},Gt=(e,t,n)=>{let o={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=o[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(o).flat().includes(t))throw new Error(`Unknown operation: ${t}`);if(!a.includes(t))throw new Error(`Operation "${t}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},ah=2,Xl=12,lc=(e=ah)=>{if(!Number.isInteger(e)||e<0||e>Xl)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Xl}.`);return e},lh=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},Yn=e=>typeof e=="number"&&Number.isFinite(e),Kn=(e,t,n,o,a={})=>{if(e==="number"){if(t==="set"&&!Yn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!Yn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!Yn(n))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(t==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);lc(a.roundTo)}}},Wn=(e,t,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!Yn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=s=>{let i=a(s,void 0,"value");if(i===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return i};switch(t){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return lh(a(e,0,"current value")/r(n),lc(o.roundTo));case"increment":return a(e,0,"current value")+a(n,1,"value");case"decrement":return a(e,0,"current value")-a(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var uo=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),r={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:Dy[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(n.getHours()),mm:o(n.getMinutes()),ss:o(n.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>r[s])},ch=(e,t)=>{let n=r=>r?.ui,o=n(e),a=n(t);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:t}:a&&o?{changeType:"update",data:t}:null},qt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,uh=(e,t)=>{let n=e?.character?.sprite,o=t?.character?.sprite,a=qt(n)?n:void 0,r=qt(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},Gl=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[n]!==void 0&&(t[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(t[n]=e[n]);return t},Hl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Kl=(e,t)=>t&&!e?{changeType:"add",data:t}:e&&!t?{changeType:"delete",data:e}:e&&t&&JSON.stringify(e)!==JSON.stringify(t)?{changeType:"update",data:t}:null,ph=(e,t)=>{let n={},o=Kl(Gl(e),Gl(t)),a=Kl(Hl(e),Hl(t));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},po=(e={},t={})=>{let n={},o=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)n[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(m=>m.applyMode==="persistent");!o.includes(l)&&(l!=="sfx"||p)&&(n[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},r=ph(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=ch(e.dialogue,t.dialogue);s&&(n.dialogue=s);let i=uh(e.dialogue,t.dialogue);return i&&(n.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},fo=(e={})=>{let t=structuredClone(e);if(t.sfx){let a=Array.isArray(t.sfx.channels)?t.sfx.channels.filter(r=>r.applyMode==="persistent"):[];a.length>0?t.sfx={channels:a}:delete t.sfx}t.background&&(t.background.animations?.playback?.continuity!=="persistent"&&delete t.background.animations,!t.background.resourceId&&!t.background.colorId&&delete t.background);let n=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};n("layout"),n("choice"),n("form"),n("screen"),t.dialogue?.ui&&(delete t.dialogue.ui.animations,Object.keys(t.dialogue.ui).length===0&&delete t.dialogue.ui,Object.keys(t.dialogue).length===0&&delete t.dialogue),t.dialogue?.character?.sprite&&(delete t.dialogue.character.sprite.animations,Object.keys(t.dialogue.character.sprite).length===0&&delete t.dialogue.character.sprite,Object.keys(t.dialogue.character).length===0&&delete t.dialogue.character,Object.keys(t.dialogue).length===0&&delete t.dialogue);let o=(a,r)=>{let s=t[a]?.items;Array.isArray(s)&&(t[a].items=s.map(i=>{let l={...i};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return o("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),o("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),t},fh=(e,t)=>{if(!e||!t)return;let n=e;for(let o of t.split(".")){if(n==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),o))return;n=n[o]}return n},Wl=e=>e!==null&&typeof e=="object"?structuredClone(e):e,dh=(e,t,n)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(t??{},n)?t[n]:void 0;if(e===n){if(o==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return Wl(o)}if(!e.startsWith(`${n}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${n}".`);let a=e.slice(n.length+1),r=fh(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return Wl(r)},mh={conditional:new Set(["branches"]),updateProjectData:new Set(["projectData"]),showConfirmDialog:new Set(["confirmActions","cancelActions"]),form:new Set(["submitActions","cancelActions"]),submitForm:new Set(["actions"]),cancelForm:new Set(["actions"])},yh=(e,t)=>{let n=e[e.length-1];return n?mh[n]?.has(t)===!0:!1},ao=(e,t,n=[])=>Array.isArray(e)?e.map(o=>ao(o,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,yh(n,o)?a:ao(a,t,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?dh(e,t,"_event"):Wr(e,t):e,Ht=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return ao(e,t)};var hh=11102230246251565e-32,cc=128,uc=1e3,pc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Kt=(e,t,n)=>{let o=Object.keys(e).find(a=>!t.has(a));if(o!==void 0)throw new Error(`${n}.${o} is not supported`)},Jn=(e,t)=>{if(!pc(e))throw new Error(`${t} must be an object`)},Qn=(e,t,{min:n,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},gh=(e,t,{min:n,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},mo=e=>{let t=structuredClone(e),n=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(n),Object.freeze(o)),o);return n(t)},bh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),fc=e=>{let t=e??bh();if(!pc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=t.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},wh=(e,t)=>{let n=4294967296-4294967296%t;for(let o=0;o<cc;o+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${cc} rejected samples`)},Ih=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},vh=(e,t)=>{if(Kt(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let n=Qn(e.min,"random.distribution.min"),a=Qn(e.max,"random.distribution.max")-n+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return mo({type:"integer",value:a===1?n:n+wh(t,a)})},kh=(e,t)=>{if(Kt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>uc)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let n=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(Jn(c,p),Kt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Jn(c.actions,`${p}.actions`),{weight:gh(c.weight,`${p}.weight`,{min:0})}}),o=Math.max(...n.map(({weight:c})=>c));if(o<=0)throw new Error("random weighted total weight must be positive");let a=n.map(c=>({...c,weight:c.weight/o})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(n[u].weight>0&&(c.weight===0||c.weight/r<=hh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Ih(t)*r,i=0,l=a.findLastIndex(({weight:c})=>c>0);for(let c=0;c<a.length;c+=1){let u=a[c];if(i+=u.weight,s<i){l=c;break}}return mo({type:"weighted",outcomeIndex:l})},dc=(e,{randomSource:t})=>{Jn(e,"random.distribution");let o={integer:vh,weighted:kh}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},Zn=(e,t)=>{if(Jn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Kt(e,new Set(["type","value"]),"random result"),Qn(e.value,"random result.value");else if(t==="weighted")Kt(e,new Set(["type","outcomeIndex"]),"random result"),Qn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:uc-1});else throw new Error(`unsupported recorded random result type: ${t}`);return mo(e)};var Zr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),hc=Object.freeze([Zr("cleanup",["clearPendingEffects","cleanAll"]),Zr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Zr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Zr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Zr("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),Zr("persistence",["saveSlot"]),Zr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),gt=new Map;hc.forEach(e=>{e.actions.forEach(t=>{if(gt.has(t))throw new Error(`duplicate action execution key: ${t}`);gt.set(t,gt.size)})});var Ah=new Set(hc.find(({name:e})=>e==="navigation").actions),mc=gt.get("saveSlot")-.5,yc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",Ph=(e,t)=>e<t?-1:e>t?1:0,es=e=>Object.entries(e).sort((t,n)=>{let o=yc(...t),a=yc(...n),r=gt.get(o),s=gt.get(a),i=r??mc,l=s??mc;return i!==l?i-l:r!==void 0&&s!==void 0?0:Ph(o,a)}),rs=e=>Ah.has(e),ts=e=>{let t=e.map(([n])=>n).filter(rs);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var Eh=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),tr=(...e)=>e.map(Eh).join(":"),ns=e=>Array.isArray(e?.sounds)?e.sounds:e?.resourceId?[{id:e.resourceId,resourceId:e.resourceId,loop:e.loop??!0,volume:e.volume,startDelayMs:e.startDelayMs??0}]:[],yo=e=>!Array.isArray(e?.sounds)&&e?.startDelayMs>0,Wt=(e,t)=>yo(e)?tr("bgm","legacy-delay",t.resourceId):tr("bgm",t.id==="default"?t.resourceId:t.id),gc=({bgm:e,resources:t,previousBgmRender:n})=>{let o=ns(e).filter(c=>t.sounds?.[c.resourceId]),a=ns(n?.bgm).filter(c=>n.resources?.sounds?.[c.resourceId]).map((c,u)=>({sound:c,renderId:n.channel?.children[u]?.id})).filter(({renderId:c})=>c!==void 0),r=new Map,s=new Set,i=(c,u)=>{!u||s.has(u.renderId)||(r.set(c.id,u.renderId),s.add(u.renderId))};return yo(e)===yo(n?.bgm)&&(o.forEach(c=>i(c,a.find(u=>u.sound.id===c.id))),o.forEach(c=>{r.has(c.id)||i(c,a.find(u=>u.sound.resourceId===c.resourceId&&Wt(n.bgm,u.sound)===Wt(e,c)))})),[...o].sort((c,u)=>+(c.id==="default")-+(u.id==="default")).forEach(c=>{if(r.has(c.id))return;let u=Wt(e,c);s.has(u)&&(u=tr("bgm",c.id)),s.has(u)&&(u=tr("bgm","clip",c.id));let p=0;for(;s.has(u);)u=tr("bgm","clip",c.id,++p);r.set(c.id,u),s.add(u)}),r};var Cr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Jt=Object.freeze({volume:100,pan:0,playbackRate:1}),ss=["volume","pan","playbackRate"],xh=["src","startAt","endAt","startDelayMs"],bc=(e,t)=>{if(!e)return null;let n=e.children??[];if(n.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return n[0]},kc=(e,t)=>e?.id===t?.id&&xh.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),Ac=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Sh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),go=e=>Math.max(-1,Math.min(1,e)),bo=({bgm:e,resources:t,renderedSound:n,property:o})=>{let a=e?.sounds?.length===1?e.sounds[0]:e?.sounds?.find(s=>Wt(e,s)===n?.id),r=t.sounds?.[a?.resourceId];return a?.[o]??r?.[o]??Jt[o]},Oh=({property:e,value:t,relative:n,bgm:o,resources:a,renderedSound:r})=>{if(!o||!r)return t;if(e==="volume"){let s=bo({bgm:o,resources:a,renderedSound:r,property:e});return t*s/100}if(e==="pan"&&!n){let s=bo({bgm:o,resources:a,renderedSound:r,property:e});return go(t+s)}return t},Rh=({authoredInitialValue:e,authoredKeyframes:t,baselineBgm:n,compiledKeyframes:o,bgm:a,resources:r,renderedSound:s})=>{if(!a||!s)return o;let i=bo({bgm:a,resources:r,renderedSound:s,property:"pan"}),l=e??n?.pan??Jt.pan;return o.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let m=Cr(p,"startValue")?l+p.startValue:l,d=m+p.value,{relative:f,...h}=c;return l=d,{...h,...Cr(p,"startValue")?{startValue:go(m+i)}:{},value:go(d+i)}})},Pc=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},Ch=(e,t)=>({...Cr(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Ec=({property:e,authored:t,speed:n,propertyPath:o,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${o}.keyframes] The final keyframe must use an absolute finite numeric value.`);let s={keyframes:t.keyframes.map(i=>{let l=Ch(i,n),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),Cr(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return Cr(t,"initialValue")&&(s.initialValue=a({property:e,value:t.initialValue,relative:!1})),s},ho=({authored:e,bgm:t,baselineBgm:n=t,property:o,propertyPath:a,renderedSound:r,resources:s,speed:i})=>{let l=Ec({property:o,authored:e,speed:i,propertyPath:a,normalizeValue:({value:c,relative:u})=>Oh({property:o,value:c,relative:u,bgm:t,resources:s,renderedSound:r})});return o==="pan"&&(l.keyframes=Rh({authoredInitialValue:e.initialValue,authoredKeyframes:e.keyframes,baselineBgm:n,compiledKeyframes:l.keyframes,bgm:t,resources:s,renderedSound:r})),l},wc=({actionPath:e,compiled:t,property:n,propertyPath:o,renderedSound:a})=>{let r=a[n]??Jt[n],s=t.keyframes.at(-1);if(!Sh(s.value,r))throw new Error(`[${e}.audioEffects]
|
|
3
|
+
[${o}.keyframes] The final keyframe value must match the persistent BGM ${n} value.`);s.value=r},xc=({selection:e,selectionPath:t,resources:n={}})=>{if(!e)return;let o=e.resourceId,a=`resources.audioEffects.${o}`,r=n.audioEffects?.[o];if(!r)throw new Error(`[${t}.resourceId]
|
|
4
4
|
[${a}] Unknown audio effect resource "${o}".`);if(r.type!=="update")throw new Error(`[${t}]
|
|
5
|
-
[${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let s=
|
|
6
|
-
[${p}] Unknown audio effect resource "${u}".`);let
|
|
7
|
-
[${p}] Audio effect resource "${u}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let A={};for(let k of
|
|
8
|
-
[${p}] Audio effect resource "${u}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let b={};for(let A of ns){if(!Cr(d.tween,A))continue;let k=`${p}.tween.${A}`,E=fo({property:A,authored:d.tween[A],speed:f,propertyPath:k,baselineBgm:s,bgm:i,resources:o,renderedSound:h}),v=h[A]??Kt[A];yc({actionPath:c,compiled:E,property:A,propertyPath:k,renderedSound:h}),(m[A]??Kt[A])!==v&&(b[A]={update:E})}return Object.keys(b).length===0?null:{...hc(e,g),properties:b}},Pc=e=>{let t=e.nextResources??e.resources,n=e.occurrence;if(!n?.selection)return[];let o=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=n.selection.resourceId,s=t?.audioEffects?.[r],i=(f,m)=>m?{...f,children:[m]}:null,l=f=>f.map(({previousSound:m,nextSound:h},g)=>xh({...e,occurrence:g===0?n:{...n,occurrenceId:`${n.occurrenceId}:${g}`},resources:t,previousChannel:i(e.previousChannel,m),nextChannel:i(e.nextChannel,h)})).filter(Boolean);if(!s||!["transition","update"].includes(s.type))return l([{previousSound:o[0],nextSound:a[0]}]);let c=new Map(o.map(f=>[f.id,f])),u=new Map(a.map(f=>[f.id,f]));if(s.type==="update"){let f=a.map(g=>({previousSound:c.get(g.id),nextSound:g})),m=f.find(({previousSound:g})=>!g);if(m)return l([m]);let h=o.find(g=>!u.has(g.id));return l(h?[{previousSound:h}]:f)}let p=[];for(let f of o){let m=u.get(f.id);(!m||!bc(f,m))&&p.push({previousSound:f,nextSound:m})}for(let f of a)c.has(f.id)||p.push({nextSound:f});if(p.length>0)return l(p);let d=o.find(f=>{let m=u.get(f.id);return m&&!wc(f,m)});return l([{previousSound:d??o[0],nextSound:d?u.get(d.id):a[0]}])};var ae=e=>structuredClone(Pe(e)?Pr(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Wt=e=>e?.animations?.playback?.continuity==="persistent",Y=(e,t)=>ie(e??{},t)&&e[t]!==void 0,ss=e=>Y(e,"alpha")||Y(e,"opacity"),Sh=e=>Y(e,"alpha")?e.alpha:e?.opacity,_c=e=>(Y(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Oh=e=>e?.applyMode==="persistent",Rh="default",Ch=e=>Array.isArray(e?.channels)?e.channels.filter(Oh).map(ae):[],Jt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},$h=e=>ss(e)||Y(e,"blur")||Y(e,"filters"),go=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],jc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],ho=["animationName","animationSpeed","loop"],_h=e=>Y(e,"transformId")||Y(e,"transform")||go.some(t=>Y(e,t)),bo=e=>e?.text&&Y(e.text,"content")&&Y(e.text,"textStyleId"),wo=e=>e?.layout&&Array.isArray(e.layout.elements),jh=e=>Y(e,"text")||Y(e,"layout"),Ec=(e,t)=>e.resourceId?!0:bo(e)?!t?.text:wo(e)?!t?.layout:!1,Nh=e=>Y(e,"resourceId")||bo(e)||wo(e),xc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Dh=e=>Y(e,"resourceId")||Y(e,"sprites")&&Array.isArray(e.sprites)&&e.sprites.length>0,Th=(e,t)=>{let n={...ae(e),...t};if(t.text&&e.text&&(n.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(n.transform={...ae(e.transform),...ae(t.transform)}),Y(t,"transform")){delete n.transformId;for(let o of go)Y(t,o)||delete n[o]}else Y(t,"transformId")&&delete n.transform;return n},Lh=(e,t)=>{let n=[e.resourceId,e.text,e.layout].filter(o=>o!==void 0).length;if(n>1)throw n===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(Y(e,"text")&&!bo(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(Y(e,"layout")&&!wo(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Sc=e=>jc.some(t=>Y(e,t)),Oc=e=>ho.some(t=>Y(e,t)),Mh=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let o of jc)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Nc=(e,t,n)=>{let o=e[n];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},Vh=(e,t)=>{if(!t)return e;let n=Y(e,"transform");for(let o of go)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},qh=(e,t)=>(t&&(!Y(e,"opacity")&&Y(t,"opacity")&&(e.opacity=t.opacity),!Y(e,"blur")&&Y(t,"blur")&&(e.blur=ae(t.blur)),!Y(e,"filters")&&Y(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Dc=(e,t,n=[],{hasPatchFn:o=()=>!1,hasSubjectFn:a=(s,i)=>t(s,i),mergeItemFn:r}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let s=e.map((i,l)=>{let c=Nc(n,i,l),u=a(i,c),p=$h(i),d=_h(i),f=o(i),m=ie(i,"animations"),h=_c(ae(i));if(!u&&(p||d||f)&&c&&(h=r?r(c,h):{...ae(c),...h}),!m){let g=c?t(c):!1,y=t(h);!u&&g&&y&&Wt(c)?h.animations=ae(c.animations):delete h.animations}return u?h:qh(Vh(h,c),c)}).filter(i=>t(i)||i.animations);return{hasValidItems:s.length>0,processedItems:s}},Fh=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},Tc=e=>!!e?.character&&ie(e.character,"sprite"),Bh=e=>{let t={},n=!1,o=Fh(e);return o!==void 0&&(t.name=o,n=!0),Tc(e)&&(t.sprite=ae(e.character.sprite),n=!0),n?t:void 0},Rc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Cc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:n&&!ie(t,"characterId"),$c=({previousCharacter:e,characterFields:t,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},c=t??{},u=s&&!n,p=u&&!r;return ie(c,"name")?i.name=c.name:(o&&!n||u)&&ie(l,"name")&&(i.name=ae(l.name)),ie(c,"sprite")?i.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(i.sprite=ae(l.sprite)),Object.keys(i).length>0?i:void 0},Uh=({dialogueState:e,content:t,append:n=!1})=>{if(!n||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...o,...t]},Yh=()=>({}),zh=(e,t)=>{if(!t.screen)return;let n=ss(t.screen),o=Y(t.screen,"blur"),a=ie(t.screen,"animations");if(!n&&!o){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=Sh(t.screen):Y(r,"opacity")&&(s.opacity=r.opacity),o?s.blur=ae(t.screen.blur):Y(r,"blur")&&(s.blur=ae(r.blur)),ie(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ie(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},Xh=(e,t)=>{if(t.background){let n=Y(t.background,"resourceId"),o=Y(t.background,"colorId"),a=ss(t.background),r=Y(t.background,"blur"),s=Y(t.background,"filters"),i=Y(t.background,"transformId"),l=Sc(t.background),c=Oc(t.background),{animationsOnly:u,state:p}=Jt(t.background,m=>Y(m,"resourceId")||Y(m,"colorId")||ss(m)||Y(m,"blur")||Y(m,"filters")||Y(m,"transformId")||Sc(m)||Oc(m));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!n&&!o&&!a&&!r&&!s&&!i&&!l&&!c){delete e.background;return}let d=e.background,f=_c(ae(t.background));if(!n&&d?.resourceId){f.resourceId=d.resourceId,!ie(f,"transformId")&&d.transformId&&(f.transformId=d.transformId);for(let m of ho)!Y(f,m)&&Y(d,m)&&(f[m]=d[m])}n||Mh(f,d,{hasAuthoredTransformId:i}),!n&&!o&&d?.colorId&&(f.colorId=d.colorId),!n&&!a&&Y(d,"opacity")&&(f.opacity=d.opacity),!n&&!r&&Y(d,"blur")&&(f.blur=ae(d.blur)),!n&&!s&&Y(d,"filters")&&(f.filters=ae(d.filters)),ie(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,ie(f,"colorId")&&f.colorId===void 0&&delete f.colorId,ie(f,"animations")&&f.animations===void 0&&delete f.animations,ie(f,"transformId")&&f.transformId===void 0&&delete f.transformId,ie(f,"opacity")&&f.opacity===void 0&&delete f.opacity,ie(f,"blur")&&f.blur===void 0&&delete f.blur,ie(f,"filters")&&f.filters===void 0&&delete f.filters;for(let m of ho)ie(f,m)&&f[m]===void 0&&delete f[m];if(!f.resourceId&&!f.colorId){delete e.background;return}!n&&d?.resourceId===f.resourceId&&d?.transformId===f.transformId&&!ie(f,"animations")&&Wt(d)&&(f.animations=ae(d.animations)),e.background=f}else e.background?.animations&&!Wt(e.background)&&(e.background.animations={})},Gh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(Rc(e.dialogue),e.dialogue.mode==="adv")){e.dialogue.content=void 0,delete e.dialogue.initialRevealedContent,delete e.dialogue.textSpeed;let u=e.dialogue.persistCharacter===!0,p=Cc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=$c({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=Jt(t.dialogue.ui,d=>!!d.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=t.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&Uh({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Cc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=ie(t.dialogue,"characterId"),i=Bh(t.dialogue),l=Tc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=$c({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Rc(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},Hh=(e,t)=>{let n=Ch(e.sfx);if(!t.sfx){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=n.filter(s=>s.id!==Rh);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(t.sfx.channels.length===0){delete e.sfx;return}let o=new Set(t.sfx.channels.map(r=>r.id)),a=n.filter(r=>!o.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Kh=(e,t,n)=>{if(t.bgm){let o=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!o||o&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Ac({bgm:ae(t.bgm),resources:n}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},Wh=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{Lh(r,Nc(n,r,s))});let{hasValidItems:o,processedItems:a}=Dc(t.visual.items,Ec,n,{hasPatchFn:jh,hasSubjectFn:Nh,mergeItemFn:Th});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!Ec(n)||!Wt(n))?{...n,animations:{}}:n))},Jh=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!xc(a)||!Wt(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=Dc(t.character.items,xc,e.character?.items||[],{hasSubjectFn:Dh});n?e.character={items:o}:delete e.character},Qh=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},Zh=(e,t)=>{if(t.layout){let{animationsOnly:n,state:o}=Jt(t.layout,a=>!!a.resourceId);if(n){e.layout=o;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},eg=(e,t)=>{if(t.choice){let{animationsOnly:n,state:o}=Jt(t.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...o};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},rg=(e,t)=>{if(t.form){let{animationsOnly:n,state:o}=Jt(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},tg=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},ng=(e,t)=>{if(t.voice){let n=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!n||n&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},sg=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Zr=(e,{resources:t}={})=>Xn(Yh,[sg,zh,Xh,Hh,(a,r)=>Kh(a,r,t),Wh,Gh,Jh,Qh,Zh,eg,rg,tg,ng])(e);var bt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Kr(e,t);return n&&typeof n=="object"?e:n};var ig=Object.freeze({dialogueTextSpeed:{source:"global.dialogueTextSpeed"},autoForwardDelay:{source:"global.autoForwardDelay"},autoForwardSpeed:{source:"global.autoForwardSpeed"},skipUnseenText:{source:"global.skipUnseenText"},skipTransitionsAndAnimations:{source:"global.skipTransitionsAndAnimations"},soundVolume:{source:"global.soundVolume"},musicVolume:{source:"global.musicVolume"},muteAll:{source:"global.muteAll"},localizationPackageId:{source:"global.localizationPackageId"},saveLoadPagination:{source:"context.runtime.saveLoadPagination"},menuPage:{source:"context.runtime.menuPage"},menuEntryPoint:{source:"context.runtime.menuEntryPoint"},autoMode:{source:"global.autoMode"},skipMode:{source:"global.skipMode"},dialogueUIHidden:{source:"global.dialogueUIHidden"},isLineCompleted:{source:"global.isLineCompleted"}}),$r=Object.freeze({dialogueTextSpeed:50,autoForwardDelay:1e3,autoForwardSpeed:50,skipUnseenText:!1,skipTransitionsAndAnimations:!1,soundVolume:50,musicVolume:50,muteAll:!1,localizationPackageId:null,autoMode:!1,skipMode:!1,dialogueUIHidden:!1,isLineCompleted:!1}),Qt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),og=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Io=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Lc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),vo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Mc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ag=(e,t)=>{let n=og[e];if(n==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(t!==null&&typeof t!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},is=(e,t)=>{if(ag(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},ko=(e={})=>{let t=e?.config;if(t===void 0)return{...$r};if(!Mc(t))throw new Error("projectData.config must be an object");let n=Object.keys(t).find(i=>i!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=t.runtimeDefaults;if(o===void 0)return{...$r};if(!Mc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Lc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...$r};return Lc.forEach(i=>{o[i]!==void 0&&(s[i]=is(i,o[i]))}),s},lg=(e,t)=>{if(t.startsWith("global.")){let n=t.slice(7);return e?.global?.[n]}if(t.startsWith("context.runtime.")){let n=t.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[n]}},_r=e=>Object.fromEntries(Object.entries(ig).map(([t,n])=>{let o=lg(e,n.source),a=o!==void 0?o:$r[t]??Qt[t];return[t,a]})),tr=(e,t)=>_r(e)[t],Vc=(e={})=>Object.fromEntries(Io.map(t=>[t,e[t]??$r[t]]));var wt=Object.freeze({VISUAL_BEHIND_BACKGROUND:10,BACKGROUND:20,VISUAL_BEHIND_CHARACTER:30,CHARACTER:40,VISUAL_BEHIND_DIALOGUE:50,DIALOGUE:60,VISUAL_BEHIND_CHOICE:70,CHOICE:80,VISUAL_FOREGROUND:90}),mr=Object.freeze({BEHIND_BACKGROUND:wt.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:wt.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:wt.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:wt.VISUAL_BEHIND_CHOICE,FOREGROUND:wt.VISUAL_FOREGROUND}),Ao=mr.BEHIND_DIALOGUE,Po=Object.freeze(Object.values(mr).sort((e,t)=>e-t));var cg={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:lo},ug=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Zt=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return Zt(t);let[n]=Object.keys(t),o=ug.exec(n);if(!o)return Zt(t);let[,a,r,s]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[i]:Zt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Zt(n)])),yr=(e,t)=>{let n={functions:cg};return Kr(Zt(e),t,n)},eu=({animationType:e,animationId:t,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},pg=({id:e,targetId:t,animation:n,playback:o,animationPath:a="animation"})=>{let r=structuredClone(n);if(eu({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let s=yg(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?iu(r):null;if(s.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&r.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&(!Number.isFinite(i)||i<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=s}}return r},fg=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return eu({animationType:e.type,animationId:t,animationPath:n}),e.type},dg=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},mg=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},yg=(e,t="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${t}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${t}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${t}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${t}] playback.loop must be a boolean.`);let n={};return e.continuity!==void 0&&(n.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(n.speed=e.speed),e.loop===!0&&(n.loop=!0),Object.keys(n).length>0?n:void 0},hg=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},Qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ru=(e={})=>Qe(e,"alpha")&&typeof e.alpha=="number"?e.alpha:Qe(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,tu=e=>e?.playback?.continuity==="persistent",_o=e=>Array.isArray(e)?e.map(_o):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=_o(e[n]),t),{}),cs=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(_o(t))},nu=(e=[])=>e.filter(t=>tu(t)).map(t=>structuredClone(t)),su=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let o=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+o},0):0,Eo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,su(n)),0),iu=e=>Math.max(Eo(e?.tween),Eo(e?.prev?.tween),Eo(e?.next?.tween),su(e?.mask?.progress)),ou=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:iu(e)/hg(e),gg=e=>e.some(t=>t?.playback?.loop===!0),qc=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let n=new Set(t.map(cs).filter(Boolean));return e.some(o=>{if(!tu(o))return!1;let a=cs(o);return a?n.has(a):!1})},Ze=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:gg(e)||r&&!t||qc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:qc({animationInstances:e,activePersistentAnimations:a}),au=(e,t,n,o,a)=>{if(e===void 0)return!0;let r=a.slice(0,o).filter(i=>i?.id===n).length,s=e?.[t]?.items?.filter(i=>i?.id===n).at(r);return Qe(s??{},"animations")},bg=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),wg=(e,t)=>{if(bg(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Ig=({resources:e,animationId:t,playback:n,instanceId:o,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?pg({id:o,targetId:a,animation:s,playback:n,animationPath:r}):null},jo=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${t} must be an array of objects`);return e},vg=({content:e,path:t,variables:n})=>jo(e,t).reduce((o,a)=>{let r=bt(a.text,{variables:n});return o+`${r??""}`.length},0),Fc=(e=[])=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,(t.get(n.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n))},Bc=(e,t=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let o=e?.sprites?.map(({resourceId:a})=>a)||[];return o.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${o.join("-")}`},vt=(e,t)=>{if(t.transformId&&t.transform)throw new Error(`Visual item "${t.id}" cannot define both transformId and transform`);if(t.transform)return t.transform;if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId or transform`);let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},kg=(e,t={})=>{if(!t?.transformId)return;let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},Ag=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Pg=(e={})=>Ag.some(t=>Qe(e,t)),lu=(e={},t)=>{if(t){if(e.images?.[t])return"sprite";if(e.videos?.[t])return"video";if(e.spritesheets?.[t])return"spritesheet-animation";if(e.layouts?.[t])return"container"}},as=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Eg=(e={})=>e.textStyles||{},xg=(e={})=>e.images||{},Sg=.5,Og=(e={},t,n)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${n}'`);return t}return Object.keys(e.animations??{})[0]},Fo=({id:e,resourceId:t,spritesheet:n,animationName:o,animationSpeed:a,loop:r,width:s,height:i,transform:l={}}={})=>{let c=Og(n,o,t),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:i??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Sg,loop:r??u.loop??!0}}},cu=({id:e,item:t,resources:n={}}={})=>{let o=n.images?.[t.resourceId];if(o)return{type:"sprite",id:e,src:o.fileId,width:o.width,height:o.height,x:0,y:0};let a=n.spritesheets?.[t.resourceId];if(a)return Fo({id:e,resourceId:t.resourceId,spritesheet:a,animationName:t.animationName,animationSpeed:t.animationSpeed,loop:t.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${t.resourceId}`)},Rg=(e={})=>e.colors||{},Cg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,en=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,kt=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},xo=(e,t,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);return e},So=(e,t,n,o,{minimum:a}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let r=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${t} for text style "${n}" must be ${r}`)}return e},fs=(e,t)=>{if(typeof e!="string"||!Cg.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},Uc=(e,t,n)=>{let o=fs(e,n);if(t===1)return o;let a=Number.parseInt(o.slice(1,3),16),r=Number.parseInt(o.slice(3,5),16),s=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${r}, ${s}, ${t})`},$g=(e={},t)=>{let n=Eg(e)?.[t];if(!n)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=xo(n.colorAlpha,"colorAlpha",t),i={fontFamily:Array.isArray(n.fontId)?a.join(", "):a[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:Uc(r.hex,s,`Color "${n.colorId}" for text style "${t}"`)};if(n.align!==void 0&&(i.align=n.align),n.wordWrap!==void 0&&(i.wordWrap=n.wordWrap),n.breakWords!==void 0&&(i.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(i.wordWrapWidth=n.wordWrapWidth),n.strokeColorId){let l=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=xo(n.strokeAlpha,"strokeAlpha",t);i.strokeColor=Uc(l.hex,c,`Stroke color "${n.strokeColorId}" for text style "${t}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth),n.shadow!==void 0){let l=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);i.shadow={color:fs(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:xo(n.shadow.alpha,"shadow.alpha",t),blur:So(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:So(n.shadow.offsetX,"offsetX",t,2),offsetY:So(n.shadow.offsetY,"offsetY",t,2)}}return i},At=e=>Array.isArray(e)?e.map(At):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,At(n)])),No=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>No(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=At(r);continue}a!=="textStyleId"&&(o[a]=No(r,t,en(n,a)))}return e.textStyleId!==void 0&&(kt(e.textStyleId,n,"textStyleId"),o.textStyle=$g(t,e.textStyleId)),o},Bo=(e={},t)=>{let n=Rg(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return fs(n.hex,`Color "${t}"`)},uu=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",Oo=(e,t,n)=>{let o=e?.[t];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${n}". Use ${uu(`${t}.fill`)} instead`)},_g=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>rn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(o[a]=rn(r,t,en(n,a)));return e.colorId!==void 0&&(kt(e.colorId,n,"colorId"),o.fill=Bo(t,e.colorId)),o},rn=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>rn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${n}". Use ${uu("fill")} instead`);Oo(e,"hover",n),Oo(e,"click",n),Oo(e,"rightClick",n)}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=At(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=_g(r,t,en(n,a));continue}o[a]=rn(r,t,en(n,a))}}return e.type==="rect"&&e.colorId!==void 0&&(kt(e.colorId,n,"colorId"),o.fill=Bo(t,e.colorId)),o},Ro=(e={},t)=>{let n=xg(e)?.[t];return n||null},pu=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Yc=(e,t,n,o)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,o))throw new Error(`Inline ${t}.${o} is not allowed in sprite layout elements at "${n}". Use ${pu(`${t}.${o}`)} instead`)},zc=(e,t,n)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},Do=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Do(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${pu(a)} instead`);Yc(e,"hover",n,"src"),Yc(e,"click",n,"src")}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=At(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=Do(r,t,en(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){kt(e.imageId,n,"imageId");let a=Ro(t,e.imageId),r=a?.fileId??e.imageId;o.src=r,o.width===void 0&&a?.width!==void 0&&(o.width=a.width),o.height===void 0&&a?.height!==void 0&&(o.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(kt(e.hoverImageId,n,"hoverImageId"),zc(o,"hover",Ro(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(kt(e.clickImageId,n,"clickImageId"),zc(o,"click",Ro(t,e.clickImageId)?.fileId??e.clickImageId)),o},jg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),ls=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>ls(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=At(e),o=typeof e.type=="string";(o||t)&&Qe(e,"opacity")&&(Qe(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])Qe(e,a)&&(n[a]=ls(e[a]));for(let[a,r]of Object.entries(e))jg(a)&&(n[a]=ls(r,{isElementPatch:o||t}));return n},Uo=(e,t={},n="root")=>ls(Do(rn(No(e,t,n),t,n),t,n)),hr=Uo,rt=(e=[])=>e.find(t=>t.id==="story"),Ng="#000000",To="bg-cg-background-color",Dg=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?fs(n?.backgroundColor??Ng,"screen.backgroundColor"):Bo(e,t.colorId),fu=(e={})=>ru(e),Tg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Yo=(e={})=>Array.isArray(e.filters)?e.filters:void 0,Xc=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=fu(e),o=Tg(e),a=Yo(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),o&&(r.blur=o),a&&(r.filters=a),r},Lg=(e={})=>ru(e),Mg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},du=(e={})=>{let t=Lg(e),n=Mg(e),o={};return t!==void 0&&(o.alpha=t),n&&(o.blur=n),o},et=(e={})=>{let t=du(e),n=Yo(e);return n&&(t.filters=n),t},Gc=(e,t,n,o)=>{let a=t[n]??e[n];return t[o]??e[o]??!1?(a??1)*-1:a},nr=(e={},t={})=>{let n={x:t.x??e.x,y:t.y??e.y,anchorX:t.anchorX??e.anchorX,anchorY:t.anchorY??e.anchorY,rotation:t.rotation??e.rotation,scaleX:Gc(e,t,"scaleX","flipX"),scaleY:Gc(e,t,"scaleY","flipY")},o=t.originX??e.originX,a=t.originY??e.originY;return o!==void 0&&(n.originX=o),a!==void 0&&(n.originY=a),n},Vg=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],zo=(e={})=>e.text&&Qe(e.text,"content")&&Qe(e.text,"textStyleId"),Xo=(e={})=>e.layout&&Array.isArray(e.layout.elements),Hc=(e={})=>{if(e.resourceId)return e.resourceId;if(zo(e))return"text";if(Xo(e))return"inline-layout"},Kc=(e,t={})=>typeof e=="string"?t.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?t.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return t.images?.[n]?.fileId??n;if(!n||typeof n!="object"||Array.isArray(n))return n;if(n.imageId){let{imageId:o,...a}=n;return{...a,src:t.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,qg=({item:e,particle:t,resources:n})=>{let o=vt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=Kc(r,n)),a.texture!==void 0&&(a.texture=Kc(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...nr(o,e)};return Object.assign(s,et(e)),s},Fg=e=>{let t=[e.resourceId,e.text,e.layout].filter(n=>n!==void 0).length;if(t>1)throw t===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(e.text&&!zo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Xo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of Vg)if(Qe(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},Bg=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:To,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Dg({resources:e,background:t,screen:n})};if(o){let r=fu(t);r!==void 0&&(a.alpha=r);let s=Yo(t);s&&(a.filters=s)}return a},Ug=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Wc=({resources:e={},resourceId:t,colorId:n})=>{let o=lu(e,t);return t&&(o||n===void 0)?{resourceId:t,targetId:as({resourceId:t,kind:o})}:n!==void 0?{resourceId:To,targetId:To}:{resourceId:void 0,targetId:void 0}},mu=100,jr=mu,Yg="channel:bgm",zg="channel:music-room",Xg="music-room:player",Gg="channel:voice",Hg="default",us=(e,t,n)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let r=n?` in ${n}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}o.add(a)})},yu=(e,t)=>e*t/mu,Go=(e={},t)=>e?.[t]??$r[t],Ho=(e={},t,n=jr)=>yu(n,Go(e,t)),ds=({id:e,volume:t,muted:n,pan:o,loop:a,playback:r,interruption:s,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),s!==void 0&&(c.interruption=s),c},os=(e,t,n,o)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:o,Kg=["muted","pan","playbackRate","startAt","endAt"],ms=({id:e,sound:t,resource:n,projectResources:o,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:s=!1})=>{let i={id:e,type:"sound",src:n.fileId,loop:os(t,n,"loop",r),volume:os(t,n,"volume",jr),startDelayMs:os(t,n,"startDelayMs",0)};Kg.forEach(c=>{let u=os(t,n,c,void 0);u!==void 0&&(i[c]=u)}),t.playback!==void 0&&(i.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=kc({selection:t[c],selectionPath:`${a}.${c}`,resources:o});u&&!s&&(i[c]=u)}let l=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<l)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${l}).`);return i},Wg=e=>Math.max(-1,Math.min(1,e)),Jg=({node:e,bgm:t,sound:n,resource:o,usesLegacySound:a})=>{a||(e.volume=yu(t.volume??jr,e.volume??jr));let r=t.muted!==void 0,s=n.muted!==void 0||o.muted!==void 0;(r||s)&&(e.muted=t.muted===!0||e.muted===!0);let i=t.pan!==void 0,l=n.pan!==void 0||o.pan!==void 0;return(i||l)&&(e.pan=Wg((t.pan??0)+(e.pan??0))),e},Ge=({variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:r=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:h,historyDialogue:g=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:b,skipTransitionsAndAnimations:A}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},E=tb({dialogueState:s,includeInactiveAdvDialogue:i,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:h,historyDialogue:g,characters:y};return E&&(v.dialogue=E,v.dialogueLines=E.lines),v},Jc=100,ps=(e,t)=>{if(Array.isArray(e))return e.map(o=>ps(o,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=ps(n[o],t)}),n.type==="text-revealing"?t(n):n},Qg=e=>ps(e,t=>({...t,revealEffect:"none"})),Zg=e=>ps(e,t=>{let n=Number(t.speed??t.displaySpeed),o=Number.isFinite(n)?Math.max(n,Jc):Jc;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),Nr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?Qg(e):n?Zg(e):e,hu=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),Lo=e=>{if(Array.isArray(e))return e.map(Lo);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Lo(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let o=n.actions,a=o&&typeof o=="object"&&!Array.isArray(o)&&Object.prototype.hasOwnProperty.call(o,"nextLine")?{...o.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...n,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},eb=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Qc="submit",Co=(e,t,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},r=n.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...o,actions:r}}},Mo=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>Mo(c,t,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===Qc,r=o&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Mo(u,t,c==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let c=t?.fields?.[l.field];if(c){let u={updateFormField:{formKey:t.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:Co(l.change,u),submit:Co(l.submit,t.submitActions)}}}return l.formRole===Qc||r?{...l,click:Co(l.click,t.submitActions,{replaceActions:!0})}:l},Vo=(e,t)=>{if(Array.isArray(e))return e.map(o=>Vo(o,t));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=Vo(a,t);for(let o of eb){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},qo=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,s=Gn({characterId:e,character:t,characterName:n,characters:o,variables:a});return{...r||{},...t||{},name:s}},gu=(e=[],t={},n={})=>e.map(o=>{let a=qo({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:t,variables:n}),r=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(s=>s?.text??"").join(""):"";return{...o,text:r,character:a,characterName:a.name}}),rb=e=>!(!e||e.mode==="adv"&&e.content===void 0),tb=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:o,runtime:a}={})=>{if(!t&&!rb(e))return;let r=e.content===void 0?[{text:""}]:jo(e.content,"dialogue.content"),s=e.content===void 0?0:vg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??$r.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,d)=>{let f=jo(p.content,`dialogue.lines[${d}].content`),m=qo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:f.map(h=>({...h,text:bt(h.text,{variables:o})})),character:m,characterName:m.name}}),u=qo({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:bt(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},Ko=({container:e,resources:t,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=yr(e,n);return hr(Nr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},$o=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),Zc=({renderStateKeyboard:e,keyboard:t,phase:n})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([o,a])=>{let r=e[o]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...r,keydown:{payload:$o(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:$o(a.keyup)});return}e[o]={...r,[n]:{payload:$o(a)}}})},nb=(e={},t={})=>{let n={};return Zc({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Zc({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},gr=({animationsDef:e,resources:t,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:r,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:w})=>{let b=Ig({resources:t,animationId:f,playback:m,instanceId:y,targetId:w,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,d=a&&r&&a===r;wg(e,s);let f=dg(e),m=mg(e),h=t?.animations?.[f],g=fg(h,{animationId:f,animationPath:s});if(g==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(g==="transition"){let y=`${i}-animation-transition`,w=m?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&d)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},sb=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),ib=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:d,activePersistentAnimations:f,restoredPersistentAnimations:m,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:w,canRollback:b,form:A,saveSlots:k=[]})=>{let{elements:E,animations:v}=e;if(t.background){let O=o===void 0?!0:Qe(o?.background??{},"animations"),L=E.find(oe=>oe.id==="story");if(!L)return e;let C=kg(a,t.background),D=C||Pg(t.background),B=n?.background?.resourceId,_=n?.background?.colorId,G=t.background.resourceId??(t.background.animations?B:void 0),fe=t.background.colorId??(t.background.animations?_:void 0),M=Ug(a,G),K={...t.background,colorId:fe};if((fe!==void 0||M)&&L.children.push(Bg({resources:a,background:K,screen:r,includeAlpha:!M})),G){let{images:oe={},videos:ne={},spritesheets:ue={}}=a,Z=lu(a,G),$;if(Z==="sprite"?$=oe[G]:Z==="video"?$=ne[G]:Z==="spritesheet-animation"&&($=ue[G]),$){let j=Z==="video",F=Z==="spritesheet-animation",J={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...C},de={...Xc(t.background,{includeDefaultAlpha:!0}),...nr(J,t.background)},Ie;F?Ie=Fo({id:as({resourceId:G,kind:Z}),resourceId:G,spritesheet:$,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:de}):Ie={id:as({resourceId:G,kind:Z}),type:j?"video":"sprite",src:$.fileId,width:$.width,height:$.height,...de},j&&(Ie.loop=t.background.loop??!1,Ie.volume=$.volume??50),Ie&&L.children.push(Ie)}}if(G){let{layouts:oe={}}=a,ne=oe[G];if(ne){let ue={id:as({resourceId:G,kind:"container"}),type:"container",children:ne.elements,...Xc(t.background)};D&&Object.assign(ue,nr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...C},t.background));let Z=yr(ue,Ge({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:d,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:w,canRollback:b,form:A,characters:a.characters||{},skipTransitionsAndAnimations:i}));L.children.push(hr(Nr(Z,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let le=Wc({resources:a,resourceId:B,colorId:_}),X=Wc({resources:a,resourceId:G,colorId:fe}),te=gr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:X.resourceId,previousTargetId:le.targetId,currentTargetId:X.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ze({animationInstances:te,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:f,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:O})&&v.push(...te)}return e},ob=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(w=>w.id==="story");if(!p)return e;let d=t.character.items||[],f=n?.character?.items||[],m=Fc(d),h=Fc(f),g=new Map,y=new Map;for(let w=0;w<f.length;w++){let b=f[w],A=g.get(b.id)??[];A.push(w),g.set(b.id,A)}for(let w=0;w<d.length;w++){let b=d[w],{transformId:A,sprites:k}=b,E=y.get(b.id)??0;y.set(b.id,E+1);let v=g.get(b.id)?.[E]??-1,O=f[v],L=O?.sprites&&O.sprites.length>0,C=k&&k.length>0,D=v>=0?Bc(O,v,h):void 0,B=C?Bc(b,w,m):void 0,_=au(o,"character",b.id,w,d),G=gr({animationsDef:b.animations,resources:a,previousResourceId:D,currentResourceId:B,previousTargetId:D,currentTargetId:B,animationPath:`character.items[${w}].animations`,idPrefix:B??D??`character-${w}`});if(b.animations&&!k&&!A&&L&&Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})){u.push(...G);continue}if(b.animations&&!k&&!A)continue;if(!k||k.length===0||!A){console.warn("Character item missing sprites or transformId:",b);continue}let fe=a.transforms[A];if(!fe){console.warn("Transform not found:",A);continue}let M={type:"container",id:B,...nr(fe,b),...et(b),children:[]};for(let K of k){let le=cu({id:`${B}-${K.id}`,item:K,resources:a});le&&M.children.push(le)}p.children.push(M),Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})&&u.push(...G)}}return e},bu=(e,t)=>{if(!Po.includes(e))throw new Error(`${t} must be one of: ${Po.join(", ")}.`)},ab=(e,t)=>{let n=!!e.resourceId||zo(e)||Xo(e),o=e.layer??(n?void 0:t?.layer)??Ao;return bu(o,`Visual item "${e.id}" layer`),o},lb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:m,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:w,form:b,saveSlots:A=[],visualLayer:k})=>{let{elements:E,animations:v}=e;if(t.visual&&a){let O=E.find(B=>B.id==="story");if(!O)return e;let L=t.visual.items,C=n?.visual?.items||[],D=Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:A,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:w,form:b,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&bu(k,"visualLayer");for(let[B,_]of L.entries()){let G=C.find(ne=>ne.id===_.id),fe=au(o,"visual",_.id,B,L),M=ab(_,G);if(k!==void 0&&M!==k)continue;if(Fg(_),_.layout){let ne=vt(a,_),ue={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...nr(ne,_)};Object.assign(ue,et(_)),O.children.push(Ko({container:ue,resources:a,templateData:D,isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}))}if(_.text){let ne=vt(a,_),ue={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...nr(ne,_)};Object.assign(ue,et(_)),O.children.push(hr(yr(ue,D),a))}if(_.resourceId){let{images:ne={},videos:ue={},spritesheets:Z={}}=a,$=Z[_.resourceId];if($){let j=vt(a,_),F=et(_),J=Fo({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:$,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...nr(j,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});J&&O.children.push(structuredClone(J))}else{let j=ne[_.resourceId]||ue[_.resourceId];if(j){let F=ue[_.resourceId]!==void 0,J=vt(a,_),de={id:`visual-${_.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...nr(J,_)};Object.assign(de,et(_)),F&&(de.loop=j.loop??!1,de.volume=j.volume??50),O.children.push(de)}}}let K=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!K){let ne=a.particles?.[_.resourceId];ne&&O.children.push(qg({item:_,particle:ne,resources:a}))}let le=!!a.particles?.[_.resourceId];if(_.resourceId&&!K&&!le){let{layouts:ne={}}=a,ue=ne[_.resourceId];if(ue){let Z=vt(a,_),$={id:`visual-${_.id}`,type:"container",children:structuredClone(ue.elements),...nr(Z,_)};Object.assign($,et(_));let j=yr($,D);O.children.push(hr(Nr(j,{isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}),a))}}let X=Hc(G),te=Hc(_),oe=gr({animationsDef:_.animations,resources:a,previousResourceId:X,currentResourceId:te,previousTargetId:X?`visual-${_.id}`:void 0,currentTargetId:te?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ze({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:fe})&&v.push(...oe)}}return e},It="dialogue-character-sprite",cb=(e,{presentationState:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=rt(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=Vt(c),d=Vt(u),f=gr({animationsDef:c?.animations,resources:o,previousResourceId:d?It:void 0,currentResourceId:p?It:void 0,previousTargetId:d?It:void 0,currentTargetId:p?It:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&d&&Ze({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...f),e;let m=o.transforms?.[c.transformId];if(!m)return console.warn("Transform not found:",c.transformId),e;let h={type:"container",id:It,...nr(m),children:[]};for(let g of c.items){let y=cu({id:`${It}-${g.id}`,item:g,resources:o});y&&h.children.push(y)}return l.children.push(h),Ze({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...f),e},ub=(e,{presentationState:t,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:d,skipTransitionsAndAnimations:f,variables:m,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:w,activePersistentAnimations:b,saveSlots:A=[]})=>{let{elements:k,animations:E}=e;if(!t.dialogue||a)return e;let v=k.find(L=>L.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:L={}}=o,C=L[t.dialogue.ui.resourceId];if(C){let D={elements:C.elements},B=Ge({variables:m,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:w,saveSlots:A,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:d,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:f}),_=yr(D,B),G=hr(Nr(_?.elements,{isLineCompleted:d,skipMode:s,skipTransitionsAndAnimations:f}),o);if(Array.isArray(G))for(let fe of G)v.children.push(fe);else G&&v.children.push(G)}}cb(e,{presentationState:t,previousPresentationState:n,resources:o,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:b});let O=gr({animationsDef:t.dialogue.ui?.animations,resources:o,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return Ze({animationInstances:O,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:b})&&E.push(...O),e},pb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:h,canRollback:g,form:y,activePersistentAnimations:w,saveSlots:b=[]})=>{let{elements:A,animations:k}=e;if(t.choice&&o){let E=rt(A);if(!E)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let L={elements:v.elements},C=yr(L,{...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m??!!t.choice,isFormVisible:h,canRollback:g,form:y,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),D=Lo(hr(Nr(C?.elements,{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:s}),o));if(Array.isArray(D))for(let B of D)E.children.push(B);else D&&E.children.push(D)}let O=gr({animationsDef:t.choice.animations,resources:o,previousResourceId:n?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});Ze({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},fb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:h,canRollback:g,activePersistentAnimations:y,saveSlots:w=[],form:b})=>{let{elements:A,animations:k}=e;if(!b?.resourceId||!o)return e;let E=rt(A);if(!E)return e;let v=o?.layouts?.[b.resourceId];if(!v)return console.warn(`Form layout not found: ${b.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},L={...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:h,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},C=yr(O,L),D=Vo(hr(Nr(Mo(C,b),{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:s}),o),b);D&&E.children.push(D);let B=gr({animationsDef:b.animations,resources:o,previousResourceId:n?.form?.resourceId,currentResourceId:b.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:b.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ze({animationInstances:B,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...B),e},db=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:h=[],skipTransitionsAndAnimations:g})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=nb(y.keyboard,y.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(y.elements)||y.elements.length===0)return e;let b=rt(e.elements);if(!b)return e;let A={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return b.children.push(Ko({container:A,resources:n,templateData:Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},Wo=({presentationState:e,resources:t={},runtime:n,variables:o,musicRoomPlayer:a,skipTransitionsAndAnimations:r=!1})=>{if(e?.bgm&&t){let s=e.bgm,i=!Array.isArray(s.sounds),l=i?s.resourceId?[{id:"default",resourceId:s.resourceId,loop:s.loop??!0,volume:s.volume,startDelayMs:s.startDelayMs??0}]:[]:s.sounds,c=!i&&s.loop===!0,u=[];if(i||us(l,"BGM sound"),c){let d=l.find(f=>f.loop===!0);if(d)throw new Error(`BGM sound "${d.id}" cannot loop inside a looping BGM channel.`)}if(l.forEach(d=>{let f=t.sounds?.[d.resourceId];if(!f)return;let m=c?{...d,loop:d.loop??!1}:d;u.push(Jg({node:ms({id:Rr("bgm",i?"default":d.id),sound:m,resource:f,projectResources:t,soundPath:`bgm.sounds[${JSON.stringify(d.id)}]`,defaultLoop:!c,skipTransitionsAndAnimations:r}),bgm:s,sound:m,resource:f,usesLegacySound:i}))}),u.length===0)return null;let p=Ge({variables:o,runtime:n}).runtime;return ds({id:Yg,volume:Go(p,"musicVolume"),muted:!1,pan:0,loop:i?void 0:s.loop,playback:a?.bgmPlayback,interruption:s.interruption,children:u,runtime:p})}return null},mb=(e,t)=>{if(!rt(e.elements))return e;let o=Wo(t);return o&&e.audio.push(o),e},yb=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:n})=>(t?.length>0&&!n&&(e.audioEffects=structuredClone(t)),e),hb=(e,{resources:t={},runtime:n,variables:o,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let s=r.tracks.find(u=>u.id===a.trackId),i=s?t.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=Ge({variables:o,runtime:n}).runtime,c=ms({id:Xg,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(ds({id:zg,volume:Ho(l,"musicVolume",jr),children:[c],runtime:l})),e},gb=(e,{presentationState:t,resources:n,runtime:o,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&n){let s=t.sfx,i=Array.isArray(s.channels)?s.channels:[],l=i.map(c=>({channel:c,usesLegacyChannel:!1}));us(i,"SFX channel"),Array.isArray(s.items)&&l.push({channel:{id:Hg,sounds:s.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,d=[];if(u||us(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let f=c.sounds.find(m=>m.loop===!0);if(f)throw new Error(`SFX sound "${f.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((f,m)=>{let h=n.sounds?.[f.resourceId];if(!h)return;let g=p?{...f,loop:f.loop??!1}:f;d.push(ms({id:u?Rr("sfx","default",m,f.id):Rr("sfx",c.id,f.id),sound:g,resource:h,projectResources:n,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),d.length!==0&&r.push(ds({id:Rr("channel","sfx",c.id),volume:Ho(o,"soundVolume",c.volume??jr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:d,runtime:o}))})}return e},bb=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},wb=(e,{presentationState:t,resources:n,currentSceneId:o,runtime:a,variables:r,skipTransitionsAndAnimations:s})=>{let{audio:i}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:jr,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,d=[];if(c||us(u,"Voice sound"),p){let m=u.find(h=>h.loop===!0);if(m)throw new Error(`Voice sound "${m.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(m=>{let h=bb(n,o,m.resourceId);if(!h)return;let g=p?{...m,loop:m.loop??!1}:m;d.push(ms({id:Rr("voice",o,c?"default":m.id),sound:g,resource:h,projectResources:n,soundPath:`voice.sounds[${JSON.stringify(m.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:s}))}),d.length===0)return e;let f=Ge({variables:r,runtime:a}).runtime;return i.push(ds({id:Gg,volume:c?l.volume??Go(f,"soundVolume"):Ho(f,"soundVolume",l.volume??jr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:d,runtime:f})),e},Ib=(e,{presentationState:t,previousPresentationState:n,resources:o={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:h=[],isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:b,animations:A}=e;if(t.layout){let O=rt(b);if(!O)return e;let L=o.layouts?.[t.layout.resourceId];if(!L)return e;let C={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:L.elements||[]};O.children.push(Ko({container:C,resources:o,templateData:Ge({variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,E=t.layout?.resourceId,v=gr({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:E,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:E?`layout-${E}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ze({animationInstances:v,isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&A.push(...v),e},vb=(e,{currentLineActions:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=t?.screen?.animations;if(!l)return e;let c=n!=null,u=gr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ze({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...u),e},kb=(e,{presentationState:t})=>{let n=rt(e.elements);return!n||!t?.screen||Object.assign(n,du(t.screen)),e},Ab=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,overlayStack:m=[],dialogueHistory:h=[],saveSlots:g=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:A}=e;return m&&m.length>0&&m.forEach((k,E)=>{let v=n.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[hu({id:`overlayStack-${E}-blocker`,screen:y}),...v.elements||[]]},L=gu(h,n.characters,o),C=Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,historyDialogue:L,characters:n.characters||{},skipTransitionsAndAnimations:b}),D=yr(O,C),[B,..._]=D.children||[],G=hr(Nr({...D,children:_},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);A.push({...G,children:B?[B,...G.children||[]]:G.children})}),e},Pb=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:h,dialogueHistory:g=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:A}=e;if(!h?.resourceId)return e;let k=n.layouts?.[h.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${h.resourceId}`),e;let E={id:"confirmDialog",type:"container",x:0,y:0,children:[hu({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=gu(g,n.characters,o),O=yr(E,Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:h,historyDialogue:v,characters:n.characters||{},skipTransitionsAndAnimations:b})),[L,...C]=O.children||[],D=hr(Nr({...O,children:C},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);return A.push({...D,children:L?[L,...D.children||[]]:D.children}),e},tn=e=>(t,n)=>lb(t,{...n,visualLayer:e}),Eb=tn(mr.BEHIND_BACKGROUND),xb=tn(mr.BEHIND_CHARACTER),Sb=tn(mr.BEHIND_DIALOGUE),Ob=tn(mr.BEHIND_CHOICE),Rb=tn(mr.FOREGROUND),wu=e=>Xn(sb,[db,Eb,ib,xb,ob,Sb,ub,Ob,pb,fb,Ib,Rb,kb,vb,mb,hb,gb,wb,yb,Ab,Pb])(e);function Iu(e,t=""){let n=[],o=e.length,a=0,r=0,s=-1,i=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,t?parseInt(t[r++],36):0])}return n}function vu(e,t,n){let o=0,a=t.length-1;for(;o<=a;){let r=o+a>>>1,s=n[r];if(e<t[r])a=r-1;else if(e>s>>>5)o=r+1;else return s&31}return 0}var ku="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Au="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Pu="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Eu=65535,Jo=40960,ys=126976,Ou=new Uint8Array(12288),Ru=new Uint8Array(3072),Cu=new Uint8Array(2816),$u,_u;{let e=(a,r,s,i,l)=>{let c=r+a.length-1;for(let u=s<r?r:s,p=i>c?c:i;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,r,s]of Iu(ku,Au))e(Ou,0,a,r,s),e(Ru,Jo,a,r,s),e(Cu,ys,a,r,s),r>=65040&&!(a>=ys&&r<=129791)&&(t[o]=a,n[o++]=r<<5|s);$u=t.slice(0,o),_u=n.slice(0,o)}function xu(e){return e<12288?Ou[e]:e<Jo?e<12336?e>=12330?3:0:e<12443?e===12336||e===12349?4:e>=12441?3:0:e===12951||e===12953?4:0:e<44032?Ru[e-Jo]:e<55204?(e-44032)%28?8:7:e<57344?e<=55238?e>=55216?13:0:e>=55243&&e<=55291?12:0:e<65024?e===64286?3:0:e<65040?3:e>=ys&&e<129792?Cu[e-ys]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:vu(e,$u,_u)}var ju=Uint8Array.from(Pu,Number);function Cb(e){return e===2381||e===2509||e===2637||e===2765||e===2893||e===3149||e===3405||e===4153||e===6098||e===6752||e===6980||e===7083||e===43456||e===43766||e===68159||e===69939||e===70608||e===71998||e===72263||e===72345||e===73538}function Su(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Cb(n)?e&6|16:e&6|8:e&6;case 4:return 2;case 10:return e&1^1;case 14:return(e&2)<<1|e&24;default:return 8}}function*Nu(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),o=n>Eu?2:1,a=xu(n),r=50200>>a&1?Su(0,a,n):0,s=0,i=n,l=a;for(;o<t;){n=e.codePointAt(o);let c=n>Eu?2:1,u=xu(n),p=ju[a<<4|u],d;p===0?d=!0:p===1?d=!1:p===2?d=!(r&1):p===3?d=!(r&4):d=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?Su(r,u,n):0,d&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=o,i=n,l=u),o+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Du(e){for(let t of Nu(e))yield t.segment}{let e=Nu("_");ju._keep=[e,e.next()]}var Tu=1e3,qu=50,$b=0,Lu=100,Mu=50,_b=60,jb=3,Nb=.5,Db=2e4,Tb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Lb=/^\s+$/u,Vu,Mb=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Du(t)):(Vu??=new n(void 0,{granularity:"grapheme"}),Array.from(Vu.segment(t),({segment:o})=>o))},Vb=e=>Mb(e).reduce((t,n)=>Lb.test(n)?t+Nb:Tb.test(n)?t+jb:t+1,0),qb=e=>2**(((Number.isFinite(e)?Math.min(Lu,Math.max($b,e)):qu)-Mu)/(Lu-Mu)),Qo=({text:e="",baseDelay:t=Tu,speed:n=qu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):Tu,a=qb(n),r=Vb(e)*_b/a,s=Math.max(o,Db);return Math.min(o+r,s)};var hs={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Xu=1,br=1,Et="choice",Tr="form",an=()=>({manual:{...hs.manual},auto:{...hs.auto},applyMode:hs.applyMode}),ua=()=>({groupId:null,variantId:null,pageIndex:0}),Fb="music-room:player",Bb=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),ws=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),pa=new Set,Ub=new Set(["groupId","variantId"]),Yb=new Set(["pageIndex"]),xt=new Set,zb=new Set(["trackId"]),Xb=new Set(["positionMs"]),Gb=new Set(["pageIndex"]),fa=new Set,Hb=new Set(["sceneId"]),Kb=new Set(["pageIndex"]),da=()=>({pageIndex:0}),ma=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...an()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ea=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},q=e=>{let t=Pe(e)?Pr(e):e;return structuredClone(t)},V=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Is=e=>{let t=e.global.audioCommandId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal audio command counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=t+1,e.global.audioCommandId},Gu=e=>{let t=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal scene replay entry counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=t+1,e.global.sceneReplayEntryId},ln=(e,t,n)=>({commandId:Is(e),operation:t,...n===void 0?{}:{positionMs:n}}),ya=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:Is(e),operation:"resume"}),e.global.musicRoomPlayer=ws({bgmPlayback:n})},Hu=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=e.projectData.resources?.achievements?.[t];if(!n)throw new Error(`Achievement resource "${t}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${n.type}"`);return n},Ku=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${t} requires a non-empty string or finite number slotId`)},st=e=>String(e),Wu=()=>({sections:[],resources:[]}),Ju=()=>({sceneIds:[]}),Wb=e=>V(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Wu(),Jb=e=>V(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Ju(),Qb=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",Zb=({sectionId:e,lineId:t,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:n,text:Qb(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),Qu=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),ew=e=>V(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,ha=e=>{if(!V(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},rw=e=>{if(!V(e?.dialogueHistory))return e.dialogueHistory=Qu(e?.rollback?.timeline?.length??0),e.dialogueHistory;let t=e.dialogueHistory;return Array.isArray(t.entries)||(t.entries=[]),Number.isInteger(t.currentLength)||(t.currentLength=t.entries.length),Array.isArray(t.checkpointLengths)||(t.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),t.currentLength=Math.min(Math.max(t.currentLength,0),t.entries.length),t},ga=e=>{let t=ha(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},tw=()=>({resourceId:void 0}),nw=e=>{if(!V(e))return e;let t={...e};return Object.prototype.hasOwnProperty.call(t,"requireComplete")&&!Object.prototype.hasOwnProperty.call(t,"requireLineCompleted")&&(t.requireLineCompleted=t.requireComplete),delete t.requireComplete,t},wr=(e,t)=>{let n=e?.story?.scenes??{};for(let[o,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:o,section:a.sections[t]};return{sceneId:void 0,section:void 0}},Zu=e=>{let t=e?.story?.scenes??{},n=new Map;for(let[o,a]of Object.entries(t)){let r=a?.sections??{};for(let s of Object.keys(r)){let i=n.get(s);if(i!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);n.set(s,o)}}},ep=e=>e,rp=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Xu)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},sw=(e,t={})=>{let n;try{n=rp(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:n,slotId:ep(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},iw=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,sw(t,n)])),ow=(e,t)=>{if(!V(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!V(o))return!1;let{variableId:a,op:r,value:s,roundTo:i}=o,l=t?.resources?.variables?.[a];if(!l||_e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Xt(l.type,r,a),Kn(l.type,r,s,a,{roundTo:i}),r!=="set"||ao(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},tp=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!V(o)||!UI(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=ow(o.payload,t);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},aw=(e,t,n)=>{let{section:o}=wr(e,t?.sectionId),r=o?.lines?.find(({id:i})=>i===t?.lineId)?.actions,s=n.split(".");for(let i of s){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(i))return;let l=Number(i);if(!Object.prototype.hasOwnProperty.call(r,l))return;r=r[l];continue}if(!V(r)||!Object.prototype.hasOwnProperty.call(r,i))return;r=r[i]}return s.at(-1)==="random"&&V(r?.distribution)?r:void 0},np=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let t=e.max-e.min+1;return Number.isSafeInteger(t)&&t>=1&&t<=4294967296},sp=(e,t,n)=>e.filter(({path:o,type:a,result:r})=>{let s=aw(n,t,o);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return V(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let i=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&i?.type==="number"&&i.scope==="context"&&i.readonly!==!0&&!_e(i)&&np(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),ba=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==br)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let n=new Set,o=e.randomOutcomes.map((a,r)=>{let s=`${a?.path}\0${a?.ordinal}`;if(!V(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||n.has(s))throw new Error(`invalid rollback random outcome at index ${r}`);return n.add(s),{path:a.path,ordinal:a.ordinal,type:a.type,result:Zn(q(a.result),a.type)}});return t===void 0?o:sp(o,e,t)},lw=(e,t)=>{!V(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!V(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=tp(n.executedActions,t);o?n.executedActions=o:delete n.executedActions;let a=ba(n,t);a?(n.randomOutcomeVersion=br,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},cw=(e,t)=>{let n=e??{};return Object.values(n).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let s=r?.rollback?.timeline;Array.isArray(s)&&s.forEach(i=>{if(!V(i))return;let l=ba(i,t);l?(i.randomOutcomeVersion=br,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),n},Fu=(e,t,n,o="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!V(e))throw new Error(`Malformed ${o}.${t}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${t}[${n}] entry: missing ${a}.`);if(t==="sections"){let r={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${o}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},uw=(e,t="viewedRegistry")=>{if(e===void 0)return Wu();if(!V(e))throw new Error(`Malformed ${t}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${t}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${t}.resources.`);let n=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,r)=>{let s=Fu(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let s=Fu(a,"resources",r,t);return[s.resourceId,s]})))}},pw=(e,t="accountReplayRegistry")=>{if(e===void 0)return Ju();if(!V(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return o}))]}},nn=(e,t,n)=>{if(!V(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:r,section:s}=wr(t,o);if(!s)throw new Error(`Malformed save slot ${n}: section "${o}" does not exist in projectData.`);if(!s.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${n}: line "${a}" does not exist in section "${o}".`);return{sceneId:r,sectionId:o,lineId:a}},ip=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],o=n.initialSectionId,a=n.sections[o];return nn({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},fw=e=>{try{return ip(e),!0}catch{return!1}},dw=(e,t,n)=>{let o=e?.pointers?.read;if(!V(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return nn(o,t,n);try{return nn(o,t,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],r=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=r;s>=0;s-=1)try{return nn(a[s],t,`${n} compatibility checkpoint`)}catch{}return ip(t)}};var op=(e,t)=>{let{section:n}=wr(e,t?.sectionId);return n?.lines?.find(o=>o.id===t?.lineId)},mw=(e,t,n)=>{if(!V(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],r=!1;if(e.entries.forEach((i,l)=>{if(!V(i))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:c}=wr(t,i.sectionId);if(!c?.lines?.some(p=>p.id===i.lineId)){r=!1,a.push(o.length);return}o.push({sectionId:i.sectionId,lineId:i.lineId,...i.appendToPrevious===!0&&r&&o.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(o.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:s}},yw=(e,t)=>V(op(e,t)?.actions?.dialogue),ap=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:o}=wr(e,n.sectionId),a=o?.lines?.findIndex(s=>s.id===n.lineId);return typeof a!="number"||a<=0?!1:o.lines.slice(0,a).findLast(s=>V(s.actions?.dialogue))?.id===t.lineId},hw=(e,t)=>{let n=Qu();return e.timeline.forEach(o=>{if(o.returnable!==!1&&yw(t,o)){let a=op(t,o),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&ap(t,r,o);n.entries.push({sectionId:o.sectionId,lineId:o.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},gw=(e,t,n,o)=>{if(n.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==o)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,s)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=r}),e},bw=(e,t,n)=>{if(!V(e)||!Array.isArray(e.timeline))return{rollback:on({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!V(c))return[];let p=ba(c);try{let d=nn(c,n,`rollback.timeline[${u}]`),f=p?sp(p,d,n):void 0,m=bs({sectionId:d.sectionId,lineId:d.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...f?{randomOutcomeVersion:br,randomOutcomes:f}:{}}),h=tp(q(c.executedActions),n);return h&&(m.executedActions=h),o.push(u),[m]}catch{return[]}});if(a.length===0)return{rollback:on({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,s=o.indexOf(r);s<0&&(s=a.length-1);let i=a[s];if(i?.sectionId!==t.sectionId||i?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?s=c:(a.push(bs({sectionId:t.sectionId,lineId:t.lineId})),o.push(null),s=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),s):0;return{rollback:{currentIndex:s,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:o,sourceTimelineLength:e.timeline.length}},lp=(e,t,n)=>{if(!V(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Ia(t),a=dw(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!V(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!V(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Yt(q(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=$w({loadedContextRuntime:V(e.runtime)?q(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=bw(e.rollback,a,t),u=e.dialogueHistory===void 0?hw(i,t):gw(mw(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:V(e.configuration)?q(e.configuration):{},views:Array.isArray(e.views)?q(e.views):[],bgm:V(e.bgm)?q(e.bgm):{resourceId:void 0},variables:{...o,...r},...u?{dialogueHistory:u}:{},rollback:i};return s&&(p.runtime=s),p},ww=(e,t)=>{if(!V(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((n,o)=>lp(n,t,o))}},Iw=(e,t)=>{if(!V(e))throw new Error("Malformed save slot.");let n=rp(e.formatVersion);return{...e,formatVersion:n,state:ww(e.state,t)}},Bu=(e,t,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${t}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${t} must be an action object`);let o=q(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},vw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:Bu(e.confirmActions,"confirmActions",{required:!0}),cancelActions:Bu(e.cancelActions,"cancelActions")}},St=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},kw=e=>(V(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Ot=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},cp=e=>{if(!(!V(e)||!e.animations))return{animations:q(e.animations)}},Aw=(e,t)=>{let n=cp(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Pw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},Ew=(e,t)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!t))return`${n}:${o}:${t}`},gs=e=>String(e??""),up=(e,t)=>{let n=gs(t);return e?.trim===!0?n.trim():n},xw=e=>V(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>V(t)).map(([t,n])=>[t,{id:t,...q(n)}])):{},Sw=(e,t)=>{if(!t||!V(e.global.formDrafts))return;let n=e.global.formDrafts[t];return V(n)?n:void 0},pp=(e,t)=>{let n=kw(e);V(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let o=n[t];return V(o.values)||(o.values={}),V(o.touched)||(o.touched={}),V(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},wa=(e,t)=>{let n=up(e,t);return e?.required===!0&&n.length===0?"required":null},Ow=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let o=xe({state:e},{sectionId:t.sectionId})?.lines||[],a=o.findIndex(r=>r.id===t.lineId);return a<0?{}:Zr(o.slice(0,a+1).map(r=>r.actions||{}),{resources:e.projectData.resources})},Rw=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let o=Pw(t),a=Ew(n,o);if(!o||!a)return null;let r=Sw(e,a),s=xw(t),i=ja({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([d,f])=>{let m=gs(i?.[f.variableId]),h=Object.prototype.hasOwnProperty.call(r?.values??{},d)?gs(r.values[d]):m,g=r?.touched?.[d]===!0,y=wa(f,h),w=r?.submitted||g?y:null,b=typeof f.maxLength=="number"?Math.max(0,Math.round(f.maxLength)):void 0,A={id:d,variableId:f.variableId,value:h,initialValue:m,valid:!y,error:w,touched:g,required:f.required===!0,trim:f.trim===!0,placeholder:f.placeholder===void 0?"":String(f.placeholder),multiline:f.multiline===!0,...b!==void 0?{maxLength:b}:{}};y&&(p=!1),l[d]=A,c.push(A),u[d]=h}),{id:o,key:a,resourceId:t.resourceId,animations:t.animations,valid:p,submitted:r?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:q(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:q(t.cancelActions??{})}}}},Pt="line",Dr="interaction",bs=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:o,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{},...a===br?{randomOutcomeVersion:br,randomOutcomes:q(r??[])}:{}}),Ia=e=>{let t=Pe(e)?Pr(e):e,{contextVariableDefaultValues:n}=Hn(t??{});return q(n)},fp=()=>({...q(Qt)}),dp=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:q(n),hasLoadedValues:!1};if(!V(e))throw new Error(`Malformed ${o}.`);let a=q(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=is(s,q(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Cw=({projectData:e,loadedGlobalRuntime:t={}})=>dp({loadedRuntime:t,runtimeIds:Io,defaults:ko(e),path:"global.runtime"}).runtimeState,$w=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=dp({loadedRuntime:e,runtimeIds:vo,defaults:fp(),path:"context.runtime"});return n?t:void 0},Mr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ye=e=>{let t=Mr(e);return t?.kind==="sceneReplay"&&V(t.sceneReplay)?t:null},mp=(e,t)=>{let n=t?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=q(r)})},_w=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:q(e.global.nextLineConfig),overlayStack:q(e.global.overlayStack),confirmDialog:q(e.global.confirmDialog),formDrafts:q(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:q(e.global.pendingScreenTransition)}}),jw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=an(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Nw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=q(t.nextLineConfig),e.global.overlayStack=q(t.overlayStack),e.global.confirmDialog=q(t.confirmDialog),e.global.formDrafts=q(t.formDrafts),e.global.isLineCompleted=t.isLineCompleted,t.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=t.isDialogueHistoryShowing,t.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=q(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Se({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e.global.skipMode&&!n&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!n&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Dw=e=>e.runtime?(vo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=q(Qt[t]))}),e.runtime):(e.runtime=fp(),e.runtime),Tw=e=>Vc(e.global),yp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Tw(e)}})},va=(e,t,n)=>{let o=is(t,n);if(t in Qt){let a=Mr(e);if(!a)return o;let r=Dw(a);return r[t]=o,o}return e.global[t]=o,o},ka=({pointer:e,projectData:t,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:q(o)},currentPointerMode:"read",pointers:{read:q(e)},configuration:{},views:[],bgm:tw(),variables:Ia(t),rollback:on({pointer:e})}),Rt=e=>e?(e.currentPointerMode="read",V(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,Lw=(e,{queueRender:t=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],o=n?.pointers?.read;if(!n||!o?.sectionId||!o?.lineId)return null;let a=ka({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Mw(e,{queueRender:t}),a},Mw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,St(e),Ot(e),e.global.nextLineConfig=an(),e.global.overlayStack=[],e.global.isLineCompleted=!0,ya(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},hp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},on=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[bs({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Vr=(e,t={})=>{if(e?.rollback)return hp(e.rollback),Array.isArray(e.rollback.timeline)||(e.rollback.timeline=[]),typeof e.rollback.currentIndex!="number"&&(e.rollback.currentIndex=e.rollback.timeline.length>0?e.rollback.timeline.length-1:-1),typeof e.rollback.isRestoring!="boolean"&&(e.rollback.isRestoring=!1),typeof e.rollback.replayStartIndex!="number"&&(e.rollback.replayStartIndex=0),e.rollback;let n=e?.pointers?.read;return e.rollback=on({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},vs=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=Vr(n);if(o.isRestoring)return;let a=ga(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(bs(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},Vw=({state:e})=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;return!Array.isArray(n?.timeline)||typeof n.currentIndex!="number"?null:{checkpointIndex:n.currentIndex,checkpoint:n.timeline[n.currentIndex]??null}},qw=({state:e},t={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:a,lineId:r}=t,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[n];return(Pe(l)?Nn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},Fw=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:s}=t,i=st(n),l=e.global.saveSlots?.[i],c=Pe(l)?Nn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,d=p?.rollback,f=d?.timeline?.[a];return!Number.isInteger(a)||d?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||f?.sectionId!==r||f?.lineId!==s||(f.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},gp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:o.currentIndex;if(r<0||r>=o.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<o.timeline.length-1){o.timeline=o.timeline.slice(0,r+1);let s=ga(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},Bw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},o={})=>{let a=o?.source===Pt?Pt:Dr,r=e.contexts?.[e.contexts.length-1],s=r?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let u=ga(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let i=r?.pointers?.read,l=n?.lineEntryId,c=a===Pt&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===i?.sectionId&&s.timeline[s.currentIndex]?.lineId===i?.lineId:n.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:s.currentIndex,source:a,...a===Pt?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Uw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),Yw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let o=t?.at(-1);if(o?.source!==Pt||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;vs(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let s=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=s.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,n?.lineEntryId===o.lineEntryId&&(n.rollbackCheckpointLineEntryId=o.lineEntryId),e},zw=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==Pt)return e;if(typeof n?.path!="string"||n.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(n.ordinal)||n.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=Zn(n.result,n.type),r=gp(e,t);if(!r)return e;if(r.randomOutcomeVersion!==br&&(r.randomOutcomeVersion=br,r.randomOutcomes=[]),r.randomOutcomes.some(({path:s,ordinal:i})=>s===n.path&&i===n.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${n.path}#${n.ordinal}`);return r.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:a}),e},sr=(e,t,n,o)=>{let r=o?.at(-1)?.source??Dr;if(!YI(t,r))return;let s=gp(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:q(n)}))},ra=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=t?.operations??[];for(let{variableId:a,op:r,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(_e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);zt(c,a),Xt(u,r,a),Kn(u,r,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=Wn(n.variables[a],r,s,{roundTo:i}))}},Xw=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:o})=>{zI(e,n,o)})},Gw=(e,t)=>{let{sectionId:n,lineId:o}=t,s=xe({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Ma(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},bp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=Vr(n),a=o.timeline[t];if(!a)return e;e.global.autoMode&&fn({state:e}),e.global.skipMode&&Lr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{n.variables=Ia(e.projectData),n.kind==="sceneReplay"&&(mp(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=q(hs),e.global.overlayStack=[],St(e),Ot(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&ma(e),Gw(e,o.timeline[l]),Xw(e,o.timeline[l]);let s=Rt(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=ha(n);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Gu(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},Hw=e=>{let{projectData:t}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:r={},runtime:s={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;Zu(t),Ft(t),Bt(t),Ut(t),Jr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],d=p.initialSectionId,f=p.sections[d],m={sceneId:u,sectionId:d,lineId:f.initialLineId??f.lines[0].id},{globalVariablesDefaultValues:h}=Hn(t),g={...h,...Yt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:uw(i,"accountViewedRegistry"),accountReplayRegistry:pw(l),nextLineConfig:an(),imageGalleryNavigation:ua(),sceneReplayNavigation:da(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:ws(),saveSlots:iw(a),localizationPackages:q(c),overlayStack:[],variables:g,...Cw({projectData:t,loadedGlobalRuntime:s})},contexts:[ka({pointer:m,projectData:t})]}},Kw=({state:e})=>e.global.overlayStack||[],Ww=({state:e})=>e.global.pendingEffects,wp=({state:e})=>e.global.skipMode,Jw=({state:e})=>e.global.autoMode,Ip=({state:e})=>e.global.dialogueUIHidden,vp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let o,a=V(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)o=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=n.pointers.read,p=xe({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let d=p.lines.findIndex(f=>f.id===u);o=p.lines.slice(0,d+1).map(f=>({sectionId:c,lineId:f.id}))}let r=[],s=ht({variables:{...e.global?.variables??{},...Mr(e)?.variables??{}},runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let d=xe({state:e},{sectionId:c.sectionId}),f=Array.isArray(d?.lines)?d.lines:[];u={lines:f,lineIndexes:new Map(f.map((m,h)=>[m.id,h])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let d=u.lines[u.nextLineIndex],f=d.actions||{};u.presentationState=Zr([u.presentationState,f],{resources:e.projectData.resources}),u.projections.set(d.id,{line:d,lineActions:f,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!ew(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:d,dialogueState:f}=u;if(!d.dialogue)continue;let m=Gn({characterId:f.characterId,character:f.character,characters:e.projectData.resources?.characters??{},variables:s}),h=Zb({sectionId:c.sectionId,lineId:p.id,content:d.dialogue.append===!0?f.content:d.dialogue.content,dialogueState:f,characterName:m}),g=r[r.length-1];if((a?c.appendToPrevious===!0:d.dialogue.append===!0)&&g?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:h.content,text:h.text,characterId:h.characterId,character:h.character,characterName:h.characterName};continue}r.push(h)}return r},Qw=(e,t,n)=>{let o=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:s,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[st(r)],u=Pe(c)?Nn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=q(n),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},Zw=({state:e},t={})=>{let n=Mr(e),o=n?.pointers?.read,a=un({state:e});if(!n||!V(a?.actions?.dialogue))return e;let r=Vr(n),s=r.timeline?.[r.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=ha(n),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||t.forceNewOccurrence!==!0&&i&&l&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let d=rw(n);d.currentLength<d.entries.length&&(d.entries=d.entries.slice(0,d.currentLength));let f=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&ap(e.projectData,p,o);if(d.entries.push({sectionId:o.sectionId,lineId:o.lineId,...f?{appendToPrevious:!0}:{}}),d.currentLength=d.entries.length,i){for(;d.checkpointLengths.length<r.timeline.length;)d.checkpointLengths.push(d.checkpointLengths.at(-1)??0);d.checkpointLengths[r.currentIndex]=d.currentLength}return Qw(e,t.savedCheckpointOccurrences,d),e},e0=({state:e})=>e.global.confirmDialog??null,cn=({state:e},{pointer:t}={})=>{let n=t??qe({state:e})?.pointer,o=Ow({state:e,pointer:n});return Rw({state:e,form:o.form,pointer:n})},r0=({state:e},{pointer:t}={})=>!!cn({state:e},{pointer:t}),Se=({state:e},{pointer:t}={})=>{let n=cn({state:e},{pointer:t});if(n)return{source:Tr,formId:n.id,formKey:n.key};let o=Sp({state:e,pointer:t});return o?{source:Et,resourceId:o}:null},t0=({state:e,registry:t},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let i=xe({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=i.lines.findIndex(u=>u.id===s.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},Aa=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},Pa=({state:e},t)=>t0({state:e,registry:e.global.accountViewedRegistry},t),n0=({state:e},t)=>Aa({registry:e.global.accountViewedRegistry},t),sn=(e,t)=>!Aa({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Ea=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),xa=(e,t)=>{let n=Ea(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},ta=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!sn(e,t[a]))return t[a]},s0=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:q(t)},kp=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??ua(),o=Ea(t),a=xa(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:sn(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:sn(e,c)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(f=>f.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(f=>f.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],d=l<0?-1:Math.floor(l/t.pageSize);p&&d===a&&!sn(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ta(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:ta(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Sa=(e,t)=>!Aa({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Oa=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ra=(e,t)=>{let n=Oa(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},na=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!Sa(e,t[a]))return t[a]},Ap=e=>({trackId:e.id,soundId:e.soundId,title:e.title,artist:e.artist??null,album:e.album??null,description:e.description??null,coverImageId:e.coverImageId??null}),i0=(e,t)=>({...Ap(t),locked:Sa(e,t)}),Uu=e=>{let t=Math.floor(e/1e3),n=t%60,o=Math.floor(t/60);if(o<60)return`${o}:${String(n).padStart(2,"0")}`;let a=Math.floor(o/60),r=o%60;return`${a}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},o0=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:q(t)},Pp=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??ws(),o=Oa(t),a=Ra(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>i0(e,u)),i=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[i],c=l?{...Ap(l),canPlayPreviousTrack:na(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:na(e,t.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Uu(n.positionMs),durationText:n.durationMs===null?null:Uu(n.durationMs),canPlay:n.status!=="playing",canPause:n.status==="playing",canSeek:n.readiness==="ready"&&n.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Ca=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),$a=(e,t)=>{let n=Ca(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},a0=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:q(t)},l0=({state:e})=>ye(e)!==null,c0=({state:e})=>{let t=ye(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Ep=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,xp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??da(),o=Ca(t),a=$a(t,n),r=a*t.pageSize,s=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!Ep(e,l.sceneId)})),i=ye(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},u0=({state:e})=>e.global.nextLineConfig,Sp=({state:e,pointer:t}={})=>{let n=t??qe({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=xe({state:e},{sectionId:o})?.lines||[],i=s.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of s.slice(0,i+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},Op=({state:e})=>!!Sp({state:e}),p0=({state:e})=>structuredClone(e),f0=({state:e})=>q(e.projectData.resources?.achievements??{}),d0=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:q(n)},Rp=({state:e})=>e.global.saveSlots,m0=({state:e},t)=>{let n=t?.slotId,o=st(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Cp=({state:e})=>q(e.global.localizationPackages),_a=({state:e})=>_r(e),y0=({state:e},t)=>tr(e,t?.runtimeId),ja=({state:e})=>{let t={...e.global?.variables??{},...Mr(e)?.variables??{}};return ht({variables:t,runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{}})},qe=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},xe=({state:e},t)=>{let{sectionId:n}=t;return wr(e.projectData,n).section},un=({state:e})=>{let t=qe({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:o}=t.pointer,a=xe({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===o)},$p=({state:e})=>{let{sectionId:t,lineId:n}=qe({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===n),i=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(d=>{p[d]=u[d]}),p});return Zr(i,{resources:e.projectData.resources})},_p=e=>{let t=un({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=ht({variables:{...e.global?.variables??{},...Mr(e)?.variables??{}},runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${bt(o?.text,{variables:n})??""}`).join("")},Ir=({state:e})=>Qo({text:_p(e),baseDelay:tr(e,"autoForwardDelay"),speed:tr(e,"autoForwardSpeed")}),h0=({state:e})=>{let t=jp({state:e}),o=un({state:e})?.actions??{},a=Zr([t??{},o],{resources:e.projectData.resources});return co(t??{},a??{})},g0=({state:e},{sectionId:t})=>{let n=xe({state:e},{sectionId:t});if(!n?.lines)return[];let o=[],a={};for(let r of n.lines){let s=r.actions||{},i=Zr([a,s],{resources:e.projectData.resources}),l=co(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=uo(i)}return o},b0=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let o=g0({state:e},{sectionId:t});return n?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},jp=({state:e})=>{let{sectionId:t,lineId:n}=qe({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===n);if(r<=0)return null;let i=a.slice(0,r).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return uo(Zr(i,{resources:e.projectData.resources}))},Na=({state:e},{slotsPerPage:t=6}={})=>{let a=((_a({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let s=0;s<t;s++){let i=a+s,l=e.global.saveSlots&&e.global.saveSlots[st(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},w0=Rp,I0=Na,Da=e=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;return!n||!Array.isArray(n.timeline)||typeof n.currentIndex!="number"?!1:n.currentIndex>=0&&n.currentIndex<n.timeline.length-1},v0=({state:e},t={})=>{let n=$p({state:e}),o=jp({state:e}),a=un({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:q(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=qe({state:e}).pointer,{sceneId:c}=wr(e.projectData,l),u={..._a({state:e}),localizationPackages:Cp({state:e})},p=t?.activePersistentAnimations??[],d=t?.restoredPersistentAnimations??[],f=cn({state:e}),m=Op({state:e}),h=kp({state:e}),g=Pp({state:e}),y=xp({state:e}),w=ja({state:e}),{saveSlots:b}=Na({state:e}),A=Da(e);return wu({presentationState:n,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:m,isFormVisible:!!f,canRollback:tf({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||A,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:f,dialogueHistory:vp({state:e}),saveSlots:b,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:d,imageGallery:h,musicRoom:g,sceneReplay:y,musicRoomPlayer:q(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},k0=({state:e},t)=>(e.global.confirmDialog=vw(t),e.global.pendingEffects.push({name:"render"}),e),A0=({state:e})=>(e.global.confirmDialog&&(St(e),e.global.pendingEffects.push({name:"render"})),e),P0=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),sr(e,"pushOverlay",n,t),e),E0=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),sr(e,"popOverlay",void 0,t),e),x0=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),sr(e,"replaceLastOverlay",n,t),e),S0=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],St(e),Ot(e),e.global.pendingEffects.push({name:"render"}),sr(e,"clearOverlays",void 0,t),e),O0=(e,{activeInteraction:t})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),t&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},pn=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Aw(e,n),Ot(e);let o=Se({state:e},{pointer:t}),a=o?.source===Et,r=o?.source===Tr;O0(e,{activeInteraction:o});let s=ye(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Gu(e);s.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:r,activeInteraction:o}},ks=(e,t,n)=>{!(t?.source===Et||t?.source===Tr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Np=({state:e})=>(Se({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),fn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),R0=({state:e})=>{let t=e.global.autoMode;return Se({state:e})&&!t||(t?fn({state:e}):Np({state:e})),e},Dp=({state:e})=>(Se({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Lr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),C0=({state:e})=>{let t=wp({state:e});return Se({state:e})&&!t||(t?Lr({state:e}):Dp({state:e})),e},As=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),sr(e,"showDialogueUI",void 0,t),e),Tp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),sr(e,"hideDialogueUI",void 0,t),e),$0=e=>{let{state:t}=e;return Ip({state:t})?As(e):Tp(e),t},qr=(e,t,n)=>(va(e,t,n),yp(e),e.global.pendingEffects.push({name:"render"}),e),dn=(e,t,n,o,a)=>{let r=va(e,t,n);return e.global.pendingEffects.push({name:"render"}),sr(e,o,{value:r},a),e},_0=({state:e},t)=>qr(e,"dialogueTextSpeed",t?.value),j0=({state:e},t)=>(qr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e),N0=({state:e},t)=>(qr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e),D0=({state:e},t)=>qr(e,"skipUnseenText",t?.value),T0=({state:e},t)=>qr(e,"skipTransitionsAndAnimations",t?.value),L0=({state:e},t)=>qr(e,"soundVolume",t?.value),M0=({state:e},t)=>qr(e,"musicVolume",t?.value),V0=({state:e},t)=>qr(e,"muteAll",t?.value),sa=({state:e,rollbackActionBatchStack:t},n)=>dn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),ia=({state:e,rollbackActionBatchStack:t})=>{let n=tr(e,"saveLoadPagination")+1;return dn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},oa=({state:e,rollbackActionBatchStack:t})=>{let n=tr(e,"saveLoadPagination")-1;return dn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},aa=({state:e,rollbackActionBatchStack:t},n)=>dn(e,"menuPage",n?.value,"setMenuPage",t),la=({state:e,rollbackActionBatchStack:t},n)=>dn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),q0=({state:e})=>(e.global.pendingEffects=[],e),F0=({state:e},t)=>(e.global.pendingEffects.push(t),e),B0=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId;return Hu(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},U0=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId,o=Hu(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${n}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let r=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:r,target:o.target,completed:r>=o.target}}),e},Lp=e=>e?.lines?.[0],Mp=(e,{sectionId:t,resetStoryState:n=!1,screen:o})=>{let a=!!cp(o),r=xe({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=Lp(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!Lw(e,{queueRender:!a}))return e;let i=Se({state:e});n&&e.global.skipMode&&Lr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Rt(l),p=u.read;n||nt(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Vr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=on({pointer:u.read}):vs(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=pn(e,l?.pointers?.read,{screenTransition:o});return ks(e,i,c),e},Y0=({state:e},t)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return Mp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Vp=e=>(e.global.accountViewedRegistry=Wb(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Ps=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(n=>({scope:n.scope,path:n.path,op:n.op,value:q(n.value)}))}})},qp=(e,t)=>{Ps(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},z0=(e,t,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=V(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(s=>s.sectionId===n);if(r){if(r.lastLineId===void 0)return!1;let s=xe({state:e},{sectionId:n});if(s?.lines){let i=s.lines.findIndex(c=>c.id===r.lastLineId),l=s.lines.findIndex(c=>c.id===o);if(i===-1||l>i)return r.lastLineId===o?!1:(r.lastLineId=o,!0)}else return r.lastLineId===o?!1:(r.lastLineId=o,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:o}),!0},nt=(e,t)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;z0(e,Vp(e),t)&&qp(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},X0=({state:e},t)=>(nt(e,t),e.global.pendingEffects.push({name:"render"}),e),G0=({state:e},t)=>{if(ye(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let o=Vp(e);o.resources.find(r=>r.resourceId===n)||(o.resources.push({resourceId:n}),qp(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},ir=(e,t,n)=>{if(!V(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},ca=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},Es=(e,t)=>{let n=e.global.imageGalleryNavigation;n.groupId===t.groupId&&n.variantId===t.variantId&&n.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},H0=({state:e},t)=>{let n="showImageGalleryVariant";ir(n,t,Ub),ca(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&ca(n,"variantId",t.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let a=o.groups.findIndex(i=>i.id===t.groupId),r=o.groups[a];if(!r)return e;let s=t.variantId===void 0?r.variants[0]:r.variants.find(i=>i.id===t.variantId);return!s||sn(e,s)||Es(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},Fp=(e,t,n,o)=>{ir(o,t,pa);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let r=e.global.imageGalleryNavigation;if(typeof r.groupId!="string"||typeof r.variantId!="string")return e;let s=a.groups.find(c=>c.id===r.groupId),i=s?.variants.findIndex(c=>c.id===r.variantId);if(!s||i===void 0||i<0)return e;let l=ta(e,s.variants,i,n);return l&&Es(e,{...r,variantId:l.id}),e},K0=({state:e},t)=>Fp(e,t,-1,"moveToPreviousImageGalleryVariant"),W0=({state:e},t)=>Fp(e,t,1,"moveToNextImageGalleryVariant"),J0=({state:e},t)=>{if(ir("clearImageGallerySelection",t,pa),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return Es(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},Bp=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=Ea(n);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=xa(n,a);return t===r||Es(e,{groupId:null,variantId:null,pageIndex:t}),e},Q0=({state:e},t)=>{if(ir("moveToImageGalleryPage",t,Yb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Bp(e,t.pageIndex)},Up=(e,t,n,o)=>{ir(o,t,pa);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=xa(a,e.global.imageGalleryNavigation)+n;return s<0?e:Bp(e,s)},Z0=({state:e},t)=>Up(e,t,1,"moveToNextImageGalleryPage"),eI=({state:e},t)=>Up(e,t,-1,"moveToPreviousImageGalleryPage"),vr=(e,t,n)=>{if(!V(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},rI=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},er=e=>{e.global.pendingEffects.push({name:"render"})},Yp=(e,t)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,r=o.trackId===t.id,s=o.bgmPlayback;a||(s={commandId:Is(e),operation:"pause"});let i=ln(e,"play",0),l=n.tracks.indexOf(t),c=r?o.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:s},er(e)},tI=({state:e},t)=>{let n="playMusicRoomTrack";vr(n,t,zb),rI(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Sa(e,a)||Yp(e,a),e},nI=({state:e},t)=>{vr("playMusicRoom",t,xt);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",r=o.readiness==="error",s=o.status==="paused"&&!r?"resume":"play",i=a?0:o.positionMs;return o.playback=ln(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),er(e),e},sI=({state:e},t)=>{vr("pauseMusicRoom",t,xt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=ln(e,"pause"),o.seekFallback=null,o.status="paused",er(e)),e},iI=({state:e},t)=>{vr("stopMusicRoom",t,xt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=ln(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,er(e)),e},oI=({state:e},t)=>{if(vr("seekMusicRoom",t,Xb),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let o=e.global.musicRoomPlayer;if(o.trackId===null||o.readiness!=="ready"||o.durationMs===null||t.positionMs>o.durationMs)return e;let a=ln(e,"seek",t.positionMs);return o.seekFallback={commandId:a.commandId,status:o.status,positionMs:o.positionMs},o.playback=a,o.positionMs=t.positionMs,t.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),er(e),e},zp=(e,t,n,o)=>{vr(o,t,xt);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===r.trackId);if(s<0)return e;let i=na(e,a.tracks,s,n);return i&&Yp(e,i),e},aI=({state:e},t)=>zp(e,t,-1,"playPreviousMusicRoomTrack"),lI=({state:e},t)=>zp(e,t,1,"playNextMusicRoomTrack"),cI=({state:e},t)=>{vr("clearMusicRoomSelection",t,xt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:Is(e),operation:"resume"};return e.global.musicRoomPlayer={...ws({bgmPlayback:r}),pageIndex:a},er(e),e},Xp=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=Oa(n))return e;let o=e.global.musicRoomPlayer,a=Ra(n,o);return t===a||(o.pageIndex=t,er(e)),e},uI=({state:e},t)=>{if(vr("moveToMusicRoomPage",t,Gb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Xp(e,t.pageIndex)},Gp=(e,t,n,o)=>{vr(o,t,xt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Ra(a,e.global.musicRoomPlayer)+n;return r<0?e:Xp(e,r)},pI=({state:e},t)=>Gp(e,t,1,"moveToNextMusicRoomPage"),fI=({state:e},t)=>Gp(e,t,-1,"moveToPreviousMusicRoomPage"),tt=e=>{let t=ye(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=q(t.sceneReplay.returnState),o=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),Nw(e,n),e.global.pendingEffects.push({name:"render"}),!0},dI=({state:e},t)=>{let n="startSceneReplay";if(ir(n,t,Hb),ca(n,"sceneId",t.sceneId),ye(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!Ep(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,i=r?.sections?.[s],l=i?.initialLineId??i?.lines?.[0]?.id;if(!i||!l||!i.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=_w(e);jw(e);let u=ka({pointer:{sceneId:a.sceneId,sectionId:s,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return mp(e,u),e.contexts.push(u),pn(e,u.pointers.read),e},Hp=({state:e},t)=>{ir("finishSceneReplay",t,fa);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Mr(e)?.rollback?.isRestoring===!0)return e;let r=qe({state:e})?.pointer,{sceneId:s}=wr(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=Jb(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Ps(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},mI=({state:e},t)=>(ir("exitSceneReplay",t,fa),tt(e),e),Kp=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=Ca(n))return e;let o=$a(n,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},yI=({state:e},t)=>{if(ir("moveToSceneReplayPage",t,Kb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Kp(e,t.pageIndex)},Wp=(e,t,n,o)=>{ir(o,t,fa);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=$a(a,e.global.sceneReplayNavigation)+n;return r<0?e:Kp(e,r)},hI=({state:e},t)=>Wp(e,t,1,"moveToNextSceneReplayPage"),gI=({state:e},t)=>Wp(e,t,-1,"moveToPreviousSceneReplayPage"),xs=(e,t)=>{let n=e.global.musicRoomPlayer;return!V(t)||t.id!==Fb||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Ta=e=>typeof e.positionMs=="number"&&Number.isFinite(e.positionMs)&&e.positionMs>=0&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>0&&e.positionMs<=e.durationMs,Jp=(e,t,n,{readiness:o=t.readiness}={})=>((t.readiness!==o||t.positionMs!==n.positionMs||t.durationMs!==n.durationMs||t.seekFallback!==null)&&(t.readiness=o,t.positionMs=n.positionMs,t.durationMs=n.durationMs,t.seekFallback=null,er(e)),e),bI=({state:e},t)=>{let n=xs(e,t);return!n||n.readiness!=="loading"||!Ta(t)?e:Jp(e,n,t,{readiness:"ready"})},wI=({state:e},t)=>{let n=xs(e,t);return!n||n.readiness!=="ready"||!Ta(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:Jp(e,n,t)},II=({state:e},t)=>{let n=xs(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Ta(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,er(e)),e},vI=({state:e},t)=>{let n=xs(e,t);if(!n||typeof t.errorCode!="string"||!Bb.has(t.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(t.errorCode==="invalid-position"){let o=n.seekFallback;if(n.playback.operation!=="seek"||o?.commandId!==t.commandId)return e;let a=n.status!==o.status||n.positionMs!==o.positionMs;return n.status=o.status,n.positionMs=o.positionMs,n.seekFallback=null,a&&er(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,er(e),e},Qp=({state:e,rollbackActionBatchStack:t},n)=>{let o=nw(n.manual),{auto:a,applyMode:r}=n,s=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,d=e.global.nextLineConfig.auto?.trigger,f=e.global.nextLineConfig.auto?.delay,m=Se({state:e});return!u&&(a!==void 0&&(p!==s||d!==i||f!==l))&&(!m&&p===!0&&(d==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:f}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),sr(e,"setNextLineConfig",n,t),e},kI=({state:e},t)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;Ku(n,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=st(n),s=q(e.contexts);s?.forEach(c=>{Rt(c),hp(c.rollback),lw(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:Xu,slotId:ep(n),savedAt:typeof a=="number"?a:Date.now(),image:o,state:i};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},AI=({state:e},t)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;Ku(n,"loadSlot");let o=st(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=Iw(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=an(),e.global.overlayStack=[],e.global.isLineCompleted=!0,St(e),Ot(e),ya(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},PI=({state:e},t)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;Zu(n),Ft(n),Bt(n),Ut(n),Jr(n?.resources?.variables??{}),ko(n);let o=fw(n),a=o?e.contexts?.map((s,i)=>lp(q(s),n,i)):void 0,r=o?cw(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=ua(),e.global.sceneReplayNavigation=da(),ya(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:i}=Hn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Yt(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return St(e),Ot(e),o&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},EI=({state:e},t)=>{let{l10nId:n,projectData:o}=t??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!V(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,va(e,"localizationPackageId",n),yp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},xI=({state:e},t)=>{let{sectionId:n,lineId:o}=t;if(!o)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let r=n||a.pointers.read?.sectionId;if(n&&!xe({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=xe({state:e},{sectionId:r});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${r} has no lines`),e;if(!s.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${r}`),e;let l=Se({state:e}),c=Rt(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=pn(e,c.read);return ks(e,l,u),e},SI=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return As({state:e,rollbackActionBatchStack:t}),e;let o=Se({state:e});if(o?.source===Et&&n?.bypassChoice!==!0||o?.source===Tr&&n?._interactionSource!==Tr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return tt(e),e;let f=qe({state:e})?.pointer,m=f?.sectionId,h=f?.lineId;m&&h&&nt(e,{sectionId:m,lineId:h}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}});let g=e.global.nextLineConfig,y=xe({state:e},{sectionId:m});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===h?ea(e):g?.auto?.enabled&&!o&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ye(e)?.sceneReplay.finishOnNextAdvance)return tt(e),e;let r=qe({state:e})?.pointer,s=r?.sectionId,i=xe({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(d=>d.id===r?.lineId)+1;if(p<c.length){let d=c[p],f=!tr(e,"skipUnseenText");if(e.global.skipMode&&f&&!Pa({state:e},{sectionId:s,lineId:d.id}))return Lr({state:e}),e;if(l&&!l.rollback&&Vr(l,{compatibilityAnchor:!0}),l){let h=Rt(l),g=h.read?.lineId;g&&s&&nt(e,{sectionId:s,lineId:g}),h.read={sectionId:s,lineId:d.id}}vs(e,{sectionId:s,lineId:d.id}),ma(e);let{activeInteraction:m}=pn(e,{sectionId:s,lineId:d.id});ks(e,o,m)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),tt(e),e;e.global.autoMode&&fn({state:e}),e.global.skipMode&&Lr({state:e}),ea(e)}return e},OI=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return tt(e),e;let n=Se({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}});let o=qe({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&nt(e,{sectionId:a,lineId:r});let s=e.global.nextLineConfig;return s?.auto?.enabled&&!n&&s.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:s.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},RI=({state:e},t)=>Mp(e,{sectionId:t?.sectionId,screen:t?.screen}),CI=({state:e,rollbackActionBatchStack:t},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return As({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e;let a=Se({state:e});if(a?.source===Et&&n?.bypassChoice!==!0||a?.source===Tr&&n?._interactionSource!==Tr||a&&a.source!==Et&&a.source!==Tr)return e;let r=ye(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(tt(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=qe({state:e})?.pointer,i=s?.sectionId,l=xe({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],d=u.findIndex(f=>f.id===s?.lineId)+1;if(d<u.length){let f=u[d],m=!tr(e,"skipUnseenText");if(e.global.skipMode&&m&&!Pa({state:e},{sectionId:i,lineId:f.id})&&(Lr({state:e}),!o))return e;if(c&&!c.rollback&&Vr(c,{compatibilityAnchor:!0}),c){let g=Rt(c),y=g.read?.lineId;y&&i&&nt(e,{sectionId:i,lineId:y}),g.read={sectionId:i,lineId:f.id}}vs(e,{sectionId:i,lineId:f.id}),ma(e);let{activeInteraction:h}=pn(e,{sectionId:i,lineId:f.id});ks(e,a,h)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),tt(e),e;e.global.autoMode&&fn({state:e}),e.global.skipMode&&Lr({state:e}),ea(e)}return e},La=(e,t={})=>{let n=cn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},$I=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],o=n?.scope,a=n?.type;if(_e(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(zt(o,t.variableId),Xt(a,"set",t.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},_I=(e,t)=>({id:e.id,key:e.key,valid:!0,values:q(t),fields:q(e.fields),fieldList:q(e.fieldList)}),jI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=qe({state:e})?.pointer,n=t?.sectionId,o=t?.lineId;n&&o&&nt(e,{sectionId:n,lineId:o})},NI=({state:e},t={})=>{let n=La(e,t),o=t.field;if(!n?.fields?.[o])return e;let a=pp(e,n.key),r=gs(t.value),s=n.fields[o],i=wa(s,r);return a.values[o]=r,a.touched[o]=!0,i?a.errors[o]=i:delete a.errors[o],e.global.pendingEffects.push({name:"render"}),e},DI=({state:e,rollbackActionBatchStack:t},n={})=>{let o=La(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=pp(e,o.key);a.submitted=!0;let r={},s={};if(Object.entries(o.fields).forEach(([d,f])=>{let m=Object.prototype.hasOwnProperty.call(a.values,d)?a.values[d]:f.value,h=wa(f,m);a.touched[d]=!0,h&&(s[d]=h),r[d]=up(f,m)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:q(s),form:{id:o.id,key:o.key,values:q(r)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([d,f])=>{let{scope:m}=$I(e,f),h=m==="context"?i.variables:e.global.variables,g=r[d];h[f.variableId]=Wn(h[f.variableId],"set",g),m==="context"&&(l=!0,u.push({variableId:f.variableId,op:"set",value:g})),(m==="device"||m==="account")&&c.push({scope:m,path:`variables.${f.variableId}`,op:"set",value:q(h[f.variableId])})}),l&&sr(e,"updateVariable",{id:"submitForm",operations:u},t),Ps(e,c);let p=_I(o,r);return jI(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},TI=({state:e},t={})=>{let n=La(e,t);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:q(n.values),fields:q(n.fields),fieldList:q(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},LI=({state:e,rollbackActionBatchStack:t},n)=>{let{id:o,operations:a=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let s=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:d})=>{let f=e.projectData.resources?.variables?.[c],m=f?.scope,h=f?.type;if(_e(f))throw new Error(`Cannot update computed variable: ${c}`);if(f?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(zt(m,c),Xt(h,u,c),Kn(h,u,p,c,{roundTo:d}),ye(e)&&m!=="context")throw new Error(`Cannot update ${m}-scoped variable "${c}" while a scene replay is active`);let g=m==="context"?r.variables:e.global.variables;if(m==="context"){s=!0;let y={variableId:c,op:u,value:p};d!==void 0&&(y.roundTo=d),l.push(y)}g[c]=Wn(g[c],u,p,{roundTo:d}),(m==="device"||m==="account")&&i.push({scope:m,path:`variables.${c}`,op:"set",value:q(g[c])})}),s&&sr(e,"updateVariable",{id:o,operations:l},t),Ps(e,i),e.global.pendingEffects.push({name:"render"}),e},He=e=>(t,n)=>e({state:t},n),Zp=e=>({variables:ht({variables:{...e.global?.variables??{},...Mr(e)?.variables??{}},runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:_r(e)}),MI=e=>{if(!V(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},VI=(e,t,n)=>{if(!V(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!V(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==n-1)throw new Error("conditional else branch must be the last branch")},qI=(e,t,n,o)=>{MI(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(VI(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!qt(r.when,{...Zp(e),...n?.bindings??{}}))){Ma(e,r.actions,n,[...o,"branches",String(a),"actions"]);return}}},FI=(e,t,n,o)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==br)return;let r=o.join("."),s=n.randomOutcomeOrdinals,i=s.get(r)??0;s.set(r,i+1);let l=a.randomOutcomes?.find(p=>p.path===r&&p.ordinal===i);if(!l)return;if(t?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${r}`);let c=Zn(q(l.result),l.type);if(c.type==="integer"){if(!np(t.distribution)||c.value<t.distribution.min||c.value>t.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${r}`);ra(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!V(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Ma(e,u,n,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},BI={conditional:{replayLine:qI},random:{replayLine:FI},updateVariable:{recordSources:[Dr],replayLine:ra,replayRecorded:ra,persistInSaveSlot:!0},setNextLineConfig:{replayLine:He(Qp)},setSaveLoadPagination:{recordSources:[Dr],replayLine:He(sa),replayRecorded:He(sa),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Dr],replayLine:He(ia),replayRecorded:He(ia),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Dr],replayLine:He(oa),replayRecorded:He(oa),persistInSaveSlot:!0},setMenuPage:{recordSources:[Dr],replayLine:He(aa),replayRecorded:He(aa),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Dr],replayLine:He(la),replayRecorded:He(la),persistInSaveSlot:!0},finishSceneReplay:{replayLine:He(Hp)}},Ss=e=>BI[e]??null,UI=e=>Ss(e)?.persistInSaveSlot===!0,YI=(e,t)=>{let n=Ss(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},zI=(e,t,n)=>{Ss(t)?.replayRecorded?.(e,n)},XI=(e,t,n,o,a)=>{let r=Ss(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,o,a);return}let s=o?.bindings??{},i=Gt({[t]:n},{...Zp(e),...s})[t];r.replayLine(e,i)},Ma=(e,t,n,o)=>{let a=es(t);ts(a);for(let[r,s]of a)XI(e,r,s,n,[...o,r])},GI=e=>e?.returnable!==!1,ef=(e,t)=>{if(t>=0)return e.currentIndex+t;let n=Math.abs(t);for(let o=e.currentIndex-1;o>=0;o-=1)if(GI(e.timeline[o])&&(n-=1,n===0))return o;return-1},rf=({state:e},t)=>{let{offset:n}=t;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let o=e.contexts[e.contexts.length-1];if(!o)return null;let a=o.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=ef(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},tf=({state:e})=>rf({state:e},{offset:-1})!==null,HI=({state:e},t)=>{let{offset:n=-1}=t;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=Vr(o,{compatibilityAnchor:!o.rollback}),r=ef(a,n);return r<0||r>=a.timeline.length?e:bp(e,r)},KI=({state:e},t)=>{let{sectionId:n,lineId:o}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=Vr(a,{compatibilityAnchor:!a.rollback}),i=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${n} rollback timeline`);return i===r.currentIndex?e:bp(e,i)},WI=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),Zo=(e,t)=>{let n=e[t];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${t} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=n+1,e[t]},Yu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,zu=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},JI=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,nf=e=>{let t=e.global?.nextLineConfig?.auto;return t?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:t.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:t.delay??1e3}},Va=e=>JSON.stringify(nf(e)),QI=({actionName:e,args:t,state:n,previousState:o})=>{let a=Yu(o),r=Yu(n);if(!JI(a,r)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&zu(o)!==zu(n))return!0;let s=t[0]??{};if(e==="jumpToLine"){let i=s.sectionId??a?.sectionId;return typeof s.lineId=="string"&&r?.sectionId===i&&r?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=wr(n.projectData,s.sectionId).section,l=Lp(i)?.id;return typeof l=="string"&&r?.sectionId===s.sectionId&&r?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let i=s.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},st(i))}return!1},ZI=({actionName:e,args:t,state:n,transactionalMetadata:o,previousState:a})=>{if(QI({actionName:e,args:t,state:n,previousState:a})){let u=Zo(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:Va(n)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let s=(a.contexts?.length??0)>(n.contexts?.length??0),i=e==="startAutoMode"||e==="startSkipMode"?Se({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&Zo(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&Zo(o,"skipSessionId")},ev=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==Va(e))&&(t.rollbackAuthoredSuppression=null)},rv=({state:e,playbackOwnership:t})=>{let n=Se({state:e}),o=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=nf(e),i=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===Va(e)),c=a?_p(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:Qo({text:c,baseDelay:tr(e,"autoForwardDelay"),speed:tr(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:s.delayMs,trigger:s.trigger}:null}},tv=({playbackOwnership:e})=>e.lineEntryId,sf=(e,t={})=>{let n=Hw(e),o=[],a=t.createPlaybackOwnership??WI;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return Kl(n,{selectPendingEffects:Ww,selectSkipMode:wp,selectAutoMode:Jw,selectIsChoiceVisible:Op,selectIsFormVisible:r0,selectActiveInteraction:Se,selectActiveForm:cn,selectDialogueUIHidden:Ip,selectDialogueHistory:vp,selectConfirmDialog:e0,selectIsLineAccountViewed:Pa,selectIsResourceAccountViewed:n0,selectImageGalleryConfig:s0,selectImageGallery:kp,selectMusicRoomConfig:o0,selectMusicRoom:Pp,selectSceneReplayConfig:a0,selectSceneReplay:xp,selectIsSceneReplayActive:l0,selectActiveSceneReplayEntry:c0,selectNextLineConfig:u0,selectSystemState:p0,selectAchievements:f0,selectAchievement:d0,selectSaveSlotMap:Rp,selectSaveSlots:w0,selectSaveSlot:m0,selectLocalizationPackages:Cp,selectRuntime:_a,selectRuntimeValue:y0,selectAllVariables:ja,selectCurrentPointer:qe,selectSection:xe,selectCurrentLine:un,selectPresentationState:$p,selectAutoForwardTimerDelay:Ir,selectPresentationChanges:h0,selectSectionLineChanges:b0,selectSaveSlotPage:Na,selectCurrentPageSlots:I0,selectRenderState:v0,selectOverlayStack:Kw,selectLineIdByOffset:rf,selectCanRollback:tf,selectRollbackCursor:Vw,selectDesiredPlaybackTimers:rv,selectPlaybackLineEntryId:tv,startAutoMode:Np,stopAutoMode:fn,toggleAutoMode:R0,startSkipMode:Dp,stopSkipMode:Lr,toggleSkipMode:C0,showDialogueUI:As,hideDialogueUI:Tp,toggleDialogueUI:$0,setDialogueTextSpeed:_0,setAutoForwardDelay:j0,setAutoForwardSpeed:N0,setSkipUnseenText:D0,setSkipTransitionsAndAnimations:T0,setSoundVolume:L0,setMusicVolume:M0,setMuteAll:V0,setSaveLoadPagination:sa,incrementSaveLoadPagination:ia,decrementSaveLoadPagination:oa,setMenuPage:aa,setMenuEntryPoint:la,showConfirmDialog:k0,hideConfirmDialog:A0,resetStoryAtSection:Y0,clearPendingEffects:q0,appendPendingEffect:F0,completeAchievement:B0,setAchievementProgress:U0,beginRollbackActionBatch:Bw,endRollbackActionBatch:Uw,ensureRandomReplayOccurrence:Yw,recordRandomOutcome:zw,markRollbackCheckpointTransient:qw,markSavedRollbackCheckpointTransient:Fw,recordCurrentDialogueHistory:Zw,addViewedLine:X0,addViewedResource:G0,showImageGalleryVariant:H0,moveToPreviousImageGalleryVariant:K0,moveToNextImageGalleryVariant:W0,clearImageGallerySelection:J0,moveToImageGalleryPage:Q0,moveToNextImageGalleryPage:Z0,moveToPreviousImageGalleryPage:eI,playMusicRoomTrack:tI,playMusicRoom:nI,pauseMusicRoom:sI,stopMusicRoom:iI,seekMusicRoom:oI,playPreviousMusicRoomTrack:aI,playNextMusicRoomTrack:lI,clearMusicRoomSelection:cI,moveToMusicRoomPage:uI,moveToNextMusicRoomPage:pI,moveToPreviousMusicRoomPage:fI,musicRoomSoundReady:bI,musicRoomSoundProgress:wI,musicRoomSoundComplete:II,musicRoomSoundError:vI,startSceneReplay:dI,finishSceneReplay:Hp,exitSceneReplay:mI,moveToSceneReplayPage:yI,moveToNextSceneReplayPage:hI,moveToPreviousSceneReplayPage:gI,setNextLineConfig:Qp,saveSlot:kI,loadSlot:AI,updateProjectData:PI,updateLocalizationPackage:EI,sectionTransition:RI,jumpToLine:xI,nextLine:SI,markLineCompleted:OI,rollbackToLine:KI,rollbackByOffset:HI,pushOverlay:P0,popOverlay:E0,replaceLastOverlay:x0,clearOverlays:S0,updateFormField:NI,submitForm:DI,cancelForm:TI,updateVariable:LI,nextLineFromSystem:CI},{createTransactionalMetadata:a,updateTransactionalMetadata:ZI,finalizeTransactionalMetadata:ev,transformActionFirstArgument:(s,i)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(s,i)=>({state:s,playbackOwnership:i})})};var nv="route-engine",sv="projectPersistence";var af=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),be=e=>Object.prototype.toString.call(e)==="[object Object]",of="variables.",iv=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!be(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lineId=="string"?{lineId:n.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!be(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},ov=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!be(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lastLineId=="string"?{lastLineId:n.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!be(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},av=(e,t)=>{let n=ov(e),o=iv(t),a=n.sections.map(s=>({...s})),r=n.resources.map(s=>({...s}));return o.sections.forEach(s=>{let i=a.find(l=>l.sectionId===s.sectionId);if(!i){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(i.lastLineId!==void 0){if(s.lineId===void 0){delete i.lastLineId;return}i.lastLineId=s.lineId}}),o.resources.forEach(s=>{r.find(l=>l.resourceId===s.resourceId)||r.push({...s})}),{sections:a,resources:r}},lv=(e={})=>{let t=be(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},cv=(e,t)=>{let n=lv(e),o=be(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},lf=(e={})=>{let t=be(e)?e:{};return{saveSlots:be(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:be(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:be(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:be(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:be(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:be(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},uv=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!be(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=t.path?.startsWith(of)?t.path.slice(of.length):null;if(o!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${n}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return{scope:t.scope,path:t.path,op:t.op,value:t.value,variableId:o}}if(t.path==="viewedRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);if(!be(t.value)||!Array.isArray(t.value.sceneIds)||t.value.sceneIds.length===0||t.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${n}].`)})},pv=(e,t)=>{let n={};return uv(t).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=av(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=cv(n.accountReplayRegistry??e.accountReplayRegistry,o.value);return}let a=o.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[a]={...e[a],...n[a],[o.variableId]:o.value}}),n},Ct=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},fv=e=>{let t=Ct(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},dv=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},mv=({indexedDB:e,databaseName:t,objectStoreName:n})=>new Promise((o,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},r.onsuccess=()=>{o(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),yv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let l=o.transaction(t,"readonly").objectStore(t).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},mn=async({databasePromise:e,objectStoreName:t,namespace:n,patch:o})=>{let a=await e;return new Promise((r,s)=>{let i=a.transaction(t,"readwrite"),l=i.objectStore(t),c=l.get(n),u=!1,p=f=>{u||(u=!0,s(f))},d=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let f=lf(c.result),m=typeof o=="function"?o(f):o,h={namespace:n,version:1,...af(),...f,...m},g=l.put(h);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},i.oncomplete=()=>{d()},i.onerror=()=>{p(i.error??new Error(`IndexedDB transaction failed while updating namespace "${n}".`))},i.onabort=()=>{p(i.error??new Error(`IndexedDB transaction aborted while updating namespace "${n}".`))}})},hv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let s=o.transaction(t,"readwrite"),l=s.objectStore(t).delete(n),c=!1,u=d=>{c||(c=!0,r(d))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{u(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{u(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},qa=(e={})=>{let{indexedDB:t,databaseName:n=nv,objectStoreName:o=sv,namespace:a}=e,r=dv(t),s=fv(a),i=mv({indexedDB:r,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await yv({databasePromise:i,objectStoreName:o,namespace:s});return{...af(),...lf(l)}},clear:async()=>hv({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>mn({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:be(l)?l:{}}}),saveGlobalDeviceVariables:async l=>mn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:be(l)?l:{}}}),saveGlobalAccountVariables:async l=>mn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:be(l)?l:{}}}),saveGlobalRuntime:async l=>mn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:be(l)?l:{}}}),applyScopedDataUpdates:async l=>mn({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>pv(c,l)})}},gv=qa;var If=vf;var bv={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ke=Object.prototype.hasOwnProperty,wv={anyOf:[{type:"null"},{type:"object",properties:{x:{type:"number",minimum:0},y:{type:"number",minimum:0},quality:{type:"number",minimum:1},kernelSize:{type:"integer",enum:[5,7,9,11,13,15]},repeatEdgePixels:{type:"boolean"}},required:["x","y"],additionalProperties:!1}]};function Fe(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e!==null){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[f]:r.push(f),s++}if(e.y===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[f]:r.push(f),s++}for(let f in e)if(!(f==="x"||f==="y"||f==="quality"||f==="kernelSize"||f==="repeatEdgePixels")){let m={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.x!==void 0){let f=e.x;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.y!==void 0){let f=e.y;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.quality!==void 0){let f=e.quality;if(typeof f=="number"){if(f<1||isNaN(f)){let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.kernelSize!==void 0){let f=e.kernelSize;if(!(typeof f=="number"&&!(f%1)&&!isNaN(f))){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[m]:r.push(m),s++}if(!(f===5||f===7||f===9||f===11||f===13||f===15)){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:wv.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[m]:r.push(m),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let f={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Fe.errors=r,s===0}var Oe=uf().default;function Rs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Rs.errors=r,s===0}function lr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)Rs(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Rs.errors:r.concat(Rs.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return lr.errors=r,s===0}var Iv={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Cs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="continuity"||i==="speed"||i==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.continuity!==void 0){let i=e.continuity;if(typeof i!="string"){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="render"||i==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Iv.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Cs.errors=r,s===0}function pe(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.playback!==void 0&&(Cs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pe.errors=r,s===0}function $s(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(bv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let i={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let i={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let i={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let i={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),e.filters!==void 0&&(lr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return $s.errors=r,s===0}function vf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return $s(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?$s.errors:r.concat($s.errors),s=r.length),vf.errors=r,s===0}var kf=Af;var pf={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},ff={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function _s(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="speed"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return _s.errors=r,s===0}function je(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}e.playback!==void 0&&(_s(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return je.errors=r,s===0}function js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(ff.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:ff.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return js.errors=r,s===0}function Ns(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var c=l===s;if(c){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=i,r!==null&&(i?r.length=i:r=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var d=p===s;if(d){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=u,r!==null&&(u?r.length=u:r=null);let f=s,m=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let w={};r===null?r=[w]:r.push(w),s++}}var g=h===s;if(s=f,r!==null&&(f?r.length=f:r=null),g){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[b]:r.push(b),s++}var g=y===s;m=g}if(!m){let y={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Ke.call(pf.properties,y)){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let b=0;b<w;b++)js(y[b],{instancePath:t+"/sounds/"+b,parentData:y,parentDataProperty:b,rootData:a})||(r=r===null?js.errors:r.concat(js.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:pf.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}e.audioEffects!==void 0&&(je(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Ns.errors=r,s===0}function Af(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ns(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length),Af.errors=r,s===0}var Pf=Ef;var vv={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ds(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],d=s,f=!0,m=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let h;if(p.sprites===void 0&&(h="sprites")){let g={};r===null?r=[g]:r.push(g),s++}}var i=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),i){let h=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};r===null?r=[y]:r.push(y),s++}var i=h===s;f=i}if(!f){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[h]:r.push(h),s++}for(let h in p)if(!Ke.call(vv.properties.items.items.properties,h)){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let h={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let h={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.x!==void 0&&typeof p.x!="number"){let h={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.y!==void 0&&typeof p.y!="number"){let h={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let h={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let h={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let h={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let h={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let h={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let h={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let h={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let h={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let h={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.alpha!==void 0){let h=p.alpha;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.opacity!==void 0){let h=p.opacity;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.blur!==void 0&&(Fe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),p.filters!==void 0&&(lr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),s=r.length)),p.sprites!==void 0){let h=p.sprites;if(Array.isArray(h)){let g=h.length;for(let y=0;y<g;y++){let w=h[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let b in w)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let A={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(w.id!==void 0&&typeof w.id!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}}}else{let g={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),s++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let c={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Ds.errors=r,s===0}function Ef(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ds(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length),Ef.errors=r,s===0}var xf=Sf;function Ts(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="items"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let d={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),s++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:t+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:t+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let d=p.click;if(!(d&&typeof d=="object"&&!Array.isArray(d))){let f={instancePath:t+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}}}else{let d={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let p={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ts.errors=r,s===0}function Sf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ts(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length),Sf.errors=r,s===0}var Of=Rf;function Ls(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let i={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ls.errors=r,s===0}function Rf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ls(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),s=r.length),Rf.errors=r,s===0}var Cf=$f;function Ms(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ms.errors=r,s===0}function $f(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ms(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),s=r.length),$f.errors=r,s===0}var _f=jf;var df={type:"object",properties:{ui:{type:"object",properties:{resourceId:{type:"string"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},mode:{type:"string",enum:["adv","nvl"]},content:{type:"array",items:{type:"object",properties:{text:{type:"string"}}}},textSpeed:{type:"number"},append:{type:"boolean"},characterId:{type:"string"},characterName:{type:"string"},persistCharacter:{type:"boolean"},persistSprite:{type:"boolean"},character:{type:"object",properties:{name:{type:"string"},sprite:{type:"object",properties:{transformId:{type:"string"},items:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},required:["id","resourceId"],additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1}},additionalProperties:!1},clear:{type:"boolean"},clearPage:{type:"boolean"}},additionalProperties:!1};function Vs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(df.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.ui!==void 0){let i=e.ui;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="resourceId"||l==="animations")){let c={instancePath:t+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.resourceId!==void 0&&typeof i.resourceId!="string"){let l={instancePath:t+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}i.animations!==void 0&&(pe(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let l={instancePath:t+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.mode!==void 0){let i=e.mode;if(typeof i!="string"){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="adv"||i==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:df.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.content!==void 0){let i=e.content;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:t+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}}else{let p={instancePath:t+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let i={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let i={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let i={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let i={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let i={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let i={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.character!==void 0){let i=e.character;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="name"||l==="sprite")){let c={instancePath:t+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.name!==void 0&&typeof i.name!="string"){let l={instancePath:t+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(i.sprite!==void 0){let l=i.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:t+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let d=c[p];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),s++}if(d.resourceId===void 0){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="resourceId"||f==="animationName"||f==="animationSpeed"||f==="loop")){let m={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(d.id!==void 0&&typeof d.id!="string"){let f={instancePath:t+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(d.resourceId!==void 0&&typeof d.resourceId!="string"){let f={instancePath:t+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(d.animationName!==void 0&&typeof d.animationName!="string"){let f={instancePath:t+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(d.animationSpeed!==void 0&&typeof d.animationSpeed!="number"){let f={instancePath:t+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:t+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}}}else{let u={instancePath:t+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[u]:r.push(u),s++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let c={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let i={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let i={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Vs.errors=r,s===0}function jf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Vs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length),jf.errors=r,s===0}var Nf=Df;function qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="id"||i==="resourceId"||i==="fields"||i==="submitActions"||i==="cancelActions"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let i={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fields!==void 0){let i=e.fields;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[p]:r.push(p),s++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.submitActions!==void 0){let i=e.submitActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.cancelActions!==void 0){let i=e.cancelActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return qs.errors=r,s===0}function Df(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return qs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),s=r.length),Df.errors=r,s===0}var Tf=Lf;function Fs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Fs.errors=r,s===0}function Lf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Fs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),s=r.length),Lf.errors=r,s===0}var Mf=Vf;function Bs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="alpha"||i==="opacity"||i==="blur"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Bs.errors=r,s===0}function Vf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Bs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length),Vf.errors=r,s===0}var qf=Ff;var mf={type:"object",properties:{items:{type:"array",items:{$ref:"#/definitions/audioSound"}},channels:{type:"array",items:{type:"object",properties:{id:{type:"string",minLength:1},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},applyMode:{type:"string",enum:["singleLine","persistent"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1},yf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function ar(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(yf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:yf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ar.errors=r,s===0}function Us(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};r===null?r=[p]:r.push(p),s++}}var c=l===s;if(c){let u={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),s++}else s=i,r!==null&&(i?r.length=i:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++)ar(u[d],{instancePath:t+"/items/"+d,parentData:u,parentDataProperty:d,rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),s=r.length)}else{let p={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++){let f=u[d];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[m]:r.push(m),s++}if(f.sounds===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[m]:r.push(m),s++}for(let m in f)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="applyMode"||m==="sounds")){let h={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(f.id!==void 0){let m=f.id;if(typeof m=="string"){if(Oe(m)<1){let h={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(f.volume!==void 0){let m=f.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let h={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),s++}if(m<0||isNaN(m)){let h={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(f.muted!==void 0&&typeof f.muted!="boolean"){let m={instancePath:t+"/channels/"+d+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(f.pan!==void 0){let m=f.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let h={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),s++}if(m<-1||isNaN(m)){let h={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(f.loop!==void 0&&typeof f.loop!="boolean"){let m={instancePath:t+"/channels/"+d+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(f.interruption!==void 0){let m=f.interruption;if(typeof m!="string"){let h={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(m==="immediate"||m==="loopEnd")){let h={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:mf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(f.applyMode!==void 0){let m=f.applyMode;if(typeof m!="string"){let h={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(m==="singleLine"||m==="persistent")){let h={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:mf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(f.sounds!==void 0){let m=f.sounds;if(Array.isArray(m)){let h=m.length;for(let g=0;g<h;g++)ar(m[g],{instancePath:t+"/channels/"+d+"/sounds/"+g,parentData:m,parentDataProperty:g,rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),s=r.length)}else{let h={instancePath:t+"/channels/"+d+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}}else{let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}return Us.errors=r,s===0}function Ff(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Us(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length),Ff.errors=r,s===0}var Bf=Uf;var hf={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ys(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(typeof e!="string"){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let f=e.length;for(let m=0;m<f;m++){let h=e[m];if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let g={instancePath:t+"/"+m+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let g={instancePath:t+"/"+m+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.furigana!==void 0){let g=h.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let y={instancePath:t+"/"+m+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let y={instancePath:t+"/"+m+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/"+m+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}}}else{let g={instancePath:t+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Ys.errors=r,s===0}function zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};r===null?r=[b]:r.push(b),s++}}var d=p===s;if(u=u||d,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.type===void 0&&(A="type")){let k={};r===null?r=[k]:r.push(k),s++}}var d=w===s;if(u=u||d,!u){let A=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.resourceId===void 0&&(E="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var d=A===s;if(u=u||d,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let L={};r===null?r=[L]:r.push(L),s++}}var d=E===s;if(u=u||d,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let D={};r===null?r=[D]:r.push(D),s++}}var d=O===s;if(u=u||d,!u){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.transform===void 0&&(B="transform")){let _={};r===null?r=[_]:r.push(_),s++}}var d=C===s;if(u=u||d,!u){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.x===void 0&&(G="x")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var d=B===s;if(u=u||d,!u){let G=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let K={};r===null?r=[K]:r.push(K),s++}}var d=G===s;if(u=u||d,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let X={};r===null?r=[X]:r.push(X),s++}}var d=M===s;if(u=u||d,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.anchorY===void 0&&(te="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),s++}}var d=le===s;if(u=u||d,!u){let te=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ne;if(e.scaleX===void 0&&(ne="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),s++}}var d=te===s;if(u=u||d,!u){let ne=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.scaleY===void 0&&(Z="scaleY")){let $={};r===null?r=[$]:r.push($),s++}}var d=ne===s;if(u=u||d,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.flipX===void 0&&(j="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var d=Z===s;if(u=u||d,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let J;if(e.flipY===void 0&&(J="flipY")){let de={};r===null?r=[de]:r.push(de),s++}}var d=j===s;if(u=u||d,!u){let J=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ie;if(e.rotation===void 0&&(Ie="rotation")){let we={};r===null?r=[we]:r.push(we),s++}}var d=J===s;if(u=u||d,!u){let Ie=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let dr={};r===null?r=[dr]:r.push(dr),s++}}var d=Ie===s;if(u=u||d,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let We;if(e.originY===void 0&&(We="originY")){let En={};r===null?r=[En]:r.push(En),s++}}var d=me===s;if(u=u||d,!u){let We=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Br;if(e.layer===void 0&&(Br="layer")){let Ur={};r===null?r=[Ur]:r.push(Ur),s++}}var d=We===s;if(u=u||d,!u){let Br=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ar;if(e.alpha===void 0&&(Ar="alpha")){let xn={};r===null?r=[xn]:r.push(xn),s++}}var d=Br===s;if(u=u||d,!u){let Ar=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let lt;if(e.opacity===void 0&&(lt="opacity")){let ct={};r===null?r=[ct]:r.push(ct),s++}}var d=Ar===s;if(u=u||d,!u){let lt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Yr;if(e.blur===void 0&&(Yr="blur")){let ut={};r===null?r=[ut]:r.push(ut),s++}}var d=lt===s;if(u=u||d,!u){let Yr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let jt;if(e.filters===void 0&&(jt="filters")){let Sn={};r===null?r=[Sn]:r.push(Sn),s++}}var d=Yr===s;if(u=u||d,!u){let jt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let On;if(e.animations===void 0&&(On="animations")){let Rn={};r===null?r=[Rn]:r.push(Rn),s++}}var d=jt===s;u=u||d}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var f=l===s;if(f){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=i,r!==null&&(i?r.length=i:r=null);let m=s,h=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var y=g===s;if(h=h||y,!h){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let A={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[A]:r.push(A),s++}var y=w===s;h=h||y}if(h)s=m,r!==null&&(m?r.length=m:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Ys(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return zs.errors=r,s===0}function Xs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="elements"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Xs.errors=r,s===0}var kv={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function Gs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(kv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Gs.errors=r,s===0}function Hs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let d={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let d=p.length;for(let f=0;f<d;f++){let m=p[f],h=s,g=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var i=g===s;if(i){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=h,r!==null&&(h?r.length=h:r=null);let y=s,w=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var l=w===s;if(l){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=y,r!==null&&(y?r.length=y:r=null);let b=s,A=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.text===void 0&&(v="text")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=A===s;if(c){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=b,r!==null&&(b?r.length=b:r=null);let k=s,E=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.transformId===void 0&&(v="transformId")||m.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=E===s;if(u){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),s++}for(let v in m)if(!Ke.call(hf.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),s++}if(m.id!==void 0&&typeof m.id!="string"){let v={instancePath:t+"/items/"+f+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let v={instancePath:t+"/items/"+f+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let v={instancePath:t+"/items/"+f+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let v={instancePath:t+"/items/"+f+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.text!==void 0&&(zs(m.text,{instancePath:t+"/items/"+f+"/text",parentData:m,parentDataProperty:"text",rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),s=r.length)),m.layout!==void 0&&(Xs(m.layout,{instancePath:t+"/items/"+f+"/layout",parentData:m,parentDataProperty:"layout",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),s=r.length)),m.transformId!==void 0&&typeof m.transformId!="string"){let v={instancePath:t+"/items/"+f+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(m.transform!==void 0&&(Gs(m.transform,{instancePath:t+"/items/"+f+"/transform",parentData:m,parentDataProperty:"transform",rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length)),m.x!==void 0&&typeof m.x!="number"){let v={instancePath:t+"/items/"+f+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.y!==void 0&&typeof m.y!="number"){let v={instancePath:t+"/items/"+f+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.anchorX!==void 0&&typeof m.anchorX!="number"){let v={instancePath:t+"/items/"+f+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.anchorY!==void 0&&typeof m.anchorY!="number"){let v={instancePath:t+"/items/"+f+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.scaleX!==void 0&&typeof m.scaleX!="number"){let v={instancePath:t+"/items/"+f+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.scaleY!==void 0&&typeof m.scaleY!="number"){let v={instancePath:t+"/items/"+f+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.flipX!==void 0&&typeof m.flipX!="boolean"){let v={instancePath:t+"/items/"+f+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(m.flipY!==void 0&&typeof m.flipY!="boolean"){let v={instancePath:t+"/items/"+f+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(m.rotation!==void 0&&typeof m.rotation!="number"){let v={instancePath:t+"/items/"+f+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.originX!==void 0&&typeof m.originX!="number"){let v={instancePath:t+"/items/"+f+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.originY!==void 0&&typeof m.originY!="number"){let v={instancePath:t+"/items/"+f+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(m.layer!==void 0){let v=m.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:hf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),s++}}if(m.alpha!==void 0){let v=m.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(m.opacity!==void 0){let v=m.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}m.blur!==void 0&&(Fe(m.blur,{instancePath:t+"/items/"+f+"/blur",parentData:m,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),m.filters!==void 0&&(lr(m.filters,{instancePath:t+"/items/"+f+"/filters",parentData:m,parentDataProperty:"filters",rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),s=r.length)),m.animations!==void 0&&(pe(m.animations,{instancePath:t+"/items/"+f+"/animations",parentData:m,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let d={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),s++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}return Hs.errors=r,s===0}function Uf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Hs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length),Uf.errors=r,s===0}var Yf=zf;var Av={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},resourceId:{type:"string"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},startDelayMs:{type:"number",minimum:0}},anyOf:[{required:["resourceId"]},{required:["sounds"]}],allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1};function Ks(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let y={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[y]:r.push(y),s++}var u=c===s;if(l=l||u,!l){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[b]:r.push(b),s++}var u=y===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let y={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[y]:r.push(y),s++}let p=s,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var f=d===s;if(f){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=p,r!==null&&(p?r.length=p:r=null);let m=s,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var g=h===s;if(g){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=m,r!==null&&(m?r.length=m:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!(y==="sounds"||y==="resourceId"||y==="volume"||y==="muted"||y==="pan"||y==="loop"||y==="interruption"||y==="startDelayMs")){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let b=0;b<w;b++)ar(y[b],{instancePath:t+"/sounds/"+b,parentData:y,parentDataProperty:b,rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Av.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Ks.errors=r,s===0}function zf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ks(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),s=r.length),zf.errors=r,s===0}var Xf=Gf;var Pv={type:"object",properties:{type:{type:"string",enum:["boolean","number"]},target:{type:"integer",minimum:1},name:{type:"string",minLength:1},description:{type:"string",minLength:1},lockedName:{type:"string",minLength:1},lockedDescription:{type:"string",minLength:1},hidden:{type:"boolean"}},required:["type","name","description"],allOf:[{if:{properties:{type:{const:"number"}}},then:{required:["target"]}},{if:{properties:{type:{const:"boolean"}}},then:{not:{required:["target"]}}}],additionalProperties:!1};function Ws(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let p=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};r===null?r=[g]:r.push(g),s++}var m=f===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let g=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.target===void 0&&(A="target")){let k={};r===null?r=[k]:r.push(k),s++}}var h=w===s;if(h){let A={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[A]:r.push(A),s++}else s=y,r!==null&&(y?r.length=y:r=null);var m=g===s;d=m}if(!d){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),s++}if(e.name===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[g]:r.push(g),s++}if(e.description===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let y={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(!(g==="boolean"||g==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Pv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[y]:r.push(y),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[y]:r.push(y),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if(Oe(g)<1){let y={instancePath:t+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if(Oe(g)<1){let y={instancePath:t+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if(Oe(g)<1){let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if(Oe(g)<1){let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return Ws.errors=r,s===0}function Gf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ws(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length),Gf.errors=r,s===0}var Hf=Kf;var Ev={type:"object",required:["type"],$defs:{keyframe:{type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}}},required:["keyframes"],additionalProperties:!1},updateTween:{type:"object",properties:{alpha:{$ref:"#/$defs/tweenProperty"},x:{$ref:"#/$defs/tweenProperty"},y:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionTween:{type:"object",properties:{translateX:{$ref:"#/$defs/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},alpha:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/tweenProperty"},compositeMaskItem:{type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1},mask:{type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]}},properties:{name:{type:"string"},type:{type:"string",enum:["update","transition"]},complete:{type:"object",properties:{payload:{type:"object"}},additionalProperties:!0},tween:{$ref:"#/$defs/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"},mask:{$ref:"#/$defs/mask"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{not:{required:["tween"]},anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/animationResource.yaml"};var xv={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1};function ot(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="value"||i==="duration"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let i={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let i={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.easing!==void 0){let i=e.easing;if(typeof i!="string"){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="linear"||i==="easeInQuad"||i==="easeOutQuad"||i==="easeInOutQuad"||i==="easeInCubic"||i==="easeOutCubic"||i==="easeInOutCubic"||i==="easeInQuart"||i==="easeOutQuart"||i==="easeInOutQuart"||i==="easeInQuint"||i==="easeOutQuint"||i==="easeInOutQuint"||i==="easeInSine"||i==="easeOutSine"||i==="easeInOutSine"||i==="easeInExpo"||i==="easeOutExpo"||i==="easeInOutExpo"||i==="easeInCirc"||i==="easeOutCirc"||i==="easeInOutCirc"||i==="easeInBack"||i==="easeOutBack"||i==="easeInOutBack"||i==="easeInBounce"||i==="easeOutBounce"||i==="easeInOutBounce"||i==="easeInElastic"||i==="easeOutElastic"||i==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:xv.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ot.errors=r,s===0}function re(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ot(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return re.errors=r,s===0}function Js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="alpha"||i==="x"||i==="y"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Js.errors=r,s===0}function Qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="translateX"||i==="translateY"||i==="alpha"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.translateX!==void 0&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Qs.errors=r,s===0}function it(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.tween!==void 0&&(Qs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return it.errors=r,s===0}var Os={type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]},Sv={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function Zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="texture"||i==="channel"||i==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let i={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.channel!==void 0){let i=e.channel;if(typeof i!="string"){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Sv.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let i={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Zs.errors=r,s===0}function ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ot(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ei.errors=r,s===0}function ri(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let p=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let b={};r===null?r=[b]:r.push(b),s++}var m=f===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let k={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[k]:r.push(k),s++}var m=b===s;d=m}if(!d){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let h=s,g=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let b={};r===null?r=[b]:r.push(b),s++}var w=y===s;if(s=h,r!==null&&(h?r.length=h:r=null),w){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[k]:r.push(k),s++}var w=b===s;g=w}if(!g){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!Ke.call(Os.properties,b)){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Os.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let b={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.textures!==void 0){let b=e.textures;if(Array.isArray(b)){if(b.length<1){let k={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=b.length;for(let k=0;k<A;k++)if(typeof b[k]!="string"){let E={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}}else{let A={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.items!==void 0){let b=e.items;if(Array.isArray(b)){if(b.length<1){let k={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=b.length;for(let k=0;k<A;k++)Zs(b[k],{instancePath:t+"/items/"+k,parentData:b,parentDataProperty:k,rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length)}else{let A={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Os.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Os.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let b={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let b={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let b={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}e.progress!==void 0&&(ei(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return ri.errors=r,s===0}function ti(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.prev===void 0&&(C="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=C===s;if(v=v||p,!v){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var p=B===s;v=v||p}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={};r===null?r=[C]:r.push(C),s++}var d=k===s;if(d){let C={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let C={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[C]:r.push(C),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let f=s,m=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};r===null?r=[b]:r.push(b),s++}var g=h===s;if(s=f,r!==null&&(f?r.length=f:r=null),g){let b=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.tween===void 0&&(C="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===s;if(y){let C={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[C]:r.push(C),s++}var w=O===s;if(v=v||w,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),s++}var w=C===s;if(v=v||w,!v){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[G]:r.push(G),s++}var w=B===s;v=v||w}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[C]:r.push(C),s++}var g=b===s;m=g}if(!m){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="complete"||b==="tween"||b==="prev"||b==="next"||b==="mask")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.type!==void 0){let b=e.type;if(typeof b!="string"){let A={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="update"||b==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Ev.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let A=b.payload;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let k={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let A={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(Js(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),s=r.length)),e.prev!==void 0&&(it(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?it.errors:r.concat(it.errors),s=r.length)),e.next!==void 0&&(it(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?it.errors:r.concat(it.errors),s=r.length)),e.mask!==void 0&&(ri(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return ti.errors=r,s===0}function Kf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ti(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),s=r.length),Kf.errors=r,s===0}var Wf=Jf;var Ov={type:"object",required:["type"],$defs:{easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},propertyTracks:{type:"object",minProperties:1,properties:{volume:{$ref:"#/$defs/volumeTweenProperty"},pan:{$ref:"#/$defs/panTweenProperty"},playbackRate:{$ref:"#/$defs/playbackRateTweenProperty"}},additionalProperties:!1}},properties:{name:{type:"string"},type:{enum:["update","transition"]},tween:{$ref:"#/$defs/propertyTracks"},prev:{$ref:"#/$defs/propertyTracks"},next:{$ref:"#/$defs/propertyTracks"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{anyOf:[{required:["prev"]},{required:["next"]}],not:{required:["tween"]}}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/audioEffectResource.yaml"};function ni(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="number"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}return ni.errors=r,s===0}var Rv={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="string"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let i={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Rv.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),s++}return si.errors=r,s===0}function cr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="startValue"||i==="value"||i==="duration"||i==="delay"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let i={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.value!==void 0&&(ni(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),s=r.length)),e.duration!==void 0){let i=e.duration;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.delay!==void 0){let i=e.delay;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.easing!==void 0&&(si(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),s=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return cr.errors=r,s===0}function ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;cr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>100||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(w<0||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>100||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(w<0||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}}var h=g===s;f=h}if(!f){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return ii.errors=r,s===0}function oi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ii(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return oi.errors=r,s===0}function ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;cr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>1||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(w<-1||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>1||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(w<-1||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}}var h=g===s;f=h}if(!f){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return ai.errors=r,s===0}function li(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ai(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return li.errors=r,s===0}function ci(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;cr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"&&(w<0||isNaN(w))){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let d=s,f=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=m===s;if(s=d,r!==null&&(d?r.length=d:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"&&(w<0||isNaN(w))){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}var h=g===s;f=h}if(!f){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return ci.errors=r,s===0}function ui(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ci(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ui.errors=r,s===0}function or(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="volume"||i==="pan"||i==="playbackRate")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.volume!==void 0&&(oi(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),s=r.length)),e.pan!==void 0&&(li(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?li.errors:r.concat(li.errors),s=r.length)),e.playbackRate!==void 0&&(ui(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return or.errors=r,s===0}function pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.prev===void 0&&(C="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=C===s;v=v||p}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={};r===null?r=[C]:r.push(C),s++}var d=k===s;if(d){let C={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let C={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[C]:r.push(C),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let f=s,m=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};r===null?r=[b]:r.push(b),s++}var g=h===s;if(s=f,r!==null&&(f?r.length=f:r=null),g){let b=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.tween===void 0&&(C="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===s;if(y){let C={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[C]:r.push(C),s++}var w=O===s;if(v=v||w,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),s++}var w=C===s;v=v||w}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[C]:r.push(C),s++}var g=b===s;m=g}if(!m){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="tween"||b==="prev"||b==="next")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.type!==void 0){let b=e.type;if(!(b==="update"||b==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Ov.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(or(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?or.errors:r.concat(or.errors),s=r.length)),e.prev!==void 0&&(or(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?or.errors:r.concat(or.errors),s=r.length)),e.next!==void 0&&(or(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?or.errors:r.concat(or.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return pi.errors=r,s===0}function Jf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return pi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),s=r.length),Jf.errors=r,s===0}var Qf=Zf;function fi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="name"||i==="nameVariableId")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let i={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return fi.errors=r,s===0}function Zf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return fi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length),Zf.errors=r,s===0}var ed=rd;var Cv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function di(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!Cv.test(i)){let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return di.errors=r,s===0}function rd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return di(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),s=r.length),rd.errors=r,s===0}var td=nd;function mi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let i=e.keyboard;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let d={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let d={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.keyup!==void 0){let i=e.keyup;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return mi.errors=r,s===0}function nd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return mi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),s=r.length),nd.errors=r,s===0}var sd=id;function yi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return yi.errors=r,s===0}function id(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return yi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),s=r.length),id.errors=r,s===0}var od=ad;function hi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return hi.errors=r,s===0}function ad(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return hi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),s=r.length),ad.errors=r,s===0}var ld=cd;function gi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return gi.errors=r,s===0}var gf=new RegExp("^\\$(if .+|for .+|else)$","u"),Ba={validate:yn};function bi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!gf.test(i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}for(let i in e)if(gf.test(i)){let l=e[i];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)Ba.validate(l[u],{instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?Ba.validate.errors:r.concat(Ba.validate.errors),s=r.length)}else{let c={instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return bi.errors=r,s===0}function yn(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;gi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;bi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length);var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return yn.errors=r,s===0}function wi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)yn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?yn.errors:r.concat(yn.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return wi.errors=r,s===0}var Ua={validate:hn};function hn(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(wi(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length)),e.children!==void 0){let i=e.children;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)Ua.validate(i[c],{instancePath:t+"/children/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Ua.validate.errors:r.concat(Ua.validate.errors),s=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return hn.errors=r,s===0}function Ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)hn(i[c],{instancePath:t+"/elements/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?hn.errors:r.concat(hn.errors),s=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.transitions!==void 0){let i={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ii.errors=r,s===0}function cd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ii(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length),cd.errors=r,s===0}var ud=pd;function vi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=null,u=s,p=s,d=s,f=s,m=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let E={};r===null?r=[E]:r.push(E),s++}}var g=h===s;if(m=m||g,!m){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.texture===void 0&&(v="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var g=k===s;if(m=m||g,!m){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.behaviors===void 0&&(L="behaviors")){let C={};r===null?r=[C]:r.push(C),s++}}var g=v===s;if(m=m||g,!m){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.emitter===void 0&&(D="emitter")){let B={};r===null?r=[B]:r.push(B),s++}}var g=L===s;m=m||g}}}if(m)s=f,r!==null&&(f?r.length=f:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=d===s;if(y){let k={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[k]:r.push(k),s++}else s=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let k={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[k]:r.push(k),s++}var b=u===s;b&&(l=!0,c=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}if(e.behaviors===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[k]:r.push(k),s++}if(e.emitter===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[k]:r.push(k),s++}}var b=w===s;if(b&&l?(l=!1,c=[c,1]):b&&(l=!0,c=1),l)s=i,r!==null&&(i?r.length=i:r=null);else{let k={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[k]:r.push(k),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[k]:r.push(k),s++}if(e.height===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[k]:r.push(k),s++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[E]:r.push(E),s++}if(k.appearance===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[E]:r.push(E),s++}for(let E in k)if(!(E==="emission"||E==="movement"||E==="appearance"||E==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let E=k.emission;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.movement!==void 0){let E=k.movement;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.appearance!==void 0){let E=k.appearance;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.bounds!==void 0){let E=k.bounds;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[E]:r.push(E),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0){let k=e.texture,E=s,v=!1,O=null,L=s;if(typeof k=="string"){if(Oe(k)<1){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[D]:r.push(D),s++}}else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[D]:r.push(D),s++}var A=L===s;A&&(v=!0,O=0);let C=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),s++}var A=C===s;if(A&&v?(v=!1,O=[O,1]):A&&(v=!0,O=1),v)s=E,r!==null&&(E?r.length=E:r=null);else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[D]:r.push(D),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let v={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let E=k.length;for(let v=0;v<E;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[L]:r.push(L),s++}for(let L in O)if(!(L==="type"||L==="config")){let C={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"};r===null?r=[C]:r.push(C),s++}if(O.type!==void 0){let L=O.type;if(typeof L=="string"){if(Oe(L)<1){let C={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[C]:r.push(C),s++}}else{let C={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[C]:r.push(C),s++}}if(O.config!==void 0){let L=O.config;if(!(L&&typeof L=="object"&&!Array.isArray(L))){let C={instancePath:t+"/behaviors/"+v+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[C]:r.push(C),s++}}}else{let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),s++}}}else{let E={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[E]:r.push(E),s++}if(k.lifetime!==void 0){let E=k.lifetime;if(E&&typeof E=="object"&&!Array.isArray(E)){if(E.min===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),s++}if(E.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),s++}if(E.min!==void 0){let v=E.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(E.max!==void 0){let v=E.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}}else{let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}return vi.errors=r,s===0}function pd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return vi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),s=r.length),pd.errors=r,s===0}var fd=dd;var bf={type:"object",properties:{fileId:{type:"string"},fileType:{type:"string"},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["fileId"],additionalProperties:!1};function ki(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(bf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:bf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ki.errors=r,s===0}function dd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ki(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),s=r.length),dd.errors=r,s===0}var md=yd;var $v=new RegExp("^.+$","u");function Ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.jsonData===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="jsonData"||i==="width"||i==="height"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.jsonData!==void 0){let i=e.jsonData;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if($v.test(l)){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++)if(typeof u[d]!="number"){let f={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}else{let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}}else{let l={instancePath:t+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ai.errors=r,s===0}function yd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ai(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),s=r.length),yd.errors=r,s===0}var hd=gd;var wf={type:"object",properties:{fontId:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1}}]},colorId:{type:"string"},colorAlpha:{type:"number"},fontSize:{type:"number"},fontWeight:{type:"string"},fontStyle:{type:"string",enum:["normal","italic","oblique"]},lineHeight:{type:"number"},align:{type:"string"},wordWrap:{type:"boolean"},breakWords:{type:"boolean"},wordWrapWidth:{type:"number"},strokeColorId:{type:"string"},strokeAlpha:{type:"number"},strokeWidth:{type:"number"},shadow:{type:"object",properties:{colorId:{type:"string",minLength:1},alpha:{type:"number",minimum:0,maximum:1},blur:{type:"number",minimum:0},offsetX:{type:"number"},offsetY:{type:"number"}},required:["colorId"],additionalProperties:!1}},required:["fontId","fontSize","fontWeight","fontStyle","lineHeight","colorId"],additionalProperties:!1};function Pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};r===null?r=[l]:r.push(l),s++}if(e.fontSize===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};r===null?r=[l]:r.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};r===null?r=[l]:r.push(l),s++}if(e.colorId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[l]:r.push(l),s++}for(let l in e)if(!Ke.call(wf.properties,l)){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,d=s;if(typeof l=="string"){if(Oe(l)<1){let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[m]:r.push(m),s++}var i=d===s;i&&(u=!0,p=0);let f=s;if(Array.isArray(l)){if(l.length<1){let y={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[y]:r.push(y),s++}let m=l.length;for(let y=0;y<m;y++){let w=l[y];if(typeof w=="string"){if(Oe(w)<1){let b={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}}let h=l.length,g;if(h>1){let y={};for(;h--;){let w=l[h];if(typeof w=="string"){if(typeof y[w]=="number"){g=y[w];let b={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:h,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+h+" are identical)"};r===null?r=[b]:r.push(b),s++;break}y[w]=h}}}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}var i=f===s;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)s=c,r!==null&&(c?r.length=c:r=null);else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[m]:r.push(m),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:t+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:t+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight!==void 0&&typeof e.fontWeight!="string"){let l={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:wf.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Oe(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Pi.errors=r,s===0}function gd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Pi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),s=r.length),gd.errors=r,s===0}var bd=wd;var _v={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function Ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(_v.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0){let i=e.x;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.y!==void 0){let i=e.y;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ei.errors=r,s===0}function wd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ei(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),s=r.length),wd.errors=r,s===0}var Id=vd;function xi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return xi.errors=r,s===0}function vd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return xi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),s=r.length),vd.errors=r,s===0}var wn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),bn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),kr=e=>e===void 0?void 0:structuredClone(e),jv=Object.freeze({achievement:"achievements",animation:"animations",audioEffect:"audioEffects",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),Nv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Dv=Object.freeze({background:If,bgm:kf,character:Pf,choice:xf,cleanAll:Of,control:Cf,dialogue:_f,form:Nf,layout:Tf,screen:Mf,sfx:qf,visual:Bf,voice:Yf}),Tv=Object.freeze({achievement:Xf,animation:Hf,audioEffect:Wf,character:Qf,color:ed,control:td,font:sd,image:od,layout:ld,particle:ud,sound:fd,spritesheet:md,textStyle:hd,transform:bd,video:Id}),Lv=new Set(["files","language","patches"]),Mv=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Vv=new Set(["lineId","mode","payload","type"]),qv=new Set(["mode","payload","sceneId","type"]),Fv=new Set(["mode","operation","payload","resourceId","type"]),Bv=new Set(["fileId","mimeType"]),H=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},rr=(e,t)=>{bn(e)||H(t,"expected an object")},Ya=(e,t)=>{Array.isArray(e)||H(t,"expected an array")},$t=(e,t)=>{(typeof e!="string"||e.length===0)&&H(t,"expected a non-empty string")},Ed=(e,t)=>{typeof e!="string"&&H(t,"expected a string")},pr=(e,t,n)=>{for(let o of Object.keys(e))t.has(o)||H(`${n}.${o}`,"unknown field")},fr=(e,t,n)=>{for(let o of t)wn(e,o)||H(n,`missing required field "${o}"`)},Uv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),Yv=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(Uv);return t?.keyword==="required"?n.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&n.push(t.params.additionalProperty),n.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},zv=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,n)=>{if(t===void 0)return n;let o=n.instancePath.split("/").length,a=t.instancePath.split("/").length;return o>a?n:t},void 0)??e[0],xd=({value:e,validator:t,path:n,contract:o})=>{if(t(e))return;let a=zv(t.errors);H(Yv(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Si=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||H(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,a)=>Si(o,`${t}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>Si(a,`${t}.${o}`,n))}},ur=(e,t)=>{e===""&&H(t,"expected a non-empty resourceId")},Xv=(e,t,n)=>{let o=(s,i)=>ur(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>ur(l?.resourceId,`${i}[${c}].resourceId`)),r=(s,i)=>{ur(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":ur(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"bgm":o(t.audioEffects,`${n}.audioEffects`),r(t,n);break;case"voice":r(t,n);break;case"sfx":a(t.items,`${n}.items`),(t.channels??[]).forEach((s,i)=>a(s?.sounds,`${n}.channels[${i}].sounds`));break;case"character":(t.items??[]).forEach((s,i)=>{(s.sprites??[]).forEach((l,c)=>ur(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":ur(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"control":ur(t.resourceId,`${n}.resourceId`);break;case"dialogue":ur(t.ui?.resourceId,`${n}.ui.resourceId`),o(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,i)=>ur(s?.resourceId,`${n}.character.sprite.items[${i}].resourceId`)),o(t.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(t.animations,`${n}.animations`);break;case"visual":(t.items??[]).forEach((s,i)=>{ur(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},_t=(e,t)=>{$t(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&H(t,`"${e}" is not a safe ID`)},Gv=(e,t)=>{$t(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&H(t,"must be a safe single filename")},gn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((a,r)=>gn(a,t[r]));if(!bn(e)||!bn(t))return!1;let n=Object.keys(e).sort(),o=Object.keys(t).sort();return gn(n,o)&&n.every(a=>gn(e[a],t[a]))},Oi=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>Oi(o,t,n)),t;if(!bn(e)||n.has(e))return t;n.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&t.add(a),Oi(a,t,n);return t},Hv=e=>{let t=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(o?.sections??{}))for(let[s,i]of(r?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=t.get(i.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:i}),t.set(i.id,l)}return t},Sd=(e,t,n)=>{let o=e.get(t)??[];return o.length===0&&H(n,`lineId "${t}" does not exist in projectData`),o.length>1&&H(n,`lineId "${t}" is not globally unique in projectData`),o[0]},Od=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],kd=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Ad=e=>{let t=kr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))bn(n)&&delete n.placeholder;return t},Kv=(e,t,n,o)=>{e==="choice"&&!gn(kd(t),kd(n))&&H(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!gn(Ad(t),Ad(n))&&H(o,"form behavior must remain identical; only presentation fields and placeholders may change")},Wv=({patch:e,path:t,lineIndex:n})=>{pr(e,Mv,t),fr(e,["type","lineId","actionType","payload"],t),_t(e.lineId,`${t}.lineId`),$t(e.actionType,`${t}.actionType`),rr(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.action supports only "replace"'),Nv.has(e.actionType)||H(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=Sd(n,e.lineId,`${t}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&H(`${t}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&H(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),wn(e.payload,"content")&&H(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&H(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),Kv(e.actionType,a,e.payload,`${t}.payload`),xd({value:e.payload,validator:Dv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Si(e.payload,`${t}.payload`),Xv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},Jv=(e,t)=>{Ya(e,t),e.forEach((n,o)=>{rr(n,`${t}[${o}]`),pr(n,new Set(["text"]),`${t}[${o}]`),fr(n,["text"],`${t}[${o}]`),Ed(n.text,`${t}[${o}].text`)})},Qv=({patch:e,path:t,lineIndex:n})=>{pr(e,Vv,t),fr(e,["type","lineId","payload"],t),_t(e.lineId,`${t}.lineId`),rr(e.payload,`${t}.payload`),pr(e.payload,new Set(["content"]),`${t}.payload`),fr(e.payload,["content"],`${t}.payload`),Jv(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.dialogue supports only "replace"');let o=Sd(n,e.lineId,`${t}.lineId`);return o.line?.actions?.dialogue===void 0&&H(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},Zv=({patch:e,path:t,projectData:n})=>(pr(e,qv,t),fr(e,["type","mode","sceneId","payload"],t),_t(e.sceneId,`${t}.sceneId`),rr(e.payload,`${t}.payload`),pr(e.payload,new Set(["name"]),`${t}.payload`),fr(e.payload,["name"],`${t}.payload`),Ed(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&H(`${t}.mode`,'story.scene requires "patch"'),wn(n?.story?.scenes??{},e.sceneId)||H(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),ek=(e,t,n)=>{rr(t,n),["font","image","sound","spritesheet","video"].includes(e)&&$t(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="spritesheet"&&(rr(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&H(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),xd({value:t,validator:Tv[e],path:n,contract:`the resource.${e} schema`}),Si(t,n)},rk=({patch:e,path:t,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{pr(e,Fv,t),fr(e,["type","resourceId","payload"],t),_t(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=jv[r];s||H(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&H(`${t}.operation`,'the only resource operation is "add"'),ek(r,e.payload,`${t}.payload`);let i=n?.resources?.[s]??{},l=wn(i,e.resourceId);e.operation==="add"&&l&&H(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&H(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of Oi(e.payload))!o.has(c)&&!a.has(c)&&H(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:t,patch:e}},Pd=({resources:e,collectionName:t,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!wn(e?.[t]??{},n))&&H(o,`${a} resource "${n}" was not found`)},tk=(e,t)=>{let n=kr(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=kr(a.patch.payload));let o=n.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,s=Array.isArray(r.fontId)?r.fontId:[r.fontId];s.forEach((i,l)=>Pd({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])Pd({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},nk=({patch:e,path:t,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(rr(e,t),$t(e.type,`${t}.type`),e.type==="line.action")return Wv({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return Qv({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return Zv({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return rk({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});H(`${t}.type`,`unsupported patch type "${e.type}"`)},sk=(e,t)=>{Ya(e,t);let n=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;rr(o,r),pr(o,Bv,r),fr(o,["fileId"],r),Gv(o.fileId,`${r}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&H(`${r}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&H(`${r}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},ik=({packageId:e,packageData:t,path:n,projectData:o,lineIndex:a,canonicalFileIds:r})=>{rr(t,n),pr(t,Lv,n),fr(t,["language","files","patches"],n),$t(t.language,`${n}.language`);let s=sk(t.files,`${n}.files`);Ya(t.patches,`${n}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=nk({patch:c,path:`${n}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return i.has(p.key)&&H(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},Rd=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};rr(t,"l10nData"),pr(t,new Set(["packages"]),"l10nData"),fr(t,["packages"],"l10nData"),rr(t.packages,"l10nData.packages");let n=Hv(e),o=Oi(e?.resources??{}),a=new Map,r=new Map;for(let[s,i]of Object.entries(t.packages)){_t(s,`l10nData.packages.${s}`);let l=ik({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&H(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&H(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}tk(e,l),a.set(s,l)}return{packages:a}},ok=(e,t)=>{let{collectionName:n,patch:o}=t;e.resources[n]??={},e.resources[n][o.resourceId]=kr(o.payload)},ak=(e,t)=>{let{patch:n}=t,o=e.story.scenes[n.sceneId];o.name=n.payload.name},lk=(e,t)=>{let{location:n,patch:o}=t,a=Od(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=kr(o.payload);return}let r=kr(n.line.actions.dialogue.content);a.actions.dialogue=kr(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},ck=(e,t)=>{let{location:n,patch:o}=t,a=Od(e,n);a.actions.dialogue.content=kr(o.payload.content)},Cd=({projectData:e,l10nData:t})=>{let n=Rd({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},Ri=({projectData:e,l10nData:t,l10nId:n=null})=>{let o=Rd({projectData:e,l10nData:t});if(n!==null&&(_t(n,"l10nId"),o.packages.has(n)||H("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=kr(e),r=o.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>ok(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>ak(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>lk(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>ck(a,s)),a};var za=Object.freeze({auto:1e3,skip:80,authored:1e3}),kn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),$d=new WeakMap,uk=new ArrayBuffer(8),Xa=new DataView(uk),pk=e=>{let t=$d.get(e);if(t)return t;let n={dispatchDepth:0};return $d.set(e,n),n},fk=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},dk=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Fr=(e,t,n)=>{if(!fk(e)||!dk(e,t))throw new TypeError(`${n} has an invalid shape`)},In=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},vn=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},_d=e=>{if(vn(e,"duration"),e===0)return 0n;Xa.setFloat64(0,e,!1);let t=Xa.getUint32(0,!1),n=Xa.getUint32(4,!1),o=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(n);if(o===0)return a;let r=1n<<52n|a,s=o-1;return r<<BigInt(s)},mk=e=>structuredClone(e),Ga=(e,t)=>e===t?!0:!e||!t||e.mode!==t.mode||e.kind!==t.kind?!1:e.mode==="legacy"?e.instanceToken===t.instanceToken:e.delayMs!==t.delayMs?!1:e.kind==="auto"?e.contentKey===t.contentKey&&e.owner.sessionId===t.owner.sessionId&&e.owner.lineEntryId===t.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===t.owner.sessionId:e.trigger===t.trigger&&e.owner.lineEntryId===t.owner.lineEntryId,Ha=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(Fr(t,["owner","delayMs","contentKey"],"auto timer"),Fr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),In(t.owner.sessionId,"auto owner sessionId"),In(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(vn(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Fr(t,["owner","delayMs"],"skip timer"),Fr(t.owner,["sessionId"],"skip timer owner"),In(t.owner.sessionId,"skip owner sessionId"),vn(t.delayMs,"skip delayMs");else{if(Fr(t,["owner","delayMs","trigger"],"authored timer"),Fr(t.owner,["lineEntryId"],"authored timer owner"),In(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(vn(t.delayMs,"authored delayMs"),t.trigger!=="fromStart"&&t.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...mk(t)}},yk=e=>{if(Fr(e,["contractVersion","status","lineEntryId","timers"],"playback schedule"),e.contractVersion!==1)throw new TypeError("playback schedule contractVersion must be 1");if(e.status!=="settled"&&e.status!=="unsettled")throw new TypeError('playback schedule status must be "settled" or "unsettled"');if(In(e.lineEntryId,"playback schedule lineEntryId"),e.status==="unsettled"){if(e.timers!==null)throw new TypeError("unsettled playback schedule timers must be null");return{contractVersion:1,status:"unsettled",lineEntryId:e.lineEntryId,timers:null}}Fr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:Ha("auto",e.timers.auto,e.lineEntryId),skip:Ha("skip",e.timers.skip,e.lineEntryId),authored:Ha("authored",e.timers.authored,e.lineEntryId)};if(t.auto&&t.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:t}},Ka=e=>({descriptor:e,remainingQuanta:_d(e.delayMs)}),Ci=["auto","skip","authored"],jd=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof t!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let o=pk(e),a=!0,r={},s={},i=null,l=null,c=null,u=null,p=!1,d=!1,f="legacy",m={auto:null,skip:null,authored:null},h={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},y=()=>Ci.some(M=>m[M]),w=()=>{l=null,c=null},b=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||d){b();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},A=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=i;M&&(w(),i=null,u=M,e.remove(M),u===M&&(u=null))},E=()=>{m={auto:null,skip:null,authored:null}},v=()=>{E(),s={},d||k()},O=M=>{if(o.dispatchDepth>0||d){c=M,b();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},L=()=>{if(!a||!y()||i)return;A();let M=r,K=s,le={},X=oe=>{if(!a||M!==r||K!==s||le!==l||X!==i||d)return;if(!oe||typeof oe.deltaMS!="number"||!Number.isFinite(oe.deltaMS)||oe.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let ne=_d(oe.deltaMS);d=!0,o.dispatchDepth+=1;let ue=s,Z=null;try{let $=[];for(let j of Ci){let F=m[j];F&&(F.remainingQuanta<=ne?($.push({kind:j,descriptor:F.descriptor,revision:g[j]}),m[j]=null):F.remainingQuanta-=ne)}if($.length>0){try{t({dueKinds:$.map(({kind:j})=>j)})}catch(j){let F=n(j);if(f==="reconciled"&&F==="preCommit")for(let{kind:J,descriptor:de}of $)h[J]=de;else f==="legacy"&&E();throw j}if(f==="legacy")for(let j of $)j.kind==="skip"&&g.skip===j.revision&&m.skip===null&&(m.skip=Ka(j.descriptor))}}catch($){Z=$}finally{o.dispatchDepth-=1,d=!1;try{ue===s?y()?L():k():i===X&&!y()&&k()}catch($){throw Z?new AggregateError([Z,$],"Playback attempt and ticker cleanup both failed"):$}}if(Z)throw Z},te={callback:X,lifecycleToken:M,generationToken:K,registrationToken:le};i=X,c=te;try{e.add(X)}catch(oe){throw i=null,w(),E(),s={},u=X,oe}O(te)},C=M=>{g[M]+=1,m[M]=null,h[M]=null,!y()&&!d&&k()},D=(M,K)=>{vn(K,`${M} delay`),f="legacy",g[M]+=1,h[M]=null,m[M]=Ka({mode:"legacy",kind:M,instanceToken:{},delayMs:K}),L()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return D("auto",M.payload?.delay??za.auto),!0;case"clearAutoNextTimer":return C("auto"),!0;case"startSkipNextTimer":return D("skip",M.payload?.delay??za.skip),!0;case"clearSkipNextTimer":return C("skip"),!0;case"nextLineConfigTimer":return D("authored",M.payload?.delay??za.authored),!0;case"clearNextLineConfigTimer":return C("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let K;try{K=yk(M)}catch(X){try{v()}catch(te){throw new AggregateError([X,te],"Playback schedule validation and cleanup both failed")}throw X}if(f="reconciled",K.status==="unsettled"){E(),d||k();return}let le={};for(let X of Ci){let te=K.timers[X],oe=h[X];if(oe&&(!te||!Ga(oe,te))&&(h[X]=null),te&&h[X]&&Ga(h[X],te)){le[X]=null;continue}let ne=m[X];le[X]=te&&ne&&Ga(ne.descriptor,te)?ne:te?Ka(te):null}m=le,y()?L():d||k()},reset:()=>{let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);r={},s={},w(),i=null,u=null,E(),h={auto:null,skip:null,authored:null};for(let X of Ci)g[X]+=1;f="legacy",a=!0;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K},dispose:()=>{a=!1,r={},s={},w(),E(),h={auto:null,skip:null,authored:null};let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);i=null,u=null;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K}}};var hk=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),gk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Wa="conditional",An="random",Qa=Symbol("conditionalAutoContinue"),bk=new Set(["sectionTransition","resetStoryAtSection"]),wk=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),Ik=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),vk=new Set(["nextLine","nextLineFromSystem"]),kk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ja="form",Ak=new Set(["submitForm","cancelForm"]),Pk="showImageGalleryVariant",Ek="playMusicRoomTrack",xk="startSceneReplay",Sk="channel:bgm",Ok=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Be=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Rk=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,Pn=e=>e?.type===Qa,at=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Ck=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function Za(e){let t=Rk(),n,o=0,a=!1,r=0,s=null,i=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,h=new Map,g=0,y=[],w=[],b=!1,A=null,k=null,E=null,v=null,O=new Map,L,C,D=null,B=!1,_=!1,G=0,fe=new Map,M=cc(e.randomSource),{handlePendingEffects:K}=e;if(typeof K!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=K.bind(K),X=typeof K.reconcilePlaybackScheduleV1=="function"?K.reconcilePlaybackScheduleV1.bind(K):null,te=typeof K.reset=="function"?K.reset.bind(K):null,oe=typeof K.dispose=="function"?K.dispose.bind(K):null;if(X&&(!te||!oe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let ne=I=>{if(_)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ue=I=>{if(ne(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},Z=(I,P)=>{if(G===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=fe.get(I);(R===void 0||S[P]>S[R])&&fe.set(I,P)},$=I=>{let P=fe.get(I)??"preCommit";return fe.delete(I),P},j=I=>{if(X){_=!0;try{let P=X(structuredClone(I));if(P!==null&&(typeof P=="object"||typeof P=="function")&&typeof P.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{_=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),J=I=>{if(!(!X||!a||!n)){B=!0;try{j(F())}catch(P){if(I){let S=new AggregateError([I,P],"Playback work and schedule invalidation both failed");throw fe.delete(I),Z(S,"reconcileFailed"),S}throw Z(P,"reconcileFailed"),P}}},de=()=>{if(!X||!B||!a||!n||i>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(P){throw Z(P,"reconcileFailed"),J(P),P}try{j({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(P){throw Z(P,"reconcileFailed"),J(P),P}B=!1},Ie=(I=new Map,P=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>P<S.expiresAt).map(([S,R])=>[S,{animation:structuredClone(R.animation),startedAt:R.startedAt,expiresAt:R.expiresAt}])),we=(I=new Map)=>Array.from(I.values()).map(P=>structuredClone(P.animation)),me=(I=Date.now())=>{f=new Map(Array.from(f.entries()).filter(([,P])=>I<P.expiresAt))},dr=()=>{if(a&&!(i>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,P=[...n.selectPendingEffects()],S=P.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let R=X?S.filter(N=>!kn.has(N.name)):S;R.length>0&&le(R)}catch(R){throw n.clearPendingEffects(),P.forEach(N=>{n.appendPendingEffect(N)}),Z(R,"postCommitUnsettled"),J(R),R}}}finally{l=!1}de()}},We=I=>{i+=1;let P=!1;try{let S=I();return P=!0,S}finally{i-=1,P&&dr()}},En=()=>{let I=n.selectSystemState();return n.selectRuntime()?.skipTransitionsAndAnimations===!0||Da(I)},Br=()=>{let I=n.selectSystemState();return I.projectData?Wo({presentationState:n.selectPresentationState(),resources:I.projectData?.resources,runtime:n.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer,skipTransitionsAndAnimations:En()}):null},Ur=()=>n.selectSystemState().projectData?structuredClone(n.selectPresentationState()?.bgm??null):null,Ar=()=>({audioEffects:structuredClone(n.selectSystemState().projectData?.resources?.audioEffects??{})}),xn=()=>structuredClone(n.selectSystemState().projectData?.resources?.sounds??{}),lt=I=>!!I?.audioEffects,ct=()=>structuredClone(b?A:Br()),Yr=()=>b?structuredClone(k):Ur(),ut=()=>b?structuredClone(E):Ar(),jt=I=>{let P=n.selectSystemState().projectData?.story?.scenes??{};return Object.entries(P).find(([,S])=>S?.sections?.[I])?.[0]},Sn=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,P=new Set(I?[]:y.map(S=>S.id));w.forEach(S=>{S.status=S.effects?.some(R=>P.has(R.id))?"active":"settled"}),I&&(y=[]),w=[]},On=(I,P,S,R,N,U,z)=>{let W=n.selectPlaybackLineEntryId?.()??0,ce=(P.actionPath??["bgm"]).join("."),he=n.selectCurrentPointer()?.pointer,ge=he?.sceneId??jt(he?.sectionId),ve=P.rollbackSource==="line"&&he?`story.scenes[${JSON.stringify(ge)}].sections[${JSON.stringify(he.sectionId)}].lines[${JSON.stringify(he.lineId)}].actions.${ce}`:ce,Re=P.rollbackSource==="line"?`${o}:${W}:${ve}`:null,Ue=Re?O.get(Re):null;if(Ue)return Ue;g+=1;let De={occurrenceId:`${t}:g${o}:l${W}:audio${g}`,actionPath:ve,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Te={...Ar(),sounds:xn()},Ce=Pc({occurrence:De,resources:Te,previousResources:z??Te,nextResources:Te,previousChannel:S,nextChannel:R,previousBgm:N,nextBgm:U});if(De.effects=structuredClone(Ce),De.status=Ce.length>0?"pending":"settled",y=structuredClone(Ce),w.push(De),Re)for(O.set(Re,De);O.size>512;){let ft=O.keys().next().value;O.delete(ft)}return De},Rn=({initialState:I,namespace:P})=>{ne("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...N}=I,U=R===void 0?void 0:structuredClone(R),z=structuredClone(I.projectData),W=Cd({projectData:z,l10nData:U}),ce=N.global??{};if(!Be(ce))throw new Error("Malformed global state.");let he=ce.runtime??{};if(!Be(he))throw new Error("Malformed global.runtime.");let ge=he.localizationPackageId;if(ge!=null&&typeof ge!="string")throw new Error("localizationPackageId requires a string or null value");let ve=new Set(W.map(({l10nId:Te})=>Te).filter(Te=>Te!==null)),Re=typeof ge=="string"&&ve.has(ge)?ge:null,Ue=Ri({projectData:z,l10nData:U,l10nId:Re}),De=sf({...N,global:{...ce,localizationPackages:W,runtime:{...he,localizationPackageId:Re}},projectData:Ue,initialAudioCommandId:S});te?.(),n=De,o+=1,a=!0,r=0,s=Ct(P),i=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,h=new Map,g=0,y=[],w=[],b=!1,A=null,k=null,E=null,v={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Ar()},O=new Map,L=z,C=U,D=Re,B=!0,_=!1,G=0,fe.clear(),n.appendPendingEffect({name:"handleLineActions"}),dr()},Md=()=>{ne("dispose"),a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,d=null,f=new Map,m=new Map,h=new Map,y=[],w=[],b=!1,A=null,k=null,E=null,v=null,O=new Map,B=!1,fe.clear(),oe?.())},Vd=()=>s,qd=()=>n.selectPresentationState(),Fd=()=>n.selectPresentationChanges(),Bd=I=>n.selectSectionLineChanges(I),rl=(I={})=>{ue("rendering"),r+=1;let P=Date.now();me(P);let S=m.size>0,R=Ie(f,P),N=S?Ie(m,P):new Map,U=n.selectRenderState({activePersistentAnimations:we(R),restoredPersistentAnimations:we(N),activeAudioEffects:structuredClone(y)}),z={...U,id:`render-${t}-${o}-${r}`};return h.set(z.id,{builtAt:P,persistentAnimationSessions:new Map([...N.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectIds:y.map(W=>W.id),bgmPresentation:Ur(),bgmResources:Ar(),retainsActiveAudioEffects:y.length>0&&y.every(W=>(U.audioEffects??[]).some(ce=>ce.id===W.id))}),z},Ud=(I={})=>rl(I),Yd=(I={})=>rl(I),zd=I=>{if(!a||!n)return;let P=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=P?h.get(P):null;P&&h.delete(P);let R=I?.audio?.find(U=>U?.id===Sk);b=!0,A=R?structuredClone(R):null,k=structuredClone(S?.bgmPresentation??null),E=structuredClone(S?.bgmResources??null);let N=new Map;nu(I?.animations).forEach(U=>{let z=cs(U);if(!z)return;let W=S?.persistentAnimationSessions?.get(z)??f.get(z),ce=Math.max(0,ou(U)),he=W?.startedAt??S?.builtAt??Date.now();N.set(z,{animation:structuredClone(U),startedAt:he,expiresAt:he+ce})}),f=N,S?.usedRestoredPersistentAnimationSessions&&(m=new Map),S?.activeAudioEffectIds?.length>0&&!S.retainsActiveAudioEffects&&y.length===S.activeAudioEffectIds.length&&S.activeAudioEffectIds.every(U=>y.some(z=>z.id===U))&&(y=[])},Xd=()=>n.selectSystemState(),Gd=()=>n.selectAchievements(),Hd=I=>n.selectAchievement(I),tl=()=>n.selectSaveSlotMap(),Kd=I=>n.selectSaveSlot(I),Wd=I=>n.selectSaveSlotPage(I),Jd=()=>n.selectImageGallery(),Qd=()=>n.selectMusicRoom(),Zd=()=>n.selectSceneReplay(),em=()=>n.selectIsSceneReplayActive(),Uk=()=>n.selectSkipMode(),Yk=()=>n.selectAutoMode(),rm=()=>n.selectRuntime(),tm=()=>n.selectIsChoiceVisible(),nm=()=>n.selectIsFormVisible(),sm=()=>n.selectActiveInteraction(),im=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),nl=(I,P,S={})=>!Be(P)||I!=="nextLine"?P:S.bypassChoice===!0?{...P,bypassChoice:!0}:S.interactionSource===Ja?{...P,_interactionSource:Ja}:P,sl=(I={})=>({type:Qa,payload:nl("nextLine",{_conditionalContinuation:!0},I)}),$i=(I,P)=>Pn(I)?{type:Qa,payload:{...I.payload,...P.payload}}:P,om=I=>{I.savedCheckpointOccurrences.forEach(P=>{n.markSavedRollbackCheckpointTransient(P)}),I.savedCheckpointOccurrences=[]},am=(I,P)=>{let S=p;return p=null,!S||!at(S.pointer,I)||S.checkpointIndex!==P?.checkpointIndex||S.checkpointIdentity!==P?.checkpoint?[]:S.savedCheckpointOccurrences},lm=I=>{let P=d;return!P||!at(P.pointer,I)?null:(d=null,P)},cm=({actionType:I,pointerBeforeAction:P,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:N,wasSceneReplayActive:U,isSceneReplayActive:z})=>{!S||!(!at(P,S)||R?.checkpoint!==N?.checkpoint||R?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(d={pointer:S,appendToPrevious:vk.has(I)&&U===z&&P?.sectionId===S.sectionId&&P?.lineId!==S.lineId,reuseExistingOccurrence:kk.has(I),forceNewOccurrence:I==="jumpToLine"})},il=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),om(I))},um=(I,P,S)=>wk.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==P?.checkpoint:S?.checkpoint!==P?.checkpoint&&S?.checkpointIndex>P?.checkpointIndex:!1,pm=I=>{let P=u.at(-1);if(!P?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&P.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:P.rollbackCursor?.checkpointIndex,sectionId:P.pointer?.sectionId,lineId:P.pointer?.lineId})},fm=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(P=>{let S=n.selectSaveSlot({slotId:P.slotId});S&&(P.saveSlotIdentity=S)})},dm=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},mm=(I,P,S)=>{let R=u.at(-1);if(!R)return;let N=n.selectCurrentPointer()?.pointer,U=um(I,P,S);if(at(R.pointer,N)){let z=S?.checkpoint!==P?.checkpoint||S?.checkpointIndex!==P?.checkpointIndex;U||z&&Ik.has(I)?(il(R),R.pointer=N,R.rollbackCursor=S,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]):z&&I==="updateProjectData"&&(R.rollbackCursor=S);return}il(R),R.pointer=N,R.rollbackCursor=n.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]},pt=(I,P)=>{if(ue(`action "${I}"`),!n[I])return;let S=P,R,N;if(I==="updateProjectData")ol(P),R=structuredClone(P.projectData),S={...P,projectData:Ri({projectData:R,l10nData:C,l10nId:D})},ol(S);else if(I==="updateLocalizationPackage"){if(N=ym(P),N===D)return;S={l10nId:N,projectData:Ri({projectData:L,l10nData:C,l10nId:N})}}bk.has(I)&&(c+=1);let U=n.selectAutoMode(),z=U?n.selectRuntime():null,W=n.selectIsSceneReplayActive?.()===!0,ce=gk.has(I)?Ie(f):null,he=n.selectCurrentPointer()?.pointer??null,ge=n.selectRollbackCursor?.()??null,ve=rs(I),Re=ve?n.selectPlaybackLineEntryId?.()??0:null,Ue=ve?ct():null,De=ve?Yr():null,Te=ve?ut():null,Ce=!1,ft;try{ft=n[I](S),Ce=!0}catch(Nt){throw Z(Nt,"preCommit"),Nt}R!==void 0&&(L=R),N!==void 0&&(D=N),hk.has(I)&&(m=ce??new Map,f=new Map,y=[]),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=[]);let fl=n.selectIsSceneReplayActive?.()===!0;W!==fl&&(f=new Map,m=new Map);let Rm=n.selectCurrentPointer()?.pointer??null,dl=n.selectRollbackCursor?.()??null,ml=ve?n.selectPlaybackLineEntryId?.()??0:null;ve&&ml!==Re&&(v={lineEntryId:ml,channel:Ue,presentation:De,resources:Te}),I==="saveSlot"?pm(P):I==="updateProjectData"&&fm(),mm(I,ge,dl),cm({actionType:I,pointerBeforeAction:he,pointerAfterAction:Rm,cursorBeforeAction:ge,cursorAfterAction:dl,wasSceneReplayActive:W,isSceneReplayActive:fl});let Cm=n.selectAutoMode()&&(I==="updateVariable"||U&&Ck(z,n.selectRuntime()));(Ok.has(I)||Cm)&&(B=!0);try{dr()}catch(Nt){throw Ce&&Z(Nt,"postCommitUnsettled"),Nt}return ft},ol=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Jr(I?.projectData?.resources?.variables??{}),Ft(I.projectData),Bt(I.projectData),Ut(I.projectData)},ym=I=>{if(!Be(I))throw new Error("updateLocalizationPackage requires an object payload");let P=Object.keys(I);if(P.length!==1||P[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},hm=(I,P,S)=>{let R=n.selectCurrentPointer()?.pointer;P!==R||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),pt("nextLineFromSystem",I.payload))},gm=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:d,persistentAnimationSessions:new Map(f),restoredPersistentAnimationSessions:new Map(m),renderPersistentAnimationMetadata:new Map(h),audioEffectOccurrenceSequence:g,activeAudioEffects:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:v?structuredClone(v):null,acceptedLineBgmActionOccurrences:new Map(O),canonicalProjectData:L,localizationPackageId:D,playbackScheduleDirty:B}),bm=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,d=I.pendingDialogueHistoryLineEntry,f=new Map(I.persistentAnimationSessions),m=new Map(I.restoredPersistentAnimationSessions),h=new Map(I.renderPersistentAnimationMetadata),g=I.audioEffectOccurrenceSequence,y=I.activeAudioEffects,w=I.pendingAudioEffectOccurrences.slice(),v=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,O=new Map(I.acceptedLineBgmActionOccurrences),L=I.canonicalProjectData,D=I.localizationPackageId,B=I.playbackScheduleDirty},_i=(I,P={})=>(ue("action batch"),We(()=>{let S=gm();try{return n[oo](()=>{let R,N=n.selectCurrentPointer()?.pointer??null,U=n.selectRollbackCursor?.()??null,z=c,W={pointer:N,rollbackCursor:U,markCurrentCheckpointTransient:P.rollbackSource==="line",savedCheckpointOccurrences:P.savedCheckpointOccurrences?.slice()??[]};u.push(W);try{n.beginRollbackActionBatch({source:P.rollbackSource});try{R=I()}finally{n.endRollbackActionBatch({})}Pn(R)&&hm(R,N,z),Sn();let ce=n.selectCurrentPointer()?.pointer??null;P.rollbackSource==="line"&&at(N,ce)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:W.savedCheckpointOccurrences,appendToPrevious:P.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:P.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:P.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!at(N,W.pointer)||U?.checkpoint!==W.rollbackCursor?.checkpoint)&&W.markCurrentCheckpointTransient&&W.savedCheckpointOccurrences.length>0&&(p={pointer:W.pointer,checkpointIndex:W.rollbackCursor?.checkpointIndex,checkpointIdentity:W.rollbackCursor?.checkpoint,savedCheckpointOccurrences:W.savedCheckpointOccurrences})}})}catch(R){throw bm(S),R}})),ji=(I,P,S,R={})=>{if(I===Wa||I===An)return _i(()=>{let N={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===An)return cl(P,S,N);let U=Ni(S),z=Gt({[I]:P},U);return ll(z[I],S,N)},R);if(I==="bgm")return _i(()=>{let N=Yr(),U=lt(P),z=U?ct():null,W=U?ut():null;pt(I,P);let ce=Ur();On(P,{...R,actionPath:R.actionPath??[I]},z,U?Br():null,N,ce,W)},R);pt(I,P)},wm=(I,P)=>{if(I!=="nextLineFromSystem")return ji(I,P);G+=1;try{return ji(I,P)}finally{G=Math.max(0,G-1)}},al=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Ni=I=>{if(al(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:P,...S}=I,R=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:P,variables:R,runtime:n.selectRuntime?n.selectRuntime():{}}},Im=I=>{if(!Be(I))return{templatePayload:I,literalTargetIds:null};let P=n.selectImageGalleryConfig();if(!Array.isArray(P?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?P.groups.find(N=>N.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let R=typeof I.variantId=="string"&&S.variants.some(N=>N.id===I.variantId);return{templatePayload:{...I,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...R?{variantId:I.variantId}:{}}}},vm=I=>!Be(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},km=I=>!Be(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},Am=I=>{if(!Be(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},Pm=(I,P,S)=>{if(!Be(I))throw new Error(`conditional branch at index ${P} must be an object`);if(!Be(I.actions))throw new Error(`conditional branch at index ${P} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&P!==S-1)throw new Error("conditional else branch must be the last branch")},ll=(I,P,S)=>{Am(I);let R=sl(S);for(let N=0;N<I.branches.length;N+=1){let U=I.branches[N];Pm(U,N,I.branches.length);let z=Ni(P);if(Object.prototype.hasOwnProperty.call(U,"when")&&!qt(U.when,z))continue;let ce=Cn(U.actions,P,{...S,actionPath:[...S.actionPath??[Wa],"branches",String(N),"actions"]});return Pn(ce)?$i(R,ce):R}return R},Em=I=>{if(!Be(I))throw new Error("random action payload must be an object");let P=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(P!==void 0)throw new Error(`random action.${P} is not supported`);if(!Be(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=L?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||_e(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},cl=(I,P,S)=>{Em(I),al(P);let R=uc(I.distribution,{randomSource:M});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let z=(S.actionPath??[An]).join("."),W=S.randomOutcomeOrdinals??new Map,ce=W.get(z)??0;W.set(z,ce+1),n.recordRandomOutcome({path:z,ordinal:ce,type:R.type,result:R}),dm()}let N;R.type==="integer"?pt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):N=Cn(I.distribution.outcomes[R.outcomeIndex].actions,P,{...S,actionPath:[...S.actionPath??[An],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let U=sl(S);return Pn(N)?$i(U,N):U},xm=(I,P)=>({...I??{},_form:P}),Sm=(I,P,S,R)=>{let N=pt(I,P),U=N?.submitted===!0&&N.valid===!0,z=N?.cancelled===!0;if(!(!U&&!z)&&Be(P.actions))return Cn(P.actions,xm(S,N.form),{...R,interactionSource:Ja})},ul=(I,P,S,R)=>{if(I===An)return cl(P,S,R);let N=Ni(S),U={templatePayload:P,literalTargetIds:null};I===Pk?U=Im(P):I===Ek?U=vm(P):I===xk&&(U=km(P));let{templatePayload:z,literalTargetIds:W}=U,he=Gt({[I]:z},N)[I],ge=W?{...he,...W}:he;if(I===Wa)return ll(ge,S,R);let ve=nl(I,ge,R);if(Ak.has(I))return Sm(I,ve,S,R);let Re=null,Ue=null,De=null,Te=!1;if(I==="bgm"){let Ce=R.audioEffectHandoff,ft=Ce?.available?Ce.presentation:Yr();Te=lt(ve),Te&&Ce?.available?(Ce.available=!1,Re=structuredClone(Ce.channel),Ue=structuredClone(Ce.presentation),De=structuredClone(Ce.resources)):Te&&(Re=ct(),Ue=ft,De=ut())}if(pt(I,ve),I==="bgm"){let Ce=Ur();On(ve,R,Re,Te?Br():null,Ue,Ce,De)}},Cn=(I,P,S)=>{let R,N=S?.executionContext??{depth:0,pendingNavigation:null},U=es(I);ts(U),N.depth+=1;try{for(let[z,W]of U){let ce={...S,executionContext:N,actionPath:[...S?.actionPath??[],z]};if(rs(z)){let ge=N.pendingNavigation;if(ge)throw new Error(`action batch cannot execute multiple navigation actions: ${ge.actionType}, ${z}`);N.pendingNavigation={actionType:z,payload:W,eventContext:P,options:ce};continue}let he=ul(z,W,P,ce);Pn(he)&&(R=$i(R,he))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let z=N.pendingNavigation;N.pendingNavigation=null,ul(z.actionType,z.payload,z.eventContext,z.options)}return R},pl=(I,P,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return _i(()=>Cn(I,P,R),R)},Om=I=>{let P=n.selectCurrentPointer()?.pointer;if(I!==P||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:Rn,dispose:Md,handleAction:ji,handleInternalAction:wm,handleActions:pl,selectRenderState:Ud,prepareRenderState:Yd,commitRenderState:zd,selectPresentationState:qd,selectPresentationChanges:Fd,selectSectionLineChanges:Bd,selectSystemState:Xd,selectAchievements:Gd,selectAchievement:Hd,selectSaveSlotMap:tl,selectSaveSlot:Kd,selectSaveSlotPage:Wd,selectSaveSlots:tl,selectImageGallery:Jd,selectMusicRoom:Qd,selectSceneReplay:Zd,selectIsSceneReplayActive:em,selectRuntime:rm,selectIsChoiceVisible:tm,selectIsFormVisible:nm,selectActiveInteraction:sm,selectHasPendingRenderWork:im,handleLineActions:I=>{ue("line action handling");let P=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!at(I.pointer,P))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return We(()=>{let S=n.selectCurrentPointer()?.pointer,R=n.selectPlaybackLineEntryId?.()??0,N=v?.lineEntryId===R?v:null,U=N?{available:!0,channel:structuredClone(N.channel),presentation:structuredClone(N.presentation),resources:structuredClone(N.resources)}:null,z=n.selectRollbackCursor?.()??null,W=p,ce=d,he=am(S,z),ge=lm(S),ve=n.selectCurrentLine(),Re=!1;if(ve?.actions){try{pl(ve.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:he,dialogueHistoryAppendToPrevious:ge?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ge?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ge?.forceNewOccurrence===!0,audioEffectHandoff:U})}catch(Ue){throw p=W,d=ce,Ue}Re=!0}return v?.lineEntryId===R&&(v=null),Om(S),Re})},getNamespace:Vd,classifyAutomaticAttemptError:$}}var $k="music-room:player",Td=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Nd=(e,t)=>Td.has(e)&&t?._event?.id===$k,Ld=({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(r)??e.selectRenderState(r);n?.(s),t.render(s),a(o)&&e.commitRenderState?.(s)},_k=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&Ld({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},jk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},Nk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},Dk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},Tk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},Lk=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Dd={render:Ld,saveSlots:jk,saveGlobalDeviceVariables:Nk,saveGlobalAccountVariables:Dk,saveGlobalRuntime:Tk,applyScopedDataUpdates:Lk,handleLineActions:_k},Mk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),el=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},Vk=(e=[])=>{let t=new Set,n=[];for(let o=e.length-1;o>=0;o-=1){let a=e[o];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!Mk.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},qk=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,d=!1,f=0,m=0,h=!0,g=jd({ticker:n,dispatchAutomaticAttempt:()=>el(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:$=>e()?.classifyAutomaticAttemptError?.($)??"preCommit"}),y=()=>{u=null,p=null,d=!1,f=0},w=()=>{g.reset(),m+=1,y(),h=!0},b=()=>{m+=1,h=!1,y(),g.dispose()},A=$=>h&&$===m,k=$=>{if(a){a($);return}console.error("RouteEngine persistence write failed.",$)},E=$=>{if(s)return s;let j=Ct($),F=l.get(j);if(F)return F;let J=qa({indexedDB:r,namespace:j});return l.set(j,J),J},v=$=>{let j=s?null:Ct(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=E(j),$(F))).catch(J=>{!s&&l.get(j)===F&&l.delete(j),k(J)})},O=$=>{if(!h)return;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;f+=1,u=j,d=!1},L=()=>f,C=($={})=>{if(!h||$?.aborted===!0)return!1;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||d?!1:(d=!0,!0)},D=($,j={})=>{if(!h)return!1;if(Nd($,j)){let J=Td.get($),de=e();return el(de,J,j?._event),!0}if($!=="renderComplete"||!C(j))return!1;let F=e();return el(F,"markLineCompleted",{}),!0},B=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),G=$=>typeof $?.selectActiveInteraction=="function"?$.selectActiveInteraction():typeof $?.selectIsChoiceVisible=="function"&&$.selectIsChoiceVisible()?{source:"choice"}:null,fe=$=>$?._formKey??$?.formKey,M=($,j)=>fe($)===j?.formKey,K=($,j)=>!$||typeof $!="object"||Array.isArray($)?!1:$._interactionSource===j?.source,le=($,j)=>K($,j)?j.source==="form"?M($,j):!0:!1,X=($,j)=>!$||typeof $!="object"||Array.isArray($)||j?.source!=="form"?!1:M($,j),te=($={},j)=>Object.keys($).length>0&&Object.entries($).every(([F,J])=>B.has(F)?X(J,j):_.has(F)),oe=($={},j)=>{let F=$?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:te(F,j):le($,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(J=>le(J,j))},ne=($,j={})=>{if(!j?.actions)return!1;let F=G($);return!F||F.source==="choice"?!1:!oe(j,F)},ue=({preprocessPayload:$,onEvent:j}={})=>async(F,J={})=>{if(!h)return!1;if(Nd(F,J))return D(F,J),j?.(F,J);let de=e(),Ie=m,we=f;if(ne(de,J))return j?.(F,J);let me=await $?.(F,J)??J;if(!A(Ie)||e()!==de||f!==we)return!1;if(ne(de,me))return j?.(F,me);if(D(F,me),me?.actions){let dr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,We;me?.bypassChoice===!0?We={bypassChoice:!0}:me?._interactionSource&&(We={interactionSource:me._interactionSource}),We?de.handleActions(me.actions,dr,We):de.handleActions(me.actions,dr)}return j?.(F,me)},Z=$=>{if(!h)return;let j=m,F=e(),J=Vk($),de=J.some(we=>we.name==="handleLineActions");J.forEach(we=>{if(!Dd[we.name]&&!kn.has(we.name)&&!o)throw new Error(`Unhandled pending effect "${we.name}".`)});let Ie={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:L,enqueuePersistenceWrite:v,lifecycleGeneration:m,isCurrentLifecycle:A};for(let we of J){if(!A(j))break;if(de&&we.name==="render")continue;if(kn.has(we.name)){g.handleLegacyEffect(we);continue}let me=Dd[we.name];if(me){me(Ie,we.payload);continue}o(we,Ie)}};return Z.handleRouteGraphicsEvent=D,Z.createRouteGraphicsEventHandler=ue,Z.reset=w,Z.dispose=b,Z.reconcilePlaybackScheduleV1=$=>g.reconcilePlaybackScheduleV1($),Z},Fk=qk;var Bk=(e,t={})=>{let{resources:n={}}=t;return Uo(e,n)};var YP=Za;export{Ao as DEFAULT_VISUAL_LAYER,wt as RENDER_LAYER,mr as VISUAL_LAYER,Fk as createEffectsHandler,gv as createIndexedDbPersistence,YP as default,lo as formatDate,rh as resolveComputedVariables,Bk as resolveLayoutReferences};
|
|
5
|
+
[${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let s=Pc(e,t),i={};for(let l of ss)Cr(r.tween,l)&&(i[l]=Ec({property:l,authored:r.tween[l],speed:s,propertyPath:`${a}.tween.${l}`}));return i},Sc=({bgm:e,resources:t={}})=>{let n=e?.audioEffects?.resourceId,o=t.audioEffects?.[n],a=o?.type==="update"?o.tween:o?.type==="transition"?o.next:void 0;if(!a||(e.sounds??[]).length===0)return e;let s=structuredClone(e);for(let i of ss){if(!Cr(a,i))continue;let l=a[i].keyframes.at(-1);typeof l?.value!="number"||!Number.isFinite(l.value)||l.relative===!0||(i==="volume"?s.volume=l.value:i==="pan"?s.pan=l.value:s.sounds.forEach(c=>{c.playbackRate=l.value}))}return s},Ic=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),vc=e=>{if(!e)return e;let t={...e};return delete t.beginEffect,delete t.endEffect,t},$h=({occurrence:e,resources:t={},previousResources:n=t,nextResources:o=t,previousChannel:a,nextChannel:r,previousBgm:s,nextBgm:i})=>{if(!e?.selection)return null;let l=e.selection,c=e.actionPath??"bgm",u=l.resourceId,p=`resources.audioEffects.${u}`,m=t.audioEffects?.[u];if(!m)throw new Error(`[${c}.audioEffects.resourceId]
|
|
6
|
+
[${p}] Unknown audio effect resource "${u}".`);let d=Pc(l,`${c}.audioEffects`),f=bc(a,c),h=bc(r,c);if(!f&&!h)return null;if(f&&h&&f.id!==h.id)throw new Error(`[${c}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let b=f?.id??h.id,y=kc(f,h),w=Ac(vc(f),vc(h));if(m.type==="transition"){if(y){if(w)return null;throw new Error(`[${c}.audioEffects]
|
|
7
|
+
[${p}] Audio effect resource "${u}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let A={};for(let k of ss){let E={},v=f?m.prev?.[k]:void 0;v&&(E.exit=ho({authored:v,bgm:s,property:k,propertyPath:`${p}.prev.${k}`,renderedSound:f,resources:n,speed:d}));let O=h?m.next?.[k]:void 0;O&&(E.enter=ho({authored:O,bgm:i,property:k,propertyPath:`${p}.next.${k}`,renderedSound:h,resources:o,speed:d}),wc({actionPath:c,compiled:E.enter,property:k,propertyPath:`${p}.next.${k}`,renderedSound:h})),Object.keys(E).length>0&&(A[k]=E)}return Object.keys(A).length===0?null:{...Ic(e,b),properties:A}}if(m.type!=="update")throw new Error(`[${p}.type] Unsupported audio effect type "${m.type}".`);if(!f||!h||!y)throw new Error(`[${c}.audioEffects]
|
|
8
|
+
[${p}] Audio effect resource "${u}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let g={};for(let A of ss){if(!Cr(m.tween,A))continue;let k=`${p}.tween.${A}`,E=ho({property:A,authored:m.tween[A],speed:d,propertyPath:k,baselineBgm:s,bgm:i,resources:o,renderedSound:h}),v=h[A]??Jt[A];wc({actionPath:c,compiled:E,property:A,propertyPath:k,renderedSound:h}),(f[A]??Jt[A])!==v&&(g[A]={update:E})}return Object.keys(g).length===0?null:{...Ic(e,b),properties:g}},Oc=e=>{let t=e.nextResources??e.resources,n=e.occurrence;if(!n?.selection)return[];let o=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=n.selection.resourceId,s=t?.audioEffects?.[r],i=(f,h)=>h?{...f,children:[h]}:null,l=(f,h,b,y)=>{if(!Array.isArray(f?.sounds))return f;let w=b?.children?.indexOf(y)??-1,g=f.sounds.filter(A=>h.sounds?.[A.resourceId])[w];return{...f,sounds:g?[g]:[]}},c=f=>f.map(({previousSound:h,nextSound:b},y)=>$h({...e,occurrence:y===0?n:{...n,occurrenceId:`${n.occurrenceId}:${y}`},resources:t,previousBgm:l(e.previousBgm,e.previousResources??t,e.previousChannel,h),nextBgm:l(e.nextBgm,t,e.nextChannel,b),previousChannel:i(e.previousChannel,h),nextChannel:i(e.nextChannel,b)})).filter(Boolean);if(!s||!["transition","update"].includes(s.type))return c([{previousSound:o[0],nextSound:a[0]}]);let u=new Map(o.map(f=>[f.id,f])),p=new Map(a.map(f=>[f.id,f]));if(s.type==="update"){let f=a.map(y=>({previousSound:u.get(y.id),nextSound:y})),h=f.find(({previousSound:y})=>!y);if(h)return c([h]);let b=o.find(y=>!p.has(y.id));return c(b?[{previousSound:b}]:f)}let m=[];for(let f of o){let h=p.get(f.id);(!h||!kc(f,h))&&m.push({previousSound:f,nextSound:h})}for(let f of a)u.has(f.id)||m.push({nextSound:f});if(m.length>0)return c(m);let d=o.find(f=>{let h=p.get(f.id);return h&&!Ac(f,h)});return c([{previousSound:d??o[0],nextSound:d?p.get(d.id):a[0]}])};var ae=e=>structuredClone(Pe(e)?Er(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Qt=e=>e?.animations?.playback?.continuity==="persistent",Y=(e,t)=>ie(e??{},t)&&e[t]!==void 0,is=e=>Y(e,"alpha")||Y(e,"opacity"),_h=e=>Y(e,"alpha")?e.alpha:e?.opacity,Tc=e=>(Y(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),jh=e=>e?.applyMode==="persistent",Nh="default",Dh=e=>Array.isArray(e?.channels)?e.channels.filter(jh).map(ae):[],Zt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Th=e=>is(e)||Y(e,"blur")||Y(e,"filters"),Io=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Lc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],wo=["animationName","animationSpeed","loop"],Lh=e=>Y(e,"transformId")||Y(e,"transform")||Io.some(t=>Y(e,t)),vo=e=>e?.text&&Y(e.text,"content")&&Y(e.text,"textStyleId"),ko=e=>e?.layout&&Array.isArray(e.layout.elements),Mh=e=>Y(e,"text")||Y(e,"layout"),Rc=(e,t)=>e.resourceId?!0:vo(e)?!t?.text:ko(e)?!t?.layout:!1,Vh=e=>Y(e,"resourceId")||vo(e)||ko(e),Cc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,qh=e=>Y(e,"resourceId")||Y(e,"sprites")&&Array.isArray(e.sprites)&&e.sprites.length>0,Fh=(e,t)=>{let n={...ae(e),...t};if(t.text&&e.text&&(n.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(n.transform={...ae(e.transform),...ae(t.transform)}),Y(t,"transform")){delete n.transformId;for(let o of Io)Y(t,o)||delete n[o]}else Y(t,"transformId")&&delete n.transform;return n},Bh=(e,t)=>{let n=[e.resourceId,e.text,e.layout].filter(o=>o!==void 0).length;if(n>1)throw n===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(Y(e,"text")&&!vo(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(Y(e,"layout")&&!ko(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},$c=e=>Lc.some(t=>Y(e,t)),_c=e=>wo.some(t=>Y(e,t)),Uh=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let o of Lc)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Mc=(e,t,n)=>{let o=e[n];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},Yh=(e,t)=>{if(!t)return e;let n=Y(e,"transform");for(let o of Io)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},zh=(e,t)=>(t&&(!Y(e,"opacity")&&Y(t,"opacity")&&(e.opacity=t.opacity),!Y(e,"blur")&&Y(t,"blur")&&(e.blur=ae(t.blur)),!Y(e,"filters")&&Y(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Vc=(e,t,n=[],{hasPatchFn:o=()=>!1,hasSubjectFn:a=(s,i)=>t(s,i),mergeItemFn:r}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let s=e.map((i,l)=>{let c=Mc(n,i,l),u=a(i,c),p=Th(i),m=Lh(i),d=o(i),f=ie(i,"animations"),h=Tc(ae(i));if(!u&&(p||m||d)&&c&&(h=r?r(c,h):{...ae(c),...h}),!f){let b=c?t(c):!1,y=t(h);!u&&b&&y&&Qt(c)?h.animations=ae(c.animations):delete h.animations}return u?h:zh(Yh(h,c),c)}).filter(i=>t(i)||i.animations);return{hasValidItems:s.length>0,processedItems:s}},Xh=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},qc=e=>!!e?.character&&ie(e.character,"sprite"),Gh=e=>{let t={},n=!1,o=Xh(e);return o!==void 0&&(t.name=o,n=!0),qc(e)&&(t.sprite=ae(e.character.sprite),n=!0),n?t:void 0},jc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Nc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:n&&!ie(t,"characterId"),Dc=({previousCharacter:e,characterFields:t,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},c=t??{},u=s&&!n,p=u&&!r;return ie(c,"name")?i.name=c.name:(o&&!n||u)&&ie(l,"name")&&(i.name=ae(l.name)),ie(c,"sprite")?i.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(i.sprite=ae(l.sprite)),Object.keys(i).length>0?i:void 0},Hh=({dialogueState:e,content:t,append:n=!1})=>{if(!n||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...o,...t]},Kh=()=>({}),Wh=(e,t)=>{if(!t.screen)return;let n=is(t.screen),o=Y(t.screen,"blur"),a=ie(t.screen,"animations");if(!n&&!o){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=_h(t.screen):Y(r,"opacity")&&(s.opacity=r.opacity),o?s.blur=ae(t.screen.blur):Y(r,"blur")&&(s.blur=ae(r.blur)),ie(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ie(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},Jh=(e,t)=>{if(t.background){let n=Y(t.background,"resourceId"),o=Y(t.background,"colorId"),a=is(t.background),r=Y(t.background,"blur"),s=Y(t.background,"filters"),i=Y(t.background,"transformId"),l=$c(t.background),c=_c(t.background),{animationsOnly:u,state:p}=Zt(t.background,f=>Y(f,"resourceId")||Y(f,"colorId")||is(f)||Y(f,"blur")||Y(f,"filters")||Y(f,"transformId")||$c(f)||_c(f));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!n&&!o&&!a&&!r&&!s&&!i&&!l&&!c){delete e.background;return}let m=e.background,d=Tc(ae(t.background));if(!n&&m?.resourceId){d.resourceId=m.resourceId,!ie(d,"transformId")&&m.transformId&&(d.transformId=m.transformId);for(let f of wo)!Y(d,f)&&Y(m,f)&&(d[f]=m[f])}n||Uh(d,m,{hasAuthoredTransformId:i}),!n&&!o&&m?.colorId&&(d.colorId=m.colorId),!n&&!a&&Y(m,"opacity")&&(d.opacity=m.opacity),!n&&!r&&Y(m,"blur")&&(d.blur=ae(m.blur)),!n&&!s&&Y(m,"filters")&&(d.filters=ae(m.filters)),ie(d,"resourceId")&&d.resourceId===void 0&&delete d.resourceId,ie(d,"colorId")&&d.colorId===void 0&&delete d.colorId,ie(d,"animations")&&d.animations===void 0&&delete d.animations,ie(d,"transformId")&&d.transformId===void 0&&delete d.transformId,ie(d,"opacity")&&d.opacity===void 0&&delete d.opacity,ie(d,"blur")&&d.blur===void 0&&delete d.blur,ie(d,"filters")&&d.filters===void 0&&delete d.filters;for(let f of wo)ie(d,f)&&d[f]===void 0&&delete d[f];if(!d.resourceId&&!d.colorId){delete e.background;return}!n&&m?.resourceId===d.resourceId&&m?.transformId===d.transformId&&!ie(d,"animations")&&Qt(m)&&(d.animations=ae(m.animations)),e.background=d}else e.background?.animations&&!Qt(e.background)&&(e.background.animations={})},Qh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(jc(e.dialogue),e.dialogue.mode==="adv")){e.dialogue.content=void 0,delete e.dialogue.initialRevealedContent,delete e.dialogue.textSpeed;let u=e.dialogue.persistCharacter===!0,p=Nc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=Dc({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=Zt(t.dialogue.ui,m=>!!m.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=t.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&Hh({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Nc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=ie(t.dialogue,"characterId"),i=Gh(t.dialogue),l=qc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=Dc({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||jc(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},Zh=(e,t)=>{let n=Dh(e.sfx);if(!t.sfx){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=n.filter(s=>s.id!==Nh);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(t.sfx.channels.length===0){delete e.sfx;return}let o=new Set(t.sfx.channels.map(r=>r.id)),a=n.filter(r=>!o.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},eg=(e,t,n)=>{if(t.bgm){let o=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!o||o&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Sc({bgm:ae(t.bgm),resources:n}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},rg=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{Bh(r,Mc(n,r,s))});let{hasValidItems:o,processedItems:a}=Vc(t.visual.items,Rc,n,{hasPatchFn:Mh,hasSubjectFn:Vh,mergeItemFn:Fh});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!Rc(n)||!Qt(n))?{...n,animations:{}}:n))},tg=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!Cc(a)||!Qt(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=Vc(t.character.items,Cc,e.character?.items||[],{hasSubjectFn:qh});n?e.character={items:o}:delete e.character},ng=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},sg=(e,t)=>{if(t.layout){let{animationsOnly:n,state:o}=Zt(t.layout,a=>!!a.resourceId);if(n){e.layout=o;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},ig=(e,t)=>{if(t.choice){let{animationsOnly:n,state:o}=Zt(t.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...o};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},og=(e,t)=>{if(t.form){let{animationsOnly:n,state:o}=Zt(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},ag=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},lg=(e,t)=>{if(t.voice){let n=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!n||n&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},cg=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},et=(e,{resources:t}={})=>Xn(Kh,[cg,Wh,Jh,Zh,(a,r)=>eg(a,r,t),rg,Qh,tg,ng,sg,ig,og,ag,lg])(e);var bt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Wr(e,t);return n&&typeof n=="object"?e:n};var ug=Object.freeze({dialogueTextSpeed:{source:"global.dialogueTextSpeed"},autoForwardDelay:{source:"global.autoForwardDelay"},autoForwardSpeed:{source:"global.autoForwardSpeed"},skipUnseenText:{source:"global.skipUnseenText"},skipTransitionsAndAnimations:{source:"global.skipTransitionsAndAnimations"},soundVolume:{source:"global.soundVolume"},musicVolume:{source:"global.musicVolume"},muteAll:{source:"global.muteAll"},localizationPackageId:{source:"global.localizationPackageId"},saveLoadPagination:{source:"context.runtime.saveLoadPagination"},menuPage:{source:"context.runtime.menuPage"},menuEntryPoint:{source:"context.runtime.menuEntryPoint"},autoMode:{source:"global.autoMode"},skipMode:{source:"global.skipMode"},dialogueUIHidden:{source:"global.dialogueUIHidden"},isLineCompleted:{source:"global.isLineCompleted"}}),$r=Object.freeze({dialogueTextSpeed:50,autoForwardDelay:1e3,autoForwardSpeed:50,skipUnseenText:!1,skipTransitionsAndAnimations:!1,soundVolume:50,musicVolume:50,muteAll:!1,localizationPackageId:null,autoMode:!1,skipMode:!1,dialogueUIHidden:!1,isLineCompleted:!1}),en=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),pg=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Ao=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Fc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),Po=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Bc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),fg=(e,t)=>{let n=pg[e];if(n==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(t!==null&&typeof t!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},os=(e,t)=>{if(fg(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},Eo=(e={})=>{let t=e?.config;if(t===void 0)return{...$r};if(!Bc(t))throw new Error("projectData.config must be an object");let n=Object.keys(t).find(i=>i!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=t.runtimeDefaults;if(o===void 0)return{...$r};if(!Bc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Fc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...$r};return Fc.forEach(i=>{o[i]!==void 0&&(s[i]=os(i,o[i]))}),s},dg=(e,t)=>{if(t.startsWith("global.")){let n=t.slice(7);return e?.global?.[n]}if(t.startsWith("context.runtime.")){let n=t.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[n]}},_r=e=>Object.fromEntries(Object.entries(ug).map(([t,n])=>{let o=dg(e,n.source),a=o!==void 0?o:$r[t]??en[t];return[t,a]})),nr=(e,t)=>_r(e)[t],Uc=(e={})=>Object.fromEntries(Ao.map(t=>[t,e[t]??$r[t]]));var wt=Object.freeze({VISUAL_BEHIND_BACKGROUND:10,BACKGROUND:20,VISUAL_BEHIND_CHARACTER:30,CHARACTER:40,VISUAL_BEHIND_DIALOGUE:50,DIALOGUE:60,VISUAL_BEHIND_CHOICE:70,CHOICE:80,VISUAL_FOREGROUND:90}),yr=Object.freeze({BEHIND_BACKGROUND:wt.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:wt.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:wt.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:wt.VISUAL_BEHIND_CHOICE,FOREGROUND:wt.VISUAL_FOREGROUND}),xo=yr.BEHIND_DIALOGUE,So=Object.freeze(Object.values(yr).sort((e,t)=>e-t));var mg={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:uo},yg=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,rn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return rn(t);let[n]=Object.keys(t),o=yg.exec(n);if(!o)return rn(t);let[,a,r,s]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[i]:rn(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,rn(n)])),hr=(e,t)=>{let n={functions:mg};return Wr(rn(e),t,n)},su=({animationType:e,animationId:t,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},hg=({id:e,targetId:t,animation:n,playback:o,animationPath:a="animation"})=>{let r=structuredClone(n);if(su({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let s=Ig(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?cu(r):null;if(s.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&r.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&(!Number.isFinite(i)||i<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=s}}return r},gg=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return su({animationType:e.type,animationId:t,animationPath:n}),e.type},bg=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},wg=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Ig=(e,t="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${t}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${t}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${t}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${t}] playback.loop must be a boolean.`);let n={};return e.continuity!==void 0&&(n.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(n.speed=e.speed),e.loop===!0&&(n.loop=!0),Object.keys(n).length>0?n:void 0},vg=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},Qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),iu=(e={})=>Qe(e,"alpha")&&typeof e.alpha=="number"?e.alpha:Qe(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,ou=e=>e?.playback?.continuity==="persistent",Do=e=>Array.isArray(e)?e.map(Do):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=Do(e[n]),t),{}),us=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(Do(t))},au=(e=[])=>e.filter(t=>ou(t)).map(t=>structuredClone(t)),lu=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let o=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+o},0):0,Oo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,lu(n)),0),cu=e=>Math.max(Oo(e?.tween),Oo(e?.prev?.tween),Oo(e?.next?.tween),lu(e?.mask?.progress)),uu=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:cu(e)/vg(e),kg=e=>e.some(t=>t?.playback?.loop===!0),Yc=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let n=new Set(t.map(us).filter(Boolean));return e.some(o=>{if(!ou(o))return!1;let a=us(o);return a?n.has(a):!1})},Ze=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:kg(e)||r&&!t||Yc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:Yc({animationInstances:e,activePersistentAnimations:a}),pu=(e,t,n,o,a)=>{if(e===void 0)return!0;let r=a.slice(0,o).filter(i=>i?.id===n).length,s=e?.[t]?.items?.filter(i=>i?.id===n).at(r);return Qe(s??{},"animations")},Ag=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Pg=(e,t)=>{if(Ag(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Eg=({resources:e,animationId:t,playback:n,instanceId:o,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?hg({id:o,targetId:a,animation:s,playback:n,animationPath:r}):null},To=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${t} must be an array of objects`);return e},xg=({content:e,path:t,variables:n})=>To(e,t).reduce((o,a)=>{let r=bt(a.text,{variables:n});return o+`${r??""}`.length},0),zc=(e=[])=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,(t.get(n.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n))},Xc=(e,t=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let o=e?.sprites?.map(({resourceId:a})=>a)||[];return o.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${o.join("-")}`},vt=(e,t)=>{if(t.transformId&&t.transform)throw new Error(`Visual item "${t.id}" cannot define both transformId and transform`);if(t.transform)return t.transform;if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId or transform`);let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},Sg=(e,t={})=>{if(!t?.transformId)return;let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},Og=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Rg=(e={})=>Og.some(t=>Qe(e,t)),fu=(e={},t)=>{if(t){if(e.images?.[t])return"sprite";if(e.videos?.[t])return"video";if(e.spritesheets?.[t])return"spritesheet-animation";if(e.layouts?.[t])return"container"}},ls=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Cg=(e={})=>e.textStyles||{},$g=(e={})=>e.images||{},_g=.5,jg=(e={},t,n)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${n}'`);return t}return Object.keys(e.animations??{})[0]},Yo=({id:e,resourceId:t,spritesheet:n,animationName:o,animationSpeed:a,loop:r,width:s,height:i,transform:l={}}={})=>{let c=jg(n,o,t),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:i??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??_g,loop:r??u.loop??!0}}},du=({id:e,item:t,resources:n={}}={})=>{let o=n.images?.[t.resourceId];if(o)return{type:"sprite",id:e,src:o.fileId,width:o.width,height:o.height,x:0,y:0};let a=n.spritesheets?.[t.resourceId];if(a)return Yo({id:e,resourceId:t.resourceId,spritesheet:a,animationName:t.animationName,animationSpeed:t.animationSpeed,loop:t.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${t.resourceId}`)},Ng=(e={})=>e.colors||{},Dg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,tn=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,kt=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},Ro=(e,t,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);return e},Co=(e,t,n,o,{minimum:a}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let r=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${t} for text style "${n}" must be ${r}`)}return e},ds=(e,t)=>{if(typeof e!="string"||!Dg.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},Gc=(e,t,n)=>{let o=ds(e,n);if(t===1)return o;let a=Number.parseInt(o.slice(1,3),16),r=Number.parseInt(o.slice(3,5),16),s=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${r}, ${s}, ${t})`},Tg=(e={},t)=>{let n=Cg(e)?.[t];if(!n)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=Ro(n.colorAlpha,"colorAlpha",t),i={fontFamily:Array.isArray(n.fontId)?a.join(", "):a[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:Gc(r.hex,s,`Color "${n.colorId}" for text style "${t}"`)};if(n.align!==void 0&&(i.align=n.align),n.wordWrap!==void 0&&(i.wordWrap=n.wordWrap),n.breakWords!==void 0&&(i.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(i.wordWrapWidth=n.wordWrapWidth),n.strokeColorId){let l=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=Ro(n.strokeAlpha,"strokeAlpha",t);i.strokeColor=Gc(l.hex,c,`Stroke color "${n.strokeColorId}" for text style "${t}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth),n.shadow!==void 0){let l=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);i.shadow={color:ds(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:Ro(n.shadow.alpha,"shadow.alpha",t),blur:Co(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:Co(n.shadow.offsetX,"offsetX",t,2),offsetY:Co(n.shadow.offsetY,"offsetY",t,2)}}return i},At=e=>Array.isArray(e)?e.map(At):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,At(n)])),Lo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Lo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=At(r);continue}a!=="textStyleId"&&(o[a]=Lo(r,t,tn(n,a)))}return e.textStyleId!==void 0&&(kt(e.textStyleId,n,"textStyleId"),o.textStyle=Tg(t,e.textStyleId)),o},zo=(e={},t)=>{let n=Ng(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return ds(n.hex,`Color "${t}"`)},mu=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",$o=(e,t,n)=>{let o=e?.[t];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${n}". Use ${mu(`${t}.fill`)} instead`)},Lg=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>nn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(o[a]=nn(r,t,tn(n,a)));return e.colorId!==void 0&&(kt(e.colorId,n,"colorId"),o.fill=zo(t,e.colorId)),o},nn=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>nn(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${n}". Use ${mu("fill")} instead`);$o(e,"hover",n),$o(e,"click",n),$o(e,"rightClick",n)}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=At(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=Lg(r,t,tn(n,a));continue}o[a]=nn(r,t,tn(n,a))}}return e.type==="rect"&&e.colorId!==void 0&&(kt(e.colorId,n,"colorId"),o.fill=zo(t,e.colorId)),o},_o=(e={},t)=>{let n=$g(e)?.[t];return n||null},yu=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Hc=(e,t,n,o)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,o))throw new Error(`Inline ${t}.${o} is not allowed in sprite layout elements at "${n}". Use ${yu(`${t}.${o}`)} instead`)},Kc=(e,t,n)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},Mo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Mo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${yu(a)} instead`);Hc(e,"hover",n,"src"),Hc(e,"click",n,"src")}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=At(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=Mo(r,t,tn(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){kt(e.imageId,n,"imageId");let a=_o(t,e.imageId),r=a?.fileId??e.imageId;o.src=r,o.width===void 0&&a?.width!==void 0&&(o.width=a.width),o.height===void 0&&a?.height!==void 0&&(o.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(kt(e.hoverImageId,n,"hoverImageId"),Kc(o,"hover",_o(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(kt(e.clickImageId,n,"clickImageId"),Kc(o,"click",_o(t,e.clickImageId)?.fileId??e.clickImageId)),o},Mg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),cs=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>cs(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=At(e),o=typeof e.type=="string";(o||t)&&Qe(e,"opacity")&&(Qe(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])Qe(e,a)&&(n[a]=cs(e[a]));for(let[a,r]of Object.entries(e))Mg(a)&&(n[a]=cs(r,{isElementPatch:o||t}));return n},Xo=(e,t={},n="root")=>cs(Mo(nn(Lo(e,t,n),t,n),t,n)),gr=Xo,tt=(e=[])=>e.find(t=>t.id==="story"),Vg="#000000",Vo="bg-cg-background-color",qg=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?ds(n?.backgroundColor??Vg,"screen.backgroundColor"):zo(e,t.colorId),hu=(e={})=>iu(e),Fg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Go=(e={})=>Array.isArray(e.filters)?e.filters:void 0,Wc=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=hu(e),o=Fg(e),a=Go(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),o&&(r.blur=o),a&&(r.filters=a),r},Bg=(e={})=>iu(e),Ug=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},gu=(e={})=>{let t=Bg(e),n=Ug(e),o={};return t!==void 0&&(o.alpha=t),n&&(o.blur=n),o},rt=(e={})=>{let t=gu(e),n=Go(e);return n&&(t.filters=n),t},Jc=(e,t,n,o)=>{let a=t[n]??e[n];return t[o]??e[o]??!1?(a??1)*-1:a},sr=(e={},t={})=>{let n={x:t.x??e.x,y:t.y??e.y,anchorX:t.anchorX??e.anchorX,anchorY:t.anchorY??e.anchorY,rotation:t.rotation??e.rotation,scaleX:Jc(e,t,"scaleX","flipX"),scaleY:Jc(e,t,"scaleY","flipY")},o=t.originX??e.originX,a=t.originY??e.originY;return o!==void 0&&(n.originX=o),a!==void 0&&(n.originY=a),n},Yg=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],Ho=(e={})=>e.text&&Qe(e.text,"content")&&Qe(e.text,"textStyleId"),Ko=(e={})=>e.layout&&Array.isArray(e.layout.elements),Qc=(e={})=>{if(e.resourceId)return e.resourceId;if(Ho(e))return"text";if(Ko(e))return"inline-layout"},Zc=(e,t={})=>typeof e=="string"?t.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?t.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return t.images?.[n]?.fileId??n;if(!n||typeof n!="object"||Array.isArray(n))return n;if(n.imageId){let{imageId:o,...a}=n;return{...a,src:t.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,zg=({item:e,particle:t,resources:n})=>{let o=vt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=Zc(r,n)),a.texture!==void 0&&(a.texture=Zc(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...sr(o,e)};return Object.assign(s,rt(e)),s},Xg=e=>{let t=[e.resourceId,e.text,e.layout].filter(n=>n!==void 0).length;if(t>1)throw t===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(e.text&&!Ho(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Ko(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of Yg)if(Qe(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},Gg=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:Vo,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:qg({resources:e,background:t,screen:n})};if(o){let r=hu(t);r!==void 0&&(a.alpha=r);let s=Go(t);s&&(a.filters=s)}return a},Hg=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,eu=({resources:e={},resourceId:t,colorId:n})=>{let o=fu(e,t);return t&&(o||n===void 0)?{resourceId:t,targetId:ls({resourceId:t,kind:o})}:n!==void 0?{resourceId:Vo,targetId:Vo}:{resourceId:void 0,targetId:void 0}},bu=100,jr=bu,Kg="channel:bgm",Wg="channel:music-room",Jg="music-room:player",Qg="channel:voice",Zg="default",ps=(e,t,n)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let r=n?` in ${n}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}o.add(a)})},wu=(e,t)=>e*t/bu,Wo=(e={},t)=>e?.[t]??$r[t],Jo=(e={},t,n=jr)=>wu(n,Wo(e,t)),ms=({id:e,volume:t,muted:n,pan:o,loop:a,playback:r,interruption:s,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),s!==void 0&&(c.interruption=s),c},as=(e,t,n,o)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:o,eb=["muted","pan","playbackRate","startAt","endAt"],ys=({id:e,sound:t,resource:n,projectResources:o,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:s=!1})=>{let i={id:e,type:"sound",src:n.fileId,loop:as(t,n,"loop",r),volume:as(t,n,"volume",jr),startDelayMs:as(t,n,"startDelayMs",0)};eb.forEach(c=>{let u=as(t,n,c,void 0);u!==void 0&&(i[c]=u)}),t.playback!==void 0&&(i.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=xc({selection:t[c],selectionPath:`${a}.${c}`,resources:o});u&&!s&&(i[c]=u)}let l=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<l)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${l}).`);return i},rb=e=>Math.max(-1,Math.min(1,e)),tb=({node:e,bgm:t,sound:n,resource:o,usesLegacySound:a})=>{a||(e.volume=wu(t.volume??jr,e.volume??jr));let r=t.muted!==void 0,s=n.muted!==void 0||o.muted!==void 0;(r||s)&&(e.muted=t.muted===!0||e.muted===!0);let i=t.pan!==void 0,l=n.pan!==void 0||o.pan!==void 0;return(i||l)&&(e.pan=rb((t.pan??0)+(e.pan??0))),e},Ge=({variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:r=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:b=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:g,skipTransitionsAndAnimations:A}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},E=ab({dialogueState:s,includeInactiveAdvDialogue:i,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:b,characters:y};return E&&(v.dialogue=E,v.dialogueLines=E.lines),v},ru=100,fs=(e,t)=>{if(Array.isArray(e))return e.map(o=>fs(o,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=fs(n[o],t)}),n.type==="text-revealing"?t(n):n},nb=e=>fs(e,t=>({...t,revealEffect:"none"})),sb=e=>fs(e,t=>{let n=Number(t.speed??t.displaySpeed),o=Number.isFinite(n)?Math.max(n,ru):ru;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),Nr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?nb(e):n?sb(e):e,Iu=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),qo=e=>{if(Array.isArray(e))return e.map(qo);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=qo(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let o=n.actions,a=o&&typeof o=="object"&&!Array.isArray(o)&&Object.prototype.hasOwnProperty.call(o,"nextLine")?{...o.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...n,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},ib=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),tu="submit",jo=(e,t,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},r=n.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...o,actions:r}}},Fo=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>Fo(c,t,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===tu,r=o&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Fo(u,t,c==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let c=t?.fields?.[l.field];if(c){let u={updateFormField:{formKey:t.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:jo(l.change,u),submit:jo(l.submit,t.submitActions)}}}return l.formRole===tu||r?{...l,click:jo(l.click,t.submitActions,{replaceActions:!0})}:l},Bo=(e,t)=>{if(Array.isArray(e))return e.map(o=>Bo(o,t));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=Bo(a,t);for(let o of ib){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},Uo=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,s=Gn({characterId:e,character:t,characterName:n,characters:o,variables:a});return{...r||{},...t||{},name:s}},vu=(e=[],t={},n={})=>e.map(o=>{let a=Uo({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:t,variables:n}),r=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(s=>s?.text??"").join(""):"";return{...o,text:r,character:a,characterName:a.name}}),ob=e=>!(!e||e.mode==="adv"&&e.content===void 0),ab=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:o,runtime:a}={})=>{if(!t&&!ob(e))return;let r=e.content===void 0?[{text:""}]:To(e.content,"dialogue.content"),s=e.content===void 0?0:xg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??$r.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,m)=>{let d=To(p.content,`dialogue.lines[${m}].content`),f=Uo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:d.map(h=>({...h,text:bt(h.text,{variables:o})})),character:f,characterName:f.name}}),u=Uo({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:bt(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},Qo=({container:e,resources:t,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=hr(e,n);return gr(Nr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},No=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),nu=({renderStateKeyboard:e,keyboard:t,phase:n})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([o,a])=>{let r=e[o]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...r,keydown:{payload:No(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:No(a.keyup)});return}e[o]={...r,[n]:{payload:No(a)}}})},lb=(e={},t={})=>{let n={};return nu({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),nu({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},br=({animationsDef:e,resources:t,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:r,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:w})=>{let g=Eg({resources:t,animationId:d,playback:f,instanceId:y,targetId:w,animationPath:s});g&&l.push(g)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,m=a&&r&&a===r;Pg(e,s);let d=bg(e),f=wg(e),h=t?.animations?.[d],b=gg(h,{animationId:d,animationPath:s});if(b==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(b==="transition"){let y=`${i}-animation-transition`,w=f?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&m)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},cb=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),ub=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:h,skipMode:b,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:A,saveSlots:k=[]})=>{let{elements:E,animations:v}=e;if(t.background){let O=o===void 0?!0:Qe(o?.background??{},"animations"),L=E.find(oe=>oe.id==="story");if(!L)return e;let C=Sg(a,t.background),D=C||Rg(t.background),B=n?.background?.resourceId,_=n?.background?.colorId,G=t.background.resourceId??(t.background.animations?B:void 0),fe=t.background.colorId??(t.background.animations?_:void 0),M=Hg(a,G),K={...t.background,colorId:fe};if((fe!==void 0||M)&&L.children.push(Gg({resources:a,background:K,screen:r,includeAlpha:!M})),G){let{images:oe={},videos:ne={},spritesheets:ue={}}=a,Z=fu(a,G),$;if(Z==="sprite"?$=oe[G]:Z==="video"?$=ne[G]:Z==="spritesheet-animation"&&($=ue[G]),$){let j=Z==="video",F=Z==="spritesheet-animation",J={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...C},de={...Wc(t.background,{includeDefaultAlpha:!0}),...sr(J,t.background)},Ie;F?Ie=Yo({id:ls({resourceId:G,kind:Z}),resourceId:G,spritesheet:$,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:de}):Ie={id:ls({resourceId:G,kind:Z}),type:j?"video":"sprite",src:$.fileId,width:$.width,height:$.height,...de},j&&(Ie.loop=t.background.loop??!1,Ie.volume=$.volume??50),Ie&&L.children.push(Ie)}}if(G){let{layouts:oe={}}=a,ne=oe[G];if(ne){let ue={id:ls({resourceId:G,kind:"container"}),type:"container",children:ne.elements,...Wc(t.background)};D&&Object.assign(ue,sr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...C},t.background));let Z=hr(ue,Ge({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:h,skipMode:b,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:A,characters:a.characters||{},skipTransitionsAndAnimations:i}));L.children.push(gr(Nr(Z,{isLineCompleted:s,skipMode:b,skipTransitionsAndAnimations:i}),a))}}let le=eu({resources:a,resourceId:B,colorId:_}),X=eu({resources:a,resourceId:G,colorId:fe}),te=br({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:X.resourceId,previousTargetId:le.targetId,currentTargetId:X.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ze({animationInstances:te,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:O})&&v.push(...te)}return e},pb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(w=>w.id==="story");if(!p)return e;let m=t.character.items||[],d=n?.character?.items||[],f=zc(m),h=zc(d),b=new Map,y=new Map;for(let w=0;w<d.length;w++){let g=d[w],A=b.get(g.id)??[];A.push(w),b.set(g.id,A)}for(let w=0;w<m.length;w++){let g=m[w],{transformId:A,sprites:k}=g,E=y.get(g.id)??0;y.set(g.id,E+1);let v=b.get(g.id)?.[E]??-1,O=d[v],L=O?.sprites&&O.sprites.length>0,C=k&&k.length>0,D=v>=0?Xc(O,v,h):void 0,B=C?Xc(g,w,f):void 0,_=pu(o,"character",g.id,w,m),G=br({animationsDef:g.animations,resources:a,previousResourceId:D,currentResourceId:B,previousTargetId:D,currentTargetId:B,animationPath:`character.items[${w}].animations`,idPrefix:B??D??`character-${w}`});if(g.animations&&!k&&!A&&L&&Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})){u.push(...G);continue}if(g.animations&&!k&&!A)continue;if(!k||k.length===0||!A){console.warn("Character item missing sprites or transformId:",g);continue}let fe=a.transforms[A];if(!fe){console.warn("Transform not found:",A);continue}let M={type:"container",id:B,...sr(fe,g),...rt(g),children:[]};for(let K of k){let le=du({id:`${B}-${K.id}`,item:K,resources:a});le&&M.children.push(le)}p.children.push(M),Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})&&u.push(...G)}}return e},ku=(e,t)=>{if(!So.includes(e))throw new Error(`${t} must be one of: ${So.join(", ")}.`)},fb=(e,t)=>{let n=!!e.resourceId||Ho(e)||Ko(e),o=e.layer??(n?void 0:t?.layer)??xo;return ku(o,`Visual item "${e.id}" layer`),o},db=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:m,restoredPersistentAnimations:d,autoMode:f,skipMode:h,isChoiceVisible:b,isFormVisible:y,canRollback:w,form:g,saveSlots:A=[],visualLayer:k})=>{let{elements:E,animations:v}=e;if(t.visual&&a){let O=E.find(B=>B.id==="story");if(!O)return e;let L=t.visual.items,C=n?.visual?.items||[],D=Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:A,dialogueState:t.dialogue,isLineCompleted:r,autoMode:f,skipMode:h,isChoiceVisible:b,isFormVisible:y,canRollback:w,form:g,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&ku(k,"visualLayer");for(let[B,_]of L.entries()){let G=C.find(ne=>ne.id===_.id),fe=pu(o,"visual",_.id,B,L),M=fb(_,G);if(k!==void 0&&M!==k)continue;if(Xg(_),_.layout){let ne=vt(a,_),ue={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...sr(ne,_)};Object.assign(ue,rt(_)),O.children.push(Qo({container:ue,resources:a,templateData:D,isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}))}if(_.text){let ne=vt(a,_),ue={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...sr(ne,_)};Object.assign(ue,rt(_)),O.children.push(gr(hr(ue,D),a))}if(_.resourceId){let{images:ne={},videos:ue={},spritesheets:Z={}}=a,$=Z[_.resourceId];if($){let j=vt(a,_),F=rt(_),J=Yo({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:$,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...sr(j,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});J&&O.children.push(structuredClone(J))}else{let j=ne[_.resourceId]||ue[_.resourceId];if(j){let F=ue[_.resourceId]!==void 0,J=vt(a,_),de={id:`visual-${_.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...sr(J,_)};Object.assign(de,rt(_)),F&&(de.loop=j.loop??!1,de.volume=j.volume??50),O.children.push(de)}}}let K=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!K){let ne=a.particles?.[_.resourceId];ne&&O.children.push(zg({item:_,particle:ne,resources:a}))}let le=!!a.particles?.[_.resourceId];if(_.resourceId&&!K&&!le){let{layouts:ne={}}=a,ue=ne[_.resourceId];if(ue){let Z=vt(a,_),$={id:`visual-${_.id}`,type:"container",children:structuredClone(ue.elements),...sr(Z,_)};Object.assign($,rt(_));let j=hr($,D);O.children.push(gr(Nr(j,{isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}),a))}}let X=Qc(G),te=Qc(_),oe=br({animationsDef:_.animations,resources:a,previousResourceId:X,currentResourceId:te,previousTargetId:X?`visual-${_.id}`:void 0,currentTargetId:te?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ze({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:m,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:fe})&&v.push(...oe)}}return e},It="dialogue-character-sprite",mb=(e,{presentationState:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=tt(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=qt(c),m=qt(u),d=br({animationsDef:c?.animations,resources:o,previousResourceId:m?It:void 0,currentResourceId:p?It:void 0,previousTargetId:m?It:void 0,currentTargetId:p?It:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&Ze({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e;let f=o.transforms?.[c.transformId];if(!f)return console.warn("Transform not found:",c.transformId),e;let h={type:"container",id:It,...sr(f),children:[]};for(let b of c.items){let y=du({id:`${It}-${b.id}`,item:b,resources:o});y&&h.children.push(y)}return l.children.push(h),Ze({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e},yb=(e,{presentationState:t,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:h,musicRoom:b,sceneReplay:y,runtime:w,activePersistentAnimations:g,saveSlots:A=[]})=>{let{elements:k,animations:E}=e;if(!t.dialogue||a)return e;let v=k.find(L=>L.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:L={}}=o,C=L[t.dialogue.ui.resourceId];if(C){let D={elements:C.elements},B=Ge({variables:f,imageGallery:h,musicRoom:b,sceneReplay:y,runtime:w,saveSlots:A,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),_=hr(D,B),G=gr(Nr(_?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(G))for(let fe of G)v.children.push(fe);else G&&v.children.push(G)}}mb(e,{presentationState:t,previousPresentationState:n,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:g});let O=br({animationsDef:t.dialogue.ui?.animations,resources:o,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return Ze({animationInstances:O,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:g})&&E.push(...O),e},hb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:b,form:y,activePersistentAnimations:w,saveSlots:g=[]})=>{let{elements:A,animations:k}=e;if(t.choice&&o){let E=tt(A);if(!E)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let L={elements:v.elements},C=hr(L,{...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f??!!t.choice,isFormVisible:h,canRollback:b,form:y,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),D=qo(gr(Nr(C?.elements,{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(D))for(let B of D)E.children.push(B);else D&&E.children.push(D)}let O=br({animationsDef:t.choice.animations,resources:o,previousResourceId:n?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});Ze({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},gb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:b,activePersistentAnimations:y,saveSlots:w=[],form:g})=>{let{elements:A,animations:k}=e;if(!g?.resourceId||!o)return e;let E=tt(A);if(!E)return e;let v=o?.layouts?.[g.resourceId];if(!v)return console.warn(`Form layout not found: ${g.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},L={...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:b,characters:o.characters||{},skipTransitionsAndAnimations:s,form:g}),form:g},C=hr(O,L),D=Bo(gr(Nr(Fo(C,g),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o),g);D&&E.children.push(D);let B=br({animationsDef:g.animations,resources:o,previousResourceId:n?.form?.resourceId,currentResourceId:g.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:g.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ze({animationInstances:B,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...B),e},bb=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],skipTransitionsAndAnimations:b})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=lb(y.keyboard,y.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(y.elements)||y.elements.length===0)return e;let g=tt(e.elements);if(!g)return e;let A={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return g.children.push(Qo({container:A,resources:n,templateData:Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:b}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:b})),e},Zo=({presentationState:e,previousBgmRender:t,resources:n={},runtime:o,variables:a,musicRoomPlayer:r,skipTransitionsAndAnimations:s=!1})=>{if(e?.bgm&&n){let i=e.bgm,l=!Array.isArray(i.sounds),c=ns(i),u=!l&&i.loop===!0,p=[];if(l||ps(c,"BGM sound"),u){let f=c.find(h=>h.loop===!0);if(f)throw new Error(`BGM sound "${f.id}" cannot loop inside a looping BGM channel.`)}let m=gc({bgm:i,resources:n,previousBgmRender:t});if(c.forEach(f=>{let h=n.sounds?.[f.resourceId];if(!h)return;let b=u?{...f,loop:f.loop??!1}:f;p.push(tb({node:ys({id:m.get(f.id),sound:b,resource:h,projectResources:n,soundPath:`bgm.sounds[${JSON.stringify(f.id)}]`,defaultLoop:!u,skipTransitionsAndAnimations:s}),bgm:i,sound:b,resource:h,usesLegacySound:l}))}),p.length===0)return null;let d=Ge({variables:a,runtime:o}).runtime;return ms({id:Kg,volume:Wo(d,"musicVolume"),muted:!1,pan:0,loop:l?void 0:i.loop,playback:r?.bgmPlayback,interruption:i.interruption,children:p,runtime:d})}return null},wb=(e,t)=>{if(!tt(e.elements))return e;let o=Zo(t);return o&&e.audio.push(o),e},Ib=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:n})=>(t?.length>0&&!n&&(e.audioEffects=structuredClone(t)),e),vb=(e,{resources:t={},runtime:n,variables:o,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let s=r.tracks.find(u=>u.id===a.trackId),i=s?t.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=Ge({variables:o,runtime:n}).runtime,c=ys({id:Jg,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(ms({id:Wg,volume:Jo(l,"musicVolume",jr),children:[c],runtime:l})),e},kb=(e,{presentationState:t,resources:n,runtime:o,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&n){let s=t.sfx,i=Array.isArray(s.channels)?s.channels:[],l=i.map(c=>({channel:c,usesLegacyChannel:!1}));ps(i,"SFX channel"),Array.isArray(s.items)&&l.push({channel:{id:Zg,sounds:s.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,m=[];if(u||ps(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let d=c.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((d,f)=>{let h=n.sounds?.[d.resourceId];if(!h)return;let b=p?{...d,loop:d.loop??!1}:d;m.push(ys({id:u?tr("sfx","default",f,d.id):tr("sfx",c.id,d.id),sound:b,resource:h,projectResources:n,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(d.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),m.length!==0&&r.push(ms({id:tr("channel","sfx",c.id),volume:Jo(o,"soundVolume",c.volume??jr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:m,runtime:o}))})}return e},Ab=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},Pb=(e,{presentationState:t,resources:n,currentSceneId:o,runtime:a,variables:r,skipTransitionsAndAnimations:s})=>{let{audio:i}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:jr,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,m=[];if(c||ps(u,"Voice sound"),p){let f=u.find(h=>h.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(f=>{let h=Ab(n,o,f.resourceId);if(!h)return;let b=p?{...f,loop:f.loop??!1}:f;m.push(ys({id:tr("voice",o,c?"default":f.id),sound:b,resource:h,projectResources:n,soundPath:`voice.sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:s}))}),m.length===0)return e;let d=Ge({variables:r,runtime:a}).runtime;return i.push(ms({id:Qg,volume:c?l.volume??Wo(d,"soundVolume"):Jo(d,"soundVolume",l.volume??jr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:m,runtime:d})),e},Eb=(e,{presentationState:t,previousPresentationState:n,resources:o={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],isLineCompleted:b,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:g,animations:A}=e;if(t.layout){let O=tt(g);if(!O)return e;let L=o.layouts?.[t.layout.resourceId];if(!L)return e;let C={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:L.elements||[]};O.children.push(Qo({container:C,resources:o,templateData:Ge({variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:b,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:b,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,E=t.layout?.resourceId,v=br({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:E,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:E?`layout-${E}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ze({animationInstances:v,isLineCompleted:b,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&A.push(...v),e},xb=(e,{currentLineActions:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=t?.screen?.animations;if(!l)return e;let c=n!=null,u=br({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ze({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...u),e},Sb=(e,{presentationState:t})=>{let n=tt(e.elements);return!n||!t?.screen||Object.assign(n,gu(t.screen)),e},Ob=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:h=[],saveSlots:b=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:A}=e;return f&&f.length>0&&f.forEach((k,E)=>{let v=n.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[Iu({id:`overlayStack-${E}-blocker`,screen:y}),...v.elements||[]]},L=vu(h,n.characters,o),C=Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:b,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:L,characters:n.characters||{},skipTransitionsAndAnimations:g}),D=hr(O,C),[B,..._]=D.children||[],G=gr(Nr({...D,children:_},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:g}),n);A.push({...G,children:B?[B,...G.children||[]]:G.children})}),e},Rb=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,dialogueHistory:b=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:A}=e;if(!h?.resourceId)return e;let k=n.layouts?.[h.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${h.resourceId}`),e;let E={id:"confirmDialog",type:"container",x:0,y:0,children:[Iu({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=vu(b,n.characters,o),O=hr(E,Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,historyDialogue:v,characters:n.characters||{},skipTransitionsAndAnimations:g})),[L,...C]=O.children||[],D=gr(Nr({...O,children:C},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:g}),n);return A.push({...D,children:L?[L,...D.children||[]]:D.children}),e},sn=e=>(t,n)=>db(t,{...n,visualLayer:e}),Cb=sn(yr.BEHIND_BACKGROUND),$b=sn(yr.BEHIND_CHARACTER),_b=sn(yr.BEHIND_DIALOGUE),jb=sn(yr.BEHIND_CHOICE),Nb=sn(yr.FOREGROUND),Au=e=>Xn(cb,[bb,Cb,ub,$b,pb,_b,yb,jb,hb,gb,Eb,Nb,Sb,xb,wb,vb,kb,Pb,Ib,Ob,Rb])(e);function Pu(e,t=""){let n=[],o=e.length,a=0,r=0,s=-1,i=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,t?parseInt(t[r++],36):0])}return n}function Eu(e,t,n){let o=0,a=t.length-1;for(;o<=a;){let r=o+a>>>1,s=n[r];if(e<t[r])a=r-1;else if(e>s>>>5)o=r+1;else return s&31}return 0}var xu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Su="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Ou="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Ru=65535,ea=40960,hs=126976,_u=new Uint8Array(12288),ju=new Uint8Array(3072),Nu=new Uint8Array(2816),Du,Tu;{let e=(a,r,s,i,l)=>{let c=r+a.length-1;for(let u=s<r?r:s,p=i>c?c:i;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,r,s]of Pu(xu,Su))e(_u,0,a,r,s),e(ju,ea,a,r,s),e(Nu,hs,a,r,s),r>=65040&&!(a>=hs&&r<=129791)&&(t[o]=a,n[o++]=r<<5|s);Du=t.slice(0,o),Tu=n.slice(0,o)}function Cu(e){return e<12288?_u[e]:e<ea?e<12336?e>=12330?3:0:e<12443?e===12336||e===12349?4:e>=12441?3:0:e===12951||e===12953?4:0:e<44032?ju[e-ea]:e<55204?(e-44032)%28?8:7:e<57344?e<=55238?e>=55216?13:0:e>=55243&&e<=55291?12:0:e<65024?e===64286?3:0:e<65040?3:e>=hs&&e<129792?Nu[e-hs]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Eu(e,Du,Tu)}var Lu=Uint8Array.from(Ou,Number);function Db(e){return e===2381||e===2509||e===2637||e===2765||e===2893||e===3149||e===3405||e===4153||e===6098||e===6752||e===6980||e===7083||e===43456||e===43766||e===68159||e===69939||e===70608||e===71998||e===72263||e===72345||e===73538}function $u(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Db(n)?e&6|16:e&6|8:e&6;case 4:return 2;case 10:return e&1^1;case 14:return(e&2)<<1|e&24;default:return 8}}function*Mu(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),o=n>Ru?2:1,a=Cu(n),r=50200>>a&1?$u(0,a,n):0,s=0,i=n,l=a;for(;o<t;){n=e.codePointAt(o);let c=n>Ru?2:1,u=Cu(n),p=Lu[a<<4|u],m;p===0?m=!0:p===1?m=!1:p===2?m=!(r&1):p===3?m=!(r&4):m=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?$u(r,u,n):0,m&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=o,i=n,l=u),o+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Vu(e){for(let t of Mu(e))yield t.segment}{let e=Mu("_");Lu._keep=[e,e.next()]}var qu=1e3,Yu=50,Tb=0,Fu=100,Bu=50,Lb=60,Mb=3,Vb=.5,qb=2e4,Fb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Bb=/^\s+$/u,Uu,Ub=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Vu(t)):(Uu??=new n(void 0,{granularity:"grapheme"}),Array.from(Uu.segment(t),({segment:o})=>o))},Yb=e=>Ub(e).reduce((t,n)=>Bb.test(n)?t+Vb:Fb.test(n)?t+Mb:t+1,0),zb=e=>2**(((Number.isFinite(e)?Math.min(Fu,Math.max(Tb,e)):Yu)-Bu)/(Fu-Bu)),ra=({text:e="",baseDelay:t=qu,speed:n=Yu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):qu,a=zb(n),r=Yb(e)*Lb/a,s=Math.max(o,qb);return Math.min(o+r,s)};var gs={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Wu=1,wr=1,Et="choice",Tr="form",cn=()=>({manual:{...gs.manual},auto:{...gs.auto},applyMode:gs.applyMode}),da=()=>({groupId:null,variantId:null,pageIndex:0}),Xb="music-room:player",Gb=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Is=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),ma=new Set,Hb=new Set(["groupId","variantId"]),Kb=new Set(["pageIndex"]),xt=new Set,Wb=new Set(["trackId"]),Jb=new Set(["positionMs"]),Qb=new Set(["pageIndex"]),ya=new Set,Zb=new Set(["sceneId"]),ew=new Set(["pageIndex"]),ha=()=>({pageIndex:0}),ga=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...cn()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},na=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},q=e=>{let t=Pe(e)?Er(e):e;return structuredClone(t)},V=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),vs=e=>{let t=e.global.audioCommandId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal audio command counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=t+1,e.global.audioCommandId},Ju=e=>{let t=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal scene replay entry counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=t+1,e.global.sceneReplayEntryId},un=(e,t,n)=>({commandId:vs(e),operation:t,...n===void 0?{}:{positionMs:n}}),ba=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:vs(e),operation:"resume"}),e.global.musicRoomPlayer=Is({bgmPlayback:n})},Qu=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=e.projectData.resources?.achievements?.[t];if(!n)throw new Error(`Achievement resource "${t}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${n.type}"`);return n},Zu=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${t} requires a non-empty string or finite number slotId`)},it=e=>String(e),ep=()=>({sections:[],resources:[]}),rp=()=>({sceneIds:[]}),rw=e=>V(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):ep(),tw=e=>V(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):rp(),nw=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",sw=({sectionId:e,lineId:t,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:n,text:nw(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),tp=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),iw=e=>V(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,wa=e=>{if(!V(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},ow=e=>{if(!V(e?.dialogueHistory))return e.dialogueHistory=tp(e?.rollback?.timeline?.length??0),e.dialogueHistory;let t=e.dialogueHistory;return Array.isArray(t.entries)||(t.entries=[]),Number.isInteger(t.currentLength)||(t.currentLength=t.entries.length),Array.isArray(t.checkpointLengths)||(t.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),t.currentLength=Math.min(Math.max(t.currentLength,0),t.entries.length),t},Ia=e=>{let t=wa(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},aw=()=>({resourceId:void 0}),lw=e=>{if(!V(e))return e;let t={...e};return Object.prototype.hasOwnProperty.call(t,"requireComplete")&&!Object.prototype.hasOwnProperty.call(t,"requireLineCompleted")&&(t.requireLineCompleted=t.requireComplete),delete t.requireComplete,t},Ir=(e,t)=>{let n=e?.story?.scenes??{};for(let[o,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:o,section:a.sections[t]};return{sceneId:void 0,section:void 0}},np=e=>{let t=e?.story?.scenes??{},n=new Map;for(let[o,a]of Object.entries(t)){let r=a?.sections??{};for(let s of Object.keys(r)){let i=n.get(s);if(i!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);n.set(s,o)}}},sp=e=>e,ip=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Wu)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},cw=(e,t={})=>{let n;try{n=ip(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:n,slotId:sp(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},uw=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,cw(t,n)])),pw=(e,t)=>{if(!V(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!V(o))return!1;let{variableId:a,op:r,value:s,roundTo:i}=o,l=t?.resources?.variables?.[a];if(!l||_e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Gt(l.type,r,a),Kn(l.type,r,s,a,{roundTo:i}),r!=="set"||co(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},op=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!V(o)||!H0(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=pw(o.payload,t);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},fw=(e,t,n)=>{let{section:o}=Ir(e,t?.sectionId),r=o?.lines?.find(({id:i})=>i===t?.lineId)?.actions,s=n.split(".");for(let i of s){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(i))return;let l=Number(i);if(!Object.prototype.hasOwnProperty.call(r,l))return;r=r[l];continue}if(!V(r)||!Object.prototype.hasOwnProperty.call(r,i))return;r=r[i]}return s.at(-1)==="random"&&V(r?.distribution)?r:void 0},ap=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let t=e.max-e.min+1;return Number.isSafeInteger(t)&&t>=1&&t<=4294967296},lp=(e,t,n)=>e.filter(({path:o,type:a,result:r})=>{let s=fw(n,t,o);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return V(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let i=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&i?.type==="number"&&i.scope==="context"&&i.readonly!==!0&&!_e(i)&&ap(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),va=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==wr)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let n=new Set,o=e.randomOutcomes.map((a,r)=>{let s=`${a?.path}\0${a?.ordinal}`;if(!V(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||n.has(s))throw new Error(`invalid rollback random outcome at index ${r}`);return n.add(s),{path:a.path,ordinal:a.ordinal,type:a.type,result:Zn(q(a.result),a.type)}});return t===void 0?o:lp(o,e,t)},dw=(e,t)=>{!V(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!V(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=op(n.executedActions,t);o?n.executedActions=o:delete n.executedActions;let a=va(n,t);a?(n.randomOutcomeVersion=wr,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},mw=(e,t)=>{let n=e??{};return Object.values(n).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let s=r?.rollback?.timeline;Array.isArray(s)&&s.forEach(i=>{if(!V(i))return;let l=va(i,t);l?(i.randomOutcomeVersion=wr,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),n},zu=(e,t,n,o="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!V(e))throw new Error(`Malformed ${o}.${t}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${t}[${n}] entry: missing ${a}.`);if(t==="sections"){let r={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${o}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},yw=(e,t="viewedRegistry")=>{if(e===void 0)return ep();if(!V(e))throw new Error(`Malformed ${t}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${t}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${t}.resources.`);let n=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,r)=>{let s=zu(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let s=zu(a,"resources",r,t);return[s.resourceId,s]})))}},hw=(e,t="accountReplayRegistry")=>{if(e===void 0)return rp();if(!V(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return o}))]}},on=(e,t,n)=>{if(!V(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:r,section:s}=Ir(t,o);if(!s)throw new Error(`Malformed save slot ${n}: section "${o}" does not exist in projectData.`);if(!s.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${n}: line "${a}" does not exist in section "${o}".`);return{sceneId:r,sectionId:o,lineId:a}},cp=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],o=n.initialSectionId,a=n.sections[o];return on({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},gw=e=>{try{return cp(e),!0}catch{return!1}},bw=(e,t,n)=>{let o=e?.pointers?.read;if(!V(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return on(o,t,n);try{return on(o,t,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],r=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=r;s>=0;s-=1)try{return on(a[s],t,`${n} compatibility checkpoint`)}catch{}return cp(t)}};var up=(e,t)=>{let{section:n}=Ir(e,t?.sectionId);return n?.lines?.find(o=>o.id===t?.lineId)},ww=(e,t,n)=>{if(!V(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],r=!1;if(e.entries.forEach((i,l)=>{if(!V(i))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:c}=Ir(t,i.sectionId);if(!c?.lines?.some(p=>p.id===i.lineId)){r=!1,a.push(o.length);return}o.push({sectionId:i.sectionId,lineId:i.lineId,...i.appendToPrevious===!0&&r&&o.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(o.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:s}},Iw=(e,t)=>V(up(e,t)?.actions?.dialogue),pp=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:o}=Ir(e,n.sectionId),a=o?.lines?.findIndex(s=>s.id===n.lineId);return typeof a!="number"||a<=0?!1:o.lines.slice(0,a).findLast(s=>V(s.actions?.dialogue))?.id===t.lineId},vw=(e,t)=>{let n=tp();return e.timeline.forEach(o=>{if(o.returnable!==!1&&Iw(t,o)){let a=up(t,o),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&pp(t,r,o);n.entries.push({sectionId:o.sectionId,lineId:o.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},kw=(e,t,n,o)=>{if(n.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==o)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,s)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=r}),e},Aw=(e,t,n)=>{if(!V(e)||!Array.isArray(e.timeline))return{rollback:ln({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!V(c))return[];let p=va(c);try{let m=on(c,n,`rollback.timeline[${u}]`),d=p?lp(p,m,n):void 0,f=ws({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...d?{randomOutcomeVersion:wr,randomOutcomes:d}:{}}),h=op(q(c.executedActions),n);return h&&(f.executedActions=h),o.push(u),[f]}catch{return[]}});if(a.length===0)return{rollback:ln({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,s=o.indexOf(r);s<0&&(s=a.length-1);let i=a[s];if(i?.sectionId!==t.sectionId||i?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?s=c:(a.push(ws({sectionId:t.sectionId,lineId:t.lineId})),o.push(null),s=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),s):0;return{rollback:{currentIndex:s,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:o,sourceTimelineLength:e.timeline.length}},fp=(e,t,n)=>{if(!V(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Aa(t),a=bw(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!V(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!V(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?zt(q(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=Tw({loadedContextRuntime:V(e.runtime)?q(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Aw(e.rollback,a,t),u=e.dialogueHistory===void 0?vw(i,t):kw(ww(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:V(e.configuration)?q(e.configuration):{},views:Array.isArray(e.views)?q(e.views):[],bgm:V(e.bgm)?q(e.bgm):{resourceId:void 0},variables:{...o,...r},...u?{dialogueHistory:u}:{},rollback:i};return s&&(p.runtime=s),p},Pw=(e,t)=>{if(!V(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((n,o)=>fp(n,t,o))}},Ew=(e,t)=>{if(!V(e))throw new Error("Malformed save slot.");let n=ip(e.formatVersion);return{...e,formatVersion:n,state:Pw(e.state,t)}},Xu=(e,t,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${t}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${t} must be an action object`);let o=q(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},xw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:Xu(e.confirmActions,"confirmActions",{required:!0}),cancelActions:Xu(e.cancelActions,"cancelActions")}},St=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Sw=e=>(V(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Ot=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},dp=e=>{if(!(!V(e)||!e.animations))return{animations:q(e.animations)}},Ow=(e,t)=>{let n=dp(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Rw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},Cw=(e,t)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!t))return`${n}:${o}:${t}`},bs=e=>String(e??""),mp=(e,t)=>{let n=bs(t);return e?.trim===!0?n.trim():n},$w=e=>V(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>V(t)).map(([t,n])=>[t,{id:t,...q(n)}])):{},_w=(e,t)=>{if(!t||!V(e.global.formDrafts))return;let n=e.global.formDrafts[t];return V(n)?n:void 0},yp=(e,t)=>{let n=Sw(e);V(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let o=n[t];return V(o.values)||(o.values={}),V(o.touched)||(o.touched={}),V(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},ka=(e,t)=>{let n=mp(e,t);return e?.required===!0&&n.length===0?"required":null},jw=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let o=xe({state:e},{sectionId:t.sectionId})?.lines||[],a=o.findIndex(r=>r.id===t.lineId);return a<0?{}:et(o.slice(0,a+1).map(r=>r.actions||{}),{resources:e.projectData.resources})},Nw=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let o=Rw(t),a=Cw(n,o);if(!o||!a)return null;let r=_w(e,a),s=$w(t),i=Ta({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=bs(i?.[d.variableId]),h=Object.prototype.hasOwnProperty.call(r?.values??{},m)?bs(r.values[m]):f,b=r?.touched?.[m]===!0,y=ka(d,h),w=r?.submitted||b?y:null,g=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,A={id:m,variableId:d.variableId,value:h,initialValue:f,valid:!y,error:w,touched:b,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...g!==void 0?{maxLength:g}:{}};y&&(p=!1),l[m]=A,c.push(A),u[m]=h}),{id:o,key:a,resourceId:t.resourceId,animations:t.animations,valid:p,submitted:r?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:q(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:q(t.cancelActions??{})}}}},Pt="line",Dr="interaction",ws=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:o,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{},...a===wr?{randomOutcomeVersion:wr,randomOutcomes:q(r??[])}:{}}),Aa=e=>{let t=Pe(e)?Er(e):e,{contextVariableDefaultValues:n}=Hn(t??{});return q(n)},hp=()=>({...q(en)}),gp=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:q(n),hasLoadedValues:!1};if(!V(e))throw new Error(`Malformed ${o}.`);let a=q(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=os(s,q(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Dw=({projectData:e,loadedGlobalRuntime:t={}})=>gp({loadedRuntime:t,runtimeIds:Ao,defaults:Eo(e),path:"global.runtime"}).runtimeState,Tw=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=gp({loadedRuntime:e,runtimeIds:Po,defaults:hp(),path:"context.runtime"});return n?t:void 0},Mr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ye=e=>{let t=Mr(e);return t?.kind==="sceneReplay"&&V(t.sceneReplay)?t:null},bp=(e,t)=>{let n=t?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=q(r)})},Lw=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:q(e.global.nextLineConfig),overlayStack:q(e.global.overlayStack),confirmDialog:q(e.global.confirmDialog),formDrafts:q(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:q(e.global.pendingScreenTransition)}}),Mw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Vw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=q(t.nextLineConfig),e.global.overlayStack=q(t.overlayStack),e.global.confirmDialog=q(t.confirmDialog),e.global.formDrafts=q(t.formDrafts),e.global.isLineCompleted=t.isLineCompleted,t.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=t.isDialogueHistoryShowing,t.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=q(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Se({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}}),e.global.skipMode&&!n&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!n&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},qw=e=>e.runtime?(Po.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=q(en[t]))}),e.runtime):(e.runtime=hp(),e.runtime),Fw=e=>Uc(e.global),wp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Fw(e)}})},Pa=(e,t,n)=>{let o=os(t,n);if(t in en){let a=Mr(e);if(!a)return o;let r=qw(a);return r[t]=o,o}return e.global[t]=o,o},Ea=({pointer:e,projectData:t,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:q(o)},currentPointerMode:"read",pointers:{read:q(e)},configuration:{},views:[],bgm:aw(),variables:Aa(t),rollback:ln({pointer:e})}),Rt=e=>e?(e.currentPointerMode="read",V(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,Bw=(e,{queueRender:t=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],o=n?.pointers?.read;if(!n||!o?.sectionId||!o?.lineId)return null;let a=Ea({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Uw(e,{queueRender:t}),a},Uw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,St(e),Ot(e),e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,ba(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Ip=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},ln=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[ws({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Vr=(e,t={})=>{if(e?.rollback)return Ip(e.rollback),Array.isArray(e.rollback.timeline)||(e.rollback.timeline=[]),typeof e.rollback.currentIndex!="number"&&(e.rollback.currentIndex=e.rollback.timeline.length>0?e.rollback.timeline.length-1:-1),typeof e.rollback.isRestoring!="boolean"&&(e.rollback.isRestoring=!1),typeof e.rollback.replayStartIndex!="number"&&(e.rollback.replayStartIndex=0),e.rollback;let n=e?.pointers?.read;return e.rollback=ln({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},ks=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=Vr(n);if(o.isRestoring)return;let a=Ia(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(ws(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},Yw=({state:e})=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;return!Array.isArray(n?.timeline)||typeof n.currentIndex!="number"?null:{checkpointIndex:n.currentIndex,checkpoint:n.timeline[n.currentIndex]??null}},zw=({state:e},t={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:a,lineId:r}=t,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[n];return(Pe(l)?Nn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},Xw=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:s}=t,i=it(n),l=e.global.saveSlots?.[i],c=Pe(l)?Nn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||d?.sectionId!==r||d?.lineId!==s||(d.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},vp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:o.currentIndex;if(r<0||r>=o.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<o.timeline.length-1){o.timeline=o.timeline.slice(0,r+1);let s=Ia(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},Gw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},o={})=>{let a=o?.source===Pt?Pt:Dr,r=e.contexts?.[e.contexts.length-1],s=r?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let u=Ia(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let i=r?.pointers?.read,l=n?.lineEntryId,c=a===Pt&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===i?.sectionId&&s.timeline[s.currentIndex]?.lineId===i?.lineId:n.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:s.currentIndex,source:a,...a===Pt?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Hw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),Kw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let o=t?.at(-1);if(o?.source!==Pt||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;ks(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let s=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=s.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,n?.lineEntryId===o.lineEntryId&&(n.rollbackCheckpointLineEntryId=o.lineEntryId),e},Ww=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==Pt)return e;if(typeof n?.path!="string"||n.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(n.ordinal)||n.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=Zn(n.result,n.type),r=vp(e,t);if(!r)return e;if(r.randomOutcomeVersion!==wr&&(r.randomOutcomeVersion=wr,r.randomOutcomes=[]),r.randomOutcomes.some(({path:s,ordinal:i})=>s===n.path&&i===n.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${n.path}#${n.ordinal}`);return r.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:a}),e},ir=(e,t,n,o)=>{let r=o?.at(-1)?.source??Dr;if(!K0(t,r))return;let s=vp(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:q(n)}))},sa=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=t?.operations??[];for(let{variableId:a,op:r,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(_e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Xt(c,a),Gt(u,r,a),Kn(u,r,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=Wn(n.variables[a],r,s,{roundTo:i}))}},Jw=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:o})=>{W0(e,n,o)})},Qw=(e,t)=>{let{sectionId:n,lineId:o}=t,s=xe({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Fa(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},kp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=Vr(n),a=o.timeline[t];if(!a)return e;e.global.autoMode&&mn({state:e}),e.global.skipMode&&Lr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{n.variables=Aa(e.projectData),n.kind==="sceneReplay"&&(bp(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=q(gs),e.global.overlayStack=[],St(e),Ot(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&ga(e),Qw(e,o.timeline[l]),Jw(e,o.timeline[l]);let s=Rt(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=wa(n);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Ju(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},Zw=e=>{let{projectData:t}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:r={},runtime:s={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;np(t),Bt(t),Ut(t),Yt(t),Qr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],m=p.initialSectionId,d=p.sections[m],f={sceneId:u,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:h}=Hn(t),b={...h,...zt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:yw(i,"accountViewedRegistry"),accountReplayRegistry:hw(l),nextLineConfig:cn(),imageGalleryNavigation:da(),sceneReplayNavigation:ha(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:Is(),saveSlots:uw(a),localizationPackages:q(c),overlayStack:[],variables:b,...Dw({projectData:t,loadedGlobalRuntime:s})},contexts:[Ea({pointer:f,projectData:t})]}},eI=({state:e})=>e.global.overlayStack||[],rI=({state:e})=>e.global.pendingEffects,Ap=({state:e})=>e.global.skipMode,tI=({state:e})=>e.global.autoMode,Pp=({state:e})=>e.global.dialogueUIHidden,Ep=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let o,a=V(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)o=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=n.pointers.read,p=xe({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let m=p.lines.findIndex(d=>d.id===u);o=p.lines.slice(0,m+1).map(d=>({sectionId:c,lineId:d.id}))}let r=[],s=ht({variables:{...e.global?.variables??{},...Mr(e)?.variables??{}},runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let m=xe({state:e},{sectionId:c.sectionId}),d=Array.isArray(m?.lines)?m.lines:[];u={lines:d,lineIndexes:new Map(d.map((f,h)=>[f.id,h])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let m=u.lines[u.nextLineIndex],d=m.actions||{};u.presentationState=et([u.presentationState,d],{resources:e.projectData.resources}),u.projections.set(m.id,{line:m,lineActions:d,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!iw(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:m,dialogueState:d}=u;if(!m.dialogue)continue;let f=Gn({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:s}),h=sw({sectionId:c.sectionId,lineId:p.id,content:m.dialogue.append===!0?d.content:m.dialogue.content,dialogueState:d,characterName:f}),b=r[r.length-1];if((a?c.appendToPrevious===!0:m.dialogue.append===!0)&&b?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:h.content,text:h.text,characterId:h.characterId,character:h.character,characterName:h.characterName};continue}r.push(h)}return r},nI=(e,t,n)=>{let o=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:s,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[it(r)],u=Pe(c)?Nn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=q(n),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},sI=({state:e},t={})=>{let n=Mr(e),o=n?.pointers?.read,a=fn({state:e});if(!n||!V(a?.actions?.dialogue))return e;let r=Vr(n),s=r.timeline?.[r.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=wa(n),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||t.forceNewOccurrence!==!0&&i&&l&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let m=ow(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&pp(e.projectData,p,o);if(m.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,i){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return nI(e,t.savedCheckpointOccurrences,m),e},iI=({state:e})=>e.global.confirmDialog??null,pn=({state:e},{pointer:t}={})=>{let n=t??qe({state:e})?.pointer,o=jw({state:e,pointer:n});return Nw({state:e,form:o.form,pointer:n})},oI=({state:e},{pointer:t}={})=>!!pn({state:e},{pointer:t}),Se=({state:e},{pointer:t}={})=>{let n=pn({state:e},{pointer:t});if(n)return{source:Tr,formId:n.id,formKey:n.key};let o=$p({state:e,pointer:t});return o?{source:Et,resourceId:o}:null},aI=({state:e,registry:t},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let i=xe({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=i.lines.findIndex(u=>u.id===s.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},xa=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},Sa=({state:e},t)=>aI({state:e,registry:e.global.accountViewedRegistry},t),lI=({state:e},t)=>xa({registry:e.global.accountViewedRegistry},t),an=(e,t)=>!xa({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Oa=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Ra=(e,t)=>{let n=Oa(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},ia=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!an(e,t[a]))return t[a]},cI=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:q(t)},xp=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??da(),o=Oa(t),a=Ra(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:an(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:an(e,c)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(d=>d.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(d=>d.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/t.pageSize);p&&m===a&&!an(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ia(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:ia(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Ca=(e,t)=>!xa({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),$a=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),_a=(e,t)=>{let n=$a(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},oa=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!Ca(e,t[a]))return t[a]},Sp=e=>({trackId:e.id,soundId:e.soundId,title:e.title,artist:e.artist??null,album:e.album??null,description:e.description??null,coverImageId:e.coverImageId??null}),uI=(e,t)=>({...Sp(t),locked:Ca(e,t)}),Gu=e=>{let t=Math.floor(e/1e3),n=t%60,o=Math.floor(t/60);if(o<60)return`${o}:${String(n).padStart(2,"0")}`;let a=Math.floor(o/60),r=o%60;return`${a}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},pI=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:q(t)},Op=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??Is(),o=$a(t),a=_a(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>uI(e,u)),i=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[i],c=l?{...Sp(l),canPlayPreviousTrack:oa(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:oa(e,t.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Gu(n.positionMs),durationText:n.durationMs===null?null:Gu(n.durationMs),canPlay:n.status!=="playing",canPause:n.status==="playing",canSeek:n.readiness==="ready"&&n.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},ja=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Na=(e,t)=>{let n=ja(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},fI=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:q(t)},dI=({state:e})=>ye(e)!==null,mI=({state:e})=>{let t=ye(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Rp=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,Cp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??ha(),o=ja(t),a=Na(t,n),r=a*t.pageSize,s=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!Rp(e,l.sceneId)})),i=ye(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},yI=({state:e})=>e.global.nextLineConfig,$p=({state:e,pointer:t}={})=>{let n=t??qe({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=xe({state:e},{sectionId:o})?.lines||[],i=s.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of s.slice(0,i+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},_p=({state:e})=>!!$p({state:e}),hI=({state:e})=>structuredClone(e),gI=({state:e})=>q(e.projectData.resources?.achievements??{}),bI=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:q(n)},jp=({state:e})=>e.global.saveSlots,wI=({state:e},t)=>{let n=t?.slotId,o=it(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Np=({state:e})=>q(e.global.localizationPackages),Da=({state:e})=>_r(e),II=({state:e},t)=>nr(e,t?.runtimeId),Ta=({state:e})=>{let t={...e.global?.variables??{},...Mr(e)?.variables??{}};return ht({variables:t,runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{}})},qe=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},xe=({state:e},t)=>{let{sectionId:n}=t;return Ir(e.projectData,n).section},fn=({state:e})=>{let t=qe({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:o}=t.pointer,a=xe({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===o)},Dp=({state:e})=>{let{sectionId:t,lineId:n}=qe({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===n),i=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(m=>{p[m]=u[m]}),p});return et(i,{resources:e.projectData.resources})},Tp=e=>{let t=fn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=ht({variables:{...e.global?.variables??{},...Mr(e)?.variables??{}},runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${bt(o?.text,{variables:n})??""}`).join("")},vr=({state:e})=>ra({text:Tp(e),baseDelay:nr(e,"autoForwardDelay"),speed:nr(e,"autoForwardSpeed")}),vI=({state:e})=>{let t=Lp({state:e}),o=fn({state:e})?.actions??{},a=et([t??{},o],{resources:e.projectData.resources});return po(t??{},a??{})},kI=({state:e},{sectionId:t})=>{let n=xe({state:e},{sectionId:t});if(!n?.lines)return[];let o=[],a={};for(let r of n.lines){let s=r.actions||{},i=et([a,s],{resources:e.projectData.resources}),l=po(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=fo(i)}return o},AI=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let o=kI({state:e},{sectionId:t});return n?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},Lp=({state:e})=>{let{sectionId:t,lineId:n}=qe({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===n);if(r<=0)return null;let i=a.slice(0,r).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return fo(et(i,{resources:e.projectData.resources}))},La=({state:e},{slotsPerPage:t=6}={})=>{let a=((Da({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let s=0;s<t;s++){let i=a+s,l=e.global.saveSlots&&e.global.saveSlots[it(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},PI=jp,EI=La,Ma=e=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;return!n||!Array.isArray(n.timeline)||typeof n.currentIndex!="number"?!1:n.currentIndex>=0&&n.currentIndex<n.timeline.length-1},xI=({state:e},t={})=>{let n=Dp({state:e}),o=Lp({state:e}),a=fn({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:q(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=qe({state:e}).pointer,{sceneId:c}=Ir(e.projectData,l),u={...Da({state:e}),localizationPackages:Np({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=pn({state:e}),f=_p({state:e}),h=xp({state:e}),b=Op({state:e}),y=Cp({state:e}),w=Ta({state:e}),{saveSlots:g}=La({state:e}),A=Ma(e);return Au({presentationState:n,previousBgmRender:t?.previousBgmRender,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:af({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||A,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:Ep({state:e}),saveSlots:g,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:h,musicRoom:b,sceneReplay:y,musicRoomPlayer:q(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},SI=({state:e},t)=>(e.global.confirmDialog=xw(t),e.global.pendingEffects.push({name:"render"}),e),OI=({state:e})=>(e.global.confirmDialog&&(St(e),e.global.pendingEffects.push({name:"render"})),e),RI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),ir(e,"pushOverlay",n,t),e),CI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),ir(e,"popOverlay",void 0,t),e),$I=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),ir(e,"replaceLastOverlay",n,t),e),_I=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],St(e),Ot(e),e.global.pendingEffects.push({name:"render"}),ir(e,"clearOverlays",void 0,t),e),jI=(e,{activeInteraction:t})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),t&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},dn=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Ow(e,n),Ot(e);let o=Se({state:e},{pointer:t}),a=o?.source===Et,r=o?.source===Tr;jI(e,{activeInteraction:o});let s=ye(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Ju(e);s.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:r,activeInteraction:o}},As=(e,t,n)=>{!(t?.source===Et||t?.source===Tr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Mp=({state:e})=>(Se({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),mn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),NI=({state:e})=>{let t=e.global.autoMode;return Se({state:e})&&!t||(t?mn({state:e}):Mp({state:e})),e},Vp=({state:e})=>(Se({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Lr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),DI=({state:e})=>{let t=Ap({state:e});return Se({state:e})&&!t||(t?Lr({state:e}):Vp({state:e})),e},Ps=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),ir(e,"showDialogueUI",void 0,t),e),qp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),ir(e,"hideDialogueUI",void 0,t),e),TI=e=>{let{state:t}=e;return Pp({state:t})?Ps(e):qp(e),t},qr=(e,t,n)=>(Pa(e,t,n),wp(e),e.global.pendingEffects.push({name:"render"}),e),yn=(e,t,n,o,a)=>{let r=Pa(e,t,n);return e.global.pendingEffects.push({name:"render"}),ir(e,o,{value:r},a),e},LI=({state:e},t)=>qr(e,"dialogueTextSpeed",t?.value),MI=({state:e},t)=>(qr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}}),e),VI=({state:e},t)=>(qr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}}),e),qI=({state:e},t)=>qr(e,"skipUnseenText",t?.value),FI=({state:e},t)=>qr(e,"skipTransitionsAndAnimations",t?.value),BI=({state:e},t)=>qr(e,"soundVolume",t?.value),UI=({state:e},t)=>qr(e,"musicVolume",t?.value),YI=({state:e},t)=>qr(e,"muteAll",t?.value),aa=({state:e,rollbackActionBatchStack:t},n)=>yn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),la=({state:e,rollbackActionBatchStack:t})=>{let n=nr(e,"saveLoadPagination")+1;return yn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},ca=({state:e,rollbackActionBatchStack:t})=>{let n=nr(e,"saveLoadPagination")-1;return yn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},ua=({state:e,rollbackActionBatchStack:t},n)=>yn(e,"menuPage",n?.value,"setMenuPage",t),pa=({state:e,rollbackActionBatchStack:t},n)=>yn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),zI=({state:e})=>(e.global.pendingEffects=[],e),XI=({state:e},t)=>(e.global.pendingEffects.push(t),e),GI=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId;return Qu(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},HI=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId,o=Qu(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${n}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let r=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:r,target:o.target,completed:r>=o.target}}),e},Fp=e=>e?.lines?.[0],Bp=(e,{sectionId:t,resetStoryState:n=!1,screen:o})=>{let a=!!dp(o),r=xe({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=Fp(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!Bw(e,{queueRender:!a}))return e;let i=Se({state:e});n&&e.global.skipMode&&Lr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Rt(l),p=u.read;n||st(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Vr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=ln({pointer:u.read}):ks(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=dn(e,l?.pointers?.read,{screenTransition:o});return As(e,i,c),e},KI=({state:e},t)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return Bp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Up=e=>(e.global.accountViewedRegistry=rw(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Es=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(n=>({scope:n.scope,path:n.path,op:n.op,value:q(n.value)}))}})},Yp=(e,t)=>{Es(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},WI=(e,t,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=V(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(s=>s.sectionId===n);if(r){if(r.lastLineId===void 0)return!1;let s=xe({state:e},{sectionId:n});if(s?.lines){let i=s.lines.findIndex(c=>c.id===r.lastLineId),l=s.lines.findIndex(c=>c.id===o);if(i===-1||l>i)return r.lastLineId===o?!1:(r.lastLineId=o,!0)}else return r.lastLineId===o?!1:(r.lastLineId=o,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:o}),!0},st=(e,t)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;WI(e,Up(e),t)&&Yp(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},JI=({state:e},t)=>(st(e,t),e.global.pendingEffects.push({name:"render"}),e),QI=({state:e},t)=>{if(ye(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let o=Up(e);o.resources.find(r=>r.resourceId===n)||(o.resources.push({resourceId:n}),Yp(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},or=(e,t,n)=>{if(!V(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},fa=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},xs=(e,t)=>{let n=e.global.imageGalleryNavigation;n.groupId===t.groupId&&n.variantId===t.variantId&&n.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},ZI=({state:e},t)=>{let n="showImageGalleryVariant";or(n,t,Hb),fa(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&fa(n,"variantId",t.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let a=o.groups.findIndex(i=>i.id===t.groupId),r=o.groups[a];if(!r)return e;let s=t.variantId===void 0?r.variants[0]:r.variants.find(i=>i.id===t.variantId);return!s||an(e,s)||xs(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},zp=(e,t,n,o)=>{or(o,t,ma);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let r=e.global.imageGalleryNavigation;if(typeof r.groupId!="string"||typeof r.variantId!="string")return e;let s=a.groups.find(c=>c.id===r.groupId),i=s?.variants.findIndex(c=>c.id===r.variantId);if(!s||i===void 0||i<0)return e;let l=ia(e,s.variants,i,n);return l&&xs(e,{...r,variantId:l.id}),e},e0=({state:e},t)=>zp(e,t,-1,"moveToPreviousImageGalleryVariant"),r0=({state:e},t)=>zp(e,t,1,"moveToNextImageGalleryVariant"),t0=({state:e},t)=>{if(or("clearImageGallerySelection",t,ma),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return xs(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},Xp=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=Oa(n);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=Ra(n,a);return t===r||xs(e,{groupId:null,variantId:null,pageIndex:t}),e},n0=({state:e},t)=>{if(or("moveToImageGalleryPage",t,Kb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Xp(e,t.pageIndex)},Gp=(e,t,n,o)=>{or(o,t,ma);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Ra(a,e.global.imageGalleryNavigation)+n;return s<0?e:Xp(e,s)},s0=({state:e},t)=>Gp(e,t,1,"moveToNextImageGalleryPage"),i0=({state:e},t)=>Gp(e,t,-1,"moveToPreviousImageGalleryPage"),kr=(e,t,n)=>{if(!V(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},o0=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},er=e=>{e.global.pendingEffects.push({name:"render"})},Hp=(e,t)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,r=o.trackId===t.id,s=o.bgmPlayback;a||(s={commandId:vs(e),operation:"pause"});let i=un(e,"play",0),l=n.tracks.indexOf(t),c=r?o.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:s},er(e)},a0=({state:e},t)=>{let n="playMusicRoomTrack";kr(n,t,Wb),o0(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Ca(e,a)||Hp(e,a),e},l0=({state:e},t)=>{kr("playMusicRoom",t,xt);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",r=o.readiness==="error",s=o.status==="paused"&&!r?"resume":"play",i=a?0:o.positionMs;return o.playback=un(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),er(e),e},c0=({state:e},t)=>{kr("pauseMusicRoom",t,xt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=un(e,"pause"),o.seekFallback=null,o.status="paused",er(e)),e},u0=({state:e},t)=>{kr("stopMusicRoom",t,xt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=un(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,er(e)),e},p0=({state:e},t)=>{if(kr("seekMusicRoom",t,Jb),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let o=e.global.musicRoomPlayer;if(o.trackId===null||o.readiness!=="ready"||o.durationMs===null||t.positionMs>o.durationMs)return e;let a=un(e,"seek",t.positionMs);return o.seekFallback={commandId:a.commandId,status:o.status,positionMs:o.positionMs},o.playback=a,o.positionMs=t.positionMs,t.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),er(e),e},Kp=(e,t,n,o)=>{kr(o,t,xt);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===r.trackId);if(s<0)return e;let i=oa(e,a.tracks,s,n);return i&&Hp(e,i),e},f0=({state:e},t)=>Kp(e,t,-1,"playPreviousMusicRoomTrack"),d0=({state:e},t)=>Kp(e,t,1,"playNextMusicRoomTrack"),m0=({state:e},t)=>{kr("clearMusicRoomSelection",t,xt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:vs(e),operation:"resume"};return e.global.musicRoomPlayer={...Is({bgmPlayback:r}),pageIndex:a},er(e),e},Wp=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=$a(n))return e;let o=e.global.musicRoomPlayer,a=_a(n,o);return t===a||(o.pageIndex=t,er(e)),e},y0=({state:e},t)=>{if(kr("moveToMusicRoomPage",t,Qb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Wp(e,t.pageIndex)},Jp=(e,t,n,o)=>{kr(o,t,xt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=_a(a,e.global.musicRoomPlayer)+n;return r<0?e:Wp(e,r)},h0=({state:e},t)=>Jp(e,t,1,"moveToNextMusicRoomPage"),g0=({state:e},t)=>Jp(e,t,-1,"moveToPreviousMusicRoomPage"),nt=e=>{let t=ye(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=q(t.sceneReplay.returnState),o=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),Vw(e,n),e.global.pendingEffects.push({name:"render"}),!0},b0=({state:e},t)=>{let n="startSceneReplay";if(or(n,t,Zb),fa(n,"sceneId",t.sceneId),ye(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!Rp(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,i=r?.sections?.[s],l=i?.initialLineId??i?.lines?.[0]?.id;if(!i||!l||!i.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=Lw(e);Mw(e);let u=Ea({pointer:{sceneId:a.sceneId,sectionId:s,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return bp(e,u),e.contexts.push(u),dn(e,u.pointers.read),e},Qp=({state:e},t)=>{or("finishSceneReplay",t,ya);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Mr(e)?.rollback?.isRestoring===!0)return e;let r=qe({state:e})?.pointer,{sceneId:s}=Ir(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=tw(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Es(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},w0=({state:e},t)=>(or("exitSceneReplay",t,ya),nt(e),e),Zp=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=ja(n))return e;let o=Na(n,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},I0=({state:e},t)=>{if(or("moveToSceneReplayPage",t,ew),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Zp(e,t.pageIndex)},ef=(e,t,n,o)=>{or(o,t,ya);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Na(a,e.global.sceneReplayNavigation)+n;return r<0?e:Zp(e,r)},v0=({state:e},t)=>ef(e,t,1,"moveToNextSceneReplayPage"),k0=({state:e},t)=>ef(e,t,-1,"moveToPreviousSceneReplayPage"),Ss=(e,t)=>{let n=e.global.musicRoomPlayer;return!V(t)||t.id!==Xb||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Va=e=>typeof e.positionMs=="number"&&Number.isFinite(e.positionMs)&&e.positionMs>=0&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>0&&e.positionMs<=e.durationMs,rf=(e,t,n,{readiness:o=t.readiness}={})=>((t.readiness!==o||t.positionMs!==n.positionMs||t.durationMs!==n.durationMs||t.seekFallback!==null)&&(t.readiness=o,t.positionMs=n.positionMs,t.durationMs=n.durationMs,t.seekFallback=null,er(e)),e),A0=({state:e},t)=>{let n=Ss(e,t);return!n||n.readiness!=="loading"||!Va(t)?e:rf(e,n,t,{readiness:"ready"})},P0=({state:e},t)=>{let n=Ss(e,t);return!n||n.readiness!=="ready"||!Va(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:rf(e,n,t)},E0=({state:e},t)=>{let n=Ss(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Va(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,er(e)),e},x0=({state:e},t)=>{let n=Ss(e,t);if(!n||typeof t.errorCode!="string"||!Gb.has(t.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(t.errorCode==="invalid-position"){let o=n.seekFallback;if(n.playback.operation!=="seek"||o?.commandId!==t.commandId)return e;let a=n.status!==o.status||n.positionMs!==o.positionMs;return n.status=o.status,n.positionMs=o.positionMs,n.seekFallback=null,a&&er(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,er(e),e},tf=({state:e,rollbackActionBatchStack:t},n)=>{let o=lw(n.manual),{auto:a,applyMode:r}=n,s=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=Se({state:e});return!u&&(a!==void 0&&(p!==s||m!==i||d!==l))&&(!f&&p===!0&&(m==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:d}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),ir(e,"setNextLineConfig",n,t),e},S0=({state:e},t)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;Zu(n,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=it(n),s=q(e.contexts);s?.forEach(c=>{Rt(c),Ip(c.rollback),dw(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:Wu,slotId:sp(n),savedAt:typeof a=="number"?a:Date.now(),image:o,state:i};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},O0=({state:e},t)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;Zu(n,"loadSlot");let o=it(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=Ew(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,St(e),Ot(e),ba(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},R0=({state:e},t)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;np(n),Bt(n),Ut(n),Yt(n),Qr(n?.resources?.variables??{}),Eo(n);let o=gw(n),a=o?e.contexts?.map((s,i)=>fp(q(s),n,i)):void 0,r=o?mw(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=da(),e.global.sceneReplayNavigation=ha(),ba(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:i}=Hn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...zt(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return St(e),Ot(e),o&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},C0=({state:e},t)=>{let{l10nId:n,projectData:o}=t??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!V(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,Pa(e,"localizationPackageId",n),wp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},$0=({state:e},t)=>{let{sectionId:n,lineId:o}=t;if(!o)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let r=n||a.pointers.read?.sectionId;if(n&&!xe({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=xe({state:e},{sectionId:r});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${r} has no lines`),e;if(!s.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${r}`),e;let l=Se({state:e}),c=Rt(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=dn(e,c.read);return As(e,l,u),e},_0=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Ps({state:e,rollbackActionBatchStack:t}),e;let o=Se({state:e});if(o?.source===Et&&n?.bypassChoice!==!0||o?.source===Tr&&n?._interactionSource!==Tr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return nt(e),e;let d=qe({state:e})?.pointer,f=d?.sectionId,h=d?.lineId;f&&h&&st(e,{sectionId:f,lineId:h}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}});let b=e.global.nextLineConfig,y=xe({state:e},{sectionId:f});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===h?na(e):b?.auto?.enabled&&!o&&b.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:b.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ye(e)?.sceneReplay.finishOnNextAdvance)return nt(e),e;let r=qe({state:e})?.pointer,s=r?.sectionId,i=xe({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(m=>m.id===r?.lineId)+1;if(p<c.length){let m=c[p],d=!nr(e,"skipUnseenText");if(e.global.skipMode&&d&&!Sa({state:e},{sectionId:s,lineId:m.id}))return Lr({state:e}),e;if(l&&!l.rollback&&Vr(l,{compatibilityAnchor:!0}),l){let h=Rt(l),b=h.read?.lineId;b&&s&&st(e,{sectionId:s,lineId:b}),h.read={sectionId:s,lineId:m.id}}ks(e,{sectionId:s,lineId:m.id}),ga(e);let{activeInteraction:f}=dn(e,{sectionId:s,lineId:m.id});As(e,o,f)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),nt(e),e;e.global.autoMode&&mn({state:e}),e.global.skipMode&&Lr({state:e}),na(e)}return e},j0=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return nt(e),e;let n=Se({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}});let o=qe({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&st(e,{sectionId:a,lineId:r});let s=e.global.nextLineConfig;return s?.auto?.enabled&&!n&&s.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:s.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},N0=({state:e},t)=>Bp(e,{sectionId:t?.sectionId,screen:t?.screen}),D0=({state:e,rollbackActionBatchStack:t},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return Ps({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:vr({state:e})}}),e;let a=Se({state:e});if(a?.source===Et&&n?.bypassChoice!==!0||a?.source===Tr&&n?._interactionSource!==Tr||a&&a.source!==Et&&a.source!==Tr)return e;let r=ye(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(nt(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=qe({state:e})?.pointer,i=s?.sectionId,l=xe({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=u.findIndex(d=>d.id===s?.lineId)+1;if(m<u.length){let d=u[m],f=!nr(e,"skipUnseenText");if(e.global.skipMode&&f&&!Sa({state:e},{sectionId:i,lineId:d.id})&&(Lr({state:e}),!o))return e;if(c&&!c.rollback&&Vr(c,{compatibilityAnchor:!0}),c){let b=Rt(c),y=b.read?.lineId;y&&i&&st(e,{sectionId:i,lineId:y}),b.read={sectionId:i,lineId:d.id}}ks(e,{sectionId:i,lineId:d.id}),ga(e);let{activeInteraction:h}=dn(e,{sectionId:i,lineId:d.id});As(e,a,h)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),nt(e),e;e.global.autoMode&&mn({state:e}),e.global.skipMode&&Lr({state:e}),na(e)}return e},qa=(e,t={})=>{let n=pn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},T0=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],o=n?.scope,a=n?.type;if(_e(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Xt(o,t.variableId),Gt(a,"set",t.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},L0=(e,t)=>({id:e.id,key:e.key,valid:!0,values:q(t),fields:q(e.fields),fieldList:q(e.fieldList)}),M0=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=qe({state:e})?.pointer,n=t?.sectionId,o=t?.lineId;n&&o&&st(e,{sectionId:n,lineId:o})},V0=({state:e},t={})=>{let n=qa(e,t),o=t.field;if(!n?.fields?.[o])return e;let a=yp(e,n.key),r=bs(t.value),s=n.fields[o],i=ka(s,r);return a.values[o]=r,a.touched[o]=!0,i?a.errors[o]=i:delete a.errors[o],e.global.pendingEffects.push({name:"render"}),e},q0=({state:e,rollbackActionBatchStack:t},n={})=>{let o=qa(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=yp(e,o.key);a.submitted=!0;let r={},s={};if(Object.entries(o.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,h=ka(d,f);a.touched[m]=!0,h&&(s[m]=h),r[m]=mp(d,f)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:q(s),form:{id:o.id,key:o.key,values:q(r)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([m,d])=>{let{scope:f}=T0(e,d),h=f==="context"?i.variables:e.global.variables,b=r[m];h[d.variableId]=Wn(h[d.variableId],"set",b),f==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:b})),(f==="device"||f==="account")&&c.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:q(h[d.variableId])})}),l&&ir(e,"updateVariable",{id:"submitForm",operations:u},t),Es(e,c);let p=L0(o,r);return M0(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},F0=({state:e},t={})=>{let n=qa(e,t);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:q(n.values),fields:q(n.fields),fieldList:q(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},B0=({state:e,rollbackActionBatchStack:t},n)=>{let{id:o,operations:a=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let s=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=e.projectData.resources?.variables?.[c],f=d?.scope,h=d?.type;if(_e(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Xt(f,c),Gt(h,u,c),Kn(h,u,p,c,{roundTo:m}),ye(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let b=f==="context"?r.variables:e.global.variables;if(f==="context"){s=!0;let y={variableId:c,op:u,value:p};m!==void 0&&(y.roundTo=m),l.push(y)}b[c]=Wn(b[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&i.push({scope:f,path:`variables.${c}`,op:"set",value:q(b[c])})}),s&&ir(e,"updateVariable",{id:o,operations:l},t),Es(e,i),e.global.pendingEffects.push({name:"render"}),e},He=e=>(t,n)=>e({state:t},n),nf=e=>({variables:ht({variables:{...e.global?.variables??{},...Mr(e)?.variables??{}},runtime:_r(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:_r(e)}),U0=e=>{if(!V(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},Y0=(e,t,n)=>{if(!V(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!V(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==n-1)throw new Error("conditional else branch must be the last branch")},z0=(e,t,n,o)=>{U0(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(Y0(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Ft(r.when,{...nf(e),...n?.bindings??{}}))){Fa(e,r.actions,n,[...o,"branches",String(a),"actions"]);return}}},X0=(e,t,n,o)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==wr)return;let r=o.join("."),s=n.randomOutcomeOrdinals,i=s.get(r)??0;s.set(r,i+1);let l=a.randomOutcomes?.find(p=>p.path===r&&p.ordinal===i);if(!l)return;if(t?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${r}`);let c=Zn(q(l.result),l.type);if(c.type==="integer"){if(!ap(t.distribution)||c.value<t.distribution.min||c.value>t.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${r}`);sa(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!V(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Fa(e,u,n,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},G0={conditional:{replayLine:z0},random:{replayLine:X0},updateVariable:{recordSources:[Dr],replayLine:sa,replayRecorded:sa,persistInSaveSlot:!0},setNextLineConfig:{replayLine:He(tf)},setSaveLoadPagination:{recordSources:[Dr],replayLine:He(aa),replayRecorded:He(aa),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Dr],replayLine:He(la),replayRecorded:He(la),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Dr],replayLine:He(ca),replayRecorded:He(ca),persistInSaveSlot:!0},setMenuPage:{recordSources:[Dr],replayLine:He(ua),replayRecorded:He(ua),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Dr],replayLine:He(pa),replayRecorded:He(pa),persistInSaveSlot:!0},finishSceneReplay:{replayLine:He(Qp)}},Os=e=>G0[e]??null,H0=e=>Os(e)?.persistInSaveSlot===!0,K0=(e,t)=>{let n=Os(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},W0=(e,t,n)=>{Os(t)?.replayRecorded?.(e,n)},J0=(e,t,n,o,a)=>{let r=Os(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,o,a);return}let s=o?.bindings??{},i=Ht({[t]:n},{...nf(e),...s})[t];r.replayLine(e,i)},Fa=(e,t,n,o)=>{let a=es(t);ts(a);for(let[r,s]of a)J0(e,r,s,n,[...o,r])},Q0=e=>e?.returnable!==!1,sf=(e,t)=>{if(t>=0)return e.currentIndex+t;let n=Math.abs(t);for(let o=e.currentIndex-1;o>=0;o-=1)if(Q0(e.timeline[o])&&(n-=1,n===0))return o;return-1},of=({state:e},t)=>{let{offset:n}=t;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let o=e.contexts[e.contexts.length-1];if(!o)return null;let a=o.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=sf(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},af=({state:e})=>of({state:e},{offset:-1})!==null,Z0=({state:e},t)=>{let{offset:n=-1}=t;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=Vr(o,{compatibilityAnchor:!o.rollback}),r=sf(a,n);return r<0||r>=a.timeline.length?e:kp(e,r)},ev=({state:e},t)=>{let{sectionId:n,lineId:o}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=Vr(a,{compatibilityAnchor:!a.rollback}),i=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${n} rollback timeline`);return i===r.currentIndex?e:kp(e,i)},rv=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),ta=(e,t)=>{let n=e[t];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${t} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=n+1,e[t]},Hu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Ku=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},tv=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,lf=e=>{let t=e.global?.nextLineConfig?.auto;return t?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:t.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:t.delay??1e3}},Ba=e=>JSON.stringify(lf(e)),nv=({actionName:e,args:t,state:n,previousState:o})=>{let a=Hu(o),r=Hu(n);if(!tv(a,r)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Ku(o)!==Ku(n))return!0;let s=t[0]??{};if(e==="jumpToLine"){let i=s.sectionId??a?.sectionId;return typeof s.lineId=="string"&&r?.sectionId===i&&r?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=Ir(n.projectData,s.sectionId).section,l=Fp(i)?.id;return typeof l=="string"&&r?.sectionId===s.sectionId&&r?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let i=s.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},it(i))}return!1},sv=({actionName:e,args:t,state:n,transactionalMetadata:o,previousState:a})=>{if(nv({actionName:e,args:t,state:n,previousState:a})){let u=ta(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:Ba(n)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let s=(a.contexts?.length??0)>(n.contexts?.length??0),i=e==="startAutoMode"||e==="startSkipMode"?Se({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&ta(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&ta(o,"skipSessionId")},iv=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==Ba(e))&&(t.rollbackAuthoredSuppression=null)},ov=({state:e,playbackOwnership:t})=>{let n=Se({state:e}),o=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=lf(e),i=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===Ba(e)),c=a?Tp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:ra({text:c,baseDelay:nr(e,"autoForwardDelay"),speed:nr(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:s.delayMs,trigger:s.trigger}:null}},av=({playbackOwnership:e})=>e.lineEntryId,cf=(e,t={})=>{let n=Zw(e),o=[],a=t.createPlaybackOwnership??rv;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return Ql(n,{selectPendingEffects:rI,selectSkipMode:Ap,selectAutoMode:tI,selectIsChoiceVisible:_p,selectIsFormVisible:oI,selectActiveInteraction:Se,selectActiveForm:pn,selectDialogueUIHidden:Pp,selectDialogueHistory:Ep,selectConfirmDialog:iI,selectIsLineAccountViewed:Sa,selectIsResourceAccountViewed:lI,selectImageGalleryConfig:cI,selectImageGallery:xp,selectMusicRoomConfig:pI,selectMusicRoom:Op,selectSceneReplayConfig:fI,selectSceneReplay:Cp,selectIsSceneReplayActive:dI,selectActiveSceneReplayEntry:mI,selectNextLineConfig:yI,selectSystemState:hI,selectAchievements:gI,selectAchievement:bI,selectSaveSlotMap:jp,selectSaveSlots:PI,selectSaveSlot:wI,selectLocalizationPackages:Np,selectRuntime:Da,selectRuntimeValue:II,selectAllVariables:Ta,selectCurrentPointer:qe,selectSection:xe,selectCurrentLine:fn,selectPresentationState:Dp,selectAutoForwardTimerDelay:vr,selectPresentationChanges:vI,selectSectionLineChanges:AI,selectSaveSlotPage:La,selectCurrentPageSlots:EI,selectRenderState:xI,selectOverlayStack:eI,selectLineIdByOffset:of,selectCanRollback:af,selectRollbackCursor:Yw,selectDesiredPlaybackTimers:ov,selectPlaybackLineEntryId:av,startAutoMode:Mp,stopAutoMode:mn,toggleAutoMode:NI,startSkipMode:Vp,stopSkipMode:Lr,toggleSkipMode:DI,showDialogueUI:Ps,hideDialogueUI:qp,toggleDialogueUI:TI,setDialogueTextSpeed:LI,setAutoForwardDelay:MI,setAutoForwardSpeed:VI,setSkipUnseenText:qI,setSkipTransitionsAndAnimations:FI,setSoundVolume:BI,setMusicVolume:UI,setMuteAll:YI,setSaveLoadPagination:aa,incrementSaveLoadPagination:la,decrementSaveLoadPagination:ca,setMenuPage:ua,setMenuEntryPoint:pa,showConfirmDialog:SI,hideConfirmDialog:OI,resetStoryAtSection:KI,clearPendingEffects:zI,appendPendingEffect:XI,completeAchievement:GI,setAchievementProgress:HI,beginRollbackActionBatch:Gw,endRollbackActionBatch:Hw,ensureRandomReplayOccurrence:Kw,recordRandomOutcome:Ww,markRollbackCheckpointTransient:zw,markSavedRollbackCheckpointTransient:Xw,recordCurrentDialogueHistory:sI,addViewedLine:JI,addViewedResource:QI,showImageGalleryVariant:ZI,moveToPreviousImageGalleryVariant:e0,moveToNextImageGalleryVariant:r0,clearImageGallerySelection:t0,moveToImageGalleryPage:n0,moveToNextImageGalleryPage:s0,moveToPreviousImageGalleryPage:i0,playMusicRoomTrack:a0,playMusicRoom:l0,pauseMusicRoom:c0,stopMusicRoom:u0,seekMusicRoom:p0,playPreviousMusicRoomTrack:f0,playNextMusicRoomTrack:d0,clearMusicRoomSelection:m0,moveToMusicRoomPage:y0,moveToNextMusicRoomPage:h0,moveToPreviousMusicRoomPage:g0,musicRoomSoundReady:A0,musicRoomSoundProgress:P0,musicRoomSoundComplete:E0,musicRoomSoundError:x0,startSceneReplay:b0,finishSceneReplay:Qp,exitSceneReplay:w0,moveToSceneReplayPage:I0,moveToNextSceneReplayPage:v0,moveToPreviousSceneReplayPage:k0,setNextLineConfig:tf,saveSlot:S0,loadSlot:O0,updateProjectData:R0,updateLocalizationPackage:C0,sectionTransition:N0,jumpToLine:$0,nextLine:_0,markLineCompleted:j0,rollbackToLine:ev,rollbackByOffset:Z0,pushOverlay:RI,popOverlay:CI,replaceLastOverlay:$I,clearOverlays:_I,updateFormField:V0,submitForm:q0,cancelForm:F0,updateVariable:B0,nextLineFromSystem:D0},{createTransactionalMetadata:a,updateTransactionalMetadata:sv,finalizeTransactionalMetadata:iv,transformActionFirstArgument:(s,i)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(s,i)=>({state:s,playbackOwnership:i})})};var lv="route-engine",cv="projectPersistence";var pf=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),be=e=>Object.prototype.toString.call(e)==="[object Object]",uf="variables.",uv=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!be(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lineId=="string"?{lineId:n.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!be(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},pv=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!be(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lastLineId=="string"?{lastLineId:n.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!be(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},fv=(e,t)=>{let n=pv(e),o=uv(t),a=n.sections.map(s=>({...s})),r=n.resources.map(s=>({...s}));return o.sections.forEach(s=>{let i=a.find(l=>l.sectionId===s.sectionId);if(!i){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(i.lastLineId!==void 0){if(s.lineId===void 0){delete i.lastLineId;return}i.lastLineId=s.lineId}}),o.resources.forEach(s=>{r.find(l=>l.resourceId===s.resourceId)||r.push({...s})}),{sections:a,resources:r}},dv=(e={})=>{let t=be(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},mv=(e,t)=>{let n=dv(e),o=be(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},ff=(e={})=>{let t=be(e)?e:{};return{saveSlots:be(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:be(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:be(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:be(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:be(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:be(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},yv=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!be(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=t.path?.startsWith(uf)?t.path.slice(uf.length):null;if(o!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${n}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return{scope:t.scope,path:t.path,op:t.op,value:t.value,variableId:o}}if(t.path==="viewedRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);if(!be(t.value)||!Array.isArray(t.value.sceneIds)||t.value.sceneIds.length===0||t.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${n}].`)})},hv=(e,t)=>{let n={};return yv(t).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=fv(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=mv(n.accountReplayRegistry??e.accountReplayRegistry,o.value);return}let a=o.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[a]={...e[a],...n[a],[o.variableId]:o.value}}),n},Ct=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},gv=e=>{let t=Ct(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},bv=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},wv=({indexedDB:e,databaseName:t,objectStoreName:n})=>new Promise((o,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},r.onsuccess=()=>{o(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),Iv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let l=o.transaction(t,"readonly").objectStore(t).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},hn=async({databasePromise:e,objectStoreName:t,namespace:n,patch:o})=>{let a=await e;return new Promise((r,s)=>{let i=a.transaction(t,"readwrite"),l=i.objectStore(t),c=l.get(n),u=!1,p=d=>{u||(u=!0,s(d))},m=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=ff(c.result),f=typeof o=="function"?o(d):o,h={namespace:n,version:1,...pf(),...d,...f},b=l.put(h);b.onerror=()=>{p(b.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},i.oncomplete=()=>{m()},i.onerror=()=>{p(i.error??new Error(`IndexedDB transaction failed while updating namespace "${n}".`))},i.onabort=()=>{p(i.error??new Error(`IndexedDB transaction aborted while updating namespace "${n}".`))}})},vv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let s=o.transaction(t,"readwrite"),l=s.objectStore(t).delete(n),c=!1,u=m=>{c||(c=!0,r(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{u(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{u(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},Ua=(e={})=>{let{indexedDB:t,databaseName:n=lv,objectStoreName:o=cv,namespace:a}=e,r=bv(t),s=gv(a),i=wv({indexedDB:r,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await Iv({databasePromise:i,objectStoreName:o,namespace:s});return{...pf(),...ff(l)}},clear:async()=>vv({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>hn({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:be(l)?l:{}}}),saveGlobalDeviceVariables:async l=>hn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:be(l)?l:{}}}),saveGlobalAccountVariables:async l=>hn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:be(l)?l:{}}}),saveGlobalRuntime:async l=>hn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:be(l)?l:{}}}),applyScopedDataUpdates:async l=>hn({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>hv(c,l)})}},kv=Ua;var Pf=Ef;var Av={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ke=Object.prototype.hasOwnProperty,Pv={anyOf:[{type:"null"},{type:"object",properties:{x:{type:"number",minimum:0},y:{type:"number",minimum:0},quality:{type:"number",minimum:1},kernelSize:{type:"integer",enum:[5,7,9,11,13,15]},repeatEdgePixels:{type:"boolean"}},required:["x","y"],additionalProperties:!1}]};function Fe(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e!==null){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[d]:r.push(d),s++}if(e.y===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[d]:r.push(d),s++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let f={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[f]:r.push(f),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Pv.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[f]:r.push(f),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Fe.errors=r,s===0}var Oe=mf().default;function Cs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Cs.errors=r,s===0}function cr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)Cs(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return cr.errors=r,s===0}var Ev={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function $s(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="continuity"||i==="speed"||i==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.continuity!==void 0){let i=e.continuity;if(typeof i!="string"){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="render"||i==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Ev.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return $s.errors=r,s===0}function pe(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.playback!==void 0&&($s(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?$s.errors:r.concat($s.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pe.errors=r,s===0}function _s(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(Av.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let i={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let i={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let i={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let i={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),e.filters!==void 0&&(cr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return _s.errors=r,s===0}function Ef(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return _s(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),s=r.length),Ef.errors=r,s===0}var xf=Sf;var yf={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},hf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="speed"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return js.errors=r,s===0}function je(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}e.playback!==void 0&&(js(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?js.errors:r.concat(js.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return je.errors=r,s===0}function Ns(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(hf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:hf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ns.errors=r,s===0}function Ds(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var c=l===s;if(c){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=i,r!==null&&(i?r.length=i:r=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var m=p===s;if(m){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=u,r!==null&&(u?r.length=u:r=null);let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let w={};r===null?r=[w]:r.push(w),s++}}var b=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let g={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),s++}var b=y===s;f=b}if(!f){let y={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Ke.call(yf.properties,y)){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let g=0;g<w;g++)Ns(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:yf.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}e.audioEffects!==void 0&&(je(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Ds.errors=r,s===0}function Sf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ds(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length),Sf.errors=r,s===0}var Of=Rf;var xv={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ts(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=s,d=!0,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let h;if(p.sprites===void 0&&(h="sprites")){let b={};r===null?r=[b]:r.push(b),s++}}var i=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),i){let h=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};r===null?r=[y]:r.push(y),s++}var i=h===s;d=i}if(!d){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[h]:r.push(h),s++}for(let h in p)if(!Ke.call(xv.properties.items.items.properties,h)){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),s++}if(p.id!==void 0&&typeof p.id!="string"){let h={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let h={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.x!==void 0&&typeof p.x!="number"){let h={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.y!==void 0&&typeof p.y!="number"){let h={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let h={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let h={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let h={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let h={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let h={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let h={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let h={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let h={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let h={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.alpha!==void 0){let h=p.alpha;if(typeof h=="number"){if(h>1||isNaN(h)){let b={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(h<0||isNaN(h)){let b={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(p.opacity!==void 0){let h=p.opacity;if(typeof h=="number"){if(h>1||isNaN(h)){let b={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(h<0||isNaN(h)){let b={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(p.blur!==void 0&&(Fe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),p.filters!==void 0&&(cr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),s=r.length)),p.sprites!==void 0){let h=p.sprites;if(Array.isArray(h)){let b=h.length;for(let y=0;y<b;y++){let w=h[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let g in w)if(!(g==="id"||g==="resourceId"||g==="animationName"||g==="animationSpeed"||g==="loop")){let A={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(w.id!==void 0&&typeof w.id!="string"){let g={instancePath:t+"/items/"+u+"/sprites/"+y+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let g={instancePath:t+"/items/"+u+"/sprites/"+y+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let g={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let g={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let g={instancePath:t+"/items/"+u+"/sprites/"+y+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}}}else{let b={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),s++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let c={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Ts.errors=r,s===0}function Rf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ts(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length),Rf.errors=r,s===0}var Cf=$f;function Ls(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="items"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:t+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:t+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let d={instancePath:t+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let m={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ls.errors=r,s===0}function $f(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ls(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),s=r.length),$f.errors=r,s===0}var _f=jf;function Ms(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let i={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ms.errors=r,s===0}function jf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ms(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),s=r.length),jf.errors=r,s===0}var Nf=Df;function Vs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Vs.errors=r,s===0}function Df(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Vs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length),Df.errors=r,s===0}var Tf=Lf;var gf={type:"object",properties:{ui:{type:"object",properties:{resourceId:{type:"string"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},mode:{type:"string",enum:["adv","nvl"]},content:{type:"array",items:{type:"object",properties:{text:{type:"string"}}}},textSpeed:{type:"number"},append:{type:"boolean"},characterId:{type:"string"},characterName:{type:"string"},persistCharacter:{type:"boolean"},persistSprite:{type:"boolean"},character:{type:"object",properties:{name:{type:"string"},sprite:{type:"object",properties:{transformId:{type:"string"},items:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},required:["id","resourceId"],additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1}},additionalProperties:!1},clear:{type:"boolean"},clearPage:{type:"boolean"}},additionalProperties:!1};function qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(gf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.ui!==void 0){let i=e.ui;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="resourceId"||l==="animations")){let c={instancePath:t+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.resourceId!==void 0&&typeof i.resourceId!="string"){let l={instancePath:t+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}i.animations!==void 0&&(pe(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let l={instancePath:t+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.mode!==void 0){let i=e.mode;if(typeof i!="string"){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="adv"||i==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:gf.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.content!==void 0){let i=e.content;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:t+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}}else{let p={instancePath:t+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let i={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let i={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let i={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let i={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let i={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let i={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.character!==void 0){let i=e.character;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="name"||l==="sprite")){let c={instancePath:t+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.name!==void 0&&typeof i.name!="string"){let l={instancePath:t+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(i.sprite!==void 0){let l=i.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:t+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[d]:r.push(d),s++}if(m.resourceId===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[d]:r.push(d),s++}for(let d in m)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(m.id!==void 0&&typeof m.id!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let d={instancePath:t+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let u={instancePath:t+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[u]:r.push(u),s++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let c={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let i={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let i={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return qs.errors=r,s===0}function Lf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return qs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),s=r.length),Lf.errors=r,s===0}var Mf=Vf;function Fs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="id"||i==="resourceId"||i==="fields"||i==="submitActions"||i==="cancelActions"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let i={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fields!==void 0){let i=e.fields;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[p]:r.push(p),s++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.submitActions!==void 0){let i=e.submitActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.cancelActions!==void 0){let i=e.cancelActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Fs.errors=r,s===0}function Vf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Fs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),s=r.length),Vf.errors=r,s===0}var qf=Ff;function Bs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Bs.errors=r,s===0}function Ff(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Bs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length),Ff.errors=r,s===0}var Bf=Uf;function Us(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="alpha"||i==="opacity"||i==="blur"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Us.errors=r,s===0}function Uf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Us(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length),Uf.errors=r,s===0}var Yf=zf;var bf={type:"object",properties:{items:{type:"array",items:{$ref:"#/definitions/audioSound"}},channels:{type:"array",items:{type:"object",properties:{id:{type:"string",minLength:1},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},applyMode:{type:"string",enum:["singleLine","persistent"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1},wf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function lr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(wf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:wf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return lr.errors=r,s===0}function Ys(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};r===null?r=[p]:r.push(p),s++}}var c=l===s;if(c){let u={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),s++}else s=i,r!==null&&(i?r.length=i:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)lr(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),s=r.length)}else{let p={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let d=u[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),s++}if(d.sounds===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="volume"||f==="muted"||f==="pan"||f==="loop"||f==="interruption"||f==="applyMode"||f==="sounds")){let h={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if(Oe(f)<1){let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),s++}if(f<0||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let f={instancePath:t+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.pan!==void 0){let f=d.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),s++}if(f<-1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:t+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.interruption!==void 0){let f=d.interruption;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="immediate"||f==="loopEnd")){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:bf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.applyMode!==void 0){let f=d.applyMode;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="singleLine"||f==="persistent")){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:bf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let h=f.length;for(let b=0;b<h;b++)lr(f[b],{instancePath:t+"/channels/"+m+"/sounds/"+b,parentData:f,parentDataProperty:b,rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),s=r.length)}else{let h={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}}else{let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}}}else{let p={instancePath:t+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}return Ys.errors=r,s===0}function zf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ys(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length),zf.errors=r,s===0}var Xf=Gf;var If={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(typeof e!="string"){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let h=e[f];if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let b={instancePath:t+"/"+f+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let b={instancePath:t+"/"+f+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(h.furigana!==void 0){let b=h.furigana;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.text!==void 0&&typeof b.text!="string"){let y={instancePath:t+"/"+f+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(b.textStyleId!==void 0&&typeof b.textStyleId!="string"){let y={instancePath:t+"/"+f+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}}}else{let b={instancePath:t+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return zs.errors=r,s===0}function Xs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let g={};r===null?r=[g]:r.push(g),s++}}var m=p===s;if(u=u||m,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.type===void 0&&(A="type")){let k={};r===null?r=[k]:r.push(k),s++}}var m=w===s;if(u=u||m,!u){let A=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.resourceId===void 0&&(E="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var m=A===s;if(u=u||m,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let L={};r===null?r=[L]:r.push(L),s++}}var m=E===s;if(u=u||m,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let D={};r===null?r=[D]:r.push(D),s++}}var m=O===s;if(u=u||m,!u){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.transform===void 0&&(B="transform")){let _={};r===null?r=[_]:r.push(_),s++}}var m=C===s;if(u=u||m,!u){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.x===void 0&&(G="x")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var m=B===s;if(u=u||m,!u){let G=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let K={};r===null?r=[K]:r.push(K),s++}}var m=G===s;if(u=u||m,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let X={};r===null?r=[X]:r.push(X),s++}}var m=M===s;if(u=u||m,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.anchorY===void 0&&(te="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),s++}}var m=le===s;if(u=u||m,!u){let te=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ne;if(e.scaleX===void 0&&(ne="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),s++}}var m=te===s;if(u=u||m,!u){let ne=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.scaleY===void 0&&(Z="scaleY")){let $={};r===null?r=[$]:r.push($),s++}}var m=ne===s;if(u=u||m,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.flipX===void 0&&(j="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var m=Z===s;if(u=u||m,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let J;if(e.flipY===void 0&&(J="flipY")){let de={};r===null?r=[de]:r.push(de),s++}}var m=j===s;if(u=u||m,!u){let J=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ie;if(e.rotation===void 0&&(Ie="rotation")){let we={};r===null?r=[we]:r.push(we),s++}}var m=J===s;if(u=u||m,!u){let Ie=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let mr={};r===null?r=[mr]:r.push(mr),s++}}var m=Ie===s;if(u=u||m,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let We;if(e.originY===void 0&&(We="originY")){let Sn={};r===null?r=[Sn]:r.push(Sn),s++}}var m=me===s;if(u=u||m,!u){let We=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Br;if(e.layer===void 0&&(Br="layer")){let Ur={};r===null?r=[Ur]:r.push(Ur),s++}}var m=We===s;if(u=u||m,!u){let Br=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Pr;if(e.alpha===void 0&&(Pr="alpha")){let On={};r===null?r=[On]:r.push(On),s++}}var m=Br===s;if(u=u||m,!u){let Pr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ct;if(e.opacity===void 0&&(ct="opacity")){let jt={};r===null?r=[jt]:r.push(jt),s++}}var m=Pr===s;if(u=u||m,!u){let ct=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Yr;if(e.blur===void 0&&(Yr="blur")){let ut={};r===null?r=[ut]:r.push(ut),s++}}var m=ct===s;if(u=u||m,!u){let Yr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let zr;if(e.filters===void 0&&(zr="filters")){let Rn={};r===null?r=[Rn]:r.push(Rn),s++}}var m=Yr===s;if(u=u||m,!u){let zr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let _i;if(e.animations===void 0&&(_i="animations")){let Nt={};r===null?r=[Nt]:r.push(Nt),s++}}var m=zr===s;u=u||m}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var d=l===s;if(d){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=i,r!==null&&(i?r.length=i:r=null);let f=s,h=!1,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var y=b===s;if(h=h||y,!h){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let A={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[A]:r.push(A),s++}var y=w===s;h=h||y}if(h)s=f,r!==null&&(f?r.length=f:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(zs(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return Xs.errors=r,s===0}function Gs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="elements"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Gs.errors=r,s===0}var Sv={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function Hs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(Sv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Hs.errors=r,s===0}function Ks(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let m={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=s,b=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.resourceId===void 0&&(v="resourceId")||f.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var i=b===s;if(i){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=h,r!==null&&(h?r.length=h:r=null);let y=s,w=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.resourceId===void 0&&(v="resourceId")||f.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var l=w===s;if(l){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=y,r!==null&&(y?r.length=y:r=null);let g=s,A=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.text===void 0&&(v="text")||f.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=A===s;if(c){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=g,r!==null&&(g?r.length=g:r=null);let k=s,E=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.transformId===void 0&&(v="transformId")||f.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=E===s;if(u){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),s++}for(let v in f)if(!Ke.call(If.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),s++}if(f.id!==void 0&&typeof f.id!="string"){let v={instancePath:t+"/items/"+d+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.animationName!==void 0&&typeof f.animationName!="string"){let v={instancePath:t+"/items/"+d+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.animationSpeed!==void 0&&typeof f.animationSpeed!="number"){let v={instancePath:t+"/items/"+d+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.resourceId!==void 0&&typeof f.resourceId!="string"){let v={instancePath:t+"/items/"+d+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.text!==void 0&&(Xs(f.text,{instancePath:t+"/items/"+d+"/text",parentData:f,parentDataProperty:"text",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),s=r.length)),f.layout!==void 0&&(Gs(f.layout,{instancePath:t+"/items/"+d+"/layout",parentData:f,parentDataProperty:"layout",rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length)),f.transformId!==void 0&&typeof f.transformId!="string"){let v={instancePath:t+"/items/"+d+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.transform!==void 0&&(Hs(f.transform,{instancePath:t+"/items/"+d+"/transform",parentData:f,parentDataProperty:"transform",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length)),f.x!==void 0&&typeof f.x!="number"){let v={instancePath:t+"/items/"+d+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.y!==void 0&&typeof f.y!="number"){let v={instancePath:t+"/items/"+d+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.anchorX!==void 0&&typeof f.anchorX!="number"){let v={instancePath:t+"/items/"+d+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.anchorY!==void 0&&typeof f.anchorY!="number"){let v={instancePath:t+"/items/"+d+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.scaleX!==void 0&&typeof f.scaleX!="number"){let v={instancePath:t+"/items/"+d+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.scaleY!==void 0&&typeof f.scaleY!="number"){let v={instancePath:t+"/items/"+d+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.flipX!==void 0&&typeof f.flipX!="boolean"){let v={instancePath:t+"/items/"+d+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(f.flipY!==void 0&&typeof f.flipY!="boolean"){let v={instancePath:t+"/items/"+d+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(f.rotation!==void 0&&typeof f.rotation!="number"){let v={instancePath:t+"/items/"+d+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.originX!==void 0&&typeof f.originX!="number"){let v={instancePath:t+"/items/"+d+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.originY!==void 0&&typeof f.originY!="number"){let v={instancePath:t+"/items/"+d+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.layer!==void 0){let v=f.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:If.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),s++}}if(f.alpha!==void 0){let v=f.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(f.opacity!==void 0){let v=f.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}f.blur!==void 0&&(Fe(f.blur,{instancePath:t+"/items/"+d+"/blur",parentData:f,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),s=r.length)),f.filters!==void 0&&(cr(f.filters,{instancePath:t+"/items/"+d+"/filters",parentData:f,parentDataProperty:"filters",rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),s=r.length)),f.animations!==void 0&&(pe(f.animations,{instancePath:t+"/items/"+d+"/animations",parentData:f,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let m={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}return Ks.errors=r,s===0}function Gf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ks(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),s=r.length),Gf.errors=r,s===0}var Hf=Kf;var Ov={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},resourceId:{type:"string"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},startDelayMs:{type:"number",minimum:0}},anyOf:[{required:["resourceId"]},{required:["sounds"]}],allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1};function Ws(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let y={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[y]:r.push(y),s++}var u=c===s;if(l=l||u,!l){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let g={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),s++}var u=y===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let y={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[y]:r.push(y),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var d=m===s;if(d){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=p,r!==null&&(p?r.length=p:r=null);let f=s,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var b=h===s;if(b){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=f,r!==null&&(f?r.length=f:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!(y==="sounds"||y==="resourceId"||y==="volume"||y==="muted"||y==="pan"||y==="loop"||y==="interruption"||y==="startDelayMs")){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let g=0;g<w;g++)lr(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Ov.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Ws.errors=r,s===0}function Kf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ws(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length),Kf.errors=r,s===0}var Wf=Jf;var Rv={type:"object",properties:{type:{type:"string",enum:["boolean","number"]},target:{type:"integer",minimum:1},name:{type:"string",minLength:1},description:{type:"string",minLength:1},lockedName:{type:"string",minLength:1},lockedDescription:{type:"string",minLength:1},hidden:{type:"boolean"}},required:["type","name","description"],allOf:[{if:{properties:{type:{const:"number"}}},then:{required:["target"]}},{if:{properties:{type:{const:"boolean"}}},then:{not:{required:["target"]}}}],additionalProperties:!1};function Js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let b={};r===null?r=[b]:r.push(b),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let b=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.target===void 0&&(A="target")){let k={};r===null?r=[k]:r.push(k),s++}}var h=w===s;if(h){let A={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[A]:r.push(A),s++}else s=y,r!==null&&(y?r.length=y:r=null);var f=b===s;m=f}if(!m){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}if(e.name===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[b]:r.push(b),s++}if(e.description===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="type"||b==="target"||b==="name"||b==="description"||b==="lockedName"||b==="lockedDescription"||b==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let b=e.type;if(typeof b!="string"){let y={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(!(b==="boolean"||b==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Rv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(e.target!==void 0){let b=e.target;if(!(typeof b=="number"&&!(b%1)&&!isNaN(b))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[y]:r.push(y),s++}if(typeof b=="number"&&(b<1||isNaN(b))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[y]:r.push(y),s++}}if(e.name!==void 0){let b=e.name;if(typeof b=="string"){if(Oe(b)<1){let y={instancePath:t+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.description!==void 0){let b=e.description;if(typeof b=="string"){if(Oe(b)<1){let y={instancePath:t+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedName!==void 0){let b=e.lockedName;if(typeof b=="string"){if(Oe(b)<1){let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedDescription!==void 0){let b=e.lockedDescription;if(typeof b=="string"){if(Oe(b)<1){let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let b={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return Js.errors=r,s===0}function Jf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Js(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),s=r.length),Jf.errors=r,s===0}var Qf=Zf;var Cv={type:"object",required:["type"],$defs:{keyframe:{type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}}},required:["keyframes"],additionalProperties:!1},updateTween:{type:"object",properties:{alpha:{$ref:"#/$defs/tweenProperty"},x:{$ref:"#/$defs/tweenProperty"},y:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionTween:{type:"object",properties:{translateX:{$ref:"#/$defs/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},alpha:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/tweenProperty"},compositeMaskItem:{type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1},mask:{type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]}},properties:{name:{type:"string"},type:{type:"string",enum:["update","transition"]},complete:{type:"object",properties:{payload:{type:"object"}},additionalProperties:!0},tween:{$ref:"#/$defs/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"},mask:{$ref:"#/$defs/mask"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{not:{required:["tween"]},anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/animationResource.yaml"};var $v={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1};function at(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="value"||i==="duration"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let i={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let i={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.easing!==void 0){let i=e.easing;if(typeof i!="string"){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="linear"||i==="easeInQuad"||i==="easeOutQuad"||i==="easeInOutQuad"||i==="easeInCubic"||i==="easeOutCubic"||i==="easeInOutCubic"||i==="easeInQuart"||i==="easeOutQuart"||i==="easeInOutQuart"||i==="easeInQuint"||i==="easeOutQuint"||i==="easeInOutQuint"||i==="easeInSine"||i==="easeOutSine"||i==="easeInOutSine"||i==="easeInExpo"||i==="easeOutExpo"||i==="easeInOutExpo"||i==="easeInCirc"||i==="easeOutCirc"||i==="easeInOutCirc"||i==="easeInBack"||i==="easeOutBack"||i==="easeInOutBack"||i==="easeInBounce"||i==="easeOutBounce"||i==="easeInOutBounce"||i==="easeInElastic"||i==="easeOutElastic"||i==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:$v.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return at.errors=r,s===0}function re(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)at(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?at.errors:r.concat(at.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return re.errors=r,s===0}function Qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="alpha"||i==="x"||i==="y"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Qs.errors=r,s===0}function Zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="translateX"||i==="translateY"||i==="alpha"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.translateX!==void 0&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Zs.errors=r,s===0}function ot(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.tween!==void 0&&(Zs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ot.errors=r,s===0}var Rs={type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]},_v={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="texture"||i==="channel"||i==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let i={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.channel!==void 0){let i=e.channel;if(typeof i!="string"){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:_v.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let i={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ei.errors=r,s===0}function ri(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)at(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?at.errors:r.concat(at.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ri.errors=r,s===0}function ti(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let g={};r===null?r=[g]:r.push(g),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let k={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[k]:r.push(k),s++}var f=g===s;m=f}if(!m){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let h=s,b=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let g={};r===null?r=[g]:r.push(g),s++}var w=y===s;if(s=h,r!==null&&(h?r.length=h:r=null),w){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[k]:r.push(k),s++}var w=g===s;b=w}if(!b){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!Ke.call(Rs.properties,g)){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.kind!==void 0){let g=e.kind;if(typeof g!="string"){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(g==="single"||g==="sequence"||g==="composite")){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Rs.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let g={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.textures!==void 0){let g=e.textures;if(Array.isArray(g)){if(g.length<1){let k={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=g.length;for(let k=0;k<A;k++)if(typeof g[k]!="string"){let E={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}}else{let A={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.items!==void 0){let g=e.items;if(Array.isArray(g)){if(g.length<1){let k={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=g.length;for(let k=0;k<A;k++)ei(g[k],{instancePath:t+"/items/"+k,parentData:g,parentDataProperty:k,rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),s=r.length)}else{let A={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.combine!==void 0){let g=e.combine;if(typeof g!="string"){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(g==="max"||g==="min"||g==="multiply"||g==="add")){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Rs.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.channel!==void 0){let g=e.channel;if(typeof g!="string"){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(g==="red"||g==="green"||g==="blue"||g==="alpha")){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Rs.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let g={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let g={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let g={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}e.progress!==void 0&&(ri(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length))}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return ti.errors=r,s===0}function ni(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let g=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.prev===void 0&&(C="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=C===s;if(v=v||p,!v){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var p=B===s;v=v||p}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={};r===null?r=[C]:r.push(C),s++}var m=k===s;if(m){let C={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let C={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[C]:r.push(C),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var b=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let g=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.tween===void 0&&(C="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===s;if(y){let C={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[C]:r.push(C),s++}var w=O===s;if(v=v||w,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),s++}var w=C===s;if(v=v||w,!v){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[G]:r.push(G),s++}var w=B===s;v=v||w}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[C]:r.push(C),s++}var b=g===s;f=b}if(!f){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!(g==="name"||g==="type"||g==="complete"||g==="tween"||g==="prev"||g==="next"||g==="mask")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let A={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(g==="update"||g==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Cv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.complete!==void 0){let g=e.complete;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.payload!==void 0){let A=g.payload;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let k={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let A={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(Qs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),s=r.length)),e.prev!==void 0&&(ot(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)),e.next!==void 0&&(ot(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)),e.mask!==void 0&&(ti(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),s=r.length))}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return ni.errors=r,s===0}function Zf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ni(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),s=r.length),Zf.errors=r,s===0}var ed=rd;var jv={type:"object",required:["type"],$defs:{easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},propertyTracks:{type:"object",minProperties:1,properties:{volume:{$ref:"#/$defs/volumeTweenProperty"},pan:{$ref:"#/$defs/panTweenProperty"},playbackRate:{$ref:"#/$defs/playbackRateTweenProperty"}},additionalProperties:!1}},properties:{name:{type:"string"},type:{enum:["update","transition"]},tween:{$ref:"#/$defs/propertyTracks"},prev:{$ref:"#/$defs/propertyTracks"},next:{$ref:"#/$defs/propertyTracks"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{anyOf:[{required:["prev"]},{required:["next"]}],not:{required:["tween"]}}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/audioEffectResource.yaml"};function si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="number"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}return si.errors=r,s===0}var Nv={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="string"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let i={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Nv.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),s++}return ii.errors=r,s===0}function ur(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="startValue"||i==="value"||i==="duration"||i==="delay"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let i={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.value!==void 0&&(si(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),s=r.length)),e.duration!==void 0){let i=e.duration;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.delay!==void 0){let i=e.delay;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.easing!==void 0&&(ii(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),s=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ur.errors=r,s===0}function oi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;ur(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>100||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var p=b===s;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>100||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var h=b===s;d=h}if(!d){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}return oi.errors=r,s===0}function ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)oi(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ai.errors=r,s===0}function li(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;ur(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var p=b===s;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var h=b===s;d=h}if(!d){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}return li.errors=r,s===0}function ci(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)li(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?li.errors:r.concat(li.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ci.errors=r,s===0}function ui(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;ur(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"&&(w<0||isNaN(w))){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var p=b===s;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"&&(w<0||isNaN(w))){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var h=b===s;d=h}if(!d){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}return ui.errors=r,s===0}function pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ui(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pi.errors=r,s===0}function ar(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="volume"||i==="pan"||i==="playbackRate")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.volume!==void 0&&(ai(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length)),e.pan!==void 0&&(ci(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),s=r.length)),e.playbackRate!==void 0&&(pi(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ar.errors=r,s===0}function fi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let g=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.prev===void 0&&(C="prev")){let D={};r===null?r=[D]:r.push(D),s++}}var p=O===s;if(v=v||p,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),s++}}var p=C===s;v=v||p}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={};r===null?r=[C]:r.push(C),s++}var m=k===s;if(m){let C={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let C={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[C]:r.push(C),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var b=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),b){let g=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.tween===void 0&&(C="tween")){let D={};r===null?r=[D]:r.push(D),s++}}var y=k===s;if(y){let C={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[C]:r.push(C),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[C]:r.push(C),s++}var w=O===s;if(v=v||w,!v){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),s++}var w=C===s;v=v||w}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let C={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[C]:r.push(C),s++}var b=g===s;f=b}if(!f){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!(g==="name"||g==="type"||g==="tween"||g==="prev"||g==="next")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(!(g==="update"||g==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:jv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(ar(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),s=r.length)),e.prev!==void 0&&(ar(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),s=r.length)),e.next!==void 0&&(ar(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),s=r.length))}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return fi.errors=r,s===0}function rd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return fi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length),rd.errors=r,s===0}var td=nd;function di(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="name"||i==="nameVariableId")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let i={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return di.errors=r,s===0}function nd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return di(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),s=r.length),nd.errors=r,s===0}var sd=id;var Dv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function mi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!Dv.test(i)){let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return mi.errors=r,s===0}function id(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return mi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),s=r.length),id.errors=r,s===0}var od=ad;function yi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let i=e.keyboard;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.keyup!==void 0){let i=e.keyup;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return yi.errors=r,s===0}function ad(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return yi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),s=r.length),ad.errors=r,s===0}var ld=cd;function hi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return hi.errors=r,s===0}function cd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return hi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),s=r.length),cd.errors=r,s===0}var ud=pd;function gi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return gi.errors=r,s===0}function pd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return gi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),s=r.length),pd.errors=r,s===0}var fd=dd;function bi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return bi.errors=r,s===0}var vf=new RegExp("^\\$(if .+|for .+|else)$","u"),za={validate:gn};function wi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!vf.test(i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}for(let i in e)if(vf.test(i)){let l=e[i];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)za.validate(l[u],{instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?za.validate.errors:r.concat(za.validate.errors),s=r.length)}else{let c={instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return wi.errors=r,s===0}function gn(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;bi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;wi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length);var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return gn.errors=r,s===0}function Ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)gn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?gn.errors:r.concat(gn.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return Ii.errors=r,s===0}var Xa={validate:bn};function bn(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(Ii(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length)),e.children!==void 0){let i=e.children;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)Xa.validate(i[c],{instancePath:t+"/children/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Xa.validate.errors:r.concat(Xa.validate.errors),s=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return bn.errors=r,s===0}function vi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)bn(i[c],{instancePath:t+"/elements/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?bn.errors:r.concat(bn.errors),s=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.transitions!==void 0){let i={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return vi.errors=r,s===0}function dd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return vi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),s=r.length),dd.errors=r,s===0}var md=yd;function ki(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=null,u=s,p=s,m=s,d=s,f=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let E={};r===null?r=[E]:r.push(E),s++}}var b=h===s;if(f=f||b,!f){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.texture===void 0&&(v="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var b=k===s;if(f=f||b,!f){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.behaviors===void 0&&(L="behaviors")){let C={};r===null?r=[C]:r.push(C),s++}}var b=v===s;if(f=f||b,!f){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.emitter===void 0&&(D="emitter")){let B={};r===null?r=[B]:r.push(B),s++}}var b=L===s;f=f||b}}}if(f)s=d,r!==null&&(d?r.length=d:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=m===s;if(y){let k={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[k]:r.push(k),s++}else s=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let k={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[k]:r.push(k),s++}var g=u===s;g&&(l=!0,c=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}if(e.behaviors===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[k]:r.push(k),s++}if(e.emitter===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[k]:r.push(k),s++}}var g=w===s;if(g&&l?(l=!1,c=[c,1]):g&&(l=!0,c=1),l)s=i,r!==null&&(i?r.length=i:r=null);else{let k={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[k]:r.push(k),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[k]:r.push(k),s++}if(e.height===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[k]:r.push(k),s++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[E]:r.push(E),s++}if(k.appearance===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[E]:r.push(E),s++}for(let E in k)if(!(E==="emission"||E==="movement"||E==="appearance"||E==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let E=k.emission;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.movement!==void 0){let E=k.movement;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.appearance!==void 0){let E=k.appearance;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.bounds!==void 0){let E=k.bounds;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[E]:r.push(E),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0){let k=e.texture,E=s,v=!1,O=null,L=s;if(typeof k=="string"){if(Oe(k)<1){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[D]:r.push(D),s++}}else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[D]:r.push(D),s++}var A=L===s;A&&(v=!0,O=0);let C=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),s++}var A=C===s;if(A&&v?(v=!1,O=[O,1]):A&&(v=!0,O=1),v)s=E,r!==null&&(E?r.length=E:r=null);else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[D]:r.push(D),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let v={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let E=k.length;for(let v=0;v<E;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[L]:r.push(L),s++}for(let L in O)if(!(L==="type"||L==="config")){let C={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"};r===null?r=[C]:r.push(C),s++}if(O.type!==void 0){let L=O.type;if(typeof L=="string"){if(Oe(L)<1){let C={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[C]:r.push(C),s++}}else{let C={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[C]:r.push(C),s++}}if(O.config!==void 0){let L=O.config;if(!(L&&typeof L=="object"&&!Array.isArray(L))){let C={instancePath:t+"/behaviors/"+v+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[C]:r.push(C),s++}}}else{let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),s++}}}else{let E={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[E]:r.push(E),s++}if(k.lifetime!==void 0){let E=k.lifetime;if(E&&typeof E=="object"&&!Array.isArray(E)){if(E.min===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),s++}if(E.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),s++}if(E.min!==void 0){let v=E.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(E.max!==void 0){let v=E.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}}else{let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}return ki.errors=r,s===0}function yd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ki(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),s=r.length),yd.errors=r,s===0}var hd=gd;var kf={type:"object",properties:{fileId:{type:"string"},fileType:{type:"string"},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["fileId"],additionalProperties:!1};function Ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Ke.call(kf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:kf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ai.errors=r,s===0}function gd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ai(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),s=r.length),gd.errors=r,s===0}var bd=wd;var Tv=new RegExp("^.+$","u");function Pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.jsonData===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="jsonData"||i==="width"||i==="height"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.jsonData!==void 0){let i=e.jsonData;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(Tv.test(l)){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)if(typeof u[m]!="number"){let d={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+m,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}}else{let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}}else{let l={instancePath:t+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Pi.errors=r,s===0}function wd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Pi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),s=r.length),wd.errors=r,s===0}var Id=vd;var Af={type:"object",properties:{fontId:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1}}]},colorId:{type:"string"},colorAlpha:{type:"number"},fontSize:{type:"number"},fontWeight:{type:"string"},fontStyle:{type:"string",enum:["normal","italic","oblique"]},lineHeight:{type:"number"},align:{type:"string"},wordWrap:{type:"boolean"},breakWords:{type:"boolean"},wordWrapWidth:{type:"number"},strokeColorId:{type:"string"},strokeAlpha:{type:"number"},strokeWidth:{type:"number"},shadow:{type:"object",properties:{colorId:{type:"string",minLength:1},alpha:{type:"number",minimum:0,maximum:1},blur:{type:"number",minimum:0},offsetX:{type:"number"},offsetY:{type:"number"}},required:["colorId"],additionalProperties:!1}},required:["fontId","fontSize","fontWeight","fontStyle","lineHeight","colorId"],additionalProperties:!1};function Ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};r===null?r=[l]:r.push(l),s++}if(e.fontSize===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};r===null?r=[l]:r.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};r===null?r=[l]:r.push(l),s++}if(e.colorId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[l]:r.push(l),s++}for(let l in e)if(!Ke.call(Af.properties,l)){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,m=s;if(typeof l=="string"){if(Oe(l)<1){let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}var i=m===s;i&&(u=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let y={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[y]:r.push(y),s++}let f=l.length;for(let y=0;y<f;y++){let w=l[y];if(typeof w=="string"){if(Oe(w)<1){let g={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}}let h=l.length,b;if(h>1){let y={};for(;h--;){let w=l[h];if(typeof w=="string"){if(typeof y[w]=="number"){b=y[w];let g={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:h,j:b},message:"must NOT have duplicate items (items ## "+b+" and "+h+" are identical)"};r===null?r=[g]:r.push(g),s++;break}y[w]=h}}}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),s++}var i=d===s;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)s=c,r!==null&&(c?r.length=c:r=null);else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:t+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:t+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight!==void 0&&typeof e.fontWeight!="string"){let l={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:Af.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Oe(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Ei.errors=r,s===0}function vd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ei(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),s=r.length),vd.errors=r,s===0}var kd=Ad;var Lv={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function xi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(Lv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0){let i=e.x;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.y!==void 0){let i=e.y;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return xi.errors=r,s===0}function Ad(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return xi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),s=r.length),Ad.errors=r,s===0}var Pd=Ed;function Si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Si.errors=r,s===0}function Ed(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Si(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),s=r.length),Ed.errors=r,s===0}var vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),In=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ar=e=>e===void 0?void 0:structuredClone(e),Mv=Object.freeze({achievement:"achievements",animation:"animations",audioEffect:"audioEffects",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),Vv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),qv=Object.freeze({background:Pf,bgm:xf,character:Of,choice:Cf,cleanAll:_f,control:Nf,dialogue:Tf,form:Mf,layout:qf,screen:Bf,sfx:Yf,visual:Xf,voice:Hf}),Fv=Object.freeze({achievement:Wf,animation:Qf,audioEffect:ed,character:td,color:sd,control:od,font:ld,image:ud,layout:fd,particle:md,sound:hd,spritesheet:bd,textStyle:Id,transform:kd,video:Pd}),Bv=new Set(["files","language","patches"]),Uv=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Yv=new Set(["lineId","mode","payload","type"]),zv=new Set(["mode","payload","sceneId","type"]),Xv=new Set(["mode","operation","payload","resourceId","type"]),Gv=new Set(["fileId","mimeType"]),H=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},rr=(e,t)=>{In(e)||H(t,"expected an object")},Ga=(e,t)=>{Array.isArray(e)||H(t,"expected an array")},$t=(e,t)=>{(typeof e!="string"||e.length===0)&&H(t,"expected a non-empty string")},Rd=(e,t)=>{typeof e!="string"&&H(t,"expected a string")},fr=(e,t,n)=>{for(let o of Object.keys(e))t.has(o)||H(`${n}.${o}`,"unknown field")},dr=(e,t,n)=>{for(let o of t)vn(e,o)||H(n,`missing required field "${o}"`)},Hv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),Kv=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(Hv);return t?.keyword==="required"?n.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&n.push(t.params.additionalProperty),n.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},Wv=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,n)=>{if(t===void 0)return n;let o=n.instancePath.split("/").length,a=t.instancePath.split("/").length;return o>a?n:t},void 0)??e[0],Cd=({value:e,validator:t,path:n,contract:o})=>{if(t(e))return;let a=Wv(t.errors);H(Kv(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Oi=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||H(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,a)=>Oi(o,`${t}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>Oi(a,`${t}.${o}`,n))}},pr=(e,t)=>{e===""&&H(t,"expected a non-empty resourceId")},Jv=(e,t,n)=>{let o=(s,i)=>pr(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>pr(l?.resourceId,`${i}[${c}].resourceId`)),r=(s,i)=>{pr(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":pr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"bgm":o(t.audioEffects,`${n}.audioEffects`),r(t,n);break;case"voice":r(t,n);break;case"sfx":a(t.items,`${n}.items`),(t.channels??[]).forEach((s,i)=>a(s?.sounds,`${n}.channels[${i}].sounds`));break;case"character":(t.items??[]).forEach((s,i)=>{(s.sprites??[]).forEach((l,c)=>pr(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":pr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"control":pr(t.resourceId,`${n}.resourceId`);break;case"dialogue":pr(t.ui?.resourceId,`${n}.ui.resourceId`),o(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,i)=>pr(s?.resourceId,`${n}.character.sprite.items[${i}].resourceId`)),o(t.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(t.animations,`${n}.animations`);break;case"visual":(t.items??[]).forEach((s,i)=>{pr(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},_t=(e,t)=>{$t(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&H(t,`"${e}" is not a safe ID`)},Qv=(e,t)=>{$t(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&H(t,"must be a safe single filename")},wn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((a,r)=>wn(a,t[r]));if(!In(e)||!In(t))return!1;let n=Object.keys(e).sort(),o=Object.keys(t).sort();return wn(n,o)&&n.every(a=>wn(e[a],t[a]))},Ri=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>Ri(o,t,n)),t;if(!In(e)||n.has(e))return t;n.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&t.add(a),Ri(a,t,n);return t},Zv=e=>{let t=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(o?.sections??{}))for(let[s,i]of(r?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=t.get(i.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:i}),t.set(i.id,l)}return t},$d=(e,t,n)=>{let o=e.get(t)??[];return o.length===0&&H(n,`lineId "${t}" does not exist in projectData`),o.length>1&&H(n,`lineId "${t}" is not globally unique in projectData`),o[0]},_d=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],xd=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Sd=e=>{let t=Ar(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))In(n)&&delete n.placeholder;return t},ek=(e,t,n,o)=>{e==="choice"&&!wn(xd(t),xd(n))&&H(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!wn(Sd(t),Sd(n))&&H(o,"form behavior must remain identical; only presentation fields and placeholders may change")},rk=({patch:e,path:t,lineIndex:n})=>{fr(e,Uv,t),dr(e,["type","lineId","actionType","payload"],t),_t(e.lineId,`${t}.lineId`),$t(e.actionType,`${t}.actionType`),rr(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.action supports only "replace"'),Vv.has(e.actionType)||H(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=$d(n,e.lineId,`${t}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&H(`${t}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&H(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),vn(e.payload,"content")&&H(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&H(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),ek(e.actionType,a,e.payload,`${t}.payload`),Cd({value:e.payload,validator:qv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Oi(e.payload,`${t}.payload`),Jv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},tk=(e,t)=>{Ga(e,t),e.forEach((n,o)=>{rr(n,`${t}[${o}]`),fr(n,new Set(["text"]),`${t}[${o}]`),dr(n,["text"],`${t}[${o}]`),Rd(n.text,`${t}[${o}].text`)})},nk=({patch:e,path:t,lineIndex:n})=>{fr(e,Yv,t),dr(e,["type","lineId","payload"],t),_t(e.lineId,`${t}.lineId`),rr(e.payload,`${t}.payload`),fr(e.payload,new Set(["content"]),`${t}.payload`),dr(e.payload,["content"],`${t}.payload`),tk(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.dialogue supports only "replace"');let o=$d(n,e.lineId,`${t}.lineId`);return o.line?.actions?.dialogue===void 0&&H(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},sk=({patch:e,path:t,projectData:n})=>(fr(e,zv,t),dr(e,["type","mode","sceneId","payload"],t),_t(e.sceneId,`${t}.sceneId`),rr(e.payload,`${t}.payload`),fr(e.payload,new Set(["name"]),`${t}.payload`),dr(e.payload,["name"],`${t}.payload`),Rd(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&H(`${t}.mode`,'story.scene requires "patch"'),vn(n?.story?.scenes??{},e.sceneId)||H(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),ik=(e,t,n)=>{rr(t,n),["font","image","sound","spritesheet","video"].includes(e)&&$t(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="spritesheet"&&(rr(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||H(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&H(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),Cd({value:t,validator:Fv[e],path:n,contract:`the resource.${e} schema`}),Oi(t,n)},ok=({patch:e,path:t,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{fr(e,Xv,t),dr(e,["type","resourceId","payload"],t),_t(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=Mv[r];s||H(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&H(`${t}.operation`,'the only resource operation is "add"'),ik(r,e.payload,`${t}.payload`);let i=n?.resources?.[s]??{},l=vn(i,e.resourceId);e.operation==="add"&&l&&H(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&H(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of Ri(e.payload))!o.has(c)&&!a.has(c)&&H(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:t,patch:e}},Od=({resources:e,collectionName:t,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!vn(e?.[t]??{},n))&&H(o,`${a} resource "${n}" was not found`)},ak=(e,t)=>{let n=Ar(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=Ar(a.patch.payload));let o=n.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,s=Array.isArray(r.fontId)?r.fontId:[r.fontId];s.forEach((i,l)=>Od({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])Od({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},lk=({patch:e,path:t,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(rr(e,t),$t(e.type,`${t}.type`),e.type==="line.action")return rk({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return nk({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return sk({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return ok({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});H(`${t}.type`,`unsupported patch type "${e.type}"`)},ck=(e,t)=>{Ga(e,t);let n=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;rr(o,r),fr(o,Gv,r),dr(o,["fileId"],r),Qv(o.fileId,`${r}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&H(`${r}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&H(`${r}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},uk=({packageId:e,packageData:t,path:n,projectData:o,lineIndex:a,canonicalFileIds:r})=>{rr(t,n),fr(t,Bv,n),dr(t,["language","files","patches"],n),$t(t.language,`${n}.language`);let s=ck(t.files,`${n}.files`);Ga(t.patches,`${n}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=lk({patch:c,path:`${n}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return i.has(p.key)&&H(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},jd=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};rr(t,"l10nData"),fr(t,new Set(["packages"]),"l10nData"),dr(t,["packages"],"l10nData"),rr(t.packages,"l10nData.packages");let n=Zv(e),o=Ri(e?.resources??{}),a=new Map,r=new Map;for(let[s,i]of Object.entries(t.packages)){_t(s,`l10nData.packages.${s}`);let l=uk({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&H(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&H(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}ak(e,l),a.set(s,l)}return{packages:a}},pk=(e,t)=>{let{collectionName:n,patch:o}=t;e.resources[n]??={},e.resources[n][o.resourceId]=Ar(o.payload)},fk=(e,t)=>{let{patch:n}=t,o=e.story.scenes[n.sceneId];o.name=n.payload.name},dk=(e,t)=>{let{location:n,patch:o}=t,a=_d(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=Ar(o.payload);return}let r=Ar(n.line.actions.dialogue.content);a.actions.dialogue=Ar(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},mk=(e,t)=>{let{location:n,patch:o}=t,a=_d(e,n);a.actions.dialogue.content=Ar(o.payload.content)},Nd=({projectData:e,l10nData:t})=>{let n=jd({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},Ci=({projectData:e,l10nData:t,l10nId:n=null})=>{let o=jd({projectData:e,l10nData:t});if(n!==null&&(_t(n,"l10nId"),o.packages.has(n)||H("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=Ar(e),r=o.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>pk(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>fk(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>dk(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>mk(a,s)),a};var Ha=Object.freeze({auto:1e3,skip:80,authored:1e3}),Pn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Dd=new WeakMap,yk=new ArrayBuffer(8),Ka=new DataView(yk),hk=e=>{let t=Dd.get(e);if(t)return t;let n={dispatchDepth:0};return Dd.set(e,n),n},gk=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},bk=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Fr=(e,t,n)=>{if(!gk(e)||!bk(e,t))throw new TypeError(`${n} has an invalid shape`)},kn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},An=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},Td=e=>{if(An(e,"duration"),e===0)return 0n;Ka.setFloat64(0,e,!1);let t=Ka.getUint32(0,!1),n=Ka.getUint32(4,!1),o=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(n);if(o===0)return a;let r=1n<<52n|a,s=o-1;return r<<BigInt(s)},wk=e=>structuredClone(e),Wa=(e,t)=>e===t?!0:!e||!t||e.mode!==t.mode||e.kind!==t.kind?!1:e.mode==="legacy"?e.instanceToken===t.instanceToken:e.delayMs!==t.delayMs?!1:e.kind==="auto"?e.contentKey===t.contentKey&&e.owner.sessionId===t.owner.sessionId&&e.owner.lineEntryId===t.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===t.owner.sessionId:e.trigger===t.trigger&&e.owner.lineEntryId===t.owner.lineEntryId,Ja=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(Fr(t,["owner","delayMs","contentKey"],"auto timer"),Fr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),kn(t.owner.sessionId,"auto owner sessionId"),kn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(An(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Fr(t,["owner","delayMs"],"skip timer"),Fr(t.owner,["sessionId"],"skip timer owner"),kn(t.owner.sessionId,"skip owner sessionId"),An(t.delayMs,"skip delayMs");else{if(Fr(t,["owner","delayMs","trigger"],"authored timer"),Fr(t.owner,["lineEntryId"],"authored timer owner"),kn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(An(t.delayMs,"authored delayMs"),t.trigger!=="fromStart"&&t.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...wk(t)}},Ik=e=>{if(Fr(e,["contractVersion","status","lineEntryId","timers"],"playback schedule"),e.contractVersion!==1)throw new TypeError("playback schedule contractVersion must be 1");if(e.status!=="settled"&&e.status!=="unsettled")throw new TypeError('playback schedule status must be "settled" or "unsettled"');if(kn(e.lineEntryId,"playback schedule lineEntryId"),e.status==="unsettled"){if(e.timers!==null)throw new TypeError("unsettled playback schedule timers must be null");return{contractVersion:1,status:"unsettled",lineEntryId:e.lineEntryId,timers:null}}Fr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:Ja("auto",e.timers.auto,e.lineEntryId),skip:Ja("skip",e.timers.skip,e.lineEntryId),authored:Ja("authored",e.timers.authored,e.lineEntryId)};if(t.auto&&t.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:t}},Qa=e=>({descriptor:e,remainingQuanta:Td(e.delayMs)}),$i=["auto","skip","authored"],Ld=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof t!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let o=hk(e),a=!0,r={},s={},i=null,l=null,c=null,u=null,p=!1,m=!1,d="legacy",f={auto:null,skip:null,authored:null},h={auto:null,skip:null,authored:null},b={auto:0,skip:0,authored:0},y=()=>$i.some(M=>f[M]),w=()=>{l=null,c=null},g=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||m){g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},A=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=i;M&&(w(),i=null,u=M,e.remove(M),u===M&&(u=null))},E=()=>{f={auto:null,skip:null,authored:null}},v=()=>{E(),s={},m||k()},O=M=>{if(o.dispatchDepth>0||m){c=M,g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},L=()=>{if(!a||!y()||i)return;A();let M=r,K=s,le={},X=oe=>{if(!a||M!==r||K!==s||le!==l||X!==i||m)return;if(!oe||typeof oe.deltaMS!="number"||!Number.isFinite(oe.deltaMS)||oe.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let ne=Td(oe.deltaMS);m=!0,o.dispatchDepth+=1;let ue=s,Z=null;try{let $=[];for(let j of $i){let F=f[j];F&&(F.remainingQuanta<=ne?($.push({kind:j,descriptor:F.descriptor,revision:b[j]}),f[j]=null):F.remainingQuanta-=ne)}if($.length>0){try{t({dueKinds:$.map(({kind:j})=>j)})}catch(j){let F=n(j);if(d==="reconciled"&&F==="preCommit")for(let{kind:J,descriptor:de}of $)h[J]=de;else d==="legacy"&&E();throw j}if(d==="legacy")for(let j of $)j.kind==="skip"&&b.skip===j.revision&&f.skip===null&&(f.skip=Qa(j.descriptor))}}catch($){Z=$}finally{o.dispatchDepth-=1,m=!1;try{ue===s?y()?L():k():i===X&&!y()&&k()}catch($){throw Z?new AggregateError([Z,$],"Playback attempt and ticker cleanup both failed"):$}}if(Z)throw Z},te={callback:X,lifecycleToken:M,generationToken:K,registrationToken:le};i=X,c=te;try{e.add(X)}catch(oe){throw i=null,w(),E(),s={},u=X,oe}O(te)},C=M=>{b[M]+=1,f[M]=null,h[M]=null,!y()&&!m&&k()},D=(M,K)=>{An(K,`${M} delay`),d="legacy",b[M]+=1,h[M]=null,f[M]=Qa({mode:"legacy",kind:M,instanceToken:{},delayMs:K}),L()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return D("auto",M.payload?.delay??Ha.auto),!0;case"clearAutoNextTimer":return C("auto"),!0;case"startSkipNextTimer":return D("skip",M.payload?.delay??Ha.skip),!0;case"clearSkipNextTimer":return C("skip"),!0;case"nextLineConfigTimer":return D("authored",M.payload?.delay??Ha.authored),!0;case"clearNextLineConfigTimer":return C("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let K;try{K=Ik(M)}catch(X){try{v()}catch(te){throw new AggregateError([X,te],"Playback schedule validation and cleanup both failed")}throw X}if(d="reconciled",K.status==="unsettled"){E(),m||k();return}let le={};for(let X of $i){let te=K.timers[X],oe=h[X];if(oe&&(!te||!Wa(oe,te))&&(h[X]=null),te&&h[X]&&Wa(h[X],te)){le[X]=null;continue}let ne=f[X];le[X]=te&&ne&&Wa(ne.descriptor,te)?ne:te?Qa(te):null}f=le,y()?L():m||k()},reset:()=>{let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);r={},s={},w(),i=null,u=null,E(),h={auto:null,skip:null,authored:null};for(let X of $i)b[X]+=1;d="legacy",a=!0;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K},dispose:()=>{a=!1,r={},s={},w(),E(),h={auto:null,skip:null,authored:null};let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);i=null,u=null;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K}}};var vk=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),kk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Za="conditional",En="random",rl=Symbol("conditionalAutoContinue"),Ak=new Set(["sectionTransition","resetStoryAtSection"]),Pk=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),Ek=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),xk=new Set(["nextLine","nextLineFromSystem"]),Sk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),el="form",Ok=new Set(["submitForm","cancelForm"]),Rk="showImageGalleryVariant",Ck="playMusicRoomTrack",$k="startSceneReplay",_k="channel:bgm",jk=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Be=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Nk=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,xn=e=>e?.type===rl,lt=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Dk=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function tl(e){let t=Nk(),n,o=0,a=!1,r=0,s=null,i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,b=0,y=[],w=[],g=!1,A=null,k=null,E=null,v=null,O=new Map,L,C,D=null,B=!1,_=!1,G=0,fe=new Map,M=fc(e.randomSource),{handlePendingEffects:K}=e;if(typeof K!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=K.bind(K),X=typeof K.reconcilePlaybackScheduleV1=="function"?K.reconcilePlaybackScheduleV1.bind(K):null,te=typeof K.reset=="function"?K.reset.bind(K):null,oe=typeof K.dispose=="function"?K.dispose.bind(K):null;if(X&&(!te||!oe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let ne=I=>{if(_)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ue=I=>{if(ne(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},Z=(I,P)=>{if(G===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=fe.get(I);(R===void 0||S[P]>S[R])&&fe.set(I,P)},$=I=>{let P=fe.get(I)??"preCommit";return fe.delete(I),P},j=I=>{if(X){_=!0;try{let P=X(structuredClone(I));if(P!==null&&(typeof P=="object"||typeof P=="function")&&typeof P.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{_=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),J=I=>{if(!(!X||!a||!n)){B=!0;try{j(F())}catch(P){if(I){let S=new AggregateError([I,P],"Playback work and schedule invalidation both failed");throw fe.delete(I),Z(S,"reconcileFailed"),S}throw Z(P,"reconcileFailed"),P}}},de=()=>{if(!X||!B||!a||!n||i>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(P){throw Z(P,"reconcileFailed"),J(P),P}try{j({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(P){throw Z(P,"reconcileFailed"),J(P),P}B=!1},Ie=(I=new Map,P=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>P<S.expiresAt).map(([S,R])=>[S,{animation:structuredClone(R.animation),startedAt:R.startedAt,expiresAt:R.expiresAt}])),we=(I=new Map)=>Array.from(I.values()).map(P=>structuredClone(P.animation)),me=(I=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,P])=>I<P.expiresAt))},mr=()=>{if(a&&!(i>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,P=[...n.selectPendingEffects()],S=P.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let R=X?S.filter(N=>!Pn.has(N.name)):S;R.length>0&&le(R)}catch(R){throw n.clearPendingEffects(),P.forEach(N=>{n.appendPendingEffect(N)}),Z(R,"postCommitUnsettled"),J(R),R}}}finally{l=!1}de()}},We=I=>{i+=1;let P=!1;try{let S=I();return P=!0,S}finally{i-=1,P&&mr()}},Sn=()=>{let I=n.selectSystemState();return n.selectRuntime()?.skipTransitionsAndAnimations===!0||Ma(I)},Br=()=>{let I=n.selectSystemState();return I.projectData?Zo({presentationState:n.selectPresentationState(),previousBgmRender:ct(),resources:I.projectData?.resources,runtime:n.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer,skipTransitionsAndAnimations:Sn()}):null},Ur=()=>n.selectSystemState().projectData?structuredClone(n.selectPresentationState()?.bgm??null):null,Pr=()=>({audioEffects:structuredClone(n.selectSystemState().projectData?.resources?.audioEffects??{}),sounds:On()}),On=()=>structuredClone(n.selectSystemState().projectData?.resources?.sounds??{}),ct=()=>({channel:A,bgm:k,resources:E}),jt=I=>!!I?.audioEffects,Yr=()=>structuredClone(g?A:Br()),ut=()=>g?structuredClone(k):Ur(),zr=()=>g?structuredClone(E):Pr(),Rn=I=>{let P=n.selectSystemState().projectData?.story?.scenes??{};return Object.entries(P).find(([,S])=>S?.sections?.[I])?.[0]},_i=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,P=new Set(I?[]:y.map(S=>S.id));w.forEach(S=>{S.status=S.effects?.some(R=>P.has(R.id))?"active":"settled"}),I&&(y=[]),w=[]},Nt=(I,P,S,R,N,U,z)=>{let W=n.selectPlaybackLineEntryId?.()??0,ce=(P.actionPath??["bgm"]).join("."),he=n.selectCurrentPointer()?.pointer,ge=he?.sceneId??Rn(he?.sectionId),ve=P.rollbackSource==="line"&&he?`story.scenes[${JSON.stringify(ge)}].sections[${JSON.stringify(he.sectionId)}].lines[${JSON.stringify(he.lineId)}].actions.${ce}`:ce,Re=P.rollbackSource==="line"?`${o}:${W}:${ve}`:null,Ue=Re?O.get(Re):null;if(Ue)return Ue;b+=1;let De={occurrenceId:`${t}:g${o}:l${W}:audio${b}`,actionPath:ve,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Te=Pr(),Ce=Oc({occurrence:De,resources:Te,previousResources:z??Te,nextResources:Te,previousChannel:S,nextChannel:R,previousBgm:N,nextBgm:U});if(De.effects=structuredClone(Ce),De.status=Ce.length>0?"pending":"settled",y=structuredClone(Ce),w.push(De),Re)for(O.set(Re,De);O.size>512;){let ft=O.keys().next().value;O.delete(ft)}return De},Bd=({initialState:I,namespace:P})=>{ne("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...N}=I,U=R===void 0?void 0:structuredClone(R),z=structuredClone(I.projectData),W=Nd({projectData:z,l10nData:U}),ce=N.global??{};if(!Be(ce))throw new Error("Malformed global state.");let he=ce.runtime??{};if(!Be(he))throw new Error("Malformed global.runtime.");let ge=he.localizationPackageId;if(ge!=null&&typeof ge!="string")throw new Error("localizationPackageId requires a string or null value");let ve=new Set(W.map(({l10nId:Te})=>Te).filter(Te=>Te!==null)),Re=typeof ge=="string"&&ve.has(ge)?ge:null,Ue=Ci({projectData:z,l10nData:U,l10nId:Re}),De=cf({...N,global:{...ce,localizationPackages:W,runtime:{...he,localizationPackageId:Re}},projectData:Ue,initialAudioCommandId:S});te?.(),n=De,o+=1,a=!0,r=0,s=Ct(P),i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,b=0,y=[],w=[],g=!1,A=null,k=null,E=null,v={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Pr()},O=new Map,L=z,C=U,D=Re,B=!0,_=!1,G=0,fe.clear(),n.appendPendingEffect({name:"handleLineActions"}),mr()},Ud=()=>{ne("dispose"),a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,y=[],w=[],g=!1,A=null,k=null,E=null,v=null,O=new Map,B=!1,fe.clear(),oe?.())},Yd=()=>s,zd=()=>n.selectPresentationState(),Xd=()=>n.selectPresentationChanges(),Gd=I=>n.selectSectionLineChanges(I),sl=(I={})=>{ue("rendering"),r+=1;let P=Date.now();me(P);let S=f.size>0,R=Ie(d,P),N=S?Ie(f,P):new Map,U=n.selectRenderState({previousBgmRender:ct(),activePersistentAnimations:we(R),restoredPersistentAnimations:we(N),activeAudioEffects:structuredClone(y)}),z={...U,id:`render-${t}-${o}-${r}`};return h.set(z.id,{builtAt:P,persistentAnimationSessions:new Map([...N.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectIds:y.map(W=>W.id),bgmPresentation:Ur(),bgmResources:Pr(),retainsActiveAudioEffects:y.length>0&&y.every(W=>(U.audioEffects??[]).some(ce=>ce.id===W.id))}),z},Hd=(I={})=>sl(I),Kd=(I={})=>sl(I),Wd=I=>{if(!a||!n)return;let P=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=P?h.get(P):null;P&&h.delete(P);let R=I?.audio?.find(U=>U?.id===_k);g=!0,A=R?structuredClone(R):null,k=structuredClone(S?.bgmPresentation??null),E=structuredClone(S?.bgmResources??null);let N=new Map;au(I?.animations).forEach(U=>{let z=us(U);if(!z)return;let W=S?.persistentAnimationSessions?.get(z)??d.get(z),ce=Math.max(0,uu(U)),he=W?.startedAt??S?.builtAt??Date.now();N.set(z,{animation:structuredClone(U),startedAt:he,expiresAt:he+ce})}),d=N,S?.usedRestoredPersistentAnimationSessions&&(f=new Map),S?.activeAudioEffectIds?.length>0&&!S.retainsActiveAudioEffects&&y.length===S.activeAudioEffectIds.length&&S.activeAudioEffectIds.every(U=>y.some(z=>z.id===U))&&(y=[])},Jd=()=>n.selectSystemState(),Qd=()=>n.selectAchievements(),Zd=I=>n.selectAchievement(I),il=()=>n.selectSaveSlotMap(),em=I=>n.selectSaveSlot(I),rm=I=>n.selectSaveSlotPage(I),tm=()=>n.selectImageGallery(),nm=()=>n.selectMusicRoom(),sm=()=>n.selectSceneReplay(),im=()=>n.selectIsSceneReplayActive(),Hk=()=>n.selectSkipMode(),Kk=()=>n.selectAutoMode(),om=()=>n.selectRuntime(),am=()=>n.selectIsChoiceVisible(),lm=()=>n.selectIsFormVisible(),cm=()=>n.selectActiveInteraction(),um=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),ol=(I,P,S={})=>!Be(P)||I!=="nextLine"?P:S.bypassChoice===!0?{...P,bypassChoice:!0}:S.interactionSource===el?{...P,_interactionSource:el}:P,al=(I={})=>({type:rl,payload:ol("nextLine",{_conditionalContinuation:!0},I)}),ji=(I,P)=>xn(I)?{type:rl,payload:{...I.payload,...P.payload}}:P,pm=I=>{I.savedCheckpointOccurrences.forEach(P=>{n.markSavedRollbackCheckpointTransient(P)}),I.savedCheckpointOccurrences=[]},fm=(I,P)=>{let S=p;return p=null,!S||!lt(S.pointer,I)||S.checkpointIndex!==P?.checkpointIndex||S.checkpointIdentity!==P?.checkpoint?[]:S.savedCheckpointOccurrences},dm=I=>{let P=m;return!P||!lt(P.pointer,I)?null:(m=null,P)},mm=({actionType:I,pointerBeforeAction:P,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:N,wasSceneReplayActive:U,isSceneReplayActive:z})=>{!S||!(!lt(P,S)||R?.checkpoint!==N?.checkpoint||R?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(m={pointer:S,appendToPrevious:xk.has(I)&&U===z&&P?.sectionId===S.sectionId&&P?.lineId!==S.lineId,reuseExistingOccurrence:Sk.has(I),forceNewOccurrence:I==="jumpToLine"})},ll=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),pm(I))},ym=(I,P,S)=>Pk.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==P?.checkpoint:S?.checkpoint!==P?.checkpoint&&S?.checkpointIndex>P?.checkpointIndex:!1,hm=I=>{let P=u.at(-1);if(!P?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&P.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:P.rollbackCursor?.checkpointIndex,sectionId:P.pointer?.sectionId,lineId:P.pointer?.lineId})},gm=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(P=>{let S=n.selectSaveSlot({slotId:P.slotId});S&&(P.saveSlotIdentity=S)})},bm=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},wm=(I,P,S)=>{let R=u.at(-1);if(!R)return;let N=n.selectCurrentPointer()?.pointer,U=ym(I,P,S);if(lt(R.pointer,N)){let z=S?.checkpoint!==P?.checkpoint||S?.checkpointIndex!==P?.checkpointIndex;U||z&&Ek.has(I)?(ll(R),R.pointer=N,R.rollbackCursor=S,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]):z&&I==="updateProjectData"&&(R.rollbackCursor=S);return}ll(R),R.pointer=N,R.rollbackCursor=n.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]},pt=(I,P)=>{if(ue(`action "${I}"`),!n[I])return;let S=P,R,N;if(I==="updateProjectData")cl(P),R=structuredClone(P.projectData),S={...P,projectData:Ci({projectData:R,l10nData:C,l10nId:D})},cl(S);else if(I==="updateLocalizationPackage"){if(N=Im(P),N===D)return;S={l10nId:N,projectData:Ci({projectData:L,l10nData:C,l10nId:N})}}Ak.has(I)&&(c+=1);let U=n.selectAutoMode(),z=U?n.selectRuntime():null,W=n.selectIsSceneReplayActive?.()===!0,ce=kk.has(I)?Ie(d):null,he=n.selectCurrentPointer()?.pointer??null,ge=n.selectRollbackCursor?.()??null,ve=rs(I),Re=ve?n.selectPlaybackLineEntryId?.()??0:null,Ue=ve?Yr():null,De=ve?ut():null,Te=ve?zr():null,Ce=!1,ft;try{ft=n[I](S),Ce=!0}catch(Dt){throw Z(Dt,"preCommit"),Dt}R!==void 0&&(L=R),N!==void 0&&(D=N),vk.has(I)&&(f=ce??new Map,d=new Map,y=[]),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=[]);let yl=n.selectIsSceneReplayActive?.()===!0;W!==yl&&(d=new Map,f=new Map);let Nm=n.selectCurrentPointer()?.pointer??null,hl=n.selectRollbackCursor?.()??null,gl=ve?n.selectPlaybackLineEntryId?.()??0:null;ve&&gl!==Re&&(v={lineEntryId:gl,channel:Ue,presentation:De,resources:Te}),I==="saveSlot"?hm(P):I==="updateProjectData"&&gm(),wm(I,ge,hl),mm({actionType:I,pointerBeforeAction:he,pointerAfterAction:Nm,cursorBeforeAction:ge,cursorAfterAction:hl,wasSceneReplayActive:W,isSceneReplayActive:yl});let Dm=n.selectAutoMode()&&(I==="updateVariable"||U&&Dk(z,n.selectRuntime()));(jk.has(I)||Dm)&&(B=!0);try{mr()}catch(Dt){throw Ce&&Z(Dt,"postCommitUnsettled"),Dt}return ft},cl=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Qr(I?.projectData?.resources?.variables??{}),Bt(I.projectData),Ut(I.projectData),Yt(I.projectData)},Im=I=>{if(!Be(I))throw new Error("updateLocalizationPackage requires an object payload");let P=Object.keys(I);if(P.length!==1||P[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},vm=(I,P,S)=>{let R=n.selectCurrentPointer()?.pointer;P!==R||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),pt("nextLineFromSystem",I.payload))},km=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(h),audioEffectOccurrenceSequence:b,activeAudioEffects:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:v?structuredClone(v):null,acceptedLineBgmActionOccurrences:new Map(O),canonicalProjectData:L,localizationPackageId:D,playbackScheduleDirty:B}),Am=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,m=I.pendingDialogueHistoryLineEntry,d=new Map(I.persistentAnimationSessions),f=new Map(I.restoredPersistentAnimationSessions),h=new Map(I.renderPersistentAnimationMetadata),b=I.audioEffectOccurrenceSequence,y=I.activeAudioEffects,w=I.pendingAudioEffectOccurrences.slice(),v=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,O=new Map(I.acceptedLineBgmActionOccurrences),L=I.canonicalProjectData,D=I.localizationPackageId,B=I.playbackScheduleDirty},Ni=(I,P={})=>(ue("action batch"),We(()=>{let S=km();try{return n[lo](()=>{let R,N=n.selectCurrentPointer()?.pointer??null,U=n.selectRollbackCursor?.()??null,z=c,W={pointer:N,rollbackCursor:U,markCurrentCheckpointTransient:P.rollbackSource==="line",savedCheckpointOccurrences:P.savedCheckpointOccurrences?.slice()??[]};u.push(W);try{n.beginRollbackActionBatch({source:P.rollbackSource});try{R=I()}finally{n.endRollbackActionBatch({})}xn(R)&&vm(R,N,z),_i();let ce=n.selectCurrentPointer()?.pointer??null;P.rollbackSource==="line"&<(N,ce)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:W.savedCheckpointOccurrences,appendToPrevious:P.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:P.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:P.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!lt(N,W.pointer)||U?.checkpoint!==W.rollbackCursor?.checkpoint)&&W.markCurrentCheckpointTransient&&W.savedCheckpointOccurrences.length>0&&(p={pointer:W.pointer,checkpointIndex:W.rollbackCursor?.checkpointIndex,checkpointIdentity:W.rollbackCursor?.checkpoint,savedCheckpointOccurrences:W.savedCheckpointOccurrences})}})}catch(R){throw Am(S),R}})),Di=(I,P,S,R={})=>{if(I===Za||I===En)return Ni(()=>{let N={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===En)return fl(P,S,N);let U=Ti(S),z=Ht({[I]:P},U);return pl(z[I],S,N)},R);if(I==="bgm")return Ni(()=>{let N=ut(),U=jt(P),z=U?Yr():null,W=U?zr():null;pt(I,P);let ce=Ur();Nt(P,{...R,actionPath:R.actionPath??[I]},z,U?Br():null,N,ce,W)},R);pt(I,P)},Pm=(I,P)=>{if(I!=="nextLineFromSystem")return Di(I,P);G+=1;try{return Di(I,P)}finally{G=Math.max(0,G-1)}},ul=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Ti=I=>{if(ul(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:P,...S}=I,R=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:P,variables:R,runtime:n.selectRuntime?n.selectRuntime():{}}},Em=I=>{if(!Be(I))return{templatePayload:I,literalTargetIds:null};let P=n.selectImageGalleryConfig();if(!Array.isArray(P?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?P.groups.find(N=>N.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let R=typeof I.variantId=="string"&&S.variants.some(N=>N.id===I.variantId);return{templatePayload:{...I,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...R?{variantId:I.variantId}:{}}}},xm=I=>!Be(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Sm=I=>!Be(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},Om=I=>{if(!Be(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},Rm=(I,P,S)=>{if(!Be(I))throw new Error(`conditional branch at index ${P} must be an object`);if(!Be(I.actions))throw new Error(`conditional branch at index ${P} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&P!==S-1)throw new Error("conditional else branch must be the last branch")},pl=(I,P,S)=>{Om(I);let R=al(S);for(let N=0;N<I.branches.length;N+=1){let U=I.branches[N];Rm(U,N,I.branches.length);let z=Ti(P);if(Object.prototype.hasOwnProperty.call(U,"when")&&!Ft(U.when,z))continue;let ce=Cn(U.actions,P,{...S,actionPath:[...S.actionPath??[Za],"branches",String(N),"actions"]});return xn(ce)?ji(R,ce):R}return R},Cm=I=>{if(!Be(I))throw new Error("random action payload must be an object");let P=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(P!==void 0)throw new Error(`random action.${P} is not supported`);if(!Be(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=L?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||_e(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},fl=(I,P,S)=>{Cm(I),ul(P);let R=dc(I.distribution,{randomSource:M});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let z=(S.actionPath??[En]).join("."),W=S.randomOutcomeOrdinals??new Map,ce=W.get(z)??0;W.set(z,ce+1),n.recordRandomOutcome({path:z,ordinal:ce,type:R.type,result:R}),bm()}let N;R.type==="integer"?pt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):N=Cn(I.distribution.outcomes[R.outcomeIndex].actions,P,{...S,actionPath:[...S.actionPath??[En],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let U=al(S);return xn(N)?ji(U,N):U},$m=(I,P)=>({...I??{},_form:P}),_m=(I,P,S,R)=>{let N=pt(I,P),U=N?.submitted===!0&&N.valid===!0,z=N?.cancelled===!0;if(!(!U&&!z)&&Be(P.actions))return Cn(P.actions,$m(S,N.form),{...R,interactionSource:el})},dl=(I,P,S,R)=>{if(I===En)return fl(P,S,R);let N=Ti(S),U={templatePayload:P,literalTargetIds:null};I===Rk?U=Em(P):I===Ck?U=xm(P):I===$k&&(U=Sm(P));let{templatePayload:z,literalTargetIds:W}=U,he=Ht({[I]:z},N)[I],ge=W?{...he,...W}:he;if(I===Za)return pl(ge,S,R);let ve=ol(I,ge,R);if(Ok.has(I))return _m(I,ve,S,R);let Re=null,Ue=null,De=null,Te=!1;if(I==="bgm"){let Ce=R.audioEffectHandoff,ft=Ce?.available?Ce.presentation:ut();Te=jt(ve),Te&&Ce?.available?(Ce.available=!1,Re=structuredClone(Ce.channel),Ue=structuredClone(Ce.presentation),De=structuredClone(Ce.resources)):Te&&(Re=Yr(),Ue=ft,De=zr())}if(pt(I,ve),I==="bgm"){let Ce=Ur();Nt(ve,R,Re,Te?Br():null,Ue,Ce,De)}},Cn=(I,P,S)=>{let R,N=S?.executionContext??{depth:0,pendingNavigation:null},U=es(I);ts(U),N.depth+=1;try{for(let[z,W]of U){let ce={...S,executionContext:N,actionPath:[...S?.actionPath??[],z]};if(rs(z)){let ge=N.pendingNavigation;if(ge)throw new Error(`action batch cannot execute multiple navigation actions: ${ge.actionType}, ${z}`);N.pendingNavigation={actionType:z,payload:W,eventContext:P,options:ce};continue}let he=dl(z,W,P,ce);xn(he)&&(R=ji(R,he))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let z=N.pendingNavigation;N.pendingNavigation=null,dl(z.actionType,z.payload,z.eventContext,z.options)}return R},ml=(I,P,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Ni(()=>Cn(I,P,R),R)},jm=I=>{let P=n.selectCurrentPointer()?.pointer;if(I!==P||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:Bd,dispose:Ud,handleAction:Di,handleInternalAction:Pm,handleActions:ml,selectRenderState:Hd,prepareRenderState:Kd,commitRenderState:Wd,selectPresentationState:zd,selectPresentationChanges:Xd,selectSectionLineChanges:Gd,selectSystemState:Jd,selectAchievements:Qd,selectAchievement:Zd,selectSaveSlotMap:il,selectSaveSlot:em,selectSaveSlotPage:rm,selectSaveSlots:il,selectImageGallery:tm,selectMusicRoom:nm,selectSceneReplay:sm,selectIsSceneReplayActive:im,selectRuntime:om,selectIsChoiceVisible:am,selectIsFormVisible:lm,selectActiveInteraction:cm,selectHasPendingRenderWork:um,handleLineActions:I=>{ue("line action handling");let P=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!lt(I.pointer,P))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return We(()=>{let S=n.selectCurrentPointer()?.pointer,R=n.selectPlaybackLineEntryId?.()??0,N=v?.lineEntryId===R?v:null,U=N?{available:!0,channel:structuredClone(N.channel),presentation:structuredClone(N.presentation),resources:structuredClone(N.resources)}:null,z=n.selectRollbackCursor?.()??null,W=p,ce=m,he=fm(S,z),ge=dm(S),ve=n.selectCurrentLine(),Re=!1;if(ve?.actions){try{ml(ve.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:he,dialogueHistoryAppendToPrevious:ge?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ge?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ge?.forceNewOccurrence===!0,audioEffectHandoff:U})}catch(Ue){throw p=W,m=ce,Ue}Re=!0}return v?.lineEntryId===R&&(v=null),jm(S),Re})},getNamespace:Yd,classifyAutomaticAttemptError:$}}var Tk="music-room:player",qd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Md=(e,t)=>qd.has(e)&&t?._event?.id===Tk,Fd=({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(r)??e.selectRenderState(r);n?.(s),t.render(s),a(o)&&e.commitRenderState?.(s)},Lk=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&Fd({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},Mk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},Vk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},qk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},Fk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},Bk=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Vd={render:Fd,saveSlots:Mk,saveGlobalDeviceVariables:Vk,saveGlobalAccountVariables:qk,saveGlobalRuntime:Fk,applyScopedDataUpdates:Bk,handleLineActions:Lk},Uk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),nl=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},Yk=(e=[])=>{let t=new Set,n=[];for(let o=e.length-1;o>=0;o-=1){let a=e[o];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!Uk.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},zk=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,m=!1,d=0,f=0,h=!0,b=Ld({ticker:n,dispatchAutomaticAttempt:()=>nl(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:$=>e()?.classifyAutomaticAttemptError?.($)??"preCommit"}),y=()=>{u=null,p=null,m=!1,d=0},w=()=>{b.reset(),f+=1,y(),h=!0},g=()=>{f+=1,h=!1,y(),b.dispose()},A=$=>h&&$===f,k=$=>{if(a){a($);return}console.error("RouteEngine persistence write failed.",$)},E=$=>{if(s)return s;let j=Ct($),F=l.get(j);if(F)return F;let J=Ua({indexedDB:r,namespace:j});return l.set(j,J),J},v=$=>{let j=s?null:Ct(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=E(j),$(F))).catch(J=>{!s&&l.get(j)===F&&l.delete(j),k(J)})},O=$=>{if(!h)return;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;d+=1,u=j,m=!1},L=()=>d,C=($={})=>{if(!h||$?.aborted===!0)return!1;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||m?!1:(m=!0,!0)},D=($,j={})=>{if(!h)return!1;if(Md($,j)){let J=qd.get($),de=e();return nl(de,J,j?._event),!0}if($!=="renderComplete"||!C(j))return!1;let F=e();return nl(F,"markLineCompleted",{}),!0},B=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),G=$=>typeof $?.selectActiveInteraction=="function"?$.selectActiveInteraction():typeof $?.selectIsChoiceVisible=="function"&&$.selectIsChoiceVisible()?{source:"choice"}:null,fe=$=>$?._formKey??$?.formKey,M=($,j)=>fe($)===j?.formKey,K=($,j)=>!$||typeof $!="object"||Array.isArray($)?!1:$._interactionSource===j?.source,le=($,j)=>K($,j)?j.source==="form"?M($,j):!0:!1,X=($,j)=>!$||typeof $!="object"||Array.isArray($)||j?.source!=="form"?!1:M($,j),te=($={},j)=>Object.keys($).length>0&&Object.entries($).every(([F,J])=>B.has(F)?X(J,j):_.has(F)),oe=($={},j)=>{let F=$?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:te(F,j):le($,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(J=>le(J,j))},ne=($,j={})=>{if(!j?.actions)return!1;let F=G($);return!F||F.source==="choice"?!1:!oe(j,F)},ue=({preprocessPayload:$,onEvent:j}={})=>async(F,J={})=>{if(!h)return!1;if(Md(F,J))return D(F,J),j?.(F,J);let de=e(),Ie=f,we=d;if(ne(de,J))return j?.(F,J);let me=await $?.(F,J)??J;if(!A(Ie)||e()!==de||d!==we)return!1;if(ne(de,me))return j?.(F,me);if(D(F,me),me?.actions){let mr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,We;me?.bypassChoice===!0?We={bypassChoice:!0}:me?._interactionSource&&(We={interactionSource:me._interactionSource}),We?de.handleActions(me.actions,mr,We):de.handleActions(me.actions,mr)}return j?.(F,me)},Z=$=>{if(!h)return;let j=f,F=e(),J=Yk($),de=J.some(we=>we.name==="handleLineActions");J.forEach(we=>{if(!Vd[we.name]&&!Pn.has(we.name)&&!o)throw new Error(`Unhandled pending effect "${we.name}".`)});let Ie={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:L,enqueuePersistenceWrite:v,lifecycleGeneration:f,isCurrentLifecycle:A};for(let we of J){if(!A(j))break;if(de&&we.name==="render")continue;if(Pn.has(we.name)){b.handleLegacyEffect(we);continue}let me=Vd[we.name];if(me){me(Ie,we.payload);continue}o(we,Ie)}};return Z.handleRouteGraphicsEvent=D,Z.createRouteGraphicsEventHandler=ue,Z.reset=w,Z.dispose=g,Z.reconcilePlaybackScheduleV1=$=>b.reconcilePlaybackScheduleV1($),Z},Xk=zk;var Gk=(e,t={})=>{let{resources:n={}}=t;return Xo(e,n)};var KP=tl;export{xo as DEFAULT_VISUAL_LAYER,wt as RENDER_LAYER,yr as VISUAL_LAYER,Xk as createEffectsHandler,kv as createIndexedDbPersistence,KP as default,uo as formatDate,oh as resolveComputedVariables,Gk as resolveLayoutReferences};
|