route-engine-js 1.36.0 → 1.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteEngine.js +2 -2
- package/package.json +5 -4
package/dist/RouteEngine.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var bp=Object.defineProperty;var wp=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Ip=(e,r)=>{for(var n in r)bp(e,n,{get:r[n],enumerable:!0})};var Dc=wp(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});function Nc(e){let r=e.length,n=0,o=0,a;for(;o<r;)n++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<r&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return n}ei.default=Nc;Nc.code='require("ajv/dist/runtime/ucs2length").default'});var bi=Symbol.for("immer-nothing"),di=Symbol.for("immer-draftable"),Ae=Symbol.for("immer-state");function _e(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var jr=Object.getPrototypeOf;function he(e){return!!e&&!!e[Ae]}function dr(e){return e?wi(e)||Array.isArray(e)||!!e[di]||!!e.constructor?.[di]||qt(e)||Vt(e):!1}var vp=Object.prototype.constructor.toString();function wi(e){if(!e||typeof e!="object")return!1;let r=jr(e);if(r===null)return!0;let n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===vp}function ks(e){return he(e)||_e(15,e),e[Ae].base_}function Dt(e,r){Mt(e)===0?Reflect.ownKeys(e).forEach(n=>{r(n,e[n],e)}):e.forEach((n,o)=>r(o,n,e))}function Mt(e){let r=e[Ae];return r?r.type_:Array.isArray(e)?1:qt(e)?2:Vt(e)?3:0}function gs(e,r){return Mt(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function Ii(e,r,n){let o=Mt(e);o===2?e.set(r,n):o===3?e.add(n):e[r]=n}function Ap(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}function qt(e){return e instanceof Map}function Vt(e){return e instanceof Set}function fr(e){return e.copy_||e.base_}function bs(e,r){if(qt(e))return new Map(e);if(Vt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=wi(e);if(r===!0||r==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Ae];let a=Reflect.ownKeys(o);for(let t=0;t<a.length;t++){let s=a[t],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(jr(e),o)}else{let o=jr(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Ps(e,r=!1){return Ft(e)||he(e)||!dr(e)||(Mt(e)>1&&(e.set=e.add=e.clear=e.delete=kp),Object.freeze(e),r&&Object.entries(e).forEach(([n,o])=>Ps(o,!0))),e}function kp(){_e(2)}function Ft(e){return Object.isFrozen(e)}var Pp={};function mr(e){let r=Pp[e];return r||_e(0,e),r}var rt;function vi(){return rt}function xp(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function mi(e,r){r&&(mr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function ws(e){Is(e),e.drafts_.forEach(Ep),e.drafts_=null}function Is(e){e===rt&&(rt=e.parent_)}function yi(e){return rt=xp(rt,e)}function Ep(e){let r=e[Ae];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function hi(e,r){r.unfinalizedDrafts_=r.drafts_.length;let n=r.drafts_[0];return e!==void 0&&e!==n?(n[Ae].modified_&&(ws(r),_e(4)),dr(e)&&(e=Tt(r,e),r.parent_||Lt(r,e)),r.patches_&&mr("Patches").generateReplacementPatches_(n[Ae].base_,e,r.patches_,r.inversePatches_)):e=Tt(r,n,[]),ws(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==bi?e:void 0}function Tt(e,r,n){if(Ft(r))return r;let o=r[Ae];if(!o)return Dt(r,(a,t)=>gi(e,o,r,a,t,n)),r;if(o.scope_!==e)return r;if(!o.modified_)return Lt(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,t=a,s=!1;o.type_===3&&(t=new Set(a),a.clear(),s=!0),Dt(t,(i,l)=>gi(e,o,a,i,l,n,s)),Lt(e,a,!1),n&&e.patches_&&mr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function gi(e,r,n,o,a,t,s){if(he(a)){let i=t&&r&&r.type_!==3&&!gs(r.assigned_,o)?t.concat(o):void 0,l=Tt(e,a,i);if(Ii(n,o,l),he(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(dr(a)&&!Ft(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Tt(e,a),(!r||!r.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&Lt(e,a)}}function Lt(e,r,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ps(r,n)}function Sp(e,r){let n=Array.isArray(e),o={type_:n?1:0,scope_:r?r.scope_:vi(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,t=xs;n&&(a=[o],t=tt);let{revoke:s,proxy:i}=Proxy.revocable(a,t);return o.draft_=i,o.revoke_=s,i}var xs={get(e,r){if(r===Ae)return e;let n=fr(e);if(!gs(n,r))return Rp(e,n,r);let o=n[r];return e.finalized_||!dr(o)?o:o===ys(e.base_,r)?(hs(e),e.copy_[r]=As(o,e)):o},has(e,r){return r in fr(e)},ownKeys(e){return Reflect.ownKeys(fr(e))},set(e,r,n){let o=Ai(fr(e),r);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=ys(fr(e),r),t=a?.[Ae];if(t&&t.base_===n)return e.copy_[r]=n,e.assigned_[r]=!1,!0;if(Ap(n,a)&&(n!==void 0||gs(e.base_,r)))return!0;hs(e),vs(e)}return e.copy_[r]===n&&(n!==void 0||r in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[r])||(e.copy_[r]=n,e.assigned_[r]=!0),!0},deleteProperty(e,r){return ys(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,hs(e),vs(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){let n=fr(e),o=Reflect.getOwnPropertyDescriptor(n,r);return o&&{writable:!0,configurable:e.type_!==1||r!=="length",enumerable:o.enumerable,value:n[r]}},defineProperty(){_e(11)},getPrototypeOf(e){return jr(e.base_)},setPrototypeOf(){_e(12)}},tt={};Dt(xs,(e,r)=>{tt[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}});tt.deleteProperty=function(e,r){return tt.set.call(this,e,r,void 0)};tt.set=function(e,r,n){return xs.set.call(this,e[0],r,n,e[0])};function ys(e,r){let n=e[Ae];return(n?fr(n):e)[r]}function Rp(e,r,n){let o=Ai(r,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Ai(e,r){if(!(r in e))return;let n=jr(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return o;n=jr(n)}}function vs(e){e.modified_||(e.modified_=!0,e.parent_&&vs(e.parent_))}function hs(e){e.copy_||(e.copy_=bs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Op=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,o)=>{if(typeof r=="function"&&typeof n!="function"){let t=n;n=r;let s=this;return function(l=t,...u){return s.produce(l,c=>n.call(this,c,...u))}}typeof n!="function"&&_e(6),o!==void 0&&typeof o!="function"&&_e(7);let a;if(dr(r)){let t=yi(this),s=As(r,void 0),i=!0;try{a=n(s),i=!1}finally{i?ws(t):Is(t)}return mi(t,o),hi(a,t)}else if(!r||typeof r!="object"){if(a=n(r),a===void 0&&(a=r),a===bi&&(a=void 0),this.autoFreeze_&&Ps(a,!0),o){let t=[],s=[];mr("Patches").generateReplacementPatches_(r,a,t,s),o(t,s)}return a}else _e(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(s,...i)=>this.produceWithPatches(s,l=>r(l,...i));let o,a;return[this.produce(r,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){dr(e)||_e(8),he(e)&&(e=er(e));let r=yi(this),n=As(e,void 0);return n[Ae].isManual_=!0,Is(r),n}finishDraft(e,r){let n=e&&e[Ae];(!n||!n.isManual_)&&_e(9);let{scope_:o}=n;return mi(o,r),hi(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,r){let n;for(n=r.length-1;n>=0;n--){let a=r[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(r=r.slice(n+1));let o=mr("Patches").applyPatches_;return he(e)?o(e,r):this.produce(e,a=>o(a,r))}};function As(e,r){let n=qt(e)?mr("MapSet").proxyMap_(e,r):Vt(e)?mr("MapSet").proxySet_(e,r):Sp(e,r);return(r?r.scope_:vi()).drafts_.push(n),n}function er(e){return he(e)||_e(10,e),ki(e)}function ki(e){if(!dr(e)||Ft(e))return e;let r=e[Ae],n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=bs(e,r.scope_.immer_.useStrictShallowCopy_)}else n=bs(e,!0);return Dt(n,(o,a)=>{Ii(n,o,ki(a))}),r&&(r.finalized_=!1),n}var Se=new Op,Es=Se.produce,X0=Se.produceWithPatches.bind(Se),W0=Se.setAutoFreeze.bind(Se),H0=Se.setUseStrictShallowCopy.bind(Se),K0=Se.applyPatches.bind(Se),J0=Se.createDraft.bind(Se),Q0=Se.finishDraft.bind(Se);var A={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},z={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Nr={NOT:0};var _=class extends Error{constructor(r){super(`Parse Error: ${r}`),this.name="JemplParseError"}},Ie=class extends Error{constructor(r){super(`Render Error: ${r}`),this.name="JemplRenderError"}};var Ss=e=>{if(!e||e.trim()==="")throw new _("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new _(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let r=["<",">","<=",">=","==","!="];for(let n of r)if(e.trim().endsWith(n))throw new _(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Pi=e=>{if(e.trim().endsWith(" in"))throw new _(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new _(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[r,n]=e.split(" in ");if(!n||n.trim()==="")throw new _(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=r.includes(",")?r.split(",").map(a=>a.trim()):[r.trim()];for(let a of o){if(!a)throw new _(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new _(`Invalid loop syntax (got: '$for ${e}')`)}};var xi=(e,r,n=!1)=>{if(r===null)return new Ie(`Cannot iterate over null value at '$for ${e}'`);if(r===void 0)return new Ie(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof r;return n?new Ie(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ie(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Ei=(e,r)=>{let n=r&&Object.keys(r).length>0?Object.keys(r).join(", "):"no custom functions provided";return new Ie(`Unknown function '${e}' (${n})`)};var Cp=(e,r,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=X(e,{functions:o,partials:a},r,{});return s===void 0?{}:s},X=(e,r,n,o)=>{let a=r.functions||r;if(e.var&&!e.type)return pe(e.var,n,o);if(e.type===A.LITERAL)return e.value;if(e.type===A.VARIABLE)return pe(e.path,n,o);if(e.type===A.INTERPOLATION)return _p(e.parts,r,n,o);switch(e.type){case A.FUNCTION:return Ri(e,r,n,o);case A.BINARY:return Oi(e,r,n,o);case A.UNARY:return Ci(e,r,n,o);case A.CONDITIONAL:return Np(e,r,n,o);case A.LOOP:return qp(e,r,n,o);case A.OBJECT:return Fp(e,r,n,o);case A.ARRAY:return Up(e,r,n,o);case A.PARTIAL:return Bp(e,r,n,o);case A.PATH_REFERENCE:return Yp(e,r,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Si=new Map,$p=e=>{let r=[],n="",o=!1;for(let a=0;a<e.length;a++){let t=e[a];if(t==="[")n&&(r.push({type:"property",value:n}),n=""),o=!0;else if(t==="]"){if(o&&n){let s=n.trim();if(/^\d+$/.test(s))r.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let i=s.slice(1,-1);r.push({type:"property",value:i})}else r.push({type:"property",value:s});n=""}o=!1}else n+=t}return n&&r.push({type:"property",value:n}),r},pe=(e,r,n)=>{if(!e)return;if(e in n)return n[e];let o=Si.get(e);if(!o){let t=[],s="",i=0;for(let l=0;l<e.length;l++){let u=e[l];u==="["?(i++,s+=u):u==="]"?(i--,s+=u):u==="."&&i===0?s&&(t.push(s),s=""):s+=u}s&&t.push(s),o=[];for(let l of t){let u=$p(l.trim());o.push(...u)}Si.set(e,o)}let a=r;for(let t=0;t<o.length;t++){let s=o[t];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},_p=(e,r,n,o)=>{let a=[];for(let t of e)if(typeof t=="string")a.push(t);else{let s=X(t,r,n,o);a.push(s!=null?String(s):"")}return a.join("")},Ri=(e,r,n,o)=>{let a=r.functions||r,t=a[e.name];if(!t)throw Ei(e.name,a);let s=e.args.map(i=>X(i,r,n,o));return t(...s)},rr=(e,r,n,o)=>{if(e.var&&!e.type)return pe(e.var,n,o);switch(e.type){case A.VARIABLE:return pe(e.path,n,o);case A.LITERAL:return e.value;case A.BINARY:return Oi(e,r,n,o);case A.UNARY:return Ci(e,r,n,o);case A.FUNCTION:return Ri(e,r,n,o);default:return X(e,r,n,o)}},Oi=(e,r,n,o)=>{if(e.op===z.AND||e.op===z.OR){let s=rr(e.left,r,n,o),i=rr(e.right,r,n,o);switch(e.op){case z.AND:return s&&i;case z.OR:return s||i}}let a=X(e.left,r,n,o),t=X(e.right,r,n,o);switch(e.op){case z.EQ:return a==t;case z.NEQ:return a!=t;case z.GT:return a>t;case z.LT:return a<t;case z.GTE:return a>=t;case z.LTE:return a<=t;case z.IN:return Array.isArray(t)?t.includes(a):!1;case z.ADD:if(typeof a!="number"||typeof t!="number")throw new Ie(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof t}`);return a+t;case z.SUBTRACT:if(typeof a!="number"||typeof t!="number")throw new Ie(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof t}`);return a-t;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ci=(e,r,n,o)=>{let a=e.op===Nr.NOT?rr(e.operand,r,n,o):X(e.operand,r,n,o);if(e.op===Nr.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},jp=(e,r,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===A.VARIABLE)if(pe(a.path,n,o)){let s=e.bodies[0];if(s.type===A.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let u=l.parsedKey?X(l.parsedKey,r,n,o):l.key,c=l.value;if(c.type===A.LITERAL)i[u]=c.value;else if(c.type===A.VARIABLE)i[u]=pe(c.path,n,o);else if(c.type===A.INTERPOLATION){let p=[];for(let m of c.parts)if(typeof m=="string")p.push(m);else if(m.type===A.VARIABLE){let d=pe(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=X(m,r,n,o);p.push(d!=null?String(d):"")}i[u]=p.join("")}else i[u]=X(c,r,n,o)}return i}}else{let s=e.bodies[1];if(s.type===A.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let u=l.parsedKey?X(l.parsedKey,r,n,o):l.key,c=l.value;if(c.type===A.LITERAL)i[u]=c.value;else if(c.type===A.VARIABLE)i[u]=pe(c.path,n,o);else if(c.type===A.INTERPOLATION){let p=[];for(let m of c.parts)if(typeof m=="string")p.push(m);else if(m.type===A.VARIABLE){let d=pe(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=X(m,r,n,o);p.push(d!=null?String(d):"")}i[u]=p.join("")}else i[u]=X(c,r,n,o)}return i}}}return null},Np=(e,r,n,o)=>{let a=jp(e,r,n,o);if(a!==null)return a;for(let t=0;t<e.conditions.length;t++){let s=e.conditions[t];if(s===null||rr(s,r,n,o))return X(e.bodies[t],r,n,o)}return $i},Dp=(e,r)=>{let n=e.body,o=e.itemVar;if(n.type===A.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===A.VARIABLE){let a=n.conditions[0].path,t=n.bodies[0];if(a.startsWith(o+".")){let s=a.substring(o.length+1);if(t.type===A.OBJECT&&t.properties.length<=5){for(let l of t.properties)if(l.parsedKey)return null;let i=[];for(let l=0;l<r.length;l++){let u=r[l];if(u[s]){let c={};for(let p of t.properties){let m=p.key,d=p.value;if(d.type===A.LITERAL)c[m]=d.value;else if(d.type===A.VARIABLE){let f=d.path;if(f===o)c[m]=u;else if(f.startsWith(o+".")){let y=f.substring(o.length+1);c[m]=u[y]}else return null}else if(d.type===A.INTERPOLATION){let f=[],y=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===A.VARIABLE){let h=g.path;if(h===o)f.push(u!=null?String(u):"");else if(h.startsWith(o+".")){let w=h.substring(o.length+1),b=u[w];f.push(b!=null?String(b):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[m]=f.join("")}else return null}i.push(c)}}return i}}}return null},Tp=(e,r)=>{let n=e.body,o=e.itemVar,a=Dp(e,r);if(a!==null)return a;if(n.type===A.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let i of n.properties)if(i.parsedKey)return null;let t=[],s=!0;for(let i of n.properties){let l=i.key,u=i.value;if(u.type===A.LITERAL)t.push({key:l,type:"literal",value:u.value});else if(u.type===A.VARIABLE){let c=u.path;if(c===o)t.push({key:l,type:"item"});else if(c.startsWith(o+".")){let p=c.substring(o.length+1);if(!p.includes(".")&&!p.includes("["))t.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(u.type===A.INTERPOLATION&&u.parts.length===1){let c=u.parts[0];if(c.type===A.VARIABLE){let p=c.path;if(p===o)t.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let m=p.substring(o.length+1);if(!m.includes(".")&&!m.includes("["))t.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(r.length);if(t.length===3&&t[0].type==="prop"&&t[0].key==="id"&&t[1].type==="prop_string"&&t[1].key==="title"&&t[2].type==="prop"&&t[2].key==="completed")for(let l=0;l<r.length;l++){let u=r[l];i[l]={id:u.id,title:u.title!=null?String(u.title):"",completed:u.completed}}else for(let l=0;l<r.length;l++){let u=r[l],c={};for(let p of t)if(p.type==="literal")c[p.key]=p.value;else if(p.type==="item")c[p.key]=u;else if(p.type==="prop")c[p.key]=u[p.prop];else if(p.type==="item_string")c[p.key]=u!=null?String(u):"";else if(p.type==="prop_string"){let m=u[p.prop];c[p.key]=m!=null?String(m):""}i[l]=c}return i}}return null},Lp=(e,r,n,o,a)=>{let t=[],s=e.body;if(s.type===A.OBJECT&&s.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let u=0;u<a.length;u++){let c=a[u],p={},m={...o,[i]:c,...l&&{[l]:u}};m.__paths__||(m.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let f=d.split("."),y=f[0];y in o.__paths__&&(d=o.__paths__[y],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[i]:`${d}[${u}]`,...l&&{[l]:u}};for(let f of s.properties){let y=f.parsedKey?X(f.parsedKey,r,n,m):f.key,g=f.value;if(g.type===A.LITERAL)p[y]=g.value;else if(g.type===A.VARIABLE){let h=g.path;if(h===i)p[y]=c;else if(h===l)p[y]=u;else if(h.startsWith(i+".")){let w=h.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[y]=c[w]:p[y]=pe(h,n,{...o,[i]:c,...l&&{[l]:u}})}else p[y]=pe(h,n,{...o,[i]:c,...l&&{[l]:u}})}else if(g.type===A.INTERPOLATION){let h=[];for(let w of g.parts)if(typeof w=="string")h.push(w);else if(w.type===A.VARIABLE){let b=w.path,E;if(b===i)E=c;else if(b===l)E=u;else if(b.startsWith(i+".")){let v=b.substring(i.length+1);!v.includes(".")&&!v.includes("[")?E=c[v]:E=pe(b,n,{...o,[i]:c,...l&&{[l]:u}})}else E=pe(b,n,{...o,[i]:c,...l&&{[l]:u}});h.push(E!=null?String(E):"")}else{let b={...o,[i]:c,...l&&{[l]:u}},E=X(w,r,n,b);h.push(E!=null?String(E):"")}p[y]=h.join("")}else{let h={...o,[i]:c,...l&&{[l]:u}};p[y]=X(g,r,n,h)}}t.push(p)}return t}return null},Mp=(e,r,n)=>{let o=e.body;if(o.type===A.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let t=o.properties[0].value;if(t.type===A.CONDITIONAL&&t.conditions.length===1&&t.conditions[0].type===A.VARIABLE&&t.conditions[0].path==="item.visible"){let s=t.bodies[0];if(s.type===A.OBJECT&&s.properties.length===2){let i=s.properties[0],l=s.properties[1];if(i.key==="id"&&i.value.type===A.VARIABLE&&i.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===A.CONDITIONAL){let u=[];for(let c=0;c<r.length;c++){let p=r[c];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),u.push(m)}}return u}}}}return null},qp=(e,r,n,o)=>{let a=X(e.iterable,r,n,o);if(!Array.isArray(a)){let u,c=!1;if(e.iterable.type===A.FUNCTION){c=!0;let m=e.iterable.args.map(d=>d.type===A.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===A.VARIABLE?d.path:d.type===A.FUNCTION?`${d.name}(...)`:"?").join(", ");u=`${e.iterable.name}(${m})`}else u=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${u}`;throw xi(p,a,c)}if(!e.indexVar){let u=Mp(e,a,e.itemVar);if(u!==null)return u}if(!e.indexVar){let u=Tp(e,a);if(u!==null)return u}let t=Lp(e,r,n,o,a);if(t!==null)return t;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let u=i.split("."),c=u[0];c in o.__paths__&&(i=o.__paths__[c],u.length>1&&(i+="."+u.slice(1).join(".")))}let l=!1;e.body.type===A.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(u=>u.type===A.OBJECT&&u.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let u=0;u<a.length;u++){let c=e.indexVar?{...o,[e.itemVar]:a[u],[e.indexVar]:u}:{...o,[e.itemVar]:a[u]};c.__paths__||(c.__paths__=o.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${i}[${u}]`},e.indexVar&&(c.__paths__[e.indexVar]=u);let p=X(e.body,r,n,c);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},Vp=(e,r,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],t=a.parsedKey?X(a.parsedKey,r,n,o):a.key,s=a.value;if(s.type===A.OBJECT&&s.properties.length<=10&&!s.whenCondition){let i={},l={},u=!0;for(let c of s.properties){let p=c.parsedKey?X(c.parsedKey,r,n,o):c.key,m=c.value;if(m.type===A.LITERAL)l[p]=m.value;else if(m.type===A.VARIABLE)l[p]=pe(m.path,n,o);else if(m.type===A.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===A.VARIABLE){let y=pe(f.path,n,o);d.push(y!=null?String(y):"")}else{u=!1;break}if(!u)break;l[p]=d.join("")}else if(m.type===A.OBJECT&&m.properties.length<=5){let d={};for(let f of m.properties){let y=f.key,g=f.value;if(g.type===A.LITERAL)d[y]=g.value;else if(g.type===A.VARIABLE)d[y]=pe(g.path,n,o);else if(g.type===A.INTERPOLATION){let h=[];for(let w of g.parts)if(typeof w=="string")h.push(w);else if(w.type===A.VARIABLE){let b=pe(w.path,n,o);h.push(b!=null?String(b):"")}else{u=!1;break}if(!u)break;d[y]=h.join("")}else{u=!1;break}}if(!u)break;l[p]=d}else{u=!1;break}}if(u)return i[t]=l,i}}return null},Fp=(e,r,n,o)=>{let a=r.functions||r;if(e.whenCondition&&!rr(e.whenCondition,a,n,o))return;let t=Vp(e,r,n,o);if(t!==null)return t;if(e.fast){let u={};for(let c of e.properties){let p=c.parsedKey?X(c.parsedKey,r,n,o):c.key,m=c.value;if(m.type===A.LITERAL)u[p]=m.value;else if(m.type===A.VARIABLE)u[p]=pe(m.path,n,o);else if(m.type===A.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===A.VARIABLE){let y=pe(f.path,n,o);d.push(y!=null?String(y):"")}else{let y=X(f,r,n,o);d.push(y!=null?String(y):"")}u[p]=d.join("")}else u[p]=X(m,r,n,o)}return u}let s={},i=null,l=!1;for(let u of e.properties)if(!u.key.startsWith("$if ")&&!u.key.match(/^\$if\s+\w+.*:?$/)&&!u.key.startsWith("$elif")&&!u.key.startsWith("$else")&&!u.key.startsWith("$for ")){l=!0;break}for(let u of e.properties)if(u.key.startsWith("$if ")||u.key.match(/^\$if\s+\w+.*:?$/)){let c=X(u.value,r,n,o);if(!l&&c!==null&&c!==void 0)return Array.isArray(c)&&c.length===1?c[0]:c;typeof c=="object"&&c!==null&&!Array.isArray(c)&&Object.assign(s,c)}else if(u.key.startsWith("$for ")){if(e.properties.length===1)return X(u.value,r,n,o)}else{let c=u.value;if(c&&c.type===A.OBJECT&&c.properties){let p=c.properties.find(m=>m.key.startsWith("$for "));if(p){let m=X(p.value,r,n,o);m!==void 0&&(s[u.key]=m)}else{let m=X(u.value,r,n,o);m!==void 0&&(s[u.key]=m)}}else{let p=u.parsedKey?X(u.parsedKey,r,n,o):u.key,m=X(u.value,r,n,o);m!==void 0&&(s[p]=m)}}return s},$i={},Up=(e,r,n,o)=>{let a=[];for(let t of e.items)if(t.type===A.LOOP){let s=X(t,r,n,o);Array.isArray(s)&&t.flatten!==!1?a.push(...s):a.push(s)}else{let s=X(t,r,n,o);s!==$i&&s!==void 0&&a.push(s)}return a},Bp=(e,r,n,o)=>{let{name:a,data:t,whenCondition:s}=e,i=r.partials||{},l=r.functions||r;if(s&&!rr(s,l,n,o))return;if(!i[a])throw new Ie(`Partial '${a}' is not defined`);let u=o._partialStack||[];if(u.includes(a))throw new Ie(`Circular partial reference detected: ${a}`);let c=i[a],p=n,m={...o,_partialStack:[...u,a]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(t){let d=X(t,r,n,o);p={...p,...d}}return X(c,r,p,m)},Yp=(e,r,n,o)=>{let{path:a}=e,t=a.split("."),s=t[0],i=t.slice(1);if(!o||!(s in o))throw new Ie(`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 Ie(`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 Ie(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Rs=Cp;var zp=/\$\{([^}]*)\}/g,Gp=/#\{([^}]*)\}/g,ji=(e,r={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,t=Xp(a,r);return{isFunction:!0,type:A.FUNCTION,name:o,args:t}},Xp=(e,r={})=>e.trim()?Wp(e).map(o=>Hp(o.trim(),r)):[],Wp=e=>{let r=[],n="",o=0,a=!1,t="";for(let s=0;s<e.length;s++){let i=e[s],l=s>0?e[s-1]:"";!a&&(i==='"'||i==="'")?(a=!0,t=i,n+=i):a&&i===t&&l!=="\\"?(a=!1,t="",n+=i):!a&&i==="("?(o++,n+=i):!a&&i===")"?(o--,n+=i):!a&&i===","&&o===0?(r.push(n),n=""):n+=i}return n&&r.push(n),r},Hp=(e,r={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:A.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:A.LITERAL,value:parseFloat(e)};if(e==="true")return{type:A.LITERAL,value:!0};if(e==="false")return{type:A.LITERAL,value:!1};if(e==="null")return{type:A.LITERAL,value:null};let n=ji(e,r);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],t=-1,s=null;for(let{op:i,type:l}of a){let u=0;for(;u<o.length;){let c=yr(o.substring(u),i);if(c===-1)break;let p=u+c;p>t&&(t=p,s={op:i,type:l}),u=p+i.length}}if(t!==-1)try{return me(o,r)}catch{return{type:A.VARIABLE,path:o}}return{type:A.VARIABLE,path:o}},Ni=/^\w+\(.*\)$/,Kp=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Jp=e=>{if(!(!e||e.trim()===""||Ni.test(e))&&Kp.test(e))throw e.includes("?")&&e.includes(":")?new _(`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 _(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new _(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},_i=e=>{let r=e.trim();if(Ni.test(r))throw new _(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(r.includes("["))throw new _(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(r))throw new _(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(r))throw new _(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(r.includes("?")&&r.includes(":"))throw new _(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:A.PATH_REFERENCE,path:r}},nt=(e,r={})=>{let n=e.trim();Jp(n);let o=ji(n,r);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let t of n)t==="["?a++:t==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:A.VARIABLE,path:n}},Os=(e,r={})=>{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,(u,c)=>{let p=`__ESCAPED_${o.length}__`;return o.push(c),p}),n=n.replace(/\\(#\{[^}]*\})/g,(u,c)=>{let p=`__ESCAPED_${o.length}__`;return o.push(c),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(zp)],t=[...n.matchAll(Gp)],s=[...a.map(u=>({match:u,type:"variable"})),...t.map(u=>({match:u,type:"pathref"}))].sort((u,c)=>u.match.index-c.match.index);if(s.length===0){let u=n;for(let c=0;c<o.length;c++)u=u.replace(`__ESCAPED_${c}__`,o[c]);return{type:A.LITERAL,value:u}}if(s.length===1&&s[0].match[0]===n&&o.length===0){let{match:u,type:c}=s[0];try{return c==="variable"?nt(u[1],r):_i(u[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:A.LITERAL,value:n};throw p}}let i=[],l=0;for(let{match:u,type:c}of s){let[p,m]=u,d=u.index;if(d>l){let f=n.substring(l,d);for(let y=0;y<o.length;y++)f=f.replace(`__ESCAPED_${y}__`,o[y]);f&&i.push(f)}try{let f;c==="variable"?f=nt(m.trim(),r):f=_i(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 u=n.substring(l);for(let c=0;c<o.length;c++)u=u.replace(`__ESCAPED_${c}__`,o[c]);u&&i.push(u)}return{type:A.INTERPOLATION,parts:i}};var _s=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Li=e=>Object.keys(e),be=e=>e.join("."),tr=(e,r,n)=>{let o=Li(e).filter(a=>!r.has(a));if(o.length>0)throw new _(`Unexpected key '${o[0]}' in condition JSON at '${be(n)}'`)},nr=(e,r)=>typeof e=="string"?Os(e,r):typeof e=="object"&&e!==null?Array.isArray(e)?Zp(e,r):ef(e,r):{type:A.LITERAL,value:e},Qp=e=>{let{$each:r,...n}=e;if(typeof r!="string")throw new _("$each value must be a non-empty string");let o=r.trim();if(o==="")throw new _("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new _("Empty $each body not allowed");if(n.$partial!==void 0)throw new _("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},Zp=(e,r)=>{let n=[],o=!1;for(let a=0;a<e.length;a++){let t=e[a];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(t.$each!==void 0)try{let l=Qp(t),u=Object.keys(l);if(u.length===1&&/^\$for(?::\w+)?\s/.test(u[0])){let c=Ti(u[0],l[u[0]],r,!0);n.push(c),o=!0;continue}}catch(l){throw l instanceof _?l:new _(l.message)}let i=Object.keys(t);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Ti(i[0],t[i[0]],r);n.push(l),o=!0;continue}}let s=nr(t,r);n.push(s),(s.type===A.FUNCTION||s.type===A.CONDITIONAL||s.type===A.LOOP||s.type===A.PARTIAL||s.type===A.OBJECT&&!s.fast||s.type===A.ARRAY&&!s.fast)&&(o=!0)}return{type:A.ARRAY,items:n,fast:!o}},ef=(e,r)=>{let n=[],o=!1,a=null,t=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new _("$partial value must be a string");if(e.$partial.trim()==="")throw new _("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],u=[];for(let[h]of t)for(let w of l)if(h===w||h.startsWith(w+" ")||h.startsWith(w+"#")){u.push(w);break}if(u.length>0)throw new _(`Cannot use $partial with ${u.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:p,...m}=e,d={},f=!1;for(let[h,w]of Object.entries(m)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),d[b]=w,f=!0}let y=null;if(f&&(y=nr(d,r),y.type===A.OBJECT)){let h=!1;for(let w of y.properties)if(w.value.type===A.VARIABLE||w.value.type===A.INTERPOLATION||w.value.type===A.FUNCTION||w.value.type===A.CONDITIONAL||w.value.type===A.OBJECT&&!w.value.fast||w.value.type===A.ARRAY&&!w.value.fast){h=!0;break}h&&(y.fast=!1)}let g={type:A.PARTIAL,name:c,data:y};return p!==void 0&&(g.whenCondition=Di(p,r)),g}for(let[l,u]of t)if(l==="$when"){if(a!==null)throw new _("Multiple '$when' directives on the same object are not allowed");if(u==null)throw new _("Missing condition expression after '$when'");a=Di(u,r),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new _("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<t.length;){let[l,u]=t[s];if(l==="$when"){s++;continue}if(l==="$each")throw new _("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=rf(t,s,r);n.push({key:l,value:c.node}),o=!0,s=c.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let c=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=c?`:${c}`:"";throw new _(`$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 _(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new _("Missing condition expression after '$if'");{let c=nr(u,r);(c.type===A.FUNCTION||c.type===A.CONDITIONAL||c.type===A.PARTIAL||c.type===A.OBJECT&&!c.fast||c.type===A.ARRAY&&!c.fast)&&(o=!0);let p=Os(l,r),m={key:l,value:c};(p.type!==A.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let i={type:A.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},rf=(e,r,n={})=>{let o=[],a=[],t=r,[s,i]=e[t],l=null,u;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],u=p[2];else throw new _(`Invalid conditional syntax: ${s}`)}else u=s.substring(4),u.endsWith(":")&&(u=u.slice(0,-1).trim());Ss(u);let c=me(u,n);for(o.push(c),a.push(nr(i,n)),t++;t<e.length;){let[p,m]=e[t],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{Ss(f);let y=me(f,n);o.push(y)}if(a.push(nr(m,n)),t++,f===null)break}else break}return{node:{type:A.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:t}},Cs={eq:z.EQ,neq:z.NEQ,gt:z.GT,gte:z.GTE,lt:z.LT,lte:z.LTE,in:z.IN,add:z.ADD,sub:z.SUBTRACT},$s={all:z.AND,any:z.OR},tf=new Set(["var","literal","call","not",...Object.keys(Cs),...Object.keys($s)]),nf=(e,r,n)=>{if(!Array.isArray(e))throw new _(`Condition JSON operator '${r}' at '${be(n)}' requires an array`);if(e.length!==2)throw new _(`Condition JSON operator '${r}' at '${be(n)}' requires exactly 2 operands`);return e},sf=(e,r,n,o,a)=>{if(!Array.isArray(e))throw new _(`Condition JSON operator '${r}' at '${be(a)}' requires an array`);if(e.length===0)throw new _(`Condition JSON operator '${r}' at '${be(a)}' requires at least 1 condition`);return e.map((s,i)=>ke(s,o,[...a,i])).reduce((s,i)=>({type:A.BINARY,op:n,left:s,right:i}))},of=(e,r,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],tr(e,new Set(["call","args"]),n);else if(_s(e.call))o=e.call.name,a=e.call.args??[],tr(e,new Set(["call"]),n),tr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new _(`Condition JSON call at '${be(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new _(`Condition JSON call at '${be(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new _(`Invalid condition JSON function name '${o}' at '${be(n)}'`);if(!Array.isArray(a))throw new _(`Condition JSON call '${o}' at '${be(n)}' requires args to be an array`);return{type:A.FUNCTION,name:o,args:a.map((t,s)=>ke(t,r,[...n,"args",s]))}},ke=(e,r={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:A.LITERAL,value:e};if(Array.isArray(e))throw new _(`Condition JSON array at '${be(n)}' must be wrapped in an operator or { literal: [...] }`);if(!_s(e))throw new _(`Invalid condition JSON value at '${be(n)}'`);let o=Li(e);if(o.length===0)throw new _(`Condition JSON object at '${be(n)}' must contain an operator`);let a=o.filter(s=>tf.has(s));if(a.length===0)throw new _(`Unknown condition JSON operator '${o[0]}' at '${be(n)}'`);if(a.length>1)throw new _(`Condition JSON at '${be(n)}' must contain exactly one operator`);let t=a.includes("call")?"call":a[0];if(t==="var"){if(tr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new _(`Condition JSON var at '${be(n)}' requires a non-empty path`);return{type:A.VARIABLE,path:e.var}}if(t==="literal")return tr(e,new Set(["literal"]),n),{type:A.LITERAL,value:e.literal};if(t==="call")return of(e,r,n);if(t==="not")return tr(e,new Set(["not"]),n),{type:A.UNARY,op:Nr.NOT,operand:ke(e.not,r,[...n,"not"])};if(t in $s)return tr(e,new Set([t]),n),sf(e[t],t,$s[t],r,[...n,t]);if(t in Cs){tr(e,new Set([t]),n);let s=nf(e[t],t,[...n,t]);return{type:A.BINARY,op:Cs[t],left:ke(s[0],r,[...n,t,0]),right:ke(s[1],r,[...n,t,1])}}throw new _(`Unknown condition JSON operator '${t}' at '${be(n)}'`)},Di=(e,r={})=>{if(e==null)throw new _("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new _("Empty condition expression after '$when'");return me(e,r)}return _s(e)||Array.isArray(e)?ke(e,r):{type:A.LITERAL,value:e}},me=(e,r={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let u=e.slice(1,-1),c=0,p=!0;for(let m=0;m<u.length;m++)if(u[m]==="("?c++:u[m]===")"&&c--,c<0){p=!1;break}if(p&&c===0)return me(u,r)}let n=yr(e,"||");if(n!==-1)return{type:A.BINARY,op:z.OR,left:me(e.substring(0,n).trim(),r),right:me(e.substring(n+2).trim(),r)};let o=yr(e,"&&");if(o!==-1)return{type:A.BINARY,op:z.AND,left:me(e.substring(0,o).trim(),r),right:me(e.substring(o+2).trim(),r)};let a=[{op:">=",type:z.GTE},{op:"<=",type:z.LTE},{op:"==",type:z.EQ},{op:"!=",type:z.NEQ},{op:">",type:z.GT},{op:"<",type:z.LT},{op:" in ",type:z.IN}];for(let{op:u,type:c}of a){let p=yr(e,u);if(p!==-1)return{type:A.BINARY,op:c,left:me(e.substring(0,p).trim(),r),right:me(e.substring(p+u.length).trim(),r)}}let t=-1,s=null,i=[{op:" + ",type:z.ADD},{op:" - ",type:z.SUBTRACT}];for(let{op:u,type:c}of i){let p=0;for(;p<e.length;){let m=yr(e.substring(p),u);if(m===-1)break;let d=p+m;d>t&&(t=d,s={op:u,type:c}),p=d+u.length}}if(t!==-1&&s)return{type:A.BINARY,op:s.type,left:me(e.substring(0,t).trim(),r),right:me(e.substring(t+s.op.length).trim(),r)};let l=[" * "," / "," % "];for(let u of l)if(yr(e,u)!==-1)throw new _(`Arithmetic operations are not allowed in conditionals: "${u}"`);return e.startsWith("!")?{type:A.UNARY,op:Nr.NOT,operand:me(e.substring(1).trim(),r)}:Mi(e,r)},yr=(e,r)=>{let n=0,o=0;for(;o<=e.length-r.length;){if(e[o]==="(")n++;else if(e[o]===")")n--;else if(n===0&&e.substring(o,o+r.length)===r)return o;o++}return-1},af=e=>{if(e=e.trim(),e==="true")return{type:A.LITERAL,value:!0};if(e==="false")return{type:A.LITERAL,value:!1};if(e==="null")return{type:A.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:A.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:A.LITERAL,value:""};if(e==="{}")return{type:A.LITERAL,value:{}};if(e==="[]")return{type:A.LITERAL,value:[]};let r=Number(e);return!isNaN(r)&&isFinite(r)?{type:A.LITERAL,value:r}:{type:A.VARIABLE,path:e}},Mi=(e,r)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return nt(n,r);let a=af(n);if(a.type===A.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:A.VARIABLE,path:n};try{return nt(n,r)}catch(t){if(t.message&&t.message.includes("not supported"))return a;throw t}},lf=(e,r=!1)=>{let n=r?"$each":"$for";try{Pi(e)}catch(o){if(o instanceof _&&r){let a=o.message.replace(/\$for/g,"$each");throw new _(a.replace("Parse Error: ",""))}throw o}},Ti=(e,r,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,t=e.match(a);if(!t){let g=o?"$each":"$for";throw new _(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=t[1],i=t[2].trim();lf(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new _(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${i}')`)}let u=l[1].trim(),c=l[2].trim(),p,m=null;if(u.includes(",")){let g=u.split(",").map(h=>h.trim());if(g.length!==2)throw new _(`Invalid loop variables: ${u}. Expected format: "item" or "item, index"`);p=g[0],m=g[1]}else p=u;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new _(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new _(`Reserved variable name: ${m}`);let f=Mi(c,n),y=nr(r,n);return{type:A.LOOP,itemVar:p,indexVar:m,iterable:f,body:y,flatten:s!=="nested"}};var cf=(e,r={})=>{let{functions:n={}}=r;return nr(e,n)},Ut=cf;var st={};Ip(st,{now:()=>uf});var uf=()=>Date.now();var pf=(e,r,n={})=>{let{functions:o={},partials:a={}}=n,t={...st,...o},s=Ut(e,{functions:t}),i={};for(let[l,u]of Object.entries(a))i[l]=Ut(u,{functions:t});return Rs(s,r,{functions:t,partials:i})},hr=pf;var ff=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",df=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,mf=(e,r)=>{if(ff(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new _("Empty condition expression");return me(e,r)}return ke(e,r)},yf=(e,r={},n={})=>{let o=df(n),a={...st,...o},t=mf(e,a);return!!rr(t,{functions:a,partials:{}},r,{})},js=yf;var Us=Symbol("runStoreTransaction"),Ls="__routeEngineConditionComparison",Bt=(e,r)=>typeof e=="number"&&typeof r=="number"&&Number.isFinite(e)&&Number.isFinite(r)||typeof e=="string"&&typeof r=="string",sr=Object.freeze({eq:(e,r)=>e===r,neq:(e,r)=>e!==r,gt:(e,r)=>Bt(e,r)&&e>r,gte:(e,r)=>Bt(e,r)&&e>=r,lt:(e,r)=>Bt(e,r)&&e<r,lte:(e,r)=>Bt(e,r)&&e<=r}),zi=Object.freeze(Object.fromEntries(Object.keys(sr).map(e=>[e,`${Ls}${e}`]))),hf=Object.freeze(Object.fromEntries(Object.entries(zi).map(([e,r])=>[r,sr[e]]))),qi=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),gf=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},Yt=e=>{if(Array.isArray(e))return e.map(Yt);if(e===null||typeof e!="object"||qi(e,"literal")||qi(e,"var"))return e;if(gf(e)?.startsWith(Ls))throw new Error(`Condition function names beginning with "${Ls}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,t=zi[o];if(t)return{call:t,args:a.map(Yt)}}return Object.fromEntries(n.map(([o,a])=>[o,Yt(a)]))},it=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return ke(e),js(Yt(e),r,{functions:hf})},bf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Gi=(e,r,n={})=>{let o=structuredClone(e),a={},t={},{transformSelectorFirstArgument:s=u=>u,transformActionFirstArgument:i=u=>u}=n;for(let[u,c]of Object.entries(r))u!=="createInitialState"&&(u.startsWith("select")?a[u]=(...p)=>c(s(o),...p):t[u]=(...p)=>{let m;return o=Es(o,f=>{let y=c(i(f),...p);m=y!==void 0&&!he(y)?y:void 0}),m});let l=u=>{if(typeof u!="function")throw new Error("Store transaction requires a callback");let c=o;try{return u()}catch(p){throw o=c,p}};return{...a,...t,[Us]:l}},Wt=(e,r)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return Es(o,t=>{a.forEach(s=>{r.forEach(i=>{i(t,s)})})})};var wf=(e,r)=>{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 ${r}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},U=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),Ms=(e,r,n)=>{Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0})},fe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),If=new Set(["pageSize","groups"]),vf=new Set(["id","variants"]),Af=new Set(["id","imageId"]),kf=new Set(["pageSize","tracks"]),Pf=new Set(["id","soundId","title","artist","album","description","coverImageId"]),xf=new Set(["pageSize","replays"]),Ef=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),gr=(e,r,n)=>{Object.keys(e).forEach(o=>{if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},Dr=(e,r)=>{if(typeof e!="string"||e.length===0)throw new Error(`${r} must be a non-empty string`)},at=(e={})=>{let r=e?.resources?.imageGallery;if(r===void 0)return;if(!fe(r))throw new Error("resources.imageGallery must be an object");if(gr(r,If,"resources.imageGallery"),!Number.isInteger(r.pageSize)||r.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(r.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[o,a]of r.groups.entries()){let t=`resources.imageGallery.groups[${o}]`;if(!fe(a))throw new Error(`${t} must be an object`);if(gr(a,vf,t),Dr(a.id,`${t}.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(`${t}.variants must be a non-empty array`);let s=new Set;for(let[i,l]of a.variants.entries()){let u=`${t}.variants[${i}]`;if(!fe(l))throw new Error(`${u} must be an object`);if(gr(l,Af,u),Dr(l.id,`${u}.id`),Dr(l.imageId,`${u}.imageId`),s.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(s.add(l.id),!U(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},lt=(e={})=>{let r=e?.resources?.musicRoom;if(r===void 0)return;if(!fe(r))throw new Error("resources.musicRoom must be an object");if(gr(r,kf,"resources.musicRoom"),!Number.isInteger(r.pageSize)||r.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(r.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[o,a]of r.tracks.entries()){let t=`resources.musicRoom.tracks[${o}]`;if(!fe(a))throw new Error(`${t} must be an object`);gr(a,Pf,t);for(let l of["id","soundId","title"])Dr(a[l],`${t}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&Dr(a[l],`${t}.${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(!U(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!fe(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&&!U(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Sf=(e,r,n)=>{let o=Array.isArray(n)?"array":typeof n;switch(r.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 "${r.type}"`)}},ct=(e={})=>{let r=e?.resources?.sceneReplay;if(r===void 0)return;if(!fe(r))throw new Error("resources.sceneReplay must be an object");if(gr(r,xf,"resources.sceneReplay"),!Number.isInteger(r.pageSize)||r.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(r.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},o=new Set;for(let[a,t]of r.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!fe(t))throw new Error(`${s} must be an object`);gr(t,Ef,s);for(let c of["sceneId","title","thumbnailImageId"])Dr(t[c],`${s}.${c}`);if(o.has(t.sceneId))throw new Error(`Duplicate scene replay sceneId "${t.sceneId}"`);if(o.add(t.sceneId),!U(e?.resources?.images,t.thumbnailImageId))throw new Error(`Scene replay scene "${t.sceneId}" references unknown thumbnail image "${t.thumbnailImageId}"`);let i=n[t.sceneId];if(!i)throw new Error(`Scene replay references unknown scene "${t.sceneId}"`);let l=i.initialSectionId,u=i.sections?.[l];if(!u)throw new Error(`Scene replay scene "${t.sceneId}" references unknown initial section "${l}"`);if(u.initialLineId!==void 0&&!u.lines?.some(c=>c.id===u.initialLineId))throw new Error(`Scene replay scene "${t.sceneId}" initial section "${l}" references unknown initial line "${u.initialLineId}"`);if(t.initialVariables!==void 0){if(!fe(t.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[c,p]of Object.entries(t.initialVariables)){let m=e?.resources?.variables?.[c];if(!m)throw new Error(`Scene replay scene "${t.sceneId}" initialVariables references unknown variable "${c}"`);if(De(m))throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize computed variable "${c}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize readonly variable "${c}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${t.sceneId}" can only initialize context variable "${c}"`);Sf(c,m,p)}}}},Xi=e=>{let r=he(e)?er(e):e;return structuredClone(r)},Rf=({characterId:e,resourceCharacter:r,variables:n={}}={})=>{if(!U(r,"nameVariableId"))return;let o=r.nameVariableId,a=n?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Ht=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0;if(r?.name!==void 0)return r.name;if(n!==void 0)return n;let s=Rf({characterId:e,resourceCharacter:t,variables:a});return s!==void 0?s:t?.name||""},De=e=>U(e,"computed"),Tr=(e={},r={})=>Object.fromEntries(Object.entries(e??{}).filter(([n])=>!De(r[n]))),Ne=(e,r)=>new Error(`${r} has invalid path: ${JSON.stringify(e)}`),Of=(e,r,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ne(r,n)}let a="";for(let t=1;t<e.length-1;t+=1){let s=e[t];if(s!=="\\"){if(s.charCodeAt(0)<32)throw Ne(r,n);a+=s;continue}if(t+=1,t>=e.length-1)throw Ne(r,n);let i=e[t];if(i==="u"){let u=e.slice(t+1,t+5);if(u.length!==4||!/^[0-9a-fA-F]{4}$/.test(u))throw Ne(r,n);a+=String.fromCharCode(Number.parseInt(u,16)),t+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!U(l,i))throw Ne(r,n);a+=l[i]}return a},Wi=(e,r="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ne(e,r);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 Ne(e,r);n.push(i)},t=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let s=e[o];if(/\d/.test(s??"")){let c=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(c,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw Ne(e,r);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ne(e,r);let i=s,l=o;o+=1;let u=!1;for(;o<e.length;){let c=e[o];if(u)u=!1;else if(c==="\\")u=!0;else if(c===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw Ne(e,r);o+=1,n.push(Of(p,e,r));return}o+=1}if(u||o>=e.length)throw Ne(e,r)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){t();continue}throw Ne(e,r)}return n},Ns=(e,r)=>{let n=e;for(let o of r){if(n==null||!U(n,o))return;n=n[o]}return n},Hi=(e,r={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Wi(e),[o,a,...t]=n;if(o==="variables"){if(!a)return r.variables;let s=typeof r.resolveVariable=="function"?r.resolveVariable(a):r.variables?.[a];return Ns(s,t)}return o==="runtime"?Ns(r.runtime,n.slice(1)):Ns(r,n)},Ki=(e,r,n)=>{if(!Array.isArray(r))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&r.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},qs=(e,r)=>{if(!Array.isArray(r))throw new Error(`Computed expression operator "${e}" requires an array`);if(r.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},Cf=(e,r)=>{if(typeof r!="number"||!Number.isFinite(r))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Me=(e,r,n,o)=>(Ki(e,r,o),r.map(a=>Xt(a,n))),je=(e,r,n,o)=>{let a=Me(e,r,n,o);return a.forEach(t=>Cf(e,t)),a},$f=(e,r,n)=>{switch(e){case"var":return Hi(r,n);case"add":{let[o,a]=je(e,r,n,2);return o+a}case"sub":{let[o,a]=je(e,r,n,2);return o-a}case"mul":{let[o,a]=je(e,r,n,2);return o*a}case"div":{let[o,a]=je(e,r,n,2);return o/a}case"mod":{let[o,a]=je(e,r,n,2);return o%a}case"neg":{let[o]=je(e,r,n,1);return-o}case"round":{let[o]=je(e,r,n,1);return Math.round(o)}case"floor":{let[o]=je(e,r,n,1);return Math.floor(o)}case"ceil":{let[o]=je(e,r,n,1);return Math.ceil(o)}case"min":{let[o,a]=je(e,r,n,2);return Math.min(o,a)}case"max":{let[o,a]=je(e,r,n,2);return Math.max(o,a)}case"clamp":{let[o,a,t]=je(e,r,n,3);return Math.min(t,Math.max(a,o))}case"eq":{let[o,a]=Me(e,r,n,2);return sr.eq(o,a)}case"neq":{let[o,a]=Me(e,r,n,2);return sr.neq(o,a)}case"gt":{let[o,a]=Me(e,r,n,2);return sr.gt(o,a)}case"gte":{let[o,a]=Me(e,r,n,2);return sr.gte(o,a)}case"lt":{let[o,a]=Me(e,r,n,2);return sr.lt(o,a)}case"lte":{let[o,a]=Me(e,r,n,2);return sr.lte(o,a)}case"in":{let[o,a]=Me(e,r,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return qs(e,r),r.every(o=>!!Xt(o,n));case"or":case"any":return qs(e,r),r.some(o=>!!Xt(o,n));case"not":{let[o]=Me(e,r,n,1);return!o}case"length":{let[o]=Me(e,r,n,1);return typeof o=="string"||Array.isArray(o)?o.length:fe(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Me(e,r,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return Xi(r);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Xt=(e,r={})=>{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 $f(o,a,r)},Vs=(e,r)=>{if(e===null||typeof e!="object"||U(e,"literal"))return e;if(U(e,"var"))return{literal:Hi(e.var,r)};if(U(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=>Vs(a,r)):Vs(o,r)]))},_f=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return ke(e),it(Vs(e,r))},Ji=(e,r)=>{if(!fe(e))throw new Error(`${r} must be an object`);let n=U(e,"expr"),o=U(e,"value");if(n===o)throw new Error(`${r} must contain exactly one of expr or value`)},Ds=(e,r,n)=>(Ji(e,r),U(e,"value")?Xi(e.value):Xt(e.expr,n)),jf=(e,r={},n="unknown")=>{if(!fe(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=U(e,"expr"),a=U(e,"value");if(U(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(!fe(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(!fe(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!U(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(_f(i.when,r))return Ds(i,`Computed variable "${n}" branch ${s}`,r)}return Ds(e.default,`Computed variable "${n}" default`,r)}if(o===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return Ds(e,`Computed variable "${n}"`,r)},Qi=(e,r,n)=>{switch(r){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: ${r} for computed variable ${e}`)}},Nf=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}),Df=new Set(["and","or","all","any"]),Tf=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Lf=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Mf=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),qf=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Zi=new WeakMap,Vi=e=>e===null?"null":Array.isArray(e)?"object":typeof e,zt=(e,r,n)=>{for(let o of Object.keys(e))if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},Vf=(e,r,n,o)=>{if(n!==void 0&&n!==r)throw new Error(`Computed variable "${e}" ${o} expected type ${r}, got ${n}`)},ea=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{let t=`Computed variable "${r}" ${a} var`,[s,i,...l]=Wi(e,t);if(s!=="variables"&&s!=="runtime")throw new Error(`${t} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${t} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!U(n,i))throw new Error(`Computed variable "${r}" ${a} references unknown variable "${i}"`);let u=n[i];return De(u)&&o.add(i),l.length===0?u?.type:void 0},ra=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${r}" ${a} must use finite numeric literals`);return Vi(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let t=Object.entries(e);if(t.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,i]]=t;if(s==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return ea(i,{variableId:r,variableConfigs:n,dependencies:o,path:a})}if(s==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${r}" ${a} must use finite numeric literals`);return Vi(i)}let l=Nf[s];if(l===void 0&&!Df.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?qs(s,i):Ki(s,i,l);let u=i.map((c,p)=>ra(c,{variableId:r,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(Lf.has(s)&&u.forEach(c=>{if(c!==void 0&&c!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Tf.has(s))return"number";if(Mf.has(s))return"boolean"},Ff=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{ke(e)}catch(s){throw new Error(`Computed variable "${r}" ${a} is invalid: ${s.message}`,{cause:s})}let t=(s,i)=>{if(s===null||typeof s!="object"||U(s,"literal"))return;if(U(s,"var")){ea(s.var,{variableId:r,variableConfigs:n,dependencies:o,path:i});return}if(U(s,"call"))throw new Error(`Computed variable "${r}" ${i} function calls are not supported`);if(U(s,"not")){t(s.not,`${i}.not`);return}let l=Object.keys(s).find(u=>qf.has(u));s[l].forEach((u,c)=>{t(u,`${i}.${l}[${c}]`)})};t(e,a)},Ts=(e,{variableId:r,variableConfig:n,variableConfigs:o,dependencies:a,path:t,allowedKeys:s=new Set(["expr","value"])})=>{if(Ji(e,`Computed variable "${r}" ${t}`),zt(e,s,t),U(e,"value")){Qi(r,n.type,e.value);return}let i=ra(e.expr,{variableId:r,variableConfigs:o,dependencies:a,path:`${t}.expr`});Vf(r,n.type,i,`${t}.expr`)},Uf=(e,r,n)=>{let o=r.computed;if(!fe(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,t=U(o,"expr"),s=U(o,"value");if(U(o,"branches")){if(zt(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),t||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(!fe(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,u)=>{if(!fe(l))throw new Error(`Computed variable "${e}" branch ${u} must be an object`);if(zt(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${u}`),!U(l,"when"))throw new Error(`Computed variable "${e}" branch ${u} requires when`);Ff(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${u}].when`}),Ts(l,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:`computed.branches[${u}]`,allowedKeys:new Set(["when","expr","value"])})}),Ts(o.default,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(zt(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),t===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return Ts(o,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed"}),a},br=(e={})=>{if(!fe(e))throw new Error("Variable configs must be an object");if(U(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(U(e,""))throw new Error("Variable ids must not be empty");let r=new Map;Object.entries(e).forEach(([t,s])=>{if(De(s)){if(!fe(s))throw new Error(`Computed variable "${t}" must be an object`);if(!U(s,"type"))throw new Error(`Computed variable "${t}" requires type`);if(!U(s,"scope"))throw new Error(`Computed variable "${t}" requires scope`);if(U(s,"default"))throw new Error(`Computed variable "${t}" must not declare a top-level default`);if(pt(s.scope,t),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${t}`);r.set(t,Uf(t,s,e))}});let n=new Set,o=[];r.forEach((t,s)=>{if(n.has(s))return;let i=[{variableId:s,dependencies:[...r.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;i.length>0;){let u=i.at(-1);if(u.nextDependencyIndex>=u.dependencies.length){i.pop(),l.delete(u.variableId),n.add(u.variableId),o.push(u.variableId);continue}let c=u.dependencies[u.nextDependencyIndex];if(u.nextDependencyIndex+=1,n.has(c))continue;let p=l.get(c);if(p!==void 0){let m=[...i.slice(p).map(({variableId:d})=>d),c].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(c,i.length),i.push({variableId:c,dependencies:[...r.get(c)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return Zi.set(e,a),a},ut=({variables:e={},runtime:r={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=Zi.get(n)??br(n),t=Tr(e,n),s=Object.entries(n).filter(([,g])=>De(g)).map(([g])=>g),i=Object.create(null),l=[],u=new Map(a.map((g,h)=>[g,h])),c=-1,p=!1,m=g=>{if(U(i,g))return i[g];let h=n[g];if(!De(h))return U(t,g)?t[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=jf(h.computed,y,g);return Qi(g,h.type,b),Ms(i,g,b),b}finally{l.pop()}},d=g=>{if(U(i,g))return i[g];let h=n[g];if(!De(h))return U(t,g)?t[g]:void 0;let w=u.get(g);if(o&&!p&&w!==void 0&&w>c){p=!0;try{for(let b=c+1;b<=w;b+=1)m(a[b]),c=b}finally{p=!1}return i[g]}return m(g)},f=new Proxy({},{get:(g,h)=>{if(typeof h=="string")return d(h)},has:(g,h)=>typeof h=="string"&&(U(t,h)||s.includes(h)),ownKeys:()=>[...new Set([...Object.keys(t),...s])],getOwnPropertyDescriptor:(g,h)=>{if(!(typeof h!="string"||!U(t,h)&&!s.includes(h)))return{enumerable:!0,configurable:!0}}}),y={variables:f,runtime:r,resolveVariable:d};return o?(s.forEach(g=>{d(g)}),{...t,...i}):f},Bf=({variables:e={},runtime:r={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return br(a),ut({variables:e,runtime:r,variableConfigs:a,eager:!0})},Kt=e=>{let r={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(De(a))return;let t=wf(a,o);a.scope==="context"?Ms(r,o,t):Ms(n,o,t)}),{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}},pt=(e,r)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${r}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${r}. Expected one of: ${n.join(", ")}`)},Jt=(e,r,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(r))throw new Error(`Unknown operation: ${r}`);if(!a.includes(r))throw new Error(`Operation "${r}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},Yf=2,Fi=12,ta=(e=Yf)=>{if(!Number.isInteger(e)||e<0||e>Fi)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Fi}.`);return e},zf=(e,r)=>{let n=10**r;return Math.round((e+Number.EPSILON)*n)/n},Gt=e=>typeof e=="number"&&Number.isFinite(e),Bs=(e,r,n,o,a={})=>{if(e==="number"){if(r==="set"&&!Gt(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(r==="multiply"&&!Gt(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(r==="divide"&&!Gt(n))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(r==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);ta(a.roundTo)}}},Qt=(e,r,n,o={})=>{let a=(s,i,l)=>{let u=s??i;if(!Gt(u))throw new Error(`Operation "${r}" requires ${l} to be a number.`);return u},t=s=>{let i=a(s,void 0,"value");if(i===0)throw new Error(`Operation "${r}" requires value to be a non-zero number.`);return i};switch(r){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return zf(a(e,0,"current value")/t(n),ta(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: ${r}`)}};var Ys=(e,r="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),t={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:bf[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(n.getHours()),mm:o(n.getMinutes()),ss:o(n.getSeconds())};return r.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>t[s])},Gf=(e,r)=>{let n=t=>t?.ui,o=n(e),a=n(r);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:r}:a&&o?{changeType:"update",data:r}:null},ot=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Xf=(e,r)=>{let n=e?.character?.sprite,o=r?.character?.sprite,a=ot(n)?n:void 0,t=ot(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(t)?null:a&&!t?{changeType:"delete",data:a}:t&&!a?{changeType:"add",data:t}:t&&a?{changeType:"update",data:t}:null},Ui=e=>{if(e?.resourceId===void 0)return;let r={resourceId:e.resourceId};e.transformId!==void 0&&(r.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"])e[n]!==void 0&&(r[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(r[n]=e[n]);return r},Bi=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Yi=(e,r)=>r&&!e?{changeType:"add",data:r}:e&&!r?{changeType:"delete",data:e}:e&&r&&JSON.stringify(e)!==JSON.stringify(r)?{changeType:"update",data:r}:null,Wf=(e,r)=>{let n={},o=Yi(Ui(e),Ui(r)),a=Yi(Bi(e),Bi(r));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},zs=(e={},r={})=>{let n={},o=["sfx","voice"],a=l=>{let u=e[l],c=r[l];c&&!u?n[l]={changeType:"add",data:c}:u&&!c?o.includes(l)||(n[l]={changeType:"delete",data:u}):u&&c&&JSON.stringify(u)!==JSON.stringify(c)&&(n[l]={changeType:"update",data:c})},t=Wf(e.background,r.background);t&&(n.background=t),a("screen"),a("bgm"),a("voice");let s=Gf(e.dialogue,r.dialogue);s&&(n.dialogue=s);let i=Xf(e.dialogue,r.dialogue);return i&&(n.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},Gs=(e={})=>{let r=structuredClone(e);r.background&&(r.background.animations?.playback?.continuity!=="persistent"&&delete r.background.animations,!r.background.resourceId&&!r.background.colorId&&delete r.background);let n=a=>{r[a]&&(delete r[a].animations,Object.keys(r[a]).length===0&&delete r[a])};n("layout"),n("choice"),n("form"),n("screen"),r.dialogue?.ui&&(delete r.dialogue.ui.animations,Object.keys(r.dialogue.ui).length===0&&delete r.dialogue.ui,Object.keys(r.dialogue).length===0&&delete r.dialogue),r.dialogue?.character?.sprite&&(delete r.dialogue.character.sprite.animations,Object.keys(r.dialogue.character.sprite).length===0&&delete r.dialogue.character.sprite,Object.keys(r.dialogue.character).length===0&&delete r.dialogue.character,Object.keys(r.dialogue).length===0&&delete r.dialogue);let o=(a,t)=>{let s=r[a]?.items;Array.isArray(s)&&(r[a].items=s.map(i=>{let l={...i};return delete l.animations,t(l)?l:null}).filter(Boolean),r[a].items.length===0&&delete r[a])};return o("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),o("visual",a=>a.resourceId||a.transformId),r},Hf=(e,r)=>{if(!e||!r)return;let n=e;for(let o of r.split(".")){if(n==null||!(o in Object(n)))return;n=n[o]}return n},Kf=(e,r)=>{if(typeof e!="string")return e;if(e==="_event"){if(r==null)throw new Error('Action template binding "_event" requires event context "_event".');return r}if(!e.startsWith("_event."))return e;if(r==null)throw new Error(`Action template binding "${e}" requires event context "_event".`);let n=e.slice(7),o=Hf(r,n);if(o===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "_event".`);return o},Jf={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"])},Qf=(e,r)=>{let n=e[e.length-1];return n?Jf[n]?.has(r)===!0:!1},Fs=(e,r,n=[])=>Array.isArray(e)?e.map(o=>Fs(o,r,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Qf(n,o)?a:Fs(a,r,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Kf(e,r._event):hr(e,r):e,Xs=(e,r)=>{if(!r)return e;if(Object.prototype.hasOwnProperty.call(r,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return Fs(e,r)};var re=e=>structuredClone(he(e)?er(e):e),H=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),na=e=>e?.animations?.playback?.continuity==="persistent",W=(e,r)=>H(e??{},r)&&e[r]!==void 0,ft=(e,r)=>e?!r(e)&&e.animations?{animationsOnly:!0,state:{animations:re(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Zf=e=>W(e,"opacity")||W(e,"blur"),ca=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],ua=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Ws=["animationName","animationSpeed","loop"],ed=e=>ca.some(r=>W(e,r)),pa=e=>e?.text&&W(e.text,"content")&&W(e.text,"textStyleId"),fa=e=>W(e,"text"),rd=(e,r)=>e.resourceId?!0:pa(e)?!r?.text:!1,td=(e,r)=>{let n={...re(e),...r};return r.text&&e.text&&(n.text={...re(e.text),...re(r.text)}),n},nd=(e,r)=>{if(fa(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!pa(e)&&!r?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},sa=e=>ua.some(r=>W(e,r)),oa=e=>Ws.some(r=>W(e,r)),sd=(e,r,{hasAuthoredTransformId:n=!1}={})=>{if(!r)return e;for(let o of ua)!n&&!W(e,o)&&W(r,o)&&(e[o]=r[o]),H(e,o)&&e[o]===void 0&&delete e[o];return e},da=(e,r,n)=>{let o=e[n];return o?.id===r?.id?o:e.find(a=>a.id===r?.id)},od=(e,r)=>{if(!r)return e;for(let n of ca)!W(e,n)&&W(r,n)&&(e[n]=r[n]),H(e,n)&&e[n]===void 0&&delete e[n];return e},id=(e,r)=>(r&&(!W(e,"opacity")&&W(r,"opacity")&&(e.opacity=r.opacity),!W(e,"blur")&&W(r,"blur")&&(e.blur=re(r.blur)),H(e,"opacity")&&e.opacity===void 0&&delete e.opacity,H(e,"blur")&&e.blur===void 0&&delete e.blur),e),ma=(e,r,n=[],{hasPatchFn:o=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let t=e.map((s,i)=>{let l=da(n,s,i),u=r(s,l),c=Zf(s),p=ed(s),m=o(s),d=H(s,"animations"),f=re(s);return!u&&(c||p||m)&&l&&(f=a?a(l,f):{...re(l),...f},d||delete f.animations),id(od(f,l),l)}).filter(s=>r(s)||s.animations);return{hasValidItems:t.length>0,processedItems:t}},ad=e=>{if(e){if(e.character&&H(e.character,"name"))return e.character.name;if(H(e,"characterName"))return e.characterName}},ya=e=>!!e?.character&&H(e.character,"sprite"),ld=e=>{let r={},n=!1,o=ad(e);return o!==void 0&&(r.name=o,n=!0),ya(e)&&(r.sprite=re(e.character.sprite),n=!0),n?r:void 0},ia=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},aa=({dialogueState:e,dialogueAction:r,persistCharacter:n})=>H(r,"persistSprite")?r.persistSprite===!0:H(e,"persistSprite")?e.persistSprite===!0:n&&!H(r,"characterId"),la=({previousCharacter:e,characterFields:r,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:t,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},u=r??{},c=s&&!n,p=c&&!t;return H(u,"name")?i.name=u.name:(o&&!n||c)&&H(l,"name")&&(i.name=re(l.name)),H(u,"sprite")?i.sprite=re(u.sprite):(a||p)&&H(l,"sprite")&&(i.sprite=re(l.sprite)),Object.keys(i).length>0?i:void 0},cd=({dialogueState:e,content:r,append:n=!1})=>{if(!n||!Array.isArray(r)){e.content=r,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>re(a)):delete e.initialRevealedContent,e.content=[...o,...r]},ud=()=>({}),pd=(e,r)=>{if(!r.screen)return;let n=W(r.screen,"opacity"),o=W(r.screen,"blur"),a=H(r.screen,"animations");if(!n&&!o){a||delete e.screen;return}let t=e.screen,s={};if(n?s.opacity=r.screen.opacity:W(t,"opacity")&&(s.opacity=t.opacity),o?s.blur=re(r.screen.blur):W(t,"blur")&&(s.blur=re(t.blur)),H(s,"opacity")&&s.opacity===void 0&&delete s.opacity,H(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},fd=(e,r)=>{if(r.background){let n=W(r.background,"resourceId"),o=W(r.background,"colorId"),a=W(r.background,"opacity"),t=W(r.background,"blur"),s=W(r.background,"transformId"),i=sa(r.background),l=oa(r.background),{animationsOnly:u,state:c}=ft(r.background,d=>W(d,"resourceId")||W(d,"colorId")||W(d,"opacity")||W(d,"blur")||W(d,"transformId")||sa(d)||oa(d));if(u){e.background=e.background?{...re(e.background),...c}:c;return}if(!n&&!o&&!a&&!t&&!s&&!i&&!l){delete e.background;return}let p=e.background,m=re(r.background);if(!n&&p?.resourceId){m.resourceId=p.resourceId,!H(m,"transformId")&&p.transformId&&(m.transformId=p.transformId);for(let d of Ws)!W(m,d)&&W(p,d)&&(m[d]=p[d])}sd(m,p,{hasAuthoredTransformId:s}),!o&&p?.colorId&&(m.colorId=p.colorId),!a&&W(p,"opacity")&&(m.opacity=p.opacity),!t&&W(p,"blur")&&(m.blur=re(p.blur)),H(m,"resourceId")&&m.resourceId===void 0&&delete m.resourceId,H(m,"colorId")&&m.colorId===void 0&&delete m.colorId,H(m,"animations")&&m.animations===void 0&&delete m.animations,H(m,"transformId")&&m.transformId===void 0&&delete m.transformId,H(m,"opacity")&&m.opacity===void 0&&delete m.opacity,H(m,"blur")&&m.blur===void 0&&delete m.blur;for(let d of Ws)H(m,d)&&m[d]===void 0&&delete m[d];if(!m.resourceId&&!m.colorId){delete e.background;return}p?.resourceId===m.resourceId&&p?.transformId===m.transformId&&!H(m,"animations")&&na(p)&&(m.animations=re(p.animations)),e.background=m}else e.background?.animations&&!na(e.background)&&(e.background.animations={})},dd=(e,r)=>{if(!r.dialogue){if(e.dialogue&&(ia(e.dialogue),e.dialogue.mode==="adv")){e.dialogue.content=void 0,delete e.dialogue.initialRevealedContent,delete e.dialogue.textSpeed;let c=e.dialogue.persistCharacter===!0,p=aa({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:c});c||delete e.dialogue.characterId,e.dialogue.character=la({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:c,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(r.dialogue.ui){let{animationsOnly:c,state:p}=ft(r.dialogue.ui,m=>!!m.resourceId);c?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...r.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});r.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),r.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=r.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(r.dialogue.content);r.dialogue.content!==void 0&&cd({dialogueState:e.dialogue,content:r.dialogue.content,append:o}),H(r.dialogue,"textSpeed")?e.dialogue.textSpeed=r.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=H(r.dialogue,"persistCharacter")?r.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let t=aa({dialogueState:e.dialogue,dialogueAction:r.dialogue,persistCharacter:a});H(r.dialogue,"persistSprite")&&(e.dialogue.persistSprite=t);let s=H(r.dialogue,"characterId"),i=ld(r.dialogue),l=ya(r.dialogue);s?r.dialogue.characterId?e.dialogue.characterId=r.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let u=la({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:t,hasExplicitPersistSprite:H(r.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(u?e.dialogue.character=u:delete e.dialogue.character,l||ia(e.dialogue),r.dialogue.clear){delete e.dialogue;return}if(r.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&r.dialogue.content!==void 0){let c={content:r.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(c.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(c.character=re(e.dialogue.character)),e.dialogue.lines.push(c)}},md=(e,r)=>{if(r.sfx){let n=Array.isArray(r.sfx.items)&&r.sfx.items.length>0,o=Array.isArray(r.sfx.channels)&&r.sfx.channels.length>0;if(!n&&!o){delete e.sfx;return}e.sfx=re(r.sfx)}else e.sfx&&delete e.sfx},yd=(e,r)=>{if(r.bgm){let n=Array.isArray(r.bgm.sounds);if(!r.bgm.resourceId&&!n||n&&r.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=re(r.bgm),r.bgm.resourceId&&(e.bgm.loop=r.bgm.loop??!0)}},hd=(e,r)=>{if(r.visual){let n=e.visual?.items||[];r.visual.items?.forEach((t,s)=>{nd(t,da(n,t,s))});let{hasValidItems:o,processedItems:a}=ma(r.visual.items,rd,n,{hasPatchFn:fa,mergeItemFn:td});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations?{...n,animations:{}}:n))},gd=(e,r)=>{if(!r.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=ma(r.character.items,a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId,e.character?.items||[]);n?e.character={items:o}:delete e.character},bd=(e,r)=>{r.animation?e.animation=r.animation:e.animation&&delete e.animation},wd=(e,r)=>{if(r.layout){let{animationsOnly:n,state:o}=ft(r.layout,a=>!!a.resourceId);if(n){e.layout=o;return}if(!r.layout.resourceId){delete e.layout;return}e.layout=r.layout}else e.layout&&delete e.layout},Id=(e,r)=>{if(r.choice){let{animationsOnly:n,state:o}=ft(r.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...o};return}if(!r.choice.resourceId){delete e.choice;return}e.choice=r.choice}else e.choice&&delete e.choice},vd=(e,r)=>{if(r.form){let{animationsOnly:n,state:o}=ft(r.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!r.form.resourceId){delete e.form;return}e.form=re(r.form)}else e.form&&delete e.form},Ad=(e,r)=>{if(r.control){if(!r.control.resourceId){delete e.control;return}e.control=r.control}},kd=(e,r)=>{if(r.voice){let n=Array.isArray(r.voice.sounds);if(!r.voice.resourceId&&!n||n&&r.voice.sounds.length===0){delete e.voice;return}e.voice=re(r.voice)}else e.voice&&delete e.voice},Pd=(e,r)=>{r.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},wr=e=>Wt(ud,[Pd,pd,fd,md,yd,hd,dd,gd,bd,wd,Id,vd,Ad,kd])(e);var Lr=(e,r)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=hr(e,r);return n&&typeof n=="object"?e:n};var xd=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"}}),or=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}),dt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Ed=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"}),Hs=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),ha=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),Ks=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),ga=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Sd=(e,r)=>{let n=Ed[e];if(n==="number"){if(typeof r!="number"||!Number.isFinite(r))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof r!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof r!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(r!==null&&typeof r!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},Zt=(e,r)=>{if(Sd(e,r),e==="autoForwardDelay"&&r<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(r<0||r>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(r)):r},Js=(e={})=>{let r=e?.config;if(r===void 0)return{...or};if(!ga(r))throw new Error("projectData.config must be an object");let n=Object.keys(r).find(i=>i!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=r.runtimeDefaults;if(o===void 0)return{...or};if(!ga(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(ha),t=Object.keys(o).find(i=>!a.has(i));if(t)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${t}"`);let s={...or};return ha.forEach(i=>{o[i]!==void 0&&(s[i]=Zt(i,o[i]))}),s},Rd=(e,r)=>{if(r.startsWith("global.")){let n=r.slice(7);return e?.global?.[n]}if(r.startsWith("context.runtime.")){let n=r.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[n]}},Ir=e=>Object.fromEntries(Object.entries(xd).map(([r,n])=>{let o=Rd(e,n.source),a=o!==void 0?o:or[r]??dt[r];return[r,a]})),ir=(e,r)=>Ir(e)[r],ba=(e={})=>Object.fromEntries(Hs.map(r=>[r,e[r]??or[r]]));var Mr=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}),Xe=Object.freeze({BEHIND_BACKGROUND:Mr.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:Mr.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:Mr.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:Mr.VISUAL_BEHIND_CHOICE,FOREGROUND:Mr.VISUAL_FOREGROUND}),Qs=Xe.BEHIND_DIALOGUE,Zs=Object.freeze(Object.values(Xe).sort((e,r)=>e-r));var Od={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([r,n])=>({id:r,...n})),formatDate:Ys},Cd=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,mt=e=>Array.isArray(e)?e.map(r=>{if(!r||typeof r!="object"||Array.isArray(r)||Object.keys(r).length!==1)return mt(r);let[n]=Object.keys(r),o=Cd.exec(n);if(!o)return mt(r);let[,a,t,s]=o,i=`$for ${a}${t?`, ${t}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(r[n])?r[n]:[];return{[i]:mt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([r,n])=>[r,mt(n)])),He=(e,r)=>{let n={functions:Od};return hr(mt(e),r,n)},go=({animationType:e,animationId:r,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${r}" has unsupported type "${e}". Use "update" or "transition".`)},$d=({id:e,targetId:r,animation:n,playback:o,animationPath:a="animation"})=>{let t=structuredClone(n);if(go({animationType:t.type,animationId:e,animationPath:a}),delete t.name,delete t.playback,t.id=e,t.targetId=r,o!==void 0){let s=Dd(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?Na(t):null;if(s.loop===!0&&t.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&t.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.`);t.playback=s}}return t},_d=(e,{animationId:r="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return go({animationType:e.type,animationId:r,animationPath:n}),e.type},jd=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Nd=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Dd=(e,r="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${r}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${r}] 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(`[${r}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${r}] 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},Td=e=>{let r=e?.playback?.speed;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:1},vr=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),$a=e=>e?.playback?.continuity==="persistent",ao=e=>Array.isArray(e)?e.map(ao):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((r,n)=>(r[n]=ao(e[n]),r),{}),nn=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let r=structuredClone(e);return r.playback&&(delete r.playback.continuity,r.playback.speed===1&&delete r.playback.speed,Object.keys(r.playback).length===0&&delete r.playback),JSON.stringify(ao(r))},_a=(e=[])=>e.filter(r=>$a(r)).map(r=>structuredClone(r)),ja=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((r,n)=>{let o=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return r+o},0):0,eo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((r,n)=>Math.max(r,ja(n)),0),Na=e=>Math.max(eo(e?.tween),eo(e?.prev?.tween),eo(e?.next?.tween),ja(e?.mask?.progress)),Da=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Na(e)/Td(e),Ld=e=>e.some(r=>r?.playback?.loop===!0),wa=({animationInstances:e,activePersistentAnimations:r})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(r)||r.length===0)return!1;let n=new Set(r.map(nn).filter(Boolean));return e.some(o=>{if(!$a(o))return!1;let a=nn(o);return a?n.has(a):!1})},qe=({animationInstances:e,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:t=!0})=>!Array.isArray(e)||e.length===0||n?!1:Ld(e)||t&&!r||wa({animationInstances:e,activePersistentAnimations:o})?!0:t?!1:wa({animationInstances:e,activePersistentAnimations:a}),Md=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(r=>e[r]!==void 0),qd=(e,r)=>{if(Md(e))throw new Error(`[${r}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Vd=({resources:e,animationId:r,playback:n,instanceId:o,targetId:a,animationPath:t="animation"})=>{if(!r||!a)return!1;let s=e?.animations?.[r];return s?$d({id:o,targetId:a,animation:s,playback:n,animationPath:t}):null},Fd=(e,{defaultTargetId:r,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return go({animationType:a.type,animationId:a.id??n,animationPath:o}),a.id??=n,a.targetId??=r,a},bo=({animations:e,transitions:r,defaultTargetId:n,idPrefix:o,animationPathPrefix:a=o})=>{r.forEach((t,s)=>{e.push(Fd(t,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},lo=(e,r)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${r} must be an array of objects`);return e},Ud=({content:e,path:r,variables:n})=>lo(e,r).reduce((o,a)=>{let t=Lr(a.text,{variables:n});return o+`${t??""}`.length},0),Ia=(e=[])=>{let r=new Map;for(let n of e)n?.id&&r.set(n.id,(r.get(n.id)??0)+1);return new Set(Array.from(r.entries()).filter(([,n])=>n>1).map(([n])=>n))},en=(e,r=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}-${r}-${o.join("-")}`},yt=(e,r)=>{if(!r.transformId)throw new Error(`Visual item "${r.id}" requires transformId`);let n=e.transforms?.[r.transformId];if(!n)throw new Error(`Transform "${r.transformId}" not found for visual item "${r.id}"`);return n},Bd=(e,r={})=>{if(!r?.transformId)return;let n=e.transforms?.[r.transformId];if(!n)throw new Error(`Transform "${r.transformId}" not found for background`);return n},Yd=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],zd=(e={})=>Yd.some(r=>vr(e,r)),Ta=(e={},r)=>{if(r){if(e.images?.[r])return"sprite";if(e.videos?.[r])return"video";if(e.spritesheets?.[r])return"spritesheet-animation";if(e.layouts?.[r])return"container"}},tn=({resourceId:e,kind:r})=>{if(e)return r?`bg-cg-background-${r}`:`bg-cg-${e}`},Gd=(e={})=>e.textStyles||{},Xd=(e={})=>e.images||{},Wd=.5,Hd=(e={},r,n)=>{if(r){if(!e.animations?.[r])throw new Error(`Animation '${r}' not found in spritesheet resource '${n}'`);return r}return Object.keys(e.animations??{})[0]},La=({id:e,resourceId:r,spritesheet:n,animationName:o,animationSpeed:a,loop:t,transform:s={}}={})=>{let i=Hd(n,o,r),l=i?n.animations?.[i]:void 0;if(!l){console.warn(`Spritesheet animation not found: ${r}`);return}return{id:e,type:"spritesheet-animation",...s,width:n.width,height:n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:l.frames,animationSpeed:a??l.animationSpeed??Wd,loop:t??l.loop??!0}}},Ma=({id:e,item:r,resources:n={}}={})=>{let o=n.images?.[r.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?.[r.resourceId];if(a)return La({id:e,resourceId:r.resourceId,spritesheet:a,animationName:r.animationName,animationSpeed:r.animationSpeed,loop:r.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${r.resourceId}`)},Kd=(e={})=>e.colors||{},Jd=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,gt=(e,r)=>e==="root"?`${r}`:`${e}.${r}`,Fr=(e,r,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${r}" must resolve to a non-empty string`)},ro=(e,r,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${r} for text style "${n}" must be a number between 0 and 1`);return e},to=(e,r,n,o,{minimum:a}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let t=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${r} for text style "${n}" must be ${t}`)}return e},an=(e,r)=>{if(typeof e!="string"||!Jd.test(e))throw new Error(`${r} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},va=(e,r,n)=>{let o=an(e,n);if(r===1)return o;let a=Number.parseInt(o.slice(1,3),16),t=Number.parseInt(o.slice(3,5),16),s=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${t}, ${s}, ${r})`},Qd=(e={},r)=>{let n=Gd(e)?.[r];if(!n)throw new Error(`Text style "${r}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let u=e.fonts?.[l];if(!u)throw new Error(`Font "${l}" not found for text style "${r}"`);return u.fileId}),t=e.colors?.[n.colorId];if(!t)throw new Error(`Color "${n.colorId}" not found for text style "${r}"`);let s=ro(n.colorAlpha,"colorAlpha",r),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:va(t.hex,s,`Color "${n.colorId}" for text style "${r}"`)};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 "${r}"`);let u=ro(n.strokeAlpha,"strokeAlpha",r);i.strokeColor=va(l.hex,u,`Stroke color "${n.strokeColorId}" for text style "${r}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${r}" 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 "${r}"`);i.shadow={color:an(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${r}"`),alpha:ro(n.shadow.alpha,"shadow.alpha",r),blur:to(n.shadow.blur,"blur",r,0,{minimum:0}),offsetX:to(n.shadow.offsetX,"offsetX",r,2),offsetY:to(n.shadow.offsetY,"offsetY",r,2)}}return i},co=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>co(a,r,`${n}[${t}]`));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,t]of Object.entries(e))a!=="textStyleId"&&(o[a]=co(t,r,gt(n,a)));return e.textStyleId!==void 0&&(Fr(e.textStyleId,n,"textStyleId"),o.textStyle=Qd(r,e.textStyleId)),o},wo=(e={},r)=>{let n=Kd(e)?.[r];if(!n)throw new Error(`Color "${r}" not found`);return an(n.hex,`Color "${r}"`)},qa=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",no=(e,r,n)=>{let o=e?.[r];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${r}.fill is not allowed in rect layout elements at "${n}". Use ${qa(`${r}.fill`)} instead`)},Zd=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>bt(a,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,t]of Object.entries(e))a!=="colorId"&&(o[a]=bt(t,r,gt(n,a)));return e.colorId!==void 0&&(Fr(e.colorId,n,"colorId"),o.fill=wo(r,e.colorId)),o},bt=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>bt(a,r,`${n}[${t}]`));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 ${qa("fill")} instead`);no(e,"hover",n),no(e,"click",n),no(e,"rightClick",n)}let o={};for(let[a,t]of Object.entries(e))if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=Zd(t,r,gt(n,a));continue}o[a]=bt(t,r,gt(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(Fr(e.colorId,n,"colorId"),o.fill=wo(r,e.colorId)),o},so=(e={},r)=>{let n=Xd(e)?.[r];return n||null},Va=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Aa=(e,r,n,o)=>{let a=e?.[r];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,o))throw new Error(`Inline ${r}.${o} is not allowed in sprite layout elements at "${n}". Use ${Va(`${r}.${o}`)} instead`)},ka=(e,r,n)=>{let o=e[r];e[r]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},uo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>uo(a,r,`${n}[${t}]`));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 ${Va(a)} instead`);Aa(e,"hover",n,"src"),Aa(e,"click",n,"src")}let o={};for(let[a,t]of Object.entries(e))e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=uo(t,r,gt(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){Fr(e.imageId,n,"imageId");let a=so(r,e.imageId),t=a?.fileId??e.imageId;o.src=t,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&&(Fr(e.hoverImageId,n,"hoverImageId"),ka(o,"hover",so(r,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Fr(e.clickImageId,n,"clickImageId"),ka(o,"click",so(r,e.clickImageId)?.fileId??e.clickImageId)),o},Io=(e,r={},n="root")=>uo(bt(co(e,r,n),r,n),r,n),Ke=Io,Ar=(e=[])=>e.find(r=>r.id==="story"),em="#000000",po="bg-cg-background-color",rm=({resources:e={},background:r={},screen:n})=>r?.colorId===void 0?an(n?.backgroundColor??em,"screen.backgroundColor"):wo(e,r.colorId),Fa=(e={})=>{if(vr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},tm=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Pa=(e={},{includeDefaultAlpha:r=!1}={})=>{let n=Fa(e),o=tm(e),a={};return(r||n!==void 0)&&(a.alpha=n??1),o&&(a.blur=o),a},nm=(e={})=>{if(vr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},sm=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ua=(e={})=>{let r=nm(e),n=sm(e),o={};return r!==void 0&&(o.alpha=r),n&&(o.blur=n),o},Vr=(e={})=>Ua(e),We=(e={},r={})=>{let n={x:r.x??e.x,y:r.y??e.y,anchorX:r.anchorX??e.anchorX,anchorY:r.anchorY??e.anchorY,rotation:r.rotation??e.rotation,scaleX:r.scaleX??e.scaleX,scaleY:r.scaleY??e.scaleY},o=r.originX??e.originX,a=r.originY??e.originY;return o!==void 0&&(n.originX=o),a!==void 0&&(n.originY=a),n},om=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],vo=(e={})=>e.text&&vr(e.text,"content")&&vr(e.text,"textStyleId"),xa=(e={})=>{if(e.resourceId)return e.resourceId;if(vo(e))return"text"},Ea=(e,r={})=>typeof e=="string"?r.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?r.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return r.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:r.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:r.images?.[n.src]?.fileId??n.src}:n})}:e,im=({item:e,particle:r,resources:n})=>{let o=yt(n,e),a=structuredClone(r),t=a.modules?.appearance?.texture;t!==void 0&&(a.modules.appearance.texture=Ea(t,n)),a.texture!==void 0&&(a.texture=Ea(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...We(o,e)};return Object.assign(s,Vr(e)),s},am=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!vo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let r of om)if(vr(e.text,r))throw new Error(`Visual item "${e.id}" text.${r} is reserved for the visual item`)}},lm=({resources:e,background:r,screen:n={width:1920,height:1080},includeOpacity:o=!1})=>{let a={id:po,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:rm({resources:e,background:r,screen:n})};if(o){let t=Fa(r);t!==void 0&&(a.alpha=t)}return a},cm=(e={},r)=>r?!!(e.images?.[r]||e.videos?.[r]||e.spritesheets?.[r]||e.layouts?.[r]):!1,Sa=({resources:e={},resourceId:r,colorId:n})=>{let o=Ta(e,r);return r&&(o||n===void 0)?{resourceId:r,targetId:tn({resourceId:r,kind:o})}:n!==void 0?{resourceId:po,targetId:po}:{resourceId:void 0,targetId:void 0}},Ba=100,ar=Ba,um="channel:bgm",pm="channel:music-room",fm="music-room:player",dm="channel:voice",mm="default",ym=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),ht=(...e)=>e.map(ym).join(":"),sn=(e,r,n)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let t=n?` in ${n}`:"";throw new Error(`Duplicate ${r} id "${a}"${t}.`)}o.add(a)})},hm=(e,r)=>e*r/Ba,Ya=(e={},r)=>e?.[r]??or[r],ln=(e={},r,n=ar)=>hm(n,Ya(e,r)),cn=({id:e,volume:r,muted:n,pan:o,loop:a,playback:t,interruption:s,children:i,runtime:l})=>{let u={id:e,type:"audio-channel",volume:r,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(u.loop=a),t!==void 0&&(u.playback=structuredClone(t)),s!==void 0&&(u.interruption=s),u},rn=(e,r,n,o)=>e[n]!==void 0?e[n]:r[n]!==void 0?r[n]:o,gm=["muted","pan","playbackRate","startAt","endAt"],un=({id:e,sound:r,resource:n,defaultLoop:o=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:rn(r,n,"loop",o),volume:rn(r,n,"volume",ar),startDelayMs:rn(r,n,"startDelayMs",0)};gm.forEach(s=>{let i=rn(r,n,s,void 0);i!==void 0&&(a[s]=i)}),r.playback!==void 0&&(a.playback=structuredClone(r.playback));let t=a.startAt??0;if(a.endAt!==void 0&&a.endAt!==null&&a.endAt<t)throw new Error(`Sound "${e}" endAt (${a.endAt}) must be greater than or equal to startAt (${t}).`);return a},Te=({variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:t=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g=[],characters:h={},dialogueUIHidden:w,skipOnlyViewedLines:b,skipTransitionsAndAnimations:E}={})=>{let v={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??u??!1,skipMode:a?.skipMode??c??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},k=Am({dialogueState:s,includeInactiveAdvDialogue:i,characters:h,variables:e,runtime:v}),x={variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:v.localizationPackageId,runtime:v,saveSlots:t,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g,characters:h};return k&&(x.dialogue=k,x.dialogueLines=k.lines),x},Ra=100,on=(e,r)=>{if(Array.isArray(e))return e.map(o=>on(o,r));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=on(n[o],r)}),n.type==="text-revealing"?r(n):n},bm=e=>on(e,r=>({...r,revealEffect:"none"})),wm=e=>on(e,r=>{let n=Number(r.speed??r.displaySpeed),o=Number.isFinite(n)?Math.max(n,Ra):Ra;return{...r,speed:o,...Object.prototype.hasOwnProperty.call(r,"displaySpeed")?{displaySpeed:o}:{}}}),lr=(e,{isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>r||o?bm(e):n?wm(e):e,za=({id:e,screen:r={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:r.width,height:r.height,x:0,y:0,click:{payload:{actions:{}}}}),fo=e=>{if(Array.isArray(e))return e.map(fo);if(!e||typeof e!="object")return e;let r={};for(let[t,s]of Object.entries(e))r[t]=fo(s);let n=r.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return r;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{...r,click:{...r.click,payload:{...n,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},Im=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Oa="submit",oo=(e,r,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},t=n.replaceActions===!0?r:{...a,...r};return{...e||{},payload:{...o,actions:t}}},mo=(e,r,n={})=>{if(Array.isArray(e))return e.map(u=>mo(u,r,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===Oa,t=o&&n.submitRoleAncestor,s=a||t?{submitRoleAncestor:!0}:{},i={};for(let[u,c]of Object.entries(e))i[u]=mo(c,r,u==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let u=r?.fields?.[l.field];if(u){let c={updateFormField:{formKey:r.key,field:u.id,value:"_event.value"}};l={...l,value:u.value,placeholder:l.placeholder===void 0?u.placeholder:l.placeholder,multiline:l.multiline===void 0?u.multiline:l.multiline,...l.maxLength===void 0&&u.maxLength!==void 0?{maxLength:u.maxLength}:{},change:oo(l.change,c),submit:oo(l.submit,r.submitActions)}}}return l.formRole===Oa||t?{...l,click:oo(l.click,r.submitActions,{replaceActions:!0})}:l},yo=(e,r)=>{if(Array.isArray(e))return e.map(o=>yo(o,r));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=yo(a,r);for(let o of Im){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},ho=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0,s=Ht({characterId:e,character:r,characterName:n,characters:o,variables:a});return{...t||{},...r||{},name:s}},Ga=(e=[],r={},n={})=>e.map(o=>{let a=ho({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:r,variables:n}),t=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(s=>s?.text??"").join(""):"";return{...o,text:t,character:a,characterName:a.name}}),vm=e=>!(!e||e.mode==="adv"&&e.content===void 0),Am=({dialogueState:e,includeInactiveAdvDialogue:r=!1,characters:n={},variables:o,runtime:a}={})=>{if(!r&&!vm(e))return;let t=e.content===void 0?[{text:""}]:lo(e.content,"dialogue.content"),s=e.content===void 0?0:Ud({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??or.dialogueTextSpeed,l=e.textSpeed??i,u=(e.lines||[]).map((p,m)=>{let d=lo(p.content,`dialogue.lines[${m}].content`),f=ho({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:d.map(y=>({...y,text:Lr(y.text,{variables:o})})),character:f,characterName:f.name}}),c=ho({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:c,textSpeed:l,content:t.map(p=>({...p,text:Lr(p.text,{variables:o})})),initialRevealedCharacters:s,lines:u}},Xa=({container:e,resources:r,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:t=!1})=>{let s=He(e,n);return Ke(lr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:t}),r)},io=(e,r={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(r),Ca=({renderStateKeyboard:e,keyboard:r,phase:n})=>{!r||typeof r!="object"||Array.isArray(r)||Object.entries(r).forEach(([o,a])=>{let t=e[o]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...t,keydown:{payload:io(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:io(a.keyup)});return}e[o]={...t,[n]:{payload:io(a)}}})},km=(e={},r={})=>{let n={};return Ca({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Ca({renderStateKeyboard:n,keyboard:r,phase:"keyup"}),Object.keys(n).length>0?n:void 0},Je=({animationsDef:e,resources:r,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:t,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],u=({instanceId:h,targetId:w})=>{let b=Vd({resources:r,animationId:d,playback:f,instanceId:h,targetId:w,animationPath:s});b&&l.push(b)},c=n!=null&&n!==!1,p=o!=null&&o!==!1,m=a&&t&&a===t;qd(e,s);let d=jd(e),f=Nd(e),y=r?.animations?.[d],g=_d(y,{animationId:d,animationPath:s});if(g==="update")return p&&t?u({instanceId:`${i}-animation-update`,targetId:t}):c&&a&&u({instanceId:`${i}-animation-update`,targetId:a}),l;if(g==="transition"){let h=`${i}-animation-transition`,w=f?.continuity==="persistent"?h:`${i}-animation-in`;if(c&&p&&m)return u({instanceId:h,targetId:t}),l;c&&u({instanceId:`${i}-animation-out`,targetId:a}),p&&u({instanceId:w,targetId:t})}return l},Pm=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),xm=(e,{presentationState:r,previousPresentationState:n,currentLineActions:o,resources:a={},screen:t={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:u,musicRoom:c,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,saveSlots:v=[]})=>{let{elements:k,animations:x}=e;if(r.background){let C=o===void 0?!0:vr(o?.background??{},"animations"),N=k.find(ue=>ue.id==="story");if(!N)return e;let P=Bd(a,r.background),T=P||zd(r.background),q=n?.background?.resourceId,le=n?.background?.colorId,B=r.background.resourceId??(r.background.animations?q:void 0),ne=r.background.colorId??(r.background.animations?le:void 0),oe=cm(a,B),de={...r.background,colorId:ne};if((ne!==void 0||oe)&&N.children.push(lm({resources:a,background:de,screen:t,includeOpacity:!oe})),B){let{images:ue={},videos:ie={},spritesheets:O={}}=a,j=Ta(a,B),M;if(j==="sprite"?M=ue[B]:j==="video"?M=ie[B]:j==="spritesheet-animation"&&(M=O[B]),M){let Z=j==="video",ge=j==="spritesheet-animation",K={x:(t?.width??1920)/2,y:(t?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...P},xe={...Pa(r.background,{includeDefaultAlpha:!0}),...We(K,r.background)},ye;ge?ye=La({id:tn({resourceId:B,kind:j}),resourceId:B,spritesheet:M,animationName:r.background.animationName,animationSpeed:r.background.animationSpeed,loop:r.background.loop,transform:xe}):ye={id:tn({resourceId:B,kind:j}),type:Z?"video":"sprite",src:M.fileId,width:M.width,height:M.height,...xe},Z&&(ye.loop=r.background.loop??!1,ye.volume=M.volume??50),ye&&N.children.push(ye)}}if(B){let{layouts:ue={}}=a,ie=ue[B];if(ie){let O={id:tn({resourceId:B,kind:"container"}),type:"container",children:ie.elements,...Pa(r.background)};T&&Object.assign(O,We({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...P},r.background));let j=He(O,Te({variables:l,imageGallery:u,musicRoom:c,sceneReplay:p,runtime:m,saveSlots:v,dialogueState:r.dialogue,isLineCompleted:s,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,characters:a.characters||{},skipTransitionsAndAnimations:i}));N.children.push(Ke(lr(j,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let ve=Sa({resources:a,resourceId:q,colorId:le}),ce=Sa({resources:a,resourceId:B,colorId:ne}),se=Je({animationsDef:r.background.animations,resources:a,previousResourceId:ve.resourceId,currentResourceId:ce.resourceId,previousTargetId:ve.targetId,currentTargetId:ce.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});qe({animationInstances:se,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:C})&&x.push(...se)}return e},Em=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{elements:i,animations:l}=e;if(r.character&&o){let u=i.find(f=>f.id==="story");if(!u)return e;let c=r.character.items||[],p=n?.character?.items||[],m=Ia(c),d=Ia(p);for(let f=0;f<c.length;f++){let y=c[f],{transformId:g,sprites:h}=y,w=p.find(T=>T.id===y.id),b=p.findIndex(T=>T.id===y.id),E=w?.sprites&&w.sprites.length>0,v=h&&h.length>0,k=b>=0?en(w,b,d):void 0,x=Je({animationsDef:y.animations,resources:o,previousResourceId:k,currentResourceId:v?en(y,f,m):void 0,previousTargetId:k,currentTargetId:v?en(y,f,m):void 0,animationPath:`character.items[${f}].animations`,idPrefix:"character"});if(y.animations&&!h&&!g&&E&&qe({animationInstances:x,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})){l.push(...x);continue}if(y.animations&&!h&&!g)continue;if(!h||h.length===0||!g){console.warn("Character item missing sprites or transformId:",y);continue}let C=en(y,f,m),N=o.transforms[g];if(!N){console.warn("Transform not found:",g);continue}let P={type:"container",id:C,...We(N,y),...Vr(y),children:[]};for(let T of h){let q=Ma({id:`${C}-${T.id}`,item:T,resources:o});q&&P.children.push(q)}u.children.push(P),qe({animationInstances:x,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&l.push(...x)}}return e},Wa=(e,r)=>{if(!Zs.includes(e))throw new Error(`${r} must be one of: ${Zs.join(", ")}.`)},Sm=(e,r)=>{let n=!!e.resourceId||vo(e),o=e.layer??(n?void 0:r?.layer)??Qs;return Wa(o,`Visual item "${e.id}" layer`),o},Rm=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:a,skipTransitionsAndAnimations:t,variables:s,imageGallery:i,musicRoom:l,sceneReplay:u,runtime:c,activePersistentAnimations:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,saveSlots:w=[],visualLayer:b})=>{let{elements:E,animations:v}=e;if(r.visual&&o){let k=E.find(P=>P.id==="story");if(!k)return e;let x=r.visual.items,C=n?.visual?.items||[],N=Te({variables:s,imageGallery:i,musicRoom:l,sceneReplay:u,runtime:c,saveSlots:w,dialogueState:r.dialogue,isLineCompleted:a,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,characters:o.characters||{},skipTransitionsAndAnimations:t});b!==void 0&&Wa(b,"visualLayer");for(let P of x){let T=C.find(oe=>oe.id===P.id),q=Sm(P,T);if(b!==void 0&&q!==b)continue;if(am(P),P.text){let oe=yt(o,P),de={...structuredClone(P.text),id:`visual-${P.id}`,type:"text",...We(oe,P)};Object.assign(de,Vr(P)),k.children.push(Ke(He(de,N),o))}if(P.resourceId){let{images:oe={},videos:de={},spritesheets:ve={}}=o,ce=ve[P.resourceId];if(ce){let se=yt(o,P),ue=P.animationName;if(ue){let ie=ce.animations?.[ue];if(!ie)throw new Error(`Animation '${ue}' not found in spritesheet resource '${P.resourceId}'`);let O=Vr(P),j={id:`visual-${P.id}`,type:"spritesheet-animation",...We(se,P),width:P.width??ce.width,height:P.height??ce.height,alpha:O.alpha??P.alpha??1,src:ce.fileId,atlas:ce.jsonData,playback:{frames:ie.frames,animationSpeed:P.animationSpeed??ie.animationSpeed??.5,loop:P.loop??ie.loop??!0}};O.blur&&(j.blur=O.blur),k.children.push(structuredClone(j))}}else{let se=oe[P.resourceId]||de[P.resourceId];if(se){let ue=de[P.resourceId]!==void 0,ie=yt(o,P),O={id:`visual-${P.id}`,type:ue?"video":"sprite",src:se.fileId,width:se.width,height:se.height,...We(ie,P)};Object.assign(O,Vr(P)),ue&&(O.loop=se.loop??!1,O.volume=se.volume??50),k.children.push(O)}}}if(P.resourceId){let oe=o.particles?.[P.resourceId];oe&&k.children.push(im({item:P,particle:oe,resources:o}))}if(P.resourceId){let{layouts:oe={}}=o,de=oe[P.resourceId];if(de){let ve=yt(o,P),ce={id:`visual-${P.id}`,type:"container",children:structuredClone(de.elements),...We(ve,P)};Object.assign(ce,Vr(P));let se=He(ce,N);k.children.push(Ke(lr(se,{isLineCompleted:a,skipMode:d,skipTransitionsAndAnimations:t}),o))}}let le=xa(T),B=xa(P),ne=Je({animationsDef:P.animations,resources:o,previousResourceId:le,currentResourceId:B,previousTargetId:le?`visual-${P.id}`:void 0,currentTargetId:B?`visual-${P.id}`:void 0,animationPath:`visual.items[${P.id}].animations`,idPrefix:P.id});qe({animationInstances:ne,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:p})&&v.push(...ne)}}return e},qr="dialogue-character-sprite",Om=(e,{presentationState:r,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:i}=e,l=Ar(e.elements);if(!l)return e;let u=r.dialogue?.character?.sprite,c=n?.dialogue?.character?.sprite,p=ot(u),m=ot(c),d=Je({animationsDef:u?.animations,resources:o,previousResourceId:m?qr:void 0,currentResourceId:p?qr:void 0,previousTargetId:m?qr:void 0,currentTargetId:p?qr:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return u?.animations&&m&&qe({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...d),e;let f=o.transforms?.[u.transformId];if(!f)return console.warn("Transform not found:",u.transformId),e;let y={type:"container",id:qr,...We(f),children:[]};for(let g of u.items){let h=Ma({id:`${qr}-${g.id}`,item:g,resources:o});h&&y.children.push(h)}return l.children.push(y),qe({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...d),e},Cm=(e,{presentationState:r,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:u,form:c,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,activePersistentAnimations:b,saveSlots:E=[]})=>{let{elements:v,animations:k}=e;if(!r.dialogue||a)return e;let x=v.find(N=>N.id==="story");if(!x)return e;if(r.dialogue.ui&&r.dialogue.ui.resourceId){let{layouts:N={}}=o,P=N[r.dialogue.ui.resourceId];if(P){let T={elements:P.elements},q=Te({variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,saveSlots:E,dialogueState:r.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:u,form:c,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),le=He(T,q),B=Ke(lr(le?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(B))for(let ne of B)x.children.push(ne);else B&&x.children.push(B)}}Om(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let C=Je({animationsDef:r.dialogue.ui?.animations,resources:o,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:r.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:r.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return qe({animationInstances:C,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&k.push(...C),e},$m=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,activePersistentAnimations:w,saveSlots:b=[]})=>{let{elements:E,animations:v}=e;if(r.choice&&o){let k=Ar(E);if(!k)return e;let x=o?.layouts[r.choice.resourceId];if(x&&x.elements){let N={elements:x.elements},P=He(N,{...Te({variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,saveSlots:b,dialogueState:r.dialogue,isLineCompleted:t,autoMode:m,skipMode:d,isChoiceVisible:f??!!r.choice,isFormVisible:y,canRollback:g,form:h,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:r.choice?.items??[]}}),T=fo(Ke(lr(P?.elements,{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(T))for(let q of T)k.children.push(q);else T&&k.children.push(T)}let C=Je({animationsDef:r.choice.animations,resources:o,previousResourceId:n?.choice?.resourceId,currentResourceId:r.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:r.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});qe({animationInstances:C,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&v.push(...C)}return e},_m=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,activePersistentAnimations:h,saveSlots:w=[],form:b})=>{let{elements:E,animations:v}=e;if(!b?.resourceId||!o)return e;let k=Ar(E);if(!k)return e;let x=o?.layouts?.[b.resourceId];if(!x)return console.warn(`Form layout not found: ${b.resourceId}`),e;let C={id:"form-container",type:"container",x:0,y:0,children:x.elements||[]},N={...Te({variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,saveSlots:w,dialogueState:r.dialogue,isLineCompleted:t,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},P=He(C,N),T=yo(Ke(lr(mo(P,b),{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o),b);T&&k.children.push(T);let q=Je({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 qe({animationInstances:q,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&v.push(...q),e},jm=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],skipTransitionsAndAnimations:g})=>{if(!r.control?.resourceId)return e;let h=n.controls?.[r.control.resourceId];if(!h)return e;let w=km(h.keyboard,h.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(h.elements)||h.elements.length===0)return e;let b=Ar(e.elements);if(!b)return e;let E={id:`control-${r.control.resourceId}`,type:"container",x:0,y:0,children:h.elements};return b.children.push(Xa({container:E,resources:n,templateData:Te({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:c,skipTransitionsAndAnimations:g})),e},Nm=(e,{presentationState:r,resources:n,runtime:o,variables:a,musicRoomPlayer:t})=>{let{elements:s,audio:i}=e;if(r.bgm&&n){if(!Ar(s))return e;let u=r.bgm,c=!Array.isArray(u.sounds),p=c?u.resourceId?[{id:"default",resourceId:u.resourceId,loop:u.loop??!0,volume:u.volume,startDelayMs:u.startDelayMs??0}]:[]:u.sounds,m=!c&&u.loop===!0,d=[];if(c||sn(p,"BGM sound"),m){let y=p.find(g=>g.loop===!0);if(y)throw new Error(`BGM sound "${y.id}" cannot loop inside a looping BGM channel.`)}if(p.forEach(y=>{let g=n.sounds?.[y.resourceId];if(!g)return;let h=m?{...y,loop:y.loop??!1}:y;d.push(un({id:ht("bgm",c?"default":y.id),sound:h,resource:g,defaultLoop:!m}))}),d.length===0)return e;let f=Te({variables:a,runtime:o}).runtime;i.push(cn({id:um,volume:ln(f,"musicVolume",c?ar:u.volume??ar),muted:u.muted,pan:u.pan,loop:c?void 0:u.loop,playback:t?.bgmPlayback,interruption:u.interruption,children:d,runtime:f}))}return e},Dm=(e,{resources:r={},runtime:n,variables:o,musicRoomPlayer:a})=>{let t=r.musicRoom;if(!t||!a?.trackId||!a.playback)return e;let s=t.tracks.find(c=>c.id===a.trackId),i=s?r.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=Te({variables:o,runtime:n}).runtime,u=un({id:fm,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i});return e.audio.push(cn({id:pm,volume:ln(l,"musicVolume",ar),children:[u],runtime:l})),e},Tm=(e,{presentationState:r,resources:n,runtime:o})=>{let{audio:a}=e;if(r.sfx&&n){let t=r.sfx,s=!Array.isArray(t.channels),i=s?[{id:mm,sounds:t.items??[]}]:t.channels;s||sn(i,"SFX channel"),i.forEach(l=>{let u=!s&&l.loop===!0,c=[];if(s||sn(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let p=l.sounds.find(m=>m.loop===!0);if(p)throw new Error(`SFX sound "${p.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((p,m)=>{let d=n.sounds?.[p.resourceId];if(!d)return;let f=u?{...p,loop:p.loop??!1}:p;c.push(un({id:s?ht("sfx","default",m,p.id):ht("sfx",l.id,p.id),sound:f,resource:d,defaultLoop:u?!1:void 0}))}),c.length!==0&&a.push(cn({id:ht("channel","sfx",l.id),volume:ln(o,"soundVolume",l.volume??ar),muted:l.muted,pan:l.pan,loop:s?void 0:l.loop,interruption:s?void 0:l.interruption,children:c,runtime:o}))})}return e},Lm=(e,r,n)=>{if(!(!r||!n))return e?.voices?.[r]?.[n]},Mm=(e,{presentationState:r,resources:n,currentSceneId:o,runtime:a,variables:t})=>{let{audio:s}=e;if(!r?.voice)return e;let i=r.voice,l=!Array.isArray(i.sounds),u=l?i.resourceId?[{id:"default",resourceId:i.resourceId,loop:i.loop??!1,volume:ar,startDelayMs:i.startDelayMs??0}]:[]:i.sounds,c=!l&&i.loop===!0,p=[];if(l||sn(u,"Voice sound"),c){let d=u.find(f=>f.loop===!0);if(d)throw new Error(`Voice sound "${d.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(d=>{let f=Lm(n,o,d.resourceId);if(!f)return;let y=c?{...d,loop:d.loop??!1}:d;p.push(un({id:ht("voice",o,l?"default":d.id),sound:y,resource:f,defaultLoop:c?!1:void 0}))}),p.length===0)return e;let m=Te({variables:t,runtime:a}).runtime;return s.push(cn({id:dm,volume:l?i.volume??Ya(m,"soundVolume"):ln(m,"soundVolume",i.volume??ar),muted:i.muted,pan:i.pan,loop:l?void 0:i.loop,interruption:i.interruption,children:p,runtime:m})),e},qm=(e,{presentationState:r,previousPresentationState:n,resources:o={},variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})=>{let{elements:b,animations:E}=e;if(r.layout){let C=Ar(b);if(!C)return e;let N=o.layouts[r.layout.resourceId];if(!N)return e;Array.isArray(N.transitions)&&!g&&!h&&bo({animations:E,transitions:N.transitions,defaultTargetId:`layout-${r.layout.resourceId}`,idPrefix:`layout-${r.layout.resourceId}`,animationPathPrefix:"layout"});let P={id:`layout-${r.layout.resourceId}`,type:"container",x:0,y:0,children:N.elements||[]};C.children.push(Xa({container:P,resources:o,templateData:Te({variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:g,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:o.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:g,skipMode:c,skipTransitionsAndAnimations:h}))}let v=n?.layout?.resourceId,k=r.layout?.resourceId,x=Je({animationsDef:r.layout?.animations,resources:o,previousResourceId:v,currentResourceId:k,previousTargetId:v?`layout-${v}`:void 0,currentTargetId:k?`layout-${k}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return qe({animationInstances:x,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})&&E.push(...x),e},Vm=(e,{currentLineActions:r,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:i}=e,l=r?.screen?.animations;if(!l)return e;let u=n!=null,c=Je({animationsDef:l,resources:o,previousResourceId:u?"story":void 0,currentResourceId:"story",previousTargetId:u?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return qe({animationInstances:c,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...c),e},Fm=(e,{presentationState:r})=>{let n=Ar(e.elements);return!n||!r?.screen||Object.assign(n,Ua(r.screen)),e},Um=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,autoMode:l,skipMode:u,isChoiceVisible:c,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:y=[],saveSlots:g=[],screen:h,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:E,animations:v}=e;return f&&f.length>0&&f.forEach((k,x)=>{let C=n.layouts[k.resourceId];if(!C){console.warn(`Overlay layout not found: ${k.resourceId}`);return}Array.isArray(C.transitions)&&(b||bo({animations:v,transitions:C.transitions,defaultTargetId:`overlayStack-${x}`,idPrefix:`overlayStack-${x}`,animationPathPrefix:`overlayStack[${x}]`}));let N={id:`overlayStack-${x}`,type:"container",x:0,y:0,children:[za({id:`overlayStack-${x}-blocker`,screen:h}),...C.elements||[]]},P=Ga(y,n.characters,o),T=Te({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:r?.dialogue,isLineCompleted:w,autoMode:l,skipMode:u,isChoiceVisible:c,isFormVisible:p,canRollback:m,form:d,historyDialogue:P,characters:n.characters||{},skipTransitionsAndAnimations:b}),q=He(N,T),[le,...B]=q.children||[],ne=Ke(lr({...q,children:B},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);E.push({...ne,children:le?[le,...ne.children||[]]:ne.children})}),e},Bm=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,dialogueHistory:g=[],screen:h,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:E,animations:v}=e;if(!y?.resourceId)return e;let k=n.layouts?.[y.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${y.resourceId}`),e;Array.isArray(k.transitions)&&!b&&bo({animations:v,transitions:k.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let x={id:"confirmDialog",type:"container",x:0,y:0,children:[za({id:"confirmDialog-blocker",screen:h}),...k.elements||[]]},C=Ga(g,n.characters,o),N=He(x,Te({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:r?.dialogue,isLineCompleted:w,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,historyDialogue:C,characters:n.characters||{},skipTransitionsAndAnimations:b})),[P,...T]=N.children||[],q=Ke(lr({...N,children:T},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);return E.push({...q,children:P?[P,...q.children||[]]:q.children}),e},wt=e=>(r,n)=>Rm(r,{...n,visualLayer:e}),Ym=wt(Xe.BEHIND_BACKGROUND),zm=wt(Xe.BEHIND_CHARACTER),Gm=wt(Xe.BEHIND_DIALOGUE),Xm=wt(Xe.BEHIND_CHOICE),Wm=wt(Xe.FOREGROUND),Ha=e=>Wt(Pm,[jm,Ym,xm,zm,Em,Gm,Cm,Xm,$m,_m,qm,Wm,Fm,Vm,Nm,Dm,Tm,Mm,Um,Bm])(e);function Ka(e,r=""){let n=[],o=e.length,a=0,t=0,s=-1,i=()=>{let l=0,u=0,c;do c=parseInt(e[a++],36),l+=(c&15)<<u,u+=4;while(c&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,r?parseInt(r[t++],36):0])}return n}function Ja(e,r,n){let o=0,a=r.length-1;for(;o<=a;){let t=o+a>>>1,s=n[t];if(e<r[t])a=t-1;else if(e>s>>>5)o=t+1;else return s&31}return 0}var Qa="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Za="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",el="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var rl=65535,Ao=40960,pn=126976,sl=new Uint8Array(12288),ol=new Uint8Array(3072),il=new Uint8Array(2816),al,ll;{let e=(a,t,s,i,l)=>{let u=t+a.length-1;for(let c=s<t?t:s,p=i>u?u:i;c<=p;c++)a[c-t]=l},r=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,t,s]of Ka(Qa,Za))e(sl,0,a,t,s),e(ol,Ao,a,t,s),e(il,pn,a,t,s),t>=65040&&!(a>=pn&&t<=129791)&&(r[o]=a,n[o++]=t<<5|s);al=r.slice(0,o),ll=n.slice(0,o)}function tl(e){return e<12288?sl[e]:e<Ao?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?ol[e-Ao]: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>=pn&&e<129792?il[e-pn]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Ja(e,al,ll)}var cl=Uint8Array.from(el,Number);function Hm(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 nl(e,r,n){switch(r){case 3:return e&24?n===8204?e&6:(e&24)===16||Hm(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*ul(e){let r=e.length;if(r===0)return;let n=e.codePointAt(0),o=n>rl?2:1,a=tl(n),t=50200>>a&1?nl(0,a,n):0,s=0,i=n,l=a;for(;o<r;){n=e.codePointAt(o);let u=n>rl?2:1,c=tl(n),p=cl[a<<4|c],m;p===0?m=!0:p===1?m=!1:p===2?m=!(t&1):p===3?m=!(t&4):m=(t&24)!==16,t=50200>>c&1&&(t!==0||c!==3)?nl(t,c,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=c),o+=u,a=c}yield{segment:e.slice(s),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*pl(e){for(let r of ul(e))yield r.segment}{let e=ul("_");cl._keep=[e,e.next()]}var fl=1e3,hl=50,Km=0,dl=100,ml=50,Jm=60,Qm=3,Zm=.5,ey=2e4,ry=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,ty=/^\s+$/u,yl,ny=e=>{let r=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(pl(r)):(yl??=new n(void 0,{granularity:"grapheme"}),Array.from(yl.segment(r),({segment:o})=>o))},sy=e=>ny(e).reduce((r,n)=>ty.test(n)?r+Zm:ry.test(n)?r+Qm:r+1,0),oy=e=>2**(((Number.isFinite(e)?Math.min(dl,Math.max(Km,e)):hl)-ml)/(dl-ml)),gl=({text:e="",baseDelay:r=fl,speed:n=hl}={})=>{let o=Number.isFinite(r)?Math.max(0,r):fl,a=oy(n),t=sy(e)*Jm/a,s=Math.max(o,ey);return Math.min(o+t,s)};var fn={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Pl=1,Eo=1,Br="choice",cr="form",At=()=>({manual:{...fn.manual},auto:{...fn.auto},applyMode:fn.applyMode}),So=()=>({groupId:null,variantId:null,pageIndex:0}),iy="music-room:player",ay=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),yn=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Ro=new Set,ly=new Set(["groupId","variantId"]),cy=new Set(["pageIndex"]),Yr=new Set,uy=new Set(["trackId"]),py=new Set(["positionMs"]),fy=new Set(["pageIndex"]),Oo=new Set,dy=new Set(["sceneId"]),my=new Set(["pageIndex"]),Co=()=>({pageIndex:0}),$o=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...At()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},D=e=>{let r=he(e)?er(e):e;return structuredClone(r)},V=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),hn=e=>{let r=e.global.audioCommandId;if(!Number.isSafeInteger(r)||r<0)throw new Error("Internal audio command counter is invalid");if(r===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=r+1,e.global.audioCommandId},xl=e=>{let r=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(r)||r<0)throw new Error("Internal scene replay entry counter is invalid");if(r===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=r+1,e.global.sceneReplayEntryId},kt=(e,r,n)=>({commandId:hn(e),operation:r,...n===void 0?{}:{positionMs:n}}),_o=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let r=e.global.musicRoomPlayer,n=r.bgmPlayback;r.trackId!==null&&(n={commandId:hn(e),operation:"resume"}),e.global.musicRoomPlayer=yn({bgmPlayback:n})},El=(e,r)=>{if(typeof r!="string"||r.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=e.projectData.resources?.achievements?.[r];if(!n)throw new Error(`Achievement resource "${r}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${r}" has invalid type "${n.type}"`);return n},Pt=e=>String(e),Sl=()=>({sections:[],resources:[]}),Rl=()=>({sceneIds:[]}),yy=e=>V(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Sl(),hy=e=>V(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Rl(),gy=e=>Array.isArray(e)?e.map(r=>r?.text??"").join(""):"",by=({sectionId:e,lineId:r,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:r,content:n,text:gy(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),wy=()=>({resourceId:void 0}),Iy=e=>{if(!V(e))return e;let r={...e};return Object.prototype.hasOwnProperty.call(r,"requireComplete")&&!Object.prototype.hasOwnProperty.call(r,"requireLineCompleted")&&(r.requireLineCompleted=r.requireComplete),delete r.requireComplete,r},Er=(e,r)=>{let n=e?.story?.scenes??{};for(let[o,a]of Object.entries(n))if(a?.sections?.[r])return{sceneId:o,section:a.sections[r]};return{sceneId:void 0,section:void 0}},Ol=e=>{let r=e?.story?.scenes??{},n=new Map;for(let[o,a]of Object.entries(r)){let t=a?.sections??{};for(let s of Object.keys(t)){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)}}},Cl=e=>{if(typeof e=="number"||typeof e!="string")return e;let r=Number(e);return Number.isFinite(r)?r:e},$l=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Pl)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},vy=(e,r={})=>{let n;try{n=$l(r.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...r,formatVersion:n,slotId:Cl(r.slotId??r.slotKey??e),savedAt:typeof r.savedAt=="number"?r.savedAt:r.date};return delete o.slotKey,delete o.date,o},Ay=(e={})=>Object.fromEntries(Object.entries(e).map(([r,n])=>[r,vy(r,n)])),_l=e=>{if(!Array.isArray(e))return;let r=e.filter(({type:n})=>ab(n));return r.length>0?r:void 0},ky=e=>{!V(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=Eo,e.timeline.forEach(r=>{if(!V(r))return;typeof r.returnable!="boolean"&&delete r.returnable;let n=_l(r.executedActions);if(n){r.executedActions=n;return}delete r.executedActions}))},bl=(e,r,n,o="viewedRegistry")=>{let a=r==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!V(e))throw new Error(`Malformed ${o}.${r}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${r}[${n}] entry: missing ${a}.`);if(r==="sections"){let t={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&&(t.lastLineId=e.lastLineId),t}return{resourceId:e.resourceId}},Py=(e,r="viewedRegistry")=>{if(e===void 0)return Sl();if(!V(e))throw new Error(`Malformed ${r}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${r}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${r}.resources.`);let n=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,t)=>{let s=bl(a,"sections",t,r);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,t)=>{let s=bl(a,"resources",t,r);return[s.resourceId,s]})))}},xy=(e,r="accountReplayRegistry")=>{if(e===void 0)return Rl();if(!V(e))throw new Error(`Malformed ${r}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${r}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${r}.sceneIds[${a}] entry.`);return o}))]}},jl=(e,r,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:t,section:s}=Er(r,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:t,sectionId:o,lineId:a}},Nl=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,Ey=(e,r)=>{let{section:n}=Er(e,r?.sectionId);return n?.lines?.find(o=>o.id===r?.lineId)},Sy=(e,r)=>{let{section:n}=Er(e,r?.sectionId),o=n?.lines?.findIndex(t=>t.id===r?.lineId);if(typeof o!="number"||o<0)return null;let a=n.lines[o+1];return a?{sectionId:r.sectionId,lineId:a.id}:null},Dl=(e,r,n)=>{if(typeof r?.sectionId!="string")return!1;let{section:o}=Er(e,r.sectionId);return Nl({sectionId:r.sectionId,lineId:o?.lines?.[0]?.id},n)},Ry=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),Ur={always:"always",maybe:"maybe",never:"never"},Oy=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return Ur.always;let r=e.when,n;if(r===null||typeof r=="boolean"||typeof r=="number")n=r;else if(V(r)&&Object.keys(r).length===1&&Object.prototype.hasOwnProperty.call(r,"literal"))n=r.literal;else return Ur.maybe;return n?Ur.always:Ur.never},Tl=(e,r)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let o=Oy(n);if(o!==Ur.never){if(r(n))return!0;if(o===Ur.always)return!1}}return!1},Ll=e=>Tl(e,r=>Object.entries(r?.actions??{}).some(([n,o])=>n==="conditional"?Ll(o):Ry.has(n))),Ml=(e,r,n)=>Tl(r,o=>Object.entries(o?.actions??{}).some(([a,t])=>a==="sectionTransition"?Dl(e,t,n):a==="conditional"?Ml(e,t,n):!1)),Cy=(e,r,n)=>{if(!r)return!0;let o=Ey(n,e)?.actions;if(!V(o))return!0;if(Dl(n,o.sectionTransition,r))return!1;let a=o.conditional;return a?!(Ml(n,a,r)||!(o.choice?.resourceId||o.form?.resourceId)&&!Ll(a)&&Nl(Sy(n,e),r)):!0},$y=(e,r,n)=>{if(!V(e)||!Array.isArray(e.timeline))return vt({pointer:r,replayStartIndex:1});let o=new WeakSet,a=e.timeline.flatMap((u,c)=>{if(!V(u))return[];try{let p=jl(u,n,`rollback.timeline[${c}]`),m=mn({sectionId:p.sectionId,lineId:p.lineId,rollbackPolicy:u.rollbackPolicy,returnable:u.returnable});typeof u.returnable=="boolean"&&o.add(m);let d=_l(D(u.executedActions));return d&&(m.executedActions=d),[m]}catch{return[]}});if(a.length===0)return vt({pointer:r,replayStartIndex:1});e.returnabilityVersion!==Eo&&a.forEach((u,c)=>{!o.has(u)&&!Cy(u,a[c+1],n)&&(u.returnable=!1)});let s=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):a.length-1;(s<0||s>=a.length)&&(s=a.length-1);let i=a[s];if(i?.sectionId!==r.sectionId||i?.lineId!==r.lineId){let u=a.findLastIndex(c=>c.sectionId===r.sectionId&&c.lineId===r.lineId);u>=0?s=u:(a.push(mn({sectionId:r.sectionId,lineId:r.lineId})),s=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),s):0;return{currentIndex:s,isRestoring:!1,replayStartIndex:l,timeline:a}},_y=(e,r,n)=>{if(!V(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Do(r),a=jl(e.pointers?.read,r,`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 t=e.variables?Tr(D(e.variables),r.resources?.variables??{}):{},s=zy({loadedContextRuntime:V(e.runtime)?D(e.runtime):{}}),i={currentPointerMode:"read",pointers:{read:a},configuration:V(e.configuration)?D(e.configuration):{},views:Array.isArray(e.views)?D(e.views):[],bgm:V(e.bgm)?D(e.bgm):{resourceId:void 0},variables:{...o,...t},rollback:$y(e.rollback,a,r)};return s&&(i.runtime=s),i},jy=(e,r)=>{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)=>_y(n,r,o))}},Ny=(e,r)=>{if(!V(e))throw new Error("Malformed save slot.");let n=$l(e.formatVersion);return{...e,formatVersion:n,state:jy(e.state,r)}},wl=(e,r,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${r}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${r} must be an action object`);let o=D(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},Dy=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:wl(e.confirmActions,"confirmActions",{required:!0}),cancelActions:wl(e.cancelActions,"cancelActions")}},zr=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Ty=e=>(V(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Gr=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},ql=e=>{if(!(!V(e)||!e.animations))return{animations:D(e.animations)}},Ly=(e,r)=>{let n=ql(r);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},My=e=>{let r=e?.id??e?.resourceId;return typeof r=="string"&&r.length>0?r:void 0},qy=(e,r)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!r))return`${n}:${o}:${r}`},dn=e=>String(e??""),Vl=(e,r)=>{let n=dn(r);return e?.trim===!0?n.trim():n},Vy=e=>V(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,r])=>V(r)).map(([r,n])=>[r,{id:r,...D(n)}])):{},Fy=(e,r)=>{if(!r||!V(e.global.formDrafts))return;let n=e.global.formDrafts[r];return V(n)?n:void 0},Fl=(e,r)=>{let n=Ty(e);V(n[r])||(n[r]={values:{},touched:{},errors:{},submitted:!1});let o=n[r];return V(o.values)||(o.values={}),V(o.touched)||(o.touched={}),V(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},jo=(e,r)=>{let n=Vl(e,r);return e?.required===!0&&n.length===0?"required":null},Uy=({state:e,pointer:r})=>{if(!r?.sectionId||!r?.lineId)return{};let o=we({state:e},{sectionId:r.sectionId})?.lines||[],a=o.findIndex(t=>t.id===r.lineId);return a<0?{}:wr(o.slice(0,a+1).map(t=>t.actions||{}))},By=({state:e,form:r,pointer:n})=>{if(!r?.resourceId)return null;let o=My(r),a=qy(n,o);if(!o||!a)return null;let t=Fy(e,a),s=Vy(r),i=gn({state:e}),l={},u=[],c={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=dn(i?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(t?.values??{},m)?dn(t.values[m]):f,g=t?.touched?.[m]===!0,h=jo(d,y),w=t?.submitted||g?h:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,E={id:m,variableId:d.variableId,value:y,initialValue:f,valid:!h,error:w,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[m]=E,u.push(E),c[m]=y}),{id:o,key:a,resourceId:r.resourceId,animations:r.animations,valid:p,submitted:t?.submitted===!0,fields:l,fieldList:u,values:c,submitActions:{submitForm:{formKey:a,actions:D(r.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:D(r.cancelActions??{})}}}},Pr=[],Il="line",No="interaction",mn=({sectionId:e,lineId:r,rollbackPolicy:n,returnable:o})=>({sectionId:e,lineId:r,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{}}),Do=e=>{let r=he(e)?er(e):e,{contextVariableDefaultValues:n}=Kt(r??{});return D(n)},Ul=()=>({...D(dt)}),Bl=({loadedRuntime:e,runtimeIds:r,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:D(n),hasLoadedValues:!1};if(!V(e))throw new Error(`Malformed ${o}.`);let a=D(n),t=!1;return r.forEach(s=>{e[s]!==void 0&&(a[s]=Zt(s,D(e[s])),t=!0)}),{runtimeState:a,hasLoadedValues:t}},Yy=({projectData:e,loadedGlobalRuntime:r={}})=>Bl({loadedRuntime:r,runtimeIds:Hs,defaults:Js(e),path:"global.runtime"}).runtimeState,zy=({loadedContextRuntime:e={}})=>{let{runtimeState:r,hasLoadedValues:n}=Bl({loadedRuntime:e,runtimeIds:Ks,defaults:Ul(),path:"context.runtime"});return n?r:void 0},Xr=e=>{let r=Array.isArray(e?.contexts)?e.contexts:[];return r[r.length-1]},te=e=>{let r=Xr(e);return r?.kind==="sceneReplay"&&V(r.sceneReplay)?r:null},Yl=(e,r)=>{let n=r?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([a,t])=>{r.variables[a]=D(t)})},Gy=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:D(e.global.nextLineConfig),overlayStack:D(e.global.overlayStack),confirmDialog:D(e.global.confirmDialog),formDrafts:D(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:D(e.global.pendingScreenTransition)}}),Xy=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=At(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Wy=(e,r)=>{e.global.autoMode=r.autoMode,e.global.skipMode=r.skipMode,e.global.dialogueUIHidden=r.dialogueUIHidden,e.global.nextLineConfig=D(r.nextLineConfig),e.global.overlayStack=D(r.overlayStack),e.global.confirmDialog=D(r.confirmDialog),e.global.formDrafts=D(r.formDrafts),e.global.isLineCompleted=r.isLineCompleted,r.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=r.isDialogueHistoryShowing,r.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=D(r.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Pe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Hr({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}})},Hy=e=>e.runtime?(Ks.forEach(r=>{e.runtime[r]===void 0&&(e.runtime[r]=D(dt[r]))}),e.runtime):(e.runtime=Ul(),e.runtime),Ky=e=>ba(e.global),zl=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Ky(e)}})},To=(e,r,n)=>{let o=Zt(r,n);if(r in dt){let a=Xr(e);if(!a)return o;let t=Hy(a);return t[r]=o,o}return e.global[r]=o,o},Lo=({pointer:e,projectData:r,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:D(o)},currentPointerMode:"read",pointers:{read:D(e)},configuration:{},views:[],bgm:wy(),variables:Do(r),rollback:vt({pointer:e})}),Wr=e=>e?(e.currentPointerMode="read",V(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,Jy=(e,{queueRender:r=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],o=n?.pointers?.read;if(!n||!o?.sectionId||!o?.lineId)return null;let a=Lo({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Qy(e,{queueRender:r}),a},Qy=(e,{queueRender:r=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,zr(e),Gr(e),e.global.nextLineConfig=At(),e.global.overlayStack=[],e.global.isLineCompleted=!0,_o(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),r&&e.global.pendingEffects.push({name:"render"})},Gl=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},vt=({pointer:e,replayStartIndex:r=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:r,timeline:n?[mn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Sr=(e,r={})=>{if(e?.rollback)return Gl(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=vt({pointer:n,replayStartIndex:r.compatibilityAnchor?1:0}),e.rollback},Mo=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=Sr(n);o.isRestoring||(o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(mn(r)),o.currentIndex=o.timeline.length-1)},Zy=({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}},eh=({state:e},r={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:a,lineId:t}=r,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(he(l)?ks(l):l)!==o||l?.sectionId!==a||l?.lineId!==t||(l.returnable=!1),e},rh=({state:e},r={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:t,lineId:s}=r,i=Pt(n),l=e.global.saveSlots?.[i],u=he(l)?ks(l):l;if(!l||u!==o)return e;let c=l.state?.contexts,p=Array.isArray(c)?c.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==t||p?.pointers?.read?.lineId!==s||d?.sectionId!==t||d?.lineId!==s||(d.returnable=!1,m.returnabilityVersion=Eo,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},th=e=>{let n=e.contexts?.[e.contexts.length-1]?.rollback;if(!n||n.isRestoring||!Array.isArray(n.timeline)||typeof n.currentIndex!="number")return null;let o=Pr[Pr.length-1],a=typeof o?.checkpointIndex=="number"?o.checkpointIndex:n.currentIndex;return a<0||a>=n.timeline.length?null:(typeof o?.checkpointIndex!="number"&&a<n.timeline.length-1&&(n.timeline=n.timeline.slice(0,a+1)),n.timeline[a]??null)},nh=({state:e},r={})=>{let n=r?.source===Il?Il:No,a=e.contexts?.[e.contexts.length-1]?.rollback;return!a||a.isRestoring||!Array.isArray(a.timeline)||typeof a.currentIndex!="number"||a.currentIndex<0||a.currentIndex>=a.timeline.length?(Pr.push({checkpointIndex:null,source:n}),e):(a.currentIndex<a.timeline.length-1&&(a.timeline=a.timeline.slice(0,a.currentIndex+1)),Pr.push({checkpointIndex:a.currentIndex,source:n}),e)},sh=({state:e})=>(Pr.pop(),e),Be=(e,r,n)=>{let a=Pr[Pr.length-1]?.source??No;if(!lb(r,a))return;let t=th(e);t&&(Array.isArray(t.executedActions)||(t.executedActions=[]),t.executedActions.push({type:r,payload:D(n)}))},vl=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=r?.operations??[];for(let{variableId:a,op:t,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],u=l?.scope,c=l?.type;if(De(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);pt(u,a),Jt(c,t,a),Bs(c,t,s,a,{roundTo:i}),u==="context"&&(n.variables[a]=Qt(n.variables[a],t,s,{roundTo:i}))}},oh=(e,r)=>{Array.isArray(r?.executedActions)&&r.executedActions.forEach(({type:n,payload:o})=>{cb(e,n,o)})},ih=(e,r)=>{let{sectionId:n,lineId:o}=r,s=we({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Object.entries(s).forEach(([i,l])=>{Ec(e,i,l)})},Xl=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=Sr(n),a=o.timeline[r];if(!a)return e;e.global.autoMode&&St({state:e}),e.global.skipMode&&ur({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=r;try{n.variables=Do(e.projectData),n.kind==="sceneReplay"&&(Yl(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=D(fn),e.global.overlayStack=[],zr(e),Gr(e),e.global.isLineCompleted=!0;let t=o.replayStartIndex??0;for(let i=t;i<=r;i++)i>t&&$o(e),ih(e,o.timeline[i]),oh(e,o.timeline[i]);let s=Wr(n);s.read={sectionId:a.sectionId,lineId:a.lineId},n.kind==="sceneReplay"&&(n.sceneReplay.entryId=xl(e)),e.global.pendingEffects=e.global.pendingEffects.filter(i=>i?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},ah=e=>{let{projectData:r}=e,n=e.global??{},{saveSlots:o={},variables:a={},runtime:t={},accountViewedRegistry:s={},accountReplayRegistry:i={},localizationPackages:l=[{l10nId:null,language:null}]}=n;Ol(r),at(r),lt(r),ct(r),br(r?.resources?.variables??{});let u=r.story.initialSceneId,c=r.story.scenes[u],p=c.initialSectionId,m=c.sections[p],d={sceneId:u,sectionId:p,lineId:m.initialLineId??m.lines[0].id},{globalVariablesDefaultValues:f}=Kt(r),y={...f,...Tr(a,r.resources?.variables??{})};return{projectData:r,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Py(s,"accountViewedRegistry"),accountReplayRegistry:xy(i),nextLineConfig:At(),imageGalleryNavigation:So(),sceneReplayNavigation:Co(),sceneReplayEntryId:0,audioCommandId:0,musicRoomPlayer:yn(),saveSlots:Ay(o),localizationPackages:D(l),overlayStack:[],variables:y,...Yy({projectData:r,loadedGlobalRuntime:t})},contexts:[Lo({pointer:d,projectData:r})]}},lh=({state:e})=>e.global.overlayStack||[],ch=({state:e})=>e.global.pendingEffects,Wl=({state:e})=>e.global.skipMode,uh=({state:e})=>e.global.autoMode,Hl=({state:e})=>e.global.dialogueUIHidden,Kl=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(!n)return[];let{sectionId:o,lineId:a}=n.pointers.read,t=we({state:e},{sectionId:o});if(!t?.lines||!Array.isArray(t.lines))return[];let s=t.lines.findIndex(p=>p.id===a),i=t.lines.slice(0,s+1),l=[],u={},c=ut({variables:{...e.global?.variables??{},...Xr(e)?.variables??{}},runtime:Ir(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});for(let p of i){let m=p.actions||{};if(u=wr([u,m]),!m.dialogue)continue;let d=u.dialogue||{},f=Ht({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:c}),y=by({sectionId:o,lineId:p.id,content:m.dialogue.append===!0?d.content:m.dialogue.content,dialogueState:d,characterName:f});if(m.dialogue.append===!0&&l.length>0){l[l.length-1]={...l[l.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}l.push(y)}return l},ph=({state:e})=>e.global.confirmDialog??null,xt=({state:e},{pointer:r}={})=>{let n=r??Re({state:e})?.pointer,o=Uy({state:e,pointer:n});return By({state:e,form:o.form,pointer:n})},fh=({state:e},{pointer:r}={})=>!!xt({state:e},{pointer:r}),Pe=({state:e},{pointer:r}={})=>{let n=xt({state:e},{pointer:r});if(n)return{source:cr,formId:n.id,formKey:n.key};let o=tc({state:e,pointer:r});return o?{source:Br,resourceId:o}:null},dh=({state:e,registry:r},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(r?.sections)?r.sections:[]).find(c=>c.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let i=we({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=i.lines.findIndex(c=>c.id===s.lastLineId),u=i.lines.findIndex(c=>c.id===a);return l===-1||u===-1?s.lastLineId===a:u<=l},qo=({registry:e},r)=>{let{resourceId:n}=r;return!!(Array.isArray(e?.resources)?e.resources:[]).find(t=>t.resourceId===n)},Vo=({state:e},r)=>dh({state:e,registry:e.global.accountViewedRegistry},r),mh=({state:e},r)=>qo({registry:e.global.accountViewedRegistry},r),It=(e,r)=>!qo({registry:e.global.accountViewedRegistry},{resourceId:r.imageId}),Fo=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Uo=(e,r)=>{let n=Fo(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},ko=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!It(e,r[a]))return r[a]},yh=({state:e})=>{let r=e.projectData?.resources?.imageGallery;return r===void 0?void 0:D(r)},Jl=({state:e})=>{let r=e.projectData?.resources?.imageGallery;if(r===void 0)return null;let n=e.global.imageGalleryNavigation??So(),o=Fo(r),a=Uo(r,n),t=a*r.pageSize,s=r.groups.slice(t,t+r.pageSize).map(l=>({groupId:l.id,locked:It(e,l.variants[0]),variants:l.variants.map(u=>({variantId:u.id,imageId:u.imageId,locked:It(e,u)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=r.groups.findIndex(d=>d.id===n.groupId),u=r.groups[l],c=u?.variants.findIndex(d=>d.id===n.variantId),p=c===void 0||c<0?void 0:u.variants[c],m=l<0?-1:Math.floor(l/r.pageSize);p&&m===a&&!It(e,p)&&(i={groupId:u.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ko(e,u.variants,c,-1)!==void 0,canMoveToNextVariant:ko(e,u.variants,c,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Bo=(e,r)=>!qo({registry:e.global.accountViewedRegistry},{resourceId:r.soundId}),Yo=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),zo=(e,r)=>{let n=Yo(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Po=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!Bo(e,r[a]))return r[a]},Ql=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}),hh=(e,r)=>({...Ql(r),locked:Bo(e,r)}),Al=e=>{let r=Math.floor(e/1e3),n=r%60,o=Math.floor(r/60);if(o<60)return`${o}:${String(n).padStart(2,"0")}`;let a=Math.floor(o/60),t=o%60;return`${a}:${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`},gh=({state:e})=>{let r=e.projectData?.resources?.musicRoom;return r===void 0?void 0:D(r)},Zl=({state:e})=>{let r=e.projectData?.resources?.musicRoom;if(r===void 0)return null;let n=e.global.musicRoomPlayer??yn(),o=Yo(r),a=zo(r,n),t=a*r.pageSize,s=r.tracks.slice(t,t+r.pageSize).map(c=>hh(e,c)),i=r.tracks.findIndex(c=>c.id===n.trackId),l=r.tracks[i],u=l?{...Ql(l),canPlayPreviousTrack:Po(e,r.tracks,i,-1)!==void 0,canPlayNextTrack:Po(e,r.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:u,playback:u?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Al(n.positionMs),durationText:n.durationMs===null?null:Al(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}}},Go=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Xo=(e,r)=>{let n=Go(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},bh=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;return r===void 0?void 0:D(r)},wh=({state:e})=>te(e)!==null,Ih=({state:e})=>{let r=te(e);return r?{sceneId:r.sceneReplay.sceneId,entryId:r.sceneReplay.entryId}:null},ec=(e,r)=>e.global.accountReplayRegistry?.sceneIds?.includes(r)===!0,rc=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;if(r===void 0)return null;let n=e.global.sceneReplayNavigation??Co(),o=Go(r),a=Xo(r,n),t=a*r.pageSize,s=r.replays.slice(t,t+r.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!ec(e,l.sceneId)})),i=te(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},vh=({state:e})=>e.global.nextLineConfig,tc=({state:e,pointer:r}={})=>{let n=r??Re({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=we({state:e},{sectionId:o})?.lines||[],i=s.findIndex(u=>u.id===a);if(i<0)return;let l;for(let u of s.slice(0,i+1)){let c=u?.actions;if(c?.cleanAll&&(l=void 0),!c||!Object.prototype.hasOwnProperty.call(c,"choice")){l=void 0;continue}let p=c.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},nc=({state:e})=>!!tc({state:e}),Ah=({state:e})=>structuredClone(e),kh=({state:e})=>D(e.projectData.resources?.achievements??{}),Ph=({state:e},r)=>{let n=e.projectData.resources?.achievements?.[r?.resourceId];return n===void 0?void 0:D(n)},sc=({state:e})=>e.global.saveSlots,xh=({state:e},r)=>{let n=r?.slotId,o=Pt(n);return e.global.saveSlots[o]},oc=({state:e})=>D(e.global.localizationPackages),Wo=({state:e})=>Ir(e),Eh=({state:e},r)=>ir(e,r?.runtimeId),gn=({state:e})=>{let r={...e.global?.variables??{},...Xr(e)?.variables??{}};return ut({variables:r,runtime:Ir(e),variableConfigs:e.projectData.resources?.variables??{}})},Re=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},we=({state:e},r)=>{let{sectionId:n}=r;return Er(e.projectData,n).section},bn=({state:e})=>{let r=Re({state:e});if(!r?.pointer)return;let{sectionId:n,lineId:o}=r.pointer,a=we({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(t=>t.id===o)},ic=({state:e})=>{let{sectionId:r,lineId:n}=Re({state:e}).pointer,a=we({state:e},{sectionId:r})?.lines||[],t=a.findIndex(u=>u.id===n),i=a.slice(0,t+1).map(u=>{let c=u.actions||{},p={};return Object.keys(c).forEach(m=>{p[m]=c[m]}),p});return wr(i)},Sh=e=>{let r=bn({state:e})?.actions?.dialogue;if(r?.clear===!0||!Array.isArray(r?.content))return"";let n=gn({state:e});return r.content.map(o=>`${Lr(o?.text,{variables:n})??""}`).join("")},Hr=({state:e})=>gl({text:Sh(e),baseDelay:ir(e,"autoForwardDelay"),speed:ir(e,"autoForwardSpeed")}),Rh=({state:e})=>{let r=ac({state:e}),o=bn({state:e})?.actions??{},a=wr([r??{},o]);return zs(r??{},a??{})},Oh=({state:e},{sectionId:r})=>{let n=we({state:e},{sectionId:r});if(!n?.lines)return[];let o=[],a={};for(let t of n.lines){let s=t.actions||{},i=wr([a,s]),l=zs(a,i);o.push({id:t.id,changes:l,presentationState:i}),a=Gs(i)}return o},Ch=({state:e},{sectionId:r,includePresentationState:n=!1})=>{let o=Oh({state:e},{sectionId:r});return n?{lines:o}:{lines:o.map(({presentationState:a,...t})=>t)}},ac=({state:e})=>{let{sectionId:r,lineId:n}=Re({state:e}).pointer,a=we({state:e},{sectionId:r})?.lines||[],t=a.findIndex(l=>l.id===n);if(t<=0)return null;let i=a.slice(0,t).map(l=>{let u=l.actions||{},c={};return Object.keys(u).forEach(p=>{c[p]=u[p]}),c});return Gs(wr(i))},Ho=({state:e},{slotsPerPage:r=6}={})=>{let a=((Wo({state:e}).saveLoadPagination??1)-1)*r+1,t=[];for(let s=0;s<r;s++){let i=a+s,l=e.global.saveSlots&&e.global.saveSlots[Pt(i)]||{};t.push({...l,slotId:i})}return{saveSlots:t}},$h=sc,_h=Ho,jh=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},Nh=({state:e},r={})=>{let n=ic({state:e}),o=ac({state:e}),a=bn({state:e})?.actions??{},t=e.global.pendingScreenTransition,s=t?.animations?{...a,screen:D(t)}:a,i=t?.animations&&o===null?{}:o,{sectionId:l}=Re({state:e}).pointer,{sceneId:u}=Er(e.projectData,l),c={...Wo({state:e}),localizationPackages:oc({state:e})},p=r?.activePersistentAnimations??[],m=r?.restoredPersistentAnimations??[],d=xt({state:e}),f=nc({state:e}),y=Jl({state:e}),g=Zl({state:e}),h=rc({state:e}),w=gn({state:e}),{saveSlots:b}=Ho({state:e}),E=jh(e);return Ha({presentationState:n,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:u,screen:e.projectData.screen,dialogueUIHidden:c.dialogueUIHidden,autoMode:c.autoMode,skipMode:c.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:Oc({state:e}),skipOnlyViewedLines:!c.skipUnseenText,isLineCompleted:c.isLineCompleted,skipTransitionsAndAnimations:!!c.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:Kl({state:e}),saveSlots:b,variables:w,runtime:c,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:D(e.global.musicRoomPlayer)})},Dh=({state:e},r)=>(e.global.confirmDialog=Dy(r),e.global.pendingEffects.push({name:"render"}),e),Th=({state:e})=>(e.global.confirmDialog&&(zr(e),e.global.pendingEffects.push({name:"render"})),e),Lh=({state:e},r)=>(e.global.overlayStack.push(r),e.global.pendingEffects.push({name:"render"}),Be(e,"pushOverlay",r),e),Mh=({state:e})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),Be(e,"popOverlay",void 0),e),qh=({state:e},r)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=r),e.global.pendingEffects.push({name:"render"}),Be(e,"replaceLastOverlay",r),e),Vh=({state:e})=>(e.global.overlayStack=[],zr(e),Gr(e),e.global.pendingEffects.push({name:"render"}),Be(e,"clearOverlays",void 0),e),Fh=(e,{activeInteraction:r})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),r&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},Et=(e,r,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Ly(e,n),Gr(e);let o=Pe({state:e},{pointer:r}),a=o?.source===Br,t=o?.source===cr;Fh(e,{activeInteraction:o});let s=te(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=xl(e);s.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:t,activeInteraction:o}},wn=(e,r,n)=>{!(r?.source===Br||r?.source===cr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},lc=({state:e})=>(Pe({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:Hr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),St=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Uh=({state:e})=>{let r=e.global.autoMode;return Pe({state:e})&&!r||(r?St({state:e}):lc({state:e})),e},cc=({state:e})=>(Pe({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),ur=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Bh=({state:e})=>{let r=Wl({state:e});return Pe({state:e})&&!r||(r?ur({state:e}):cc({state:e})),e},In=({state:e})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),Be(e,"showDialogueUI",void 0),e),uc=({state:e})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),Be(e,"hideDialogueUI",void 0),e),Yh=({state:e})=>(Hl({state:e})?In({state:e}):uc({state:e}),e),pr=(e,r,n)=>(To(e,r,n),zl(e),e.global.pendingEffects.push({name:"render"}),e),Rt=(e,r,n,o)=>{let a=To(e,r,n);return e.global.pendingEffects.push({name:"render"}),Be(e,o,{value:a}),e},zh=({state:e},r)=>pr(e,"dialogueTextSpeed",r?.value),Gh=({state:e},r)=>pr(e,"autoForwardDelay",r?.value),Xh=({state:e},r)=>pr(e,"autoForwardSpeed",r?.value),Wh=({state:e},r)=>pr(e,"skipUnseenText",r?.value),Hh=({state:e},r)=>pr(e,"skipTransitionsAndAnimations",r?.value),Kh=({state:e},r)=>pr(e,"soundVolume",r?.value),Jh=({state:e},r)=>pr(e,"musicVolume",r?.value),Qh=({state:e},r)=>pr(e,"muteAll",r?.value),Zh=({state:e},r)=>Rt(e,"saveLoadPagination",r?.value,"setSaveLoadPagination"),eg=({state:e})=>{let r=ir(e,"saveLoadPagination")+1;return Rt(e,"saveLoadPagination",r,"incrementSaveLoadPagination"),e},rg=({state:e})=>{let r=ir(e,"saveLoadPagination")-1;return Rt(e,"saveLoadPagination",r,"decrementSaveLoadPagination"),e},tg=({state:e},r)=>Rt(e,"menuPage",r?.value,"setMenuPage"),ng=({state:e},r)=>Rt(e,"menuEntryPoint",r?.value,"setMenuEntryPoint"),sg=({state:e})=>(e.global.pendingEffects=[],e),og=({state:e},r)=>(e.global.pendingEffects.push(r),e),ig=({state:e},r)=>{if(te(e))return e;let n=r?.resourceId;return El(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},ag=({state:e},r)=>{if(te(e))return e;let n=r?.resourceId,o=El(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=r?.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 t=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:t,target:o.target,completed:t>=o.target}}),e},pc=(e,{sectionId:r,resetStoryState:n=!1,screen:o})=>{let a=!!ql(o),t=we({state:e},{sectionId:r});if(!t)return console.warn(`Section not found: ${r}`),e;let s=t.lines?.[0];if(!s)return console.warn(`Section ${r} has no lines`),e;if(n&&!Jy(e,{queueRender:!a}))return e;let i=Pe({state:e});n&&e.global.skipMode&&ur({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let c=Wr(l),p=c.read;n||xr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Sr(l,{compatibilityAnchor:!0}),c.read={sectionId:r,lineId:s.id},n?l.rollback=vt({pointer:c.read}):Mo(e,{sectionId:r,lineId:s.id})}let{activeInteraction:u}=Et(e,l?.pointers?.read,{screenTransition:o});return wn(e,i,u),e},lg=({state:e},r)=>{if(te(e))throw new Error("Cannot reset the story while a scene replay is active");return pc(e,{sectionId:r?.sectionId,resetStoryState:!0,screen:r?.screen})},fc=e=>(e.global.accountViewedRegistry=yy(e.global.accountViewedRegistry),e.global.accountViewedRegistry),vn=(e,r)=>{!Array.isArray(r)||r.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:r.map(n=>({scope:n.scope,path:n.path,op:n.op,value:D(n.value)}))}})},dc=(e,r)=>{vn(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(r?.sections)?r.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(r?.resources)?r.resources:[]}}])},cg=(e,r,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=V(r)?r:{};Array.isArray(a.sections)||(a.sections=[]);let t=a.sections.find(s=>s.sectionId===n);if(t){if(t.lastLineId===void 0)return!1;let s=we({state:e},{sectionId:n});if(s?.lines){let i=s.lines.findIndex(u=>u.id===t.lastLineId),l=s.lines.findIndex(u=>u.id===o);if(i===-1||l>i)return t.lastLineId===o?!1:(t.lastLineId=o,!0)}else return t.lastLineId===o?!1:(t.lastLineId=o,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:o}),!0},xr=(e,r)=>{if(te(e)||e.global.accountViewedRegistry===void 0)return;cg(e,fc(e),r)&&dc(e,{sections:[{sectionId:r.sectionId,lastLineId:r.lineId}],resources:[]})},ug=({state:e},r)=>(xr(e,r),e.global.pendingEffects.push({name:"render"}),e),pg=({state:e},r)=>{if(te(e))return e;let{resourceId:n}=r;if(e.global.accountViewedRegistry!==void 0){let o=fc(e);o.resources.find(t=>t.resourceId===n)||(o.resources.push({resourceId:n}),dc(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Ye=(e,r,n)=>{if(!V(r))throw new Error(`${e} payload must be an object`);Object.keys(r).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},xo=(e,r,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${r}`)},An=(e,r)=>{let n=e.global.imageGalleryNavigation;n.groupId===r.groupId&&n.variantId===r.variantId&&n.pageIndex===r.pageIndex||(e.global.imageGalleryNavigation=r,e.global.pendingEffects.push({name:"render"}))},fg=({state:e},r)=>{let n="showImageGalleryVariant";Ye(n,r,ly),xo(n,"groupId",r.groupId),Object.prototype.hasOwnProperty.call(r,"variantId")&&xo(n,"variantId",r.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let a=o.groups.findIndex(i=>i.id===r.groupId),t=o.groups[a];if(!t)return e;let s=r.variantId===void 0?t.variants[0]:t.variants.find(i=>i.id===r.variantId);return!s||It(e,s)||An(e,{groupId:t.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},mc=(e,r,n,o)=>{Ye(o,r,Ro);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let t=e.global.imageGalleryNavigation;if(typeof t.groupId!="string"||typeof t.variantId!="string")return e;let s=a.groups.find(u=>u.id===t.groupId),i=s?.variants.findIndex(u=>u.id===t.variantId);if(!s||i===void 0||i<0)return e;let l=ko(e,s.variants,i,n);return l&&An(e,{...t,variantId:l.id}),e},dg=({state:e},r)=>mc(e,r,-1,"moveToPreviousImageGalleryVariant"),mg=({state:e},r)=>mc(e,r,1,"moveToNextImageGalleryVariant"),yg=({state:e},r)=>{if(Ye("clearImageGallerySelection",r,Ro),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return An(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},yc=(e,r)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=Fo(n);if(r>=o)return e;let a=e.global.imageGalleryNavigation,t=Uo(n,a);return r===t||An(e,{groupId:null,variantId:null,pageIndex:r}),e},hg=({state:e},r)=>{if(Ye("moveToImageGalleryPage",r,cy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return yc(e,r.pageIndex)},hc=(e,r,n,o)=>{Ye(o,r,Ro);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Uo(a,e.global.imageGalleryNavigation)+n;return s<0?e:yc(e,s)},gg=({state:e},r)=>hc(e,r,1,"moveToNextImageGalleryPage"),bg=({state:e},r)=>hc(e,r,-1,"moveToPreviousImageGalleryPage"),Qe=(e,r,n)=>{if(!V(r))throw new Error(`${e} payload must be an object`);Object.keys(r).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},wg=(e,r)=>{if(typeof r!="string"||r.length===0)throw new Error(`${e} requires a non-empty trackId`)},Ve=e=>{e.global.pendingEffects.push({name:"render"})},gc=(e,r)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,t=o.trackId===r.id,s=o.bgmPlayback;a||(s={commandId:hn(e),operation:"pause"});let i=kt(e,"play",0),l=n.tracks.indexOf(r),u=t?o.durationMs:null;e.global.musicRoomPlayer={trackId:r.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:u===null?"loading":"ready",positionMs:0,durationMs:u,playback:i,seekFallback:null,bgmPlayback:s},Ve(e)},Ig=({state:e},r)=>{let n="playMusicRoomTrack";Qe(n,r,uy),wg(n,r.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(t=>t.id===r.trackId);return!a||Bo(e,a)||gc(e,a),e},vg=({state:e},r)=>{Qe("playMusicRoom",r,Yr);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",t=o.readiness==="error",s=o.status==="paused"&&!t?"resume":"play",i=a?0:o.positionMs;return o.playback=kt(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,t&&(o.readiness=o.durationMs===null?"loading":"ready"),Ve(e),e},Ag=({state:e},r)=>{Qe("pauseMusicRoom",r,Yr);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=kt(e,"pause"),o.seekFallback=null,o.status="paused",Ve(e)),e},kg=({state:e},r)=>{Qe("stopMusicRoom",r,Yr);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=kt(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,Ve(e)),e},Pg=({state:e},r)=>{if(Qe("seekMusicRoom",r,py),typeof r.positionMs!="number"||!Number.isFinite(r.positionMs)||r.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||r.positionMs>o.durationMs)return e;let a=kt(e,"seek",r.positionMs);return o.seekFallback={commandId:a.commandId,status:o.status,positionMs:o.positionMs},o.playback=a,o.positionMs=r.positionMs,r.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),Ve(e),e},bc=(e,r,n,o)=>{Qe(o,r,Yr);let a=e.projectData?.resources?.musicRoom,t=e.global.musicRoomPlayer;if(!a||t.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===t.trackId);if(s<0)return e;let i=Po(e,a.tracks,s,n);return i&&gc(e,i),e},xg=({state:e},r)=>bc(e,r,-1,"playPreviousMusicRoomTrack"),Eg=({state:e},r)=>bc(e,r,1,"playNextMusicRoomTrack"),Sg=({state:e},r)=>{Qe("clearMusicRoomSelection",r,Yr);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,t={commandId:hn(e),operation:"resume"};return e.global.musicRoomPlayer={...yn({bgmPlayback:t}),pageIndex:a},Ve(e),e},wc=(e,r)=>{let n=e.projectData?.resources?.musicRoom;if(!n||r>=Yo(n))return e;let o=e.global.musicRoomPlayer,a=zo(n,o);return r===a||(o.pageIndex=r,Ve(e)),e},Rg=({state:e},r)=>{if(Qe("moveToMusicRoomPage",r,fy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return wc(e,r.pageIndex)},Ic=(e,r,n,o)=>{Qe(o,r,Yr);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let t=zo(a,e.global.musicRoomPlayer)+n;return t<0?e:wc(e,t)},Og=({state:e},r)=>Ic(e,r,1,"moveToNextMusicRoomPage"),Cg=({state:e},r)=>Ic(e,r,-1,"moveToPreviousMusicRoomPage"),kr=e=>{let r=te(e);if(!r)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=D(r.sceneReplay.returnState),o=r.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),Wy(e,n),e.global.pendingEffects.push({name:"render"}),!0},$g=({state:e},r)=>{let n="startSceneReplay";if(Ye(n,r,dy),xo(n,"sceneId",r.sceneId),te(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===r.sceneId);if(!a||!ec(e,a.sceneId))return e;let t=e.projectData.story.scenes[a.sceneId],s=t?.initialSectionId,i=t?.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 u=Gy(e);Xy(e);let c=Lo({pointer:{sceneId:a.sceneId,sectionId:s,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:u}});return Yl(e,c),e.contexts.push(c),Et(e,c.pointers.read),e},vc=({state:e},r)=>{Ye("finishSceneReplay",r,Oo);let o=te(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Xr(e)?.rollback?.isRestoring===!0)return e;let t=Re({state:e})?.pointer,{sceneId:s}=Er(e.projectData,t?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=hy(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),vn(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},_g=({state:e},r)=>(Ye("exitSceneReplay",r,Oo),kr(e),e),Ac=(e,r)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||r>=Go(n))return e;let o=Xo(n,e.global.sceneReplayNavigation);return r===o||(e.global.sceneReplayNavigation.pageIndex=r,e.global.pendingEffects.push({name:"render"})),e},jg=({state:e},r)=>{if(Ye("moveToSceneReplayPage",r,my),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Ac(e,r.pageIndex)},kc=(e,r,n,o)=>{Ye(o,r,Oo);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let t=Xo(a,e.global.sceneReplayNavigation)+n;return t<0?e:Ac(e,t)},Ng=({state:e},r)=>kc(e,r,1,"moveToNextSceneReplayPage"),Dg=({state:e},r)=>kc(e,r,-1,"moveToPreviousSceneReplayPage"),kn=(e,r)=>{let n=e.global.musicRoomPlayer;return!V(r)||r.id!==iy||n.trackId===null||!n.playback||r.commandId!==n.playback.commandId?null:n},Ko=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,Pc=(e,r,n,{readiness:o=r.readiness}={})=>((r.readiness!==o||r.positionMs!==n.positionMs||r.durationMs!==n.durationMs||r.seekFallback!==null)&&(r.readiness=o,r.positionMs=n.positionMs,r.durationMs=n.durationMs,r.seekFallback=null,Ve(e)),e),Tg=({state:e},r)=>{let n=kn(e,r);return!n||n.readiness!=="loading"||!Ko(r)?e:Pc(e,n,r,{readiness:"ready"})},Lg=({state:e},r)=>{let n=kn(e,r);return!n||n.readiness!=="ready"||!Ko(r)||n.status==="stopped"&&r.positionMs!==0||n.status==="ended"&&r.positionMs!==r.durationMs?e:Pc(e,n,r)},Mg=({state:e},r)=>{let n=kn(e,r);return!n||n.readiness!=="ready"||n.status!=="playing"||!Ko(r)||r.positionMs!==r.durationMs||(n.status="ended",n.positionMs=r.positionMs,n.durationMs=r.durationMs,n.seekFallback=null,Ve(e)),e},qg=({state:e},r)=>{let n=kn(e,r);if(!n||typeof r.errorCode!="string"||!ay.has(r.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(r.errorCode==="invalid-position"){let o=n.seekFallback;if(n.playback.operation!=="seek"||o?.commandId!==r.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&&Ve(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,Ve(e),e},xc=({state:e},r)=>{let n=Iy(r.manual),{auto:o,applyMode:a}=r,t=e.global.nextLineConfig.auto?.enabled,s=e.global.nextLineConfig?.applyMode,i=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;n&&o?(e.global.nextLineConfig={manual:n,auto:o},a!==void 0?e.global.nextLineConfig.applyMode=a:s!==void 0&&(e.global.nextLineConfig.applyMode=s)):(n&&(e.global.nextLineConfig.manual=n),o&&(e.global.nextLineConfig.auto=o),a!==void 0&&(e.global.nextLineConfig.applyMode=a));let l=e.global.nextLineConfig.auto?.enabled,u=Pe({state:e});return!i&&!u&&l===!0&&!t?e.global.nextLineConfig.auto?.trigger==="fromStart"?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}}):e.global.isLineCompleted&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}}):!i&&l===!1&&t&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.pendingEffects.push({name:"render"}),Be(e,"setNextLineConfig",r),e},Vg=({state:e},r)=>{if(te(e))throw new Error("Cannot save while a scene replay is active");let n=r?.slotId;if(n==null||n==="")throw new Error("saveSlot requires slotId");let{thumbnailImage:o}=r,a=r?.savedAt,t=Pt(n),s=D(e.contexts);s?.forEach(u=>{Wr(u),Gl(u.rollback),ky(u.rollback)});let i={contexts:s},l={formatVersion:Pl,slotId:Cl(n),savedAt:typeof a=="number"?a:Date.now(),image:o,state:i};return e.global.saveSlots[t]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},Fg=({state:e},r)=>{if(te(e))throw new Error("Cannot load while a scene replay is active");let n=r?.slotId;if(n==null||n==="")throw new Error("loadSlot requires slotId");let o=Pt(n),a=e.global.saveSlots[o];if(a){let t=Ny(a,e.projectData);e.contexts=t.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=At(),e.global.overlayStack=[],e.global.isLineCompleted=!0,zr(e),Gr(e),_o(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},Ug=({state:e},r)=>{if(te(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=r;Ol(n),at(n),lt(n),ct(n),br(n?.resources?.variables??{}),Js(n),e.projectData=n,e.global.imageGalleryNavigation=So(),e.global.sceneReplayNavigation=Co(),_o(e);let o=n?.resources?.variables??{},{contextVariableDefaultValues:a,globalVariablesDefaultValues:t}=Kt(n??{});return Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...t,...Tr(e.global.variables,o)}),e.contexts?.forEach(s=>{Object.prototype.hasOwnProperty.call(s??{},"variables")&&(s.variables={...a,...Tr(s.variables,o)})}),zr(e),Gr(e),e.global.pendingEffects.push({name:"render"}),e},Bg=({state:e},r)=>{let{l10nId:n,projectData:o}=r??{};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,To(e,"localizationPackageId",n),zl(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Pe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Hr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},Yg=({state:e},r)=>{let{sectionId:n,lineId:o}=r;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 t=n||a.pointers.read?.sectionId;if(n&&!we({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=we({state:e},{sectionId:t});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${t} has no lines`),e;if(!s.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${t}`),e;let l=Pe({state:e}),u=Wr(a);u.read={sectionId:t,lineId:o};let{activeInteraction:c}=Et(e,u.read);return wn(e,l,c),e},zg=({state:e},r)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return In({state:e}),e;let n=Pe({state:e});if(n?.source===Br&&r?.bypassChoice!==!0||n?.source===cr&&r?._interactionSource!==cr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,te(e)?.sceneReplay.exitOnLineCompleted)return kr(e),e;let m=Re({state:e})?.pointer,d=m?.sectionId,f=m?.lineId;d&&f&&xr(e,{sectionId:d,lineId:f}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Hr({state:e})}});let y=e.global.nextLineConfig;return y?.auto?.enabled&&!n&&y.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:y.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(te(e)?.sceneReplay.finishOnNextAdvance)return kr(e),e;let a=Re({state:e})?.pointer,t=a?.sectionId,s=we({state:e},{sectionId:t}),i=e.contexts[e.contexts.length-1],l=s?.lines||[],c=l.findIndex(p=>p.id===a?.lineId)+1;if(c<l.length){let p=l[c],m=!ir(e,"skipUnseenText");if(e.global.skipMode&&m&&!Vo({state:e},{sectionId:t,lineId:p.id}))return ur({state:e}),e;if(i&&!i.rollback&&Sr(i,{compatibilityAnchor:!0}),i){let f=Wr(i),y=f.read?.lineId;y&&t&&xr(e,{sectionId:t,lineId:y}),f.read={sectionId:t,lineId:p.id}}Mo(e,{sectionId:t,lineId:p.id}),$o(e);let{activeInteraction:d}=Et(e,{sectionId:t,lineId:p.id});wn(e,n,d)}else{if(te(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),kr(e),e;e.global.autoMode&&St({state:e}),e.global.skipMode&&ur({state:e})}return e},Gg=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,te(e)?.sceneReplay.exitOnLineCompleted)return kr(e),e;let n=Pe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Hr({state:e})}});let o=Re({state:e})?.pointer,a=o?.sectionId,t=o?.lineId;a&&t&&xr(e,{sectionId:a,lineId:t});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},Xg=({state:e},r)=>pc(e,{sectionId:r?.sectionId,screen:r?.screen}),Wg=({state:e},r)=>{let n=r?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!n)return In({state:e}),e;let o=Pe({state:e});if(o?.source===Br&&r?.bypassChoice!==!0||o?.source===cr&&r?._interactionSource!==cr||o&&o.source!==Br&&o.source!==cr)return e;let a=te(e);if(a?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(kr(e),e):(a.sceneReplay.exitOnLineCompleted=!0,e);let t=Re({state:e})?.pointer,s=t?.sectionId,i=we({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],u=i?.lines||[],p=u.findIndex(m=>m.id===t?.lineId)+1;if(p<u.length){let m=u[p],d=!ir(e,"skipUnseenText");if(e.global.skipMode&&d&&!Vo({state:e},{sectionId:s,lineId:m.id})&&(ur({state:e}),!n))return e;if(l&&!l.rollback&&Sr(l,{compatibilityAnchor:!0}),l){let y=Wr(l),g=y.read?.lineId;g&&s&&xr(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:m.id}}Mo(e,{sectionId:s,lineId:m.id}),$o(e);let{activeInteraction:f}=Et(e,{sectionId:s,lineId:m.id});wn(e,o,f)}else{if(te(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),kr(e),e;e.global.autoMode&&St({state:e}),e.global.skipMode&&ur({state:e}),e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))}return e},Jo=(e,r={})=>{let n=xt({state:e});return!n||r.formKey&&r.formKey!==n.key||r.formId&&r.formId!==n.id?null:n},Hg=(e,r)=>{if(!r.variableId)throw new Error(`form field "${r.id}" requires variableId`);let n=e.projectData.resources?.variables?.[r.variableId],o=n?.scope,a=n?.type;if(De(n))throw new Error(`Cannot update computed variable: ${r.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${r.variableId}`);if(pt(o,r.variableId),Jt(a,"set",r.variableId),te(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${r.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},Kg=(e,r)=>({id:e.id,key:e.key,valid:!0,values:D(r),fields:D(e.fields),fieldList:D(e.fieldList)}),Jg=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let r=Re({state:e})?.pointer,n=r?.sectionId,o=r?.lineId;n&&o&&xr(e,{sectionId:n,lineId:o})},Qg=({state:e},r={})=>{let n=Jo(e,r),o=r.field;if(!n?.fields?.[o])return e;let a=Fl(e,n.key),t=dn(r.value),s=n.fields[o],i=jo(s,t);return a.values[o]=t,a.touched[o]=!0,i?a.errors[o]=i:delete a.errors[o],e.global.pendingEffects.push({name:"render"}),e},Zg=({state:e},r={})=>{let n=Jo(e,r);if(!n)return{submitted:!1,valid:!1,reason:"inactive"};let o=Fl(e,n.key);o.submitted=!0;let a={},t={};if(Object.entries(n.fields).forEach(([p,m])=>{let d=Object.prototype.hasOwnProperty.call(o.values,p)?o.values[p]:m.value,f=jo(m,d);o.touched[p]=!0,f&&(t[p]=f),a[p]=Vl(m,d)}),o.errors=t,Object.keys(t).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:D(t),form:{id:n.id,key:n.key,values:D(a)}};let s=e.contexts[e.contexts.length-1];if(s?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let i=!1,l=[],u=[];Object.entries(n.fields).forEach(([p,m])=>{let{scope:d}=Hg(e,m),f=d==="context"?s.variables:e.global.variables,y=a[p];f[m.variableId]=Qt(f[m.variableId],"set",y),d==="context"&&(i=!0,u.push({variableId:m.variableId,op:"set",value:y})),(d==="device"||d==="account")&&l.push({scope:d,path:`variables.${m.variableId}`,op:"set",value:D(f[m.variableId])})}),i&&Be(e,"updateVariable",{id:"submitForm",operations:u}),vn(e,l);let c=Kg(n,a);return Jg(e),delete e.global.formDrafts[n.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:c}},eb=({state:e},r={})=>{let n=Jo(e,r);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:D(n.values),fields:D(n.fields),fieldList:D(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},rb=({state:e},r)=>{let{id:n,operations:o=[]}=r;if(!n)throw new Error("updateVariable requires an id field");if(typeof n!="string"||!/^[a-zA-Z0-9]+$/.test(n))throw new Error(`updateVariable id must be alphanumeric, got: "${n}"`);let a=e.contexts[e.contexts.length-1];if(a?.rollback?.isRestoring)return e;let t=!1,s=[],i=[];return o.forEach(({variableId:l,op:u,value:c,roundTo:p})=>{let m=e.projectData.resources?.variables?.[l],d=m?.scope,f=m?.type;if(De(m))throw new Error(`Cannot update computed variable: ${l}`);if(m?.readonly===!0)throw new Error(`Cannot update readonly variable: ${l}`);if(pt(d,l),Jt(f,u,l),Bs(f,u,c,l,{roundTo:p}),te(e)&&d!=="context")throw new Error(`Cannot update ${d}-scoped variable "${l}" while a scene replay is active`);let y=d==="context"?a.variables:e.global.variables;if(d==="context"){t=!0;let g={variableId:l,op:u,value:c};p!==void 0&&(g.roundTo=p),i.push(g)}y[l]=Qt(y[l],u,c,{roundTo:p}),(d==="device"||d==="account")&&s.push({scope:d,path:`variables.${l}`,op:"set",value:D(y[l])})}),t&&Be(e,"updateVariable",{id:n,operations:i}),vn(e,s),e.global.pendingEffects.push({name:"render"}),e},kl=e=>(r,n)=>e({state:r},n),tb=e=>({variables:ut({variables:{...e.global?.variables??{},...Xr(e)?.variables??{}},runtime:Ir(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Ir(e)}),nb=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")},sb=(e,r,n)=>{if(!V(e))throw new Error(`conditional branch at index ${r} must be an object`);if(!V(e.actions))throw new Error(`conditional branch at index ${r} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&r!==n-1)throw new Error("conditional else branch must be the last branch")},ob=(e,r)=>{nb(r);for(let n=0;n<r.branches.length;n+=1){let o=r.branches[n];if(sb(o,n,r.branches.length),!(Object.prototype.hasOwnProperty.call(o,"when")&&!it(o.when,tb(e)))){Object.entries(o.actions).forEach(([t,s])=>{Ec(e,t,s)});return}}},ib={conditional:{replayLine:ob},updateVariable:{recordSources:[No],replayLine:vl,replayRecorded:vl,persistInSaveSlot:!0},setNextLineConfig:{replayLine:kl(xc)},finishSceneReplay:{replayLine:kl(vc)}},Pn=e=>ib[e]??null,ab=e=>Pn(e)?.persistInSaveSlot===!0,lb=(e,r)=>{let n=Pn(e)?.recordSources;return Array.isArray(n)&&n.includes(r)},cb=(e,r,n)=>{Pn(r)?.replayRecorded?.(e,n)},Ec=(e,r,n)=>{Pn(r)?.replayLine?.(e,n)},ub=e=>e?.returnable!==!1,Sc=(e,r)=>{if(r>=0)return e.currentIndex+r;let n=Math.abs(r);for(let o=e.currentIndex-1;o>=0;o-=1)if(ub(e.timeline[o])&&(n-=1,n===0))return o;return-1},Rc=({state:e},r)=>{let{offset:n}=r;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 t=Sc(a,n);if(t<0||t>=a.timeline.length)return null;let s=a.timeline[t];return{sectionId:s.sectionId,lineId:s.lineId}},Oc=({state:e})=>Rc({state:e},{offset:-1})!==null,pb=({state:e},r)=>{let{offset:n=-1}=r;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=Sr(o,{compatibilityAnchor:!o.rollback}),t=Sc(a,n);return t<0||t>=a.timeline.length?e:Xl(e,t)},fb=({state:e},r)=>{let{sectionId:n,lineId:o}=r,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let t=Sr(a,{compatibilityAnchor:!a.rollback}),i=t.timeline.slice(0,t.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===t.currentIndex?e:Xl(e,i)},Cc=e=>{let r=ah(e);return Gi(r,{selectPendingEffects:ch,selectSkipMode:Wl,selectAutoMode:uh,selectIsChoiceVisible:nc,selectIsFormVisible:fh,selectActiveInteraction:Pe,selectActiveForm:xt,selectDialogueUIHidden:Hl,selectDialogueHistory:Kl,selectConfirmDialog:ph,selectIsLineAccountViewed:Vo,selectIsResourceAccountViewed:mh,selectImageGalleryConfig:yh,selectImageGallery:Jl,selectMusicRoomConfig:gh,selectMusicRoom:Zl,selectSceneReplayConfig:bh,selectSceneReplay:rc,selectIsSceneReplayActive:wh,selectActiveSceneReplayEntry:Ih,selectNextLineConfig:vh,selectSystemState:Ah,selectAchievements:kh,selectAchievement:Ph,selectSaveSlotMap:sc,selectSaveSlots:$h,selectSaveSlot:xh,selectLocalizationPackages:oc,selectRuntime:Wo,selectRuntimeValue:Eh,selectAllVariables:gn,selectCurrentPointer:Re,selectSection:we,selectCurrentLine:bn,selectPresentationState:ic,selectAutoForwardTimerDelay:Hr,selectPresentationChanges:Rh,selectSectionLineChanges:Ch,selectSaveSlotPage:Ho,selectCurrentPageSlots:_h,selectRenderState:Nh,selectOverlayStack:lh,selectLineIdByOffset:Rc,selectCanRollback:Oc,selectRollbackCursor:Zy,startAutoMode:lc,stopAutoMode:St,toggleAutoMode:Uh,startSkipMode:cc,stopSkipMode:ur,toggleSkipMode:Bh,showDialogueUI:In,hideDialogueUI:uc,toggleDialogueUI:Yh,setDialogueTextSpeed:zh,setAutoForwardDelay:Gh,setAutoForwardSpeed:Xh,setSkipUnseenText:Wh,setSkipTransitionsAndAnimations:Hh,setSoundVolume:Kh,setMusicVolume:Jh,setMuteAll:Qh,setSaveLoadPagination:Zh,incrementSaveLoadPagination:eg,decrementSaveLoadPagination:rg,setMenuPage:tg,setMenuEntryPoint:ng,showConfirmDialog:Dh,hideConfirmDialog:Th,resetStoryAtSection:lg,clearPendingEffects:sg,appendPendingEffect:og,completeAchievement:ig,setAchievementProgress:ag,beginRollbackActionBatch:nh,endRollbackActionBatch:sh,markRollbackCheckpointTransient:eh,markSavedRollbackCheckpointTransient:rh,addViewedLine:ug,addViewedResource:pg,showImageGalleryVariant:fg,moveToPreviousImageGalleryVariant:dg,moveToNextImageGalleryVariant:mg,clearImageGallerySelection:yg,moveToImageGalleryPage:hg,moveToNextImageGalleryPage:gg,moveToPreviousImageGalleryPage:bg,playMusicRoomTrack:Ig,playMusicRoom:vg,pauseMusicRoom:Ag,stopMusicRoom:kg,seekMusicRoom:Pg,playPreviousMusicRoomTrack:xg,playNextMusicRoomTrack:Eg,clearMusicRoomSelection:Sg,moveToMusicRoomPage:Rg,moveToNextMusicRoomPage:Og,moveToPreviousMusicRoomPage:Cg,musicRoomSoundReady:Tg,musicRoomSoundProgress:Lg,musicRoomSoundComplete:Mg,musicRoomSoundError:qg,startSceneReplay:$g,finishSceneReplay:vc,exitSceneReplay:_g,moveToSceneReplayPage:jg,moveToNextSceneReplayPage:Ng,moveToPreviousSceneReplayPage:Dg,setNextLineConfig:xc,saveSlot:Vg,loadSlot:Fg,updateProjectData:Ug,updateLocalizationPackage:Bg,sectionTransition:Xg,jumpToLine:Yg,nextLine:zg,markLineCompleted:Gg,rollbackToLine:fb,rollbackByOffset:pb,pushOverlay:Lh,popOverlay:Mh,replaceLastOverlay:qh,clearOverlays:Vh,updateFormField:Qg,submitForm:Zg,cancelForm:eb,updateVariable:rb,nextLineFromSystem:Wg},{transformActionFirstArgument:o=>({state:o}),transformSelectorFirstArgument:o=>({state:o})})};var db="route-engine",mb="projectPersistence";var _c=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),ae=e=>Object.prototype.toString.call(e)==="[object Object]",$c="variables.",yb=(e={})=>{let r=ae(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!ae(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(r.resources)?r.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!ae(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},hb=(e={})=>{let r=ae(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!ae(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(r.resources)?r.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!ae(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},gb=(e,r)=>{let n=hb(e),o=yb(r),a=n.sections.map(s=>({...s})),t=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=>{t.find(l=>l.resourceId===s.resourceId)||t.push({...s})}),{sections:a,resources:t}},bb=(e={})=>{let r=ae(e)?e:{},n=Array.isArray(r.sceneIds)?r.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},wb=(e,r)=>{let n=bb(e),o=ae(r)&&Array.isArray(r.sceneIds)?r.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},jc=(e={})=>{let r=ae(e)?e:{};return{saveSlots:ae(r.saveSlots)?r.saveSlots:{},globalDeviceVariables:ae(r.globalDeviceVariables)?r.globalDeviceVariables:{},globalAccountVariables:ae(r.globalAccountVariables)?r.globalAccountVariables:{},globalRuntime:ae(r.globalRuntime)?r.globalRuntime:{},accountViewedRegistry:ae(r.accountViewedRegistry)?r.accountViewedRegistry:{},accountReplayRegistry:ae(r.accountReplayRegistry)?r.accountReplayRegistry:{}}},Ib=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((r,n)=>{if(!ae(r))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=r.path?.startsWith($c)?r.path.slice($c.length):null;if(o!==null){if(!["device","account"].includes(r.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${r.scope}" at updates[${n}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${r.path}" at updates[${n}].`);if(r.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${r.op}" at updates[${n}].`);return{scope:r.scope,path:r.path,op:r.op,value:r.value,variableId:o}}if(r.path==="viewedRegistry"){if(r.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${r.scope}" at updates[${n}].`);if(r.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${r.op}" at updates[${n}].`);return r}if(r.path==="replayRegistry"){if(r.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${r.scope}" at updates[${n}].`);if(r.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${r.op}" at updates[${n}].`);if(!ae(r.value)||!Array.isArray(r.value.sceneIds)||r.value.sceneIds.length===0||r.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...r,value:{sceneIds:[...new Set(r.value.sceneIds)]}}}throw typeof r.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${r.path}" at updates[${n}].`)})},vb=(e,r)=>{let n={};return Ib(r).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=gb(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=wb(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},Qo=e=>{if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null},Ab=e=>{let r=Qo(e);if(!r)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return r},kb=e=>{let r=e??globalThis.indexedDB;if(!r)throw new Error("IndexedDB is not available in this environment.");return r},Pb=({indexedDB:e,databaseName:r,objectStoreName:n})=>new Promise((o,a)=>{let t=e.open(r,1);t.onupgradeneeded=()=>{let s=t.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},t.onsuccess=()=>{o(t.result)},t.onerror=()=>{a(t.error??new Error(`Failed to open IndexedDB database "${r}".`))}}),xb=async({databasePromise:e,objectStoreName:r,namespace:n})=>{let o=await e;return new Promise((a,t)=>{let l=o.transaction(r,"readonly").objectStore(r).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{t(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},Ot=async({databasePromise:e,objectStoreName:r,namespace:n,patch:o})=>{let a=await e;return new Promise((t,s)=>{let i=a.transaction(r,"readwrite"),l=i.objectStore(r),u=l.get(n),c=!1,p=d=>{c||(c=!0,s(d))},m=()=>{c||(c=!0,t())};u.onerror=()=>{p(u.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},u.onsuccess=()=>{let d=jc(u.result),f=typeof o=="function"?o(d):o,y={namespace:n,version:1,..._c(),...d,...f},g=l.put(y);g.onerror=()=>{p(g.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}".`))}})},Eb=async({databasePromise:e,objectStoreName:r,namespace:n})=>{let o=await e;return new Promise((a,t)=>{let s=o.transaction(r,"readwrite"),l=s.objectStore(r).delete(n),u=!1,c=m=>{u||(u=!0,t(m))},p=()=>{u||(u=!0,a())};l.onerror=()=>{c(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{c(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{c(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},Zo=(e={})=>{let{indexedDB:r,databaseName:n=db,objectStoreName:o=mb,namespace:a}=e,t=kb(r),s=Ab(a),i=Pb({indexedDB:t,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await xb({databasePromise:i,objectStoreName:o,namespace:s});return{..._c(),...jc(l)}},clear:async()=>Eb({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>Ot({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:ae(l)?l:{}}}),saveGlobalDeviceVariables:async l=>Ot({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:ae(l)?l:{}}}),saveGlobalAccountVariables:async l=>Ot({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:ae(l)?l:{}}}),saveGlobalRuntime:async l=>Ot({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:ae(l)?l:{}}}),applyScopedDataUpdates:async l=>Ot({databasePromise:i,objectStoreName:o,namespace:s,patch:u=>vb(u,l)})}},Sb=Zo;var Fc=Uc;var Rb={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"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ze=Object.prototype.hasOwnProperty,Ob={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 $e(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,u=s;if(e!==null){let p={instancePath:r,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};t===null?t=[p]:t.push(p),s++}var c=u===s;if(l=l||c,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};t===null?t=[d]:t.push(d),s++}if(e.y===void 0){let d={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};t===null?t=[d]:t.push(d),s++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let f={instancePath:r,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};t===null?t=[f]:t.push(f),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:r+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:r+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let f={instancePath:r+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let f={instancePath:r+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[f]:t.push(f),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let f={instancePath:r+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Ob.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};t===null?t=[f]:t.push(f),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:r+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}}else{let d={instancePath:r,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}var c=p===s;l=l||c}if(l)s=i,t!==null&&(i?t.length=i:t=null);else{let p={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[p]:t.push(p),s++}return $e.errors=t,s===0}var Cb={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function En(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=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:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.continuity!==void 0){let i=e.continuity;if(typeof i!="string"){let l={instancePath:r+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="render"||i==="persistent")){let l={instancePath:r+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Cb.properties.continuity.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:r+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return En.errors=t,s===0}function J(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}e.playback!==void 0&&(En(e.playback,{instancePath:r+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(t=t===null?En.errors:t.concat(En.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return J.errors=t,s===0}function Sn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ze.call(Rb.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let i={instancePath:r+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let i={instancePath:r+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let i={instancePath:r+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let i={instancePath:r+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:r+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:r+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}e.blur!==void 0&&($e(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(t=t===null?$e.errors:t.concat($e.errors),s=t.length)),e.animations!==void 0&&(J(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Sn.errors=t,s===0}function Uc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Sn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Sn.errors:t.concat(Sn.errors),s=t.length),Uc.errors=t,s===0}var Bc=Yc;var $b={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},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}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1},Tc={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}},required:["id","resourceId"],additionalProperties:!1},Ce=Dc().default;function Oe(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[i]:t.push(i),s++}if(e.resourceId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!Ze.call(Tc.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Ce(i)<1){let l={instancePath:r+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Ce(i)<1){let l={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Tc.properties.endAt.type},message:"must be number,null"};t===null?t=[l]:t.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Oe.errors=t,s===0}function Rn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.resourceId===void 0&&(d="resourceId")||e.sounds===void 0&&(d="sounds")){let f={};t===null?t=[f]:t.push(f),s++}}var u=l===s;if(u){let d={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[d]:t.push(d),s++}else s=i,t!==null&&(i?t.length=i:t=null);let c=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.startDelayMs===void 0&&(d="startDelayMs")||e.sounds===void 0&&(d="sounds")){let f={};t===null?t=[f]:t.push(f),s++}}var m=p===s;if(m){let d={instancePath:r,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[d]:t.push(d),s++}else s=c,t!==null&&(c?t.length=c:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let d in e)if(!(d==="sounds"||d==="resourceId"||d==="loop"||d==="interruption"||d==="volume"||d==="muted"||d==="pan"||d==="startDelayMs")){let f={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};t===null?t=[f]:t.push(f),s++}if(e.sounds!==void 0){let d=e.sounds;if(Array.isArray(d)){let f=d.length;for(let y=0;y<f;y++)Oe(d[y],{instancePath:r+"/sounds/"+y,parentData:d,parentDataProperty:y,rootData:a})||(t=t===null?Oe.errors:t.concat(Oe.errors),s=t.length)}else{let f={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[f]:t.push(f),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let d={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[d]:t.push(d),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let d={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}if(e.interruption!==void 0){let d=e.interruption;if(typeof d!="string"){let f={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(!(d==="immediate"||d==="loopEnd")){let f={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:$b.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[f]:t.push(f),s++}}if(e.volume!==void 0){let d=e.volume;if(typeof d=="number"){if(d>100||isNaN(d)){let f={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[f]:t.push(f),s++}if(d<0||isNaN(d)){let f={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let d={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}if(e.pan!==void 0){let d=e.pan;if(typeof d=="number"){if(d>1||isNaN(d)){let f={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[f]:t.push(f),s++}if(d<-1||isNaN(d)){let f={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}}if(e.startDelayMs!==void 0){let d=e.startDelayMs;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}}}else{let d={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}return Rn.errors=t,s===0}function Yc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Rn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Rn.errors:t.concat(Rn.errors),s=t.length),Yc.errors=t,s===0}var zc=Gc;var _b={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"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},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 On(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let u={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let u=l.length;for(let c=0;c<u;c++){let p=l[c],m=s,d=!0,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let y;if(p.sprites===void 0&&(y="sprites")){let g={};t===null?t=[g]:t.push(g),s++}}var i=f===s;if(s=m,t!==null&&(m?t.length=m:t=null),i){let y=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let h={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};t===null?t=[h]:t.push(h),s++}var i=y===s;d=i}if(!d){let y={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[y]:t.push(y),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let y={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[y]:t.push(y),s++}for(let y in p)if(!Ze.call(_b.properties.items.items.properties,y)){let g={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};t===null?t=[g]:t.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let y={instancePath:r+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let y={instancePath:r+"/items/"+c+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(p.x!==void 0&&typeof p.x!="number"){let y={instancePath:r+"/items/"+c+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.y!==void 0&&typeof p.y!="number"){let y={instancePath:r+"/items/"+c+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let y={instancePath:r+"/items/"+c+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let y={instancePath:r+"/items/"+c+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let y={instancePath:r+"/items/"+c+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let y={instancePath:r+"/items/"+c+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let y={instancePath:r+"/items/"+c+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let y={instancePath:r+"/items/"+c+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let y={instancePath:r+"/items/"+c+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.opacity!==void 0){let y=p.opacity;if(typeof y=="number"){if(y>1||isNaN(y)){let g={instancePath:r+"/items/"+c+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[g]:t.push(g),s++}if(y<0||isNaN(y)){let g={instancePath:r+"/items/"+c+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[g]:t.push(g),s++}}else{let g={instancePath:r+"/items/"+c+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[g]:t.push(g),s++}}if(p.blur!==void 0&&($e(p.blur,{instancePath:r+"/items/"+c+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(t=t===null?$e.errors:t.concat($e.errors),s=t.length)),p.sprites!==void 0){let y=p.sprites;if(Array.isArray(y)){let g=y.length;for(let h=0;h<g;h++){let w=y[h];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 E={instancePath:r+"/items/"+c+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(w.id!==void 0&&typeof w.id!="string"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[b]:t.push(b),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[b]:t.push(b),s++}}else{let b={instancePath:r+"/items/"+c+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}}}else{let g={instancePath:r+"/items/"+c+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[g]:t.push(g),s++}}p.animations!==void 0&&(J(p.animations,{instancePath:r+"/items/"+c+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let y={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[y]:t.push(y),s++}}}else{let u={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[u]:t.push(u),s++}}}else{let l={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}return On.errors=t,s===0}function Gc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return On(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?On.errors:t.concat(On.errors),s=t.length),Gc.errors=t,s===0}var Xc=Wc;function Cn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=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:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let u=0;u<l;u++){let c=i[u];if(c&&typeof c=="object"&&!Array.isArray(c)){for(let p in c)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(c.id!==void 0&&typeof c.id!="string"){let p={instancePath:r+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}if(c.content!==void 0&&typeof c.content!="string"){let p={instancePath:r+"/items/"+u+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}if(c.events!==void 0){let p=c.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:r+"/items/"+u+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}}}else{let m={instancePath:r+"/items/"+u+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[m]:t.push(m),s++}}}else{let p={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}e.animations!==void 0&&(J(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Cn.errors=t,s===0}function Wc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Cn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Cn.errors:t.concat(Cn.errors),s=t.length),Wc.errors=t,s===0}var Hc=Kc;function $n(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="mode"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let i={instancePath:r+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return $n.errors=t,s===0}function Kc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return $n(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?$n.errors:t.concat($n.errors),s=t.length),Kc.errors=t,s===0}var Jc=Qc;function _n(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="resourceId"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return _n.errors=t,s===0}function Qc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return _n(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?_n.errors:t.concat(_n.errors),s=t.length),Qc.errors=t,s===0}var Zc=eu;var Lc={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 jn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ze.call(Lc.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.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 u={instancePath:r+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(i.resourceId!==void 0&&typeof i.resourceId!="string"){let l={instancePath:r+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}i.animations!==void 0&&(J(i.animations,{instancePath:r+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let l={instancePath:r+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.mode!==void 0){let i=e.mode;if(typeof i!="string"){let l={instancePath:r+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="adv"||i==="nvl")){let l={instancePath:r+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Lc.properties.mode.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.content!==void 0){let i=e.content;if(Array.isArray(i)){let l=i.length;for(let u=0;u<l;u++){let c=i[u];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.text!==void 0&&typeof c.text!="string"){let p={instancePath:r+"/content/"+u+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}}else{let p={instancePath:r+"/content/"+u,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let i={instancePath:r+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let i={instancePath:r+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let i={instancePath:r+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let i={instancePath:r+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let i={instancePath:r+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let i={instancePath:r+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.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 u={instancePath:r+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(i.name!==void 0&&typeof i.name!="string"){let l={instancePath:r+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(i.sprite!==void 0){let l=i.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let u in l)if(!(u==="transformId"||u==="items"||u==="animations")){let c={instancePath:r+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let u={instancePath:r+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[u]:t.push(u),s++}if(l.items!==void 0){let u=l.items;if(Array.isArray(u)){let c=u.length;for(let p=0;p<c;p++){let m=u[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[d]:t.push(d),s++}if(m.resourceId===void 0){let d={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[d]:t.push(d),s++}for(let d in m)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let f={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};t===null?t=[f]:t.push(f),s++}if(m.id!==void 0&&typeof m.id!="string"){let d={instancePath:r+"/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"};t===null?t=[d]:t.push(d),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let d={instancePath:r+"/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"};t===null?t=[d]:t.push(d),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let d={instancePath:r+"/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"};t===null?t=[d]:t.push(d),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let d={instancePath:r+"/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"};t===null?t=[d]:t.push(d),s++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let d={instancePath:r+"/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"};t===null?t=[d]:t.push(d),s++}}else{let d={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}}}else{let c={instancePath:r+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[c]:t.push(c),s++}}l.animations!==void 0&&(J(l.animations,{instancePath:r+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let u={instancePath:r+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}}}else{let l={instancePath:r+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let i={instancePath:r+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let i={instancePath:r+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return jn.errors=t,s===0}function eu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return jn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?jn.errors:t.concat(jn.errors),s=t.length),eu.errors=t,s===0}var ru=tu;function Nn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=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:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let i={instancePath:r+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.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 u=i[l];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.variableId===void 0){let c={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};t===null?t=[c]:t.push(c),s++}for(let c in u)if(!(c==="variableId"||c==="required"||c==="trim"||c==="placeholder"||c==="multiline"||c==="maxLength")){let p={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(u.variableId!==void 0&&typeof u.variableId!="string"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}if(u.required!==void 0&&typeof u.required!="boolean"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}if(u.trim!==void 0&&typeof u.trim!="boolean"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}if(u.placeholder!==void 0&&typeof u.placeholder!="string"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}if(u.multiline!==void 0&&typeof u.multiline!="boolean"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}if(u.maxLength!==void 0){let c=u.maxLength;if(!(typeof c=="number"&&!(c%1)&&!isNaN(c))){let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}if(typeof c=="number"&&(c<0||isNaN(c))){let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}}else{let c={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),s++}}else{let l={instancePath:r+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.submitActions!==void 0){let i=e.submitActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:r+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.cancelActions!==void 0){let i=e.cancelActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:r+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}e.animations!==void 0&&(J(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Nn.errors=t,s===0}function tu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Nn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Nn.errors:t.concat(Nn.errors),s=t.length),tu.errors=t,s===0}var nu=su;function Dn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}e.animations!==void 0&&(J(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Dn.errors=t,s===0}function su(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Dn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Dn.errors:t.concat(Dn.errors),s=t.length),su.errors=t,s===0}var ou=iu;function Tn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="opacity"||i==="blur"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}e.blur!==void 0&&($e(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(t=t===null?$e.errors:t.concat($e.errors),s=t.length)),e.animations!==void 0&&(J(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Tn.errors=t,s===0}function iu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Tn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Tn.errors:t.concat(Tn.errors),s=t.length),iu.errors=t,s===0}var au=lu;var jb={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"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1};function Ln(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let c;if(e.items===void 0&&(c="items")||e.channels===void 0&&(c="channels")){let p={};t===null?t=[p]:t.push(p),s++}}var u=l===s;if(u){let c={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[c]:t.push(c),s++}else s=i,t!==null&&(i?t.length=i:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let c in e)if(!(c==="items"||c==="channels")){let p={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(e.items!==void 0){let c=e.items;if(Array.isArray(c)){let p=c.length;for(let m=0;m<p;m++)Oe(c[m],{instancePath:r+"/items/"+m,parentData:c,parentDataProperty:m,rootData:a})||(t=t===null?Oe.errors:t.concat(Oe.errors),s=t.length)}else{let p={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[p]:t.push(p),s++}}if(e.channels!==void 0){let c=e.channels;if(Array.isArray(c)){let p=c.length;for(let m=0;m<p;m++){let d=c[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:r+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[f]:t.push(f),s++}if(d.sounds===void 0){let f={instancePath:r+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};t===null?t=[f]:t.push(f),s++}for(let f in d)if(!(f==="id"||f==="volume"||f==="muted"||f==="pan"||f==="loop"||f==="interruption"||f==="sounds")){let y={instancePath:r+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};t===null?t=[y]:t.push(y),s++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if(Ce(f)<1){let y={instancePath:r+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let y={instancePath:r+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[y]:t.push(y),s++}if(f<0||isNaN(f)){let y={instancePath:r+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let f={instancePath:r+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[f]:t.push(f),s++}if(d.pan!==void 0){let f=d.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let y={instancePath:r+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[y]:t.push(y),s++}if(f<-1||isNaN(f)){let y={instancePath:r+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:r+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[f]:t.push(f),s++}if(d.interruption!==void 0){let f=d.interruption;if(typeof f!="string"){let y={instancePath:r+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(!(f==="immediate"||f==="loopEnd")){let y={instancePath:r+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:jb.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[y]:t.push(y),s++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let y=f.length;for(let g=0;g<y;g++)Oe(f[g],{instancePath:r+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(t=t===null?Oe.errors:t.concat(Oe.errors),s=t.length)}else{let y={instancePath:r+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[y]:t.push(y),s++}}}else{let f={instancePath:r+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),s++}}}else{let p={instancePath:r+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[p]:t.push(p),s++}}}else{let c={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),s++}return Ln.errors=t,s===0}function lu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ln(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ln.errors:t.concat(Ln.errors),s=t.length),lu.errors=t,s===0}var cu=uu;var Mc={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"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}}],additionalProperties:!1}}},additionalProperties:!1};function Mn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,u=s;if(typeof e!="string"){let p={instancePath:r,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}var c=u===s;if(l=l||c,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let y=e[f];if(y&&typeof y=="object"&&!Array.isArray(y)){if(y.text!==void 0&&typeof y.text!="string"){let g={instancePath:r+"/"+f+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[g]:t.push(g),s++}if(y.textStyleId!==void 0&&typeof y.textStyleId!="string"){let g={instancePath:r+"/"+f+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[g]:t.push(g),s++}if(y.furigana!==void 0){let g=y.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let h={instancePath:r+"/"+f+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let h={instancePath:r+"/"+f+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[h]:t.push(h),s++}}}else{let g={instancePath:r+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[g]:t.push(g),s++}}}else{let d={instancePath:r,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[d]:t.push(d),s++}var c=p===s;l=l||c}if(l)s=i,t!==null&&(i?t.length=i:t=null);else{let p={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[p]:t.push(p),s++}return Mn.errors=t,s===0}function qn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=s,u=s,c=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};t===null?t=[b]:t.push(b),s++}}var m=p===s;if(c=c||m,!c){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let v={};t===null?t=[v]:t.push(v),s++}}var m=w===s;if(c=c||m,!c){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.resourceId===void 0&&(k="resourceId")){let x={};t===null?t=[x]:t.push(x),s++}}var m=E===s;if(c=c||m,!c){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let N={};t===null?t=[N]:t.push(N),s++}}var m=k===s;if(c=c||m,!c){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.x===void 0&&(P="x")){let T={};t===null?t=[T]:t.push(T),s++}}var m=C===s;if(c=c||m,!c){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.y===void 0&&(q="y")){let le={};t===null?t=[le]:t.push(le),s++}}var m=P===s;if(c=c||m,!c){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.anchorX===void 0&&(B="anchorX")){let ne={};t===null?t=[ne]:t.push(ne),s++}}var m=q===s;if(c=c||m,!c){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.anchorY===void 0&&(oe="anchorY")){let de={};t===null?t=[de]:t.push(de),s++}}var m=B===s;if(c=c||m,!c){let oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ve;if(e.scaleX===void 0&&(ve="scaleX")){let ce={};t===null?t=[ce]:t.push(ce),s++}}var m=oe===s;if(c=c||m,!c){let ve=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.scaleY===void 0&&(se="scaleY")){let ue={};t===null?t=[ue]:t.push(ue),s++}}var m=ve===s;if(c=c||m,!c){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ie;if(e.rotation===void 0&&(ie="rotation")){let O={};t===null?t=[O]:t.push(O),s++}}var m=se===s;if(c=c||m,!c){let ie=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.originX===void 0&&(j="originX")){let M={};t===null?t=[M]:t.push(M),s++}}var m=ie===s;if(c=c||m,!c){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.originY===void 0&&(Z="originY")){let ge={};t===null?t=[ge]:t.push(ge),s++}}var m=j===s;if(c=c||m,!c){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.layer===void 0&&(K="layer")){let xe={};t===null?t=[xe]:t.push(xe),s++}}var m=Z===s;if(c=c||m,!c){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ye;if(e.opacity===void 0&&(ye="opacity")){let Qr={};t===null?t=[Qr]:t.push(Qr),s++}}var m=K===s;if(c=c||m,!c){let ye=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Zr;if(e.blur===void 0&&(Zr="blur")){let et={};t===null?t=[et]:t.push(et),s++}}var m=ye===s;if(c=c||m,!c){let Zr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ps;if(e.animations===void 0&&(ps="animations")){let jt={};t===null?t=[jt]:t.push(jt),s++}}var m=Zr===s;c=c||m}}}}}}}}}}}}}}}}if(c)s=u,t!==null&&(u?t.length=u:t=null);else{let w={};t===null?t=[w]:t.push(w),s++}var d=l===s;if(d){let w={instancePath:r,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[w]:t.push(w),s++}else s=i,t!==null&&(i?t.length=i:t=null);let f=s,y=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};t===null?t=[w]:t.push(w),s++}var h=g===s;if(y=y||h,!y){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let E={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};t===null?t=[E]:t.push(E),s++}var h=w===s;y=y||h}if(y)s=f,t!==null&&(f?t.length=f:t=null);else{let w={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[w]:t.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Mn(e.content,{instancePath:r+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(t=t===null?Mn.errors:t.concat(Mn.errors),s=t.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:r+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[w]:t.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[w]:t.push(w),s++}return qn.errors=t,s===0}function Vn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let u={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let u=l.length;for(let c=0;c<u;c++){let p=l[c],m=s,d=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let f;if(p.resourceId===void 0&&(f="resourceId")||p.text===void 0&&(f="text")){let y={};t===null?t=[y]:t.push(y),s++}}var i=d===s;if(i){let f={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[f]:t.push(f),s++}else s=m,t!==null&&(m?t.length=m:t=null);if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let f={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[f]:t.push(f),s++}for(let f in p)if(!Ze.call(Mc.properties.items.items.properties,f)){let y={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};t===null?t=[y]:t.push(y),s++}if(p.id!==void 0&&typeof p.id!="string"){let f={instancePath:r+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(p.animationName!==void 0&&typeof p.animationName!="string"){let f={instancePath:r+"/items/"+c+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(p.animationSpeed!==void 0&&typeof p.animationSpeed!="number"){let f={instancePath:r+"/items/"+c+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.resourceId!==void 0&&typeof p.resourceId!="string"){let f={instancePath:r+"/items/"+c+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(p.text!==void 0&&(qn(p.text,{instancePath:r+"/items/"+c+"/text",parentData:p,parentDataProperty:"text",rootData:a})||(t=t===null?qn.errors:t.concat(qn.errors),s=t.length)),p.transformId!==void 0&&typeof p.transformId!="string"){let f={instancePath:r+"/items/"+c+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(p.x!==void 0&&typeof p.x!="number"){let f={instancePath:r+"/items/"+c+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.y!==void 0&&typeof p.y!="number"){let f={instancePath:r+"/items/"+c+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let f={instancePath:r+"/items/"+c+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let f={instancePath:r+"/items/"+c+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let f={instancePath:r+"/items/"+c+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let f={instancePath:r+"/items/"+c+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let f={instancePath:r+"/items/"+c+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let f={instancePath:r+"/items/"+c+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let f={instancePath:r+"/items/"+c+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),s++}if(p.layer!==void 0){let f=p.layer;if(typeof f!="number"){let y={instancePath:r+"/items/"+c+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(!(f===10||f===30||f===50||f===70||f===90)){let y={instancePath:r+"/items/"+c+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:Mc.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};t===null?t=[y]:t.push(y),s++}}if(p.opacity!==void 0){let f=p.opacity;if(typeof f=="number"){if(f>1||isNaN(f)){let y={instancePath:r+"/items/"+c+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[y]:t.push(y),s++}if(f<0||isNaN(f)){let y={instancePath:r+"/items/"+c+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/items/"+c+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}}p.blur!==void 0&&($e(p.blur,{instancePath:r+"/items/"+c+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(t=t===null?$e.errors:t.concat($e.errors),s=t.length)),p.animations!==void 0&&(J(p.animations,{instancePath:r+"/items/"+c+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(t=t===null?J.errors:t.concat(J.errors),s=t.length))}else{let f={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),s++}}}else{let u={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[u]:t.push(u),s++}}}else{let l={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}return Vn.errors=t,s===0}function uu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Vn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Vn.errors:t.concat(Vn.errors),s=t.length),uu.errors=t,s===0}var pu=fu;var Nb={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 Fn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,u=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let h={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[h]:t.push(h),s++}var c=u===s;if(l=l||c,!l){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};t===null?t=[b]:t.push(b),s++}var c=h===s;l=l||c}if(l)s=i,t!==null&&(i?t.length=i:t=null);else{let h={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[h]:t.push(h),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.resourceId===void 0&&(h="resourceId")||e.sounds===void 0&&(h="sounds")){let w={};t===null?t=[w]:t.push(w),s++}}var d=m===s;if(d){let h={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[h]:t.push(h),s++}else s=p,t!==null&&(p?t.length=p:t=null);let f=s,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.startDelayMs===void 0&&(h="startDelayMs")||e.sounds===void 0&&(h="sounds")){let w={};t===null?t=[w]:t.push(w),s++}}var g=y===s;if(g){let h={instancePath:r,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[h]:t.push(h),s++}else s=f,t!==null&&(f?t.length=f:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let h in e)if(!(h==="sounds"||h==="resourceId"||h==="volume"||h==="muted"||h==="pan"||h==="loop"||h==="interruption"||h==="startDelayMs")){let w={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};t===null?t=[w]:t.push(w),s++}if(e.sounds!==void 0){let h=e.sounds;if(Array.isArray(h)){let w=h.length;for(let b=0;b<w;b++)Oe(h[b],{instancePath:r+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:a})||(t=t===null?Oe.errors:t.concat(Oe.errors),s=t.length)}else{let w={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[w]:t.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let h={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(e.volume!==void 0){let h=e.volume;if(typeof h=="number"){if(h>100||isNaN(h)){let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[w]:t.push(w),s++}if(h<0||isNaN(h)){let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let h={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[h]:t.push(h),s++}if(e.pan!==void 0){let h=e.pan;if(typeof h=="number"){if(h>1||isNaN(h)){let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[w]:t.push(w),s++}if(h<-1||isNaN(h)){let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let h={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[h]:t.push(h),s++}if(e.interruption!==void 0){let h=e.interruption;if(typeof h!="string"){let w={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[w]:t.push(w),s++}if(!(h==="immediate"||h==="loopEnd")){let w={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Nb.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[w]:t.push(w),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let w={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}}else{let h={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[h]:t.push(h),s++}return Fn.errors=t,s===0}function fu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Fn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Fn.errors:t.concat(Fn.errors),s=t.length),fu.errors=t,s===0}var du=mu;var Db={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 Un(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,u=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};t===null?t=[g]:t.push(g),s++}var c=u===s;if(s=i,t!==null&&(i?t.length=i:t=null),c){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};t===null?t=[w]:t.push(w),s++}var c=g===s;l=c}if(!l){let g={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[g]:t.push(g),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};t===null?t=[g]:t.push(g),s++}var f=d===s;if(s=p,t!==null&&(p?t.length=p:t=null),f){let g=s,h=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let v={};t===null?t=[v]:t.push(v),s++}}var y=w===s;if(y){let E={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[E]:t.push(E),s++}else s=h,t!==null&&(h?t.length=h:t=null);var f=g===s;m=f}if(!m){let g={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[g]:t.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[g]:t.push(g),s++}if(e.name===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};t===null?t=[g]:t.push(g),s++}if(e.description===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};t===null?t=[g]:t.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let h={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};t===null?t=[h]:t.push(h),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let h={instancePath:r+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(!(g==="boolean"||g==="number")){let h={instancePath:r+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Db.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[h]:t.push(h),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let h={instancePath:r+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[h]:t.push(h),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let h={instancePath:r+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[h]:t.push(h),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if(Ce(g)<1){let h={instancePath:r+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if(Ce(g)<1){let h={instancePath:r+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if(Ce(g)<1){let h={instancePath:r+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if(Ce(g)<1){let h={instancePath:r+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:r+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[g]:t.push(g),s++}}else{let g={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[g]:t.push(g),s++}return Un.errors=t,s===0}function mu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Un(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Un.errors:t.concat(Un.errors),s=t.length),mu.errors=t,s===0}var yu=hu;var Tb={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 Lb={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 Or(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};t===null?t=[i]:t.push(i),s++}if(e.duration===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="value"||i==="duration"||i==="easing"||i==="relative")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let i={instancePath:r+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let i={instancePath:r+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.easing!==void 0){let i=e.easing;if(typeof i!="string"){let l={instancePath:r+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.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:r+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:Lb.properties.easing.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:r+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Or.errors=t,s===0}function G(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:r+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let u={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[u]:t.push(u),s++}let l=i.length;for(let u=0;u<l;u++)Or(i[u],{instancePath:r+"/keyframes/"+u,parentData:i,parentDataProperty:u,rootData:a})||(t=t===null?Or.errors:t.concat(Or.errors),s=t.length)}else{let l={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return G.errors=t,s===0}function Bn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="alpha"||i==="x"||i==="y"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.alpha!==void 0&&(G(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.x!==void 0&&(G(e.x,{instancePath:r+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.y!==void 0&&(G(e.y,{instancePath:r+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.scaleX!==void 0&&(G(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.scaleY!==void 0&&(G(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.rotation!==void 0&&(G(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Bn.errors=t,s===0}function Yn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="translateX"||i==="translateY"||i==="alpha"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.translateX!==void 0&&(G(e.translateX,{instancePath:r+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.translateY!==void 0&&(G(e.translateY,{instancePath:r+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.alpha!==void 0&&(G(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.scaleX!==void 0&&(G(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.scaleY!==void 0&&(G(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length)),e.rotation!==void 0&&(G(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?G.errors:t.concat(G.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Yn.errors=t,s===0}function Rr(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="tween"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.tween!==void 0&&(Yn(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Yn.errors:t.concat(Yn.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Rr.errors=t,s===0}var xn={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"]}}]},Mb={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function zn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="texture"||i==="channel"||i==="invert")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let i={instancePath:r+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.channel!==void 0){let i=e.channel;if(typeof i!="string"){let l={instancePath:r+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:r+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Mb.properties.channel.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let i={instancePath:r+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return zn.errors=t,s===0}function Gn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:r+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let u={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[u]:t.push(u),s++}let l=i.length;for(let u=0;u<l;u++)Or(i[u],{instancePath:r+"/keyframes/"+u,parentData:i,parentDataProperty:u,rootData:a})||(t=t===null?Or.errors:t.concat(Or.errors),s=t.length)}else{let l={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Gn.errors=t,s===0}function Xn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,u=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let b={};t===null?t=[b]:t.push(b),s++}var c=u===s;if(s=i,t!==null&&(i?t.length=i:t=null),c){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let v={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[v]:t.push(v),s++}var c=b===s;l=c}if(!l){let b={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let b={};t===null?t=[b]:t.push(b),s++}var f=d===s;if(s=p,t!==null&&(p?t.length=p:t=null),f){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let v={instancePath:r,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};t===null?t=[v]:t.push(v),s++}var f=b===s;m=f}if(!m){let b={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let y=s,g=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let b={};t===null?t=[b]:t.push(b),s++}var w=h===s;if(s=y,t!==null&&(y?t.length=y:t=null),w){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let v={instancePath:r,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};t===null?t=[v]:t.push(v),s++}var w=b===s;g=w}if(!g){let b={instancePath:r,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[b]:t.push(b),s++}for(let b in e)if(!Ze.call(xn.properties,b)){let E={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let E={instancePath:r+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let E={instancePath:r+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:xn.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let b={instancePath:r+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(e.textures!==void 0){let b=e.textures;if(Array.isArray(b)){if(b.length<1){let v={instancePath:r+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[v]:t.push(v),s++}let E=b.length;for(let v=0;v<E;v++)if(typeof b[v]!="string"){let k={instancePath:r+"/textures/"+v,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[k]:t.push(k),s++}}else{let E={instancePath:r+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[E]:t.push(E),s++}}if(e.items!==void 0){let b=e.items;if(Array.isArray(b)){if(b.length<1){let v={instancePath:r+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[v]:t.push(v),s++}let E=b.length;for(let v=0;v<E;v++)zn(b[v],{instancePath:r+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(t=t===null?zn.errors:t.concat(zn.errors),s=t.length)}else{let E={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[E]:t.push(E),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let E={instancePath:r+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let E={instancePath:r+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:xn.properties.combine.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let E={instancePath:r+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let E={instancePath:r+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:xn.properties.channel.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let b={instancePath:r+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[b]:t.push(b),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let b={instancePath:r+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[b]:t.push(b),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let b={instancePath:r+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}e.progress!==void 0&&(Gn(e.progress,{instancePath:r+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(t=t===null?Gn.errors:t.concat(Gn.errors),s=t.length))}else{let b={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}return Xn.errors=t,s===0}function Wn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,u=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};t===null?t=[b]:t.push(b),s++}var c=u===s;if(s=i,t!==null&&(i?t.length=i:t=null),c){let b=s,E=s,v=s,k=s,x=!1,C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.prev===void 0&&(P="prev")){let T={};t===null?t=[T]:t.push(T),s++}}var p=C===s;if(x=x||p,!x){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.next===void 0&&(q="next")){let le={};t===null?t=[le]:t.push(le),s++}}var p=P===s;if(x=x||p,!x){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.mask===void 0&&(B="mask")){let ne={};t===null?t=[ne]:t.push(ne),s++}}var p=q===s;x=x||p}}if(x)s=k,t!==null&&(k?t.length=k:t=null);else{let P={};t===null?t=[P]:t.push(P),s++}var m=v===s;if(m){let P={instancePath:r,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[P]:t.push(P),s++}else s=E,t!==null&&(E?t.length=E:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let P={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[P]:t.push(P),s++}var c=b===s;l=c}if(!l){let b={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let d=s,f=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};t===null?t=[b]:t.push(b),s++}var g=y===s;if(s=d,t!==null&&(d?t.length=d:t=null),g){let b=s,E=s,v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.tween===void 0&&(P="tween")){let T={};t===null?t=[T]:t.push(T),s++}}var h=v===s;if(h){let P={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[P]:t.push(P),s++}else s=E,t!==null&&(E?t.length=E:t=null);let k=s,x=!1,C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let P={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};t===null?t=[P]:t.push(P),s++}var w=C===s;if(x=x||w,!x){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let q={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};t===null?t=[q]:t.push(q),s++}var w=P===s;if(x=x||w,!x){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let B={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};t===null?t=[B]:t.push(B),s++}var w=q===s;x=x||w}}if(x)s=k,t!==null&&(k?t.length=k:t=null);else{let P={instancePath:r,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[P]:t.push(P),s++}var g=b===s;f=g}if(!f){let b={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[b]:t.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="complete"||b==="tween"||b==="prev"||b==="next"||b==="mask")){let E={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(e.type!==void 0){let b=e.type;if(typeof b!="string"){let E={instancePath:r+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="update"||b==="transition")){let E={instancePath:r+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Tb.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let E=b.payload;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:r+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[v]:t.push(v),s++}}}else{let E={instancePath:r+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),s++}}e.tween!==void 0&&(Bn(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Bn.errors:t.concat(Bn.errors),s=t.length)),e.prev!==void 0&&(Rr(e.prev,{instancePath:r+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(t=t===null?Rr.errors:t.concat(Rr.errors),s=t.length)),e.next!==void 0&&(Rr(e.next,{instancePath:r+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(t=t===null?Rr.errors:t.concat(Rr.errors),s=t.length)),e.mask!==void 0&&(Xn(e.mask,{instancePath:r+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(t=t===null?Xn.errors:t.concat(Xn.errors),s=t.length))}else{let b={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}return Wn.errors=t,s===0}function hu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Wn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Wn.errors:t.concat(Wn.errors),s=t.length),hu.errors=t,s===0}var gu=bu;function Hn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="name"||i==="nameVariableId")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let i={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Ce(i)<1){let l={instancePath:r+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Hn.errors=t,s===0}function bu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Hn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Hn.errors:t.concat(Hn.errors),s=t.length),bu.errors=t,s===0}var wu=Iu;var qb=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function Kn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="hex"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!qb.test(i)){let l={instancePath:r+"/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})$"'};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Kn.errors=t,s===0}function Iu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Kn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Kn.errors:t.concat(Kn.errors),s=t.length),Iu.errors=t,s===0}var vu=Au;function Jn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=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 u=i[l];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.actions!==void 0){let c=u.actions;if(!(c&&typeof c=="object"&&!Array.isArray(c))){let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}if(u.payload!==void 0){let c=u.payload;if(!(c&&typeof c=="object"&&!Array.isArray(c))){let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}if(u.keydown!==void 0){let c=u.keydown;if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.payload!==void 0){let p=c.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:r+"/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"};t===null?t=[m]:t.push(m),s++}}}else{let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}if(u.keyup!==void 0){let c=u.keyup;if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.payload!==void 0){let p=c.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:r+"/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"};t===null?t=[m]:t.push(m),s++}}}else{let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}}else{let c={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),s++}}else{let l={instancePath:r+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.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 u=i[l];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.actions!==void 0){let c=u.actions;if(!(c&&typeof c=="object"&&!Array.isArray(c))){let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}if(u.payload!==void 0){let c=u.payload;if(!(c&&typeof c=="object"&&!Array.isArray(c))){let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}}else{let c={instancePath:r+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),s++}}else{let l={instancePath:r+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let u=0;u<l;u++){let c=i[u];if(!(c&&typeof c=="object"&&!Array.isArray(c))){let p={instancePath:r+"/elements/"+u,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Jn.errors=t,s===0}function Au(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Jn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Jn.errors:t.concat(Jn.errors),s=t.length),Au.errors=t,s===0}var ku=Pu;function Qn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Qn.errors=t,s===0}function Pu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Qn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Qn.errors:t.concat(Qn.errors),s=t.length),Pu.errors=t,s===0}var xu=Eu;function Zn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Zn.errors=t,s===0}function Eu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Zn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Zn.errors:t.concat(Zn.errors),s=t.length),Eu.errors=t,s===0}var Su=Ru;function es(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=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 u=0;u<l;u++){let c=i[u];if(!(c&&typeof c=="object"&&!Array.isArray(c))){let p={instancePath:r+"/elements/"+u,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return es.errors=t,s===0}function Ru(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return es(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?es.errors:t.concat(es.errors),s=t.length),Ru.errors=t,s===0}var Ou=Cu;function rs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,u=null,c=s,p=s,m=s,d=s,f=!1,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.count===void 0&&(v="count")){let k={};t===null?t=[k]:t.push(k),s++}}var g=y===s;if(f=f||g,!f){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.texture===void 0&&(x="texture")){let C={};t===null?t=[C]:t.push(C),s++}}var g=v===s;if(f=f||g,!f){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let N;if(e.behaviors===void 0&&(N="behaviors")){let P={};t===null?t=[P]:t.push(P),s++}}var g=x===s;if(f=f||g,!f){let N=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.emitter===void 0&&(T="emitter")){let q={};t===null?t=[q]:t.push(q),s++}}var g=N===s;f=f||g}}}if(f)s=d,t!==null&&(d?t.length=d:t=null);else{let v={};t===null?t=[v]:t.push(v),s++}var h=m===s;if(h){let v={instancePath:r,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[v]:t.push(v),s++}else s=p,t!==null&&(p?t.length=p:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let v={instancePath:r,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};t===null?t=[v]:t.push(v),s++}var b=c===s;b&&(l=!0,u=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let v={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[v]:t.push(v),s++}if(e.behaviors===void 0){let v={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};t===null?t=[v]:t.push(v),s++}if(e.emitter===void 0){let v={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};t===null?t=[v]:t.push(v),s++}}var b=w===s;if(b&&l?(l=!1,u=[u,1]):b&&(l=!0,u=1),l)s=i,t!==null&&(i?t.length=i:t=null);else{let v={instancePath:r,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:u},message:"must match exactly one schema in oneOf"};t===null?t=[v]:t.push(v),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let v={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[v]:t.push(v),s++}if(e.height===void 0){let v={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[v]:t.push(v),s++}for(let v in e)if(!(v==="width"||v==="height"||v==="seed"||v==="modules"||v==="count"||v==="texture"||v==="behaviors"||v==="emitter")){let k={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};t===null?t=[k]:t.push(k),s++}if(e.width!==void 0){let v=e.width;if(typeof v=="number"){if(v<=0||isNaN(v)){let k={instancePath:r+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[k]:t.push(k),s++}}else{let k={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}}if(e.height!==void 0){let v=e.height;if(typeof v=="number"){if(v<=0||isNaN(v)){let k={instancePath:r+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[k]:t.push(k),s++}}else{let k={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let v={instancePath:r+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[v]:t.push(v),s++}if(e.modules!==void 0){let v=e.modules;if(v&&typeof v=="object"&&!Array.isArray(v)){if(v.emission===void 0){let k={instancePath:r+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};t===null?t=[k]:t.push(k),s++}if(v.appearance===void 0){let k={instancePath:r+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};t===null?t=[k]:t.push(k),s++}for(let k in v)if(!(k==="emission"||k==="movement"||k==="appearance"||k==="bounds")){let x={instancePath:r+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};t===null?t=[x]:t.push(x),s++}if(v.emission!==void 0){let k=v.emission;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:r+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}if(v.movement!==void 0){let k=v.movement;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:r+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}if(v.appearance!==void 0){let k=v.appearance;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:r+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}if(v.bounds!==void 0){let k=v.bounds;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:r+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}}else{let k={instancePath:r+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}if(e.count!==void 0){let v=e.count;if(!(typeof v=="number"&&!(v%1)&&!isNaN(v))){let k={instancePath:r+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[k]:t.push(k),s++}if(typeof v=="number"&&(v<1||isNaN(v))){let k={instancePath:r+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[k]:t.push(k),s++}}if(e.texture!==void 0){let v=e.texture,k=s,x=!1,C=null,N=s;if(typeof v=="string"){if(Ce(v)<1){let T={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[T]:t.push(T),s++}}else{let T={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[T]:t.push(T),s++}var E=N===s;E&&(x=!0,C=0);let P=s;if(!(v&&typeof v=="object"&&!Array.isArray(v))){let T={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[T]:t.push(T),s++}var E=P===s;if(E&&x?(x=!1,C=[C,1]):E&&(x=!0,C=1),x)s=k,t!==null&&(k?t.length=k:t=null);else{let T={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:C},message:"must match exactly one schema in oneOf"};t===null?t=[T]:t.push(T),s++}}if(e.behaviors!==void 0){let v=e.behaviors;if(Array.isArray(v)){if(v.length<1){let x={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[x]:t.push(x),s++}let k=v.length;for(let x=0;x<k;x++){let C=v[x];if(C&&typeof C=="object"&&!Array.isArray(C)){if(C.type===void 0){let N={instancePath:r+"/behaviors/"+x,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[N]:t.push(N),s++}for(let N in C)if(!(N==="type"||N==="config")){let P={instancePath:r+"/behaviors/"+x,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:N},message:"must NOT have additional properties"};t===null?t=[P]:t.push(P),s++}if(C.type!==void 0){let N=C.type;if(typeof N=="string"){if(Ce(N)<1){let P={instancePath:r+"/behaviors/"+x+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[P]:t.push(P),s++}}else{let P={instancePath:r+"/behaviors/"+x+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[P]:t.push(P),s++}}if(C.config!==void 0){let N=C.config;if(!(N&&typeof N=="object"&&!Array.isArray(N))){let P={instancePath:r+"/behaviors/"+x+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[P]:t.push(P),s++}}}else{let N={instancePath:r+"/behaviors/"+x,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[N]:t.push(N),s++}}}else{let k={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[k]:t.push(k),s++}}if(e.emitter!==void 0){let v=e.emitter;if(v&&typeof v=="object"&&!Array.isArray(v)){if(v.lifetime===void 0){let k={instancePath:r+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};t===null?t=[k]:t.push(k),s++}if(v.lifetime!==void 0){let k=v.lifetime;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.min===void 0){let x={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};t===null?t=[x]:t.push(x),s++}if(k.max===void 0){let x={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};t===null?t=[x]:t.push(x),s++}if(k.min!==void 0){let x=k.min;if(typeof x=="number"){if(x<0||isNaN(x)){let C={instancePath:r+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[C]:t.push(C),s++}}else{let C={instancePath:r+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[C]:t.push(C),s++}}if(k.max!==void 0){let x=k.max;if(typeof x=="number"){if(x<0||isNaN(x)){let C={instancePath:r+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[C]:t.push(C),s++}}else{let C={instancePath:r+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[C]:t.push(C),s++}}}else{let x={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}}else{let k={instancePath:r+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}}else{let v={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[v]:t.push(v),s++}return rs.errors=t,s===0}function Cu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return rs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?rs.errors:t.concat(rs.errors),s=t.length),Cu.errors=t,s===0}var $u=_u;var qc={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 ts(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!Ze.call(qc.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:qc.properties.endAt.type},message:"must be number,null"};t===null?t=[l]:t.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ts.errors=t,s===0}function _u(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ts(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ts.errors:t.concat(ts.errors),s=t.length),_u.errors=t,s===0}var ju=Nu;var Vb=new RegExp("^.+$","u");function ns(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.jsonData===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="jsonData"||i==="width"||i==="height"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.jsonData!==void 0){let i=e.jsonData;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:r+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.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(Vb.test(l)){let u=i[l];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.frames===void 0){let c={instancePath:r+"/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'"};t===null?t=[c]:t.push(c),s++}for(let c in u)if(!(c==="frames"||c==="animationSpeed"||c==="loop")){let p={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(u.frames!==void 0){let c=u.frames;if(Array.isArray(c)){let p=c.length;for(let m=0;m<p;m++)if(typeof c[m]!="number"){let d={instancePath:r+"/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"};t===null?t=[d]:t.push(d),s++}}else{let p={instancePath:r+"/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"};t===null?t=[p]:t.push(p),s++}}if(u.animationSpeed!==void 0&&typeof u.animationSpeed!="number"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}if(u.loop!==void 0&&typeof u.loop!="boolean"){let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}}else{let c={instancePath:r+"/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"};t===null?t=[c]:t.push(c),s++}}}else{let l={instancePath:r+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ns.errors=t,s===0}function Nu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ns(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ns.errors:t.concat(ns.errors),s=t.length),Nu.errors=t,s===0}var Du=Tu;var Vc={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 ss(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};t===null?t=[l]:t.push(l),s++}if(e.fontSize===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};t===null?t=[l]:t.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};t===null?t=[l]:t.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};t===null?t=[l]:t.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};t===null?t=[l]:t.push(l),s++}if(e.colorId===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};t===null?t=[l]:t.push(l),s++}for(let l in e)if(!Ze.call(Vc.properties,l)){let u={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(e.fontId!==void 0){let l=e.fontId,u=s,c=!1,p=null,m=s;if(typeof l=="string"){if(Ce(l)<1){let f={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}var i=m===s;i&&(c=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let h={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[h]:t.push(h),s++}let f=l.length;for(let h=0;h<f;h++){let w=l[h];if(typeof w=="string"){if(Ce(w)<1){let b={instancePath:r+"/fontId/"+h,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[b]:t.push(b),s++}}else{let b={instancePath:r+"/fontId/"+h,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}}let y=l.length,g;if(y>1){let h={};for(;y--;){let w=l[y];if(typeof w=="string"){if(typeof h[w]=="number"){g=h[w];let b={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:y,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+y+" are identical)"};t===null?t=[b]:t.push(b),s++;break}h[w]=y}}}}else{let f={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[f]:t.push(f),s++}var i=d===s;if(i&&c?(c=!1,p=[p,1]):i&&(c=!0,p=1),c)s=u,t!==null&&(u?t.length=u:t=null);else{let f={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};t===null?t=[f]:t.push(f),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:r+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:r+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:r+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.fontWeight!==void 0&&typeof e.fontWeight!="string"){let l={instancePath:r+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let u={instancePath:r+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[u]:t.push(u),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let u={instancePath:r+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:Vc.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};t===null?t=[u]:t.push(u),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:r+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:r+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:r+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[l]:t.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:r+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[l]:t.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:r+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:r+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:r+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:r+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.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 u={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};t===null?t=[u]:t.push(u),s++}for(let u in l)if(!(u==="colorId"||u==="alpha"||u==="blur"||u==="offsetX"||u==="offsetY")){let c={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(l.colorId!==void 0){let u=l.colorId;if(typeof u=="string"){if(Ce(u)<1){let c={instancePath:r+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[c]:t.push(c),s++}}else{let c={instancePath:r+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[c]:t.push(c),s++}}if(l.alpha!==void 0){let u=l.alpha;if(typeof u=="number"){if(u>1||isNaN(u)){let c={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[c]:t.push(c),s++}if(u<0||isNaN(u)){let c={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[c]:t.push(c),s++}}else{let c={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[c]:t.push(c),s++}}if(l.blur!==void 0){let u=l.blur;if(typeof u=="number"){if(u<0||isNaN(u)){let c={instancePath:r+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[c]:t.push(c),s++}}else{let c={instancePath:r+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[c]:t.push(c),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let u={instancePath:r+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let u={instancePath:r+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}}}else{let l={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}return ss.errors=t,s===0}function Tu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ss(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ss.errors:t.concat(ss.errors),s=t.length),Tu.errors=t,s===0}var Lu=Mu;var Fb={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function os(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ze.call(Fb.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.x!==void 0){let i=e.x;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.y!==void 0){let i=e.y;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return os.errors=t,s===0}function Mu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return os(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?os.errors:t.concat(os.errors),s=t.length),Mu.errors=t,s===0}var qu=Vu;function is(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return is.errors=t,s===0}function Vu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return is(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?is.errors:t.concat(is.errors),s=t.length),Vu.errors=t,s===0}var ls=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),$t=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Cr=e=>e===void 0?void 0:structuredClone(e),Ub=Object.freeze({achievement:"achievements",animation:"animations",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),Bb=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Yb=Object.freeze({background:Fc,bgm:Bc,character:zc,choice:Xc,cleanAll:Hc,control:Jc,dialogue:Zc,form:ru,layout:nu,screen:ou,sfx:au,visual:cu,voice:pu}),zb=Object.freeze({achievement:du,animation:yu,character:gu,color:wu,control:vu,font:ku,image:xu,layout:Su,particle:Ou,sound:$u,spritesheet:ju,textStyle:Du,transform:Lu,video:qu}),Gb=new Set(["files","language","patches"]),Xb=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Wb=new Set(["lineId","mode","payload","type"]),Hb=new Set(["mode","payload","sceneId","type"]),Kb=new Set(["mode","operation","payload","resourceId","type"]),Jb=new Set(["fileId","mimeType"]),F=(e,r)=>{throw new Error(`Invalid l10nData at ${e}: ${r}`)},Fe=(e,r)=>{$t(e)||F(r,"expected an object")},ri=(e,r)=>{Array.isArray(e)||F(r,"expected an array")},Kr=(e,r)=>{(typeof e!="string"||e.length===0)&&F(r,"expected a non-empty string")},Bu=(e,r)=>{typeof e!="string"&&F(r,"expected a string")},ze=(e,r,n)=>{for(let o of Object.keys(e))r.has(o)||F(`${n}.${o}`,"unknown field")},Ge=(e,r,n)=>{for(let o of r)ls(e,o)||F(n,`missing required field "${o}"`)},Qb=e=>e.replaceAll("~1","/").replaceAll("~0","~"),Zb=(e,r)=>{let n=(r?.instancePath??"").split("/").slice(1).map(Qb);return r?.keyword==="required"?n.push(r.params.missingProperty):r?.keyword==="additionalProperties"&&n.push(r.params.additionalProperty),n.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},e0=(e=[])=>e.filter(r=>!["anyOf","if","not","oneOf"].includes(r.keyword)).reduce((r,n)=>{if(r===void 0)return n;let o=n.instancePath.split("/").length,a=r.instancePath.split("/").length;return o>a?n:r},void 0)??e[0],Yu=({value:e,validator:r,path:n,contract:o})=>{if(r(e))return;let a=e0(r.errors);F(Zb(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Jr=(e,r)=>{Kr(e,r),(e==="__proto__"||e==="constructor"||e==="prototype")&&F(r,`"${e}" is not a safe ID`)},r0=(e,r)=>{Kr(e,r),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&F(r,"must be a safe single filename")},Ct=(e,r)=>{if(Object.is(e,r))return!0;if(Array.isArray(e)||Array.isArray(r))return!Array.isArray(e)||!Array.isArray(r)?!1:e.length===r.length&&e.every((a,t)=>Ct(a,r[t]));if(!$t(e)||!$t(r))return!1;let n=Object.keys(e).sort(),o=Object.keys(r).sort();return Ct(n,o)&&n.every(a=>Ct(e[a],r[a]))},as=(e,r=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>as(o,r,n)),r;if(!$t(e)||n.has(e))return r;n.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&r.add(a),as(a,r,n);return r},t0=e=>{let r=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[a,t]of Object.entries(o?.sections??{}))for(let[s,i]of(t?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=r.get(i.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:i}),r.set(i.id,l)}return r},zu=(e,r,n)=>{let o=e.get(r)??[];return o.length===0&&F(n,`lineId "${r}" does not exist in projectData`),o.length>1&&F(n,`lineId "${r}" is not globally unique in projectData`),o[0]},Gu=(e,r)=>e.story.scenes[r.sceneId].sections[r.sectionId].lines[r.lineIndex],Fu=e=>({items:(e?.items??[]).map(r=>({id:r?.id,events:r?.events}))}),Uu=e=>{let r=Cr(e??{});delete r.resourceId,delete r.animations;for(let n of Object.values(r.fields??{}))$t(n)&&delete n.placeholder;return r},n0=(e,r,n,o)=>{e==="choice"&&!Ct(Fu(r),Fu(n))&&F(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Ct(Uu(r),Uu(n))&&F(o,"form behavior must remain identical; only presentation fields and placeholders may change")},s0=({patch:e,path:r,lineIndex:n})=>{ze(e,Xb,r),Ge(e,["type","lineId","actionType","payload"],r),Jr(e.lineId,`${r}.lineId`),Kr(e.actionType,`${r}.actionType`),Fe(e.payload,`${r}.payload`),e.mode!==void 0&&e.mode!=="replace"&&F(`${r}.mode`,'line.action supports only "replace"'),Bb.has(e.actionType)||F(`${r}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=zu(n,e.lineId,`${r}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&F(`${r}.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")&&F(`${r}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),ls(e.payload,"content")&&F(`${r}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&F(`${r}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),n0(e.actionType,a,e.payload,`${r}.payload`),Yu({value:e.payload,validator:Yb[e.actionType],path:`${r}.payload`,contract:`the ${e.actionType} presentation-action schema`}),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},o0=(e,r)=>{ri(e,r),e.forEach((n,o)=>{Fe(n,`${r}[${o}]`),ze(n,new Set(["text"]),`${r}[${o}]`),Ge(n,["text"],`${r}[${o}]`),Bu(n.text,`${r}[${o}].text`)})},i0=({patch:e,path:r,lineIndex:n})=>{ze(e,Wb,r),Ge(e,["type","lineId","payload"],r),Jr(e.lineId,`${r}.lineId`),Fe(e.payload,`${r}.payload`),ze(e.payload,new Set(["content"]),`${r}.payload`),Ge(e.payload,["content"],`${r}.payload`),o0(e.payload.content,`${r}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&F(`${r}.mode`,'line.dialogue supports only "replace"');let o=zu(n,e.lineId,`${r}.lineId`);return o.line?.actions?.dialogue===void 0&&F(`${r}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},a0=({patch:e,path:r,projectData:n})=>(ze(e,Hb,r),Ge(e,["type","mode","sceneId","payload"],r),Jr(e.sceneId,`${r}.sceneId`),Fe(e.payload,`${r}.payload`),ze(e.payload,new Set(["name"]),`${r}.payload`),Ge(e.payload,["name"],`${r}.payload`),Bu(e.payload.name,`${r}.payload.name`),e.mode!=="patch"&&F(`${r}.mode`,'story.scene requires "patch"'),ls(n?.story?.scenes??{},e.sceneId)||F(`${r}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),l0=(e,r,n)=>{Fe(r,n),["font","image","sound","spritesheet","video"].includes(e)&&Kr(r.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(r.width)||F(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||F(`${n}.height`,"expected an integer")),e==="spritesheet"&&(Fe(r.jsonData,`${n}.jsonData`),Number.isInteger(r.width)||F(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||F(`${n}.height`,"expected an integer")),e==="color"&&(typeof r.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r.hex))&&F(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),Yu({value:r,validator:zb[e],path:n,contract:`the resource.${e} schema`})},c0=({patch:e,path:r,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{ze(e,Kb,r),Ge(e,["type","resourceId","payload"],r),Jr(e.resourceId,`${r}.resourceId`);let t=e.type.slice(9),s=Ub[t];s||F(`${r}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&F(`${r}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&F(`${r}.operation`,'the only resource operation is "add"'),l0(t,e.payload,`${r}.payload`);let i=n?.resources?.[s]??{},l=ls(i,e.resourceId);e.operation==="add"&&l&&F(`${r}.resourceId`,`cannot add existing ${t} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&F(`${r}.resourceId`,`cannot replace missing ${t} resource "${e.resourceId}"`);for(let u of as(e.payload))!o.has(u)&&!a.has(u)&&F(`${r}.payload`,`fileId "${u}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,patch:e}},u0=({patch:e,path:r,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:t})=>{if(Fe(e,r),Kr(e.type,`${r}.type`),e.type==="line.action")return s0({patch:e,path:r,lineIndex:o});if(e.type==="line.dialogue")return i0({patch:e,path:r,lineIndex:o});if(e.type==="story.scene")return a0({patch:e,path:r,projectData:n});if(e.type.startsWith("resource."))return c0({patch:e,path:r,projectData:n,packageFileIds:a,canonicalFileIds:t});F(`${r}.type`,`unsupported patch type "${e.type}"`)},p0=(e,r)=>{ri(e,r);let n=new Set;return e.forEach((o,a)=>{let t=`${r}[${a}]`;Fe(o,t),ze(o,Jb,t),Ge(o,["fileId"],t),r0(o.fileId,`${t}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&F(`${t}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&F(`${t}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},f0=({packageId:e,packageData:r,path:n,projectData:o,lineIndex:a,canonicalFileIds:t})=>{Fe(r,n),ze(r,Gb,n),Ge(r,["language","files","patches"],n),Kr(r.language,`${n}.language`);let s=p0(r.files,`${n}.files`);ri(r.patches,`${n}.patches`);let i=new Set,l=r.patches.map((u,c)=>{let p=u0({patch:u,path:`${n}.patches[${c}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:t});return i.has(p.key)&&F(`${n}.patches[${c}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:r,fileIds:s,patches:l}},Xu=({projectData:e,l10nData:r})=>{if(r===void 0)return{packages:new Map};Fe(r,"l10nData"),ze(r,new Set(["packages"]),"l10nData"),Ge(r,["packages"],"l10nData"),Fe(r.packages,"l10nData.packages");let n=t0(e),o=as(e?.resources??{}),a=new Map,t=new Map;for(let[s,i]of Object.entries(r.packages)){Jr(s,`l10nData.packages.${s}`);let l=f0({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let u of l.fileIds){o.has(u)&&F(`l10nData.packages.${s}.files`,`fileId "${u}" conflicts with a canonical project file`);let c=t.get(u);c!==void 0&&F(`l10nData.packages.${s}.files`,`fileId "${u}" is already declared by package "${c}"`),t.set(u,s)}a.set(s,l)}return{packages:a}},d0=(e,r)=>{let{collectionName:n,patch:o}=r;e.resources[n]??={},e.resources[n][o.resourceId]=Cr(o.payload)},m0=(e,r)=>{let{patch:n}=r,o=e.story.scenes[n.sceneId];o.name=n.payload.name},y0=(e,r)=>{let{location:n,patch:o}=r,a=Gu(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=Cr(o.payload);return}let t=Cr(n.line.actions.dialogue.content);a.actions.dialogue=Cr(o.payload),t!==void 0&&(a.actions.dialogue.content=t)},h0=(e,r)=>{let{location:n,patch:o}=r,a=Gu(e,n);a.actions.dialogue.content=Cr(o.payload.content)},Wu=({projectData:e,l10nData:r})=>{let n=Xu({projectData:e,l10nData:r});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},cs=({projectData:e,l10nData:r,l10nId:n=null})=>{let o=Xu({projectData:e,l10nData:r});if(n!==null&&(Jr(n,"l10nId"),o.packages.has(n)||F("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=Cr(e),t=o.packages.get(n).patches;return t.filter(s=>s.kind==="resource").forEach(s=>d0(a,s)),t.filter(s=>s.kind==="story.scene").forEach(s=>m0(a,s)),t.filter(s=>s.kind==="line.action").forEach(s=>y0(a,s)),t.filter(s=>s.kind==="line.dialogue").forEach(s=>h0(a,s)),a};var g0=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),b0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Hu="conditional",si=Symbol("conditionalAutoContinue"),w0=new Set(["sectionTransition","resetStoryAtSection"]),I0=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),v0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),ti="form",A0=new Set(["submitForm","cancelForm"]),k0="showImageGalleryVariant",P0="playMusicRoomTrack",x0="startSceneReplay",Ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),us=e=>e?.type===si,ni=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId;function oi(e){let r,n=0,o=null,a=0,t=!1,s=0,i=[],l=null,u=new Map,c=new Map,p=new Map,m,d,f=null,{handlePendingEffects:y}=e,g=(I=new Map,S=Date.now())=>new Map(Array.from(I.entries()).filter(([,R])=>S<R.expiresAt).map(([R,$])=>[R,{animation:structuredClone($.animation),startedAt:$.startedAt,expiresAt:$.expiresAt}])),h=(I=new Map)=>Array.from(I.values()).map(S=>structuredClone(S.animation)),w=(I=Date.now())=>{u=new Map(Array.from(u.entries()).filter(([,S])=>I<S.expiresAt))},b=()=>{if(!(a>0||t)){t=!0;try{for(;r.selectPendingEffects().length>0;){let I=[...r.selectPendingEffects()];r.clearPendingEffects();try{y(I)}catch(S){throw r.clearPendingEffects(),I.forEach(R=>{r.appendPendingEffect(R)}),S}}}finally{t=!1}}},E=I=>{a+=1;let S=!1;try{let R=I();return S=!0,R}finally{a-=1,S&&b()}},v=({initialState:I,namespace:S})=>{let{l10nData:R,...$}=I,L=R===void 0?void 0:structuredClone(R),Y=structuredClone(I.projectData),Q=Wu({projectData:Y,l10nData:L}),ee=$.global??{};if(!Ue(ee))throw new Error("Malformed global state.");let Ee=ee.runtime??{};if(!Ue(Ee))throw new Error("Malformed global.runtime.");let Le=Ee.localizationPackageId;if(Le!=null&&typeof Le!="string")throw new Error("localizationPackageId requires a string or null value");let $r=new Set(Q.map(({l10nId:ms})=>ms).filter(ms=>ms!==null)),_r=typeof Le=="string"&&$r.has(Le)?Le:null,gp=cs({projectData:Y,l10nData:L,l10nId:_r});r=Cc({...$,global:{...ee,localizationPackages:Q,runtime:{...Ee,localizationPackageId:_r}},projectData:gp}),n=0,o=Qo(S),a=0,t=!1,s=0,i=[],l=null,u=new Map,c=new Map,p=new Map,m=Y,d=L,f=_r,r.appendPendingEffect({name:"handleLineActions"}),b()},k=()=>o,x=()=>r.selectPresentationState(),C=()=>r.selectPresentationChanges(),N=I=>r.selectSectionLineChanges(I),P=(I={})=>{n+=1;let S=Date.now();w(S);let R=c.size>0,$=g(u,S),L=R?g(c,S):new Map,Q={...r.selectRenderState({activePersistentAnimations:h($),restoredPersistentAnimations:h(L)}),id:`render-${n}`};return p.set(Q.id,{builtAt:S,persistentAnimationSessions:new Map([...L.entries(),...$.entries()]),usedRestoredPersistentAnimationSessions:R}),Q},T=(I={})=>P(I),q=(I={})=>P(I),le=I=>{let S=typeof I?.id=="string"&&I.id.length>0?I.id:null,R=S?p.get(S):null;S&&p.delete(S);let $=new Map;_a(I?.animations).forEach(L=>{let Y=nn(L);if(!Y)return;let Q=R?.persistentAnimationSessions?.get(Y)??u.get(Y),ee=Math.max(0,Da(L)),Ee=Q?.startedAt??R?.builtAt??Date.now();$.set(Y,{animation:structuredClone(L),startedAt:Ee,expiresAt:Ee+ee})}),u=$,R?.usedRestoredPersistentAnimationSessions&&(c=new Map)},B=()=>r.selectSystemState(),ne=()=>r.selectAchievements(),oe=I=>r.selectAchievement(I),de=()=>r.selectSaveSlotMap(),ve=I=>r.selectSaveSlot(I),ce=I=>r.selectSaveSlotPage(I),se=()=>r.selectImageGallery(),ue=()=>r.selectMusicRoom(),ie=()=>r.selectSceneReplay(),O=()=>r.selectIsSceneReplayActive(),j=()=>r.selectSkipMode(),M=()=>r.selectAutoMode(),Z=()=>r.selectRuntime(),ge=()=>r.selectIsChoiceVisible(),K=()=>r.selectIsFormVisible(),xe=()=>r.selectActiveInteraction(),ye=()=>r.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),Qr=(I,S,R={})=>!Ue(S)||I!=="nextLine"?S:R.bypassChoice===!0?{...S,bypassChoice:!0}:R.interactionSource===ti?{...S,_interactionSource:ti}:S,Zr=(I={})=>({type:si,payload:Qr("nextLine",{_conditionalContinuation:!0},I)}),et=(I,S)=>us(I)?{type:si,payload:{...I.payload,...S.payload}}:S,ps=I=>{I.savedCheckpointOccurrences.forEach(S=>{r.markSavedRollbackCheckpointTransient(S)}),I.savedCheckpointOccurrences=[]},jt=(I,S)=>{let R=l;return l=null,!R||!ni(R.pointer,I)||R.checkpointIndex!==S?.checkpointIndex||R.checkpointIdentity!==S?.checkpoint?[]:R.savedCheckpointOccurrences},ai=I=>{I.markCurrentCheckpointTransient&&(r.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),ps(I))},ep=(I,S,R)=>I0.has(I)?I==="resetStoryAtSection"?R?.checkpoint!==S?.checkpoint:R?.checkpoint!==S?.checkpoint&&R?.checkpointIndex>S?.checkpointIndex:!1,rp=I=>{let S=i.at(-1);if(!S?.markCurrentCheckpointTransient)return;let R=r.selectSaveSlot({slotId:I?.slotId});R&&S.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:R,checkpointIndex:S.rollbackCursor?.checkpointIndex,sectionId:S.pointer?.sectionId,lineId:S.pointer?.lineId})},tp=(I,S,R)=>{let $=i.at(-1);if(!$)return;let L=r.selectCurrentPointer()?.pointer,Y=ep(I,S,R);if(ni($.pointer,L)){let Q=R?.checkpoint!==S?.checkpoint||R?.checkpointIndex!==S?.checkpointIndex;(Y||Q&&v0.has(I))&&(ai($),$.pointer=L,$.rollbackCursor=R,$.markCurrentCheckpointTransient=Y,$.savedCheckpointOccurrences=[]);return}ai($),$.pointer=L,$.rollbackCursor=r.selectRollbackCursor?.()??null,$.markCurrentCheckpointTransient=Y,$.savedCheckpointOccurrences=[]},Nt=(I,S)=>{if(!r[I])return;let R=S,$,L;if(I==="updateProjectData")li(S),$=structuredClone(S.projectData),R={...S,projectData:cs({projectData:$,l10nData:d,l10nId:f})},li(R);else if(I==="updateLocalizationPackage"){if(L=np(S),L===f)return;R={l10nId:L,projectData:cs({projectData:m,l10nData:d,l10nId:L})}}w0.has(I)&&(s+=1);let Y=r.selectIsSceneReplayActive?.()===!0,Q=b0.has(I)?g(u):null,ee=r.selectRollbackCursor?.()??null,Ee=r[I](R);$!==void 0&&(m=$),L!==void 0&&(f=L),g0.has(I)&&(c=Q??new Map,u=new Map);let Le=r.selectIsSceneReplayActive?.()===!0;Y!==Le&&(u=new Map,c=new Map);let $r=r.selectRollbackCursor?.()??null;return I==="saveSlot"&&rp(S),tp(I,ee,$r),b(),Ee},li=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");br(I?.projectData?.resources?.variables??{}),at(I.projectData),lt(I.projectData),ct(I.projectData)},np=I=>{if(!Ue(I))throw new Error("updateLocalizationPackage requires an object payload");let S=Object.keys(I);if(S.length!==1||S[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},sp=(I,S,R)=>{let $=r.selectCurrentPointer()?.pointer;S!==$||R!==s||(r.appendPendingEffect({name:"clearAutoNextTimer"}),r.appendPendingEffect({name:"clearNextLineConfigTimer"}),Nt("nextLineFromSystem",I.payload))},op=()=>({renderSequence:n,conditionalRoutingSequence:s,rollbackNavigationContexts:i.slice(),pendingRollbackLineEntrySaveHandoff:l,persistentAnimationSessions:new Map(u),restoredPersistentAnimationSessions:new Map(c),renderPersistentAnimationMetadata:new Map(p),canonicalProjectData:m,localizationPackageId:f}),ip=I=>{n=I.renderSequence,s=I.conditionalRoutingSequence,i=I.rollbackNavigationContexts.slice(),l=I.pendingRollbackLineEntrySaveHandoff,u=new Map(I.persistentAnimationSessions),c=new Map(I.restoredPersistentAnimationSessions),p=new Map(I.renderPersistentAnimationMetadata),m=I.canonicalProjectData,f=I.localizationPackageId},ci=(I,S={})=>E(()=>{let R=op();try{return r[Us](()=>{let $,L=r.selectCurrentPointer()?.pointer??null,Y=r.selectRollbackCursor?.()??null,Q=s,ee={pointer:L,rollbackCursor:Y,markCurrentCheckpointTransient:S.rollbackSource==="line",savedCheckpointOccurrences:S.savedCheckpointOccurrences?.slice()??[]};i.push(ee);try{r.beginRollbackActionBatch({source:S.rollbackSource});try{$=I()}finally{r.endRollbackActionBatch({})}us($)&&sp($,L,Q)}finally{i.pop(),(!ni(L,ee.pointer)||Y?.checkpoint!==ee.rollbackCursor?.checkpoint)&&ee.markCurrentCheckpointTransient&&ee.savedCheckpointOccurrences.length>0&&(l={pointer:ee.pointer,checkpointIndex:ee.rollbackCursor?.checkpointIndex,checkpointIdentity:ee.rollbackCursor?.checkpoint,savedCheckpointOccurrences:ee.savedCheckpointOccurrences})}})}catch($){throw ip(R),$}}),ui=(I,S,R,$={})=>{if(I===Hu)return ci(()=>{let L=fs(R),Y=Xs({[I]:S},L);return pi(Y[I],R,$)},$);Nt(I,S)},ap=(I,S)=>{ui(I,S)},fs=I=>{if(!I)return{variables:r.selectAllVariables?r.selectAllVariables():void 0,runtime:r.selectRuntime?r.selectRuntime():{}};if(Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".');let{_event:S,...R}=I,$=r.selectAllVariables?r.selectAllVariables():void 0;return{...R,_event:S,variables:$,runtime:r.selectRuntime?r.selectRuntime():{}}},lp=I=>{if(!Ue(I))return{templatePayload:I,literalTargetIds:null};let S=r.selectImageGalleryConfig();if(!Array.isArray(S?.groups))return{templatePayload:I,literalTargetIds:null};let R=typeof I.groupId=="string"?S.groups.find(L=>L.id===I.groupId):void 0;if(!R)return{templatePayload:I,literalTargetIds:null};let $=typeof I.variantId=="string"&&R.variants.some(L=>L.id===I.variantId);return{templatePayload:{...I,groupId:null,...$?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...$?{variantId:I.variantId}:{}}}},cp=I=>!Ue(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:r.selectMusicRoomConfig()?.tracks?.some($=>$.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},up=I=>!Ue(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:r.selectSceneReplayConfig()?.replays?.some($=>$.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},pp=I=>{if(!Ue(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")},fp=(I,S,R)=>{if(!Ue(I))throw new Error(`conditional branch at index ${S} must be an object`);if(!Ue(I.actions))throw new Error(`conditional branch at index ${S} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&S!==R-1)throw new Error("conditional else branch must be the last branch")},pi=(I,S,R)=>{pp(I);let $=Zr(R);for(let L=0;L<I.branches.length;L+=1){let Y=I.branches[L];fp(Y,L,I.branches.length);let Q=fs(S);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!it(Y.when,Q))continue;let Ee=ds(Y.actions,S,R);return us(Ee)?et($,Ee):$}return $},dp=(I,S)=>({...I??{},_form:S}),mp=(I,S,R,$)=>{let L=Nt(I,S),Y=L?.submitted===!0&&L.valid===!0,Q=L?.cancelled===!0;if(!(!Y&&!Q)&&Ue(S.actions))return ds(S.actions,dp(R,L.form),{...$,interactionSource:ti})},yp=(I,S,R,$)=>{let L=fs(R),Y={templatePayload:S,literalTargetIds:null};I===k0?Y=lp(S):I===P0?Y=cp(S):I===x0&&(Y=up(S));let{templatePayload:Q,literalTargetIds:ee}=Y,Le=Xs({[I]:Q},L)[I],$r=ee?{...Le,...ee}:Le;if(I===Hu)return pi($r,R,$);let _r=Qr(I,$r,$);if(A0.has(I))return mp(I,_r,R,$);Nt(I,_r)},ds=(I,S,R)=>{let $;return Object.entries(I).forEach(([L,Y])=>{let Q=yp(L,Y,S,R);us(Q)&&($=et($,Q))}),$},fi=(I,S,R={})=>ci(()=>ds(I,S,R),R),hp=I=>{let S=r.selectCurrentPointer()?.pointer;if(I!==S||r.selectActiveInteraction())return;let R=r.selectNextLineConfig();R?.auto?.enabled&&R.auto.trigger==="fromStart"&&r.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:R.auto.delay}})};return{init:v,handleAction:ui,handleInternalAction:ap,handleActions:fi,selectRenderState:T,prepareRenderState:q,commitRenderState:le,selectPresentationState:x,selectPresentationChanges:C,selectSectionLineChanges:N,selectSystemState:B,selectAchievements:ne,selectAchievement:oe,selectSaveSlotMap:de,selectSaveSlot:ve,selectSaveSlotPage:ce,selectSaveSlots:de,selectImageGallery:se,selectMusicRoom:ue,selectSceneReplay:ie,selectIsSceneReplayActive:O,selectRuntime:Z,selectIsChoiceVisible:ge,selectIsFormVisible:K,selectActiveInteraction:xe,selectHasPendingRenderWork:ye,handleLineActions:I=>{if(typeof I?.sceneReplaySceneId=="string"){let S=r.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return E(()=>{let S=r.selectCurrentPointer()?.pointer,R=r.selectRollbackCursor?.()??null,$=l,L=jt(S,R),Y=r.selectCurrentLine(),Q=!1;if(Y?.actions){try{fi(Y.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:L})}catch(ee){throw l=$,ee}Q=!0}return hp(S),Q})},getNamespace:k}}var ii=()=>{let e=0,r=null;return{getElapsed:()=>e,setElapsed:n=>{e=n},addElapsed:n=>{e+=n},getCallback:()=>r,setCallback:n=>{r=n}}},E0=80,S0="music-room:player",Qu=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Ku=(e,r)=>Qu.has(e)&&r?._event?.id===S0,Zu=({engine:e,routeGraphics:r,trackRenderDispatch:n},o)=>{if(e.selectHasPendingRenderWork?.())return;let a=e.prepareRenderState?.(o)??e.selectRenderState(o);n?.(a),r.render(a),e.commitRenderState?.(a)},R0=({engine:e,routeGraphics:r,trackRenderDispatch:n,getRenderDispatchCount:o},a)=>{let t=o?.()??0,s=e.handleLineActions(a);(o?.()??0)===t&&Zu({engine:e,routeGraphics:r,trackRenderDispatch:n},a)},O0=({engine:e,ticker:r,autoTimer:n},o)=>{let a=n.getCallback();a&&r.remove(a),n.setElapsed(0);let t=s=>{n.addElapsed(s.deltaMS);let i=o.delay??1e3;n.getElapsed()>=i&&(r.remove(t),n.setCallback(null),n.setElapsed(0),_t(e,"nextLineFromSystem",{}))};n.setCallback(t),r.add(t)},C0=({ticker:e,autoTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},$0=({engine:e,ticker:r,skipTimer:n},o)=>{let a=n.getCallback();a&&r.remove(a),n.setElapsed(0);let t=s=>{n.addElapsed(s.deltaMS);let i=o?.delay??E0;n.getElapsed()>=i&&(n.setElapsed(0),_t(e,"nextLineFromSystem",{}))};n.setCallback(t),r.add(t)},_0=({ticker:e,skipTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},j0=({engine:e,ticker:r,nextLineConfigTimerState:n},o)=>{let a=n.getCallback();a&&r.remove(a),n.setElapsed(0);let t=s=>{n.addElapsed(s.deltaMS);let i=o.delay??1e3;n.getElapsed()>=i&&(n.setElapsed(0),_t(e,"nextLineFromSystem",{}),r.remove(t),n.getCallback()===t&&n.setCallback(null))};n.setCallback(t),r.add(t)},N0=({ticker:e,nextLineConfigTimerState:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},D0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveSlots(r?.saveSlots))},T0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalDeviceVariables(r?.globalDeviceVariables))},L0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalAccountVariables(r?.globalAccountVariables))},M0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalRuntime(r?.globalRuntime))},q0=({enqueuePersistenceWrite:e},r)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(r?.updates)})},Ju={render:Zu,saveSlots:D0,saveGlobalDeviceVariables:T0,saveGlobalAccountVariables:L0,saveGlobalRuntime:M0,applyScopedDataUpdates:q0,handleLineActions:R0,startAutoNextTimer:O0,clearAutoNextTimer:C0,startSkipNextTimer:$0,clearSkipNextTimer:_0,nextLineConfigTimer:j0,clearNextLineConfigTimer:N0},V0=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),_t=(e,r,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(r,n)},F0=(e=[])=>{let r=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(!V0.has(a.name)){n.unshift(a);continue}r.has(a.name)||(r.add(a.name),n.unshift(a))}return n},U0=({getEngine:e,routeGraphics:r,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:t,persistence:s,namespace:i})=>{let l=ii(),u=ii(),c=ii(),p=s??null,m=Promise.resolve(),d=null,f=null,y=!1,g=0,h=O=>{if(a){a(O);return}console.error("RouteEngine persistence write failed.",O)},w=()=>{if(p)return p;let O=e();return p=Zo({indexedDB:t,namespace:i??O?.getNamespace?.()}),p},b=O=>{m=m.catch(()=>{}).then(()=>{let j=w();return O(j)}).catch(j=>{h(j)})},E=O=>{let j=typeof O?.id=="string"&&O.id.length>0?O.id:null;g+=1,d=j,y=!1},v=()=>g,k=(O={})=>{if(O?.aborted===!0)return!1;let j=typeof O?.id=="string"&&O.id.length>0?O.id:null;return j?j!==d||j===f?!1:(f=j,!0):d!==null||y?!1:(y=!0,!0)},x=(O,j={})=>{if(Ku(O,j)){let Z=Qu.get(O),ge=e();return _t(ge,Z,j?._event),!0}if(O!=="renderComplete"||!k(j))return!1;let M=e();return _t(M,"markLineCompleted",{}),!0},C=new Set(["updateFormField","submitForm","cancelForm"]),N=new Set(["updateVariable"]),P=O=>typeof O?.selectActiveInteraction=="function"?O.selectActiveInteraction():typeof O?.selectIsChoiceVisible=="function"&&O.selectIsChoiceVisible()?{source:"choice"}:null,T=O=>O?._formKey??O?.formKey,q=(O,j)=>T(O)===j?.formKey,le=(O,j)=>!O||typeof O!="object"||Array.isArray(O)?!1:O._interactionSource===j?.source,B=(O,j)=>le(O,j)?j.source==="form"?q(O,j):!0:!1,ne=(O,j)=>!O||typeof O!="object"||Array.isArray(O)||j?.source!=="form"?!1:q(O,j),oe=(O={})=>Object.keys(O).some(j=>C.has(j)),de=(O={},j)=>Object.entries(O).some(([M,Z])=>C.has(M)&&ne(Z,j)),ve=(O={})=>Object.keys(O).length>0&&Object.keys(O).every(j=>N.has(j)),ce=(O={},j)=>{let M=O?.actions;return j?.source==="form"?!M||typeof M!="object"||Array.isArray(M)?!1:de(M,j)?!0:oe(M)?!1:ve(M):B(O,j)?!0:!M||typeof M!="object"||Array.isArray(M)?!1:Object.values(M).some(Z=>B(Z,j))},se=(O,j={})=>{if(!j?.actions)return!1;let M=P(O);return!M||M.source==="choice"?!1:!ce(j,M)},ue=({preprocessPayload:O,onEvent:j}={})=>async(M,Z={})=>{if(Ku(M,Z))return x(M,Z),j?.(M,Z);let ge=e();if(se(ge,Z))return j?.(M,Z);let K=await O?.(M,Z)??Z;if(se(ge,K))return j?.(M,K);if(x(M,K),K?.actions){let xe=K?._event?{_event:K._event}:K?.event?{_event:K.event}:void 0,ye;K?.bypassChoice===!0?ye={bypassChoice:!0}:K?._interactionSource&&(ye={interactionSource:K._interactionSource}),ye?ge.handleActions(K.actions,xe,ye):ge.handleActions(K.actions,xe)}return j?.(M,K)},ie=O=>{let j=e(),M=F0(O),Z=M.some(K=>K.name==="handleLineActions");M.forEach(K=>{if(!Ju[K.name]&&!o)throw new Error(`Unhandled pending effect "${K.name}".`)});let ge={engine:j,routeGraphics:r,ticker:n,autoTimer:l,skipTimer:u,nextLineConfigTimerState:c,trackRenderDispatch:E,getRenderDispatchCount:v,enqueuePersistenceWrite:b};for(let K of M){if(Z&&K.name==="render")continue;let xe=Ju[K.name];if(xe){xe(ge,K.payload);continue}o(K,ge)}};return ie.handleRouteGraphicsEvent=x,ie.createRouteGraphicsEventHandler=ue,ie},B0=U0;var Y0=(e,r={})=>{let{resources:n={}}=r;return Io(e,n)};var SI=oi;export{Qs as DEFAULT_VISUAL_LAYER,Mr as RENDER_LAYER,Xe as VISUAL_LAYER,B0 as createEffectsHandler,Sb as createIndexedDbPersistence,SI as default,Ys as formatDate,Bf as resolveComputedVariables,Y0 as resolveLayoutReferences};
|
|
1
|
+
var jp=Object.defineProperty;var Np=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Dp=(e,t)=>{for(var n in t)jp(e,n,{get:t[n],enumerable:!0})};var Gc=Np(lo=>{"use strict";Object.defineProperty(lo,"__esModule",{value:!0});function zc(e){let t=e.length,n=0,i=0,a;for(;i<t;)n++,a=e.charCodeAt(i++),a>=55296&&a<=56319&&i<t&&(a=e.charCodeAt(i),(a&64512)===56320&&i++);return n}lo.default=zc;zc.code='require("ajv/dist/runtime/ucs2length").default'});var So=Symbol.for("immer-nothing"),Ao=Symbol.for("immer-draftable"),Se=Symbol.for("immer-state");function Te(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Br=Object.getPrototypeOf;function he(e){return!!e&&!!e[Se]}function kr(e){return e?Ro(e)||Array.isArray(e)||!!e[Ao]||!!e.constructor?.[Ao]||Wt(e)||Kt(e):!1}var Tp=Object.prototype.constructor.toString();function Ro(e){if(!e||typeof e!="object")return!1;let t=Br(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)===Tp}function Ht(e){return he(e)||Te(15,e),e[Se].base_}function Yt(e,t){Xt(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,i)=>t(i,n,e))}function Xt(e){let t=e[Se];return t?t.type_:Array.isArray(e)?1:Wt(e)?2:Kt(e)?3:0}function xs(e,t){return Xt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Oo(e,t,n){let i=Xt(e);i===2?e.set(t,n):i===3?e.add(n):e[t]=n}function Lp(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Wt(e){return e instanceof Map}function Kt(e){return e instanceof Set}function Ar(e){return e.copy_||e.base_}function Es(e,t){if(Wt(e))return new Map(e);if(Kt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Ro(e);if(t===!0||t==="class_only"&&!n){let i=Object.getOwnPropertyDescriptors(e);delete i[Se];let a=Reflect.ownKeys(i);for(let r=0;r<a.length;r++){let s=a[r],o=i[s];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(i[s]={configurable:!0,writable:!0,enumerable:o.enumerable,value:e[s]})}return Object.create(Br(e),i)}else{let i=Br(e);if(i!==null&&n)return{...e};let a=Object.create(i);return Object.assign(a,e)}}function $s(e,t=!1){return Jt(e)||he(e)||!kr(e)||(Xt(e)>1&&(e.set=e.add=e.clear=e.delete=Mp),Object.freeze(e),t&&Object.entries(e).forEach(([n,i])=>$s(i,!0))),e}function Mp(){Te(2)}function Jt(e){return Object.isFrozen(e)}var qp={};function Pr(e){let t=qp[e];return t||Te(0,e),t}var pt;function Co(){return pt}function Vp(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ko(e,t){t&&(Pr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ss(e){Rs(e),e.drafts_.forEach(Fp),e.drafts_=null}function Rs(e){e===pt&&(pt=e.parent_)}function Po(e){return pt=Vp(pt,e)}function Fp(e){let t=e[Se];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function xo(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Se].modified_&&(Ss(t),Te(4)),kr(e)&&(e=zt(t,e),t.parent_||Gt(t,e)),t.patches_&&Pr("Patches").generateReplacementPatches_(n[Se].base_,e,t.patches_,t.inversePatches_)):e=zt(t,n,[]),Ss(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==So?e:void 0}function zt(e,t,n){if(Jt(t))return t;let i=t[Se];if(!i)return Yt(t,(a,r)=>Eo(e,i,t,a,r,n)),t;if(i.scope_!==e)return t;if(!i.modified_)return Gt(e,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;let a=i.copy_,r=a,s=!1;i.type_===3&&(r=new Set(a),a.clear(),s=!0),Yt(r,(o,l)=>Eo(e,i,a,o,l,n,s)),Gt(e,a,!1),n&&e.patches_&&Pr("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function Eo(e,t,n,i,a,r,s){if(he(a)){let o=r&&t&&t.type_!==3&&!xs(t.assigned_,i)?r.concat(i):void 0,l=zt(e,a,o);if(Oo(n,i,l),he(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(kr(a)&&!Jt(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;zt(e,a),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&Gt(e,a)}}function Gt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&$s(t,n)}function Up(e,t){let n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:Co(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=i,r=_s;n&&(a=[i],r=dt);let{revoke:s,proxy:o}=Proxy.revocable(a,r);return i.draft_=o,i.revoke_=s,o}var _s={get(e,t){if(t===Se)return e;let n=Ar(e);if(!xs(n,t))return Bp(e,n,t);let i=n[t];return e.finalized_||!kr(i)?i:i===ks(e.base_,t)?(Ps(e),e.copy_[t]=Cs(i,e)):i},has(e,t){return t in Ar(e)},ownKeys(e){return Reflect.ownKeys(Ar(e))},set(e,t,n){let i=$o(Ar(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){let a=ks(Ar(e),t),r=a?.[Se];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Lp(n,a)&&(n!==void 0||xs(e.base_,t)))return!0;Ps(e),Os(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 ks(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Ps(e),Os(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Ar(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:n[t]}},defineProperty(){Te(11)},getPrototypeOf(e){return Br(e.base_)},setPrototypeOf(){Te(12)}},dt={};Yt(_s,(e,t)=>{dt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});dt.deleteProperty=function(e,t){return dt.set.call(this,e,t,void 0)};dt.set=function(e,t,n){return _s.set.call(this,e[0],t,n,e[0])};function ks(e,t){let n=e[Se];return(n?Ar(n):e)[t]}function Bp(e,t,n){let i=$o(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function $o(e,t){if(!(t in e))return;let n=Br(e);for(;n;){let i=Object.getOwnPropertyDescriptor(n,t);if(i)return i;n=Br(n)}}function Os(e){e.modified_||(e.modified_=!0,e.parent_&&Os(e.parent_))}function Ps(e){e.copy_||(e.copy_=Es(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Yp=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,i)=>{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"&&Te(6),i!==void 0&&typeof i!="function"&&Te(7);let a;if(kr(t)){let r=Po(this),s=Cs(t,void 0),o=!0;try{a=n(s),o=!1}finally{o?Ss(r):Rs(r)}return ko(r,i),xo(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===So&&(a=void 0),this.autoFreeze_&&$s(a,!0),i){let r=[],s=[];Pr("Patches").generateReplacementPatches_(t,a,r,s),i(r,s)}return a}else Te(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...o)=>this.produceWithPatches(s,l=>t(l,...o));let i,a;return[this.produce(t,n,(s,o)=>{i=s,a=o}),i,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){kr(e)||Te(8),he(e)&&(e=cr(e));let t=Po(this),n=Cs(e,void 0);return n[Se].isManual_=!0,Rs(t),n}finishDraft(e,t){let n=e&&e[Se];(!n||!n.isManual_)&&Te(9);let{scope_:i}=n;return ko(i,t),xo(void 0,i)}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 i=Pr("Patches").applyPatches_;return he(e)?i(e,t):this.produce(e,a=>i(a,t))}};function Cs(e,t){let n=Wt(e)?Pr("MapSet").proxyMap_(e,t):Kt(e)?Pr("MapSet").proxySet_(e,t):Up(e,t);return(t?t.scope_:Co()).drafts_.push(n),n}function cr(e){return he(e)||Te(10,e),_o(e)}function _o(e){if(!kr(e)||Jt(e))return e;let t=e[Se],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Es(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Es(e,!0);return Yt(n,(i,a)=>{Oo(n,i,_o(a))}),t&&(t.finalized_=!1),n}var Ce=new Yp,js=Ce.produce,b0=Ce.produceWithPatches.bind(Ce),I0=Ce.setAutoFreeze.bind(Ce),w0=Ce.setUseStrictShallowCopy.bind(Ce),v0=Ce.applyPatches.bind(Ce),A0=Ce.createDraft.bind(Ce),k0=Ce.finishDraft.bind(Ce);var A={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},Y={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Yr={NOT:0};var _=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},ke=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Ns=e=>{if(!e||e.trim()==="")throw new _("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new _(`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 _(`Incomplete comparison expression - missing right operand (got: '${e}')`)},jo=e=>{if(e.trim().endsWith(" in"))throw new _(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new _(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new _(`Missing iterable expression after 'in' (got: '$for ${e}')`);let i=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of i){if(!a)throw new _(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new _(`Invalid loop syntax (got: '$for ${e}')`)}};var No=(e,t,n=!1)=>{if(t===null)return new ke(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new ke(`Cannot iterate over undefined value at '$for ${e}'`);let i=typeof t;return n?new ke(`Cannot iterate over non-array value in loop '${e}' - got ${i} instead`):new ke(`Cannot iterate over non-array value (got: ${i}) at '$for ${e}'`)},Do=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new ke(`Unknown function '${e}' (${n})`)};var zp=(e,t,n={})=>{let i={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(i=n.functions||{},a=n.partials||{}):typeof n=="object"&&(i=n));let s=H(e,{functions:i,partials:a},t,{});return s===void 0?{}:s},H=(e,t,n,i)=>{let a=t.functions||t;if(e.var&&!e.type)return me(e.var,n,i);if(e.type===A.LITERAL)return e.value;if(e.type===A.VARIABLE)return me(e.path,n,i);if(e.type===A.INTERPOLATION)return Hp(e.parts,t,n,i);switch(e.type){case A.FUNCTION:return Lo(e,t,n,i);case A.BINARY:return Mo(e,t,n,i);case A.UNARY:return qo(e,t,n,i);case A.CONDITIONAL:return Wp(e,t,n,i);case A.LOOP:return ed(e,t,n,i);case A.OBJECT:return td(e,t,n,i);case A.ARRAY:return nd(e,t,n,i);case A.PARTIAL:return sd(e,t,n,i);case A.PATH_REFERENCE:return id(e,t,n,i);default:throw new Error(`Unknown node type: ${e.type}`)}},To=new Map,Gp=e=>{let t=[],n="",i=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")n&&(t.push({type:"property",value:n}),n=""),i=!0;else if(r==="]"){if(i&&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 o=s.slice(1,-1);t.push({type:"property",value:o})}else t.push({type:"property",value:s});n=""}i=!1}else n+=r}return n&&t.push({type:"property",value:n}),t},me=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let i=To.get(e);if(!i){let r=[],s="",o=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(o++,s+=c):c==="]"?(o--,s+=c):c==="."&&o===0?s&&(r.push(s),s=""):s+=c}s&&r.push(s),i=[];for(let l of r){let c=Gp(l.trim());i.push(...c)}To.set(e,i)}let a=t;for(let r=0;r<i.length;r++){let s=i[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},Hp=(e,t,n,i)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=H(r,t,n,i);a.push(s!=null?String(s):"")}return a.join("")},Lo=(e,t,n,i)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Do(e.name,a);let s=e.args.map(o=>H(o,t,n,i));return r(...s)},ur=(e,t,n,i)=>{if(e.var&&!e.type)return me(e.var,n,i);switch(e.type){case A.VARIABLE:return me(e.path,n,i);case A.LITERAL:return e.value;case A.BINARY:return Mo(e,t,n,i);case A.UNARY:return qo(e,t,n,i);case A.FUNCTION:return Lo(e,t,n,i);default:return H(e,t,n,i)}},Mo=(e,t,n,i)=>{if(e.op===Y.AND||e.op===Y.OR){let s=ur(e.left,t,n,i),o=ur(e.right,t,n,i);switch(e.op){case Y.AND:return s&&o;case Y.OR:return s||o}}let a=H(e.left,t,n,i),r=H(e.right,t,n,i);switch(e.op){case Y.EQ:return a==r;case Y.NEQ:return a!=r;case Y.GT:return a>r;case Y.LT:return a<r;case Y.GTE:return a>=r;case Y.LTE:return a<=r;case Y.IN:return Array.isArray(r)?r.includes(a):!1;case Y.ADD:if(typeof a!="number"||typeof r!="number")throw new ke(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case Y.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new ke(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},qo=(e,t,n,i)=>{let a=e.op===Yr.NOT?ur(e.operand,t,n,i):H(e.operand,t,n,i);if(e.op===Yr.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Xp=(e,t,n,i)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===A.VARIABLE)if(me(a.path,n,i)){let s=e.bodies[0];if(s.type===A.OBJECT&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?H(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===A.LITERAL)o[c]=u.value;else if(u.type===A.VARIABLE)o[c]=me(u.path,n,i);else if(u.type===A.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===A.VARIABLE){let d=me(m.path,n,i);p.push(d!=null?String(d):"")}else{let d=H(m,t,n,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=H(u,t,n,i)}return o}}else{let s=e.bodies[1];if(s.type===A.OBJECT&&s.properties.length<=5){let o={};for(let l of s.properties){let c=l.parsedKey?H(l.parsedKey,t,n,i):l.key,u=l.value;if(u.type===A.LITERAL)o[c]=u.value;else if(u.type===A.VARIABLE)o[c]=me(u.path,n,i);else if(u.type===A.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===A.VARIABLE){let d=me(m.path,n,i);p.push(d!=null?String(d):"")}else{let d=H(m,t,n,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=H(u,t,n,i)}return o}}}return null},Wp=(e,t,n,i)=>{let a=Xp(e,t,n,i);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let s=e.conditions[r];if(s===null||ur(s,t,n,i))return H(e.bodies[r],t,n,i)}return Vo},Kp=(e,t)=>{let n=e.body,i=e.itemVar;if(n.type===A.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===A.VARIABLE){let a=n.conditions[0].path,r=n.bodies[0];if(a.startsWith(i+".")){let s=a.substring(i.length+1);if(r.type===A.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let o=[];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===A.LITERAL)u[m]=d.value;else if(d.type===A.VARIABLE){let f=d.path;if(f===i)u[m]=c;else if(f.startsWith(i+".")){let y=f.substring(i.length+1);u[m]=c[y]}else return null}else if(d.type===A.INTERPOLATION){let f=[],y=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===A.VARIABLE){let h=g.path;if(h===i)f.push(c!=null?String(c):"");else if(h.startsWith(i+".")){let I=h.substring(i.length+1),b=c[I];f.push(b!=null?String(b):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;u[m]=f.join("")}else return null}o.push(u)}}return o}}}return null},Jp=(e,t)=>{let n=e.body,i=e.itemVar,a=Kp(e,t);if(a!==null)return a;if(n.type===A.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let o of n.properties)if(o.parsedKey)return null;let r=[],s=!0;for(let o of n.properties){let l=o.key,c=o.value;if(c.type===A.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===A.VARIABLE){let u=c.path;if(u===i)r.push({key:l,type:"item"});else if(u.startsWith(i+".")){let p=u.substring(i.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===A.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===A.VARIABLE){let p=u.path;if(p===i)r.push({key:l,type:"item_string"});else if(p.startsWith(i+".")){let m=p.substring(i.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 o=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];o[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):""}o[l]=u}return o}}return null},Qp=(e,t,n,i,a)=>{let r=[],s=e.body;if(s.type===A.OBJECT&&s.fast!==!1){let o=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...i,[o]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=i.__paths__||{});let d=e.iterable.path||"";if(i&&i.__paths__&&d){let f=d.split("."),y=f[0];y in i.__paths__&&(d=i.__paths__[y],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[o]:`${d}[${c}]`,...l&&{[l]:c}};for(let f of s.properties){let y=f.parsedKey?H(f.parsedKey,t,n,m):f.key,g=f.value;if(g.type===A.LITERAL)p[y]=g.value;else if(g.type===A.VARIABLE){let h=g.path;if(h===o)p[y]=u;else if(h===l)p[y]=c;else if(h.startsWith(o+".")){let I=h.substring(o.length+1);!I.includes(".")&&!I.includes("[")?p[y]=u[I]:p[y]=me(h,n,{...i,[o]:u,...l&&{[l]:c}})}else p[y]=me(h,n,{...i,[o]:u,...l&&{[l]:c}})}else if(g.type===A.INTERPOLATION){let h=[];for(let I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=I.path,x;if(b===o)x=u;else if(b===l)x=c;else if(b.startsWith(o+".")){let v=b.substring(o.length+1);!v.includes(".")&&!v.includes("[")?x=u[v]:x=me(b,n,{...i,[o]:u,...l&&{[l]:c}})}else x=me(b,n,{...i,[o]:u,...l&&{[l]:c}});h.push(x!=null?String(x):"")}else{let b={...i,[o]:u,...l&&{[l]:c}},x=H(I,t,n,b);h.push(x!=null?String(x):"")}p[y]=h.join("")}else{let h={...i,[o]:u,...l&&{[l]:c}};p[y]=H(g,t,n,h)}}r.push(p)}return r}return null},Zp=(e,t,n)=>{let i=e.body;if(i.type===A.OBJECT&&i.properties.length===1&&i.properties[0].key==="$if item.visible"){let r=i.properties[0].value;if(r.type===A.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===A.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===A.OBJECT&&s.properties.length===2){let o=s.properties[0],l=s.properties[1];if(o.key==="id"&&o.value.type===A.VARIABLE&&o.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===A.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},ed=(e,t,n,i)=>{let a=H(e.iterable,t,n,i);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===A.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===A.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===A.VARIABLE?d.path:d.type===A.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 No(p,a,u)}if(!e.indexVar){let c=Zp(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=Jp(e,a);if(c!==null)return c}let r=Qp(e,t,n,i,a);if(r!==null)return r;let s=[],o=e.iterable.path||"";if(i&&i.__paths__&&o){let c=o.split("."),u=c[0];u in i.__paths__&&(o=i.__paths__[u],c.length>1&&(o+="."+c.slice(1).join(".")))}let l=!1;e.body.type===A.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===A.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?{...i,[e.itemVar]:a[c],[e.indexVar]:c}:{...i,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=i.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${o}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=H(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},rd=(e,t,n,i)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?H(a.parsedKey,t,n,i):a.key,s=a.value;if(s.type===A.OBJECT&&s.properties.length<=10&&!s.whenCondition){let o={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?H(u.parsedKey,t,n,i):u.key,m=u.value;if(m.type===A.LITERAL)l[p]=m.value;else if(m.type===A.VARIABLE)l[p]=me(m.path,n,i);else if(m.type===A.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===A.VARIABLE){let y=me(f.path,n,i);d.push(y!=null?String(y):"")}else{c=!1;break}if(!c)break;l[p]=d.join("")}else if(m.type===A.OBJECT&&m.properties.length<=5){let d={};for(let f of m.properties){let y=f.key,g=f.value;if(g.type===A.LITERAL)d[y]=g.value;else if(g.type===A.VARIABLE)d[y]=me(g.path,n,i);else if(g.type===A.INTERPOLATION){let h=[];for(let I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=me(I.path,n,i);h.push(b!=null?String(b):"")}else{c=!1;break}if(!c)break;d[y]=h.join("")}else{c=!1;break}}if(!c)break;l[p]=d}else{c=!1;break}}if(c)return o[r]=l,o}}return null},td=(e,t,n,i)=>{let a=t.functions||t;if(e.whenCondition&&!ur(e.whenCondition,a,n,i))return;let r=rd(e,t,n,i);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?H(u.parsedKey,t,n,i):u.key,m=u.value;if(m.type===A.LITERAL)c[p]=m.value;else if(m.type===A.VARIABLE)c[p]=me(m.path,n,i);else if(m.type===A.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===A.VARIABLE){let y=me(f.path,n,i);d.push(y!=null?String(y):"")}else{let y=H(f,t,n,i);d.push(y!=null?String(y):"")}c[p]=d.join("")}else c[p]=H(m,t,n,i)}return c}let s={},o=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=H(c.value,t,n,i);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 H(c.value,t,n,i)}else{let u=c.value;if(u&&u.type===A.OBJECT&&u.properties){let p=u.properties.find(m=>m.key.startsWith("$for "));if(p){let m=H(p.value,t,n,i);m!==void 0&&(s[c.key]=m)}else{let m=H(c.value,t,n,i);m!==void 0&&(s[c.key]=m)}}else{let p=c.parsedKey?H(c.parsedKey,t,n,i):c.key,m=H(c.value,t,n,i);m!==void 0&&(s[p]=m)}}return s},Vo={},nd=(e,t,n,i)=>{let a=[];for(let r of e.items)if(r.type===A.LOOP){let s=H(r,t,n,i);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=H(r,t,n,i);s!==Vo&&s!==void 0&&a.push(s)}return a},sd=(e,t,n,i)=>{let{name:a,data:r,whenCondition:s}=e,o=t.partials||{},l=t.functions||t;if(s&&!ur(s,l,n,i))return;if(!o[a])throw new ke(`Partial '${a}' is not defined`);let c=i._partialStack||[];if(c.includes(a))throw new ke(`Circular partial reference detected: ${a}`);let u=o[a],p=n,m={...i,_partialStack:[...c,a]};if(i){p={...n};for(let d of Object.keys(i))d.startsWith("_")||(p[d]=i[d])}if(r){let d=H(r,t,n,i);p={...p,...d}}return H(u,t,p,m)},id=(e,t,n,i)=>{let{path:a}=e,r=a.split("."),s=r[0],o=r.slice(1);if(!i||!(s in i))throw new ke(`Path reference '#{${a}}' refers to '${s}' which is not a loop variable in the current scope`);if(i.__paths__||(i.__paths__={}),!(s in i.__paths__))throw new ke(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=i.__paths__[s];if(typeof l=="number"){if(o.length>0)throw new ke(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return o.length>0&&(l+="."+o.join(".")),l};var Ds=zp;var od=/\$\{([^}]*)\}/g,ad=/#\{([^}]*)\}/g,Uo=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,i,a]=n,r=ld(a,t);return{isFunction:!0,type:A.FUNCTION,name:i,args:r}},ld=(e,t={})=>e.trim()?cd(e).map(i=>ud(i.trim(),t)):[],cd=e=>{let t=[],n="",i=0,a=!1,r="";for(let s=0;s<e.length;s++){let o=e[s],l=s>0?e[s-1]:"";!a&&(o==='"'||o==="'")?(a=!0,r=o,n+=o):a&&o===r&&l!=="\\"?(a=!1,r="",n+=o):!a&&o==="("?(i++,n+=o):!a&&o===")"?(i--,n+=o):!a&&o===","&&i===0?(t.push(n),n=""):n+=o}return n&&t.push(n),t},ud=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:A.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:A.LITERAL,value:parseFloat(e)};if(e==="true")return{type:A.LITERAL,value:!0};if(e==="false")return{type:A.LITERAL,value:!1};if(e==="null")return{type:A.LITERAL,value:null};let n=Uo(e,t);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let i=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,s=null;for(let{op:o,type:l}of a){let c=0;for(;c<i.length;){let u=xr(i.substring(c),o);if(u===-1)break;let p=c+u;p>r&&(r=p,s={op:o,type:l}),c=p+o.length}}if(r!==-1)try{return ge(i,t)}catch{return{type:A.VARIABLE,path:i}}return{type:A.VARIABLE,path:i}},Bo=/^\w+\(.*\)$/,pd=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,dd=e=>{if(!(!e||e.trim()===""||Bo.test(e))&&pd.test(e))throw e.includes("?")&&e.includes(":")?new _(`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 _(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new _(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Fo=e=>{let t=e.trim();if(Bo.test(t))throw new _(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new _(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new _(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new _(`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 _(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:A.PATH_REFERENCE,path:t}},ft=(e,t={})=>{let n=e.trim();dd(n);let i=Uo(n,t);if(i.isFunction)return{type:i.type,name:i.name,args:i.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:A.VARIABLE,path:n}},Ts=(e,t={})=>{let n=e,i=[];(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_${i.length}__`;return i.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${i.length}__`;return i.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(od)],r=[...n.matchAll(ad)],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<i.length;u++)c=c.replace(`__ESCAPED_${u}__`,i[u]);return{type:A.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&i.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?ft(c[1],t):Fo(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:A.LITERAL,value:n};throw p}}let o=[],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 y=0;y<i.length;y++)f=f.replace(`__ESCAPED_${y}__`,i[y]);f&&o.push(f)}try{let f;u==="variable"?f=ft(m.trim(),t):f=Fo(m.trim()),o.push(f)}catch(f){if(f.message==="Invalid array index syntax")o.push(p);else throw f}l=d+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<i.length;u++)c=c.replace(`__ESCAPED_${u}__`,i[u]);c&&o.push(c)}return{type:A.INTERPOLATION,parts:o}};var qs=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Go=e=>Object.keys(e),Ae=e=>e.join("."),pr=(e,t,n)=>{let i=Go(e).filter(a=>!t.has(a));if(i.length>0)throw new _(`Unexpected key '${i[0]}' in condition JSON at '${Ae(n)}'`)},dr=(e,t)=>typeof e=="string"?Ts(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?md(e,t):yd(e,t):{type:A.LITERAL,value:e},fd=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new _("$each value must be a non-empty string");let i=t.trim();if(i==="")throw new _("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new _("Empty $each body not allowed");if(n.$partial!==void 0)throw new _("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${i}`]:n}},md=(e,t)=>{let n=[],i=!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=fd(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=zo(c[0],l[c[0]],t,!0);n.push(u),i=!0;continue}}catch(l){throw l instanceof _?l:new _(l.message)}let o=Object.keys(r);if(o.length===1&&/^\$for(?::\w+)?\s/.test(o[0])){let l=zo(o[0],r[o[0]],t);n.push(l),i=!0;continue}}let s=dr(r,t);n.push(s),(s.type===A.FUNCTION||s.type===A.CONDITIONAL||s.type===A.LOOP||s.type===A.PARTIAL||s.type===A.OBJECT&&!s.fast||s.type===A.ARRAY&&!s.fast)&&(i=!0)}return{type:A.ARRAY,items:n,fast:!i}},yd=(e,t)=>{let n=[],i=!1,a=null,r=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new _("$partial value must be a string");if(e.$partial.trim()==="")throw new _("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[h]of r)for(let I of l)if(h===I||h.startsWith(I+" ")||h.startsWith(I+"#")){c.push(I);break}if(c.length>0)throw new _(`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[h,I]of Object.entries(m)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),d[b]=I,f=!0}let y=null;if(f&&(y=dr(d,t),y.type===A.OBJECT)){let h=!1;for(let I of y.properties)if(I.value.type===A.VARIABLE||I.value.type===A.INTERPOLATION||I.value.type===A.FUNCTION||I.value.type===A.CONDITIONAL||I.value.type===A.OBJECT&&!I.value.fast||I.value.type===A.ARRAY&&!I.value.fast){h=!0;break}h&&(y.fast=!1)}let g={type:A.PARTIAL,name:u,data:y};return p!==void 0&&(g.whenCondition=Yo(p,t)),g}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new _("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new _("Missing condition expression after '$when'");a=Yo(c,t),i=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new _("'$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 _("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=hd(r,s,t);n.push({key:l,value:u.node}),i=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new _(`$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 _(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new _("Missing condition expression after '$if'");{let u=dr(c,t);(u.type===A.FUNCTION||u.type===A.CONDITIONAL||u.type===A.PARTIAL||u.type===A.OBJECT&&!u.fast||u.type===A.ARRAY&&!u.fast)&&(i=!0);let p=Ts(l,t),m={key:l,value:u};(p.type!==A.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let o={type:A.OBJECT,properties:n,fast:!i};return a&&(o.whenCondition=a),o},hd=(e,t,n={})=>{let i=[],a=[],r=t,[s,o]=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 _(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Ns(c);let u=ge(c,n);for(i.push(u),a.push(dr(o,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)i.push(null);else{Ns(f);let y=ge(f,n);i.push(y)}if(a.push(dr(m,n)),r++,f===null)break}else break}return{node:{type:A.CONDITIONAL,conditions:i,bodies:a,id:l},nextIndex:r}},Ls={eq:Y.EQ,neq:Y.NEQ,gt:Y.GT,gte:Y.GTE,lt:Y.LT,lte:Y.LTE,in:Y.IN,add:Y.ADD,sub:Y.SUBTRACT},Ms={all:Y.AND,any:Y.OR},gd=new Set(["var","literal","call","not",...Object.keys(Ls),...Object.keys(Ms)]),bd=(e,t,n)=>{if(!Array.isArray(e))throw new _(`Condition JSON operator '${t}' at '${Ae(n)}' requires an array`);if(e.length!==2)throw new _(`Condition JSON operator '${t}' at '${Ae(n)}' requires exactly 2 operands`);return e},Id=(e,t,n,i,a)=>{if(!Array.isArray(e))throw new _(`Condition JSON operator '${t}' at '${Ae(a)}' requires an array`);if(e.length===0)throw new _(`Condition JSON operator '${t}' at '${Ae(a)}' requires at least 1 condition`);return e.map((s,o)=>Re(s,i,[...a,o])).reduce((s,o)=>({type:A.BINARY,op:n,left:s,right:o}))},wd=(e,t,n)=>{let i,a;if(typeof e.call=="string")i=e.call,a=e.args??[],pr(e,new Set(["call","args"]),n);else if(qs(e.call))i=e.call.name,a=e.call.args??[],pr(e,new Set(["call"]),n),pr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new _(`Condition JSON call at '${Ae(n)}' requires a function name`);if(typeof i!="string"||i.trim()==="")throw new _(`Condition JSON call at '${Ae(n)}' requires a non-empty function name`);if(!/^\w+$/.test(i))throw new _(`Invalid condition JSON function name '${i}' at '${Ae(n)}'`);if(!Array.isArray(a))throw new _(`Condition JSON call '${i}' at '${Ae(n)}' requires args to be an array`);return{type:A.FUNCTION,name:i,args:a.map((r,s)=>Re(r,t,[...n,"args",s]))}},Re=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:A.LITERAL,value:e};if(Array.isArray(e))throw new _(`Condition JSON array at '${Ae(n)}' must be wrapped in an operator or { literal: [...] }`);if(!qs(e))throw new _(`Invalid condition JSON value at '${Ae(n)}'`);let i=Go(e);if(i.length===0)throw new _(`Condition JSON object at '${Ae(n)}' must contain an operator`);let a=i.filter(s=>gd.has(s));if(a.length===0)throw new _(`Unknown condition JSON operator '${i[0]}' at '${Ae(n)}'`);if(a.length>1)throw new _(`Condition JSON at '${Ae(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(pr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new _(`Condition JSON var at '${Ae(n)}' requires a non-empty path`);return{type:A.VARIABLE,path:e.var}}if(r==="literal")return pr(e,new Set(["literal"]),n),{type:A.LITERAL,value:e.literal};if(r==="call")return wd(e,t,n);if(r==="not")return pr(e,new Set(["not"]),n),{type:A.UNARY,op:Yr.NOT,operand:Re(e.not,t,[...n,"not"])};if(r in Ms)return pr(e,new Set([r]),n),Id(e[r],r,Ms[r],t,[...n,r]);if(r in Ls){pr(e,new Set([r]),n);let s=bd(e[r],r,[...n,r]);return{type:A.BINARY,op:Ls[r],left:Re(s[0],t,[...n,r,0]),right:Re(s[1],t,[...n,r,1])}}throw new _(`Unknown condition JSON operator '${r}' at '${Ae(n)}'`)},Yo=(e,t={})=>{if(e==null)throw new _("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new _("Empty condition expression after '$when'");return ge(e,t)}return qs(e)||Array.isArray(e)?Re(e,t):{type:A.LITERAL,value:e}},ge=(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 ge(c,t)}let n=xr(e,"||");if(n!==-1)return{type:A.BINARY,op:Y.OR,left:ge(e.substring(0,n).trim(),t),right:ge(e.substring(n+2).trim(),t)};let i=xr(e,"&&");if(i!==-1)return{type:A.BINARY,op:Y.AND,left:ge(e.substring(0,i).trim(),t),right:ge(e.substring(i+2).trim(),t)};let a=[{op:">=",type:Y.GTE},{op:"<=",type:Y.LTE},{op:"==",type:Y.EQ},{op:"!=",type:Y.NEQ},{op:">",type:Y.GT},{op:"<",type:Y.LT},{op:" in ",type:Y.IN}];for(let{op:c,type:u}of a){let p=xr(e,c);if(p!==-1)return{type:A.BINARY,op:u,left:ge(e.substring(0,p).trim(),t),right:ge(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,o=[{op:" + ",type:Y.ADD},{op:" - ",type:Y.SUBTRACT}];for(let{op:c,type:u}of o){let p=0;for(;p<e.length;){let m=xr(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:A.BINARY,op:s.type,left:ge(e.substring(0,r).trim(),t),right:ge(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(xr(e,c)!==-1)throw new _(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:A.UNARY,op:Yr.NOT,operand:ge(e.substring(1).trim(),t)}:Ho(e,t)},xr=(e,t)=>{let n=0,i=0;for(;i<=e.length-t.length;){if(e[i]==="(")n++;else if(e[i]===")")n--;else if(n===0&&e.substring(i,i+t.length)===t)return i;i++}return-1},vd=e=>{if(e=e.trim(),e==="true")return{type:A.LITERAL,value:!0};if(e==="false")return{type:A.LITERAL,value:!1};if(e==="null")return{type:A.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:A.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:A.LITERAL,value:""};if(e==="{}")return{type:A.LITERAL,value:{}};if(e==="[]")return{type:A.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:A.LITERAL,value:t}:{type:A.VARIABLE,path:e}},Ho=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return ft(n,t);let a=vd(n);if(a.type===A.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:A.VARIABLE,path:n};try{return ft(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Ad=(e,t=!1)=>{let n=t?"$each":"$for";try{jo(e)}catch(i){if(i instanceof _&&t){let a=i.message.replace(/\$for/g,"$each");throw new _(a.replace("Parse Error: ",""))}throw i}},zo=(e,t,n,i=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let g=i?"$each":"$for";throw new _(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=r[1],o=r[2].trim();Ad(o,i);let l=o.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=i?"$each":"$for";throw new _(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${o}')`)}let c=l[1].trim(),u=l[2].trim(),p,m=null;if(c.includes(",")){let g=c.split(",").map(h=>h.trim());if(g.length!==2)throw new _(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=g[0],m=g[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new _(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new _(`Reserved variable name: ${m}`);let f=Ho(u,n),y=dr(t,n);return{type:A.LOOP,itemVar:p,indexVar:m,iterable:f,body:y,flatten:s!=="nested"}};var kd=(e,t={})=>{let{functions:n={}}=t;return dr(e,n)},Qt=kd;var mt={};Dp(mt,{now:()=>Pd});var Pd=()=>Date.now();var xd=(e,t,n={})=>{let{functions:i={},partials:a={}}=n,r={...mt,...i},s=Qt(e,{functions:r}),o={};for(let[l,c]of Object.entries(a))o[l]=Qt(c,{functions:r});return Ds(s,t,{functions:r,partials:o})},Er=xd;var Ed=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Sd=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Rd=(e,t)=>{if(Ed(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new _("Empty condition expression");return ge(e,t)}return Re(e,t)},Od=(e,t={},n={})=>{let i=Sd(n),a={...mt,...i},r=Rd(e,a);return!!ur(r,{functions:a,partials:{}},t,{})},Vs=Od;var Ws=Symbol("runStoreTransaction"),Ys="__routeEngineConditionComparison",Zt=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",fr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Zt(e,t)&&e>t,gte:(e,t)=>Zt(e,t)&&e>=t,lt:(e,t)=>Zt(e,t)&&e<t,lte:(e,t)=>Zt(e,t)&&e<=t}),ea=Object.freeze(Object.fromEntries(Object.keys(fr).map(e=>[e,`${Ys}${e}`]))),Cd=Object.freeze(Object.fromEntries(Object.entries(ea).map(([e,t])=>[t,fr[e]]))),Xo=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),$d=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},en=e=>{if(Array.isArray(e))return e.map(en);if(e===null||typeof e!="object"||Xo(e,"literal")||Xo(e,"var"))return e;if($d(e)?.startsWith(Ys))throw new Error(`Condition function names beginning with "${Ys}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[i,a]]=n,r=ea[i];if(r)return{call:r,args:a.map(en)}}return Object.fromEntries(n.map(([i,a])=>[i,en(a)]))},ht=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Re(e),Vs(en(e),t,{functions:Cd})},_d=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],ra=(e,t,n={})=>{let i=structuredClone(e),a={},r={},{transformSelectorFirstArgument:s=c=>c,transformActionFirstArgument:o=c=>c}=n;for(let[c,u]of Object.entries(t))c!=="createInitialState"&&(c.startsWith("select")?a[c]=(...p)=>u(s(i),...p):r[c]=(...p)=>{let m;return i=js(i,f=>{let y=u(o(f),...p);m=y!==void 0&&!he(y)?y:void 0}),m});let l=c=>{if(typeof c!="function")throw new Error("Store transaction requires a callback");let u=i;try{return c()}catch(p){throw i=u,p}};return{...a,...r,[Ws]:l}},sn=(e,t)=>n=>{let i=e(),a=Array.isArray(n)?n:[n];return js(i,r=>{a.forEach(s=>{t.forEach(o=>{o(r,s)})})})};var jd=(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{}}},B=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),zs=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},ye=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Nd=new Set(["pageSize","groups"]),Dd=new Set(["id","variants"]),Td=new Set(["id","imageId"]),Ld=new Set(["pageSize","tracks"]),Md=new Set(["id","soundId","title","artist","album","description","coverImageId"]),qd=new Set(["pageSize","replays"]),Vd=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Sr=(e,t,n)=>{Object.keys(e).forEach(i=>{if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)})},zr=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},gt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!ye(t))throw new Error("resources.imageGallery must be an object");if(Sr(t,Nd,"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[i,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${i}]`;if(!ye(a))throw new Error(`${r} must be an object`);if(Sr(a,Dd,r),zr(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[o,l]of a.variants.entries()){let c=`${r}.variants[${o}]`;if(!ye(l))throw new Error(`${c} must be an object`);if(Sr(l,Td,c),zr(l.id,`${c}.id`),zr(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),!B(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(!ye(t))throw new Error("resources.musicRoom must be an object");if(Sr(t,Ld,"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[i,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${i}]`;if(!ye(a))throw new Error(`${r} must be an object`);Sr(a,Md,r);for(let l of["id","soundId","title"])zr(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&zr(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(!B(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!ye(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 o=s.startAt??0;if(typeof o!="number"||!Number.isFinite(o)||o<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<=o))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!B(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Fd=(e,t,n)=>{let i=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 ${i}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${i}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${i}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${i}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},It=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!ye(t))throw new Error("resources.sceneReplay must be an object");if(Sr(t,qd,"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??{},i=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!ye(r))throw new Error(`${s} must be an object`);Sr(r,Vd,s);for(let u of["sceneId","title","thumbnailImageId"])zr(r[u],`${s}.${u}`);if(i.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(i.add(r.sceneId),!B(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let o=n[r.sceneId];if(!o)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=o.initialSectionId,c=o.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(!ye(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(qe(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}"`);Fd(u,m,p)}}}},ta=e=>{let t=he(e)?cr(e):e;return structuredClone(t)},Ud=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!B(t,"nameVariableId"))return;let i=t.nameVariableId,a=n?.[i];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${i}" must resolve to a string variable`);return a},on=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0;if(t?.name!==void 0)return t.name;if(n!==void 0)return n;let s=Ud({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},qe=e=>B(e,"computed"),Gr=(e={},t={})=>Object.fromEntries(Object.entries(e??{}).filter(([n])=>!qe(t[n]))),Me=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),Bd=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Me(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 Me(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Me(t,n);let o=e[r];if(o==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Me(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
+
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!B(l,o))throw Me(t,n);a+=l[o]}return a},na=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Me(e,t);let n=[],i=0,a=()=>{let s=i;for(;i<e.length&&e[i]!=="."&&e[i]!=="["&&e[i]!=="]";)i+=1;let o=e.slice(s,i);if(o.length===0||o.trim()!==o||/\s/.test(o))throw Me(e,t);n.push(o)},r=()=>{for(i+=1;i<e.length&&/\s/.test(e[i]);)i+=1;let s=e[i];if(/\d/.test(s??"")){let u=i;for(;i<e.length&&/\d/.test(e[i]);)i+=1;let p=e.slice(u,i);for(;i<e.length&&/\s/.test(e[i]);)i+=1;if(e[i]!=="]"||p.length>1&&p.startsWith("0"))throw Me(e,t);i+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Me(e,t);let o=s,l=i;i+=1;let c=!1;for(;i<e.length;){let u=e[i];if(c)c=!1;else if(u==="\\")c=!0;else if(u===o){let p=e.slice(l,i+1);for(i+=1;i<e.length&&/\s/.test(e[i]);)i+=1;if(e[i]!=="]")throw Me(e,t);i+=1,n.push(Bd(p,e,t));return}i+=1}if(c||i>=e.length)throw Me(e,t)};for(a();i<e.length;){if(e[i]==="."){i+=1,a();continue}if(e[i]==="["){r();continue}throw Me(e,t)}return n},Fs=(e,t)=>{let n=e;for(let i of t){if(n==null||!B(n,i))return;n=n[i]}return n},sa=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=na(e),[i,a,...r]=n;if(i==="variables"){if(!a)return t.variables;let s=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return Fs(s,r)}return i==="runtime"?Fs(t.runtime,n.slice(1)):Fs(t,n)},ia=(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)`)},Gs=(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`)},Yd=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Fe=(e,t,n,i)=>(ia(e,t,i),t.map(a=>nn(a,n))),Le=(e,t,n,i)=>{let a=Fe(e,t,n,i);return a.forEach(r=>Yd(e,r)),a},zd=(e,t,n)=>{switch(e){case"var":return sa(t,n);case"add":{let[i,a]=Le(e,t,n,2);return i+a}case"sub":{let[i,a]=Le(e,t,n,2);return i-a}case"mul":{let[i,a]=Le(e,t,n,2);return i*a}case"div":{let[i,a]=Le(e,t,n,2);return i/a}case"mod":{let[i,a]=Le(e,t,n,2);return i%a}case"neg":{let[i]=Le(e,t,n,1);return-i}case"round":{let[i]=Le(e,t,n,1);return Math.round(i)}case"floor":{let[i]=Le(e,t,n,1);return Math.floor(i)}case"ceil":{let[i]=Le(e,t,n,1);return Math.ceil(i)}case"min":{let[i,a]=Le(e,t,n,2);return Math.min(i,a)}case"max":{let[i,a]=Le(e,t,n,2);return Math.max(i,a)}case"clamp":{let[i,a,r]=Le(e,t,n,3);return Math.min(r,Math.max(a,i))}case"eq":{let[i,a]=Fe(e,t,n,2);return fr.eq(i,a)}case"neq":{let[i,a]=Fe(e,t,n,2);return fr.neq(i,a)}case"gt":{let[i,a]=Fe(e,t,n,2);return fr.gt(i,a)}case"gte":{let[i,a]=Fe(e,t,n,2);return fr.gte(i,a)}case"lt":{let[i,a]=Fe(e,t,n,2);return fr.lt(i,a)}case"lte":{let[i,a]=Fe(e,t,n,2);return fr.lte(i,a)}case"in":{let[i,a]=Fe(e,t,n,2);return Array.isArray(a)?a.includes(i):!1}case"and":case"all":return Gs(e,t),t.every(i=>!!nn(i,n));case"or":case"any":return Gs(e,t),t.some(i=>!!nn(i,n));case"not":{let[i]=Fe(e,t,n,1);return!i}case"length":{let[i]=Fe(e,t,n,1);return typeof i=="string"||Array.isArray(i)?i.length:ye(i)?Object.keys(i).length:0}case"includes":{let[i,a]=Fe(e,t,n,2);return typeof i=="string"?typeof a=="string"&&i.includes(a):Array.isArray(i)?i.includes(a):!1}case"literal":return ta(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},nn=(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[[i,a]]=n;return zd(i,a,t)},Hs=(e,t)=>{if(e===null||typeof e!="object"||B(e,"literal"))return e;if(B(e,"var"))return{literal:sa(e.var,t)};if(B(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([n,i])=>[n,Array.isArray(i)?i.map(a=>Hs(a,t)):Hs(i,t)]))},Gd=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Re(e),ht(Hs(e,t))},oa=(e,t)=>{if(!ye(e))throw new Error(`${t} must be an object`);let n=B(e,"expr"),i=B(e,"value");if(n===i)throw new Error(`${t} must contain exactly one of expr or value`)},Us=(e,t,n)=>(oa(e,t),B(e,"value")?ta(e.value):nn(e.expr,n)),Hd=(e,t={},n="unknown")=>{if(!ye(e))throw new Error(`Computed variable "${n}" computed must be an object`);let i=B(e,"expr"),a=B(e,"value");if(B(e,"branches")){if(i||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(!ye(e.default))throw new Error(`Computed variable "${n}" requires default`);for(let s=0;s<e.branches.length;s+=1){let o=e.branches[s];if(!ye(o))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!B(o,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Gd(o.when,t))return Us(o,`Computed variable "${n}" branch ${s}`,t)}return Us(e.default,`Computed variable "${n}" default`,t)}if(i===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return Us(e,`Computed variable "${n}"`,t)},aa=(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}`)}},Xd=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}),Wd=new Set(["and","or","all","any"]),Kd=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Jd=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Qd=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Zd=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),la=new WeakMap,Wo=e=>e===null?"null":Array.isArray(e)?"object":typeof e,rn=(e,t,n)=>{for(let i of Object.keys(e))if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)},ef=(e,t,n,i)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${i} expected type ${t}, got ${n}`)},ca=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,o,...l]=na(e,r);if(s!=="variables"&&s!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!o)throw new Error(`${r} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!B(n,o))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${o}"`);let c=n[o];return qe(c)&&i.add(o),l.length===0?c?.type:void 0},ua=(e,{variableId:t,variableConfigs:n,dependencies:i,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 Wo(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,o]]=r;if(s==="var"){if(typeof o!="string"||o.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return ca(o,{variableId:t,variableConfigs:n,dependencies:i,path:a})}if(s==="literal"){if(typeof o=="number"&&!Number.isFinite(o))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Wo(o)}let l=Xd[s];if(l===void 0&&!Wd.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?Gs(s,o):ia(s,o,l);let c=o.map((u,p)=>ua(u,{variableId:t,variableConfigs:n,dependencies:i,path:`${a}.${s}[${p}]`}));if(Jd.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Kd.has(s))return"number";if(Qd.has(s))return"boolean"},rf=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Re(e)}catch(s){throw new Error(`Computed variable "${t}" ${a} is invalid: ${s.message}`,{cause:s})}let r=(s,o)=>{if(s===null||typeof s!="object"||B(s,"literal"))return;if(B(s,"var")){ca(s.var,{variableId:t,variableConfigs:n,dependencies:i,path:o});return}if(B(s,"call"))throw new Error(`Computed variable "${t}" ${o} function calls are not supported`);if(B(s,"not")){r(s.not,`${o}.not`);return}let l=Object.keys(s).find(c=>Zd.has(c));s[l].forEach((c,u)=>{r(c,`${o}.${l}[${u}]`)})};r(e,a)},Bs=(e,{variableId:t,variableConfig:n,variableConfigs:i,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(oa(e,`Computed variable "${t}" ${r}`),rn(e,s,r),B(e,"value")){aa(t,n.type,e.value);return}let o=ua(e.expr,{variableId:t,variableConfigs:i,dependencies:a,path:`${r}.expr`});ef(t,n.type,o,`${r}.expr`)},tf=(e,t,n)=>{let i=t.computed;if(!ye(i))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=B(i,"expr"),s=B(i,"value");if(B(i,"branches")){if(rn(i,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(i.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(i.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!ye(i.default))throw new Error(`Computed variable "${e}" requires default`);return i.branches.forEach((l,c)=>{if(!ye(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(rn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!B(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);rf(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Bs(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Bs(i.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(rn(i,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 Bs(i,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Rr=(e={})=>{if(!ye(e))throw new Error("Variable configs must be an object");if(B(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(B(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(qe(s)){if(!ye(s))throw new Error(`Computed variable "${r}" must be an object`);if(!B(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!B(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(B(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(vt(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,tf(r,s,e))}});let n=new Set,i=[];t.forEach((r,s)=>{if(n.has(s))return;let o=[{variableId:s,dependencies:[...t.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;o.length>0;){let c=o.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){o.pop(),l.delete(c.variableId),n.add(c.variableId),i.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=[...o.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,o.length),o.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(i)});return la.set(e,a),a},wt=({variables:e={},runtime:t={},variableConfigs:n={},eager:i=!0}={})=>{let{evaluationOrder:a}=la.get(n)??Rr(n),r=Gr(e,n),s=Object.entries(n).filter(([,g])=>qe(g)).map(([g])=>g),o=Object.create(null),l=[],c=new Map(a.map((g,h)=>[g,h])),u=-1,p=!1,m=g=>{if(B(o,g))return o[g];let h=n[g];if(!qe(h))return B(r,g)?r[g]:void 0;let I=l.indexOf(g);if(I>=0){let b=[...l.slice(I),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=Hd(h.computed,y,g);return aa(g,h.type,b),zs(o,g,b),b}finally{l.pop()}},d=g=>{if(B(o,g))return o[g];let h=n[g];if(!qe(h))return B(r,g)?r[g]:void 0;let I=c.get(g);if(i&&!p&&I!==void 0&&I>u){p=!0;try{for(let b=u+1;b<=I;b+=1)m(a[b]),u=b}finally{p=!1}return o[g]}return m(g)},f=new Proxy({},{get:(g,h)=>{if(typeof h=="string")return d(h)},has:(g,h)=>typeof h=="string"&&(B(r,h)||s.includes(h)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(g,h)=>{if(!(typeof h!="string"||!B(r,h)&&!s.includes(h)))return{enumerable:!0,configurable:!0}}}),y={variables:f,runtime:t,resolveVariable:d};return i?(s.forEach(g=>{d(g)}),{...r,...o}):f},nf=({variables:e={},runtime:t={},variableConfigs:n,projectData:i}={})=>{let a=n??i?.resources?.variables??{};return Rr(a),wt({variables:e,runtime:t,variableConfigs:a,eager:!0})},an=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([i,a])=>{if(qe(a))return;let r=jd(a,i);a.scope==="context"?zs(t,i,r):zs(n,i,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},vt=(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(", ")}`)},ln=(e,t,n)=>{let i={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=i[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(i).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(", ")}`)},sf=2,Ko=12,pa=(e=sf)=>{if(!Number.isInteger(e)||e<0||e>Ko)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Ko}.`);return e},of=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},tn=e=>typeof e=="number"&&Number.isFinite(e),Ks=(e,t,n,i,a={})=>{if(e==="number"){if(t==="set"&&!tn(n))throw new Error(`Operation "set" requires value to be a number for variable "${i}".`);if(t==="multiply"&&!tn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${i}".`);if(t==="divide"&&!tn(n))throw new Error(`Operation "divide" requires value to be a number for variable "${i}".`);if(t==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${i}".`);pa(a.roundTo)}}},cn=(e,t,n,i={})=>{let a=(s,o,l)=>{let c=s??o;if(!tn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=s=>{let o=a(s,void 0,"value");if(o===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return o};switch(t){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return of(a(e,0,"current value")/r(n),pa(i.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 Js=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),i=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),r={DD:i(n.getDate()),MM:i(n.getMonth()+1),MMM:_d[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:i(n.getHours()),mm:i(n.getMinutes()),ss:i(n.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>r[s])},af=(e,t)=>{let n=r=>r?.ui,i=n(e),a=n(t);return JSON.stringify(i)===JSON.stringify(a)?null:i&&!a?{changeType:"delete",data:e}:a&&!i?{changeType:"add",data:t}:a&&i?{changeType:"update",data:t}:null},yt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,lf=(e,t)=>{let n=e?.character?.sprite,i=t?.character?.sprite,a=yt(n)?n:void 0,r=yt(i)?i: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},Jo=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","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},Qo=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Zo=(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,cf=(e,t)=>{let n={},i=Zo(Jo(e),Jo(t)),a=Zo(Qo(e),Qo(t));return i&&(n.resource=i),a&&(n.color=a),Object.keys(n).length>0?n:null},Qs=(e={},t={})=>{let n={},i=["sfx","voice"],a=l=>{let c=e[l],u=t[l];u&&!c?n[l]={changeType:"add",data:u}:c&&!u?i.includes(l)||(n[l]={changeType:"delete",data:c}):c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},r=cf(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=af(e.dialogue,t.dialogue);s&&(n.dialogue=s);let o=lf(e.dialogue,t.dialogue);return o&&(n.dialogueSprite=o),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},Zs=(e={})=>{let t=structuredClone(e);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 i=(a,r)=>{let s=t[a]?.items;Array.isArray(s)&&(t[a].items=s.map(o=>{let l={...o};return delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return i("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),i("visual",a=>a.resourceId||a.transformId),t},uf=(e,t)=>{if(!e||!t)return;let n=e;for(let i of t.split(".")){if(n==null||!(i in Object(n)))return;n=n[i]}return n},pf=(e,t)=>{if(typeof e!="string")return e;if(e==="_event"){if(t==null)throw new Error('Action template binding "_event" requires event context "_event".');return t}if(!e.startsWith("_event."))return e;if(t==null)throw new Error(`Action template binding "${e}" requires event context "_event".`);let n=e.slice(7),i=uf(t,n);if(i===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "_event".`);return i},df={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"])},ff=(e,t)=>{let n=e[e.length-1];return n?df[n]?.has(t)===!0:!1},Xs=(e,t,n=[])=>Array.isArray(e)?e.map(i=>Xs(i,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,ff(n,i)?a:Xs(a,t,[...n,i])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?pf(e,t._event):Er(e,t):e,ei=(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 Xs(e,t)};var te=e=>structuredClone(he(e)?cr(e):e),W=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),da=e=>e?.animations?.playback?.continuity==="persistent",X=(e,t)=>W(e??{},t)&&e[t]!==void 0,At=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:te(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},mf=e=>X(e,"opacity")||X(e,"blur"),ba=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Ia=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],ri=["animationName","animationSpeed","loop"],yf=e=>ba.some(t=>X(e,t)),wa=e=>e?.text&&X(e.text,"content")&&X(e.text,"textStyleId"),va=e=>X(e,"text"),hf=(e,t)=>e.resourceId?!0:wa(e)?!t?.text:!1,gf=(e,t)=>{let n={...te(e),...t};return t.text&&e.text&&(n.text={...te(e.text),...te(t.text)}),n},bf=(e,t)=>{if(va(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!wa(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},fa=e=>Ia.some(t=>X(e,t)),ma=e=>ri.some(t=>X(e,t)),If=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let i of Ia)!n&&!X(e,i)&&X(t,i)&&(e[i]=t[i]),W(e,i)&&e[i]===void 0&&delete e[i];return e},Aa=(e,t,n)=>{let i=e[n];return i?.id===t?.id?i:e.find(a=>a.id===t?.id)},wf=(e,t)=>{if(!t)return e;for(let n of ba)!X(e,n)&&X(t,n)&&(e[n]=t[n]),W(e,n)&&e[n]===void 0&&delete e[n];return e},vf=(e,t)=>(t&&(!X(e,"opacity")&&X(t,"opacity")&&(e.opacity=t.opacity),!X(e,"blur")&&X(t,"blur")&&(e.blur=te(t.blur)),W(e,"opacity")&&e.opacity===void 0&&delete e.opacity,W(e,"blur")&&e.blur===void 0&&delete e.blur),e),ka=(e,t,n=[],{hasPatchFn:i=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let r=e.map((s,o)=>{let l=Aa(n,s,o),c=t(s,l),u=mf(s),p=yf(s),m=i(s),d=W(s,"animations"),f=te(s);return!c&&(u||p||m)&&l&&(f=a?a(l,f):{...te(l),...f},d||delete f.animations),vf(wf(f,l),l)}).filter(s=>t(s)||s.animations);return{hasValidItems:r.length>0,processedItems:r}},Af=e=>{if(e){if(e.character&&W(e.character,"name"))return e.character.name;if(W(e,"characterName"))return e.characterName}},Pa=e=>!!e?.character&&W(e.character,"sprite"),kf=e=>{let t={},n=!1,i=Af(e);return i!==void 0&&(t.name=i,n=!0),Pa(e)&&(t.sprite=te(e.character.sprite),n=!0),n?t:void 0},ya=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},ha=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>W(t,"persistSprite")?t.persistSprite===!0:W(e,"persistSprite")?e.persistSprite===!0:n&&!W(t,"characterId"),ga=({previousCharacter:e,characterFields:t,hasCharacterId:n,persistCharacter:i,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:s})=>{let o={},l=e??{},c=t??{},u=s&&!n,p=u&&!r;return W(c,"name")?o.name=c.name:(i&&!n||u)&&W(l,"name")&&(o.name=te(l.name)),W(c,"sprite")?o.sprite=te(c.sprite):(a||p)&&W(l,"sprite")&&(o.sprite=te(l.sprite)),Object.keys(o).length>0?o:void 0},Pf=({dialogueState:e,content:t,append:n=!1})=>{if(!n||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let i=Array.isArray(e.content)?e.content:[];i.length>0?e.initialRevealedContent=i.map(a=>te(a)):delete e.initialRevealedContent,e.content=[...i,...t]},xf=()=>({}),Ef=(e,t)=>{if(!t.screen)return;let n=X(t.screen,"opacity"),i=X(t.screen,"blur"),a=W(t.screen,"animations");if(!n&&!i){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=t.screen.opacity:X(r,"opacity")&&(s.opacity=r.opacity),i?s.blur=te(t.screen.blur):X(r,"blur")&&(s.blur=te(r.blur)),W(s,"opacity")&&s.opacity===void 0&&delete s.opacity,W(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},Sf=(e,t)=>{if(t.background){let n=X(t.background,"resourceId"),i=X(t.background,"colorId"),a=X(t.background,"opacity"),r=X(t.background,"blur"),s=X(t.background,"transformId"),o=fa(t.background),l=ma(t.background),{animationsOnly:c,state:u}=At(t.background,d=>X(d,"resourceId")||X(d,"colorId")||X(d,"opacity")||X(d,"blur")||X(d,"transformId")||fa(d)||ma(d));if(c){e.background=e.background?{...te(e.background),...u}:u;return}if(!n&&!i&&!a&&!r&&!s&&!o&&!l){delete e.background;return}let p=e.background,m=te(t.background);if(!n&&p?.resourceId){m.resourceId=p.resourceId,!W(m,"transformId")&&p.transformId&&(m.transformId=p.transformId);for(let d of ri)!X(m,d)&&X(p,d)&&(m[d]=p[d])}If(m,p,{hasAuthoredTransformId:s}),!i&&p?.colorId&&(m.colorId=p.colorId),!a&&X(p,"opacity")&&(m.opacity=p.opacity),!r&&X(p,"blur")&&(m.blur=te(p.blur)),W(m,"resourceId")&&m.resourceId===void 0&&delete m.resourceId,W(m,"colorId")&&m.colorId===void 0&&delete m.colorId,W(m,"animations")&&m.animations===void 0&&delete m.animations,W(m,"transformId")&&m.transformId===void 0&&delete m.transformId,W(m,"opacity")&&m.opacity===void 0&&delete m.opacity,W(m,"blur")&&m.blur===void 0&&delete m.blur;for(let d of ri)W(m,d)&&m[d]===void 0&&delete m[d];if(!m.resourceId&&!m.colorId){delete e.background;return}p?.resourceId===m.resourceId&&p?.transformId===m.transformId&&!W(m,"animations")&&da(p)&&(m.animations=te(p.animations)),e.background=m}else e.background?.animations&&!da(e.background)&&(e.background.animations={})},Rf=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(ya(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=ha({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=ga({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}=At(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 i=t.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&Pf({dialogueState:e.dialogue,content:t.dialogue.content,append:i}),W(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=W(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=ha({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});W(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=W(t.dialogue,"characterId"),o=kf(t.dialogue),l=Pa(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!i&&delete e.dialogue.characterId;let c=ga({previousCharacter:e.dialogue.character,characterFields:o,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:W(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:i});if(c?e.dialogue.character=c:delete e.dialogue.character,l||ya(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=te(e.dialogue.character)),e.dialogue.lines.push(u)}},Of=(e,t)=>{if(t.sfx){let n=Array.isArray(t.sfx.items)&&t.sfx.items.length>0,i=Array.isArray(t.sfx.channels)&&t.sfx.channels.length>0;if(!n&&!i){delete e.sfx;return}e.sfx=te(t.sfx)}else e.sfx&&delete e.sfx},Cf=(e,t)=>{if(t.bgm){let n=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!n||n&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=te(t.bgm),t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},$f=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{bf(r,Aa(n,r,s))});let{hasValidItems:i,processedItems:a}=ka(t.visual.items,hf,n,{hasPatchFn:va,mergeItemFn:gf});i?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations?{...n,animations:{}}:n))},_f=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:i}=ka(t.character.items,a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId,e.character?.items||[]);n?e.character={items:i}:delete e.character},jf=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},Nf=(e,t)=>{if(t.layout){let{animationsOnly:n,state:i}=At(t.layout,a=>!!a.resourceId);if(n){e.layout=i;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},Df=(e,t)=>{if(t.choice){let{animationsOnly:n,state:i}=At(t.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...i};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},Tf=(e,t)=>{if(t.form){let{animationsOnly:n,state:i}=At(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...i};return}if(!t.form.resourceId){delete e.form;return}e.form=te(t.form)}else e.form&&delete e.form},Lf=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},Mf=(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=te(t.voice)}else e.voice&&delete e.voice},qf=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Or=e=>sn(xf,[qf,Ef,Sf,Of,Cf,$f,Rf,_f,jf,Nf,Df,Tf,Lf,Mf])(e);var Hr=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Er(e,t);return n&&typeof n=="object"?e:n};var Vf=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"}}),mr=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}),kt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Ff=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"}),ti=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),xa=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),ni=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Ea=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Uf=(e,t)=>{let n=Ff[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}"`)},un=(e,t)=>{if(Uf(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},si=(e={})=>{let t=e?.config;if(t===void 0)return{...mr};if(!Ea(t))throw new Error("projectData.config must be an object");let n=Object.keys(t).find(o=>o!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let i=t.runtimeDefaults;if(i===void 0)return{...mr};if(!Ea(i))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(xa),r=Object.keys(i).find(o=>!a.has(o));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...mr};return xa.forEach(o=>{i[o]!==void 0&&(s[o]=un(o,i[o]))}),s},Bf=(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),i=Array.isArray(e?.contexts)?e.contexts:[];return i[i.length-1]?.runtime?.[n]}},Cr=e=>Object.fromEntries(Object.entries(Vf).map(([t,n])=>{let i=Bf(e,n.source),a=i!==void 0?i:mr[t]??kt[t];return[t,a]})),yr=(e,t)=>Cr(e)[t],Sa=(e={})=>Object.fromEntries(ti.map(t=>[t,e[t]??mr[t]]));var Xr=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}),er=Object.freeze({BEHIND_BACKGROUND:Xr.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:Xr.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:Xr.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:Xr.VISUAL_BEHIND_CHOICE,FOREGROUND:Xr.VISUAL_FOREGROUND}),ii=er.BEHIND_DIALOGUE,oi=Object.freeze(Object.values(er).sort((e,t)=>e-t));var Yf={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:Js},zf=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Pt=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return Pt(t);let[n]=Object.keys(t),i=zf.exec(n);if(!i)return Pt(t);let[,a,r,s]=i,o=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[o]:Pt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Pt(n)])),tr=(e,t)=>{let n={functions:Yf};return Er(Pt(e),t,n)},ki=({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".`)},Gf=({id:e,targetId:t,animation:n,playback:i,animationPath:a="animation"})=>{let r=structuredClone(n);if(ki({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,i!==void 0){let s=Kf(i,`${a}.playback`);if(s!==void 0){let o=s.loop===!0?Ba(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(o)||o<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=s}}return r},Hf=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return ki({animationType:e.type,animationId:t,animationPath:n}),e.type},Xf=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Wf=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Kf=(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},Jf=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},$r=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Va=e=>e?.playback?.continuity==="persistent",mi=e=>Array.isArray(e)?e.map(mi):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=mi(e[n]),t),{}),mn=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(mi(t))},Fa=(e=[])=>e.filter(t=>Va(t)).map(t=>structuredClone(t)),Ua=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let i=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+i},0):0,ai=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,Ua(n)),0),Ba=e=>Math.max(ai(e?.tween),ai(e?.prev?.tween),ai(e?.next?.tween),Ua(e?.mask?.progress)),Ya=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Ba(e)/Jf(e),Qf=e=>e.some(t=>t?.playback?.loop===!0),Ra=({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(mn).filter(Boolean));return e.some(i=>{if(!Va(i))return!1;let a=mn(i);return a?n.has(a):!1})},Ue=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:Qf(e)||r&&!t||Ra({animationInstances:e,activePersistentAnimations:i})?!0:r?!1:Ra({animationInstances:e,activePersistentAnimations:a}),Zf=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),em=(e,t)=>{if(Zf(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},rm=({resources:e,animationId:t,playback:n,instanceId:i,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?Gf({id:i,targetId:a,animation:s,playback:n,animationPath:r}):null},tm=(e,{defaultTargetId:t,defaultId:n,animationPath:i="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return ki({animationType:a.type,animationId:a.id??n,animationPath:i}),a.id??=n,a.targetId??=t,a},Pi=({animations:e,transitions:t,defaultTargetId:n,idPrefix:i,animationPathPrefix:a=i})=>{t.forEach((r,s)=>{e.push(tm(r,{defaultTargetId:n,defaultId:`${i}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},yi=(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},nm=({content:e,path:t,variables:n})=>yi(e,t).reduce((i,a)=>{let r=Hr(a.text,{variables:n});return i+`${r??""}`.length},0),Oa=(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))},pn=(e,t=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let i=e?.sprites?.map(({resourceId:a})=>a)||[];return i.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${i.join("-")}`},xt=(e,t)=>{if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId`);let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},sm=(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},im=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],om=(e={})=>im.some(t=>$r(e,t)),za=(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"}},fn=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},am=(e={})=>e.textStyles||{},lm=(e={})=>e.images||{},cm=.5,um=(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]},Ga=({id:e,resourceId:t,spritesheet:n,animationName:i,animationSpeed:a,loop:r,transform:s={}}={})=>{let o=um(n,i,t),l=o?n.animations?.[o]:void 0;if(!l){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...s,width:n.width,height:n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:l.frames,animationSpeed:a??l.animationSpeed??cm,loop:r??l.loop??!0}}},Ha=({id:e,item:t,resources:n={}}={})=>{let i=n.images?.[t.resourceId];if(i)return{type:"sprite",id:e,src:i.fileId,width:i.width,height:i.height,x:0,y:0};let a=n.spritesheets?.[t.resourceId];if(a)return Ga({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}`)},pm=(e={})=>e.colors||{},dm=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,St=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,Jr=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},li=(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},ci=(e,t,n,i,{minimum:a}={})=>{if(e===void 0)return i;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},gn=(e,t)=>{if(typeof e!="string"||!dm.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},Ca=(e,t,n)=>{let i=gn(e,n);if(t===1)return i;let a=Number.parseInt(i.slice(1,3),16),r=Number.parseInt(i.slice(3,5),16),s=Number.parseInt(i.slice(5,7),16);return`rgba(${a}, ${r}, ${s}, ${t})`},fm=(e={},t)=>{let n=am(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=li(n.colorAlpha,"colorAlpha",t),o={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:Ca(r.hex,s,`Color "${n.colorId}" for text style "${t}"`)};if(n.align!==void 0&&(o.align=n.align),n.wordWrap!==void 0&&(o.wordWrap=n.wordWrap),n.breakWords!==void 0&&(o.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(o.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=li(n.strokeAlpha,"strokeAlpha",t);o.strokeColor=Ca(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&&(o.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}"`);o.shadow={color:gn(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:li(n.shadow.alpha,"shadow.alpha",t),blur:ci(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:ci(n.shadow.offsetX,"offsetX",t,2),offsetY:ci(n.shadow.offsetY,"offsetY",t,2)}}return o},hi=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>hi(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 i={};for(let[a,r]of Object.entries(e))a!=="textStyleId"&&(i[a]=hi(r,t,St(n,a)));return e.textStyleId!==void 0&&(Jr(e.textStyleId,n,"textStyleId"),i.textStyle=fm(t,e.textStyleId)),i},xi=(e={},t)=>{let n=pm(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return gn(n.hex,`Color "${t}"`)},Xa=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",ui=(e,t,n)=>{let i=e?.[t];if(!(!i||typeof i!="object"||Array.isArray(i))&&Object.prototype.hasOwnProperty.call(i,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${n}". Use ${Xa(`${t}.fill`)} instead`)},mm=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Rt(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let i={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(i[a]=Rt(r,t,St(n,a)));return e.colorId!==void 0&&(Jr(e.colorId,n,"colorId"),i.fill=xi(t,e.colorId)),i},Rt=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Rt(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 ${Xa("fill")} instead`);ui(e,"hover",n),ui(e,"click",n),ui(e,"rightClick",n)}let i={};for(let[a,r]of Object.entries(e))if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){i[a]=mm(r,t,St(n,a));continue}i[a]=Rt(r,t,St(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(Jr(e.colorId,n,"colorId"),i.fill=xi(t,e.colorId)),i},pi=(e={},t)=>{let n=lm(e)?.[t];return n||null},Wa=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",$a=(e,t,n,i)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,i))throw new Error(`Inline ${t}.${i} is not allowed in sprite layout elements at "${n}". Use ${Wa(`${t}.${i}`)} instead`)},_a=(e,t,n)=>{let i=e[t];e[t]={...i&&typeof i=="object"&&!Array.isArray(i)?i:{},src:n}},gi=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>gi(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 ${Wa(a)} instead`);$a(e,"hover",n,"src"),$a(e,"click",n,"src")}let i={};for(let[a,r]of Object.entries(e))e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(i[a]=gi(r,t,St(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){Jr(e.imageId,n,"imageId");let a=pi(t,e.imageId),r=a?.fileId??e.imageId;i.src=r,i.width===void 0&&a?.width!==void 0&&(i.width=a.width),i.height===void 0&&a?.height!==void 0&&(i.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(Jr(e.hoverImageId,n,"hoverImageId"),_a(i,"hover",pi(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Jr(e.clickImageId,n,"clickImageId"),_a(i,"click",pi(t,e.clickImageId)?.fileId??e.clickImageId)),i},Ei=(e,t={},n="root")=>gi(Rt(hi(e,t,n),t,n),t,n),nr=Ei,_r=(e=[])=>e.find(t=>t.id==="story"),ym="#000000",bi="bg-cg-background-color",hm=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?gn(n?.backgroundColor??ym,"screen.backgroundColor"):xi(e,t.colorId),Ka=(e={})=>{if($r(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},gm=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},ja=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Ka(e),i=gm(e),a={};return(t||n!==void 0)&&(a.alpha=n??1),i&&(a.blur=i),a},bm=(e={})=>{if($r(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},Im=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ja=(e={})=>{let t=bm(e),n=Im(e),i={};return t!==void 0&&(i.alpha=t),n&&(i.blur=n),i},Kr=(e={})=>Ja(e),rr=(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:t.scaleX??e.scaleX,scaleY:t.scaleY??e.scaleY},i=t.originX??e.originX,a=t.originY??e.originY;return i!==void 0&&(n.originX=i),a!==void 0&&(n.originY=a),n},wm=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],Si=(e={})=>e.text&&$r(e.text,"content")&&$r(e.text,"textStyleId"),Na=(e={})=>{if(e.resourceId)return e.resourceId;if(Si(e))return"text"},Da=(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:i,...a}=n;return{...a,src:t.images?.[i]?.fileId??i}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,vm=({item:e,particle:t,resources:n})=>{let i=xt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=Da(r,n)),a.texture!==void 0&&(a.texture=Da(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...rr(i,e)};return Object.assign(s,Kr(e)),s},Am=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!Si(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let t of wm)if($r(e.text,t))throw new Error(`Visual item "${e.id}" text.${t} is reserved for the visual item`)}},km=({resources:e,background:t,screen:n={width:1920,height:1080},includeOpacity:i=!1})=>{let a={id:bi,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:hm({resources:e,background:t,screen:n})};if(i){let r=Ka(t);r!==void 0&&(a.alpha=r)}return a},Pm=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Ta=({resources:e={},resourceId:t,colorId:n})=>{let i=za(e,t);return t&&(i||n===void 0)?{resourceId:t,targetId:fn({resourceId:t,kind:i})}:n!==void 0?{resourceId:bi,targetId:bi}:{resourceId:void 0,targetId:void 0}},Qa=100,hr=Qa,xm="channel:bgm",Em="channel:music-room",Sm="music-room:player",Rm="channel:voice",Om="default",Cm=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Et=(...e)=>e.map(Cm).join(":"),yn=(e,t,n)=>{let i=new Set;e.forEach(({id:a})=>{if(i.has(a)){let r=n?` in ${n}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}i.add(a)})},$m=(e,t)=>e*t/Qa,Za=(e={},t)=>e?.[t]??mr[t],bn=(e={},t,n=hr)=>$m(n,Za(e,t)),In=({id:e,volume:t,muted:n,pan:i,loop:a,playback:r,interruption:s,children:o,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(n??!1),pan:i??0,children:o};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),s!==void 0&&(c.interruption=s),c},dn=(e,t,n,i)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:i,_m=["muted","pan","playbackRate","startAt","endAt"],wn=({id:e,sound:t,resource:n,defaultLoop:i=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:dn(t,n,"loop",i),volume:dn(t,n,"volume",hr),startDelayMs:dn(t,n,"startDelayMs",0)};_m.forEach(s=>{let o=dn(t,n,s,void 0);o!==void 0&&(a[s]=o)}),t.playback!==void 0&&(a.playback=structuredClone(t.playback));let r=a.startAt??0;if(a.endAt!==void 0&&a.endAt!==null&&a.endAt<r)throw new Error(`Sound "${e}" endAt (${a.endAt}) must be greater than or equal to startAt (${r}).`);return a},Ve=({variables:e,imageGallery:t,musicRoom:n,sceneReplay:i,runtime:a,saveSlots:r=[],dialogueState:s,includeInactiveAdvDialogue:o=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g=[],characters:h={},dialogueUIHidden:I,skipOnlyViewedLines:b,skipTransitionsAndAnimations:x}={})=>{let v={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??I??!1,isLineCompleted:a?.isLineCompleted??l??!1},k=Lm({dialogueState:s,includeInactiveAdvDialogue:o,characters:h,variables:e,runtime:v}),S={variables:e,imageGallery:t,musicRoom:n,sceneReplay:i,localizationPackages:a?.localizationPackages??[],localizationPackageId:v.localizationPackageId,runtime:v,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g,characters:h};return k&&(S.dialogue=k,S.dialogueLines=k.lines),S},La=100,hn=(e,t)=>{if(Array.isArray(e))return e.map(i=>hn(i,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(i=>{n[i]=hn(n[i],t)}),n.type==="text-revealing"?t(n):n},jm=e=>hn(e,t=>({...t,revealEffect:"none"})),Nm=e=>hn(e,t=>{let n=Number(t.speed??t.displaySpeed),i=Number.isFinite(n)?Math.max(n,La):La;return{...t,speed:i,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:i}:{}}}),gr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:i=!1}={})=>t||i?jm(e):n?Nm(e):e,el=({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:{}}}}),Ii=e=>{if(Array.isArray(e))return e.map(Ii);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Ii(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let i=n.actions,a=i&&typeof i=="object"&&!Array.isArray(i)&&Object.prototype.hasOwnProperty.call(i,"nextLine")?{...i.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...n,bypassChoice:!0,...a?{actions:{...i,nextLine:a}}:{}}}}},Dm=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Ma="submit",di=(e,t,n={})=>{let i=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=i.actions&&typeof i.actions=="object"?i.actions:{},r=n.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...i,actions:r}}},wi=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>wi(c,t,n));if(!e||typeof e!="object")return e;let i=typeof e.type=="string",a=i&&e.formRole===Ma,r=i&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},o={};for(let[c,u]of Object.entries(e))o[c]=wi(u,t,c==="children"?s:{});let l=o;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:di(l.change,u),submit:di(l.submit,t.submitActions)}}}return l.formRole===Ma||r?{...l,click:di(l.click,t.submitActions,{replaceActions:!0})}:l},vi=(e,t)=>{if(Array.isArray(e))return e.map(i=>vi(i,t));if(!e||typeof e!="object")return e;let n={};for(let[i,a]of Object.entries(e))n[i]=vi(a,t);for(let i of Dm){let a=n[i]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[i]={...n[i],payload:{...a,_interactionSource:"form"}})}return n},Ai=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0,s=on({characterId:e,character:t,characterName:n,characters:i,variables:a});return{...r||{},...t||{},name:s}},rl=(e=[],t={},n={})=>e.map(i=>{let a=Ai({characterId:i.characterId,character:i.character,characterName:i.characterName,characters:t,variables:n}),r=typeof i.text=="string"?i.text:Array.isArray(i.content)?i.content.map(s=>s?.text??"").join(""):"";return{...i,text:r,character:a,characterName:a.name}}),Tm=e=>!(!e||e.mode==="adv"&&e.content===void 0),Lm=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:i,runtime:a}={})=>{if(!t&&!Tm(e))return;let r=e.content===void 0?[{text:""}]:yi(e.content,"dialogue.content"),s=e.content===void 0?0:nm({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:i}),o=a?.dialogueTextSpeed??mr.dialogueTextSpeed,l=e.textSpeed??o,c=(e.lines||[]).map((p,m)=>{let d=yi(p.content,`dialogue.lines[${m}].content`),f=Ai({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:i});return{...p,textSpeed:p.textSpeed??o,content:d.map(y=>({...y,text:Hr(y.text,{variables:i})})),character:f,characterName:f.name}}),u=Ai({characterId:e.characterId,character:e.character,characters:n,variables:i});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:Hr(p.text,{variables:i})})),initialRevealedCharacters:s,lines:c}},tl=({container:e,resources:t,templateData:n,isLineCompleted:i=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=tr(e,n);return nr(gr(s,{isLineCompleted:i,skipMode:a,skipTransitionsAndAnimations:r}),t)},fi=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),qa=({renderStateKeyboard:e,keyboard:t,phase:n})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([i,a])=>{let r=e[i]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[i]={...r,keydown:{payload:fi(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[i].keyup={payload:fi(a.keyup)});return}e[i]={...r,[n]:{payload:fi(a)}}})},Mm=(e={},t={})=>{let n={};return qa({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),qa({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},sr=({animationsDef:e,resources:t,previousResourceId:n,currentResourceId:i,previousTargetId:a,currentTargetId:r,animationPath:s,idPrefix:o})=>{if(!e)return[];let l=[],c=({instanceId:h,targetId:I})=>{let b=rm({resources:t,animationId:d,playback:f,instanceId:h,targetId:I,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=i!=null&&i!==!1,m=a&&r&&a===r;em(e,s);let d=Xf(e),f=Wf(e),y=t?.animations?.[d],g=Hf(y,{animationId:d,animationPath:s});if(g==="update")return p&&r?c({instanceId:`${o}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${o}-animation-update`,targetId:a}),l;if(g==="transition"){let h=`${o}-animation-transition`,I=f?.continuity==="persistent"?h:`${o}-animation-in`;if(u&&p&&m)return c({instanceId:h,targetId:r}),l;u&&c({instanceId:`${o}-animation-out`,targetId:a}),p&&c({instanceId:I,targetId:r})}return l},qm=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Vm=(e,{presentationState:t,previousPresentationState:n,currentLineActions:i,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:o,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:I,canRollback:b,form:x,saveSlots:v=[]})=>{let{elements:k,animations:S}=e;if(t.background){let O=i===void 0?!0:$r(i?.background??{},"animations"),j=k.find(pe=>pe.id==="story");if(!j)return e;let E=sm(a,t.background),T=E||om(t.background),q=n?.background?.resourceId,ae=n?.background?.colorId,G=t.background.resourceId??(t.background.animations?q:void 0),ee=t.background.colorId??(t.background.animations?ae:void 0),re=Pm(a,G),be={...t.background,colorId:ee};if((ee!==void 0||re)&&j.children.push(km({resources:a,background:be,screen:r,includeOpacity:!re})),G){let{images:pe={},videos:le={},spritesheets:ie={}}=a,ce=za(a,G),ve;if(ce==="sprite"?ve=pe[G]:ce==="video"?ve=le[G]:ce==="spritesheet-animation"&&(ve=ie[G]),ve){let Ge=ce==="video",lr=ce==="spritesheet-animation",He={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...E},Ze={...ja(t.background,{includeDefaultAlpha:!0}),...rr(He,t.background)},Ie;lr?Ie=Ga({id:fn({resourceId:G,kind:ce}),resourceId:G,spritesheet:ve,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:Ze}):Ie={id:fn({resourceId:G,kind:ce}),type:Ge?"video":"sprite",src:ve.fileId,width:ve.width,height:ve.height,...Ze},Ge&&(Ie.loop=t.background.loop??!1,Ie.volume=ve.volume??50),Ie&&j.children.push(Ie)}}if(G){let{layouts:pe={}}=a,le=pe[G];if(le){let ie={id:fn({resourceId:G,kind:"container"}),type:"container",children:le.elements,...ja(t.background)};T&&Object.assign(ie,rr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...E},t.background));let ce=tr(ie,Ve({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:v,dialogueState:t.dialogue,isLineCompleted:s,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:I,canRollback:b,form:x,characters:a.characters||{},skipTransitionsAndAnimations:o}));j.children.push(nr(gr(ce,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:o}),a))}}let Pe=Ta({resources:a,resourceId:q,colorId:ae}),ue=Ta({resources:a,resourceId:G,colorId:ee}),se=sr({animationsDef:t.background.animations,resources:a,previousResourceId:Pe.resourceId,currentResourceId:ue.resourceId,previousTargetId:Pe.targetId,currentTargetId:ue.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ue({animationInstances:se,isLineCompleted:s,skipTransitionsAndAnimations:o,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:O})&&S.push(...se)}return e},Fm=(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{elements:o,animations:l}=e;if(t.character&&i){let c=o.find(f=>f.id==="story");if(!c)return e;let u=t.character.items||[],p=n?.character?.items||[],m=Oa(u),d=Oa(p);for(let f=0;f<u.length;f++){let y=u[f],{transformId:g,sprites:h}=y,I=p.find(T=>T.id===y.id),b=p.findIndex(T=>T.id===y.id),x=I?.sprites&&I.sprites.length>0,v=h&&h.length>0,k=b>=0?pn(I,b,d):void 0,S=sr({animationsDef:y.animations,resources:i,previousResourceId:k,currentResourceId:v?pn(y,f,m):void 0,previousTargetId:k,currentTargetId:v?pn(y,f,m):void 0,animationPath:`character.items[${f}].animations`,idPrefix:"character"});if(y.animations&&!h&&!g&&x&&Ue({animationInstances:S,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})){l.push(...S);continue}if(y.animations&&!h&&!g)continue;if(!h||h.length===0||!g){console.warn("Character item missing sprites or transformId:",y);continue}let O=pn(y,f,m),j=i.transforms[g];if(!j){console.warn("Transform not found:",g);continue}let E={type:"container",id:O,...rr(j,y),...Kr(y),children:[]};for(let T of h){let q=Ha({id:`${O}-${T.id}`,item:T,resources:i});q&&E.children.push(q)}c.children.push(E),Ue({animationInstances:S,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&l.push(...S)}}return e},nl=(e,t)=>{if(!oi.includes(e))throw new Error(`${t} must be one of: ${oi.join(", ")}.`)},Um=(e,t)=>{let n=!!e.resourceId||Si(e),i=e.layer??(n?void 0:t?.layer)??ii;return nl(i,`Visual item "${e.id}" layer`),i},Bm=(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:a,skipTransitionsAndAnimations:r,variables:s,imageGallery:o,musicRoom:l,sceneReplay:c,runtime:u,activePersistentAnimations:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,saveSlots:I=[],visualLayer:b})=>{let{elements:x,animations:v}=e;if(t.visual&&i){let k=x.find(E=>E.id==="story");if(!k)return e;let S=t.visual.items,O=n?.visual?.items||[],j=Ve({variables:s,imageGallery:o,musicRoom:l,sceneReplay:c,runtime:u,saveSlots:I,dialogueState:t.dialogue,isLineCompleted:a,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,characters:i.characters||{},skipTransitionsAndAnimations:r});b!==void 0&&nl(b,"visualLayer");for(let E of S){let T=O.find(re=>re.id===E.id),q=Um(E,T);if(b!==void 0&&q!==b)continue;if(Am(E),E.text){let re=xt(i,E),be={...structuredClone(E.text),id:`visual-${E.id}`,type:"text",...rr(re,E)};Object.assign(be,Kr(E)),k.children.push(nr(tr(be,j),i))}if(E.resourceId){let{images:re={},videos:be={},spritesheets:Pe={}}=i,ue=Pe[E.resourceId];if(ue){let se=xt(i,E),pe=E.animationName;if(pe){let le=ue.animations?.[pe];if(!le)throw new Error(`Animation '${pe}' not found in spritesheet resource '${E.resourceId}'`);let ie=Kr(E),ce={id:`visual-${E.id}`,type:"spritesheet-animation",...rr(se,E),width:E.width??ue.width,height:E.height??ue.height,alpha:ie.alpha??E.alpha??1,src:ue.fileId,atlas:ue.jsonData,playback:{frames:le.frames,animationSpeed:E.animationSpeed??le.animationSpeed??.5,loop:E.loop??le.loop??!0}};ie.blur&&(ce.blur=ie.blur),k.children.push(structuredClone(ce))}}else{let se=re[E.resourceId]||be[E.resourceId];if(se){let pe=be[E.resourceId]!==void 0,le=xt(i,E),ie={id:`visual-${E.id}`,type:pe?"video":"sprite",src:se.fileId,width:se.width,height:se.height,...rr(le,E)};Object.assign(ie,Kr(E)),pe&&(ie.loop=se.loop??!1,ie.volume=se.volume??50),k.children.push(ie)}}}if(E.resourceId){let re=i.particles?.[E.resourceId];re&&k.children.push(vm({item:E,particle:re,resources:i}))}if(E.resourceId){let{layouts:re={}}=i,be=re[E.resourceId];if(be){let Pe=xt(i,E),ue={id:`visual-${E.id}`,type:"container",children:structuredClone(be.elements),...rr(Pe,E)};Object.assign(ue,Kr(E));let se=tr(ue,j);k.children.push(nr(gr(se,{isLineCompleted:a,skipMode:d,skipTransitionsAndAnimations:r}),i))}}let ae=Na(T),G=Na(E),ee=sr({animationsDef:E.animations,resources:i,previousResourceId:ae,currentResourceId:G,previousTargetId:ae?`visual-${E.id}`:void 0,currentTargetId:G?`visual-${E.id}`:void 0,animationPath:`visual.items[${E.id}].animations`,idPrefix:E.id});Ue({animationInstances:ee,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:p})&&v.push(...ee)}}return e},Wr="dialogue-character-sprite",Ym=(e,{presentationState:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=_r(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=yt(c),m=yt(u),d=sr({animationsDef:c?.animations,resources:i,previousResourceId:m?Wr:void 0,currentResourceId:p?Wr:void 0,previousTargetId:m?Wr:void 0,currentTargetId:p?Wr:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&Ue({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...d),e;let f=i.transforms?.[c.transformId];if(!f)return console.warn("Transform not found:",c.transformId),e;let y={type:"container",id:Wr,...rr(f),children:[]};for(let g of c.items){let h=Ha({id:`${Wr}-${g.id}`,item:g,resources:i});h&&y.children.push(h)}return l.children.push(y),Ue({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...d),e},zm=(e,{presentationState:t,previousPresentationState:n,resources:i={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:I,activePersistentAnimations:b,saveSlots:x=[]})=>{let{elements:v,animations:k}=e;if(!t.dialogue||a)return e;let S=v.find(j=>j.id==="story");if(!S)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:j={}}=i,E=j[t.dialogue.ui.resourceId];if(E){let T={elements:E.elements},q=Ve({variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:I,saveSlots:x,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:s,isChoiceVisible:o,isFormVisible:l,canRollback:c,form:u,characters:i.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),ae=tr(T,q),G=nr(gr(ae?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),i);if(Array.isArray(G))for(let ee of G)S.children.push(ee);else G&&S.children.push(G)}}Ym(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let O=sr({animationsDef:t.dialogue.ui?.animations,resources:i,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 Ue({animationInstances:O,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&k.push(...O),e},Gm=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,activePersistentAnimations:I,saveSlots:b=[]})=>{let{elements:x,animations:v}=e;if(t.choice&&i){let k=_r(x);if(!k)return e;let S=i?.layouts[t.choice.resourceId];if(S&&S.elements){let j={elements:S.elements},E=tr(j,{...Ve({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f??!!t.choice,isFormVisible:y,canRollback:g,form:h,characters:i.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),T=Ii(nr(gr(E?.elements,{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),i));if(Array.isArray(T))for(let q of T)k.children.push(q);else T&&k.children.push(T)}let O=sr({animationsDef:t.choice.animations,resources:i,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"});Ue({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:I})&&v.push(...O)}return e},Hm=(e,{presentationState:t,previousPresentationState:n,resources:i,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,activePersistentAnimations:h,saveSlots:I=[],form:b})=>{let{elements:x,animations:v}=e;if(!b?.resourceId||!i)return e;let k=_r(x);if(!k)return e;let S=i?.layouts?.[b.resourceId];if(!S)return console.warn(`Form layout not found: ${b.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:S.elements||[]},j={...Ve({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:I,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,characters:i.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},E=tr(O,j),T=vi(nr(gr(wi(E,b),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),i),b);T&&k.children.push(T);let q=sr({animationsDef:b.animations,resources:i,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 Ue({animationInstances:q,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&v.push(...q),e},Xm=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],skipTransitionsAndAnimations:g})=>{if(!t.control?.resourceId)return e;let h=n.controls?.[t.control.resourceId];if(!h)return e;let I=Mm(h.keyboard,h.keyup);if(I&&Object.keys(I).length>0&&(e.global.keyboard=I),!Array.isArray(h.elements)||h.elements.length===0)return e;let b=_r(e.elements);if(!b)return e;let x={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:h.elements};return b.children.push(tl({container:x,resources:n,templateData:Ve({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:y,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},Wm=(e,{presentationState:t,resources:n,runtime:i,variables:a,musicRoomPlayer:r})=>{let{elements:s,audio:o}=e;if(t.bgm&&n){if(!_r(s))return e;let c=t.bgm,u=!Array.isArray(c.sounds),p=u?c.resourceId?[{id:"default",resourceId:c.resourceId,loop:c.loop??!0,volume:c.volume,startDelayMs:c.startDelayMs??0}]:[]:c.sounds,m=!u&&c.loop===!0,d=[];if(u||yn(p,"BGM sound"),m){let y=p.find(g=>g.loop===!0);if(y)throw new Error(`BGM sound "${y.id}" cannot loop inside a looping BGM channel.`)}if(p.forEach(y=>{let g=n.sounds?.[y.resourceId];if(!g)return;let h=m?{...y,loop:y.loop??!1}:y;d.push(wn({id:Et("bgm",u?"default":y.id),sound:h,resource:g,defaultLoop:!m}))}),d.length===0)return e;let f=Ve({variables:a,runtime:i}).runtime;o.push(In({id:xm,volume:bn(f,"musicVolume",u?hr:c.volume??hr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,playback:r?.bgmPlayback,interruption:c.interruption,children:d,runtime:f}))}return e},Km=(e,{resources:t={},runtime:n,variables:i,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let s=r.tracks.find(u=>u.id===a.trackId),o=s?t.sounds?.[s.soundId]:void 0;if(!s||!o)return e;let l=Ve({variables:i,runtime:n}).runtime,c=wn({id:Sm,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:o});return e.audio.push(In({id:Em,volume:bn(l,"musicVolume",hr),children:[c],runtime:l})),e},Jm=(e,{presentationState:t,resources:n,runtime:i})=>{let{audio:a}=e;if(t.sfx&&n){let r=t.sfx,s=!Array.isArray(r.channels),o=s?[{id:Om,sounds:r.items??[]}]:r.channels;s||yn(o,"SFX channel"),o.forEach(l=>{let c=!s&&l.loop===!0,u=[];if(s||yn(l.sounds,"SFX sound",`SFX channel "${l.id}"`),c){let p=l.sounds.find(m=>m.loop===!0);if(p)throw new Error(`SFX sound "${p.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((p,m)=>{let d=n.sounds?.[p.resourceId];if(!d)return;let f=c?{...p,loop:p.loop??!1}:p;u.push(wn({id:s?Et("sfx","default",m,p.id):Et("sfx",l.id,p.id),sound:f,resource:d,defaultLoop:c?!1:void 0}))}),u.length!==0&&a.push(In({id:Et("channel","sfx",l.id),volume:bn(i,"soundVolume",l.volume??hr),muted:l.muted,pan:l.pan,loop:s?void 0:l.loop,interruption:s?void 0:l.interruption,children:u,runtime:i}))})}return e},Qm=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},Zm=(e,{presentationState:t,resources:n,currentSceneId:i,runtime:a,variables:r})=>{let{audio:s}=e;if(!t?.voice)return e;let o=t.voice,l=!Array.isArray(o.sounds),c=l?o.resourceId?[{id:"default",resourceId:o.resourceId,loop:o.loop??!1,volume:hr,startDelayMs:o.startDelayMs??0}]:[]:o.sounds,u=!l&&o.loop===!0,p=[];if(l||yn(c,"Voice sound"),u){let d=c.find(f=>f.loop===!0);if(d)throw new Error(`Voice sound "${d.id}" cannot loop inside a looping Voice channel.`)}if(c.forEach(d=>{let f=Qm(n,i,d.resourceId);if(!f)return;let y=u?{...d,loop:d.loop??!1}:d;p.push(wn({id:Et("voice",i,l?"default":d.id),sound:y,resource:f,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let m=Ve({variables:r,runtime:a}).runtime;return s.push(In({id:Rm,volume:l?o.volume??Za(m,"soundVolume"):bn(m,"soundVolume",o.volume??hr),muted:o.muted,pan:o.pan,loop:l?void 0:o.loop,interruption:o.interruption,children:p,runtime:m})),e},ey=(e,{presentationState:t,previousPresentationState:n,resources:i={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:I})=>{let{elements:b,animations:x}=e;if(t.layout){let O=_r(b);if(!O)return e;let j=i.layouts[t.layout.resourceId];if(!j)return e;Array.isArray(j.transitions)&&!g&&!h&&Pi({animations:x,transitions:j.transitions,defaultTargetId:`layout-${t.layout.resourceId}`,idPrefix:`layout-${t.layout.resourceId}`,animationPathPrefix:"layout"});let E={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:j.elements||[]};O.children.push(tl({container:E,resources:i,templateData:Ve({variables:a,imageGallery:r,musicRoom:s,sceneReplay:o,runtime:l,saveSlots:y,dialogueState:t.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:i.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:h}))}let v=n?.layout?.resourceId,k=t.layout?.resourceId,S=sr({animationsDef:t.layout?.animations,resources:i,previousResourceId:v,currentResourceId:k,previousTargetId:v?`layout-${v}`:void 0,currentTargetId:k?`layout-${k}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ue({animationInstances:S,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:I})&&x.push(...S),e},ry=(e,{currentLineActions:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=t?.screen?.animations;if(!l)return e;let c=n!=null,u=sr({animationsDef:l,resources:i,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ue({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...u),e},ty=(e,{presentationState:t})=>{let n=_r(e.elements);return!n||!t?.screen||Object.assign(n,Ja(t.screen)),e},ny=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:y=[],saveSlots:g=[],screen:h,isLineCompleted:I,skipTransitionsAndAnimations:b})=>{let{elements:x,animations:v}=e;return f&&f.length>0&&f.forEach((k,S)=>{let O=n.layouts[k.resourceId];if(!O){console.warn(`Overlay layout not found: ${k.resourceId}`);return}Array.isArray(O.transitions)&&(b||Pi({animations:v,transitions:O.transitions,defaultTargetId:`overlayStack-${S}`,idPrefix:`overlayStack-${S}`,animationPathPrefix:`overlayStack[${S}]`}));let j={id:`overlayStack-${S}`,type:"container",x:0,y:0,children:[el({id:`overlayStack-${S}-blocker`,screen:h}),...O.elements||[]]},E=rl(y,n.characters,i),T=Ve({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:I,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:E,characters:n.characters||{},skipTransitionsAndAnimations:b}),q=tr(j,T),[ae,...G]=q.children||[],ee=nr(gr({...q,children:G},{isLineCompleted:I,skipMode:c,skipTransitionsAndAnimations:b}),n);x.push({...ee,children:ae?[ae,...ee.children||[]]:ee.children})}),e},sy=(e,{presentationState:t,resources:n={},variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,dialogueHistory:g=[],screen:h,isLineCompleted:I,skipTransitionsAndAnimations:b})=>{let{elements:x,animations:v}=e;if(!y?.resourceId)return e;let k=n.layouts?.[y.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${y.resourceId}`),e;Array.isArray(k.transitions)&&!b&&Pi({animations:v,transitions:k.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let S={id:"confirmDialog",type:"container",x:0,y:0,children:[el({id:"confirmDialog-blocker",screen:h}),...k.elements||[]]},O=rl(g,n.characters,i),j=tr(S,Ve({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:I,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,historyDialogue:O,characters:n.characters||{},skipTransitionsAndAnimations:b})),[E,...T]=j.children||[],q=nr(gr({...j,children:T},{isLineCompleted:I,skipMode:u,skipTransitionsAndAnimations:b}),n);return x.push({...q,children:E?[E,...q.children||[]]:q.children}),e},Ot=e=>(t,n)=>Bm(t,{...n,visualLayer:e}),iy=Ot(er.BEHIND_BACKGROUND),oy=Ot(er.BEHIND_CHARACTER),ay=Ot(er.BEHIND_DIALOGUE),ly=Ot(er.BEHIND_CHOICE),cy=Ot(er.FOREGROUND),sl=e=>sn(qm,[Xm,iy,Vm,oy,Fm,ay,zm,ly,Gm,Hm,ey,cy,ty,ry,Wm,Km,Jm,Zm,ny,sy])(e);function il(e,t=""){let n=[],i=e.length,a=0,r=0,s=-1,o=()=>{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<i;){let l=s+1+o();s=l+o(),n.push([l,s,t?parseInt(t[r++],36):0])}return n}function ol(e,t,n){let i=0,a=t.length-1;for(;i<=a;){let r=i+a>>>1,s=n[r];if(e<t[r])a=r-1;else if(e>s>>>5)i=r+1;else return s&31}return 0}var al="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",ll="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",cl="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var ul=65535,Ri=40960,vn=126976,fl=new Uint8Array(12288),ml=new Uint8Array(3072),yl=new Uint8Array(2816),hl,gl;{let e=(a,r,s,o,l)=>{let c=r+a.length-1;for(let u=s<r?r:s,p=o>c?c:o;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),n=new Uint32Array(320),i=0;for(let[a,r,s]of il(al,ll))e(fl,0,a,r,s),e(ml,Ri,a,r,s),e(yl,vn,a,r,s),r>=65040&&!(a>=vn&&r<=129791)&&(t[i]=a,n[i++]=r<<5|s);hl=t.slice(0,i),gl=n.slice(0,i)}function pl(e){return e<12288?fl[e]:e<Ri?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?ml[e-Ri]: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>=vn&&e<129792?yl[e-vn]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:ol(e,hl,gl)}var bl=Uint8Array.from(cl,Number);function uy(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 dl(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||uy(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*Il(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),i=n>ul?2:1,a=pl(n),r=50200>>a&1?dl(0,a,n):0,s=0,o=n,l=a;for(;i<t;){n=e.codePointAt(i);let c=n>ul?2:1,u=pl(n),p=bl[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)?dl(r,u,n):0,m&&(yield{segment:e.slice(s,i),index:s,input:e,_hd:o,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=i,o=n,l=u),i+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:o,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*wl(e){for(let t of Il(e))yield t.segment}{let e=Il("_");bl._keep=[e,e.next()]}var vl=1e3,xl=50,py=0,Al=100,kl=50,dy=60,fy=3,my=.5,yy=2e4,hy=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,gy=/^\s+$/u,Pl,by=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(wl(t)):(Pl??=new n(void 0,{granularity:"grapheme"}),Array.from(Pl.segment(t),({segment:i})=>i))},Iy=e=>by(e).reduce((t,n)=>gy.test(n)?t+my:hy.test(n)?t+fy:t+1,0),wy=e=>2**(((Number.isFinite(e)?Math.min(Al,Math.max(py,e)):xl)-kl)/(Al-kl)),El=({text:e="",baseDelay:t=vl,speed:n=xl}={})=>{let i=Number.isFinite(t)?Math.max(0,t):vl,a=wy(n),r=Iy(e)*dy/a,s=Math.max(i,yy);return Math.min(i+r,s)};var An={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},jl=1,_i=1,Zr="choice",br="form",_t=()=>({manual:{...An.manual},auto:{...An.auto},applyMode:An.applyMode}),ji=()=>({groupId:null,variantId:null,pageIndex:0}),vy="music-room:player",Ay=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),xn=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Ni=new Set,ky=new Set(["groupId","variantId"]),Py=new Set(["pageIndex"]),et=new Set,xy=new Set(["trackId"]),Ey=new Set(["positionMs"]),Sy=new Set(["pageIndex"]),Di=new Set,Ry=new Set(["sceneId"]),Oy=new Set(["pageIndex"]),Ti=()=>({pageIndex:0}),Li=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={..._t()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},D=e=>{let t=he(e)?cr(e):e;return structuredClone(t)},L=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),En=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},Nl=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},jt=(e,t,n)=>({commandId:En(e),operation:t,...n===void 0?{}:{positionMs:n}}),Mi=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:En(e),operation:"resume"}),e.global.musicRoomPlayer=xn({bgmPlayback:n})},Dl=(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},rt=e=>String(e),Tl=()=>({sections:[],resources:[]}),Ll=()=>({sceneIds:[]}),Cy=e=>L(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Tl(),$y=e=>L(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Ll(),_y=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",jy=({sectionId:e,lineId:t,content:n,dialogueState:i,characterName:a})=>({sectionId:e,lineId:t,content:n,text:_y(n),characterId:i.characterId,character:{...i.character||{},name:a},characterName:a}),Ml=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),Ny=e=>L(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,qi=e=>{if(!L(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},Dy=e=>{if(!L(e?.dialogueHistory))return e.dialogueHistory=Ml(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},Vi=e=>{let t=qi(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},Ty=()=>({resourceId:void 0}),Ly=e=>{if(!L(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[i,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:i,section:a.sections[t]};return{sceneId:void 0,section:void 0}},ql=e=>{let t=e?.story?.scenes??{},n=new Map;for(let[i,a]of Object.entries(t)){let r=a?.sections??{};for(let s of Object.keys(r)){let o=n.get(s);if(o!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${o}" and "${i}". Section IDs must be globally unique.`);n.set(s,i)}}},Vl=e=>{if(typeof e=="number"||typeof e!="string")return e;let t=Number(e);return Number.isFinite(t)?t:e},Fl=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==jl)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},My=(e,t={})=>{let n;try{n=Fl(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let i={...t,formatVersion:n,slotId:Vl(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete i.slotKey,delete i.date,i},qy=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,My(t,n)])),Ul=e=>{if(!Array.isArray(e))return;let t=e.filter(({type:n})=>Ob(n));return t.length>0?t:void 0},Vy=e=>{!L(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=_i,e.timeline.forEach(t=>{if(!L(t))return;typeof t.returnable!="boolean"&&delete t.returnable;let n=Ul(t.executedActions);if(n){t.executedActions=n;return}delete t.executedActions}))},Sl=(e,t,n,i="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!L(e))throw new Error(`Malformed ${i}.${t}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${i}.${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 ${i}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},Fy=(e,t="viewedRegistry")=>{if(e===void 0)return Tl();if(!L(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??[],i=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,r)=>{let s=Sl(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(i.map((a,r)=>{let s=Sl(a,"resources",r,t);return[s.resourceId,s]})))}},Uy=(e,t="accountReplayRegistry")=>{if(e===void 0)return Ll();if(!L(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((i,a)=>{if(typeof i!="string"||i.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return i}))]}},Bl=(e,t,n)=>{if(!L(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:i,lineId:a}=e;if(typeof i!="string"||i.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,i);if(!s)throw new Error(`Malformed save slot ${n}: section "${i}" 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 "${i}".`);return{sceneId:r,sectionId:i,lineId:a}},Yl=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Fi=(e,t)=>{let{section:n}=ir(e,t?.sectionId);return n?.lines?.find(i=>i.id===t?.lineId)},By=(e,t,n)=>{if(!L(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 i=[],a=[0],r=!1;if(e.entries.forEach((o,l)=>{if(!L(o))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof o.sectionId!="string"||o.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof o.lineId!="string"||o.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(o.appendToPrevious!==void 0&&typeof o.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:c}=ir(t,o.sectionId);if(!c?.lines?.some(p=>p.id===o.lineId)){r=!1,a.push(i.length);return}i.push({sectionId:o.sectionId,lineId:o.lineId,...o.appendToPrevious===!0&&r&&i.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(i.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((o,l)=>{if(!Number.isInteger(o)||o<0||o>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[o]});return{entries:i,currentLength:a[e.currentLength],checkpointLengths:s}},Yy=(e,t)=>L(Fi(e,t)?.actions?.dialogue),zl=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:i}=ir(e,n.sectionId),a=i?.lines?.findIndex(s=>s.id===n.lineId);return typeof a!="number"||a<=0?!1:i.lines.slice(0,a).findLast(s=>L(s.actions?.dialogue))?.id===t.lineId},zy=(e,t)=>{let n=Ml();return e.timeline.forEach(i=>{if(i.returnable!==!1&&Yy(t,i)){let a=Fi(t,i),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&zl(t,r,i);n.entries.push({sectionId:i.sectionId,lineId:i.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},Gy=(e,t,n,i)=>{if(n.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==i)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},Hy=(e,t)=>{let{section:n}=ir(e,t?.sectionId),i=n?.lines?.findIndex(r=>r.id===t?.lineId);if(typeof i!="number"||i<0)return null;let a=n.lines[i+1];return a?{sectionId:t.sectionId,lineId:a.id}:null},Gl=(e,t,n)=>{if(typeof t?.sectionId!="string")return!1;let{section:i}=ir(e,t.sectionId);return Yl({sectionId:t.sectionId,lineId:i?.lines?.[0]?.id},n)},Xy=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),Qr={always:"always",maybe:"maybe",never:"never"},Wy=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return Qr.always;let t=e.when,n;if(t===null||typeof t=="boolean"||typeof t=="number")n=t;else if(L(t)&&Object.keys(t).length===1&&Object.prototype.hasOwnProperty.call(t,"literal"))n=t.literal;else return Qr.maybe;return n?Qr.always:Qr.never},Hl=(e,t)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let i=Wy(n);if(i!==Qr.never){if(t(n))return!0;if(i===Qr.always)return!1}}return!1},Xl=e=>Hl(e,t=>Object.entries(t?.actions??{}).some(([n,i])=>n==="conditional"?Xl(i):Xy.has(n))),Wl=(e,t,n)=>Hl(t,i=>Object.entries(i?.actions??{}).some(([a,r])=>a==="sectionTransition"?Gl(e,r,n):a==="conditional"?Wl(e,r,n):!1)),Ky=(e,t,n)=>{if(!t)return!0;let i=Fi(n,e)?.actions;if(!L(i))return!0;if(Gl(n,i.sectionTransition,t))return!1;let a=i.conditional;return a?!(Wl(n,a,t)||!(i.choice?.resourceId||i.form?.resourceId)&&!Xl(a)&&Yl(Hy(n,e),t)):!0},Jy=(e,t,n)=>{if(!L(e)||!Array.isArray(e.timeline))return{rollback:$t({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let i=new WeakSet,a=[],r=e.timeline.flatMap((p,m)=>{if(!L(p))return[];try{let d=Bl(p,n,`rollback.timeline[${m}]`),f=Pn({sectionId:d.sectionId,lineId:d.lineId,rollbackPolicy:p.rollbackPolicy,returnable:p.returnable});typeof p.returnable=="boolean"&&i.add(f);let y=Ul(D(p.executedActions));return y&&(f.executedActions=y),a.push(m),[f]}catch{return[]}});if(r.length===0)return{rollback:$t({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};e.returnabilityVersion!==_i&&r.forEach((p,m)=>{!i.has(p)&&!Ky(p,r[m+1],n)&&(p.returnable=!1)});let o=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,l=a.indexOf(o);l<0&&(l=r.length-1);let c=r[l];if(c?.sectionId!==t.sectionId||c?.lineId!==t.lineId){let p=r.findLastIndex(m=>m.sectionId===t.sectionId&&m.lineId===t.lineId);p>=0?l=p:(r.push(Pn({sectionId:t.sectionId,lineId:t.lineId})),a.push(null),l=r.length-1)}let u=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),l):0;return{rollback:{currentIndex:l,isRestoring:!1,replayStartIndex:u,timeline:r},sourceCheckpointIndexes:a,sourceTimelineLength:e.timeline.length}},Qy=(e,t,n)=>{if(!L(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let i=Yi(t),a=Bl(e.pointers?.read,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!L(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!L(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Gr(D(e.variables),t.resources?.variables??{}):{},s=ph({loadedContextRuntime:L(e.runtime)?D(e.runtime):{}}),{rollback:o,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Jy(e.rollback,a,t),u=e.dialogueHistory===void 0?zy(o,t):Gy(By(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),o,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:L(e.configuration)?D(e.configuration):{},views:Array.isArray(e.views)?D(e.views):[],bgm:L(e.bgm)?D(e.bgm):{resourceId:void 0},variables:{...i,...r},...u?{dialogueHistory:u}:{},rollback:o};return s&&(p.runtime=s),p},Zy=(e,t)=>{if(!L(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,i)=>Qy(n,t,i))}},eh=(e,t)=>{if(!L(e))throw new Error("Malformed save slot.");let n=Fl(e.formatVersion);return{...e,formatVersion:n,state:Zy(e.state,t)}},Rl=(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 i=D(e),a=i.hideConfirmDialog??{};return delete i.hideConfirmDialog,{hideConfirmDialog:a,...i}},rh=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:Rl(e.confirmActions,"confirmActions",{required:!0}),cancelActions:Rl(e.cancelActions,"cancelActions")}},tt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},th=e=>(L(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),nt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Kl=e=>{if(!(!L(e)||!e.animations))return{animations:D(e.animations)}},nh=(e,t)=>{let n=Kl(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},sh=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},ih=(e,t)=>{let n=e?.sectionId,i=e?.lineId;if(!(!n||!i||!t))return`${n}:${i}:${t}`},kn=e=>String(e??""),Jl=(e,t)=>{let n=kn(t);return e?.trim===!0?n.trim():n},oh=e=>L(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>L(t)).map(([t,n])=>[t,{id:t,...D(n)}])):{},ah=(e,t)=>{if(!t||!L(e.global.formDrafts))return;let n=e.global.formDrafts[t];return L(n)?n:void 0},Ql=(e,t)=>{let n=th(e);L(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let i=n[t];return L(i.values)||(i.values={}),L(i.touched)||(i.touched={}),L(i.errors)||(i.errors={}),typeof i.submitted!="boolean"&&(i.submitted=!1),i},Ui=(e,t)=>{let n=Jl(e,t);return e?.required===!0&&n.length===0?"required":null},lh=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let i=we({state:e},{sectionId:t.sectionId})?.lines||[],a=i.findIndex(r=>r.id===t.lineId);return a<0?{}:Or(i.slice(0,a+1).map(r=>r.actions||{}))},ch=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let i=sh(t),a=ih(n,i);if(!i||!a)return null;let r=ah(e,a),s=oh(t),o=Sn({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=kn(o?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(r?.values??{},m)?kn(r.values[m]):f,g=r?.touched?.[m]===!0,h=Ui(d,y),I=r?.submitted||g?h:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,x={id:m,variableId:d.variableId,value:y,initialValue:f,valid:!h,error:I,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[m]=x,c.push(x),u[m]=y}),{id:i,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:D(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:D(t.cancelActions??{})}}}},Ol="line",Bi="interaction",Pn=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:i})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof i=="boolean"?{returnable:i}:{}}),Yi=e=>{let t=he(e)?cr(e):e,{contextVariableDefaultValues:n}=an(t??{});return D(n)},Zl=()=>({...D(kt)}),ec=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:i})=>{if(e===void 0)return{runtimeState:D(n),hasLoadedValues:!1};if(!L(e))throw new Error(`Malformed ${i}.`);let a=D(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=un(s,D(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},uh=({projectData:e,loadedGlobalRuntime:t={}})=>ec({loadedRuntime:t,runtimeIds:ti,defaults:si(e),path:"global.runtime"}).runtimeState,ph=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=ec({loadedRuntime:e,runtimeIds:ni,defaults:Zl(),path:"context.runtime"});return n?t:void 0},Dr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ne=e=>{let t=Dr(e);return t?.kind==="sceneReplay"&&L(t.sceneReplay)?t:null},rc=(e,t)=>{let n=t?.sceneReplay?.sceneId,i=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(i?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=D(r)})},dh=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:D(e.global.nextLineConfig),overlayStack:D(e.global.overlayStack),confirmDialog:D(e.global.confirmDialog),formDrafts:D(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:D(e.global.pendingScreenTransition)}}),fh=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=_t(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},mh=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=D(t.nextLineConfig),e.global.overlayStack=D(t.overlayStack),e.global.confirmDialog=D(t.confirmDialog),e.global.formDrafts=D(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=D(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Oe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:it({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}})},yh=e=>e.runtime?(ni.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=D(kt[t]))}),e.runtime):(e.runtime=Zl(),e.runtime),hh=e=>Sa(e.global),tc=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:hh(e)}})},zi=(e,t,n)=>{let i=un(t,n);if(t in kt){let a=Dr(e);if(!a)return i;let r=yh(a);return r[t]=i,i}return e.global[t]=i,i},Gi=({pointer:e,projectData:t,kind:n,sceneReplay:i})=>({...n===void 0?{}:{kind:n},...i===void 0?{}:{sceneReplay:D(i)},currentPointerMode:"read",pointers:{read:D(e)},configuration:{},views:[],bgm:Ty(),variables:Yi(t),rollback:$t({pointer:e})}),st=e=>e?(e.currentPointerMode="read",L(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,gh=(e,{queueRender:t=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],i=n?.pointers?.read;if(!n||!i?.sectionId||!i?.lineId)return null;let a=Gi({pointer:i,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,bh(e,{queueRender:t}),a},bh=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,tt(e),nt(e),e.global.nextLineConfig=_t(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Mi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},nc=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},$t=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[Pn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},wr=(e,t={})=>{if(e?.rollback)return nc(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=$t({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},Hi=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=wr(n);if(i.isRestoring)return;let a=Vi(n);i.currentIndex<i.timeline.length-1&&(i.timeline=i.timeline.slice(0,i.currentIndex+1)),i.timeline.push(Pn(t)),i.currentIndex=i.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,i.currentIndex),a.checkpointLengths.push(a.currentLength))},Ih=({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}},wh=({state:e},t={})=>{let{checkpointIndex:n,checkpointIdentity:i,sectionId:a,lineId:r}=t,o=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(o?.timeline)||typeof o.currentIndex!="number")return e;let l=o.timeline[n];return(he(l)?Ht(l):l)!==i||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},vh=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:i,checkpointIndex:a,sectionId:r,lineId:s}=t,o=rt(n),l=e.global.saveSlots?.[o],c=he(l)?Ht(l):l;if(!l||c!==i)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,m.returnabilityVersion=_i,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Ah=(e,t)=>{let n=e.contexts?.[e.contexts.length-1],i=n?.rollback;if(!i||i.isRestoring||!Array.isArray(i.timeline)||typeof i.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:i.currentIndex;if(r<0||r>=i.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<i.timeline.length-1){i.timeline=i.timeline.slice(0,r+1);let s=Vi(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return i.timeline[r]??null},kh=({state:e,rollbackActionBatchStack:t},n={})=>{let i=n?.source===Ol?Ol:Bi,a=e.contexts?.[e.contexts.length-1],r=a?.rollback;if(!r||r.isRestoring||!Array.isArray(r.timeline)||typeof r.currentIndex!="number"||r.currentIndex<0||r.currentIndex>=r.timeline.length)return t.push({checkpointIndex:null,source:i}),e;if(r.currentIndex<r.timeline.length-1){r.timeline=r.timeline.slice(0,r.currentIndex+1);let s=Vi(a);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r.currentIndex+1))}return t.push({checkpointIndex:r.currentIndex,source:i}),e},Ph=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),We=(e,t,n,i)=>{let r=i?.at(-1)?.source??Bi;if(!Cb(t,r))return;let s=Ah(e,i);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:D(n)}))},Cl=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=t?.operations??[];for(let{variableId:a,op:r,value:s,roundTo:o}of i){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(qe(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);vt(c,a),ln(u,r,a),Ks(u,r,s,a,{roundTo:o}),c==="context"&&(n.variables[a]=cn(n.variables[a],r,s,{roundTo:o}))}},xh=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:i})=>{$b(e,n,i)})},Eh=(e,t)=>{let{sectionId:n,lineId:i}=t,s=we({state:e},{sectionId:n})?.lines?.find(o=>o.id===i)?.actions;s&&Object.entries(s).forEach(([o,l])=>{Lc(e,o,l)})},sc=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let i=wr(n),a=i.timeline[t];if(!a)return e;e.global.autoMode&&Lt({state:e}),e.global.skipMode&&Ir({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),i.isRestoring=!0,i.currentIndex=t;try{n.variables=Yi(e.projectData),n.kind==="sceneReplay"&&(rc(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=D(An),e.global.overlayStack=[],tt(e),nt(e),e.global.isLineCompleted=!0;let r=i.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&Li(e),Eh(e,i.timeline[l]),xh(e,i.timeline[l]);let s=st(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let o=qi(n);o&&(o.currentLength=Math.min(o.checkpointLengths[t]??0,o.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Nl(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{i.isRestoring=!1}return e},Sh=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 i=e.global??{},{saveSlots:a={},variables:r={},runtime:s={},accountViewedRegistry:o={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=i;ql(t),gt(t),bt(t),It(t),Rr(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:y}=an(t),g={...y,...Gr(r,t.resources?.variables??{})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Fy(o,"accountViewedRegistry"),accountReplayRegistry:Uy(l),nextLineConfig:_t(),imageGalleryNavigation:ji(),sceneReplayNavigation:Ti(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:xn(),saveSlots:qy(a),localizationPackages:D(c),overlayStack:[],variables:g,...uh({projectData:t,loadedGlobalRuntime:s})},contexts:[Gi({pointer:f,projectData:t})]}},Rh=({state:e})=>e.global.overlayStack||[],Oh=({state:e})=>e.global.pendingEffects,ic=({state:e})=>e.global.skipMode,Ch=({state:e})=>e.global.autoMode,oc=({state:e})=>e.global.dialogueUIHidden,ac=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let i,a=L(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)i=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=n.pointers.read,p=we({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let m=p.lines.findIndex(d=>d.id===u);i=p.lines.slice(0,m+1).map(d=>({sectionId:c,lineId:d.id}))}let r=[],s=wt({variables:{...e.global?.variables??{},...Dr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),o=new Map,l=c=>{let u=o.get(c.sectionId);if(!u){let m=we({state:e},{sectionId:c.sectionId}),d=Array.isArray(m?.lines)?m.lines:[];u={lines:d,lineIndexes:new Map(d.map((f,y)=>[f.id,y])),projections:new Map,nextLineIndex:0,presentationState:{}},o.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=Or([u.presentationState,d]),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 i){if(!Ny(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:m,dialogueState:d}=u;if(!m.dialogue)continue;let f=on({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:s}),y=jy({sectionId:c.sectionId,lineId:p.id,content:m.dialogue.append===!0?d.content:m.dialogue.content,dialogueState:d,characterName:f}),g=r[r.length-1];if((a?c.appendToPrevious===!0:m.dialogue.append===!0)&&g?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}r.push(y)}return r},$h=(e,t,n)=>{let i=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:s,sectionId:o,lineId:l}=a,c=e.global.saveSlots?.[rt(r)],u=he(c)?Ht(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==o||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=D(n),i=!0)}i&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},_h=({state:e},t={})=>{let n=Dr(e),i=n?.pointers?.read,a=Dt({state:e});if(!n||!L(a?.actions?.dialogue))return e;let r=wr(n),s=r.timeline?.[r.currentIndex],o=s?.sectionId===i?.sectionId&&s?.lineId===i?.lineId,l=qi(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===i.sectionId&&p?.lineId===i.lineId||t.forceNewOccurrence!==!0&&o&&l&&c===l.currentLength&&c>u&&p?.sectionId===i.sectionId&&p?.lineId===i.lineId)return e;let m=Dy(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&zl(e.projectData,p,i);if(m.entries.push({sectionId:i.sectionId,lineId:i.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,o){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return $h(e,t.savedCheckpointOccurrences,m),e},jh=({state:e})=>e.global.confirmDialog??null,Nt=({state:e},{pointer:t}={})=>{let n=t??$e({state:e})?.pointer,i=lh({state:e,pointer:n});return ch({state:e,form:i.form,pointer:n})},Nh=({state:e},{pointer:t}={})=>!!Nt({state:e},{pointer:t}),Oe=({state:e},{pointer:t}={})=>{let n=Nt({state:e},{pointer:t});if(n)return{source:br,formId:n.id,formKey:n.key};let i=fc({state:e,pointer:t});return i?{source:Zr,resourceId:i}:null},Dh=({state:e,registry:t},n)=>{let{sectionId:i,lineId:a}=n,s=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===i);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let o=we({state:e},{sectionId:i});if(!o||!o.lines||!Array.isArray(o.lines))return s.lastLineId===a;let l=o.lines.findIndex(u=>u.id===s.lastLineId),c=o.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},Xi=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},Wi=({state:e},t)=>Dh({state:e,registry:e.global.accountViewedRegistry},t),Th=({state:e},t)=>Xi({registry:e.global.accountViewedRegistry},t),Ct=(e,t)=>!Xi({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Ki=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Ji=(e,t)=>{let n=Ki(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Oi=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!Ct(e,t[a]))return t[a]},Lh=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:D(t)},lc=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??ji(),i=Ki(t),a=Ji(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:Ct(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:Ct(e,c)}))})),o=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&&!Ct(e,p)&&(o={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:Oi(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:Oi(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:o,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Qi=(e,t)=>!Xi({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Zi=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),eo=(e,t)=>{let n=Zi(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Ci=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!Qi(e,t[a]))return t[a]},cc=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}),Mh=(e,t)=>({...cc(t),locked:Qi(e,t)}),$l=e=>{let t=Math.floor(e/1e3),n=t%60,i=Math.floor(t/60);if(i<60)return`${i}:${String(n).padStart(2,"0")}`;let a=Math.floor(i/60),r=i%60;return`${a}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},qh=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:D(t)},uc=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??xn(),i=Zi(t),a=eo(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>Mh(e,u)),o=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[o],c=l?{...cc(l),canPlayPreviousTrack:Ci(e,t.tracks,o,-1)!==void 0,canPlayNextTrack:Ci(e,t.tracks,o,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:$l(n.positionMs),durationText:n.durationMs===null?null:$l(n.durationMs),canPlay:n.status!=="playing",canPause:n.status==="playing",canSeek:n.readiness==="ready"&&n.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},ro=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),to=(e,t)=>{let n=ro(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Vh=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:D(t)},Fh=({state:e})=>ne(e)!==null,Uh=({state:e})=>{let t=ne(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},pc=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,dc=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??Ti(),i=ro(t),a=to(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:!pc(e,l.sceneId)})),o=ne(e);return{isActive:o!==null,activeSceneId:o?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},Bh=({state:e})=>e.global.nextLineConfig,fc=({state:e,pointer:t}={})=>{let n=t??$e({state:e})?.pointer;if(!n)return;let i=n?.sectionId,a=n?.lineId,s=we({state:e},{sectionId:i})?.lines||[],o=s.findIndex(c=>c.id===a);if(o<0)return;let l;for(let c of s.slice(0,o+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},mc=({state:e})=>!!fc({state:e}),Yh=({state:e})=>structuredClone(e),zh=({state:e})=>D(e.projectData.resources?.achievements??{}),Gh=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:D(n)},yc=({state:e})=>e.global.saveSlots,Hh=({state:e},t)=>{let n=t?.slotId,i=rt(n);return e.global.saveSlots[i]},hc=({state:e})=>D(e.global.localizationPackages),no=({state:e})=>Cr(e),Xh=({state:e},t)=>yr(e,t?.runtimeId),Sn=({state:e})=>{let t={...e.global?.variables??{},...Dr(e)?.variables??{}};return wt({variables:t,runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{}})},$e=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},we=({state:e},t)=>{let{sectionId:n}=t;return ir(e.projectData,n).section},Dt=({state:e})=>{let t=$e({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:i}=t.pointer,a=we({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===i)},gc=({state:e})=>{let{sectionId:t,lineId:n}=$e({state:e}).pointer,a=we({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===n),o=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(m=>{p[m]=u[m]}),p});return Or(o)},Wh=e=>{let t=Dt({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=Sn({state:e});return t.content.map(i=>`${Hr(i?.text,{variables:n})??""}`).join("")},it=({state:e})=>El({text:Wh(e),baseDelay:yr(e,"autoForwardDelay"),speed:yr(e,"autoForwardSpeed")}),Kh=({state:e})=>{let t=bc({state:e}),i=Dt({state:e})?.actions??{},a=Or([t??{},i]);return Qs(t??{},a??{})},Jh=({state:e},{sectionId:t})=>{let n=we({state:e},{sectionId:t});if(!n?.lines)return[];let i=[],a={};for(let r of n.lines){let s=r.actions||{},o=Or([a,s]),l=Qs(a,o);i.push({id:r.id,changes:l,presentationState:o}),a=Zs(o)}return i},Qh=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let i=Jh({state:e},{sectionId:t});return n?{lines:i}:{lines:i.map(({presentationState:a,...r})=>r)}},bc=({state:e})=>{let{sectionId:t,lineId:n}=$e({state:e}).pointer,a=we({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===n);if(r<=0)return null;let o=a.slice(0,r).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return Zs(Or(o))},so=({state:e},{slotsPerPage:t=6}={})=>{let a=((no({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let s=0;s<t;s++){let o=a+s,l=e.global.saveSlots&&e.global.saveSlots[rt(o)]||{};r.push({...l,slotId:o})}return{saveSlots:r}},Zh=yc,eg=so,rg=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},tg=({state:e},t={})=>{let n=gc({state:e}),i=bc({state:e}),a=Dt({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:D(r)}:a,o=r?.animations&&i===null?{}:i,{sectionId:l}=$e({state:e}).pointer,{sceneId:c}=ir(e.projectData,l),u={...no({state:e}),localizationPackages:hc({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=Nt({state:e}),f=mc({state:e}),y=lc({state:e}),g=uc({state:e}),h=dc({state:e}),I=Sn({state:e}),{saveSlots:b}=so({state:e}),x=rg(e);return sl({presentationState:n,previousPresentationState:o,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:Vc({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||x,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:ac({state:e}),saveSlots:b,variables:I,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:D(e.global.musicRoomPlayer)})},ng=({state:e},t)=>(e.global.confirmDialog=rh(t),e.global.pendingEffects.push({name:"render"}),e),sg=({state:e})=>(e.global.confirmDialog&&(tt(e),e.global.pendingEffects.push({name:"render"})),e),ig=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),We(e,"pushOverlay",n,t),e),og=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),We(e,"popOverlay",void 0,t),e),ag=({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"}),We(e,"replaceLastOverlay",n,t),e),lg=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],tt(e),nt(e),e.global.pendingEffects.push({name:"render"}),We(e,"clearOverlays",void 0,t),e),cg=(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"})},Tt=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,nh(e,n),nt(e);let i=Oe({state:e},{pointer:t}),a=i?.source===Zr,r=i?.source===br;cg(e,{activeInteraction:i});let s=ne(e),o={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Nl(e);s.sceneReplay.entryId=l,o.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(o),{isChoiceVisible:a,isFormVisible:r,activeInteraction:i}},Rn=(e,t,n)=>{!(t?.source===Zr||t?.source===br)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Ic=({state:e})=>(Oe({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:it({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),Lt=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),ug=({state:e})=>{let t=e.global.autoMode;return Oe({state:e})&&!t||(t?Lt({state:e}):Ic({state:e})),e},wc=({state:e})=>(Oe({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),Ir=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),pg=({state:e})=>{let t=ic({state:e});return Oe({state:e})&&!t||(t?Ir({state:e}):wc({state:e})),e},On=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),We(e,"showDialogueUI",void 0,t),e),vc=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),We(e,"hideDialogueUI",void 0,t),e),dg=e=>{let{state:t}=e;return oc({state:t})?On(e):vc(e),t},vr=(e,t,n)=>(zi(e,t,n),tc(e),e.global.pendingEffects.push({name:"render"}),e),Mt=(e,t,n,i,a)=>{let r=zi(e,t,n);return e.global.pendingEffects.push({name:"render"}),We(e,i,{value:r},a),e},fg=({state:e},t)=>vr(e,"dialogueTextSpeed",t?.value),mg=({state:e},t)=>vr(e,"autoForwardDelay",t?.value),yg=({state:e},t)=>vr(e,"autoForwardSpeed",t?.value),hg=({state:e},t)=>vr(e,"skipUnseenText",t?.value),gg=({state:e},t)=>vr(e,"skipTransitionsAndAnimations",t?.value),bg=({state:e},t)=>vr(e,"soundVolume",t?.value),Ig=({state:e},t)=>vr(e,"musicVolume",t?.value),wg=({state:e},t)=>vr(e,"muteAll",t?.value),vg=({state:e,rollbackActionBatchStack:t},n)=>Mt(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),Ag=({state:e,rollbackActionBatchStack:t})=>{let n=yr(e,"saveLoadPagination")+1;return Mt(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},kg=({state:e,rollbackActionBatchStack:t})=>{let n=yr(e,"saveLoadPagination")-1;return Mt(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},Pg=({state:e,rollbackActionBatchStack:t},n)=>Mt(e,"menuPage",n?.value,"setMenuPage",t),xg=({state:e,rollbackActionBatchStack:t},n)=>Mt(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),Eg=({state:e})=>(e.global.pendingEffects=[],e),Sg=({state:e},t)=>(e.global.pendingEffects.push(t),e),Rg=({state:e},t)=>{if(ne(e))return e;let n=t?.resourceId;return Dl(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},Og=({state:e},t)=>{if(ne(e))return e;let n=t?.resourceId,i=Dl(e,n);if(i.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(i.target)||i.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let r=Math.min(a,i.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:r,target:i.target,completed:r>=i.target}}),e},Ac=(e,{sectionId:t,resetStoryState:n=!1,screen:i})=>{let a=!!Kl(i),r=we({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=r.lines?.[0];if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!gh(e,{queueRender:!a}))return e;let o=Oe({state:e});n&&e.global.skipMode&&Ir({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=st(l),p=u.read;n||Nr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||wr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=$t({pointer:u.read}):Hi(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=Tt(e,l?.pointers?.read,{screenTransition:i});return Rn(e,o,c),e},Cg=({state:e},t)=>{if(ne(e))throw new Error("Cannot reset the story while a scene replay is active");return Ac(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},kc=e=>(e.global.accountViewedRegistry=Cy(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Cn=(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:D(n.value)}))}})},Pc=(e,t)=>{Cn(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:[]}}])},$g=(e,t,{sectionId:n,lineId:i})=>{if(!n||!i)return!1;let a=L(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=we({state:e},{sectionId:n});if(s?.lines){let o=s.lines.findIndex(c=>c.id===r.lastLineId),l=s.lines.findIndex(c=>c.id===i);if(o===-1||l>o)return r.lastLineId===i?!1:(r.lastLineId=i,!0)}else return r.lastLineId===i?!1:(r.lastLineId=i,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:i}),!0},Nr=(e,t)=>{if(ne(e)||e.global.accountViewedRegistry===void 0)return;$g(e,kc(e),t)&&Pc(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},_g=({state:e},t)=>(Nr(e,t),e.global.pendingEffects.push({name:"render"}),e),jg=({state:e},t)=>{if(ne(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let i=kc(e);i.resources.find(r=>r.resourceId===n)||(i.resources.push({resourceId:n}),Pc(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Ke=(e,t,n)=>{if(!L(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(i=>{if(!n.has(i))throw new Error(`${e} payload contains unsupported property "${i}"`)})},$i=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},$n=(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"}))},Ng=({state:e},t)=>{let n="showImageGalleryVariant";Ke(n,t,ky),$i(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&$i(n,"variantId",t.variantId);let i=e.projectData?.resources?.imageGallery;if(i===void 0)return e;let a=i.groups.findIndex(o=>o.id===t.groupId),r=i.groups[a];if(!r)return e;let s=t.variantId===void 0?r.variants[0]:r.variants.find(o=>o.id===t.variantId);return!s||Ct(e,s)||$n(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/i.pageSize)}),e},xc=(e,t,n,i)=>{Ke(i,t,Ni);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),o=s?.variants.findIndex(c=>c.id===r.variantId);if(!s||o===void 0||o<0)return e;let l=Oi(e,s.variants,o,n);return l&&$n(e,{...r,variantId:l.id}),e},Dg=({state:e},t)=>xc(e,t,-1,"moveToPreviousImageGalleryVariant"),Tg=({state:e},t)=>xc(e,t,1,"moveToNextImageGalleryVariant"),Lg=({state:e},t)=>{if(Ke("clearImageGallerySelection",t,Ni),e.projectData?.resources?.imageGallery===void 0)return e;let i=e.global.imageGalleryNavigation;return $n(e,{groupId:null,variantId:null,pageIndex:i.pageIndex}),e},Ec=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let i=Ki(n);if(t>=i)return e;let a=e.global.imageGalleryNavigation,r=Ji(n,a);return t===r||$n(e,{groupId:null,variantId:null,pageIndex:t}),e},Mg=({state:e},t)=>{if(Ke("moveToImageGalleryPage",t,Py),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Ec(e,t.pageIndex)},Sc=(e,t,n,i)=>{Ke(i,t,Ni);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Ji(a,e.global.imageGalleryNavigation)+n;return s<0?e:Ec(e,s)},qg=({state:e},t)=>Sc(e,t,1,"moveToNextImageGalleryPage"),Vg=({state:e},t)=>Sc(e,t,-1,"moveToPreviousImageGalleryPage"),or=(e,t,n)=>{if(!L(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(i=>{if(!n.has(i))throw new Error(`${e} payload contains unsupported property "${i}"`)})},Fg=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},Be=e=>{e.global.pendingEffects.push({name:"render"})},Rc=(e,t)=>{let n=e.projectData.resources.musicRoom,i=e.global.musicRoomPlayer,a=i.trackId!==null,r=i.trackId===t.id,s=i.bgmPlayback;a||(s={commandId:En(e),operation:"pause"});let o=jt(e,"play",0),l=n.tracks.indexOf(t),c=r?i.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:o,seekFallback:null,bgmPlayback:s},Be(e)},Ug=({state:e},t)=>{let n="playMusicRoomTrack";or(n,t,xy),Fg(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Qi(e,a)||Rc(e,a),e},Bg=({state:e},t)=>{or("playMusicRoom",t,et);let i=e.global.musicRoomPlayer;if(i.trackId===null||i.status==="playing")return e;let a=i.status==="ended",r=i.readiness==="error",s=i.status==="paused"&&!r?"resume":"play",o=a?0:i.positionMs;return i.playback=jt(e,s,s==="play"?o:void 0),i.seekFallback=null,i.status="playing",i.positionMs=o,r&&(i.readiness=i.durationMs===null?"loading":"ready"),Be(e),e},Yg=({state:e},t)=>{or("pauseMusicRoom",t,et);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status!=="playing"||(i.playback=jt(e,"pause"),i.seekFallback=null,i.status="paused",Be(e)),e},zg=({state:e},t)=>{or("stopMusicRoom",t,et);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status==="stopped"&&i.positionMs===0||(i.playback=jt(e,"stop"),i.seekFallback=null,i.status="stopped",i.positionMs=0,Be(e)),e},Gg=({state:e},t)=>{if(or("seekMusicRoom",t,Ey),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let i=e.global.musicRoomPlayer;if(i.trackId===null||i.readiness!=="ready"||i.durationMs===null||t.positionMs>i.durationMs)return e;let a=jt(e,"seek",t.positionMs);return i.seekFallback={commandId:a.commandId,status:i.status,positionMs:i.positionMs},i.playback=a,i.positionMs=t.positionMs,t.positionMs===i.durationMs?i.status="ended":i.status==="ended"&&(i.status="stopped"),Be(e),e},Oc=(e,t,n,i)=>{or(i,t,et);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 o=Ci(e,a.tracks,s,n);return o&&Rc(e,o),e},Hg=({state:e},t)=>Oc(e,t,-1,"playPreviousMusicRoomTrack"),Xg=({state:e},t)=>Oc(e,t,1,"playNextMusicRoomTrack"),Wg=({state:e},t)=>{or("clearMusicRoomSelection",t,et);let i=e.global.musicRoomPlayer;if(i.trackId===null)return e;let a=i.pageIndex,r={commandId:En(e),operation:"resume"};return e.global.musicRoomPlayer={...xn({bgmPlayback:r}),pageIndex:a},Be(e),e},Cc=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=Zi(n))return e;let i=e.global.musicRoomPlayer,a=eo(n,i);return t===a||(i.pageIndex=t,Be(e)),e},Kg=({state:e},t)=>{if(or("moveToMusicRoomPage",t,Sy),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Cc(e,t.pageIndex)},$c=(e,t,n,i)=>{or(i,t,et);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=eo(a,e.global.musicRoomPlayer)+n;return r<0?e:Cc(e,r)},Jg=({state:e},t)=>$c(e,t,1,"moveToNextMusicRoomPage"),Qg=({state:e},t)=>$c(e,t,-1,"moveToPreviousMusicRoomPage"),jr=e=>{let t=ne(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=D(t.sceneReplay.returnState),i=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==i),e.contexts.pop(),mh(e,n),e.global.pendingEffects.push({name:"render"}),!0},Zg=({state:e},t)=>{let n="startSceneReplay";if(Ke(n,t,Ry),$i(n,"sceneId",t.sceneId),ne(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||!pc(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,o=r?.sections?.[s],l=o?.initialLineId??o?.lines?.[0]?.id;if(!o||!l||!o.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=dh(e);fh(e);let u=Gi({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 rc(e,u),e.contexts.push(u),Tt(e,u.pointers.read),e},_c=({state:e},t)=>{Ke("finishSceneReplay",t,Di);let i=ne(e);if(i)return i.sceneReplay.finishOnNextAdvance=!0,e;if(Dr(e)?.rollback?.isRestoring===!0)return e;let r=$e({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=$y(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Cn(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},eb=({state:e},t)=>(Ke("exitSceneReplay",t,Di),jr(e),e),jc=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=ro(n))return e;let i=to(n,e.global.sceneReplayNavigation);return t===i||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},rb=({state:e},t)=>{if(Ke("moveToSceneReplayPage",t,Oy),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return jc(e,t.pageIndex)},Nc=(e,t,n,i)=>{Ke(i,t,Di);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=to(a,e.global.sceneReplayNavigation)+n;return r<0?e:jc(e,r)},tb=({state:e},t)=>Nc(e,t,1,"moveToNextSceneReplayPage"),nb=({state:e},t)=>Nc(e,t,-1,"moveToPreviousSceneReplayPage"),_n=(e,t)=>{let n=e.global.musicRoomPlayer;return!L(t)||t.id!==vy||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},io=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,Dc=(e,t,n,{readiness:i=t.readiness}={})=>((t.readiness!==i||t.positionMs!==n.positionMs||t.durationMs!==n.durationMs||t.seekFallback!==null)&&(t.readiness=i,t.positionMs=n.positionMs,t.durationMs=n.durationMs,t.seekFallback=null,Be(e)),e),sb=({state:e},t)=>{let n=_n(e,t);return!n||n.readiness!=="loading"||!io(t)?e:Dc(e,n,t,{readiness:"ready"})},ib=({state:e},t)=>{let n=_n(e,t);return!n||n.readiness!=="ready"||!io(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:Dc(e,n,t)},ob=({state:e},t)=>{let n=_n(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!io(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,Be(e)),e},ab=({state:e},t)=>{let n=_n(e,t);if(!n||typeof t.errorCode!="string"||!Ay.has(t.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(t.errorCode==="invalid-position"){let i=n.seekFallback;if(n.playback.operation!=="seek"||i?.commandId!==t.commandId)return e;let a=n.status!==i.status||n.positionMs!==i.positionMs;return n.status=i.status,n.positionMs=i.positionMs,n.seekFallback=null,a&&Be(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,Be(e),e},Tc=({state:e,rollbackActionBatchStack:t},n)=>{let i=Ly(n.manual),{auto:a,applyMode:r}=n,s=e.global.nextLineConfig.auto?.enabled,o=e.global.nextLineConfig?.applyMode,l=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;i&&a?(e.global.nextLineConfig={manual:i,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:o!==void 0&&(e.global.nextLineConfig.applyMode=o)):(i&&(e.global.nextLineConfig.manual=i),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let c=e.global.nextLineConfig.auto?.enabled,u=Oe({state:e});return!l&&!u&&c===!0&&!s?e.global.nextLineConfig.auto?.trigger==="fromStart"?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}}):e.global.isLineCompleted&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}}):!l&&c===!1&&s&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.pendingEffects.push({name:"render"}),We(e,"setNextLineConfig",n,t),e},lb=({state:e},t)=>{if(ne(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;if(n==null||n==="")throw new Error("saveSlot requires slotId");let{thumbnailImage:i}=t,a=t?.savedAt,r=rt(n),s=D(e.contexts);s?.forEach(c=>{st(c),nc(c.rollback),Vy(c.rollback)});let o={contexts:s},l={formatVersion:jl,slotId:Vl(n),savedAt:typeof a=="number"?a:Date.now(),image:i,state:o};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},cb=({state:e},t)=>{if(ne(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;if(n==null||n==="")throw new Error("loadSlot requires slotId");let i=rt(n),a=e.global.saveSlots[i];if(a){let r=eh(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=_t(),e.global.overlayStack=[],e.global.isLineCompleted=!0,tt(e),nt(e),Mi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},ub=({state:e},t)=>{if(ne(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;ql(n),gt(n),bt(n),It(n),Rr(n?.resources?.variables??{}),si(n),e.projectData=n,e.global.imageGalleryNavigation=ji(),e.global.sceneReplayNavigation=Ti(),Mi(e);let i=n?.resources?.variables??{},{contextVariableDefaultValues:a,globalVariablesDefaultValues:r}=an(n??{});return Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...r,...Gr(e.global.variables,i)}),e.contexts?.forEach(s=>{Object.prototype.hasOwnProperty.call(s??{},"variables")&&(s.variables={...a,...Gr(s.variables,i)})}),tt(e),nt(e),e.global.pendingEffects.push({name:"render"}),e},pb=({state:e},t)=>{let{l10nId:n,projectData:i}=t??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!L(i))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=i,zi(e,"localizationPackageId",n),tc(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Oe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:it({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},db=({state:e},t)=>{let{sectionId:n,lineId:i}=t;if(!i)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&&!we({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=we({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===i))return console.warn(`Line not found: ${i} in section ${r}`),e;let l=Oe({state:e}),c=st(a);c.read={sectionId:r,lineId:i};let{activeInteraction:u}=Tt(e,c.read);return Rn(e,l,u),e},fb=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return On({state:e,rollbackActionBatchStack:t}),e;let i=Oe({state:e});if(i?.source===Zr&&n?.bypassChoice!==!0||i?.source===br&&n?._interactionSource!==br)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ne(e)?.sceneReplay.exitOnLineCompleted)return jr(e),e;let d=$e({state:e})?.pointer,f=d?.sectionId,y=d?.lineId;f&&y&&Nr(e,{sectionId:f,lineId:y}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!i&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:it({state:e})}});let g=e.global.nextLineConfig;return g?.auto?.enabled&&!i&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ne(e)?.sceneReplay.finishOnNextAdvance)return jr(e),e;let r=$e({state:e})?.pointer,s=r?.sectionId,o=we({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=o?.lines||[],p=c.findIndex(m=>m.id===r?.lineId)+1;if(p<c.length){let m=c[p],d=!yr(e,"skipUnseenText");if(e.global.skipMode&&d&&!Wi({state:e},{sectionId:s,lineId:m.id}))return Ir({state:e}),e;if(l&&!l.rollback&&wr(l,{compatibilityAnchor:!0}),l){let y=st(l),g=y.read?.lineId;g&&s&&Nr(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:m.id}}Hi(e,{sectionId:s,lineId:m.id}),Li(e);let{activeInteraction:f}=Tt(e,{sectionId:s,lineId:m.id});Rn(e,i,f)}else{if(ne(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),jr(e),e;e.global.autoMode&&Lt({state:e}),e.global.skipMode&&Ir({state:e})}return e},mb=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ne(e)?.sceneReplay.exitOnLineCompleted)return jr(e),e;let n=Oe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:it({state:e})}});let i=$e({state:e})?.pointer,a=i?.sectionId,r=i?.lineId;a&&r&&Nr(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},yb=({state:e},t)=>Ac(e,{sectionId:t?.sectionId,screen:t?.screen}),hb=({state:e,rollbackActionBatchStack:t},n)=>{let i=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!i)return On({state:e,rollbackActionBatchStack:t}),e;let a=Oe({state:e});if(a?.source===Zr&&n?.bypassChoice!==!0||a?.source===br&&n?._interactionSource!==br||a&&a.source!==Zr&&a.source!==br)return e;let r=ne(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(jr(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=$e({state:e})?.pointer,o=s?.sectionId,l=we({state:e},{sectionId:o}),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=!yr(e,"skipUnseenText");if(e.global.skipMode&&f&&!Wi({state:e},{sectionId:o,lineId:d.id})&&(Ir({state:e}),!i))return e;if(c&&!c.rollback&&wr(c,{compatibilityAnchor:!0}),c){let g=st(c),h=g.read?.lineId;h&&o&&Nr(e,{sectionId:o,lineId:h}),g.read={sectionId:o,lineId:d.id}}Hi(e,{sectionId:o,lineId:d.id}),Li(e);let{activeInteraction:y}=Tt(e,{sectionId:o,lineId:d.id});Rn(e,a,y)}else{if(ne(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),jr(e),e;e.global.autoMode&&Lt({state:e}),e.global.skipMode&&Ir({state:e}),e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))}return e},oo=(e,t={})=>{let n=Nt({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},gb=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],i=n?.scope,a=n?.type;if(qe(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(vt(i,t.variableId),ln(a,"set",t.variableId),ne(e)&&i!=="context")throw new Error(`Cannot update ${i}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:i}},bb=(e,t)=>({id:e.id,key:e.key,valid:!0,values:D(t),fields:D(e.fields),fieldList:D(e.fieldList)}),Ib=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=$e({state:e})?.pointer,n=t?.sectionId,i=t?.lineId;n&&i&&Nr(e,{sectionId:n,lineId:i})},wb=({state:e},t={})=>{let n=oo(e,t),i=t.field;if(!n?.fields?.[i])return e;let a=Ql(e,n.key),r=kn(t.value),s=n.fields[i],o=Ui(s,r);return a.values[i]=r,a.touched[i]=!0,o?a.errors[i]=o:delete a.errors[i],e.global.pendingEffects.push({name:"render"}),e},vb=({state:e,rollbackActionBatchStack:t},n={})=>{let i=oo(e,n);if(!i)return{submitted:!1,valid:!1,reason:"inactive"};let a=Ql(e,i.key);a.submitted=!0;let r={},s={};if(Object.entries(i.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,y=Ui(d,f);a.touched[m]=!0,y&&(s[m]=y),r[m]=Jl(d,f)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:D(s),form:{id:i.id,key:i.key,values:D(r)}};let o=e.contexts[e.contexts.length-1];if(o?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(i.fields).forEach(([m,d])=>{let{scope:f}=gb(e,d),y=f==="context"?o.variables:e.global.variables,g=r[m];y[d.variableId]=cn(y[d.variableId],"set",g),f==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:g})),(f==="device"||f==="account")&&c.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:D(y[d.variableId])})}),l&&We(e,"updateVariable",{id:"submitForm",operations:u},t),Cn(e,c);let p=bb(i,r);return Ib(e),delete e.global.formDrafts[i.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},Ab=({state:e},t={})=>{let n=oo(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:D(n.values),fields:D(n.fields),fieldList:D(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},kb=({state:e,rollbackActionBatchStack:t},n)=>{let{id:i,operations:a=[]}=n;if(!i)throw new Error("updateVariable requires an id field");if(typeof i!="string"||!/^[a-zA-Z0-9]+$/.test(i))throw new Error(`updateVariable id must be alphanumeric, got: "${i}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let s=!1,o=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=e.projectData.resources?.variables?.[c],f=d?.scope,y=d?.type;if(qe(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(vt(f,c),ln(y,u,c),Ks(y,u,p,c,{roundTo:m}),ne(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let g=f==="context"?r.variables:e.global.variables;if(f==="context"){s=!0;let h={variableId:c,op:u,value:p};m!==void 0&&(h.roundTo=m),l.push(h)}g[c]=cn(g[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&o.push({scope:f,path:`variables.${c}`,op:"set",value:D(g[c])})}),s&&We(e,"updateVariable",{id:i,operations:l},t),Cn(e,o),e.global.pendingEffects.push({name:"render"}),e},_l=e=>(t,n)=>e({state:t},n),Pb=e=>({variables:wt({variables:{...e.global?.variables??{},...Dr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Cr(e)}),xb=e=>{if(!L(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")},Eb=(e,t,n)=>{if(!L(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!L(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")},Sb=(e,t)=>{xb(t);for(let n=0;n<t.branches.length;n+=1){let i=t.branches[n];if(Eb(i,n,t.branches.length),!(Object.prototype.hasOwnProperty.call(i,"when")&&!ht(i.when,Pb(e)))){Object.entries(i.actions).forEach(([r,s])=>{Lc(e,r,s)});return}}},Rb={conditional:{replayLine:Sb},updateVariable:{recordSources:[Bi],replayLine:Cl,replayRecorded:Cl,persistInSaveSlot:!0},setNextLineConfig:{replayLine:_l(Tc)},finishSceneReplay:{replayLine:_l(_c)}},jn=e=>Rb[e]??null,Ob=e=>jn(e)?.persistInSaveSlot===!0,Cb=(e,t)=>{let n=jn(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},$b=(e,t,n)=>{jn(t)?.replayRecorded?.(e,n)},Lc=(e,t,n)=>{jn(t)?.replayLine?.(e,n)},_b=e=>e?.returnable!==!1,Mc=(e,t)=>{if(t>=0)return e.currentIndex+t;let n=Math.abs(t);for(let i=e.currentIndex-1;i>=0;i-=1)if(_b(e.timeline[i])&&(n-=1,n===0))return i;return-1},qc=({state:e},t)=>{let{offset:n}=t;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let i=e.contexts[e.contexts.length-1];if(!i)return null;let a=i.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=Mc(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},Vc=({state:e})=>qc({state:e},{offset:-1})!==null,jb=({state:e},t)=>{let{offset:n=-1}=t;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let i=e.contexts?.[e.contexts.length-1];if(!i)return e;let a=wr(i,{compatibilityAnchor:!i.rollback}),r=Mc(a,n);return r<0||r>=a.timeline.length?e:sc(e,r)},Nb=({state:e},t)=>{let{sectionId:n,lineId:i}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=wr(a,{compatibilityAnchor:!a.rollback}),o=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===i);if(o===-1)throw new Error(`Line ${i} not found in section ${n} rollback timeline`);return o===r.currentIndex?e:sc(e,o)},Fc=e=>{let t=Sh(e),n=[];return ra(t,{selectPendingEffects:Oh,selectSkipMode:ic,selectAutoMode:Ch,selectIsChoiceVisible:mc,selectIsFormVisible:Nh,selectActiveInteraction:Oe,selectActiveForm:Nt,selectDialogueUIHidden:oc,selectDialogueHistory:ac,selectConfirmDialog:jh,selectIsLineAccountViewed:Wi,selectIsResourceAccountViewed:Th,selectImageGalleryConfig:Lh,selectImageGallery:lc,selectMusicRoomConfig:qh,selectMusicRoom:uc,selectSceneReplayConfig:Vh,selectSceneReplay:dc,selectIsSceneReplayActive:Fh,selectActiveSceneReplayEntry:Uh,selectNextLineConfig:Bh,selectSystemState:Yh,selectAchievements:zh,selectAchievement:Gh,selectSaveSlotMap:yc,selectSaveSlots:Zh,selectSaveSlot:Hh,selectLocalizationPackages:hc,selectRuntime:no,selectRuntimeValue:Xh,selectAllVariables:Sn,selectCurrentPointer:$e,selectSection:we,selectCurrentLine:Dt,selectPresentationState:gc,selectAutoForwardTimerDelay:it,selectPresentationChanges:Kh,selectSectionLineChanges:Qh,selectSaveSlotPage:so,selectCurrentPageSlots:eg,selectRenderState:tg,selectOverlayStack:Rh,selectLineIdByOffset:qc,selectCanRollback:Vc,selectRollbackCursor:Ih,startAutoMode:Ic,stopAutoMode:Lt,toggleAutoMode:ug,startSkipMode:wc,stopSkipMode:Ir,toggleSkipMode:pg,showDialogueUI:On,hideDialogueUI:vc,toggleDialogueUI:dg,setDialogueTextSpeed:fg,setAutoForwardDelay:mg,setAutoForwardSpeed:yg,setSkipUnseenText:hg,setSkipTransitionsAndAnimations:gg,setSoundVolume:bg,setMusicVolume:Ig,setMuteAll:wg,setSaveLoadPagination:vg,incrementSaveLoadPagination:Ag,decrementSaveLoadPagination:kg,setMenuPage:Pg,setMenuEntryPoint:xg,showConfirmDialog:ng,hideConfirmDialog:sg,resetStoryAtSection:Cg,clearPendingEffects:Eg,appendPendingEffect:Sg,completeAchievement:Rg,setAchievementProgress:Og,beginRollbackActionBatch:kh,endRollbackActionBatch:Ph,markRollbackCheckpointTransient:wh,markSavedRollbackCheckpointTransient:vh,recordCurrentDialogueHistory:_h,addViewedLine:_g,addViewedResource:jg,showImageGalleryVariant:Ng,moveToPreviousImageGalleryVariant:Dg,moveToNextImageGalleryVariant:Tg,clearImageGallerySelection:Lg,moveToImageGalleryPage:Mg,moveToNextImageGalleryPage:qg,moveToPreviousImageGalleryPage:Vg,playMusicRoomTrack:Ug,playMusicRoom:Bg,pauseMusicRoom:Yg,stopMusicRoom:zg,seekMusicRoom:Gg,playPreviousMusicRoomTrack:Hg,playNextMusicRoomTrack:Xg,clearMusicRoomSelection:Wg,moveToMusicRoomPage:Kg,moveToNextMusicRoomPage:Jg,moveToPreviousMusicRoomPage:Qg,musicRoomSoundReady:sb,musicRoomSoundProgress:ib,musicRoomSoundComplete:ob,musicRoomSoundError:ab,startSceneReplay:Zg,finishSceneReplay:_c,exitSceneReplay:eb,moveToSceneReplayPage:rb,moveToNextSceneReplayPage:tb,moveToPreviousSceneReplayPage:nb,setNextLineConfig:Tc,saveSlot:lb,loadSlot:cb,updateProjectData:ub,updateLocalizationPackage:pb,sectionTransition:yb,jumpToLine:db,nextLine:fb,markLineCompleted:mb,rollbackToLine:Nb,rollbackByOffset:jb,pushOverlay:ig,popOverlay:og,replaceLastOverlay:ag,clearOverlays:lg,updateFormField:wb,submitForm:vb,cancelForm:Ab,updateVariable:kb,nextLineFromSystem:hb},{transformActionFirstArgument:a=>({state:a,rollbackActionBatchStack:n}),transformSelectorFirstArgument:a=>({state:a})})};var Db="route-engine",Tb="projectPersistence";var Bc=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),oe=e=>Object.prototype.toString.call(e)==="[object Object]",Uc="variables.",Lb=(e={})=>{let t=oe(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!oe(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)}:!oe(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Mb=(e={})=>{let t=oe(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!oe(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)}:!oe(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},qb=(e,t)=>{let n=Mb(e),i=Lb(t),a=n.sections.map(s=>({...s})),r=n.resources.map(s=>({...s}));return i.sections.forEach(s=>{let o=a.find(l=>l.sectionId===s.sectionId);if(!o){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(o.lastLineId!==void 0){if(s.lineId===void 0){delete o.lastLineId;return}o.lastLineId=s.lineId}}),i.resources.forEach(s=>{r.find(l=>l.resourceId===s.resourceId)||r.push({...s})}),{sections:a,resources:r}},Vb=(e={})=>{let t=oe(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(i=>typeof i=="string"&&i.length>0))]}},Fb=(e,t)=>{let n=Vb(e),i=oe(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...i.filter(a=>typeof a=="string"&&a.length>0)])]}},Yc=(e={})=>{let t=oe(e)?e:{};return{saveSlots:oe(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:oe(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:oe(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:oe(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:oe(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:oe(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},Ub=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!oe(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let i=t.path?.startsWith(Uc)?t.path.slice(Uc.length):null;if(i!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(i.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:i}}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(!oe(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}].`)})},Bb=(e,t)=>{let n={};return Ub(t).forEach(i=>{if(i.path==="viewedRegistry"){n.accountViewedRegistry=qb(n.accountViewedRegistry??e.accountViewedRegistry,i.value);return}if(i.path==="replayRegistry"){n.accountReplayRegistry=Fb(n.accountReplayRegistry??e.accountReplayRegistry,i.value);return}let a=i.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[a]={...e[a],...n[a],[i.variableId]:i.value}}),n},ot=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},Yb=e=>{let t=ot(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},zb=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},Gb=({indexedDB:e,databaseName:t,objectStoreName:n})=>new Promise((i,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},r.onsuccess=()=>{i(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),Hb=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let i=await e;return new Promise((a,r)=>{let l=i.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.`))}})},qt=async({databasePromise:e,objectStoreName:t,namespace:n,patch:i})=>{let a=await e;return new Promise((r,s)=>{let o=a.transaction(t,"readwrite"),l=o.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=Yc(c.result),f=typeof i=="function"?i(d):i,y={namespace:n,version:1,...Bc(),...d,...f},g=l.put(y);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},o.oncomplete=()=>{m()},o.onerror=()=>{p(o.error??new Error(`IndexedDB transaction failed while updating namespace "${n}".`))},o.onabort=()=>{p(o.error??new Error(`IndexedDB transaction aborted while updating namespace "${n}".`))}})},Xb=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let i=await e;return new Promise((a,r)=>{let s=i.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}".`))}})},ao=(e={})=>{let{indexedDB:t,databaseName:n=Db,objectStoreName:i=Tb,namespace:a}=e,r=zb(t),s=Yb(a),o=Gb({indexedDB:r,databaseName:n,objectStoreName:i});return{namespace:s,load:async()=>{let l=await Hb({databasePromise:o,objectStoreName:i,namespace:s});return{...Bc(),...Yc(l)}},clear:async()=>Xb({databasePromise:o,objectStoreName:i,namespace:s}),saveSlots:async l=>qt({databasePromise:o,objectStoreName:i,namespace:s,patch:{saveSlots:oe(l)?l:{}}}),saveGlobalDeviceVariables:async l=>qt({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalDeviceVariables:oe(l)?l:{}}}),saveGlobalAccountVariables:async l=>qt({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalAccountVariables:oe(l)?l:{}}}),saveGlobalRuntime:async l=>qt({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalRuntime:oe(l)?l:{}}}),applyScopedDataUpdates:async l=>qt({databasePromise:o,objectStoreName:i,namespace:s,patch:c=>Bb(c,l)})}},Wb=ao;var Qc=Zc;var Kb={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"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},ar=Object.prototype.hasOwnProperty,Jb={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 Ne(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=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:Jb.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=o,r!==null&&(o?r.length=o: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 Ne.errors=r,s===0}var Qb={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Dn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="continuity"||o==="speed"||o==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.continuity!==void 0){let o=e.continuity;if(typeof o!="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(!(o==="render"||o==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Qb.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 o=e.speed;if(typeof o=="number"){if(o<=0||isNaN(o)){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 o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Dn.errors=r,s===0}function J(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="resourceId"||o==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}e.playback!==void 0&&(Dn(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Dn.errors:r.concat(Dn.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return J.errors=r,s===0}function Tn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!ar.call(Kb.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let o={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let o={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let o={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let o={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.x!==void 0&&typeof e.x!="number"){let o={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.y!==void 0&&typeof e.y!="number"){let o={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.opacity!==void 0){let o=e.opacity;if(typeof o=="number"){if(o>1||isNaN(o)){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(o<0||isNaN(o)){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&&(Ne(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),s=r.length)),e.animations!==void 0&&(J(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Tn.errors=r,s===0}function Zc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Tn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Tn.errors:r.concat(Tn.errors),s=r.length),Zc.errors=r,s===0}var eu=ru;var Zb={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},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}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1},Hc={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}},required:["id","resourceId"],additionalProperties:!1},je=Gc().default;function _e(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[o]:r.push(o),s++}if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!ar.call(Hc.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let o=e.id;if(typeof o=="string"){if(je(o)<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 o=e.resourceId;if(typeof o=="string"){if(je(o)<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 o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){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(o<0||isNaN(o)){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 o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){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(o<-1||isNaN(o)){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 o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){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 o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){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 o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){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 o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Hc.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof o=="number"&&(o<0||isNaN(o))){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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return _e.errors=r,s===0}function Ln(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.resourceId===void 0&&(d="resourceId")||e.sounds===void 0&&(d="sounds")){let f={};r===null?r=[f]:r.push(f),s++}}var c=l===s;if(c){let d={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[d]:r.push(d),s++}else s=o,r!==null&&(o?r.length=o:r=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.startDelayMs===void 0&&(d="startDelayMs")||e.sounds===void 0&&(d="sounds")){let f={};r===null?r=[f]:r.push(f),s++}}var m=p===s;if(m){let d={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[d]:r.push(d),s++}else s=u,r!==null&&(u?r.length=u:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let d in e)if(!(d==="sounds"||d==="resourceId"||d==="loop"||d==="interruption"||d==="volume"||d==="muted"||d==="pan"||d==="startDelayMs")){let f={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(e.sounds!==void 0){let d=e.sounds;if(Array.isArray(d)){let f=d.length;for(let y=0;y<f;y++)_e(d[y],{instancePath:t+"/sounds/"+y,parentData:d,parentDataProperty:y,rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)}else{let f={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let d={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let d={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}if(e.interruption!==void 0){let d=e.interruption;if(typeof d!="string"){let f={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(!(d==="immediate"||d==="loopEnd")){let f={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Zb.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[f]:r.push(f),s++}}if(e.volume!==void 0){let d=e.volume;if(typeof d=="number"){if(d>100||isNaN(d)){let f={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[f]:r.push(f),s++}if(d<0||isNaN(d)){let f={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let d={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}if(e.pan!==void 0){let d=e.pan;if(typeof d=="number"){if(d>1||isNaN(d)){let f={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[f]:r.push(f),s++}if(d<-1||isNaN(d)){let f={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.startDelayMs!==void 0){let d=e.startDelayMs;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}}else{let d={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}return Ln.errors=r,s===0}function ru(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Ln(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Ln.errors:r.concat(Ln.errors),s=r.length),ru.errors=r,s===0}var tu=nu;var eI={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"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},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 Mn(e,{instancePath:t="",parentData:n,parentDataProperty:i,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 y;if(p.sprites===void 0&&(y="sprites")){let g={};r===null?r=[g]:r.push(g),s++}}var o=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),o){let y=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let h={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=[h]:r.push(h),s++}var o=y===s;d=o}if(!d){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[y]:r.push(y),s++}for(let y in p)if(!ar.call(eI.properties.items.items.properties,y)){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let y={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let y={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(p.x!==void 0&&typeof p.x!="number"){let y={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.y!==void 0&&typeof p.y!="number"){let y={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let y={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let y={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let y={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let y={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let y={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let y={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let y={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(p.opacity!==void 0){let y=p.opacity;if(typeof y=="number"){if(y>1||isNaN(y)){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(y<0||isNaN(y)){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&&(Ne(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),s=r.length)),p.sprites!==void 0){let y=p.sprites;if(Array.isArray(y)){let g=y.length;for(let h=0;h<g;h++){let I=y[h];if(I&&typeof I=="object"&&!Array.isArray(I)){for(let b in I)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let x={instancePath:t+"/items/"+u+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),s++}if(I.id!==void 0&&typeof I.id!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+h+"/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(I.resourceId!==void 0&&typeof I.resourceId!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+h+"/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(I.animationName!==void 0&&typeof I.animationName!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+h+"/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(I.animationSpeed!==void 0&&typeof I.animationSpeed!="number"){let b={instancePath:t+"/items/"+u+"/sprites/"+h+"/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(I.loop!==void 0&&typeof I.loop!="boolean"){let b={instancePath:t+"/items/"+u+"/sprites/"+h+"/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/"+h,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&&(J(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),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 Mn.errors=r,s===0}function nu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Mn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Mn.errors:r.concat(Mn.errors),s=r.length),nu.errors=r,s===0}var su=iu;function qn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="resourceId"||o==="items"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.items!==void 0){let o=e.items;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[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&&(J(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return qn.errors=r,s===0}function iu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return qn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?qn.errors:r.concat(qn.errors),s=r.length),iu.errors=r,s===0}var ou=au;function Vn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(o!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let o={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Vn.errors=r,s===0}function au(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Vn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Vn.errors:r.concat(Vn.errors),s=r.length),au.errors=r,s===0}var lu=cu;function Fn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(o!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Fn.errors=r,s===0}function cu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Fn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Fn.errors:r.concat(Fn.errors),s=r.length),cu.errors=r,s===0}var uu=pu;var Xc={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 Un(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!ar.call(Xc.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.ui!==void 0){let o=e.ui;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)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(o.resourceId!==void 0&&typeof o.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++}o.animations!==void 0&&(J(o.animations,{instancePath:t+"/ui/animations",parentData:o,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.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 o=e.mode;if(typeof o!="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(!(o==="adv"||o==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Xc.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 o=e.content;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[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 o={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let o={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let o={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let o={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let o={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let o={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.character!==void 0){let o=e.character;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)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(o.name!==void 0&&typeof o.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(o.sprite!==void 0){let l=o.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&&(J(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.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 o={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let o={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Un.errors=r,s===0}function pu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Un(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Un.errors:r.concat(Un.errors),s=r.length),pu.errors=r,s===0}var du=fu;function Bn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="id"||o==="resourceId"||o==="fields"||o==="submitActions"||o==="cancelActions"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let o={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fields!==void 0){let o=e.fields;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[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 o=e.submitActions;if(!(o&&typeof o=="object"&&!Array.isArray(o))){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 o=e.cancelActions;if(!(o&&typeof o=="object"&&!Array.isArray(o))){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&&(J(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Bn.errors=r,s===0}function fu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Bn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Bn.errors:r.concat(Bn.errors),s=r.length),fu.errors=r,s===0}var mu=yu;function Yn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="resourceId"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let o={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}e.animations!==void 0&&(J(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Yn.errors=r,s===0}function yu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Yn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Yn.errors:r.concat(Yn.errors),s=r.length),yu.errors=r,s===0}var hu=gu;function zn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="opacity"||o==="blur"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.opacity!==void 0){let o=e.opacity;if(typeof o=="number"){if(o>1||isNaN(o)){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(o<0||isNaN(o)){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&&(Ne(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),s=r.length)),e.animations!==void 0&&(J(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return zn.errors=r,s===0}function gu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return zn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?zn.errors:r.concat(zn.errors),s=r.length),gu.errors=r,s===0}var bu=Iu;var rI={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"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1};function Gn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=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=o,r!==null&&(o?r.length=o: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++)_e(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?_e.errors:r.concat(_e.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==="sounds")){let y={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if(je(f)<1){let y={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=[y]:r.push(y),s++}}else{let y={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let y={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=[y]:r.push(y),s++}if(f<0||isNaN(f)){let y={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=[y]:r.push(y),s++}}else{let y={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),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 y={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=[y]:r.push(y),s++}if(f<-1||isNaN(f)){let y={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=[y]:r.push(y),s++}}else{let y={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),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 y={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(!(f==="immediate"||f==="loopEnd")){let y={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:rI.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let y=f.length;for(let g=0;g<y;g++)_e(f[g],{instancePath:t+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)}else{let y={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[y]:r.push(y),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 Gn.errors=r,s===0}function Iu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Gn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Gn.errors:r.concat(Gn.errors),s=r.length),Iu.errors=r,s===0}var wu=vu;var Wc={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"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}}],additionalProperties:!1}}},additionalProperties:!1};function Hn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=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 y=e[f];if(y&&typeof y=="object"&&!Array.isArray(y)){if(y.text!==void 0&&typeof y.text!="string"){let g={instancePath:t+"/"+f+"/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(y.textStyleId!==void 0&&typeof y.textStyleId!="string"){let g={instancePath:t+"/"+f+"/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(y.furigana!==void 0){let g=y.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let h={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=[h]:r.push(h),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let g={instancePath:t+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),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=o,r!==null&&(o?r.length=o: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 Hn.errors=r,s===0}function Xn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.id===void 0&&(I="id")){let b={};r===null?r=[b]:r.push(b),s++}}var m=p===s;if(u=u||m,!u){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.type===void 0&&(x="type")){let v={};r===null?r=[v]:r.push(v),s++}}var m=I===s;if(u=u||m,!u){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.resourceId===void 0&&(k="resourceId")){let S={};r===null?r=[S]:r.push(S),s++}}var m=x===s;if(u=u||m,!u){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.transformId===void 0&&(O="transformId")){let j={};r===null?r=[j]:r.push(j),s++}}var m=k===s;if(u=u||m,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.x===void 0&&(E="x")){let T={};r===null?r=[T]:r.push(T),s++}}var m=O===s;if(u=u||m,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.y===void 0&&(q="y")){let ae={};r===null?r=[ae]:r.push(ae),s++}}var m=E===s;if(u=u||m,!u){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.anchorX===void 0&&(G="anchorX")){let ee={};r===null?r=[ee]:r.push(ee),s++}}var m=q===s;if(u=u||m,!u){let G=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let re;if(e.anchorY===void 0&&(re="anchorY")){let be={};r===null?r=[be]:r.push(be),s++}}var m=G===s;if(u=u||m,!u){let re=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Pe;if(e.scaleX===void 0&&(Pe="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),s++}}var m=re===s;if(u=u||m,!u){let Pe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.scaleY===void 0&&(se="scaleY")){let pe={};r===null?r=[pe]:r.push(pe),s++}}var m=Pe===s;if(u=u||m,!u){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.rotation===void 0&&(le="rotation")){let ie={};r===null?r=[ie]:r.push(ie),s++}}var m=se===s;if(u=u||m,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ce;if(e.originX===void 0&&(ce="originX")){let ve={};r===null?r=[ve]:r.push(ve),s++}}var m=le===s;if(u=u||m,!u){let ce=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ge;if(e.originY===void 0&&(Ge="originY")){let lr={};r===null?r=[lr]:r.push(lr),s++}}var m=ce===s;if(u=u||m,!u){let Ge=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let He;if(e.layer===void 0&&(He="layer")){let Ze={};r===null?r=[Ze]:r.push(Ze),s++}}var m=Ge===s;if(u=u||m,!u){let He=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ie;if(e.opacity===void 0&&(Ie="opacity")){let $={};r===null?r=[$]:r.push($),s++}}var m=He===s;if(u=u||m,!u){let Ie=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let N;if(e.blur===void 0&&(N="blur")){let V={};r===null?r=[V]:r.push(V),s++}}var m=Ie===s;if(u=u||m,!u){let N=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Q;if(e.animations===void 0&&(Q="animations")){let xe={};r===null?r=[xe]:r.push(xe),s++}}var m=N===s;u=u||m}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let I={};r===null?r=[I]:r.push(I),s++}var d=l===s;if(d){let I={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[I]:r.push(I),s++}else s=o,r!==null&&(o?r.length=o:r=null);let f=s,y=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let I={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[I]:r.push(I),s++}var h=g===s;if(y=y||h,!y){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let x={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[x]:r.push(x),s++}var h=I===s;y=y||h}if(y)s=f,r!==null&&(f?r.length=f:r=null);else{let I={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[I]:r.push(I),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Hn(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Hn.errors:r.concat(Hn.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let I={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),s++}if(e.width!==void 0&&typeof e.width!="number"){let I={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}if(e.height!==void 0&&typeof e.height!="number"){let I={instancePath:t+"/height",schemaPath:"#/properties/height/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 Xn.errors=r,s===0}function Wn(e,{instancePath:t="",parentData:n,parentDataProperty:i,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=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let f;if(p.resourceId===void 0&&(f="resourceId")||p.text===void 0&&(f="text")){let y={};r===null?r=[y]:r.push(y),s++}}var o=d===s;if(o){let f={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[f]:r.push(f),s++}else s=m,r!==null&&(m?r.length=m:r=null);if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let f={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),s++}for(let f in p)if(!ar.call(Wc.properties.items.items.properties,f)){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(p.id!==void 0&&typeof p.id!="string"){let f={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(p.animationName!==void 0&&typeof p.animationName!="string"){let f={instancePath:t+"/items/"+u+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(p.animationSpeed!==void 0&&typeof p.animationSpeed!="number"){let f={instancePath:t+"/items/"+u+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.resourceId!==void 0&&typeof p.resourceId!="string"){let f={instancePath:t+"/items/"+u+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(p.text!==void 0&&(Xn(p.text,{instancePath:t+"/items/"+u+"/text",parentData:p,parentDataProperty:"text",rootData:a})||(r=r===null?Xn.errors:r.concat(Xn.errors),s=r.length)),p.transformId!==void 0&&typeof p.transformId!="string"){let f={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}if(p.x!==void 0&&typeof p.x!="number"){let f={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.y!==void 0&&typeof p.y!="number"){let f={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let f={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let f={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let f={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let f={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let f={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let f={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let f={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}if(p.layer!==void 0){let f=p.layer;if(typeof f!="number"){let y={instancePath:t+"/items/"+u+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}if(!(f===10||f===30||f===50||f===70||f===90)){let y={instancePath:t+"/items/"+u+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:Wc.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(p.opacity!==void 0){let f=p.opacity;if(typeof f=="number"){if(f>1||isNaN(f)){let y={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=[y]:r.push(y),s++}if(f<0||isNaN(f)){let y={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=[y]:r.push(y),s++}}else{let y={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[y]:r.push(y),s++}}p.blur!==void 0&&(Ne(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),s=r.length)),p.animations!==void 0&&(J(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?J.errors:r.concat(J.errors),s=r.length))}else{let f={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),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 Wn.errors=r,s===0}function vu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Wn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Wn.errors:r.concat(Wn.errors),s=r.length),vu.errors=r,s===0}var Au=ku;var tI={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 Kn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let h={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[h]:r.push(h),s++}var u=c===s;if(l=l||u,!l){let h=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=h===s;l=l||u}if(l)s=o,r!==null&&(o?r.length=o:r=null);else{let h={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[h]:r.push(h),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.resourceId===void 0&&(h="resourceId")||e.sounds===void 0&&(h="sounds")){let I={};r===null?r=[I]:r.push(I),s++}}var d=m===s;if(d){let h={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[h]:r.push(h),s++}else s=p,r!==null&&(p?r.length=p:r=null);let f=s,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.startDelayMs===void 0&&(h="startDelayMs")||e.sounds===void 0&&(h="sounds")){let I={};r===null?r=[I]:r.push(I),s++}}var g=y===s;if(g){let h={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[h]:r.push(h),s++}else s=f,r!==null&&(f?r.length=f:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let h in e)if(!(h==="sounds"||h==="resourceId"||h==="volume"||h==="muted"||h==="pan"||h==="loop"||h==="interruption"||h==="startDelayMs")){let I={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[I]:r.push(I),s++}if(e.sounds!==void 0){let h=e.sounds;if(Array.isArray(h)){let I=h.length;for(let b=0;b<I;b++)_e(h[b],{instancePath:t+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)}else{let I={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[I]:r.push(I),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let h={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(e.volume!==void 0){let h=e.volume;if(typeof h=="number"){if(h>100||isNaN(h)){let I={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[I]:r.push(I),s++}if(h<0||isNaN(h)){let I={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[I]:r.push(I),s++}}else{let I={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let h={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(e.pan!==void 0){let h=e.pan;if(typeof h=="number"){if(h>1||isNaN(h)){let I={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[I]:r.push(I),s++}if(h<-1||isNaN(h)){let I={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[I]:r.push(I),s++}}else{let I={instancePath:t+"/pan",schemaPath:"#/properties/pan/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 h={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(e.interruption!==void 0){let h=e.interruption;if(typeof h!="string"){let I={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[I]:r.push(I),s++}if(!(h==="immediate"||h==="loopEnd")){let I={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:tI.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[I]:r.push(I),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let I={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[I]:r.push(I),s++}}else{let I={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[I]:r.push(I),s++}}}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}return Kn.errors=r,s===0}function ku(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Kn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Kn.errors:r.concat(Kn.errors),s=r.length),ku.errors=r,s===0}var Pu=xu;var nI={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 Jn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=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=o,r!==null&&(o?r.length=o:r=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let I={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[I]:r.push(I),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.type!==void 0&&e.type!=="boolean"){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,h=s,I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.target===void 0&&(x="target")){let v={};r===null?r=[v]:r.push(v),s++}}var y=I===s;if(y){let x={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[x]:r.push(x),s++}else s=h,r!==null&&(h?r.length=h:r=null);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++}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 h={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let h={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(g==="boolean"||g==="number")){let h={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:nI.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let h={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[h]:r.push(h),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let h={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[h]:r.push(h),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if(je(g)<1){let h={instancePath:t+"/name",schemaPath:"#/properties/name/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+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if(je(g)<1){let h={instancePath:t+"/description",schemaPath:"#/properties/description/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+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if(je(g)<1){let h={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/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+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if(je(g)<1){let h={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/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+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),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 Jn.errors=r,s===0}function xu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Jn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Jn.errors:r.concat(Jn.errors),s=r.length),xu.errors=r,s===0}var Eu=Su;var sI={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 iI={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 Lr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[o]:r.push(o),s++}if(e.duration===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="value"||o==="duration"||o==="easing"||o==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let o={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let o={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.easing!==void 0){let o=e.easing;if(typeof o!="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(!(o==="linear"||o==="easeInQuad"||o==="easeOutQuad"||o==="easeInOutQuad"||o==="easeInCubic"||o==="easeOutCubic"||o==="easeInOutCubic"||o==="easeInQuart"||o==="easeOutQuart"||o==="easeInOutQuart"||o==="easeInQuint"||o==="easeOutQuint"||o==="easeInOutQuint"||o==="easeInSine"||o==="easeOutSine"||o==="easeInOutSine"||o==="easeInExpo"||o==="easeOutExpo"||o==="easeInOutExpo"||o==="easeInCirc"||o==="easeOutCirc"||o==="easeInOutCirc"||o==="easeInBack"||o==="easeOutBack"||o==="easeInOutBack"||o==="easeInBounce"||o==="easeOutBounce"||o==="easeInOutBounce"||o==="easeInElastic"||o==="easeOutElastic"||o==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:iI.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 o={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Lr.errors=r,s===0}function z(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let o={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.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=o.length;for(let c=0;c<l;c++)Lr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Lr.errors:r.concat(Lr.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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return z.errors=r,s===0}function Qn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="alpha"||o==="x"||o==="y"||o==="scaleX"||o==="scaleY"||o==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.alpha!==void 0&&(z(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.x!==void 0&&(z(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.y!==void 0&&(z(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.scaleX!==void 0&&(z(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.scaleY!==void 0&&(z(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.rotation!==void 0&&(z(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Qn.errors=r,s===0}function Zn(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let o={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="translateX"||o==="translateY"||o==="alpha"||o==="scaleX"||o==="scaleY"||o==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.translateX!==void 0&&(z(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.translateY!==void 0&&(z(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.alpha!==void 0&&(z(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.scaleX!==void 0&&(z(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.scaleY!==void 0&&(z(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length)),e.rotation!==void 0&&(z(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?z.errors:r.concat(z.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Zn.errors=r,s===0}function Tr(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(o!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.tween!==void 0&&(Zn(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Zn.errors:r.concat(Zn.errors),s=r.length))}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return Tr.errors=r,s===0}var Nn={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"]}}]},oI={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function es(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="texture"||o==="channel"||o==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let o={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.channel!==void 0){let o=e.channel;if(typeof o!="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(!(o==="red"||o==="green"||o==="blue"||o==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:oI.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 o={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return es.errors=r,s===0}function rs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="initialValue"||o==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let o={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.keyframes!==void 0){let o=e.keyframes;if(Array.isArray(o)){if(o.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=o.length;for(let c=0;c<l;c++)Lr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Lr.errors:r.concat(Lr.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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return rs.errors=r,s===0}function ts(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=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=o,r!==null&&(o?r.length=o:r=null),u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let v={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[v]:r.push(v),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.kind!==void 0&&e.kind!=="sequence"){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;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let v={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[v]:r.push(v),s++}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++}let y=s,g=!0,h=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 I=h===s;if(s=y,r!==null&&(y?r.length=y:r=null),I){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let v={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[v]:r.push(v),s++}var I=b===s;g=I}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(!ar.call(Nn.properties,b)){let x={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let x={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[x]:r.push(x),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let x={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Nn.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[x]:r.push(x),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 v={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let x=b.length;for(let v=0;v<x;v++)if(typeof b[v]!="string"){let k={instancePath:t+"/textures/"+v,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[k]:r.push(k),s++}}else{let x={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[x]:r.push(x),s++}}if(e.items!==void 0){let b=e.items;if(Array.isArray(b)){if(b.length<1){let v={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let x=b.length;for(let v=0;v<x;v++)es(b[v],{instancePath:t+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(r=r===null?es.errors:r.concat(es.errors),s=r.length)}else{let x={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[x]:r.push(x),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let x={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[x]:r.push(x),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let x={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Nn.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[x]:r.push(x),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let x={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[x]:r.push(x),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let x={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Nn.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[x]:r.push(x),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&&(rs(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?rs.errors:r.concat(rs.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 ts.errors=r,s===0}function ns(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=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=o,r!==null&&(o?r.length=o:r=null),u){let b=s,x=s,v=s,k=s,S=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.prev===void 0&&(E="prev")){let T={};r===null?r=[T]:r.push(T),s++}}var p=O===s;if(S=S||p,!S){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.next===void 0&&(q="next")){let ae={};r===null?r=[ae]:r.push(ae),s++}}var p=E===s;if(S=S||p,!S){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let ee={};r===null?r=[ee]:r.push(ee),s++}}var p=q===s;S=S||p}}if(S)s=k,r!==null&&(k?r.length=k:r=null);else{let E={};r===null?r=[E]:r.push(E),s++}var m=v===s;if(m){let E={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[E]:r.push(E),s++}else s=x,r!==null&&(x?r.length=x:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let E={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[E]:r.push(E),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 d=s,f=!0,y=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=y===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let b=s,x=s,v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.tween===void 0&&(E="tween")){let T={};r===null?r=[T]:r.push(T),s++}}var h=v===s;if(h){let E={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[E]:r.push(E),s++}else s=x,r!==null&&(x?r.length=x:r=null);let k=s,S=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let E={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[E]:r.push(E),s++}var I=O===s;if(S=S||I,!S){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let q={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[q]:r.push(q),s++}var I=E===s;if(S=S||I,!S){let q=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 I=q===s;S=S||I}}if(S)s=k,r!==null&&(k?r.length=k:r=null);else{let E={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[E]:r.push(E),s++}var g=b===s;f=g}if(!f){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 x={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),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 x={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[x]:r.push(x),s++}if(!(b==="update"||b==="transition")){let x={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:sI.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[x]:r.push(x),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let x=b.payload;if(!(x&&typeof x=="object"&&!Array.isArray(x))){let v={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let x={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),s++}}e.tween!==void 0&&(Qn(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Qn.errors:r.concat(Qn.errors),s=r.length)),e.prev!==void 0&&(Tr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Tr.errors:r.concat(Tr.errors),s=r.length)),e.next!==void 0&&(Tr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Tr.errors:r.concat(Tr.errors),s=r.length)),e.mask!==void 0&&(ts(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?ts.errors:r.concat(ts.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 ns.errors=r,s===0}function Su(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ns(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ns.errors:r.concat(ns.errors),s=r.length),Su.errors=r,s===0}var Ru=Ou;function ss(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!(o==="name"||o==="nameVariableId")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let o={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.nameVariableId!==void 0){let o=e.nameVariableId;if(typeof o=="string"){if(je(o)<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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ss.errors=r,s===0}function Ou(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ss(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ss.errors:r.concat(ss.errors),s=r.length),Ou.errors=r,s===0}var Cu=$u;var aI=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function is(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(o!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.hex!==void 0){let o=e.hex;if(typeof o=="string"){if(!aI.test(o)){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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return is.errors=r,s===0}function $u(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return is(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?is.errors:r.concat(is.errors),s=r.length),$u.errors=r,s===0}var _u=ju;function os(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let o=e.keyboard;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[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 o=e.keyup;if(o&&typeof o=="object"&&!Array.isArray(o))for(let l in o){let c=o[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 o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return os.errors=r,s===0}function ju(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return os(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?os.errors:r.concat(os.errors),s=r.length),ju.errors=r,s===0}var Nu=Du;function as(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return as.errors=r,s===0}function Du(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return as(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?as.errors:r.concat(as.errors),s=r.length),Du.errors=r,s===0}var Tu=Lu;function ls(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),s++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="fileType"||o==="width"||o==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.width!==void 0){let o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ls.errors=r,s===0}function Lu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ls(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ls.errors:r.concat(ls.errors),s=r.length),Lu.errors=r,s===0}var Mu=qu;function cs(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let o=e.elements;if(Array.isArray(o)){let l=o.length;for(let c=0;c<l;c++){let u=o[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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return cs.errors=r,s===0}function qu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return cs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?cs.errors:r.concat(cs.errors),s=r.length),qu.errors=r,s===0}var Vu=Fu;function us(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0,o=s,l=!1,c=null,u=s,p=s,m=s,d=s,f=!1,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.count===void 0&&(v="count")){let k={};r===null?r=[k]:r.push(k),s++}}var g=y===s;if(f=f||g,!f){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let S;if(e.texture===void 0&&(S="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var g=v===s;if(f=f||g,!f){let S=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.behaviors===void 0&&(j="behaviors")){let E={};r===null?r=[E]:r.push(E),s++}}var g=S===s;if(f=f||g,!f){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.emitter===void 0&&(T="emitter")){let q={};r===null?r=[q]:r.push(q),s++}}var g=j===s;f=f||g}}}if(f)s=d,r!==null&&(d?r.length=d:r=null);else{let v={};r===null?r=[v]:r.push(v),s++}var h=m===s;if(h){let v={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),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 v={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[v]:r.push(v),s++}var b=u===s;b&&(l=!0,c=0);let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let v={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[v]:r.push(v),s++}if(e.behaviors===void 0){let v={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[v]:r.push(v),s++}if(e.emitter===void 0){let v={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[v]:r.push(v),s++}}var b=I===s;if(b&&l?(l=!1,c=[c,1]):b&&(l=!0,c=1),l)s=o,r!==null&&(o?r.length=o:r=null);else{let v={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[v]:r.push(v),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let v={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[v]:r.push(v),s++}if(e.height===void 0){let v={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[v]:r.push(v),s++}for(let v in e)if(!(v==="width"||v==="height"||v==="seed"||v==="modules"||v==="count"||v==="texture"||v==="behaviors"||v==="emitter")){let k={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[k]:r.push(k),s++}if(e.width!==void 0){let v=e.width;if(typeof v=="number"){if(v<=0||isNaN(v)){let k={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[k]:r.push(k),s++}}else{let k={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}}if(e.height!==void 0){let v=e.height;if(typeof v=="number"){if(v<=0||isNaN(v)){let k={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[k]:r.push(k),s++}}else{let k={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let v={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(e.modules!==void 0){let v=e.modules;if(v&&typeof v=="object"&&!Array.isArray(v)){if(v.emission===void 0){let k={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[k]:r.push(k),s++}if(v.appearance===void 0){let k={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[k]:r.push(k),s++}for(let k in v)if(!(k==="emission"||k==="movement"||k==="appearance"||k==="bounds")){let S={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[S]:r.push(S),s++}if(v.emission!==void 0){let k=v.emission;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[S]:r.push(S),s++}}if(v.movement!==void 0){let k=v.movement;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[S]:r.push(S),s++}}if(v.appearance!==void 0){let k=v.appearance;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[S]:r.push(S),s++}}if(v.bounds!==void 0){let k=v.bounds;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[S]:r.push(S),s++}}}else{let k={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}if(e.count!==void 0){let v=e.count;if(!(typeof v=="number"&&!(v%1)&&!isNaN(v))){let k={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[k]:r.push(k),s++}if(typeof v=="number"&&(v<1||isNaN(v))){let k={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[k]:r.push(k),s++}}if(e.texture!==void 0){let v=e.texture,k=s,S=!1,O=null,j=s;if(typeof v=="string"){if(je(v)<1){let T={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=[T]:r.push(T),s++}}else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[T]:r.push(T),s++}var x=j===s;x&&(S=!0,O=0);let E=s;if(!(v&&typeof v=="object"&&!Array.isArray(v))){let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[T]:r.push(T),s++}var x=E===s;if(x&&S?(S=!1,O=[O,1]):x&&(S=!0,O=1),S)s=k,r!==null&&(k?r.length=k:r=null);else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[T]:r.push(T),s++}}if(e.behaviors!==void 0){let v=e.behaviors;if(Array.isArray(v)){if(v.length<1){let S={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[S]:r.push(S),s++}let k=v.length;for(let S=0;S<k;S++){let O=v[S];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let j={instancePath:t+"/behaviors/"+S,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[j]:r.push(j),s++}for(let j in O)if(!(j==="type"||j==="config")){let E={instancePath:t+"/behaviors/"+S,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:j},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(O.type!==void 0){let j=O.type;if(typeof j=="string"){if(je(j)<1){let E={instancePath:t+"/behaviors/"+S+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/behaviors/"+S+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}}if(O.config!==void 0){let j=O.config;if(!(j&&typeof j=="object"&&!Array.isArray(j))){let E={instancePath:t+"/behaviors/"+S+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}}else{let j={instancePath:t+"/behaviors/"+S,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[j]:r.push(j),s++}}}else{let k={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[k]:r.push(k),s++}}if(e.emitter!==void 0){let v=e.emitter;if(v&&typeof v=="object"&&!Array.isArray(v)){if(v.lifetime===void 0){let k={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[k]:r.push(k),s++}if(v.lifetime!==void 0){let k=v.lifetime;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.min===void 0){let S={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[S]:r.push(S),s++}if(k.max===void 0){let S={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[S]:r.push(S),s++}if(k.min!==void 0){let S=k.min;if(typeof S=="number"){if(S<0||isNaN(S)){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(k.max!==void 0){let S=k.max;if(typeof S=="number"){if(S<0||isNaN(S)){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 S={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[S]:r.push(S),s++}}}else{let k={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let v={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}return us.errors=r,s===0}function Fu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return us(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?us.errors:r.concat(us.errors),s=r.length),Fu.errors=r,s===0}var Uu=Bu;var Kc={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 ps(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!ar.call(Kc.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let o={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.volume!==void 0){let o=e.volume;if(typeof o=="number"){if(o>100||isNaN(o)){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(o<0||isNaN(o)){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 o={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[o]:r.push(o),s++}if(e.pan!==void 0){let o=e.pan;if(typeof o=="number"){if(o>1||isNaN(o)){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(o<-1||isNaN(o)){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 o=e.startDelayMs;if(typeof o=="number"){if(o<0||isNaN(o)){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 o=e.playbackRate;if(typeof o=="number"){if(o<0||isNaN(o)){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 o=e.startAt;if(typeof o=="number"){if(o<0||isNaN(o)){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 o=e.endAt;if(typeof o!="number"&&o!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Kc.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof o=="number"&&(o<0||isNaN(o))){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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ps.errors=r,s===0}function Bu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ps(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ps.errors:r.concat(ps.errors),s=r.length),Bu.errors=r,s===0}var Yu=zu;var lI=new RegExp("^.+$","u");function ds(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}if(e.jsonData===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[o]:r.push(o),s++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),s++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="jsonData"||o==="width"||o==="height"||o==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.jsonData!==void 0){let o=e.jsonData;if(!(o&&typeof o=="object"&&!Array.isArray(o))){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 o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o=e.animations;if(o&&typeof o=="object"&&!Array.isArray(o)){for(let l in o)if(lI.test(l)){let c=o[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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ds.errors=r,s===0}function zu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ds(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ds.errors:r.concat(ds.errors),s=r.length),zu.errors=r,s===0}var Gu=Hu;var Jc={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 fs(e,{instancePath:t="",parentData:n,parentDataProperty:i,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(!ar.call(Jc.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(je(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 o=m===s;o&&(u=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let h={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=[h]:r.push(h),s++}let f=l.length;for(let h=0;h<f;h++){let I=l[h];if(typeof I=="string"){if(je(I)<1){let b={instancePath:t+"/fontId/"+h,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/"+h,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 y=l.length,g;if(y>1){let h={};for(;y--;){let I=l[y];if(typeof I=="string"){if(typeof h[I]=="number"){g=h[I];let b={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:y,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+y+" are identical)"};r===null?r=[b]:r.push(b),s++;break}h[I]=y}}}}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 o=d===s;if(o&&u?(u=!1,p=[p,1]):o&&(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:Jc.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(je(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 fs.errors=r,s===0}function Hu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return fs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?fs.errors:r.concat(fs.errors),s=r.length),Hu.errors=r,s===0}var Xu=Wu;var cI={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function ms(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let o in e)if(!ar.call(cI.properties,o)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0){let o=e.x;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o=e.y;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let o={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let o={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let o={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let o={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let o={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let o={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[o]:r.push(o),s++}}else{let o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ms.errors=r,s===0}function Wu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ms(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ms.errors:r.concat(ms.errors),s=r.length),Wu.errors=r,s===0}var Ku=Ju;function ys(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[o]:r.push(o),s++}if(e.width===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[o]:r.push(o),s++}if(e.height===void 0){let o={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[o]:r.push(o),s++}for(let o in e)if(!(o==="fileId"||o==="fileType"||o==="width"||o==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:o},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let o={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let o={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[o]:r.push(o),s++}if(e.width!==void 0){let o=e.width;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o=e.height;if(!(typeof o=="number"&&!(o%1)&&!isNaN(o))){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 o={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[o]:r.push(o),s++}return ys.errors=r,s===0}function Ju(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ys(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ys.errors:r.concat(ys.errors),s=r.length),Ju.errors=r,s===0}var gs=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ft=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Mr=e=>e===void 0?void 0:structuredClone(e),uI=Object.freeze({achievement:"achievements",animation:"animations",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),pI=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),dI=Object.freeze({background:Qc,bgm:eu,character:tu,choice:su,cleanAll:ou,control:lu,dialogue:uu,form:du,layout:mu,screen:hu,sfx:bu,visual:wu,voice:Au}),fI=Object.freeze({achievement:Pu,animation:Eu,character:Ru,color:Cu,control:_u,font:Nu,image:Tu,layout:Mu,particle:Vu,sound:Uu,spritesheet:Yu,textStyle:Gu,transform:Xu,video:Ku}),mI=new Set(["files","language","patches"]),yI=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),hI=new Set(["lineId","mode","payload","type"]),gI=new Set(["mode","payload","sceneId","type"]),bI=new Set(["mode","operation","payload","resourceId","type"]),II=new Set(["fileId","mimeType"]),F=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},Ye=(e,t)=>{Ft(e)||F(t,"expected an object")},co=(e,t)=>{Array.isArray(e)||F(t,"expected an array")},at=(e,t)=>{(typeof e!="string"||e.length===0)&&F(t,"expected a non-empty string")},ep=(e,t)=>{typeof e!="string"&&F(t,"expected a string")},Je=(e,t,n)=>{for(let i of Object.keys(e))t.has(i)||F(`${n}.${i}`,"unknown field")},Qe=(e,t,n)=>{for(let i of t)gs(e,i)||F(n,`missing required field "${i}"`)},wI=e=>e.replaceAll("~1","/").replaceAll("~0","~"),vI=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(wI);return t?.keyword==="required"?n.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&n.push(t.params.additionalProperty),n.reduce((i,a)=>/^\d+$/.test(a)?`${i}[${a}]`:`${i}.${a}`,e)},AI=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,n)=>{if(t===void 0)return n;let i=n.instancePath.split("/").length,a=t.instancePath.split("/").length;return i>a?n:t},void 0)??e[0],rp=({value:e,validator:t,path:n,contract:i})=>{if(t(e))return;let a=AI(t.errors);F(vI(n,a),`does not match ${i}: ${a?.message??"schema validation failed"}`)},lt=(e,t)=>{at(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&F(t,`"${e}" is not a safe ID`)},kI=(e,t)=>{at(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&F(t,"must be a safe single filename")},Vt=(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)=>Vt(a,t[r]));if(!Ft(e)||!Ft(t))return!1;let n=Object.keys(e).sort(),i=Object.keys(t).sort();return Vt(n,i)&&n.every(a=>Vt(e[a],t[a]))},hs=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(i=>hs(i,t,n)),t;if(!Ft(e)||n.has(e))return t;n.add(e);for(let[i,a]of Object.entries(e))i==="fileId"&&typeof a=="string"&&t.add(a),hs(a,t,n);return t},PI=e=>{let t=new Map;for(let[n,i]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(i?.sections??{}))for(let[s,o]of(r?.lines??[]).entries()){if(typeof o?.id!="string")continue;let l=t.get(o.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:o}),t.set(o.id,l)}return t},tp=(e,t,n)=>{let i=e.get(t)??[];return i.length===0&&F(n,`lineId "${t}" does not exist in projectData`),i.length>1&&F(n,`lineId "${t}" is not globally unique in projectData`),i[0]},np=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Qu=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Zu=e=>{let t=Mr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))Ft(n)&&delete n.placeholder;return t},xI=(e,t,n,i)=>{e==="choice"&&!Vt(Qu(t),Qu(n))&&F(i,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Vt(Zu(t),Zu(n))&&F(i,"form behavior must remain identical; only presentation fields and placeholders may change")},EI=({patch:e,path:t,lineIndex:n})=>{Je(e,yI,t),Qe(e,["type","lineId","actionType","payload"],t),lt(e.lineId,`${t}.lineId`),at(e.actionType,`${t}.actionType`),Ye(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&F(`${t}.mode`,'line.action supports only "replace"'),pI.has(e.actionType)||F(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let i=tp(n,e.lineId,`${t}.lineId`),a=i.line?.actions?.[e.actionType];return a===void 0&&F(`${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")&&F(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),gs(e.payload,"content")&&F(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&F(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),xI(e.actionType,a,e.payload,`${t}.payload`),rp({value:e.payload,validator:dI[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:i,patch:e}},SI=(e,t)=>{co(e,t),e.forEach((n,i)=>{Ye(n,`${t}[${i}]`),Je(n,new Set(["text"]),`${t}[${i}]`),Qe(n,["text"],`${t}[${i}]`),ep(n.text,`${t}[${i}].text`)})},RI=({patch:e,path:t,lineIndex:n})=>{Je(e,hI,t),Qe(e,["type","lineId","payload"],t),lt(e.lineId,`${t}.lineId`),Ye(e.payload,`${t}.payload`),Je(e.payload,new Set(["content"]),`${t}.payload`),Qe(e.payload,["content"],`${t}.payload`),SI(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&F(`${t}.mode`,'line.dialogue supports only "replace"');let i=tp(n,e.lineId,`${t}.lineId`);return i.line?.actions?.dialogue===void 0&&F(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:i,patch:e}},OI=({patch:e,path:t,projectData:n})=>(Je(e,gI,t),Qe(e,["type","mode","sceneId","payload"],t),lt(e.sceneId,`${t}.sceneId`),Ye(e.payload,`${t}.payload`),Je(e.payload,new Set(["name"]),`${t}.payload`),Qe(e.payload,["name"],`${t}.payload`),ep(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&F(`${t}.mode`,'story.scene requires "patch"'),gs(n?.story?.scenes??{},e.sceneId)||F(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),CI=(e,t,n)=>{Ye(t,n),["font","image","sound","spritesheet","video"].includes(e)&&at(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||F(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||F(`${n}.height`,"expected an integer")),e==="spritesheet"&&(Ye(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||F(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||F(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&F(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),rp({value:t,validator:fI[e],path:n,contract:`the resource.${e} schema`})},$I=({patch:e,path:t,projectData:n,packageFileIds:i,canonicalFileIds:a})=>{Je(e,bI,t),Qe(e,["type","resourceId","payload"],t),lt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=uI[r];s||F(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&F(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&F(`${t}.operation`,'the only resource operation is "add"'),CI(r,e.payload,`${t}.payload`);let o=n?.resources?.[s]??{},l=gs(o,e.resourceId);e.operation==="add"&&l&&F(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&F(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of hs(e.payload))!i.has(c)&&!a.has(c)&&F(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,patch:e}},_I=({patch:e,path:t,projectData:n,lineIndex:i,packageFileIds:a,canonicalFileIds:r})=>{if(Ye(e,t),at(e.type,`${t}.type`),e.type==="line.action")return EI({patch:e,path:t,lineIndex:i});if(e.type==="line.dialogue")return RI({patch:e,path:t,lineIndex:i});if(e.type==="story.scene")return OI({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return $I({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});F(`${t}.type`,`unsupported patch type "${e.type}"`)},jI=(e,t)=>{co(e,t);let n=new Set;return e.forEach((i,a)=>{let r=`${t}[${a}]`;Ye(i,r),Je(i,II,r),Qe(i,["fileId"],r),kI(i.fileId,`${r}.fileId`),i.mimeType!==void 0&&(typeof i.mimeType!="string"||i.mimeType.length===0)&&F(`${r}.mimeType`,"expected a non-empty string"),n.has(i.fileId)&&F(`${r}.fileId`,`duplicate fileId "${i.fileId}"`),n.add(i.fileId)}),n},NI=({packageId:e,packageData:t,path:n,projectData:i,lineIndex:a,canonicalFileIds:r})=>{Ye(t,n),Je(t,mI,n),Qe(t,["language","files","patches"],n),at(t.language,`${n}.language`);let s=jI(t.files,`${n}.files`);co(t.patches,`${n}.patches`);let o=new Set,l=t.patches.map((c,u)=>{let p=_I({patch:c,path:`${n}.patches[${u}]`,projectData:i,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return o.has(p.key)&&F(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),o.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},sp=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};Ye(t,"l10nData"),Je(t,new Set(["packages"]),"l10nData"),Qe(t,["packages"],"l10nData"),Ye(t.packages,"l10nData.packages");let n=PI(e),i=hs(e?.resources??{}),a=new Map,r=new Map;for(let[s,o]of Object.entries(t.packages)){lt(s,`l10nData.packages.${s}`);let l=NI({packageId:s,packageData:o,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:i});for(let c of l.fileIds){i.has(c)&&F(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&F(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}a.set(s,l)}return{packages:a}},DI=(e,t)=>{let{collectionName:n,patch:i}=t;e.resources[n]??={},e.resources[n][i.resourceId]=Mr(i.payload)},TI=(e,t)=>{let{patch:n}=t,i=e.story.scenes[n.sceneId];i.name=n.payload.name},LI=(e,t)=>{let{location:n,patch:i}=t,a=np(e,n);if(i.actionType!=="dialogue"){a.actions[i.actionType]=Mr(i.payload);return}let r=Mr(n.line.actions.dialogue.content);a.actions.dialogue=Mr(i.payload),r!==void 0&&(a.actions.dialogue.content=r)},MI=(e,t)=>{let{location:n,patch:i}=t,a=np(e,n);a.actions.dialogue.content=Mr(i.payload.content)},ip=({projectData:e,l10nData:t})=>{let n=sp({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),i=>({l10nId:i.id,language:i.data.language}))]},bs=({projectData:e,l10nData:t,l10nId:n=null})=>{let i=sp({projectData:e,l10nData:t});if(n!==null&&(lt(n,"l10nId"),i.packages.has(n)||F("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=Mr(e),r=i.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>DI(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>TI(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>LI(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>MI(a,s)),a};var qI=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),VI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),op="conditional",po=Symbol("conditionalAutoContinue"),FI=new Set(["sectionTransition","resetStoryAtSection"]),UI=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),BI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),YI=new Set(["nextLine","nextLineFromSystem"]),zI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),uo="form",GI=new Set(["submitForm","cancelForm"]),HI="showImageGalleryVariant",XI="playMusicRoomTrack",WI="startSceneReplay",ze=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),KI=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,Is=e=>e?.type===po,ct=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId;function fo(e){let t=KI(),n,i=0,a=!1,r=0,s=null,o=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,y=new Map,g,h,I=null,{handlePendingEffects:b}=e,x=w=>{if(!a||!n)throw new Error(`RouteEngine ${w} requires an active engine`)},v=(w=new Map,P=Date.now())=>new Map(Array.from(w.entries()).filter(([,R])=>P<R.expiresAt).map(([R,C])=>[R,{animation:structuredClone(C.animation),startedAt:C.startedAt,expiresAt:C.expiresAt}])),k=(w=new Map)=>Array.from(w.values()).map(P=>structuredClone(P.animation)),S=(w=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,P])=>w<P.expiresAt))},O=()=>{if(a&&!(o>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let w=[...n.selectPendingEffects()];n.clearPendingEffects();try{b(w)}catch(P){throw n.clearPendingEffects(),w.forEach(R=>{n.appendPendingEffect(R)}),P}}}finally{l=!1}}},j=w=>{o+=1;let P=!1;try{let R=w();return P=!0,R}finally{o-=1,P&&O()}},E=({initialState:w,namespace:P})=>{let R=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:C,...M}=w,U=C===void 0?void 0:structuredClone(C),K=structuredClone(w.projectData),Z=ip({projectData:K,l10nData:U}),fe=M.global??{};if(!ze(fe))throw new Error("Malformed global state.");let Xe=fe.runtime??{};if(!ze(Xe))throw new Error("Malformed global.runtime.");let De=Xe.localizationPackageId;if(De!=null&&typeof De!="string")throw new Error("localizationPackageId requires a string or null value");let Fr=new Set(Z.map(({l10nId:As})=>As).filter(As=>As!==null)),Ur=typeof De=="string"&&Fr.has(De)?De:null,$p=bs({projectData:K,l10nData:U,l10nId:Ur}),_p=Fc({...M,global:{...fe,localizationPackages:Z,runtime:{...Xe,localizationPackageId:Ur}},projectData:$p,initialAudioCommandId:R});b.reset?.(),n=_p,i+=1,a=!0,r=0,s=ot(P),o=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,y=new Map,g=K,h=U,I=Ur,n.appendPendingEffect({name:"handleLineActions"}),O()},T=()=>{a&&(a=!1,i+=1,n?.clearPendingEffects?.(),o=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,y=new Map,b.dispose?.())},q=()=>s,ae=()=>n.selectPresentationState(),G=()=>n.selectPresentationChanges(),ee=w=>n.selectSectionLineChanges(w),re=(w={})=>{x("rendering"),r+=1;let P=Date.now();S(P);let R=f.size>0,C=v(d,P),M=R?v(f,P):new Map,K={...n.selectRenderState({activePersistentAnimations:k(C),restoredPersistentAnimations:k(M)}),id:`render-${t}-${i}-${r}`};return y.set(K.id,{builtAt:P,persistentAnimationSessions:new Map([...M.entries(),...C.entries()]),usedRestoredPersistentAnimationSessions:R}),K},be=(w={})=>re(w),Pe=(w={})=>re(w),ue=w=>{if(!a||!n)return;let P=typeof w?.id=="string"&&w.id.length>0?w.id:null,R=P?y.get(P):null;P&&y.delete(P);let C=new Map;Fa(w?.animations).forEach(M=>{let U=mn(M);if(!U)return;let K=R?.persistentAnimationSessions?.get(U)??d.get(U),Z=Math.max(0,Ya(M)),fe=K?.startedAt??R?.builtAt??Date.now();C.set(U,{animation:structuredClone(M),startedAt:fe,expiresAt:fe+Z})}),d=C,R?.usedRestoredPersistentAnimationSessions&&(f=new Map)},se=()=>n.selectSystemState(),pe=()=>n.selectAchievements(),le=w=>n.selectAchievement(w),ie=()=>n.selectSaveSlotMap(),ce=w=>n.selectSaveSlot(w),ve=w=>n.selectSaveSlotPage(w),Ge=()=>n.selectImageGallery(),lr=()=>n.selectMusicRoom(),He=()=>n.selectSceneReplay(),Ze=()=>n.selectIsSceneReplayActive(),Ie=()=>n.selectSkipMode(),$=()=>n.selectAutoMode(),N=()=>n.selectRuntime(),V=()=>n.selectIsChoiceVisible(),Q=()=>n.selectIsFormVisible(),xe=()=>n.selectActiveInteraction(),qr=()=>n.selectPendingEffects().some(w=>w?.name==="handleLineActions"||w?.name==="render"),Ee=(w,P,R={})=>!ze(P)||w!=="nextLine"?P:R.bypassChoice===!0?{...P,bypassChoice:!0}:R.interactionSource===uo?{...P,_interactionSource:uo}:P,de=(w={})=>({type:po,payload:Ee("nextLine",{_conditionalContinuation:!0},w)}),ut=(w,P)=>Is(w)?{type:po,payload:{...w.payload,...P.payload}}:P,Vr=w=>{w.savedCheckpointOccurrences.forEach(P=>{n.markSavedRollbackCheckpointTransient(P)}),w.savedCheckpointOccurrences=[]},pp=(w,P)=>{let R=p;return p=null,!R||!ct(R.pointer,w)||R.checkpointIndex!==P?.checkpointIndex||R.checkpointIdentity!==P?.checkpoint?[]:R.savedCheckpointOccurrences},dp=w=>{let P=m;return!P||!ct(P.pointer,w)?null:(m=null,P)},fp=({actionType:w,pointerBeforeAction:P,pointerAfterAction:R,cursorBeforeAction:C,cursorAfterAction:M,wasSceneReplayActive:U,isSceneReplayActive:K})=>{!R||!(!ct(P,R)||C?.checkpoint!==M?.checkpoint||C?.checkpointIndex!==M?.checkpointIndex||w==="jumpToLine")||(m={pointer:R,appendToPrevious:YI.has(w)&&U===K&&P?.sectionId===R.sectionId&&P?.lineId!==R.lineId,reuseExistingOccurrence:zI.has(w),forceNewOccurrence:w==="jumpToLine"})},ho=w=>{w.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:w.rollbackCursor?.checkpointIndex,checkpointIdentity:w.rollbackCursor?.checkpoint,sectionId:w.pointer?.sectionId,lineId:w.pointer?.lineId}),Vr(w))},mp=(w,P,R)=>UI.has(w)?w==="resetStoryAtSection"?R?.checkpoint!==P?.checkpoint:R?.checkpoint!==P?.checkpoint&&R?.checkpointIndex>P?.checkpointIndex:!1,yp=w=>{let P=u.at(-1);if(!P?.markCurrentCheckpointTransient)return;let R=n.selectSaveSlot({slotId:w?.slotId});R&&P.savedCheckpointOccurrences.push({slotId:w.slotId,saveSlotIdentity:R,checkpointIndex:P.rollbackCursor?.checkpointIndex,sectionId:P.pointer?.sectionId,lineId:P.pointer?.lineId})},hp=(w,P,R)=>{let C=u.at(-1);if(!C)return;let M=n.selectCurrentPointer()?.pointer,U=mp(w,P,R);if(ct(C.pointer,M)){let K=R?.checkpoint!==P?.checkpoint||R?.checkpointIndex!==P?.checkpointIndex;(U||K&&BI.has(w))&&(ho(C),C.pointer=M,C.rollbackCursor=R,C.markCurrentCheckpointTransient=U,C.savedCheckpointOccurrences=[]);return}ho(C),C.pointer=M,C.rollbackCursor=n.selectRollbackCursor?.()??null,C.markCurrentCheckpointTransient=U,C.savedCheckpointOccurrences=[]},Bt=(w,P)=>{if(x(`action "${w}"`),!n[w])return;let R=P,C,M;if(w==="updateProjectData")go(P),C=structuredClone(P.projectData),R={...P,projectData:bs({projectData:C,l10nData:h,l10nId:I})},go(R);else if(w==="updateLocalizationPackage"){if(M=gp(P),M===I)return;R={l10nId:M,projectData:bs({projectData:g,l10nData:h,l10nId:M})}}FI.has(w)&&(c+=1);let U=n.selectIsSceneReplayActive?.()===!0,K=VI.has(w)?v(d):null,Z=n.selectCurrentPointer()?.pointer??null,fe=n.selectRollbackCursor?.()??null,Xe=n[w](R);C!==void 0&&(g=C),M!==void 0&&(I=M),qI.has(w)&&(f=K??new Map,d=new Map);let De=n.selectIsSceneReplayActive?.()===!0;U!==De&&(d=new Map,f=new Map);let Fr=n.selectCurrentPointer()?.pointer??null,Ur=n.selectRollbackCursor?.()??null;return w==="saveSlot"&&yp(P),hp(w,fe,Ur),fp({actionType:w,pointerBeforeAction:Z,pointerAfterAction:Fr,cursorBeforeAction:fe,cursorAfterAction:Ur,wasSceneReplayActive:U,isSceneReplayActive:De}),O(),Xe},go=w=>{if(!Object.prototype.hasOwnProperty.call(w??{},"projectData"))throw new Error("updateProjectData requires projectData");Rr(w?.projectData?.resources?.variables??{}),gt(w.projectData),bt(w.projectData),It(w.projectData)},gp=w=>{if(!ze(w))throw new Error("updateLocalizationPackage requires an object payload");let P=Object.keys(w);if(P.length!==1||P[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(w.l10nId!==null&&(typeof w.l10nId!="string"||w.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return w.l10nId},bp=(w,P,R)=>{let C=n.selectCurrentPointer()?.pointer;P!==C||R!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),Bt("nextLineFromSystem",w.payload))},Ip=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(y),canonicalProjectData:g,localizationPackageId:I}),wp=w=>{r=w.renderSequence,c=w.conditionalRoutingSequence,u=w.rollbackNavigationContexts.slice(),p=w.pendingRollbackLineEntrySaveHandoff,m=w.pendingDialogueHistoryLineEntry,d=new Map(w.persistentAnimationSessions),f=new Map(w.restoredPersistentAnimationSessions),y=new Map(w.renderPersistentAnimationMetadata),g=w.canonicalProjectData,I=w.localizationPackageId},bo=(w,P={})=>(x("action batch"),j(()=>{let R=Ip();try{return n[Ws](()=>{let C,M=n.selectCurrentPointer()?.pointer??null,U=n.selectRollbackCursor?.()??null,K=c,Z={pointer:M,rollbackCursor:U,markCurrentCheckpointTransient:P.rollbackSource==="line",savedCheckpointOccurrences:P.savedCheckpointOccurrences?.slice()??[]};u.push(Z);try{n.beginRollbackActionBatch({source:P.rollbackSource});try{C=w()}finally{n.endRollbackActionBatch({})}Is(C)&&bp(C,M,K);let fe=n.selectCurrentPointer()?.pointer??null;P.rollbackSource==="line"&&ct(M,fe)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:Z.savedCheckpointOccurrences,appendToPrevious:P.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:P.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:P.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!ct(M,Z.pointer)||U?.checkpoint!==Z.rollbackCursor?.checkpoint)&&Z.markCurrentCheckpointTransient&&Z.savedCheckpointOccurrences.length>0&&(p={pointer:Z.pointer,checkpointIndex:Z.rollbackCursor?.checkpointIndex,checkpointIdentity:Z.rollbackCursor?.checkpoint,savedCheckpointOccurrences:Z.savedCheckpointOccurrences})}})}catch(C){throw wp(R),C}})),Io=(w,P,R,C={})=>{if(w===op)return bo(()=>{let M=ws(R),U=ei({[w]:P},M);return wo(U[w],R,C)},C);Bt(w,P)},vp=(w,P)=>{Io(w,P)},ws=w=>{if(!w)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};if(Object.prototype.hasOwnProperty.call(w,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".');let{_event:P,...R}=w,C=n.selectAllVariables?n.selectAllVariables():void 0;return{...R,_event:P,variables:C,runtime:n.selectRuntime?n.selectRuntime():{}}},Ap=w=>{if(!ze(w))return{templatePayload:w,literalTargetIds:null};let P=n.selectImageGalleryConfig();if(!Array.isArray(P?.groups))return{templatePayload:w,literalTargetIds:null};let R=typeof w.groupId=="string"?P.groups.find(M=>M.id===w.groupId):void 0;if(!R)return{templatePayload:w,literalTargetIds:null};let C=typeof w.variantId=="string"&&R.variants.some(M=>M.id===w.variantId);return{templatePayload:{...w,groupId:null,...C?{variantId:null}:{}},literalTargetIds:{groupId:w.groupId,...C?{variantId:w.variantId}:{}}}},kp=w=>!ze(w)||typeof w.trackId!="string"?{templatePayload:w,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(C=>C.id===w.trackId)?{templatePayload:{...w,trackId:null},literalTargetIds:{trackId:w.trackId}}:{templatePayload:w,literalTargetIds:null},Pp=w=>!ze(w)||typeof w.sceneId!="string"?{templatePayload:w,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(C=>C.sceneId===w.sceneId)?{templatePayload:{...w,sceneId:null},literalTargetIds:{sceneId:w.sceneId}}:{templatePayload:w,literalTargetIds:null},xp=w=>{if(!ze(w))throw new Error("conditional action payload must be an object");if(!Array.isArray(w.branches))throw new Error("conditional action requires branches array");if(w.branches.length===0)throw new Error("conditional action requires at least one branch")},Ep=(w,P,R)=>{if(!ze(w))throw new Error(`conditional branch at index ${P} must be an object`);if(!ze(w.actions))throw new Error(`conditional branch at index ${P} requires actions object`);if(!Object.prototype.hasOwnProperty.call(w,"when")&&P!==R-1)throw new Error("conditional else branch must be the last branch")},wo=(w,P,R)=>{xp(w);let C=de(R);for(let M=0;M<w.branches.length;M+=1){let U=w.branches[M];Ep(U,M,w.branches.length);let K=ws(P);if(Object.prototype.hasOwnProperty.call(U,"when")&&!ht(U.when,K))continue;let fe=vs(U.actions,P,R);return Is(fe)?ut(C,fe):C}return C},Sp=(w,P)=>({...w??{},_form:P}),Rp=(w,P,R,C)=>{let M=Bt(w,P),U=M?.submitted===!0&&M.valid===!0,K=M?.cancelled===!0;if(!(!U&&!K)&&ze(P.actions))return vs(P.actions,Sp(R,M.form),{...C,interactionSource:uo})},Op=(w,P,R,C)=>{let M=ws(R),U={templatePayload:P,literalTargetIds:null};w===HI?U=Ap(P):w===XI?U=kp(P):w===WI&&(U=Pp(P));let{templatePayload:K,literalTargetIds:Z}=U,Xe=ei({[w]:K},M)[w],De=Z?{...Xe,...Z}:Xe;if(w===op)return wo(De,R,C);let Fr=Ee(w,De,C);if(GI.has(w))return Rp(w,Fr,R,C);Bt(w,Fr)},vs=(w,P,R)=>{let C;return Object.entries(w).forEach(([M,U])=>{let K=Op(M,U,P,R);Is(K)&&(C=ut(C,K))}),C},vo=(w,P,R={})=>bo(()=>vs(w,P,R),R),Cp=w=>{let P=n.selectCurrentPointer()?.pointer;if(w!==P||n.selectActiveInteraction())return;let R=n.selectNextLineConfig();R?.auto?.enabled&&R.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:R.auto.delay}})};return{init:E,dispose:T,handleAction:Io,handleInternalAction:vp,handleActions:vo,selectRenderState:be,prepareRenderState:Pe,commitRenderState:ue,selectPresentationState:ae,selectPresentationChanges:G,selectSectionLineChanges:ee,selectSystemState:se,selectAchievements:pe,selectAchievement:le,selectSaveSlotMap:ie,selectSaveSlot:ce,selectSaveSlotPage:ve,selectSaveSlots:ie,selectImageGallery:Ge,selectMusicRoom:lr,selectSceneReplay:He,selectIsSceneReplayActive:Ze,selectRuntime:N,selectIsChoiceVisible:V,selectIsFormVisible:Q,selectActiveInteraction:xe,selectHasPendingRenderWork:qr,handleLineActions:w=>{if(x("line action handling"),typeof w?.sceneReplaySceneId=="string"){let P=n.selectActiveSceneReplayEntry?.();if(P?.sceneId!==w.sceneReplaySceneId||P?.entryId!==w.entryId)return!1}return j(()=>{let P=n.selectCurrentPointer()?.pointer,R=n.selectRollbackCursor?.()??null,C=p,M=m,U=pp(P,R),K=dp(P),Z=n.selectCurrentLine(),fe=!1;if(Z?.actions){try{vo(Z.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:U,dialogueHistoryAppendToPrevious:K?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:K?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:K?.forceNewOccurrence===!0})}catch(Xe){throw p=C,m=M,Xe}fe=!0}return Cp(P),fe})},getNamespace:q}}var mo=()=>{let e=0,t=null;return{getElapsed:()=>e,setElapsed:n=>{e=n},addElapsed:n=>{e+=n},getCallback:()=>t,setCallback:n=>{t=n}}},JI=80,QI="music-room:player",cp=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),ap=(e,t)=>cp.has(e)&&t?._event?.id===QI,up=({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:i,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(r)??e.selectRenderState(r);n?.(s),t.render(s),a(i)&&e.commitRenderState?.(s)},ZI=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:i,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let o=i?.()??0,l=e.handleLineActions(s);(i?.()??0)===o&&up({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},yo=({ticker:e,timerState:t,callback:n})=>{e.remove(n),t.getCallback()===n&&(t.setCallback(null),t.setElapsed(0))},e0=({engine:e,ticker:t,autoTimer:n,lifecycleGeneration:i,isCurrentLifecycle:a},r)=>{let s=n.getCallback();s&&t.remove(s),n.setElapsed(0);let o=l=>{if(!a(i)){yo({ticker:t,timerState:n,callback:o});return}n.addElapsed(l.deltaMS);let c=r.delay??1e3;n.getElapsed()>=c&&(t.remove(o),n.setCallback(null),n.setElapsed(0),Ut(e,"nextLineFromSystem",{}))};n.setCallback(o),t.add(o)},r0=({ticker:e,autoTimer:t},n)=>{let i=t.getCallback();i&&(e.remove(i),t.setCallback(null)),t.setElapsed(0)},t0=({engine:e,ticker:t,skipTimer:n,lifecycleGeneration:i,isCurrentLifecycle:a},r)=>{let s=n.getCallback();s&&t.remove(s),n.setElapsed(0);let o=l=>{if(!a(i)){yo({ticker:t,timerState:n,callback:o});return}n.addElapsed(l.deltaMS);let c=r?.delay??JI;n.getElapsed()>=c&&(n.setElapsed(0),Ut(e,"nextLineFromSystem",{}))};n.setCallback(o),t.add(o)},n0=({ticker:e,skipTimer:t},n)=>{let i=t.getCallback();i&&(e.remove(i),t.setCallback(null)),t.setElapsed(0)},s0=({engine:e,ticker:t,nextLineConfigTimerState:n,lifecycleGeneration:i,isCurrentLifecycle:a},r)=>{let s=n.getCallback();s&&t.remove(s),n.setElapsed(0);let o=l=>{if(!a(i)){yo({ticker:t,timerState:n,callback:o});return}n.addElapsed(l.deltaMS);let c=r.delay??1e3;n.getElapsed()>=c&&(n.setElapsed(0),Ut(e,"nextLineFromSystem",{}),t.remove(o),n.getCallback()===o&&n.setCallback(null))};n.setCallback(o),t.add(o)},i0=({ticker:e,nextLineConfigTimerState:t},n)=>{let i=t.getCallback();i&&(e.remove(i),t.setCallback(null)),t.setElapsed(0)},o0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},a0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},l0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},c0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},u0=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},lp={render:up,saveSlots:o0,saveGlobalDeviceVariables:a0,saveGlobalAccountVariables:l0,saveGlobalRuntime:c0,applyScopedDataUpdates:u0,handleLineActions:ZI,startAutoNextTimer:e0,clearAutoNextTimer:r0,startSkipNextTimer:t0,clearSkipNextTimer:n0,nextLineConfigTimer:s0,clearNextLineConfigTimer:i0},p0=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Ut=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},d0=(e=[])=>{let t=new Set,n=[];for(let i=e.length-1;i>=0;i-=1){let a=e[i];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!p0.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},f0=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:i,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:o})=>{let l=mo(),c=mo(),u=mo(),p=new Map,m=Promise.resolve(),d=null,f=null,y=!1,g=0,h=0,I=!0,b=$=>{let N=$.getCallback();N&&n.remove(N),$.setCallback(null),$.setElapsed(0)},x=()=>{b(l),b(c),b(u)},v=()=>{d=null,f=null,y=!1,g=0},k=()=>{h+=1,x(),v(),I=!0},S=()=>{h+=1,I=!1,x(),v()},O=$=>I&&$===h,j=$=>{if(a){a($);return}console.error("RouteEngine persistence write failed.",$)},E=$=>{if(s)return s;let N=ot($),V=p.get(N);if(V)return V;let Q=ao({indexedDB:r,namespace:N});return p.set(N,Q),Q},T=$=>{let N=s?null:ot(o??e()?.getNamespace?.()),V;m=m.catch(()=>{}).then(()=>(V=E(N),$(V))).catch(Q=>{!s&&p.get(N)===V&&p.delete(N),j(Q)})},q=$=>{if(!I)return;let N=typeof $?.id=="string"&&$.id.length>0?$.id:null;g+=1,d=N,y=!1},ae=()=>g,G=($={})=>{if(!I||$?.aborted===!0)return!1;let N=typeof $?.id=="string"&&$.id.length>0?$.id:null;return N?N!==d||N===f?!1:(f=N,!0):d!==null||y?!1:(y=!0,!0)},ee=($,N={})=>{if(!I)return!1;if(ap($,N)){let Q=cp.get($),xe=e();return Ut(xe,Q,N?._event),!0}if($!=="renderComplete"||!G(N))return!1;let V=e();return Ut(V,"markLineCompleted",{}),!0},re=new Set(["updateFormField","submitForm","cancelForm"]),be=new Set(["updateVariable"]),Pe=$=>typeof $?.selectActiveInteraction=="function"?$.selectActiveInteraction():typeof $?.selectIsChoiceVisible=="function"&&$.selectIsChoiceVisible()?{source:"choice"}:null,ue=$=>$?._formKey??$?.formKey,se=($,N)=>ue($)===N?.formKey,pe=($,N)=>!$||typeof $!="object"||Array.isArray($)?!1:$._interactionSource===N?.source,le=($,N)=>pe($,N)?N.source==="form"?se($,N):!0:!1,ie=($,N)=>!$||typeof $!="object"||Array.isArray($)||N?.source!=="form"?!1:se($,N),ce=($={})=>Object.keys($).some(N=>re.has(N)),ve=($={},N)=>Object.entries($).some(([V,Q])=>re.has(V)&&ie(Q,N)),Ge=($={})=>Object.keys($).length>0&&Object.keys($).every(N=>be.has(N)),lr=($={},N)=>{let V=$?.actions;return N?.source==="form"?!V||typeof V!="object"||Array.isArray(V)?!1:ve(V,N)?!0:ce(V)?!1:Ge(V):le($,N)?!0:!V||typeof V!="object"||Array.isArray(V)?!1:Object.values(V).some(Q=>le(Q,N))},He=($,N={})=>{if(!N?.actions)return!1;let V=Pe($);return!V||V.source==="choice"?!1:!lr(N,V)},Ze=({preprocessPayload:$,onEvent:N}={})=>async(V,Q={})=>{if(!I)return!1;if(ap(V,Q))return ee(V,Q),N?.(V,Q);let xe=e(),qr=h,Ee=g;if(He(xe,Q))return N?.(V,Q);let de=await $?.(V,Q)??Q;if(!O(qr)||e()!==xe||g!==Ee)return!1;if(He(xe,de))return N?.(V,de);if(ee(V,de),de?.actions){let ut=de?._event?{_event:de._event}:de?.event?{_event:de.event}:void 0,Vr;de?.bypassChoice===!0?Vr={bypassChoice:!0}:de?._interactionSource&&(Vr={interactionSource:de._interactionSource}),Vr?xe.handleActions(de.actions,ut,Vr):xe.handleActions(de.actions,ut)}return N?.(V,de)},Ie=$=>{if(!I)return;let N=h,V=e(),Q=d0($),xe=Q.some(Ee=>Ee.name==="handleLineActions");Q.forEach(Ee=>{if(!lp[Ee.name]&&!i)throw new Error(`Unhandled pending effect "${Ee.name}".`)});let qr={engine:V,routeGraphics:t,ticker:n,autoTimer:l,skipTimer:c,nextLineConfigTimerState:u,trackRenderDispatch:q,getRenderDispatchCount:ae,enqueuePersistenceWrite:T,lifecycleGeneration:h,isCurrentLifecycle:O};for(let Ee of Q){if(!O(N))break;if(xe&&Ee.name==="render")continue;let de=lp[Ee.name];if(de){de(qr,Ee.payload);continue}i(Ee,qr)}};return Ie.handleRouteGraphicsEvent=ee,Ie.createRouteGraphicsEventHandler=Ze,Ie.reset=k,Ie.dispose=S,Ie},m0=f0;var y0=(e,t={})=>{let{resources:n={}}=t;return Ei(e,n)};var Qw=fo;export{ii as DEFAULT_VISUAL_LAYER,Xr as RENDER_LAYER,er as VISUAL_LAYER,m0 as createEffectsHandler,Wb as createIndexedDbPersistence,Qw as default,Js as formatDate,nf as resolveComputedVariables,y0 as resolveLayoutReferences};
|