route-engine-js 1.34.0 → 1.36.0
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 +1 -1
package/dist/RouteEngine.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var mp=Object.defineProperty;var yp=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),hp=(e,t)=>{for(var n in t)mp(e,n,{get:t[n],enumerable:!0})};var _c=yp(Ji=>{"use strict";Object.defineProperty(Ji,"__esModule",{value:!0});function Cc(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}Ji.default=Cc;Cc.code='require("ajv/dist/runtime/ucs2length").default'});var ho=Symbol.for("immer-nothing"),uo=Symbol.for("immer-draftable"),Ae=Symbol.for("immer-state");function _e(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var jr=Object.getPrototypeOf;function ye(e){return!!e&&!!e[Ae]}function fr(e){return e?go(e)||Array.isArray(e)||!!e[uo]||!!e.constructor?.[uo]||qt(e)||Vt(e):!1}var gp=Object.prototype.constructor.toString();function go(e){if(!e||typeof e!="object")return!1;let t=jr(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)===gp}function vs(e){return ye(e)||_e(15,e),e[Ae].base_}function Dt(e,t){Mt(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,i)=>t(i,n,e))}function Mt(e){let t=e[Ae];return t?t.type_:Array.isArray(e)?1:qt(e)?2:Vt(e)?3:0}function ys(e,t){return Mt(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function bo(e,t,n){let i=Mt(e);i===2?e.set(t,n):i===3?e.add(n):e[t]=n}function bp(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function qt(e){return e instanceof Map}function Vt(e){return e instanceof Set}function pr(e){return e.copy_||e.base_}function hs(e,t){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=go(e);if(t===!0||t==="class_only"&&!n){let i=Object.getOwnPropertyDescriptors(e);delete i[Ae];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(jr(e),i)}else{let i=jr(e);if(i!==null&&n)return{...e};let a=Object.create(i);return Object.assign(a,e)}}function As(e,t=!1){return Ft(e)||ye(e)||!fr(e)||(Mt(e)>1&&(e.set=e.add=e.clear=e.delete=wp),Object.freeze(e),t&&Object.entries(e).forEach(([n,i])=>As(i,!0))),e}function wp(){_e(2)}function Ft(e){return Object.isFrozen(e)}var Ip={};function dr(e){let t=Ip[e];return t||_e(0,e),t}var et;function wo(){return et}function vp(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function po(e,t){t&&(dr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function gs(e){bs(e),e.drafts_.forEach(Ap),e.drafts_=null}function bs(e){e===et&&(et=e.parent_)}function fo(e){return et=vp(et,e)}function Ap(e){let t=e[Ae];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function mo(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Ae].modified_&&(gs(t),_e(4)),fr(e)&&(e=Tt(t,e),t.parent_||Lt(t,e)),t.patches_&&dr("Patches").generateReplacementPatches_(n[Ae].base_,e,t.patches_,t.inversePatches_)):e=Tt(t,n,[]),gs(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==ho?e:void 0}function Tt(e,t,n){if(Ft(t))return t;let i=t[Ae];if(!i)return Dt(t,(a,r)=>yo(e,i,t,a,r,n)),t;if(i.scope_!==e)return t;if(!i.modified_)return Lt(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),Dt(r,(o,l)=>yo(e,i,a,o,l,n,s)),Lt(e,a,!1),n&&e.patches_&&dr("Patches").generatePatches_(i,n,e.patches_,e.inversePatches_)}return i.copy_}function yo(e,t,n,i,a,r,s){if(ye(a)){let o=r&&t&&t.type_!==3&&!ys(t.assigned_,i)?r.concat(i):void 0,l=Tt(e,a,o);if(bo(n,i,l),ye(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(fr(a)&&!Ft(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Tt(e,a),(!t||!t.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&Lt(e,a)}}function Lt(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&As(t,n)}function kp(e,t){let n=Array.isArray(e),i={type_:n?1:0,scope_:t?t.scope_:wo(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=i,r=ks;n&&(a=[i],r=rt);let{revoke:s,proxy:o}=Proxy.revocable(a,r);return i.draft_=o,i.revoke_=s,o}var ks={get(e,t){if(t===Ae)return e;let n=pr(e);if(!ys(n,t))return Pp(e,n,t);let i=n[t];return e.finalized_||!fr(i)?i:i===ds(e.base_,t)?(ms(e),e.copy_[t]=Is(i,e)):i},has(e,t){return t in pr(e)},ownKeys(e){return Reflect.ownKeys(pr(e))},set(e,t,n){let i=Io(pr(e),t);if(i?.set)return i.set.call(e.draft_,n),!0;if(!e.modified_){let a=ds(pr(e),t),r=a?.[Ae];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(bp(n,a)&&(n!==void 0||ys(e.base_,t)))return!0;ms(e),ws(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 ds(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,ms(e),ws(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=pr(e),i=Reflect.getOwnPropertyDescriptor(n,t);return i&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:i.enumerable,value:n[t]}},defineProperty(){_e(11)},getPrototypeOf(e){return jr(e.base_)},setPrototypeOf(){_e(12)}},rt={};Dt(ks,(e,t)=>{rt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});rt.deleteProperty=function(e,t){return rt.set.call(this,e,t,void 0)};rt.set=function(e,t,n){return ks.set.call(this,e[0],t,n,e[0])};function ds(e,t){let n=e[Ae];return(n?pr(n):e)[t]}function Pp(e,t,n){let i=Io(t,n);return i?"value"in i?i.value:i.get?.call(e.draft_):void 0}function Io(e,t){if(!(t in e))return;let n=jr(e);for(;n;){let i=Object.getOwnPropertyDescriptor(n,t);if(i)return i;n=jr(n)}}function ws(e){e.modified_||(e.modified_=!0,e.parent_&&ws(e.parent_))}function ms(e){e.copy_||(e.copy_=hs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var xp=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"&&_e(6),i!==void 0&&typeof i!="function"&&_e(7);let a;if(fr(t)){let r=fo(this),s=Is(t,void 0),o=!0;try{a=n(s),o=!1}finally{o?gs(r):bs(r)}return po(r,i),mo(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===ho&&(a=void 0),this.autoFreeze_&&As(a,!0),i){let r=[],s=[];dr("Patches").generateReplacementPatches_(t,a,r,s),i(r,s)}return a}else _e(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){fr(e)||_e(8),ye(e)&&(e=er(e));let t=fo(this),n=Is(e,void 0);return n[Ae].isManual_=!0,bs(t),n}finishDraft(e,t){let n=e&&e[Ae];(!n||!n.isManual_)&&_e(9);let{scope_:i}=n;return po(i,t),mo(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=dr("Patches").applyPatches_;return ye(e)?i(e,t):this.produce(e,a=>i(a,t))}};function Is(e,t){let n=qt(e)?dr("MapSet").proxyMap_(e,t):Vt(e)?dr("MapSet").proxySet_(e,t):kp(e,t);return(t?t.scope_:wo()).drafts_.push(n),n}function er(e){return ye(e)||_e(10,e),vo(e)}function vo(e){if(!fr(e)||Ft(e))return e;let t=e[Ae],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=hs(e,t.scope_.immer_.useStrictShallowCopy_)}else n=hs(e,!0);return Dt(n,(i,a)=>{bo(n,i,vo(a))}),t&&(t.finalized_=!1),n}var Se=new xp,Ps=Se.produce,q0=Se.produceWithPatches.bind(Se),V0=Se.setAutoFreeze.bind(Se),F0=Se.setUseStrictShallowCopy.bind(Se),U0=Se.applyPatches.bind(Se),B0=Se.createDraft.bind(Se),Y0=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(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ie=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var xs=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}')`)},Ao=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 ko=(e,t,n=!1)=>{if(t===null)return new Ie(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ie(`Cannot iterate over undefined value at '$for ${e}'`);let i=typeof t;return n?new Ie(`Cannot iterate over non-array value in loop '${e}' - got ${i} instead`):new Ie(`Cannot iterate over non-array value (got: ${i}) at '$for ${e}'`)},Po=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ie(`Unknown function '${e}' (${n})`)};var Ep=(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=X(e,{functions:i,partials:a},t,{});return s===void 0?{}:s},X=(e,t,n,i)=>{let a=t.functions||t;if(e.var&&!e.type)return ue(e.var,n,i);if(e.type===A.LITERAL)return e.value;if(e.type===A.VARIABLE)return ue(e.path,n,i);if(e.type===A.INTERPOLATION)return Op(e.parts,t,n,i);switch(e.type){case A.FUNCTION:return Eo(e,t,n,i);case A.BINARY:return So(e,t,n,i);case A.UNARY:return Oo(e,t,n,i);case A.CONDITIONAL:return Cp(e,t,n,i);case A.LOOP:return Dp(e,t,n,i);case A.OBJECT:return Lp(e,t,n,i);case A.ARRAY:return Mp(e,t,n,i);case A.PARTIAL:return qp(e,t,n,i);case A.PATH_REFERENCE:return Vp(e,t,n,i);default:throw new Error(`Unknown node type: ${e.type}`)}},xo=new Map,Sp=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},ue=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let i=xo.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=Sp(l.trim());i.push(...c)}xo.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},Op=(e,t,n,i)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=X(r,t,n,i);a.push(s!=null?String(s):"")}return a.join("")},Eo=(e,t,n,i)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Po(e.name,a);let s=e.args.map(o=>X(o,t,n,i));return r(...s)},rr=(e,t,n,i)=>{if(e.var&&!e.type)return ue(e.var,n,i);switch(e.type){case A.VARIABLE:return ue(e.path,n,i);case A.LITERAL:return e.value;case A.BINARY:return So(e,t,n,i);case A.UNARY:return Oo(e,t,n,i);case A.FUNCTION:return Eo(e,t,n,i);default:return X(e,t,n,i)}},So=(e,t,n,i)=>{if(e.op===z.AND||e.op===z.OR){let s=rr(e.left,t,n,i),o=rr(e.right,t,n,i);switch(e.op){case z.AND:return s&&o;case z.OR:return s||o}}let a=X(e.left,t,n,i),r=X(e.right,t,n,i);switch(e.op){case z.EQ:return a==r;case z.NEQ:return a!=r;case z.GT:return a>r;case z.LT:return a<r;case z.GTE:return a>=r;case z.LTE:return a<=r;case z.IN:return Array.isArray(r)?r.includes(a):!1;case z.ADD:if(typeof a!="number"||typeof r!="number")throw new Ie(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case z.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ie(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Oo=(e,t,n,i)=>{let a=e.op===Nr.NOT?rr(e.operand,t,n,i):X(e.operand,t,n,i);if(e.op===Nr.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Rp=(e,t,n,i)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===A.VARIABLE)if(ue(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?X(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]=ue(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=ue(m.path,n,i);p.push(d!=null?String(d):"")}else{let d=X(m,t,n,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=X(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?X(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]=ue(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=ue(m.path,n,i);p.push(d!=null?String(d):"")}else{let d=X(m,t,n,i);p.push(d!=null?String(d):"")}o[c]=p.join("")}else o[c]=X(u,t,n,i)}return o}}}return null},Cp=(e,t,n,i)=>{let a=Rp(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||rr(s,t,n,i))return X(e.bodies[r],t,n,i)}return Ro},_p=(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 w=h.substring(i.length+1),b=c[w];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},$p=(e,t)=>{let n=e.body,i=e.itemVar,a=_p(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},jp=(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?X(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 w=h.substring(o.length+1);!w.includes(".")&&!w.includes("[")?p[y]=u[w]:p[y]=ue(h,n,{...i,[o]:u,...l&&{[l]:c}})}else p[y]=ue(h,n,{...i,[o]:u,...l&&{[l]:c}})}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===o)E=u;else if(b===l)E=c;else if(b.startsWith(o+".")){let v=b.substring(o.length+1);!v.includes(".")&&!v.includes("[")?E=u[v]:E=ue(b,n,{...i,[o]:u,...l&&{[l]:c}})}else E=ue(b,n,{...i,[o]:u,...l&&{[l]:c}});h.push(E!=null?String(E):"")}else{let b={...i,[o]:u,...l&&{[l]:c}},E=X(w,t,n,b);h.push(E!=null?String(E):"")}p[y]=h.join("")}else{let h={...i,[o]:u,...l&&{[l]:c}};p[y]=X(g,t,n,h)}}r.push(p)}return r}return null},Np=(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},Dp=(e,t,n,i)=>{let a=X(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 ko(p,a,u)}if(!e.indexVar){let c=Np(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=$p(e,a);if(c!==null)return c}let r=jp(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=X(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},Tp=(e,t,n,i)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?X(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?X(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]=ue(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=ue(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]=ue(g.path,n,i);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=ue(w.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},Lp=(e,t,n,i)=>{let a=t.functions||t;if(e.whenCondition&&!rr(e.whenCondition,a,n,i))return;let r=Tp(e,t,n,i);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?X(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]=ue(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=ue(f.path,n,i);d.push(y!=null?String(y):"")}else{let y=X(f,t,n,i);d.push(y!=null?String(y):"")}c[p]=d.join("")}else c[p]=X(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=X(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 X(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=X(p.value,t,n,i);m!==void 0&&(s[c.key]=m)}else{let m=X(c.value,t,n,i);m!==void 0&&(s[c.key]=m)}}else{let p=c.parsedKey?X(c.parsedKey,t,n,i):c.key,m=X(c.value,t,n,i);m!==void 0&&(s[p]=m)}}return s},Ro={},Mp=(e,t,n,i)=>{let a=[];for(let r of e.items)if(r.type===A.LOOP){let s=X(r,t,n,i);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=X(r,t,n,i);s!==Ro&&s!==void 0&&a.push(s)}return a},qp=(e,t,n,i)=>{let{name:a,data:r,whenCondition:s}=e,o=t.partials||{},l=t.functions||t;if(s&&!rr(s,l,n,i))return;if(!o[a])throw new Ie(`Partial '${a}' is not defined`);let c=i._partialStack||[];if(c.includes(a))throw new Ie(`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=X(r,t,n,i);p={...p,...d}}return X(u,t,p,m)},Vp=(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 Ie(`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 Ie(`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 Ie(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return o.length>0&&(l+="."+o.join(".")),l};var Es=Ep;var Fp=/\$\{([^}]*)\}/g,Up=/#\{([^}]*)\}/g,_o=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,i,a]=n,r=Bp(a,t);return{isFunction:!0,type:A.FUNCTION,name:i,args:r}},Bp=(e,t={})=>e.trim()?Yp(e).map(i=>zp(i.trim(),t)):[],Yp=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},zp=(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=_o(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=mr(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 de(i,t)}catch{return{type:A.VARIABLE,path:i}}return{type:A.VARIABLE,path:i}},$o=/^\w+\(.*\)$/,Gp=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Xp=e=>{if(!(!e||e.trim()===""||$o.test(e))&&Gp.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}"`)},Co=e=>{let t=e.trim();if($o.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}},tt=(e,t={})=>{let n=e.trim();Xp(n);let i=_o(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}},Ss=(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(Fp)],r=[...n.matchAll(Up)],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"?tt(c[1],t):Co(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=tt(m.trim(),t):f=Co(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 Cs=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Do=e=>Object.keys(e),be=e=>e.join("."),tr=(e,t,n)=>{let i=Do(e).filter(a=>!t.has(a));if(i.length>0)throw new $(`Unexpected key '${i[0]}' in condition JSON at '${be(n)}'`)},nr=(e,t)=>typeof e=="string"?Ss(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?Hp(e,t):Kp(e,t):{type:A.LITERAL,value:e},Wp=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}},Hp=(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=Wp(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=No(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=No(o[0],r[o[0]],t);n.push(l),i=!0;continue}}let s=nr(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}},Kp=(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 w of l)if(h===w||h.startsWith(w+" ")||h.startsWith(w+"#")){c.push(w);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,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,t),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:u,data:y};return p!==void 0&&(g.whenCondition=jo(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=jo(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=Jp(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=nr(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=Ss(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},Jp=(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());xs(c);let u=de(c,n);for(i.push(u),a.push(nr(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{xs(f);let y=de(f,n);i.push(y)}if(a.push(nr(m,n)),r++,f===null)break}else break}return{node:{type:A.CONDITIONAL,conditions:i,bodies:a,id:l},nextIndex:r}},Os={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},Rs={all:z.AND,any:z.OR},Qp=new Set(["var","literal","call","not",...Object.keys(Os),...Object.keys(Rs)]),Zp=(e,t,n)=>{if(!Array.isArray(e))throw new $(`Condition JSON operator '${t}' at '${be(n)}' requires an array`);if(e.length!==2)throw new $(`Condition JSON operator '${t}' at '${be(n)}' requires exactly 2 operands`);return e},ef=(e,t,n,i,a)=>{if(!Array.isArray(e))throw new $(`Condition JSON operator '${t}' at '${be(a)}' requires an array`);if(e.length===0)throw new $(`Condition JSON operator '${t}' at '${be(a)}' requires at least 1 condition`);return e.map((s,o)=>ke(s,i,[...a,o])).reduce((s,o)=>({type:A.BINARY,op:n,left:s,right:o}))},rf=(e,t,n)=>{let i,a;if(typeof e.call=="string")i=e.call,a=e.args??[],tr(e,new Set(["call","args"]),n);else if(Cs(e.call))i=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 i!="string"||i.trim()==="")throw new $(`Condition JSON call at '${be(n)}' requires a non-empty function name`);if(!/^\w+$/.test(i))throw new $(`Invalid condition JSON function name '${i}' at '${be(n)}'`);if(!Array.isArray(a))throw new $(`Condition JSON call '${i}' at '${be(n)}' requires args to be an array`);return{type:A.FUNCTION,name:i,args:a.map((r,s)=>ke(r,t,[...n,"args",s]))}},ke=(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 '${be(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Cs(e))throw new $(`Invalid condition JSON value at '${be(n)}'`);let i=Do(e);if(i.length===0)throw new $(`Condition JSON object at '${be(n)}' must contain an operator`);let a=i.filter(s=>Qp.has(s));if(a.length===0)throw new $(`Unknown condition JSON operator '${i[0]}' at '${be(n)}'`);if(a.length>1)throw new $(`Condition JSON at '${be(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="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(r==="literal")return tr(e,new Set(["literal"]),n),{type:A.LITERAL,value:e.literal};if(r==="call")return rf(e,t,n);if(r==="not")return tr(e,new Set(["not"]),n),{type:A.UNARY,op:Nr.NOT,operand:ke(e.not,t,[...n,"not"])};if(r in Rs)return tr(e,new Set([r]),n),ef(e[r],r,Rs[r],t,[...n,r]);if(r in Os){tr(e,new Set([r]),n);let s=Zp(e[r],r,[...n,r]);return{type:A.BINARY,op:Os[r],left:ke(s[0],t,[...n,r,0]),right:ke(s[1],t,[...n,r,1])}}throw new $(`Unknown condition JSON operator '${r}' at '${be(n)}'`)},jo=(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 de(e,t)}return Cs(e)||Array.isArray(e)?ke(e,t):{type:A.LITERAL,value:e}},de=(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 de(c,t)}let n=mr(e,"||");if(n!==-1)return{type:A.BINARY,op:z.OR,left:de(e.substring(0,n).trim(),t),right:de(e.substring(n+2).trim(),t)};let i=mr(e,"&&");if(i!==-1)return{type:A.BINARY,op:z.AND,left:de(e.substring(0,i).trim(),t),right:de(e.substring(i+2).trim(),t)};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:c,type:u}of a){let p=mr(e,c);if(p!==-1)return{type:A.BINARY,op:u,left:de(e.substring(0,p).trim(),t),right:de(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,o=[{op:" + ",type:z.ADD},{op:" - ",type:z.SUBTRACT}];for(let{op:c,type:u}of o){let p=0;for(;p<e.length;){let m=mr(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:de(e.substring(0,r).trim(),t),right:de(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(mr(e,c)!==-1)throw new $(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:A.UNARY,op:Nr.NOT,operand:de(e.substring(1).trim(),t)}:To(e,t)},mr=(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},tf=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}},To=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return tt(n,t);let a=tf(n);if(a.type===A.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:A.VARIABLE,path:n};try{return tt(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},nf=(e,t=!1)=>{let n=t?"$each":"$for";try{Ao(e)}catch(i){if(i instanceof $&&t){let a=i.message.replace(/\$for/g,"$each");throw new $(a.replace("Parse Error: ",""))}throw i}},No=(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();nf(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=To(u,n),y=nr(t,n);return{type:A.LOOP,itemVar:p,indexVar:m,iterable:f,body:y,flatten:s!=="nested"}};var sf=(e,t={})=>{let{functions:n={}}=t;return nr(e,n)},Ut=sf;var nt={};hp(nt,{now:()=>of});var of=()=>Date.now();var af=(e,t,n={})=>{let{functions:i={},partials:a={}}=n,r={...nt,...i},s=Ut(e,{functions:r}),o={};for(let[l,c]of Object.entries(a))o[l]=Ut(c,{functions:r});return Es(s,t,{functions:r,partials:o})},yr=af;var lf=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",cf=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,uf=(e,t)=>{if(lf(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new $("Empty condition expression");return de(e,t)}return ke(e,t)},pf=(e,t={},n={})=>{let i=cf(n),a={...nt,...i},r=uf(e,a);return!!rr(r,{functions:a,partials:{}},t,{})},_s=pf;var Vs=Symbol("runStoreTransaction"),Ds="__routeEngineConditionComparison",Bt=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",sr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Bt(e,t)&&e>t,gte:(e,t)=>Bt(e,t)&&e>=t,lt:(e,t)=>Bt(e,t)&&e<t,lte:(e,t)=>Bt(e,t)&&e<=t}),Bo=Object.freeze(Object.fromEntries(Object.keys(sr).map(e=>[e,`${Ds}${e}`]))),ff=Object.freeze(Object.fromEntries(Object.entries(Bo).map(([e,t])=>[t,sr[e]]))),Lo=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),df=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"||Lo(e,"literal")||Lo(e,"var"))return e;if(df(e)?.startsWith(Ds))throw new Error(`Condition function names beginning with "${Ds}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[i,a]]=n,r=Bo[i];if(r)return{call:r,args:a.map(Yt)}}return Object.fromEntries(n.map(([i,a])=>[i,Yt(a)]))},it=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return ke(e),_s(Yt(e),t,{functions:ff})},mf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Yo=(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=Ps(i,f=>{let y=u(o(f),...p);m=y!==void 0&&!ye(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,[Vs]:l}},Wt=(e,t)=>n=>{let i=e(),a=Array.isArray(n)?n:[n];return Ps(i,r=>{a.forEach(s=>{t.forEach(o=>{o(r,s)})})})};var yf=(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{}}},U=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Ts=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},pe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),hf=new Set(["pageSize","groups"]),gf=new Set(["id","variants"]),bf=new Set(["id","imageId"]),wf=new Set(["pageSize","tracks"]),If=new Set(["id","soundId","title","artist","album","description","coverImageId"]),vf=new Set(["pageSize","replays"]),Af=new Set(["id","title","thumbnailImageId","startSectionId","initialVariables"]),hr=(e,t,n)=>{Object.keys(e).forEach(i=>{if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)})},Dr=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},ot=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!pe(t))throw new Error("resources.imageGallery must be an object");if(hr(t,hf,"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(!pe(a))throw new Error(`${r} must be an object`);if(hr(a,gf,r),Dr(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(!pe(l))throw new Error(`${c} must be an object`);if(hr(l,bf,c),Dr(l.id,`${c}.id`),Dr(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),!U(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},at=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!pe(t))throw new Error("resources.musicRoom must be an object");if(hr(t,wf,"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(!pe(a))throw new Error(`${r} must be an object`);hr(a,If,r);for(let l of["id","soundId","title"])Dr(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&Dr(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(!U(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!pe(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&&!U(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},kf=(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}"`)}},lt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!pe(t))throw new Error("resources.sceneReplay must be an object");if(hr(t,vf,"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=new Map;Object.values(e?.story?.scenes??{}).forEach(a=>{Object.entries(a?.sections??{}).forEach(([r,s])=>{n.set(r,s)})});let i=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!pe(r))throw new Error(`${s} must be an object`);hr(r,Af,s);for(let l of["id","title","thumbnailImageId","startSectionId"])Dr(r[l],`${s}.${l}`);if(i.has(r.id))throw new Error(`Duplicate scene replay id "${r.id}"`);if(i.add(r.id),!U(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay "${r.id}" references unknown thumbnail image "${r.thumbnailImageId}"`);if(!n.has(r.startSectionId))throw new Error(`Scene replay "${r.id}" references unknown start section "${r.startSectionId}"`);let o=n.get(r.startSectionId);if(o.initialLineId!==void 0&&!o.lines?.some(l=>l.id===o.initialLineId))throw new Error(`Scene replay "${r.id}" start section "${r.startSectionId}" references unknown initial line "${o.initialLineId}"`);if(r.initialVariables!==void 0){if(!pe(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[l,c]of Object.entries(r.initialVariables)){let u=e?.resources?.variables?.[l];if(!u)throw new Error(`Scene replay "${r.id}" initialVariables references unknown variable "${l}"`);if(Ne(u))throw new Error(`Scene replay "${r.id}" cannot initialize computed variable "${l}"`);if(u.readonly===!0)throw new Error(`Scene replay "${r.id}" cannot initialize readonly variable "${l}"`);if(u.scope!=="context")throw new Error(`Scene replay "${r.id}" can only initialize context variable "${l}"`);kf(l,u,c)}}}},zo=e=>{let t=ye(e)?er(e):e;return structuredClone(t)},Pf=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!U(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},Ht=({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=Pf({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},Ne=e=>U(e,"computed"),Tr=(e={},t={})=>Object.fromEntries(Object.entries(e??{}).filter(([n])=>!Ne(t[n]))),je=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),xf=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw je(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 je(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw je(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 je(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!U(l,o))throw je(t,n);a+=l[o]}return a},Go=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw je(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 je(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 je(e,t);i+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw je(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 je(e,t);i+=1,n.push(xf(p,e,t));return}i+=1}if(c||i>=e.length)throw je(e,t)};for(a();i<e.length;){if(e[i]==="."){i+=1,a();continue}if(e[i]==="["){r();continue}throw je(e,t)}return n},$s=(e,t)=>{let n=e;for(let i of t){if(n==null||!U(n,i))return;n=n[i]}return n},Xo=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Go(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 $s(s,r)}return i==="runtime"?$s(t.runtime,n.slice(1)):$s(t,n)},Wo=(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)`)},Ls=(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`)},Ef=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Me=(e,t,n,i)=>(Wo(e,t,i),t.map(a=>Xt(a,n))),$e=(e,t,n,i)=>{let a=Me(e,t,n,i);return a.forEach(r=>Ef(e,r)),a},Sf=(e,t,n)=>{switch(e){case"var":return Xo(t,n);case"add":{let[i,a]=$e(e,t,n,2);return i+a}case"sub":{let[i,a]=$e(e,t,n,2);return i-a}case"mul":{let[i,a]=$e(e,t,n,2);return i*a}case"div":{let[i,a]=$e(e,t,n,2);return i/a}case"mod":{let[i,a]=$e(e,t,n,2);return i%a}case"neg":{let[i]=$e(e,t,n,1);return-i}case"round":{let[i]=$e(e,t,n,1);return Math.round(i)}case"floor":{let[i]=$e(e,t,n,1);return Math.floor(i)}case"ceil":{let[i]=$e(e,t,n,1);return Math.ceil(i)}case"min":{let[i,a]=$e(e,t,n,2);return Math.min(i,a)}case"max":{let[i,a]=$e(e,t,n,2);return Math.max(i,a)}case"clamp":{let[i,a,r]=$e(e,t,n,3);return Math.min(r,Math.max(a,i))}case"eq":{let[i,a]=Me(e,t,n,2);return sr.eq(i,a)}case"neq":{let[i,a]=Me(e,t,n,2);return sr.neq(i,a)}case"gt":{let[i,a]=Me(e,t,n,2);return sr.gt(i,a)}case"gte":{let[i,a]=Me(e,t,n,2);return sr.gte(i,a)}case"lt":{let[i,a]=Me(e,t,n,2);return sr.lt(i,a)}case"lte":{let[i,a]=Me(e,t,n,2);return sr.lte(i,a)}case"in":{let[i,a]=Me(e,t,n,2);return Array.isArray(a)?a.includes(i):!1}case"and":case"all":return Ls(e,t),t.every(i=>!!Xt(i,n));case"or":case"any":return Ls(e,t),t.some(i=>!!Xt(i,n));case"not":{let[i]=Me(e,t,n,1);return!i}case"length":{let[i]=Me(e,t,n,1);return typeof i=="string"||Array.isArray(i)?i.length:pe(i)?Object.keys(i).length:0}case"includes":{let[i,a]=Me(e,t,n,2);return typeof i=="string"?typeof a=="string"&&i.includes(a):Array.isArray(i)?i.includes(a):!1}case"literal":return zo(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Xt=(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 Sf(i,a,t)},Ms=(e,t)=>{if(e===null||typeof e!="object"||U(e,"literal"))return e;if(U(e,"var"))return{literal:Xo(e.var,t)};if(U(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=>Ms(a,t)):Ms(i,t)]))},Of=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return ke(e),it(Ms(e,t))},Ho=(e,t)=>{if(!pe(e))throw new Error(`${t} must be an object`);let n=U(e,"expr"),i=U(e,"value");if(n===i)throw new Error(`${t} must contain exactly one of expr or value`)},js=(e,t,n)=>(Ho(e,t),U(e,"value")?zo(e.value):Xt(e.expr,n)),Rf=(e,t={},n="unknown")=>{if(!pe(e))throw new Error(`Computed variable "${n}" computed must be an object`);let i=U(e,"expr"),a=U(e,"value");if(U(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(!pe(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(!pe(o))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!U(o,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Of(o.when,t))return js(o,`Computed variable "${n}" branch ${s}`,t)}return js(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 js(e,`Computed variable "${n}"`,t)},Ko=(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}`)}},Cf=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}),_f=new Set(["and","or","all","any"]),$f=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),jf=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Nf=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Df=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Jo=new WeakMap,Mo=e=>e===null?"null":Array.isArray(e)?"object":typeof e,zt=(e,t,n)=>{for(let i of Object.keys(e))if(!t.has(i))throw new Error(`${n} contains unsupported property "${i}"`)},Tf=(e,t,n,i)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${i} expected type ${t}, got ${n}`)},Qo=(e,{variableId:t,variableConfigs:n,dependencies:i,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,o,...l]=Go(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(!U(n,o))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${o}"`);let c=n[o];return Ne(c)&&i.add(o),l.length===0?c?.type:void 0},Zo=(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 Mo(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 Qo(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 Mo(o)}let l=Cf[s];if(l===void 0&&!_f.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?Ls(s,o):Wo(s,o,l);let c=o.map((u,p)=>Zo(u,{variableId:t,variableConfigs:n,dependencies:i,path:`${a}.${s}[${p}]`}));if(jf.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),$f.has(s))return"number";if(Nf.has(s))return"boolean"},Lf=(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{ke(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"||U(s,"literal"))return;if(U(s,"var")){Qo(s.var,{variableId:t,variableConfigs:n,dependencies:i,path:o});return}if(U(s,"call"))throw new Error(`Computed variable "${t}" ${o} function calls are not supported`);if(U(s,"not")){r(s.not,`${o}.not`);return}let l=Object.keys(s).find(c=>Df.has(c));s[l].forEach((c,u)=>{r(c,`${o}.${l}[${u}]`)})};r(e,a)},Ns=(e,{variableId:t,variableConfig:n,variableConfigs:i,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(Ho(e,`Computed variable "${t}" ${r}`),zt(e,s,r),U(e,"value")){Ko(t,n.type,e.value);return}let o=Zo(e.expr,{variableId:t,variableConfigs:i,dependencies:a,path:`${r}.expr`});Tf(t,n.type,o,`${r}.expr`)},Mf=(e,t,n)=>{let i=t.computed;if(!pe(i))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=U(i,"expr"),s=U(i,"value");if(U(i,"branches")){if(zt(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(!pe(i.default))throw new Error(`Computed variable "${e}" requires default`);return i.branches.forEach((l,c)=>{if(!pe(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(zt(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!U(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Lf(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Ns(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Ns(i.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(zt(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 Ns(i,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},gr=(e={})=>{if(!pe(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 t=new Map;Object.entries(e).forEach(([r,s])=>{if(Ne(s)){if(!pe(s))throw new Error(`Computed variable "${r}" must be an object`);if(!U(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!U(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(U(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(ut(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,Mf(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 Jo.set(e,a),a},ct=({variables:e={},runtime:t={},variableConfigs:n={},eager:i=!0}={})=>{let{evaluationOrder:a}=Jo.get(n)??gr(n),r=Tr(e,n),s=Object.entries(n).filter(([,g])=>Ne(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(U(o,g))return o[g];let h=n[g];if(!Ne(h))return U(r,g)?r[g]:void 0;let w=l.indexOf(g);if(w>=0){let b=[...l.slice(w),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=Rf(h.computed,y,g);return Ko(g,h.type,b),Ts(o,g,b),b}finally{l.pop()}},d=g=>{if(U(o,g))return o[g];let h=n[g];if(!Ne(h))return U(r,g)?r[g]:void 0;let w=c.get(g);if(i&&!p&&w!==void 0&&w>u){p=!0;try{for(let b=u+1;b<=w;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"&&(U(r,h)||s.includes(h)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(g,h)=>{if(!(typeof h!="string"||!U(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},qf=({variables:e={},runtime:t={},variableConfigs:n,projectData:i}={})=>{let a=n??i?.resources?.variables??{};return gr(a),ct({variables:e,runtime:t,variableConfigs:a,eager:!0})},Kt=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([i,a])=>{if(Ne(a))return;let r=yf(a,i);a.scope==="context"?Ts(t,i,r):Ts(n,i,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},ut=(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(", ")}`)},Jt=(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(", ")}`)},Vf=2,qo=12,ea=(e=Vf)=>{if(!Number.isInteger(e)||e<0||e>qo)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${qo}.`);return e},Ff=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},Gt=e=>typeof e=="number"&&Number.isFinite(e),Fs=(e,t,n,i,a={})=>{if(e==="number"){if(t==="set"&&!Gt(n))throw new Error(`Operation "set" requires value to be a number for variable "${i}".`);if(t==="multiply"&&!Gt(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${i}".`);if(t==="divide"&&!Gt(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}".`);ea(a.roundTo)}}},Qt=(e,t,n,i={})=>{let a=(s,o,l)=>{let c=s??o;if(!Gt(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 Ff(a(e,0,"current value")/r(n),ea(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 Us=(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:mf[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])},Uf=(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},st=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Bf=(e,t)=>{let n=e?.character?.sprite,i=t?.character?.sprite,a=st(n)?n:void 0,r=st(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},Vo=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},Fo=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Uo=(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,Yf=(e,t)=>{let n={},i=Uo(Vo(e),Vo(t)),a=Uo(Fo(e),Fo(t));return i&&(n.resource=i),a&&(n.color=a),Object.keys(n).length>0?n:null},Bs=(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=Yf(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=Uf(e.dialogue,t.dialogue);s&&(n.dialogue=s);let o=Bf(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},Ys=(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},zf=(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},Gf=(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=zf(t,n);if(i===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "_event".`);return i},Xf={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"])},Wf=(e,t)=>{let n=e[e.length-1];return n?Xf[n]?.has(t)===!0:!1},qs=(e,t,n=[])=>Array.isArray(e)?e.map(i=>qs(i,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([i,a])=>[i,Wf(n,i)?a:qs(a,t,[...n,i])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Gf(e,t._event):yr(e,t):e,zs=(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 qs(e,t)};var re=e=>structuredClone(ye(e)?er(e):e),H=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),ra=e=>e?.animations?.playback?.continuity==="persistent",W=(e,t)=>H(e??{},t)&&e[t]!==void 0,pt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:re(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Hf=e=>W(e,"opacity")||W(e,"blur"),aa=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],la=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Gs=["animationName","animationSpeed","loop"],Kf=e=>aa.some(t=>W(e,t)),ca=e=>e?.text&&W(e.text,"content")&&W(e.text,"textStyleId"),ua=e=>W(e,"text"),Jf=(e,t)=>e.resourceId?!0:ca(e)?!t?.text:!1,Qf=(e,t)=>{let n={...re(e),...t};return t.text&&e.text&&(n.text={...re(e.text),...re(t.text)}),n},Zf=(e,t)=>{if(ua(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!ca(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},ta=e=>la.some(t=>W(e,t)),na=e=>Gs.some(t=>W(e,t)),ed=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let i of la)!n&&!W(e,i)&&W(t,i)&&(e[i]=t[i]),H(e,i)&&e[i]===void 0&&delete e[i];return e},pa=(e,t,n)=>{let i=e[n];return i?.id===t?.id?i:e.find(a=>a.id===t?.id)},rd=(e,t)=>{if(!t)return e;for(let n of aa)!W(e,n)&&W(t,n)&&(e[n]=t[n]),H(e,n)&&e[n]===void 0&&delete e[n];return e},td=(e,t)=>(t&&(!W(e,"opacity")&&W(t,"opacity")&&(e.opacity=t.opacity),!W(e,"blur")&&W(t,"blur")&&(e.blur=re(t.blur)),H(e,"opacity")&&e.opacity===void 0&&delete e.opacity,H(e,"blur")&&e.blur===void 0&&delete e.blur),e),fa=(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=pa(n,s,o),c=t(s,l),u=Hf(s),p=Kf(s),m=i(s),d=H(s,"animations"),f=re(s);return!c&&(u||p||m)&&l&&(f=a?a(l,f):{...re(l),...f},d||delete f.animations),td(rd(f,l),l)}).filter(s=>t(s)||s.animations);return{hasValidItems:r.length>0,processedItems:r}},nd=e=>{if(e){if(e.character&&H(e.character,"name"))return e.character.name;if(H(e,"characterName"))return e.characterName}},da=e=>!!e?.character&&H(e.character,"sprite"),sd=e=>{let t={},n=!1,i=nd(e);return i!==void 0&&(t.name=i,n=!0),da(e)&&(t.sprite=re(e.character.sprite),n=!0),n?t:void 0},sa=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},ia=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>H(t,"persistSprite")?t.persistSprite===!0:H(e,"persistSprite")?e.persistSprite===!0:n&&!H(t,"characterId"),oa=({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 H(c,"name")?o.name=c.name:(i&&!n||u)&&H(l,"name")&&(o.name=re(l.name)),H(c,"sprite")?o.sprite=re(c.sprite):(a||p)&&H(l,"sprite")&&(o.sprite=re(l.sprite)),Object.keys(o).length>0?o:void 0},id=({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=>re(a)):delete e.initialRevealedContent,e.content=[...i,...t]},od=()=>({}),ad=(e,t)=>{if(!t.screen)return;let n=W(t.screen,"opacity"),i=W(t.screen,"blur"),a=H(t.screen,"animations");if(!n&&!i){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=t.screen.opacity:W(r,"opacity")&&(s.opacity=r.opacity),i?s.blur=re(t.screen.blur):W(r,"blur")&&(s.blur=re(r.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},ld=(e,t)=>{if(t.background){let n=W(t.background,"resourceId"),i=W(t.background,"colorId"),a=W(t.background,"opacity"),r=W(t.background,"blur"),s=W(t.background,"transformId"),o=ta(t.background),l=na(t.background),{animationsOnly:c,state:u}=pt(t.background,d=>W(d,"resourceId")||W(d,"colorId")||W(d,"opacity")||W(d,"blur")||W(d,"transformId")||ta(d)||na(d));if(c){e.background=e.background?{...re(e.background),...u}:u;return}if(!n&&!i&&!a&&!r&&!s&&!o&&!l){delete e.background;return}let p=e.background,m=re(t.background);if(!n&&p?.resourceId){m.resourceId=p.resourceId,!H(m,"transformId")&&p.transformId&&(m.transformId=p.transformId);for(let d of Gs)!W(m,d)&&W(p,d)&&(m[d]=p[d])}ed(m,p,{hasAuthoredTransformId:s}),!i&&p?.colorId&&(m.colorId=p.colorId),!a&&W(p,"opacity")&&(m.opacity=p.opacity),!r&&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 Gs)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")&&ra(p)&&(m.animations=re(p.animations)),e.background=m}else e.background?.animations&&!ra(e.background)&&(e.background.animations={})},cd=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(sa(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=ia({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=oa({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}=pt(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&&id({dialogueState:e.dialogue,content:t.dialogue.content,append:i}),H(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=H(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=ia({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});H(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=H(t.dialogue,"characterId"),o=sd(t.dialogue),l=da(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!i&&delete e.dialogue.characterId;let c=oa({previousCharacter:e.dialogue.character,characterFields:o,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:H(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:i});if(c?e.dialogue.character=c:delete e.dialogue.character,l||sa(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=re(e.dialogue.character)),e.dialogue.lines.push(u)}},ud=(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=re(t.sfx)}else e.sfx&&delete e.sfx},pd=(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=re(t.bgm),t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},fd=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{Zf(r,pa(n,r,s))});let{hasValidItems:i,processedItems:a}=fa(t.visual.items,Jf,n,{hasPatchFn:ua,mergeItemFn:Qf});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))},dd=(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}=fa(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},md=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},yd=(e,t)=>{if(t.layout){let{animationsOnly:n,state:i}=pt(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},hd=(e,t)=>{if(t.choice){let{animationsOnly:n,state:i}=pt(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},gd=(e,t)=>{if(t.form){let{animationsOnly:n,state:i}=pt(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...i};return}if(!t.form.resourceId){delete e.form;return}e.form=re(t.form)}else e.form&&delete e.form},bd=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},wd=(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=re(t.voice)}else e.voice&&delete e.voice},Id=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},br=e=>Wt(od,[Id,ad,ld,ud,pd,fd,cd,dd,md,yd,hd,gd,bd,wd])(e);var Lr=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=yr(e,t);return n&&typeof n=="object"?e:n};var vd=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"}}),wr=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}),ft=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),ma=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"}),Xs=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Ws=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Ad=(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]}},Ir=e=>Object.fromEntries(Object.entries(vd).map(([t,n])=>{let i=Ad(e,n.source),a=i!==void 0?i:wr[t]??ft[t];return[t,a]})),ir=(e,t)=>Ir(e)[t],ya=(e={})=>Object.fromEntries(Xs.map(t=>[t,e[t]??wr[t]]));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}),Hs=Xe.BEHIND_DIALOGUE,Ks=Object.freeze(Object.values(Xe).sort((e,t)=>e-t));var kd={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:Us},Pd=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,dt=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return dt(t);let[n]=Object.keys(t),i=Pd.exec(n);if(!i)return dt(t);let[,a,r,s]=i,o=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[o]:dt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,dt(n)])),He=(e,t)=>{let n={functions:kd};return yr(dt(e),t,n)},di=({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".`)},xd=({id:e,targetId:t,animation:n,playback:i,animationPath:a="animation"})=>{let r=structuredClone(n);if(di({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,i!==void 0){let s=Rd(i,`${a}.playback`);if(s!==void 0){let o=s.loop===!0?_a(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},Ed=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return di({animationType:e.type,animationId:t,animationPath:n}),e.type},Sd=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Od=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Rd=(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},Cd=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},vr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Oa=e=>e?.playback?.continuity==="persistent",si=e=>Array.isArray(e)?e.map(si):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=si(e[n]),t),{}),tn=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(si(t))},Ra=(e=[])=>e.filter(t=>Oa(t)).map(t=>structuredClone(t)),Ca=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,Js=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,Ca(n)),0),_a=e=>Math.max(Js(e?.tween),Js(e?.prev?.tween),Js(e?.next?.tween),Ca(e?.mask?.progress)),$a=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:_a(e)/Cd(e),_d=e=>e.some(t=>t?.playback?.loop===!0),ha=({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(tn).filter(Boolean));return e.some(i=>{if(!Oa(i))return!1;let a=tn(i);return a?n.has(a):!1})},qe=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:_d(e)||r&&!t||ha({animationInstances:e,activePersistentAnimations:i})?!0:r?!1:ha({animationInstances:e,activePersistentAnimations:a}),$d=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),jd=(e,t)=>{if($d(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Nd=({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?xd({id:i,targetId:a,animation:s,playback:n,animationPath:r}):null},Dd=(e,{defaultTargetId:t,defaultId:n,animationPath:i="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return di({animationType:a.type,animationId:a.id??n,animationPath:i}),a.id??=n,a.targetId??=t,a},mi=({animations:e,transitions:t,defaultTargetId:n,idPrefix:i,animationPathPrefix:a=i})=>{t.forEach((r,s)=>{e.push(Dd(r,{defaultTargetId:n,defaultId:`${i}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},ii=(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},Td=({content:e,path:t,variables:n})=>ii(e,t).reduce((i,a)=>{let r=Lr(a.text,{variables:n});return i+`${r??""}`.length},0),ga=(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))},Zt=(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("-")}`},mt=(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},Ld=(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},Md=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],qd=(e={})=>Md.some(t=>vr(e,t)),ja=(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"}},rn=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Vd=(e={})=>e.textStyles||{},Fd=(e={})=>e.images||{},Ud=.5,Bd=(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]},Na=({id:e,resourceId:t,spritesheet:n,animationName:i,animationSpeed:a,loop:r,transform:s={}}={})=>{let o=Bd(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??Ud,loop:r??l.loop??!0}}},Da=({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 Na({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}`)},Yd=(e={})=>e.colors||{},zd=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,ht=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,Fr=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},Qs=(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},Zs=(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},on=(e,t)=>{if(typeof e!="string"||!zd.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},ba=(e,t,n)=>{let i=on(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})`},Gd=(e={},t)=>{let n=Vd(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=Qs(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:ba(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=Qs(n.strokeAlpha,"strokeAlpha",t);o.strokeColor=ba(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:on(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:Qs(n.shadow.alpha,"shadow.alpha",t),blur:Zs(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:Zs(n.shadow.offsetX,"offsetX",t,2),offsetY:Zs(n.shadow.offsetY,"offsetY",t,2)}}return o},oi=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>oi(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]=oi(r,t,ht(n,a)));return e.textStyleId!==void 0&&(Fr(e.textStyleId,n,"textStyleId"),i.textStyle=Gd(t,e.textStyleId)),i},yi=(e={},t)=>{let n=Yd(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return on(n.hex,`Color "${t}"`)},Ta=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",ei=(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 ${Ta(`${t}.fill`)} instead`)},Xd=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>gt(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]=gt(r,t,ht(n,a)));return e.colorId!==void 0&&(Fr(e.colorId,n,"colorId"),i.fill=yi(t,e.colorId)),i},gt=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>gt(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 ${Ta("fill")} instead`);ei(e,"hover",n),ei(e,"click",n),ei(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]=Xd(r,t,ht(n,a));continue}i[a]=gt(r,t,ht(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(Fr(e.colorId,n,"colorId"),i.fill=yi(t,e.colorId)),i},ri=(e={},t)=>{let n=Fd(e)?.[t];return n||null},La=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",wa=(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 ${La(`${t}.${i}`)} instead`)},Ia=(e,t,n)=>{let i=e[t];e[t]={...i&&typeof i=="object"&&!Array.isArray(i)?i:{},src:n}},ai=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>ai(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 ${La(a)} instead`);wa(e,"hover",n,"src"),wa(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]=ai(r,t,ht(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){Fr(e.imageId,n,"imageId");let a=ri(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&&(Fr(e.hoverImageId,n,"hoverImageId"),Ia(i,"hover",ri(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Fr(e.clickImageId,n,"clickImageId"),Ia(i,"click",ri(t,e.clickImageId)?.fileId??e.clickImageId)),i},hi=(e,t={},n="root")=>ai(gt(oi(e,t,n),t,n),t,n),Ke=hi,Ar=(e=[])=>e.find(t=>t.id==="story"),Wd="#000000",li="bg-cg-background-color",Hd=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?on(n?.backgroundColor??Wd,"screen.backgroundColor"):yi(e,t.colorId),Ma=(e={})=>{if(vr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},Kd=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},va=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Ma(e),i=Kd(e),a={};return(t||n!==void 0)&&(a.alpha=n??1),i&&(a.blur=i),a},Jd=(e={})=>{if(vr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},Qd=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},qa=(e={})=>{let t=Jd(e),n=Qd(e),i={};return t!==void 0&&(i.alpha=t),n&&(i.blur=n),i},Vr=(e={})=>qa(e),We=(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},Zd=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],gi=(e={})=>e.text&&vr(e.text,"content")&&vr(e.text,"textStyleId"),Aa=(e={})=>{if(e.resourceId)return e.resourceId;if(gi(e))return"text"},ka=(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,em=({item:e,particle:t,resources:n})=>{let i=mt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=ka(r,n)),a.texture!==void 0&&(a.texture=ka(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(i,e)};return Object.assign(s,Vr(e)),s},rm=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!gi(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let t of Zd)if(vr(e.text,t))throw new Error(`Visual item "${e.id}" text.${t} is reserved for the visual item`)}},tm=({resources:e,background:t,screen:n={width:1920,height:1080},includeOpacity:i=!1})=>{let a={id:li,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Hd({resources:e,background:t,screen:n})};if(i){let r=Ma(t);r!==void 0&&(a.alpha=r)}return a},nm=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Pa=({resources:e={},resourceId:t,colorId:n})=>{let i=ja(e,t);return t&&(i||n===void 0)?{resourceId:t,targetId:rn({resourceId:t,kind:i})}:n!==void 0?{resourceId:li,targetId:li}:{resourceId:void 0,targetId:void 0}},Va=100,or=Va,sm="channel:bgm",im="channel:music-room",om="music-room:player",am="channel:voice",lm="default",cm=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),yt=(...e)=>e.map(cm).join(":"),nn=(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)})},um=(e,t)=>e*t/Va,Fa=(e={},t)=>e?.[t]??wr[t],an=(e={},t,n=or)=>um(n,Fa(e,t)),ln=({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},en=(e,t,n,i)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:i,pm=["muted","pan","playbackRate","startAt","endAt"],cn=({id:e,sound:t,resource:n,defaultLoop:i=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:en(t,n,"loop",i),volume:en(t,n,"volume",or),startDelayMs:en(t,n,"startDelayMs",0)};pm.forEach(s=>{let o=en(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},De=({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: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??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},k=hm({dialogueState:s,includeInactiveAdvDialogue:o,characters:h,variables:e,runtime:v}),x={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&&(x.dialogue=k,x.dialogueLines=k.lines),x},xa=100,sn=(e,t)=>{if(Array.isArray(e))return e.map(i=>sn(i,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(i=>{n[i]=sn(n[i],t)}),n.type==="text-revealing"?t(n):n},fm=e=>sn(e,t=>({...t,revealEffect:"none"})),dm=e=>sn(e,t=>{let n=Number(t.speed??t.displaySpeed),i=Number.isFinite(n)?Math.max(n,xa):xa;return{...t,speed:i,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:i}:{}}}),ar=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:i=!1}={})=>t||i?fm(e):n?dm(e):e,Ua=({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:{}}}}),ci=e=>{if(Array.isArray(e))return e.map(ci);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=ci(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}}:{}}}}},mm=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Ea="submit",ti=(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}}},ui=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>ui(c,t,n));if(!e||typeof e!="object")return e;let i=typeof e.type=="string",a=i&&e.formRole===Ea,r=i&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},o={};for(let[c,u]of Object.entries(e))o[c]=ui(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:ti(l.change,u),submit:ti(l.submit,t.submitActions)}}}return l.formRole===Ea||r?{...l,click:ti(l.click,t.submitActions,{replaceActions:!0})}:l},pi=(e,t)=>{if(Array.isArray(e))return e.map(i=>pi(i,t));if(!e||typeof e!="object")return e;let n={};for(let[i,a]of Object.entries(e))n[i]=pi(a,t);for(let i of mm){let a=n[i]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[i]={...n[i],payload:{...a,_interactionSource:"form"}})}return n},fi=({characterId:e,character:t,characterName:n,characters:i={},variables:a={}}={})=>{let r=e?i?.[e]:void 0,s=Ht({characterId:e,character:t,characterName:n,characters:i,variables:a});return{...r||{},...t||{},name:s}},Ba=(e=[],t={},n={})=>e.map(i=>{let a=fi({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}}),ym=e=>!(!e||e.mode==="adv"&&e.content===void 0),hm=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:i,runtime:a}={})=>{if(!t&&!ym(e))return;let r=e.content===void 0?[{text:""}]:ii(e.content,"dialogue.content"),s=e.content===void 0?0:Td({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:i}),o=a?.dialogueTextSpeed??wr.dialogueTextSpeed,l=e.textSpeed??o,c=(e.lines||[]).map((p,m)=>{let d=ii(p.content,`dialogue.lines[${m}].content`),f=fi({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:Lr(y.text,{variables:i})})),character:f,characterName:f.name}}),u=fi({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:Lr(p.text,{variables:i})})),initialRevealedCharacters:s,lines:c}},Ya=({container:e,resources:t,templateData:n,isLineCompleted:i=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=He(e,n);return Ke(ar(s,{isLineCompleted:i,skipMode:a,skipTransitionsAndAnimations:r}),t)},ni=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),Sa=({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:ni(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[i].keyup={payload:ni(a.keyup)});return}e[i]={...r,[n]:{payload:ni(a)}}})},gm=(e={},t={})=>{let n={};return Sa({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Sa({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},Je=({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:w})=>{let b=Nd({resources:t,animationId:d,playback:f,instanceId:h,targetId:w,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=i!=null&&i!==!1,m=a&&r&&a===r;jd(e,s);let d=Sd(e),f=Od(e),y=t?.animations?.[d],g=Ed(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`,w=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:w,targetId:r})}return l},bm=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),wm=(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:w,canRollback:b,form:E,saveSlots:v=[]})=>{let{elements:k,animations:x}=e;if(t.background){let C=i===void 0?!0:vr(i?.background??{},"animations"),N=k.find(ce=>ce.id==="story");if(!N)return e;let P=Ld(a,t.background),T=P||qd(t.background),q=n?.background?.resourceId,ae=n?.background?.colorId,B=t.background.resourceId??(t.background.animations?q:void 0),ne=t.background.colorId??(t.background.animations?ae:void 0),ie=nm(a,B),fe={...t.background,colorId:ne};if((ne!==void 0||ie)&&N.children.push(tm({resources:a,background:fe,screen:r,includeOpacity:!ie})),B){let{images:ce={},videos:oe={},spritesheets:R={}}=a,j=ja(a,B),M;if(j==="sprite"?M=ce[B]:j==="video"?M=oe[B]:j==="spritesheet-animation"&&(M=R[B]),M){let Z=j==="video",ge=j==="spritesheet-animation",K={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...P},xe={...va(t.background,{includeDefaultAlpha:!0}),...We(K,t.background)},me;ge?me=Na({id:rn({resourceId:B,kind:j}),resourceId:B,spritesheet:M,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:xe}):me={id:rn({resourceId:B,kind:j}),type:Z?"video":"sprite",src:M.fileId,width:M.width,height:M.height,...xe},Z&&(me.loop=t.background.loop??!1,me.volume=M.volume??50),me&&N.children.push(me)}}if(B){let{layouts:ce={}}=a,oe=ce[B];if(oe){let R={id:rn({resourceId:B,kind:"container"}),type:"container",children:oe.elements,...va(t.background)};T&&Object.assign(R,We({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...P},t.background));let j=He(R,De({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:v,dialogueState:t.dialogue,isLineCompleted:s,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,characters:a.characters||{},skipTransitionsAndAnimations:o}));N.children.push(Ke(ar(j,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:o}),a))}}let ve=Pa({resources:a,resourceId:q,colorId:ae}),le=Pa({resources:a,resourceId:B,colorId:ne}),se=Je({animationsDef:t.background.animations,resources:a,previousResourceId:ve.resourceId,currentResourceId:le.resourceId,previousTargetId:ve.targetId,currentTargetId:le.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});qe({animationInstances:se,isLineCompleted:s,skipTransitionsAndAnimations:o,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:C})&&x.push(...se)}return e},Im=(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=ga(u),d=ga(p);for(let f=0;f<u.length;f++){let y=u[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?Zt(w,b,d):void 0,x=Je({animationsDef:y.animations,resources:i,previousResourceId:k,currentResourceId:v?Zt(y,f,m):void 0,previousTargetId:k,currentTargetId:v?Zt(y,f,m):void 0,animationPath:`character.items[${f}].animations`,idPrefix:"character"});if(y.animations&&!h&&!g&&E&&qe({animationInstances:x,isLineCompleted:a,skipTransitionsAndAnimations:r,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=Zt(y,f,m),N=i.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=Da({id:`${C}-${T.id}`,item:T,resources:i});q&&P.children.push(q)}c.children.push(P),qe({animationInstances:x,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&l.push(...x)}}return e},za=(e,t)=>{if(!Ks.includes(e))throw new Error(`${t} must be one of: ${Ks.join(", ")}.`)},vm=(e,t)=>{let n=!!e.resourceId||gi(e),i=e.layer??(n?void 0:t?.layer)??Hs;return za(i,`Visual item "${e.id}" layer`),i},Am=(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:w=[],visualLayer:b})=>{let{elements:E,animations:v}=e;if(t.visual&&i){let k=E.find(P=>P.id==="story");if(!k)return e;let x=t.visual.items,C=n?.visual?.items||[],N=De({variables:s,imageGallery:o,musicRoom:l,sceneReplay:c,runtime:u,saveSlots:w,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&&za(b,"visualLayer");for(let P of x){let T=C.find(ie=>ie.id===P.id),q=vm(P,T);if(b!==void 0&&q!==b)continue;if(rm(P),P.text){let ie=mt(i,P),fe={...structuredClone(P.text),id:`visual-${P.id}`,type:"text",...We(ie,P)};Object.assign(fe,Vr(P)),k.children.push(Ke(He(fe,N),i))}if(P.resourceId){let{images:ie={},videos:fe={},spritesheets:ve={}}=i,le=ve[P.resourceId];if(le){let se=mt(i,P),ce=P.animationName;if(ce){let oe=le.animations?.[ce];if(!oe)throw new Error(`Animation '${ce}' not found in spritesheet resource '${P.resourceId}'`);let R=Vr(P),j={id:`visual-${P.id}`,type:"spritesheet-animation",...We(se,P),width:P.width??le.width,height:P.height??le.height,alpha:R.alpha??P.alpha??1,src:le.fileId,atlas:le.jsonData,playback:{frames:oe.frames,animationSpeed:P.animationSpeed??oe.animationSpeed??.5,loop:P.loop??oe.loop??!0}};R.blur&&(j.blur=R.blur),k.children.push(structuredClone(j))}}else{let se=ie[P.resourceId]||fe[P.resourceId];if(se){let ce=fe[P.resourceId]!==void 0,oe=mt(i,P),R={id:`visual-${P.id}`,type:ce?"video":"sprite",src:se.fileId,width:se.width,height:se.height,...We(oe,P)};Object.assign(R,Vr(P)),ce&&(R.loop=se.loop??!1,R.volume=se.volume??50),k.children.push(R)}}}if(P.resourceId){let ie=i.particles?.[P.resourceId];ie&&k.children.push(em({item:P,particle:ie,resources:i}))}if(P.resourceId){let{layouts:ie={}}=i,fe=ie[P.resourceId];if(fe){let ve=mt(i,P),le={id:`visual-${P.id}`,type:"container",children:structuredClone(fe.elements),...We(ve,P)};Object.assign(le,Vr(P));let se=He(le,N);k.children.push(Ke(ar(se,{isLineCompleted:a,skipMode:d,skipTransitionsAndAnimations:r}),i))}}let ae=Aa(T),B=Aa(P),ne=Je({animationsDef:P.animations,resources:i,previousResourceId:ae,currentResourceId:B,previousTargetId:ae?`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:r,activePersistentAnimations:p})&&v.push(...ne)}}return e},qr="dialogue-character-sprite",km=(e,{presentationState:t,previousPresentationState:n,resources:i={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:o}=e,l=Ar(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=st(c),m=st(u),d=Je({animationsDef:c?.animations,resources:i,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 c?.animations&&m&&qe({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:qr,...We(f),children:[]};for(let g of c.items){let h=Da({id:`${qr}-${g.id}`,item:g,resources:i});h&&y.children.push(h)}return l.children.push(y),qe({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...d),e},Pm=(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:w,activePersistentAnimations:b,saveSlots:E=[]})=>{let{elements:v,animations:k}=e;if(!t.dialogue||a)return e;let x=v.find(N=>N.id==="story");if(!x)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:N={}}=i,P=N[t.dialogue.ui.resourceId];if(P){let T={elements:P.elements},q=De({variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,saveSlots:E,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=He(T,q),B=Ke(ar(ae?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),i);if(Array.isArray(B))for(let ne of B)x.children.push(ne);else B&&x.children.push(B)}}km(e,{presentationState:t,previousPresentationState:n,resources:i,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let C=Je({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 qe({animationInstances:C,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&k.push(...C),e},xm=(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:w,saveSlots:b=[]})=>{let{elements:E,animations:v}=e;if(t.choice&&i){let k=Ar(E);if(!k)return e;let x=i?.layouts[t.choice.resourceId];if(x&&x.elements){let N={elements:x.elements},P=He(N,{...De({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=ci(Ke(ar(P?.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 C=Je({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"});qe({animationInstances:C,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&v.push(...C)}return e},Em=(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:w=[],form:b})=>{let{elements:E,animations:v}=e;if(!b?.resourceId||!i)return e;let k=Ar(E);if(!k)return e;let x=i?.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={...De({variables:o,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,characters:i.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},P=He(C,N),T=pi(Ke(ar(ui(P,b),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),i),b);T&&k.children.push(T);let q=Je({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 qe({animationInstances:q,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&v.push(...q),e},Sm=(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 w=gm(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-${t.control.resourceId}`,type:"container",x:0,y:0,children:h.elements};return b.children.push(Ya({container:E,resources:n,templateData:De({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},Om=(e,{presentationState:t,resources:n,runtime:i,variables:a,musicRoomPlayer:r})=>{let{elements:s,audio:o}=e;if(t.bgm&&n){if(!Ar(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||nn(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(cn({id:yt("bgm",u?"default":y.id),sound:h,resource:g,defaultLoop:!m}))}),d.length===0)return e;let f=De({variables:a,runtime:i}).runtime;o.push(ln({id:sm,volume:an(f,"musicVolume",u?or:c.volume??or),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,playback:r?.bgmPlayback,interruption:c.interruption,children:d,runtime:f}))}return e},Rm=(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=De({variables:i,runtime:n}).runtime,c=cn({id:om,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:o});return e.audio.push(ln({id:im,volume:an(l,"musicVolume",or),children:[c],runtime:l})),e},Cm=(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:lm,sounds:r.items??[]}]:r.channels;s||nn(o,"SFX channel"),o.forEach(l=>{let c=!s&&l.loop===!0,u=[];if(s||nn(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(cn({id:s?yt("sfx","default",m,p.id):yt("sfx",l.id,p.id),sound:f,resource:d,defaultLoop:c?!1:void 0}))}),u.length!==0&&a.push(ln({id:yt("channel","sfx",l.id),volume:an(i,"soundVolume",l.volume??or),muted:l.muted,pan:l.pan,loop:s?void 0:l.loop,interruption:s?void 0:l.interruption,children:u,runtime:i}))})}return e},_m=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},$m=(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:or,startDelayMs:o.startDelayMs??0}]:[]:o.sounds,u=!l&&o.loop===!0,p=[];if(l||nn(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=_m(n,i,d.resourceId);if(!f)return;let y=u?{...d,loop:d.loop??!1}:d;p.push(cn({id:yt("voice",i,l?"default":d.id),sound:y,resource:f,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let m=De({variables:r,runtime:a}).runtime;return s.push(ln({id:am,volume:l?o.volume??Fa(m,"soundVolume"):an(m,"soundVolume",o.volume??or),muted:o.muted,pan:o.pan,loop:l?void 0:o.loop,interruption:o.interruption,children:p,runtime:m})),e},jm=(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:w})=>{let{elements:b,animations:E}=e;if(t.layout){let C=Ar(b);if(!C)return e;let N=i.layouts[t.layout.resourceId];if(!N)return e;Array.isArray(N.transitions)&&!g&&!h&&mi({animations:E,transitions:N.transitions,defaultTargetId:`layout-${t.layout.resourceId}`,idPrefix:`layout-${t.layout.resourceId}`,animationPathPrefix:"layout"});let P={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:N.elements||[]};C.children.push(Ya({container:P,resources:i,templateData:De({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,x=Je({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 qe({animationInstances:x,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})&&E.push(...x),e},Nm=(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=Je({animationsDef:l,resources:i,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return qe({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&o.push(...u),e},Dm=(e,{presentationState:t})=>{let n=Ar(e.elements);return!n||!t?.screen||Object.assign(n,qa(t.screen)),e},Tm=(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: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||mi({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:[Ua({id:`overlayStack-${x}-blocker`,screen:h}),...C.elements||[]]},P=Ba(y,n.characters,i),T=De({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:P,characters:n.characters||{},skipTransitionsAndAnimations:b}),q=He(N,T),[ae,...B]=q.children||[],ne=Ke(ar({...q,children:B},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);E.push({...ne,children:ae?[ae,...ne.children||[]]:ne.children})}),e},Lm=(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: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&&mi({animations:v,transitions:k.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let x={id:"confirmDialog",type:"container",x:0,y:0,children:[Ua({id:"confirmDialog-blocker",screen:h}),...k.elements||[]]},C=Ba(g,n.characters,i),N=He(x,De({variables:i,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:o,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,historyDialogue:C,characters:n.characters||{},skipTransitionsAndAnimations:b})),[P,...T]=N.children||[],q=Ke(ar({...N,children:T},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);return E.push({...q,children:P?[P,...q.children||[]]:q.children}),e},bt=e=>(t,n)=>Am(t,{...n,visualLayer:e}),Mm=bt(Xe.BEHIND_BACKGROUND),qm=bt(Xe.BEHIND_CHARACTER),Vm=bt(Xe.BEHIND_DIALOGUE),Fm=bt(Xe.BEHIND_CHOICE),Um=bt(Xe.FOREGROUND),Ga=e=>Wt(bm,[Sm,Mm,wm,qm,Im,Vm,Pm,Fm,xm,Em,jm,Um,Dm,Nm,Om,Rm,Cm,$m,Tm,Lm])(e);function Xa(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 Wa(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 Ha="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Ka="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Ja="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Qa=65535,bi=40960,un=126976,rl=new Uint8Array(12288),tl=new Uint8Array(3072),nl=new Uint8Array(2816),sl,il;{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 Xa(Ha,Ka))e(rl,0,a,r,s),e(tl,bi,a,r,s),e(nl,un,a,r,s),r>=65040&&!(a>=un&&r<=129791)&&(t[i]=a,n[i++]=r<<5|s);sl=t.slice(0,i),il=n.slice(0,i)}function Za(e){return e<12288?rl[e]:e<bi?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?tl[e-bi]: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>=un&&e<129792?nl[e-un]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Wa(e,sl,il)}var ol=Uint8Array.from(Ja,Number);function Bm(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 el(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Bm(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*al(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),i=n>Qa?2:1,a=Za(n),r=50200>>a&1?el(0,a,n):0,s=0,o=n,l=a;for(;i<t;){n=e.codePointAt(i);let c=n>Qa?2:1,u=Za(n),p=ol[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)?el(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*ll(e){for(let t of al(e))yield t.segment}{let e=al("_");ol._keep=[e,e.next()]}var cl=1e3,dl=50,Ym=0,ul=100,pl=50,zm=60,Gm=3,Xm=.5,Wm=2e4,Hm=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Km=/^\s+$/u,fl,Jm=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(ll(t)):(fl??=new n(void 0,{granularity:"grapheme"}),Array.from(fl.segment(t),({segment:i})=>i))},Qm=e=>Jm(e).reduce((t,n)=>Km.test(n)?t+Xm:Hm.test(n)?t+Gm:t+1,0),Zm=e=>2**(((Number.isFinite(e)?Math.min(ul,Math.max(Ym,e)):dl)-pl)/(ul-pl)),ml=({text:e="",baseDelay:t=cl,speed:n=dl}={})=>{let i=Number.isFinite(t)?Math.max(0,t):cl,a=Zm(n),r=Qm(e)*zm/a,s=Math.max(i,Wm);return Math.min(i+r,s)};var pn={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},vl=1,Ai=1,Br="choice",lr="form",vt=()=>({manual:{...pn.manual},auto:{...pn.auto},applyMode:pn.applyMode}),ki=()=>({groupId:null,variantId:null,pageIndex:0}),ey="music-room:player",ry=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),mn=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Pi=new Set,ty=new Set(["groupId","variantId"]),ny=new Set(["pageIndex"]),Yr=new Set,sy=new Set(["trackId"]),iy=new Set(["positionMs"]),oy=new Set(["pageIndex"]),xi=new Set,ay=new Set(["replayId"]),ly=new Set(["pageIndex"]),Ei=()=>({pageIndex:0}),Si=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...vt()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},D=e=>{let t=ye(e)?er(e):e;return structuredClone(t)},F=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),yn=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},Al=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},At=(e,t,n)=>({commandId:yn(e),operation:t,...n===void 0?{}:{positionMs:n}}),Oi=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:yn(e),operation:"resume"}),e.global.musicRoomPlayer=mn({bgmPlayback:n})},kl=(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},kt=e=>String(e),Pl=()=>({sections:[],resources:[]}),cy=e=>F(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Pl(),uy=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",py=({sectionId:e,lineId:t,content:n,dialogueState:i,characterName:a})=>({sectionId:e,lineId:t,content:n,text:uy(n),characterId:i.characterId,character:{...i.character||{},name:a},characterName:a}),fy=()=>({resourceId:void 0}),dy=e=>{if(!F(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},Er=(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}},xl=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)}}},El=e=>{if(typeof e=="number"||typeof e!="string")return e;let t=Number(e);return Number.isFinite(t)?t:e},Sl=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==vl)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},my=(e,t={})=>{let n;try{n=Sl(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let i={...t,formatVersion:n,slotId:El(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete i.slotKey,delete i.date,i},yy=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,my(t,n)])),Ol=e=>{if(!Array.isArray(e))return;let t=e.filter(({type:n})=>rb(n));return t.length>0?t:void 0},hy=e=>{!F(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=Ai,e.timeline.forEach(t=>{if(!F(t))return;typeof t.returnable!="boolean"&&delete t.returnable;let n=Ol(t.executedActions);if(n){t.executedActions=n;return}delete t.executedActions}))},yl=(e,t,n,i="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!F(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}},gy=(e,t="viewedRegistry")=>{if(e===void 0)return Pl();if(!F(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=yl(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(i.map((a,r)=>{let s=yl(a,"resources",r,t);return[s.resourceId,s]})))}},Rl=(e,t,n)=>{if(!F(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}=Er(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}},Cl=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,by=(e,t)=>{let{section:n}=Er(e,t?.sectionId);return n?.lines?.find(i=>i.id===t?.lineId)},wy=(e,t)=>{let{section:n}=Er(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},_l=(e,t,n)=>{if(typeof t?.sectionId!="string")return!1;let{section:i}=Er(e,t.sectionId);return Cl({sectionId:t.sectionId,lineId:i?.lines?.[0]?.id},n)},Iy=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),Ur={always:"always",maybe:"maybe",never:"never"},vy=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return Ur.always;let t=e.when,n;if(t===null||typeof t=="boolean"||typeof t=="number")n=t;else if(F(t)&&Object.keys(t).length===1&&Object.prototype.hasOwnProperty.call(t,"literal"))n=t.literal;else return Ur.maybe;return n?Ur.always:Ur.never},$l=(e,t)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let i=vy(n);if(i!==Ur.never){if(t(n))return!0;if(i===Ur.always)return!1}}return!1},jl=e=>$l(e,t=>Object.entries(t?.actions??{}).some(([n,i])=>n==="conditional"?jl(i):Iy.has(n))),Nl=(e,t,n)=>$l(t,i=>Object.entries(i?.actions??{}).some(([a,r])=>a==="sectionTransition"?_l(e,r,n):a==="conditional"?Nl(e,r,n):!1)),Ay=(e,t,n)=>{if(!t)return!0;let i=by(n,e)?.actions;if(!F(i))return!0;if(_l(n,i.sectionTransition,t))return!1;let a=i.conditional;return a?!(Nl(n,a,t)||!(i.choice?.resourceId||i.form?.resourceId)&&!jl(a)&&Cl(wy(n,e),t)):!0},ky=(e,t,n)=>{if(!F(e)||!Array.isArray(e.timeline))return It({pointer:t,replayStartIndex:1});let i=new WeakSet,a=e.timeline.flatMap((c,u)=>{if(!F(c))return[];try{let p=Rl(c,n,`rollback.timeline[${u}]`),m=dn({sectionId:p.sectionId,lineId:p.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable});typeof c.returnable=="boolean"&&i.add(m);let d=Ol(D(c.executedActions));return d&&(m.executedActions=d),[m]}catch{return[]}});if(a.length===0)return It({pointer:t,replayStartIndex:1});e.returnabilityVersion!==Ai&&a.forEach((c,u)=>{!i.has(c)&&!Ay(c,a[u+1],n)&&(c.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 o=a[s];if(o?.sectionId!==t.sectionId||o?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?s=c:(a.push(dn({sectionId:t.sectionId,lineId:t.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}},Py=(e,t,n)=>{if(!F(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let i=_i(t),a=Rl(e.pointers?.read,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!F(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!F(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Tr(D(e.variables),t.resources?.variables??{}):{},s=Ly({loadedContextRuntime:F(e.runtime)?D(e.runtime):{}}),o={currentPointerMode:"read",pointers:{read:a},configuration:F(e.configuration)?D(e.configuration):{},views:Array.isArray(e.views)?D(e.views):[],bgm:F(e.bgm)?D(e.bgm):{resourceId:void 0},variables:{...i,...r},rollback:ky(e.rollback,a,t)};return s&&(o.runtime=s),o},xy=(e,t)=>{if(!F(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)=>Py(n,t,i))}},Ey=(e,t)=>{if(!F(e))throw new Error("Malformed save slot.");let n=Sl(e.formatVersion);return{...e,formatVersion:n,state:xy(e.state,t)}},hl=(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}},Sy=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:hl(e.confirmActions,"confirmActions",{required:!0}),cancelActions:hl(e.cancelActions,"cancelActions")}},zr=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Oy=e=>(F(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Gr=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Dl=e=>{if(!(!F(e)||!e.animations))return{animations:D(e.animations)}},Ry=(e,t)=>{let n=Dl(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Cy=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},_y=(e,t)=>{let n=e?.sectionId,i=e?.lineId;if(!(!n||!i||!t))return`${n}:${i}:${t}`},fn=e=>String(e??""),Tl=(e,t)=>{let n=fn(t);return e?.trim===!0?n.trim():n},$y=e=>F(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>F(t)).map(([t,n])=>[t,{id:t,...D(n)}])):{},jy=(e,t)=>{if(!t||!F(e.global.formDrafts))return;let n=e.global.formDrafts[t];return F(n)?n:void 0},Ll=(e,t)=>{let n=Oy(e);F(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let i=n[t];return F(i.values)||(i.values={}),F(i.touched)||(i.touched={}),F(i.errors)||(i.errors={}),typeof i.submitted!="boolean"&&(i.submitted=!1),i},Ri=(e,t)=>{let n=Tl(e,t);return e?.required===!0&&n.length===0?"required":null},Ny=({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?{}:br(i.slice(0,a+1).map(r=>r.actions||{}))},Dy=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let i=Cy(t),a=_y(n,i);if(!i||!a)return null;let r=jy(e,a),s=$y(t),o=hn({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=fn(o?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(r?.values??{},m)?fn(r.values[m]):f,g=r?.touched?.[m]===!0,h=Ri(d,y),w=r?.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,c.push(E),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??{})}}}},Pr=[],gl="line",Ci="interaction",dn=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:i})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof i=="boolean"?{returnable:i}:{}}),_i=e=>{let t=ye(e)?er(e):e,{contextVariableDefaultValues:n}=Kt(t??{});return D(n)},Ml=()=>({...D(ft)}),ql=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:i})=>{if(e===void 0)return{runtimeState:D(n),hasLoadedValues:!1};if(!F(e))throw new Error(`Malformed ${i}.`);let a=D(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=Ul(s,D(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Ty=({loadedGlobalRuntime:e={}})=>ql({loadedRuntime:e,runtimeIds:Xs,defaults:wr,path:"global.runtime"}).runtimeState,Ly=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=ql({loadedRuntime:e,runtimeIds:Ws,defaults:Ml(),path:"context.runtime"});return n?t:void 0},Pt=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},te=e=>{let t=Pt(e);return t?.kind==="sceneReplay"&&F(t.sceneReplay)?t:null},Vl=(e,t)=>{let n=t?.sceneReplay?.replayId,i=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.id===n);Object.entries(i?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=D(r)})},My=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)}}),qy=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=vt(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Vy=(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=Pe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Wr({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}})},Fy=e=>e.runtime?(Ws.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=D(ft[t]))}),e.runtime):(e.runtime=Ml(),e.runtime),Uy=e=>ya(e.global),Fl=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Uy(e)}})},By=e=>ma[e],Yy=(e,t)=>{let n=By(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}"`)},Ul=(e,t)=>{if(Yy(e,t),e==="autoForwardSpeed"&&(t<0||t>100))throw new Error("autoForwardSpeed requires a value between 0 and 100");return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},$i=(e,t,n)=>{let i=Ul(t,n);if(t in ft){let a=Pt(e);if(!a)return i;let r=Fy(a);return r[t]=i,i}return e.global[t]=i,i},ji=({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:fy(),variables:_i(t),rollback:It({pointer:e})}),Xr=e=>e?(e.currentPointerMode="read",F(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,zy=(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=ji({pointer:i,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Gy(e,{queueRender:t}),a},Gy=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,zr(e),Gr(e),e.global.nextLineConfig=vt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Oi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Bl=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},It=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[dn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Sr=(e,t={})=>{if(e?.rollback)return Bl(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=It({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},Ni=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let i=Sr(n);i.isRestoring||(i.currentIndex<i.timeline.length-1&&(i.timeline=i.timeline.slice(0,i.currentIndex+1)),i.timeline.push(dn(t)),i.currentIndex=i.timeline.length-1)},Xy=({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}},Wy=({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(ye(l)?vs(l):l)!==i||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},Hy=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:i,checkpointIndex:a,sectionId:r,lineId:s}=t,o=kt(n),l=e.global.saveSlots?.[o],c=ye(l)?vs(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=Ai,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Ky=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 i=Pr[Pr.length-1],a=typeof i?.checkpointIndex=="number"?i.checkpointIndex:n.currentIndex;return a<0||a>=n.timeline.length?null:(typeof i?.checkpointIndex!="number"&&a<n.timeline.length-1&&(n.timeline=n.timeline.slice(0,a+1)),n.timeline[a]??null)},Jy=({state:e},t={})=>{let n=t?.source===gl?gl:Ci,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)},Qy=({state:e})=>(Pr.pop(),e),Be=(e,t,n)=>{let a=Pr[Pr.length-1]?.source??Ci;if(!tb(t,a))return;let r=Ky(e);r&&(Array.isArray(r.executedActions)||(r.executedActions=[]),r.executedActions.push({type:t,payload:D(n)}))},bl=(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(Ne(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);ut(c,a),Jt(u,r,a),Fs(u,r,s,a,{roundTo:o}),c==="context"&&(n.variables[a]=Qt(n.variables[a],r,s,{roundTo:o}))}},Zy=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:i})=>{nb(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])=>{Ac(e,o,l)})},Yl=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let i=Sr(n),a=i.timeline[t];if(!a)return e;e.global.autoMode&&St({state:e}),e.global.skipMode&&cr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),i.isRestoring=!0,i.currentIndex=t;try{n.variables=_i(e.projectData),n.kind==="sceneReplay"&&(Vl(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(pn),e.global.overlayStack=[],zr(e),Gr(e),e.global.isLineCompleted=!0;let r=i.replayStartIndex??0;for(let o=r;o<=t;o++)o>r&&Si(e),eh(e,i.timeline[o]),Zy(e,i.timeline[o]);let s=Xr(n);s.read={sectionId:a.sectionId,lineId:a.lineId},n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Al(e)),e.global.pendingEffects=e.global.pendingEffects.filter(o=>o?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{i.isRestoring=!1}return e},rh=e=>{let{projectData:t}=e,n=e.global??{},{saveSlots:i={},variables:a={},runtime:r={},accountViewedRegistry:s={},localizationPackages:o=[{l10nId:null,language:null}]}=n;xl(t),ot(t),at(t),lt(t),gr(t?.resources?.variables??{});let l=t.story.initialSceneId,c=t.story.scenes[l],u=c.initialSectionId,p=c.sections[u],m={sceneId:l,sectionId:u,lineId:p.initialLineId??p.lines[0].id},{globalVariablesDefaultValues:d}=Kt(t),f={...d,...Tr(a,t.resources?.variables??{})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:gy(s,"accountViewedRegistry"),nextLineConfig:vt(),imageGalleryNavigation:ki(),sceneReplayNavigation:Ei(),sceneReplayEntryId:0,audioCommandId:0,musicRoomPlayer:mn(),saveSlots:yy(i),localizationPackages:D(o),overlayStack:[],variables:f,...Ty({loadedGlobalRuntime:r})},contexts:[ji({pointer:m,projectData:t})]}},th=({state:e})=>e.global.overlayStack||[],nh=({state:e})=>e.global.pendingEffects,zl=({state:e})=>e.global.skipMode,sh=({state:e})=>e.global.autoMode,Gl=({state:e})=>e.global.dialogueUIHidden,Xl=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let{sectionId:i,lineId:a}=n.pointers.read,r=we({state:e},{sectionId:i});if(!r?.lines||!Array.isArray(r.lines))return[];let s=r.lines.findIndex(p=>p.id===a),o=r.lines.slice(0,s+1),l=[],c={},u=ct({variables:{...e.global?.variables??{},...Pt(e)?.variables??{}},runtime:Ir(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});for(let p of o){let m=p.actions||{};if(c=br([c,m]),!m.dialogue)continue;let d=c.dialogue||{},f=Ht({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:u}),y=py({sectionId:i,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},ih=({state:e})=>e.global.confirmDialog??null,xt=({state:e},{pointer:t}={})=>{let n=t??Te({state:e})?.pointer,i=Ny({state:e,pointer:n});return Dy({state:e,form:i.form,pointer:n})},oh=({state:e},{pointer:t}={})=>!!xt({state:e},{pointer:t}),Pe=({state:e},{pointer:t}={})=>{let n=xt({state:e},{pointer:t});if(n)return{source:lr,formId:n.id,formKey:n.key};let i=Ql({state:e,pointer:t});return i?{source:Br,resourceId:i}:null},ah=({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},Di=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},Ti=({state:e},t)=>ah({state:e,registry:e.global.accountViewedRegistry},t),lh=({state:e},t)=>Di({registry:e.global.accountViewedRegistry},t),wt=(e,t)=>!Di({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Li=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Mi=(e,t)=>{let n=Li(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},wi=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!wt(e,t[a]))return t[a]},ch=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:D(t)},Wl=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??ki(),i=Li(t),a=Mi(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:wt(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:wt(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&&!wt(e,p)&&(o={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:wi(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:wi(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)=>!Di({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Vi=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Fi=(e,t)=>{let n=Vi(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},Ii=(e,t,n,i)=>{for(let a=n+i;a>=0&&a<t.length;a+=i)if(!qi(e,t[a]))return t[a]},Hl=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}),uh=(e,t)=>({...Hl(t),locked:qi(e,t)}),wl=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")}`},ph=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:D(t)},Kl=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??mn(),i=Vi(t),a=Fi(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>uh(e,u)),o=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[o],c=l?{...Hl(l),canPlayPreviousTrack:Ii(e,t.tracks,o,-1)!==void 0,canPlayNextTrack:Ii(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:wl(n.positionMs),durationText:n.durationMs===null?null:wl(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}}},Ui=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Bi=(e,t)=>{let n=Ui(e);if(n===0)return 0;let i=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(i,0),n-1)},fh=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:D(t)},dh=({state:e})=>te(e)!==null,mh=({state:e})=>{let t=te(e);return t?{replayId:t.sceneReplay.replayId,entryId:t.sceneReplay.entryId}:null},Jl=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??Ei(),i=Ui(t),a=Bi(t,n),r=a*t.pageSize,s=t.replays.slice(r,r+t.pageSize).map(l=>({replayId:l.id,title:l.title,thumbnailImageId:l.thumbnailImageId})),o=te(e);return{isActive:o!==null,activeReplayId:o?.sceneReplay.replayId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:i,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<i}}},yh=({state:e})=>e.global.nextLineConfig,Ql=({state:e,pointer:t}={})=>{let n=t??Te({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},Zl=({state:e})=>!!Ql({state:e}),hh=({state:e})=>structuredClone(e),gh=({state:e})=>D(e.projectData.resources?.achievements??{}),bh=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:D(n)},ec=({state:e})=>e.global.saveSlots,wh=({state:e},t)=>{let n=t?.slotId,i=kt(n);return e.global.saveSlots[i]},rc=({state:e})=>D(e.global.localizationPackages),Yi=({state:e})=>Ir(e),Ih=({state:e},t)=>ir(e,t?.runtimeId),hn=({state:e})=>{let t={...e.global?.variables??{},...Pt(e)?.variables??{}};return ct({variables:t,runtime:Ir(e),variableConfigs:e.projectData.resources?.variables??{}})},Te=({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 Er(e.projectData,n).section},gn=({state:e})=>{let t=Te({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)},tc=({state:e})=>{let{sectionId:t,lineId:n}=Te({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 br(o)},vh=e=>{let t=gn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=hn({state:e});return t.content.map(i=>`${Lr(i?.text,{variables:n})??""}`).join("")},Wr=({state:e})=>ml({text:vh(e),baseDelay:ir(e,"autoForwardDelay"),speed:ir(e,"autoForwardSpeed")}),Ah=({state:e})=>{let t=nc({state:e}),i=gn({state:e})?.actions??{},a=br([t??{},i]);return Bs(t??{},a??{})},kh=({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=br([a,s]),l=Bs(a,o);i.push({id:r.id,changes:l,presentationState:o}),a=Ys(o)}return i},Ph=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let i=kh({state:e},{sectionId:t});return n?{lines:i}:{lines:i.map(({presentationState:a,...r})=>r)}},nc=({state:e})=>{let{sectionId:t,lineId:n}=Te({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 Ys(br(o))},zi=({state:e},{slotsPerPage:t=6}={})=>{let a=((Yi({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[kt(o)]||{};r.push({...l,slotId:o})}return{saveSlots:r}},xh=ec,Eh=zi,Sh=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},Oh=({state:e},t={})=>{let n=tc({state:e}),i=nc({state:e}),a=gn({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:D(r)}:a,o=r?.animations&&i===null?{}:i,{sectionId:l}=Te({state:e}).pointer,{sceneId:c}=Er(e.projectData,l),u={...Yi({state:e}),localizationPackages:rc({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=xt({state:e}),f=Zl({state:e}),y=Wl({state:e}),g=Kl({state:e}),h=Jl({state:e}),w=hn({state:e}),{saveSlots:b}=zi({state:e}),E=Sh(e);return Ga({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:xc({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:Xl({state:e}),saveSlots:b,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:D(e.global.musicRoomPlayer)})},Rh=({state:e},t)=>(e.global.confirmDialog=Sy(t),e.global.pendingEffects.push({name:"render"}),e),Ch=({state:e})=>(e.global.confirmDialog&&(zr(e),e.global.pendingEffects.push({name:"render"})),e),_h=({state:e},t)=>(e.global.overlayStack.push(t),e.global.pendingEffects.push({name:"render"}),Be(e,"pushOverlay",t),e),$h=({state:e})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),Be(e,"popOverlay",void 0),e),jh=({state:e},t)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=t),e.global.pendingEffects.push({name:"render"}),Be(e,"replaceLastOverlay",t),e),Nh=({state:e})=>(e.global.overlayStack=[],zr(e),Gr(e),e.global.pendingEffects.push({name:"render"}),Be(e,"clearOverlays",void 0),e),Dh=(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"})},Et=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Ry(e,n),Gr(e);let i=Pe({state:e},{pointer:t}),a=i?.source===Br,r=i?.source===lr;Dh(e,{activeInteraction:i});let s=te(e),o={name:"handleLineActions"};if(typeof s?.sceneReplay?.replayId=="string"){let l=Al(e);s.sceneReplay.entryId=l,o.payload={sceneReplayId:s.sceneReplay.replayId,entryId:l}}return e.global.pendingEffects.push(o),{isChoiceVisible:a,isFormVisible:r,activeInteraction:i}},bn=(e,t,n)=>{!(t?.source===Br||t?.source===lr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},sc=({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:Wr({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),Th=({state:e})=>{let t=e.global.autoMode;return Pe({state:e})&&!t||(t?St({state:e}):sc({state:e})),e},ic=({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),cr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Lh=({state:e})=>{let t=zl({state:e});return Pe({state:e})&&!t||(t?cr({state:e}):ic({state:e})),e},wn=({state:e})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),Be(e,"showDialogueUI",void 0),e),oc=({state:e})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),Be(e,"hideDialogueUI",void 0),e),Mh=({state:e})=>(Gl({state:e})?wn({state:e}):oc({state:e}),e),ur=(e,t,n)=>($i(e,t,n),Fl(e),e.global.pendingEffects.push({name:"render"}),e),Ot=(e,t,n,i)=>{let a=$i(e,t,n);return e.global.pendingEffects.push({name:"render"}),Be(e,i,{value:a}),e},qh=({state:e},t)=>ur(e,"dialogueTextSpeed",t?.value),Vh=({state:e},t)=>ur(e,"autoForwardDelay",t?.value),Fh=({state:e},t)=>ur(e,"autoForwardSpeed",t?.value),Uh=({state:e},t)=>ur(e,"skipUnseenText",t?.value),Bh=({state:e},t)=>ur(e,"skipTransitionsAndAnimations",t?.value),Yh=({state:e},t)=>ur(e,"soundVolume",t?.value),zh=({state:e},t)=>ur(e,"musicVolume",t?.value),Gh=({state:e},t)=>ur(e,"muteAll",t?.value),Xh=({state:e},t)=>Ot(e,"saveLoadPagination",t?.value,"setSaveLoadPagination"),Wh=({state:e})=>{let t=ir(e,"saveLoadPagination")+1;return Ot(e,"saveLoadPagination",t,"incrementSaveLoadPagination"),e},Hh=({state:e})=>{let t=ir(e,"saveLoadPagination")-1;return Ot(e,"saveLoadPagination",t,"decrementSaveLoadPagination"),e},Kh=({state:e},t)=>Ot(e,"menuPage",t?.value,"setMenuPage"),Jh=({state:e},t)=>Ot(e,"menuEntryPoint",t?.value,"setMenuEntryPoint"),Qh=({state:e})=>(e.global.pendingEffects=[],e),Zh=({state:e},t)=>(e.global.pendingEffects.push(t),e),eg=({state:e},t)=>{if(te(e))return e;let n=t?.resourceId;return kl(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},rg=({state:e},t)=>{if(te(e))return e;let n=t?.resourceId,i=kl(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=!!Dl(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&&!zy(e,{queueRender:!a}))return e;let o=Pe({state:e});n&&e.global.skipMode&&cr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Xr(l),p=u.read;n||xr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Sr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=It({pointer:u.read}):Ni(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=Et(e,l?.pointers?.read,{screenTransition:i});return bn(e,o,c),e},tg=({state:e},t)=>{if(te(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})},lc=e=>(e.global.accountViewedRegistry=cy(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Gi=(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)}))}})},cc=(e,t)=>{Gi(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:[]}}])},ng=(e,t,{sectionId:n,lineId:i})=>{if(!n||!i)return!1;let a=F(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},xr=(e,t)=>{if(te(e)||e.global.accountViewedRegistry===void 0)return;ng(e,lc(e),t)&&cc(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},sg=({state:e},t)=>(xr(e,t),e.global.pendingEffects.push({name:"render"}),e),ig=({state:e},t)=>{if(te(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let i=lc(e);i.resources.find(r=>r.resourceId===n)||(i.resources.push({resourceId:n}),cc(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Ye=(e,t,n)=>{if(!F(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}"`)})},vi=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},In=(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"}))},og=({state:e},t)=>{let n="showImageGalleryVariant";Ye(n,t,ty),vi(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&vi(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||wt(e,s)||In(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/i.pageSize)}),e},uc=(e,t,n,i)=>{Ye(i,t,Pi);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=wi(e,s.variants,o,n);return l&&In(e,{...r,variantId:l.id}),e},ag=({state:e},t)=>uc(e,t,-1,"moveToPreviousImageGalleryVariant"),lg=({state:e},t)=>uc(e,t,1,"moveToNextImageGalleryVariant"),cg=({state:e},t)=>{if(Ye("clearImageGallerySelection",t,Pi),e.projectData?.resources?.imageGallery===void 0)return e;let i=e.global.imageGalleryNavigation;return In(e,{groupId:null,variantId:null,pageIndex:i.pageIndex}),e},pc=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let i=Li(n);if(t>=i)return e;let a=e.global.imageGalleryNavigation,r=Mi(n,a);return t===r||In(e,{groupId:null,variantId:null,pageIndex:t}),e},ug=({state:e},t)=>{if(Ye("moveToImageGalleryPage",t,ny),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return pc(e,t.pageIndex)},fc=(e,t,n,i)=>{Ye(i,t,Pi);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Mi(a,e.global.imageGalleryNavigation)+n;return s<0?e:pc(e,s)},pg=({state:e},t)=>fc(e,t,1,"moveToNextImageGalleryPage"),fg=({state:e},t)=>fc(e,t,-1,"moveToPreviousImageGalleryPage"),Qe=(e,t,n)=>{if(!F(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}"`)})},dg=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},Ve=e=>{e.global.pendingEffects.push({name:"render"})},dc=(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:yn(e),operation:"pause"});let o=At(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},Ve(e)},mg=({state:e},t)=>{let n="playMusicRoomTrack";Qe(n,t,sy),dg(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||qi(e,a)||dc(e,a),e},yg=({state:e},t)=>{Qe("playMusicRoom",t,Yr);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=At(e,s,s==="play"?o:void 0),i.seekFallback=null,i.status="playing",i.positionMs=o,r&&(i.readiness=i.durationMs===null?"loading":"ready"),Ve(e),e},hg=({state:e},t)=>{Qe("pauseMusicRoom",t,Yr);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status!=="playing"||(i.playback=At(e,"pause"),i.seekFallback=null,i.status="paused",Ve(e)),e},gg=({state:e},t)=>{Qe("stopMusicRoom",t,Yr);let i=e.global.musicRoomPlayer;return i.trackId===null||i.status==="stopped"&&i.positionMs===0||(i.playback=At(e,"stop"),i.seekFallback=null,i.status="stopped",i.positionMs=0,Ve(e)),e},bg=({state:e},t)=>{if(Qe("seekMusicRoom",t,iy),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=At(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"),Ve(e),e},mc=(e,t,n,i)=>{Qe(i,t,Yr);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=Ii(e,a.tracks,s,n);return o&&dc(e,o),e},wg=({state:e},t)=>mc(e,t,-1,"playPreviousMusicRoomTrack"),Ig=({state:e},t)=>mc(e,t,1,"playNextMusicRoomTrack"),vg=({state:e},t)=>{Qe("clearMusicRoomSelection",t,Yr);let i=e.global.musicRoomPlayer;if(i.trackId===null)return e;let a=i.pageIndex,r={commandId:yn(e),operation:"resume"};return e.global.musicRoomPlayer={...mn({bgmPlayback:r}),pageIndex:a},Ve(e),e},yc=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=Vi(n))return e;let i=e.global.musicRoomPlayer,a=Fi(n,i);return t===a||(i.pageIndex=t,Ve(e)),e},Ag=({state:e},t)=>{if(Qe("moveToMusicRoomPage",t,oy),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return yc(e,t.pageIndex)},hc=(e,t,n,i)=>{Qe(i,t,Yr);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Fi(a,e.global.musicRoomPlayer)+n;return r<0?e:yc(e,r)},kg=({state:e},t)=>hc(e,t,1,"moveToNextMusicRoomPage"),Pg=({state:e},t)=>hc(e,t,-1,"moveToPreviousMusicRoomPage"),kr=e=>{let t=te(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.replayId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplayId!==i),e.contexts.pop(),Vy(e,n),e.global.pendingEffects.push({name:"render"}),!0},xg=({state:e},t)=>{let n="startSceneReplay";if(Ye(n,t,ay),vi(n,"replayId",t.replayId),te(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(u=>u.id===t.replayId);if(!a)return e;let{sceneId:r,section:s}=Er(e.projectData,a.startSectionId),o=s?.initialLineId??s?.lines?.[0]?.id;if(!s||!o||!s.lines.some(u=>u.id===o))throw new Error(`Scene replay "${a.id}" has an invalid start section`);let l=My(e);qy(e);let c=ji({pointer:{sceneId:r,sectionId:a.startSectionId,lineId:o},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{replayId:a.id,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:l}});return Vl(e,c),e.contexts.push(c),Et(e,c.pointers.read),e},gc=({state:e},t)=>{Ye("finishSceneReplay",t,xi);let i=te(e);return i&&(i.sceneReplay.finishOnNextAdvance=!0),e},Eg=({state:e},t)=>(Ye("exitSceneReplay",t,xi),kr(e),e),bc=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=Ui(n))return e;let i=Bi(n,e.global.sceneReplayNavigation);return t===i||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},Sg=({state:e},t)=>{if(Ye("moveToSceneReplayPage",t,ly),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return bc(e,t.pageIndex)},wc=(e,t,n,i)=>{Ye(i,t,xi);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Bi(a,e.global.sceneReplayNavigation)+n;return r<0?e:bc(e,r)},Og=({state:e},t)=>wc(e,t,1,"moveToNextSceneReplayPage"),Rg=({state:e},t)=>wc(e,t,-1,"moveToPreviousSceneReplayPage"),vn=(e,t)=>{let n=e.global.musicRoomPlayer;return!F(t)||t.id!==ey||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Xi=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,Ic=(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,Ve(e)),e),Cg=({state:e},t)=>{let n=vn(e,t);return!n||n.readiness!=="loading"||!Xi(t)?e:Ic(e,n,t,{readiness:"ready"})},_g=({state:e},t)=>{let n=vn(e,t);return!n||n.readiness!=="ready"||!Xi(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:Ic(e,n,t)},$g=({state:e},t)=>{let n=vn(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Xi(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,Ve(e)),e},jg=({state:e},t)=>{let n=vn(e,t);if(!n||typeof t.errorCode!="string"||!ry.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&&Ve(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,Ve(e),e},vc=({state:e},t)=>{let n=dy(t.manual),{auto:i,applyMode:a}=t,r=e.global.nextLineConfig.auto?.enabled,s=e.global.nextLineConfig?.applyMode,o=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;n&&i?(e.global.nextLineConfig={manual:n,auto:i},a!==void 0?e.global.nextLineConfig.applyMode=a:s!==void 0&&(e.global.nextLineConfig.applyMode=s)):(n&&(e.global.nextLineConfig.manual=n),i&&(e.global.nextLineConfig.auto=i),a!==void 0&&(e.global.nextLineConfig.applyMode=a));let l=e.global.nextLineConfig.auto?.enabled,c=Pe({state:e});return!o&&!c&&l===!0&&!r?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}}):!o&&l===!1&&r&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.pendingEffects.push({name:"render"}),Be(e,"setNextLineConfig",t),e},Ng=({state:e},t)=>{if(te(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=kt(n),s=D(e.contexts);s?.forEach(c=>{Xr(c),Bl(c.rollback),hy(c.rollback)});let o={contexts:s},l={formatVersion:vl,slotId:El(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},Dg=({state:e},t)=>{if(te(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=kt(n),a=e.global.saveSlots[i];if(a){let r=Ey(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=vt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,zr(e),Gr(e),Oi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},Tg=({state:e},t)=>{if(te(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;xl(n),ot(n),at(n),lt(n),gr(n?.resources?.variables??{}),e.projectData=n,e.global.imageGalleryNavigation=ki(),e.global.sceneReplayNavigation=Ei(),Oi(e);let i=n?.resources?.variables??{},{contextVariableDefaultValues:a,globalVariablesDefaultValues:r}=Kt(n??{});return Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...r,...Tr(e.global.variables,i)}),e.contexts?.forEach(s=>{Object.prototype.hasOwnProperty.call(s??{},"variables")&&(s.variables={...a,...Tr(s.variables,i)})}),zr(e),Gr(e),e.global.pendingEffects.push({name:"render"}),e},Lg=({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(!F(i))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=i,$i(e,"localizationPackageId",n),Fl(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Pe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Wr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},Mg=({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=Pe({state:e}),c=Xr(a);c.read={sectionId:r,lineId:i};let{activeInteraction:u}=Et(e,c.read);return bn(e,l,u),e},qg=({state:e},t)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return wn({state:e}),e;let n=Pe({state:e});if(n?.source===Br&&t?.bypassChoice!==!0||n?.source===lr&&t?._interactionSource!==lr)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=Te({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:Wr({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=Te({state:e})?.pointer,r=a?.sectionId,s=we({state:e},{sectionId:r}),o=e.contexts[e.contexts.length-1],l=s?.lines||[],u=l.findIndex(p=>p.id===a?.lineId)+1;if(u<l.length){let p=l[u],m=!ir(e,"skipUnseenText");if(e.global.skipMode&&m&&!Ti({state:e},{sectionId:r,lineId:p.id}))return cr({state:e}),e;if(o&&!o.rollback&&Sr(o,{compatibilityAnchor:!0}),o){let f=Xr(o),y=f.read?.lineId;y&&r&&xr(e,{sectionId:r,lineId:y}),f.read={sectionId:r,lineId:p.id}}Ni(e,{sectionId:r,lineId:p.id}),Si(e);let{activeInteraction:d}=Et(e,{sectionId:r,lineId:p.id});bn(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&&cr({state:e})}return e},Vg=({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:Wr({state:e})}});let i=Te({state:e})?.pointer,a=i?.sectionId,r=i?.lineId;a&&r&&xr(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},Fg=({state:e},t)=>ac(e,{sectionId:t?.sectionId,screen:t?.screen}),Ug=({state:e},t)=>{let n=t?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!n)return wn({state:e}),e;let i=Pe({state:e});if(i?.source===Br&&t?.bypassChoice!==!0||i?.source===lr&&t?._interactionSource!==lr||i&&i.source!==Br&&i.source!==lr)return e;let a=te(e);if(a?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(kr(e),e):(a.sceneReplay.exitOnLineCompleted=!0,e);let r=Te({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=!ir(e,"skipUnseenText");if(e.global.skipMode&&d&&!Ti({state:e},{sectionId:s,lineId:m.id})&&(cr({state:e}),!n))return e;if(l&&!l.rollback&&Sr(l,{compatibilityAnchor:!0}),l){let y=Xr(l),g=y.read?.lineId;g&&s&&xr(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:m.id}}Ni(e,{sectionId:s,lineId:m.id}),Si(e);let{activeInteraction:f}=Et(e,{sectionId:s,lineId:m.id});bn(e,i,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&&cr({state:e}),e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))}return e},Wi=(e,t={})=>{let n=xt({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},Bg=(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(Ne(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(ut(i,t.variableId),Jt(a,"set",t.variableId),te(e)&&i!=="context")throw new Error(`Cannot update ${i}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:i}},Yg=(e,t)=>({id:e.id,key:e.key,valid:!0,values:D(t),fields:D(e.fields),fieldList:D(e.fieldList)}),zg=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Te({state:e})?.pointer,n=t?.sectionId,i=t?.lineId;n&&i&&xr(e,{sectionId:n,lineId:i})},Gg=({state:e},t={})=>{let n=Wi(e,t),i=t.field;if(!n?.fields?.[i])return e;let a=Ll(e,n.key),r=fn(t.value),s=n.fields[i],o=Ri(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},Xg=({state:e},t={})=>{let n=Wi(e,t);if(!n)return{submitted:!1,valid:!1,reason:"inactive"};let i=Ll(e,n.key);i.submitted=!0;let a={},r={};if(Object.entries(n.fields).forEach(([p,m])=>{let d=Object.prototype.hasOwnProperty.call(i.values,p)?i.values[p]:m.value,f=Ri(m,d);i.touched[p]=!0,f&&(r[p]=f),a[p]=Tl(m,d)}),i.errors=r,Object.keys(r).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:D(r),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 o=!1,l=[],c=[];Object.entries(n.fields).forEach(([p,m])=>{let{scope:d}=Bg(e,m),f=d==="context"?s.variables:e.global.variables,y=a[p];f[m.variableId]=Qt(f[m.variableId],"set",y),d==="context"&&(o=!0,c.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])})}),o&&Be(e,"updateVariable",{id:"submitForm",operations:c}),Gi(e,l);let u=Yg(n,a);return zg(e),delete e.global.formDrafts[n.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:u}},Wg=({state:e},t={})=>{let n=Wi(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"}},Hg=({state:e},t)=>{let{id:n,operations:i=[]}=t;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 r=!1,s=[],o=[];return i.forEach(({variableId:l,op:c,value:u,roundTo:p})=>{let m=e.projectData.resources?.variables?.[l],d=m?.scope,f=m?.type;if(Ne(m))throw new Error(`Cannot update computed variable: ${l}`);if(m?.readonly===!0)throw new Error(`Cannot update readonly variable: ${l}`);if(ut(d,l),Jt(f,c,l),Fs(f,c,u,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"){r=!0;let g={variableId:l,op:c,value:u};p!==void 0&&(g.roundTo=p),o.push(g)}y[l]=Qt(y[l],c,u,{roundTo:p}),(d==="device"||d==="account")&&s.push({scope:d,path:`variables.${l}`,op:"set",value:D(y[l])})}),r&&Be(e,"updateVariable",{id:n,operations:o}),Gi(e,s),e.global.pendingEffects.push({name:"render"}),e},Il=e=>(t,n)=>e({state:t},n),Kg=e=>({variables:ct({variables:{...e.global?.variables??{},...Pt(e)?.variables??{}},runtime:Ir(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Ir(e)}),Jg=e=>{if(!F(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")},Qg=(e,t,n)=>{if(!F(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!F(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")},Zg=(e,t)=>{Jg(t);for(let n=0;n<t.branches.length;n+=1){let i=t.branches[n];if(Qg(i,n,t.branches.length),!(Object.prototype.hasOwnProperty.call(i,"when")&&!it(i.when,Kg(e)))){Object.entries(i.actions).forEach(([r,s])=>{Ac(e,r,s)});return}}},eb={conditional:{replayLine:Zg},updateVariable:{recordSources:[Ci],replayLine:bl,replayRecorded:bl,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Il(vc)},finishSceneReplay:{replayLine:Il(gc)}},An=e=>eb[e]??null,rb=e=>An(e)?.persistInSaveSlot===!0,tb=(e,t)=>{let n=An(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},nb=(e,t,n)=>{An(t)?.replayRecorded?.(e,n)},Ac=(e,t,n)=>{An(t)?.replayLine?.(e,n)},sb=e=>e?.returnable!==!1,kc=(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(sb(e.timeline[i])&&(n-=1,n===0))return i;return-1},Pc=({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=kc(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},xc=({state:e})=>Pc({state:e},{offset:-1})!==null,ib=({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=Sr(i,{compatibilityAnchor:!i.rollback}),r=kc(a,n);return r<0||r>=a.timeline.length?e:Yl(e,r)},ob=({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=Sr(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:Yl(e,o)},Ec=e=>{let t=rh(e);return Yo(t,{selectPendingEffects:nh,selectSkipMode:zl,selectAutoMode:sh,selectIsChoiceVisible:Zl,selectIsFormVisible:oh,selectActiveInteraction:Pe,selectActiveForm:xt,selectDialogueUIHidden:Gl,selectDialogueHistory:Xl,selectConfirmDialog:ih,selectIsLineAccountViewed:Ti,selectIsResourceAccountViewed:lh,selectImageGalleryConfig:ch,selectImageGallery:Wl,selectMusicRoomConfig:ph,selectMusicRoom:Kl,selectSceneReplayConfig:fh,selectSceneReplay:Jl,selectIsSceneReplayActive:dh,selectActiveSceneReplayEntry:mh,selectNextLineConfig:yh,selectSystemState:hh,selectAchievements:gh,selectAchievement:bh,selectSaveSlotMap:ec,selectSaveSlots:xh,selectSaveSlot:wh,selectLocalizationPackages:rc,selectRuntime:Yi,selectRuntimeValue:Ih,selectAllVariables:hn,selectCurrentPointer:Te,selectSection:we,selectCurrentLine:gn,selectPresentationState:tc,selectAutoForwardTimerDelay:Wr,selectPresentationChanges:Ah,selectSectionLineChanges:Ph,selectSaveSlotPage:zi,selectCurrentPageSlots:Eh,selectRenderState:Oh,selectOverlayStack:th,selectLineIdByOffset:Pc,selectCanRollback:xc,selectRollbackCursor:Xy,startAutoMode:sc,stopAutoMode:St,toggleAutoMode:Th,startSkipMode:ic,stopSkipMode:cr,toggleSkipMode:Lh,showDialogueUI:wn,hideDialogueUI:oc,toggleDialogueUI:Mh,setDialogueTextSpeed:qh,setAutoForwardDelay:Vh,setAutoForwardSpeed:Fh,setSkipUnseenText:Uh,setSkipTransitionsAndAnimations:Bh,setSoundVolume:Yh,setMusicVolume:zh,setMuteAll:Gh,setSaveLoadPagination:Xh,incrementSaveLoadPagination:Wh,decrementSaveLoadPagination:Hh,setMenuPage:Kh,setMenuEntryPoint:Jh,showConfirmDialog:Rh,hideConfirmDialog:Ch,resetStoryAtSection:tg,clearPendingEffects:Qh,appendPendingEffect:Zh,completeAchievement:eg,setAchievementProgress:rg,beginRollbackActionBatch:Jy,endRollbackActionBatch:Qy,markRollbackCheckpointTransient:Wy,markSavedRollbackCheckpointTransient:Hy,addViewedLine:sg,addViewedResource:ig,showImageGalleryVariant:og,moveToPreviousImageGalleryVariant:ag,moveToNextImageGalleryVariant:lg,clearImageGallerySelection:cg,moveToImageGalleryPage:ug,moveToNextImageGalleryPage:pg,moveToPreviousImageGalleryPage:fg,playMusicRoomTrack:mg,playMusicRoom:yg,pauseMusicRoom:hg,stopMusicRoom:gg,seekMusicRoom:bg,playPreviousMusicRoomTrack:wg,playNextMusicRoomTrack:Ig,clearMusicRoomSelection:vg,moveToMusicRoomPage:Ag,moveToNextMusicRoomPage:kg,moveToPreviousMusicRoomPage:Pg,musicRoomSoundReady:Cg,musicRoomSoundProgress:_g,musicRoomSoundComplete:$g,musicRoomSoundError:jg,startSceneReplay:xg,finishSceneReplay:gc,exitSceneReplay:Eg,moveToSceneReplayPage:Sg,moveToNextSceneReplayPage:Og,moveToPreviousSceneReplayPage:Rg,setNextLineConfig:vc,saveSlot:Ng,loadSlot:Dg,updateProjectData:Tg,updateLocalizationPackage:Lg,sectionTransition:Fg,jumpToLine:Mg,nextLine:qg,markLineCompleted:Vg,rollbackToLine:ob,rollbackByOffset:ib,pushOverlay:_h,popOverlay:$h,replaceLastOverlay:jh,clearOverlays:Nh,updateFormField:Gg,submitForm:Xg,cancelForm:Wg,updateVariable:Hg,nextLineFromSystem:Ug},{transformActionFirstArgument:i=>({state:i}),transformSelectorFirstArgument:i=>({state:i})})};var ab="route-engine",lb="projectPersistence";var Oc=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{}}),he=e=>Object.prototype.toString.call(e)==="[object Object]",Sc="variables.",cb=(e={})=>{let t=he(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!he(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)}:!he(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},ub=(e={})=>{let t=he(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!he(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)}:!he(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},pb=(e,t)=>{let n=ub(e),i=cb(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}},Rc=(e={})=>{let t=he(e)?e:{};return{saveSlots:he(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:he(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:he(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:he(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:he(t.accountViewedRegistry)?t.accountViewedRegistry:{}}},fb=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!he(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let i=t.path?.startsWith(Sc)?t.path.slice(Sc.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}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${n}].`)})},db=(e,t)=>{let n={};return fb(t).forEach(i=>{if(i.path==="viewedRegistry"){n.accountViewedRegistry=pb(n.accountViewedRegistry??e.accountViewedRegistry,i.value);return}let a=i.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[a]={...e[a],...n[a],[i.variableId]:i.value}}),n},Hi=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},mb=e=>{let t=Hi(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},yb=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},hb=({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}".`))}}),gb=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.`))}})},Rt=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=Rc(c.result),f=typeof i=="function"?i(d):i,y={namespace:n,version:1,...Oc(),...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}".`))}})},bb=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}".`))}})},Ki=(e={})=>{let{indexedDB:t,databaseName:n=ab,objectStoreName:i=lb,namespace:a}=e,r=yb(t),s=mb(a),o=hb({indexedDB:r,databaseName:n,objectStoreName:i});return{namespace:s,load:async()=>{let l=await gb({databasePromise:o,objectStoreName:i,namespace:s});return{...Oc(),...Rc(l)}},clear:async()=>bb({databasePromise:o,objectStoreName:i,namespace:s}),saveSlots:async l=>Rt({databasePromise:o,objectStoreName:i,namespace:s,patch:{saveSlots:he(l)?l:{}}}),saveGlobalDeviceVariables:async l=>Rt({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalDeviceVariables:he(l)?l:{}}}),saveGlobalAccountVariables:async l=>Rt({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalAccountVariables:he(l)?l:{}}}),saveGlobalRuntime:async l=>Rt({databasePromise:o,objectStoreName:i,namespace:s,patch:{globalRuntime:he(l)?l:{}}}),applyScopedDataUpdates:async l=>Rt({databasePromise:o,objectStoreName:i,namespace:s,patch:c=>db(c,l)})}},wb=Ki;var Lc=Mc;var Ib={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,vb={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 Ce(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:vb.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 Ce.errors=r,s===0}var Ab={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Pn(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:Ab.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 Pn.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&&(Pn(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Pn.errors:r.concat(Pn.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 xn(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(!Ze.call(Ib.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&&(Ce(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ce.errors:r.concat(Ce.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 xn.errors=r,s===0}function Mc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return xn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?xn.errors:r.concat(xn.errors),s=r.length),Mc.errors=r,s===0}var qc=Vc;var kb={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},$c={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},Re=_c().default;function Oe(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(!Ze.call($c.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(Re(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(Re(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:$c.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 Oe.errors=r,s===0}function En(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++)Oe(d[y],{instancePath:t+"/sounds/"+y,parentData:d,parentDataProperty:y,rootData:a})||(r=r===null?Oe.errors:r.concat(Oe.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:kb.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 En.errors=r,s===0}function Vc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return En(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?En.errors:r.concat(En.errors),s=r.length),Vc.errors=r,s===0}var Fc=Uc;var Pb={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 Sn(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(!Ze.call(Pb.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&&(Ce(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Ce.errors:r.concat(Ce.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 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: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=[E]:r.push(E),s++}if(w.id!==void 0&&typeof w.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(w.resourceId!==void 0&&typeof w.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(w.animationName!==void 0&&typeof w.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(w.animationSpeed!==void 0&&typeof w.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(w.loop!==void 0&&typeof w.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 Sn.errors=r,s===0}function Uc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Sn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Sn.errors:r.concat(Sn.errors),s=r.length),Uc.errors=r,s===0}var Bc=Yc;function On(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 On.errors=r,s===0}function Yc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return On(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?On.errors:r.concat(On.errors),s=r.length),Yc.errors=r,s===0}var zc=Gc;function Rn(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 Rn.errors=r,s===0}function Gc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Rn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Rn.errors:r.concat(Rn.errors),s=r.length),Gc.errors=r,s===0}var Xc=Wc;function Cn(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 Cn.errors=r,s===0}function Wc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Cn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Cn.errors:r.concat(Cn.errors),s=r.length),Wc.errors=r,s===0}var Hc=Kc;var jc={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 _n(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(!Ze.call(jc.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:jc.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 _n.errors=r,s===0}function Kc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return _n(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?_n.errors:r.concat(_n.errors),s=r.length),Kc.errors=r,s===0}var Jc=Qc;function $n(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 $n.errors=r,s===0}function Qc(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return $n(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?$n.errors:r.concat($n.errors),s=r.length),Qc.errors=r,s===0}var Zc=eu;function jn(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 jn.errors=r,s===0}function eu(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),eu.errors=r,s===0}var ru=tu;function Nn(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&&(Ce(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Ce.errors:r.concat(Ce.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 Nn.errors=r,s===0}function tu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Nn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Nn.errors:r.concat(Nn.errors),s=r.length),tu.errors=r,s===0}var nu=su;var xb={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 Dn(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++)Oe(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?Oe.errors:r.concat(Oe.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(Re(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:xb.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++)Oe(f[g],{instancePath:t+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?Oe.errors:r.concat(Oe.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 Dn.errors=r,s===0}function su(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Dn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Dn.errors:r.concat(Dn.errors),s=r.length),su.errors=r,s===0}var iu=ou;var Nc={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 Tn(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 Tn.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,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};r===null?r=[b]:r.push(b),s++}}var m=p===s;if(u=u||m,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let v={};r===null?r=[v]:r.push(v),s++}}var m=w===s;if(u=u||m,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.resourceId===void 0&&(k="resourceId")){let x={};r===null?r=[x]:r.push(x),s++}}var m=E===s;if(u=u||m,!u){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let N={};r===null?r=[N]:r.push(N),s++}}var m=k===s;if(u=u||m,!u){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.x===void 0&&(P="x")){let T={};r===null?r=[T]:r.push(T),s++}}var m=C===s;if(u=u||m,!u){let P=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=P===s;if(u=u||m,!u){let q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.anchorX===void 0&&(B="anchorX")){let ne={};r===null?r=[ne]:r.push(ne),s++}}var m=q===s;if(u=u||m,!u){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ie;if(e.anchorY===void 0&&(ie="anchorY")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var m=B===s;if(u=u||m,!u){let ie=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ve;if(e.scaleX===void 0&&(ve="scaleX")){let le={};r===null?r=[le]:r.push(le),s++}}var m=ie===s;if(u=u||m,!u){let ve=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.scaleY===void 0&&(se="scaleY")){let ce={};r===null?r=[ce]:r.push(ce),s++}}var m=ve===s;if(u=u||m,!u){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.rotation===void 0&&(oe="rotation")){let R={};r===null?r=[R]:r.push(R),s++}}var m=se===s;if(u=u||m,!u){let oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.originX===void 0&&(j="originX")){let M={};r===null?r=[M]:r.push(M),s++}}var m=oe===s;if(u=u||m,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.originY===void 0&&(Z="originY")){let ge={};r===null?r=[ge]:r.push(ge),s++}}var m=j===s;if(u=u||m,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.layer===void 0&&(K="layer")){let xe={};r===null?r=[xe]:r.push(xe),s++}}var m=Z===s;if(u=u||m,!u){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.opacity===void 0&&(me="opacity")){let Jr={};r===null?r=[Jr]:r.push(Jr),s++}}var m=K===s;if(u=u||m,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Qr;if(e.blur===void 0&&(Qr="blur")){let Zr={};r===null?r=[Zr]:r.push(Zr),s++}}var m=me===s;if(u=u||m,!u){let Qr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let cs;if(e.animations===void 0&&(cs="animations")){let jt={};r===null?r=[jt]:r.push(jt),s++}}var m=Qr===s;u=u||m}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var d=l===s;if(d){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=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 w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var 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:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[E]:r.push(E),s++}var h=w===s;y=y||h}if(y)s=f,r!==null&&(f?r.length=f:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Tn(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Tn.errors:r.concat(Tn.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return Ln.errors=r,s===0}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=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(!Ze.call(Nc.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&&(Ln(p.text,{instancePath:t+"/items/"+u+"/text",parentData:p,parentDataProperty:"text",rootData:a})||(r=r===null?Ln.errors:r.concat(Ln.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:Nc.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&&(Ce(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Ce.errors:r.concat(Ce.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 Mn.errors=r,s===0}function ou(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),ou.errors=r,s===0}var au=lu;var Eb={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 qn(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 w={};r===null?r=[w]:r.push(w),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 w={};r===null?r=[w]:r.push(w),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 w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[w]:r.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:t+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:a})||(r=r===null?Oe.errors:r.concat(Oe.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let 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 w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(h<0||isNaN(h)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let 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 w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(h<-1||isNaN(h)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let 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 w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(h==="immediate"||h==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Eb.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}return qn.errors=r,s===0}function lu(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),lu.errors=r,s===0}var cu=uu;var Sb={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 Vn(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 w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let p=s,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,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let v={};r===null?r=[v]:r.push(v),s++}}var y=w===s;if(y){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=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:Sb.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(Re(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(Re(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(Re(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(Re(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 Vn.errors=r,s===0}function uu(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),uu.errors=r,s===0}var pu=fu;var Ob={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 Rb={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 Rr(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:Rb.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 Rr.errors=r,s===0}function G(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++)Rr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Rr.errors:r.concat(Rr.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 G.errors=r,s===0}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(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&&(G(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.x!==void 0&&(G(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.y!==void 0&&(G(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.scaleX!==void 0&&(G(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.scaleY!==void 0&&(G(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.rotation!==void 0&&(G(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?G.errors:r.concat(G.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 Fn.errors=r,s===0}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)){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&&(G(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.translateY!==void 0&&(G(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.alpha!==void 0&&(G(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.scaleX!==void 0&&(G(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.scaleY!==void 0&&(G(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?G.errors:r.concat(G.errors),s=r.length)),e.rotation!==void 0&&(G(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?G.errors:r.concat(G.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 Un.errors=r,s===0}function Or(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&&(Un(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Un.errors:r.concat(Un.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 Or.errors=r,s===0}var kn={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"]}}]},Cb={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};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)){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:Cb.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 Bn.errors=r,s===0}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)){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++)Rr(o[c],{instancePath:t+"/keyframes/"+c,parentData:o,parentDataProperty:c,rootData:a})||(r=r===null?Rr.errors:r.concat(Rr.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 Yn.errors=r,s===0}function zn(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 w=h===s;if(s=y,r!==null&&(y?r.length=y:r=null),w){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 w=b===s;g=w}if(!g){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!Ze.call(kn.properties,b)){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:kn.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),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 E=b.length;for(let v=0;v<E;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 E={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),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 E=b.length;for(let v=0;v<E;v++)Bn(b[v],{instancePath:t+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(r=r===null?Bn.errors:r.concat(Bn.errors),s=r.length)}else{let E={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:kn.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:kn.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),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&&(Yn(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?Yn.errors:r.concat(Yn.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 zn.errors=r,s===0}function Gn(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,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={};r===null?r=[T]:r.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 ae={};r===null?r=[ae]:r.push(ae),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={};r===null?r=[ne]:r.push(ne),s++}}var p=q===s;x=x||p}}if(x)s=k,r!==null&&(k?r.length=k:r=null);else{let P={};r===null?r=[P]:r.push(P),s++}var m=v===s;if(m){let P={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[P]:r.push(P),s++}else s=E,r!==null&&(E?r.length=E:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let P={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[P]:r.push(P),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,E=s,v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.tween===void 0&&(P="tween")){let T={};r===null?r=[T]:r.push(T),s++}}var h=v===s;if(h){let P={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[P]:r.push(P),s++}else s=E,r!==null&&(E?r.length=E:r=null);let k=s,x=!1,C=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let P={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[P]:r.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: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 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:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[B]:r.push(B),s++}var w=q===s;x=x||w}}if(x)s=k,r!==null&&(k?r.length=k:r=null);else{let P={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[P]:r.push(P),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 E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),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 E={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(b==="update"||b==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Ob.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.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: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 E={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(Fn(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Fn.errors:r.concat(Fn.errors),s=r.length)),e.prev!==void 0&&(Or(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Or.errors:r.concat(Or.errors),s=r.length)),e.next!==void 0&&(Or(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Or.errors:r.concat(Or.errors),s=r.length)),e.mask!==void 0&&(zn(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?zn.errors:r.concat(zn.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 Gn.errors=r,s===0}function fu(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),fu.errors=r,s===0}var du=mu;function Xn(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(Re(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 Xn.errors=r,s===0}function mu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Xn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Xn.errors:r.concat(Xn.errors),s=r.length),mu.errors=r,s===0}var yu=hu;var _b=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");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)){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(!_b.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 Wn.errors=r,s===0}function hu(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),hu.errors=r,s===0}var gu=bu;function Hn(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 Hn.errors=r,s===0}function bu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return Hn(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?Hn.errors:r.concat(Hn.errors),s=r.length),bu.errors=r,s===0}var wu=Iu;function Kn(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 Kn.errors=r,s===0}function Iu(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),Iu.errors=r,s===0}var vu=Au;function Jn(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 Jn.errors=r,s===0}function Au(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),Au.errors=r,s===0}var ku=Pu;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(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 Qn.errors=r,s===0}function Pu(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),Pu.errors=r,s===0}var xu=Eu;function Zn(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 x;if(e.texture===void 0&&(x="texture")){let C={};r===null?r=[C]:r.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={};r===null?r=[P]:r.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={};r===null?r=[q]:r.push(q),s++}}var g=N===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 w=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=w===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 x={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[x]:r.push(x),s++}if(v.emission!==void 0){let k=v.emission;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),s++}}if(v.movement!==void 0){let k=v.movement;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),s++}}if(v.appearance!==void 0){let k=v.appearance;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),s++}}if(v.bounds!==void 0){let k=v.bounds;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let x={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),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,x=!1,C=null,N=s;if(typeof v=="string"){if(Re(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 E=N===s;E&&(x=!0,C=0);let P=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 E=P===s;if(E&&x?(x=!1,C=[C,1]):E&&(x=!0,C=1),x)s=k,r!==null&&(k?r.length=k:r=null);else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:C},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 x={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[x]:r.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:t+"/behaviors/"+x,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[N]:r.push(N),s++}for(let N in C)if(!(N==="type"||N==="config")){let P={instancePath:t+"/behaviors/"+x,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:N},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),s++}if(C.type!==void 0){let N=C.type;if(typeof N=="string"){if(Re(N)<1){let P={instancePath:t+"/behaviors/"+x+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[P]:r.push(P),s++}}else{let P={instancePath:t+"/behaviors/"+x+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),s++}}if(C.config!==void 0){let N=C.config;if(!(N&&typeof N=="object"&&!Array.isArray(N))){let P={instancePath:t+"/behaviors/"+x+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),s++}}}else{let N={instancePath:t+"/behaviors/"+x,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[N]:r.push(N),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 x={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[x]:r.push(x),s++}if(k.max===void 0){let x={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[x]:r.push(x),s++}if(k.min!==void 0){let x=k.min;if(typeof x=="number"){if(x<0||isNaN(x)){let C={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=[C]:r.push(C),s++}}else{let C={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=[C]:r.push(C),s++}}if(k.max!==void 0){let x=k.max;if(typeof x=="number"){if(x<0||isNaN(x)){let C={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=[C]:r.push(C),s++}}else{let C={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=[C]:r.push(C),s++}}}else{let x={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[x]:r.push(x),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 Zn.errors=r,s===0}function Eu(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),Eu.errors=r,s===0}var Su=Ou;var Dc={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 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.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(!Ze.call(Dc.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:Dc.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 es.errors=r,s===0}function Ou(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return es(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?es.errors:r.concat(es.errors),s=r.length),Ou.errors=r,s===0}var Ru=Cu;var $b=new RegExp("^.+$","u");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.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($b.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 rs.errors=r,s===0}function Cu(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return rs(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?rs.errors:r.concat(rs.errors),s=r.length),Cu.errors=r,s===0}var _u=$u;var Tc={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 ts(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(!Ze.call(Tc.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(Re(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 w=l[h];if(typeof w=="string"){if(Re(w)<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 w=l[y];if(typeof w=="string"){if(typeof h[w]=="number"){g=h[w];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[w]=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:Tc.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(Re(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 ts.errors=r,s===0}function $u(e,{instancePath:t="",parentData:n,parentDataProperty:i,rootData:a=e}={}){let r=null,s=0;return ts(e,{instancePath:t,parentData:n,parentDataProperty:i,rootData:a})||(r=r===null?ts.errors:r.concat(ts.errors),s=r.length),$u.errors=r,s===0}var ju=Nu;var jb={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 ns(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(!Ze.call(jb.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 ns.errors=r,s===0}function Nu(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),Nu.errors=r,s===0}var Du=Tu;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)){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 ss.errors=r,s===0}function Tu(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),Tu.errors=r,s===0}var os=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_t=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Cr=e=>e===void 0?void 0:structuredClone(e),Nb=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"}),Db=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Tb=Object.freeze({background:Lc,bgm:qc,character:Fc,choice:Bc,cleanAll:zc,control:Xc,dialogue:Hc,form:Jc,layout:Zc,screen:ru,sfx:nu,visual:iu,voice:au}),Lb=Object.freeze({achievement:cu,animation:pu,character:du,color:yu,control:gu,font:wu,image:vu,layout:ku,particle:xu,sound:Su,spritesheet:Ru,textStyle:_u,transform:ju,video:Du}),Mb=new Set(["files","language","patches"]),qb=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Vb=new Set(["lineId","mode","payload","type"]),Fb=new Set(["mode","payload","sceneId","type"]),Ub=new Set(["mode","operation","payload","resourceId","type"]),Bb=new Set(["fileId","mimeType"]),V=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},Fe=(e,t)=>{_t(e)||V(t,"expected an object")},Qi=(e,t)=>{Array.isArray(e)||V(t,"expected an array")},Hr=(e,t)=>{(typeof e!="string"||e.length===0)&&V(t,"expected a non-empty string")},qu=(e,t)=>{typeof e!="string"&&V(t,"expected a string")},ze=(e,t,n)=>{for(let i of Object.keys(e))t.has(i)||V(`${n}.${i}`,"unknown field")},Ge=(e,t,n)=>{for(let i of t)os(e,i)||V(n,`missing required field "${i}"`)},Yb=e=>e.replaceAll("~1","/").replaceAll("~0","~"),zb=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(Yb);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)},Gb=(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],Vu=({value:e,validator:t,path:n,contract:i})=>{if(t(e))return;let a=Gb(t.errors);V(zb(n,a),`does not match ${i}: ${a?.message??"schema validation failed"}`)},Kr=(e,t)=>{Hr(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&V(t,`"${e}" is not a safe ID`)},Xb=(e,t)=>{Hr(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&V(t,"must be a safe single filename")},Ct=(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)=>Ct(a,t[r]));if(!_t(e)||!_t(t))return!1;let n=Object.keys(e).sort(),i=Object.keys(t).sort();return Ct(n,i)&&n.every(a=>Ct(e[a],t[a]))},is=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(i=>is(i,t,n)),t;if(!_t(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),is(a,t,n);return t},Wb=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},Fu=(e,t,n)=>{let i=e.get(t)??[];return i.length===0&&V(n,`lineId "${t}" does not exist in projectData`),i.length>1&&V(n,`lineId "${t}" is not globally unique in projectData`),i[0]},Uu=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Lu=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Mu=e=>{let t=Cr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))_t(n)&&delete n.placeholder;return t},Hb=(e,t,n,i)=>{e==="choice"&&!Ct(Lu(t),Lu(n))&&V(i,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Ct(Mu(t),Mu(n))&&V(i,"form behavior must remain identical; only presentation fields and placeholders may change")},Kb=({patch:e,path:t,lineIndex:n})=>{ze(e,qb,t),Ge(e,["type","lineId","actionType","payload"],t),Kr(e.lineId,`${t}.lineId`),Hr(e.actionType,`${t}.actionType`),Fe(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&V(`${t}.mode`,'line.action supports only "replace"'),Db.has(e.actionType)||V(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let i=Fu(n,e.lineId,`${t}.lineId`),a=i.line?.actions?.[e.actionType];return a===void 0&&V(`${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")&&V(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),os(e.payload,"content")&&V(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&V(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),Hb(e.actionType,a,e.payload,`${t}.payload`),Vu({value:e.payload,validator:Tb[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}},Jb=(e,t)=>{Qi(e,t),e.forEach((n,i)=>{Fe(n,`${t}[${i}]`),ze(n,new Set(["text"]),`${t}[${i}]`),Ge(n,["text"],`${t}[${i}]`),qu(n.text,`${t}[${i}].text`)})},Qb=({patch:e,path:t,lineIndex:n})=>{ze(e,Vb,t),Ge(e,["type","lineId","payload"],t),Kr(e.lineId,`${t}.lineId`),Fe(e.payload,`${t}.payload`),ze(e.payload,new Set(["content"]),`${t}.payload`),Ge(e.payload,["content"],`${t}.payload`),Jb(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&V(`${t}.mode`,'line.dialogue supports only "replace"');let i=Fu(n,e.lineId,`${t}.lineId`);return i.line?.actions?.dialogue===void 0&&V(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:i,patch:e}},Zb=({patch:e,path:t,projectData:n})=>(ze(e,Fb,t),Ge(e,["type","mode","sceneId","payload"],t),Kr(e.sceneId,`${t}.sceneId`),Fe(e.payload,`${t}.payload`),ze(e.payload,new Set(["name"]),`${t}.payload`),Ge(e.payload,["name"],`${t}.payload`),qu(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&V(`${t}.mode`,'story.scene requires "patch"'),os(n?.story?.scenes??{},e.sceneId)||V(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),e0=(e,t,n)=>{Fe(t,n),["font","image","sound","spritesheet","video"].includes(e)&&Hr(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||V(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||V(`${n}.height`,"expected an integer")),e==="spritesheet"&&(Fe(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||V(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||V(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&V(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),Vu({value:t,validator:Lb[e],path:n,contract:`the resource.${e} schema`})},r0=({patch:e,path:t,projectData:n,packageFileIds:i,canonicalFileIds:a})=>{ze(e,Ub,t),Ge(e,["type","resourceId","payload"],t),Kr(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=Nb[r];s||V(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&V(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&V(`${t}.operation`,'the only resource operation is "add"'),e0(r,e.payload,`${t}.payload`);let o=n?.resources?.[s]??{},l=os(o,e.resourceId);e.operation==="add"&&l&&V(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&V(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of is(e.payload))!i.has(c)&&!a.has(c)&&V(`${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}},t0=({patch:e,path:t,projectData:n,lineIndex:i,packageFileIds:a,canonicalFileIds:r})=>{if(Fe(e,t),Hr(e.type,`${t}.type`),e.type==="line.action")return Kb({patch:e,path:t,lineIndex:i});if(e.type==="line.dialogue")return Qb({patch:e,path:t,lineIndex:i});if(e.type==="story.scene")return Zb({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return r0({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});V(`${t}.type`,`unsupported patch type "${e.type}"`)},n0=(e,t)=>{Qi(e,t);let n=new Set;return e.forEach((i,a)=>{let r=`${t}[${a}]`;Fe(i,r),ze(i,Bb,r),Ge(i,["fileId"],r),Xb(i.fileId,`${r}.fileId`),i.mimeType!==void 0&&(typeof i.mimeType!="string"||i.mimeType.length===0)&&V(`${r}.mimeType`,"expected a non-empty string"),n.has(i.fileId)&&V(`${r}.fileId`,`duplicate fileId "${i.fileId}"`),n.add(i.fileId)}),n},s0=({packageId:e,packageData:t,path:n,projectData:i,lineIndex:a,canonicalFileIds:r})=>{Fe(t,n),ze(t,Mb,n),Ge(t,["language","files","patches"],n),Hr(t.language,`${n}.language`);let s=n0(t.files,`${n}.files`);Qi(t.patches,`${n}.patches`);let o=new Set,l=t.patches.map((c,u)=>{let p=t0({patch:c,path:`${n}.patches[${u}]`,projectData:i,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return o.has(p.key)&&V(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),o.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},Bu=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};Fe(t,"l10nData"),ze(t,new Set(["packages"]),"l10nData"),Ge(t,["packages"],"l10nData"),Fe(t.packages,"l10nData.packages");let n=Wb(e),i=is(e?.resources??{}),a=new Map,r=new Map;for(let[s,o]of Object.entries(t.packages)){Kr(s,`l10nData.packages.${s}`);let l=s0({packageId:s,packageData:o,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:i});for(let c of l.fileIds){i.has(c)&&V(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&V(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}a.set(s,l)}return{packages:a}},i0=(e,t)=>{let{collectionName:n,patch:i}=t;e.resources[n]??={},e.resources[n][i.resourceId]=Cr(i.payload)},o0=(e,t)=>{let{patch:n}=t,i=e.story.scenes[n.sceneId];i.name=n.payload.name},a0=(e,t)=>{let{location:n,patch:i}=t,a=Uu(e,n);if(i.actionType!=="dialogue"){a.actions[i.actionType]=Cr(i.payload);return}let r=Cr(n.line.actions.dialogue.content);a.actions.dialogue=Cr(i.payload),r!==void 0&&(a.actions.dialogue.content=r)},l0=(e,t)=>{let{location:n,patch:i}=t,a=Uu(e,n);a.actions.dialogue.content=Cr(i.payload.content)},Yu=({projectData:e,l10nData:t})=>{let n=Bu({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),i=>({l10nId:i.id,language:i.data.language}))]},as=({projectData:e,l10nData:t,l10nId:n=null})=>{let i=Bu({projectData:e,l10nData:t});if(n!==null&&(Kr(n,"l10nId"),i.packages.has(n)||V("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=Cr(e),r=i.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>i0(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>o0(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>a0(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>l0(a,s)),a};var c0=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),u0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),zu="conditional",ro=Symbol("conditionalAutoContinue"),p0=new Set(["sectionTransition","resetStoryAtSection"]),f0=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),d0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Zi="form",m0=new Set(["submitForm","cancelForm"]),y0="showImageGalleryVariant",h0="playMusicRoomTrack",g0="startSceneReplay",Ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ls=e=>e?.type===ro,eo=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId;function to(e){let t,n=0,i=null,a=0,r=!1,s=0,o=[],l=null,c=new Map,u=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(([,O])=>S<O.expiresAt).map(([O,_])=>[O,{animation:structuredClone(_.animation),startedAt:_.startedAt,expiresAt:_.expiresAt}])),h=(I=new Map)=>Array.from(I.values()).map(S=>structuredClone(S.animation)),w=(I=Date.now())=>{c=new Map(Array.from(c.entries()).filter(([,S])=>I<S.expiresAt))},b=()=>{if(!(a>0||r)){r=!0;try{for(;t.selectPendingEffects().length>0;){let I=[...t.selectPendingEffects()];t.clearPendingEffects();try{y(I)}catch(S){throw t.clearPendingEffects(),I.forEach(O=>{t.appendPendingEffect(O)}),S}}}finally{r=!1}}},E=I=>{a+=1;let S=!1;try{let O=I();return S=!0,O}finally{a-=1,S&&b()}},v=({initialState:I,namespace:S})=>{let{l10nData:O,..._}=I,L=O===void 0?void 0:structuredClone(O),Y=structuredClone(I.projectData),Q=Yu({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:fs})=>fs).filter(fs=>fs!==null)),$r=typeof Le=="string"&&_r.has(Le)?Le:null,dp=as({projectData:Y,l10nData:L,l10nId:$r});t=Ec({..._,global:{...ee,localizationPackages:Q,runtime:{...Ee,localizationPackageId:$r}},projectData:dp}),n=0,i=Hi(S),a=0,r=!1,s=0,o=[],l=null,c=new Map,u=new Map,p=new Map,m=Y,d=L,f=$r,t.appendPendingEffect({name:"handleLineActions"}),b()},k=()=>i,x=()=>t.selectPresentationState(),C=()=>t.selectPresentationChanges(),N=I=>t.selectSectionLineChanges(I),P=(I={})=>{n+=1;let S=Date.now();w(S);let O=u.size>0,_=g(c,S),L=O?g(u,S):new Map,Q={...t.selectRenderState({activePersistentAnimations:h(_),restoredPersistentAnimations:h(L)}),id:`render-${n}`};return p.set(Q.id,{builtAt:S,persistentAnimationSessions:new Map([...L.entries(),..._.entries()]),usedRestoredPersistentAnimationSessions:O}),Q},T=(I={})=>P(I),q=(I={})=>P(I),ae=I=>{let S=typeof I?.id=="string"&&I.id.length>0?I.id:null,O=S?p.get(S):null;S&&p.delete(S);let _=new Map;Ra(I?.animations).forEach(L=>{let Y=tn(L);if(!Y)return;let Q=O?.persistentAnimationSessions?.get(Y)??c.get(Y),ee=Math.max(0,$a(L)),Ee=Q?.startedAt??O?.builtAt??Date.now();_.set(Y,{animation:structuredClone(L),startedAt:Ee,expiresAt:Ee+ee})}),c=_,O?.usedRestoredPersistentAnimationSessions&&(u=new Map)},B=()=>t.selectSystemState(),ne=()=>t.selectAchievements(),ie=I=>t.selectAchievement(I),fe=()=>t.selectSaveSlotMap(),ve=I=>t.selectSaveSlot(I),le=I=>t.selectSaveSlotPage(I),se=()=>t.selectImageGallery(),ce=()=>t.selectMusicRoom(),oe=()=>t.selectSceneReplay(),R=()=>t.selectIsSceneReplayActive(),j=()=>t.selectSkipMode(),M=()=>t.selectAutoMode(),Z=()=>t.selectRuntime(),ge=()=>t.selectIsChoiceVisible(),K=()=>t.selectIsFormVisible(),xe=()=>t.selectActiveInteraction(),me=()=>t.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),Jr=(I,S,O={})=>!Ue(S)||I!=="nextLine"?S:O.bypassChoice===!0?{...S,bypassChoice:!0}:O.interactionSource===Zi?{...S,_interactionSource:Zi}:S,Qr=(I={})=>({type:ro,payload:Jr("nextLine",{_conditionalContinuation:!0},I)}),Zr=(I,S)=>ls(I)?{type:ro,payload:{...I.payload,...S.payload}}:S,cs=I=>{I.savedCheckpointOccurrences.forEach(S=>{t.markSavedRollbackCheckpointTransient(S)}),I.savedCheckpointOccurrences=[]},jt=(I,S)=>{let O=l;return l=null,!O||!eo(O.pointer,I)||O.checkpointIndex!==S?.checkpointIndex||O.checkpointIdentity!==S?.checkpoint?[]:O.savedCheckpointOccurrences},so=I=>{I.markCurrentCheckpointTransient&&(t.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),cs(I))},Ku=(I,S,O)=>f0.has(I)?I==="resetStoryAtSection"?O?.checkpoint!==S?.checkpoint:O?.checkpoint!==S?.checkpoint&&O?.checkpointIndex>S?.checkpointIndex:!1,Ju=I=>{let S=o.at(-1);if(!S?.markCurrentCheckpointTransient)return;let O=t.selectSaveSlot({slotId:I?.slotId});O&&S.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:O,checkpointIndex:S.rollbackCursor?.checkpointIndex,sectionId:S.pointer?.sectionId,lineId:S.pointer?.lineId})},Qu=(I,S,O)=>{let _=o.at(-1);if(!_)return;let L=t.selectCurrentPointer()?.pointer,Y=Ku(I,S,O);if(eo(_.pointer,L)){let Q=O?.checkpoint!==S?.checkpoint||O?.checkpointIndex!==S?.checkpointIndex;(Y||Q&&d0.has(I))&&(so(_),_.pointer=L,_.rollbackCursor=O,_.markCurrentCheckpointTransient=Y,_.savedCheckpointOccurrences=[]);return}so(_),_.pointer=L,_.rollbackCursor=t.selectRollbackCursor?.()??null,_.markCurrentCheckpointTransient=Y,_.savedCheckpointOccurrences=[]},Nt=(I,S)=>{if(!t[I])return;let O=S,_,L;if(I==="updateProjectData")io(S),_=structuredClone(S.projectData),O={...S,projectData:as({projectData:_,l10nData:d,l10nId:f})},io(O);else if(I==="updateLocalizationPackage"){if(L=Zu(S),L===f)return;O={l10nId:L,projectData:as({projectData:m,l10nData:d,l10nId:L})}}p0.has(I)&&(s+=1);let Y=t.selectIsSceneReplayActive?.()===!0,Q=u0.has(I)?g(c):null,ee=t.selectRollbackCursor?.()??null,Ee=t[I](O);_!==void 0&&(m=_),L!==void 0&&(f=L),c0.has(I)&&(u=Q??new Map,c=new Map);let Le=t.selectIsSceneReplayActive?.()===!0;Y!==Le&&(c=new Map,u=new Map);let _r=t.selectRollbackCursor?.()??null;return I==="saveSlot"&&Ju(S),Qu(I,ee,_r),b(),Ee},io=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");gr(I?.projectData?.resources?.variables??{}),ot(I.projectData),at(I.projectData),lt(I.projectData)},Zu=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},ep=(I,S,O)=>{let _=t.selectCurrentPointer()?.pointer;S!==_||O!==s||(t.appendPendingEffect({name:"clearAutoNextTimer"}),t.appendPendingEffect({name:"clearNextLineConfigTimer"}),Nt("nextLineFromSystem",I.payload))},rp=()=>({renderSequence:n,conditionalRoutingSequence:s,rollbackNavigationContexts:o.slice(),pendingRollbackLineEntrySaveHandoff:l,persistentAnimationSessions:new Map(c),restoredPersistentAnimationSessions:new Map(u),renderPersistentAnimationMetadata:new Map(p),canonicalProjectData:m,localizationPackageId:f}),tp=I=>{n=I.renderSequence,s=I.conditionalRoutingSequence,o=I.rollbackNavigationContexts.slice(),l=I.pendingRollbackLineEntrySaveHandoff,c=new Map(I.persistentAnimationSessions),u=new Map(I.restoredPersistentAnimationSessions),p=new Map(I.renderPersistentAnimationMetadata),m=I.canonicalProjectData,f=I.localizationPackageId},oo=(I,S={})=>E(()=>{let O=rp();try{return t[Vs](()=>{let _,L=t.selectCurrentPointer()?.pointer??null,Y=t.selectRollbackCursor?.()??null,Q=s,ee={pointer:L,rollbackCursor:Y,markCurrentCheckpointTransient:S.rollbackSource==="line",savedCheckpointOccurrences:S.savedCheckpointOccurrences?.slice()??[]};o.push(ee);try{t.beginRollbackActionBatch({source:S.rollbackSource});try{_=I()}finally{t.endRollbackActionBatch({})}ls(_)&&ep(_,L,Q)}finally{o.pop(),(!eo(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 tp(O),_}}),ao=(I,S,O,_={})=>{if(I===zu)return oo(()=>{let L=us(O),Y=zs({[I]:S},L);return lo(Y[I],O,_)},_);Nt(I,S)},np=(I,S)=>{ao(I,S)},us=I=>{if(!I)return{variables:t.selectAllVariables?t.selectAllVariables():void 0,runtime:t.selectRuntime?t.selectRuntime():{}};if(Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".');let{_event:S,...O}=I,_=t.selectAllVariables?t.selectAllVariables():void 0;return{...O,_event:S,variables:_,runtime:t.selectRuntime?t.selectRuntime():{}}},sp=I=>{if(!Ue(I))return{templatePayload:I,literalTargetIds:null};let S=t.selectImageGalleryConfig();if(!Array.isArray(S?.groups))return{templatePayload:I,literalTargetIds:null};let O=typeof I.groupId=="string"?S.groups.find(L=>L.id===I.groupId):void 0;if(!O)return{templatePayload:I,literalTargetIds:null};let _=typeof I.variantId=="string"&&O.variants.some(L=>L.id===I.variantId);return{templatePayload:{...I,groupId:null,..._?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,..._?{variantId:I.variantId}:{}}}},ip=I=>!Ue(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:t.selectMusicRoomConfig()?.tracks?.some(_=>_.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},op=I=>!Ue(I)||typeof I.replayId!="string"?{templatePayload:I,literalTargetIds:null}:t.selectSceneReplayConfig()?.replays?.some(_=>_.id===I.replayId)?{templatePayload:{...I,replayId:null},literalTargetIds:{replayId:I.replayId}}:{templatePayload:I,literalTargetIds:null},ap=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")},lp=(I,S,O)=>{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!==O-1)throw new Error("conditional else branch must be the last branch")},lo=(I,S,O)=>{ap(I);let _=Qr(O);for(let L=0;L<I.branches.length;L+=1){let Y=I.branches[L];lp(Y,L,I.branches.length);let Q=us(S);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!it(Y.when,Q))continue;let Ee=ps(Y.actions,S,O);return ls(Ee)?Zr(_,Ee):_}return _},cp=(I,S)=>({...I??{},_form:S}),up=(I,S,O,_)=>{let L=Nt(I,S),Y=L?.submitted===!0&&L.valid===!0,Q=L?.cancelled===!0;if(!(!Y&&!Q)&&Ue(S.actions))return ps(S.actions,cp(O,L.form),{..._,interactionSource:Zi})},pp=(I,S,O,_)=>{let L=us(O),Y={templatePayload:S,literalTargetIds:null};I===y0?Y=sp(S):I===h0?Y=ip(S):I===g0&&(Y=op(S));let{templatePayload:Q,literalTargetIds:ee}=Y,Le=zs({[I]:Q},L)[I],_r=ee?{...Le,...ee}:Le;if(I===zu)return lo(_r,O,_);let $r=Jr(I,_r,_);if(m0.has(I))return up(I,$r,O,_);Nt(I,$r)},ps=(I,S,O)=>{let _;return Object.entries(I).forEach(([L,Y])=>{let Q=pp(L,Y,S,O);ls(Q)&&(_=Zr(_,Q))}),_},co=(I,S,O={})=>oo(()=>ps(I,S,O),O),fp=I=>{let S=t.selectCurrentPointer()?.pointer;if(I!==S||t.selectActiveInteraction())return;let O=t.selectNextLineConfig();O?.auto?.enabled&&O.auto.trigger==="fromStart"&&t.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:O.auto.delay}})};return{init:v,handleAction:ao,handleInternalAction:np,handleActions:co,selectRenderState:T,prepareRenderState:q,commitRenderState:ae,selectPresentationState:x,selectPresentationChanges:C,selectSectionLineChanges:N,selectSystemState:B,selectAchievements:ne,selectAchievement:ie,selectSaveSlotMap:fe,selectSaveSlot:ve,selectSaveSlotPage:le,selectSaveSlots:fe,selectImageGallery:se,selectMusicRoom:ce,selectSceneReplay:oe,selectIsSceneReplayActive:R,selectRuntime:Z,selectIsChoiceVisible:ge,selectIsFormVisible:K,selectActiveInteraction:xe,selectHasPendingRenderWork:me,handleLineActions:I=>{if(typeof I?.sceneReplayId=="string"){let S=t.selectActiveSceneReplayEntry?.();if(S?.replayId!==I.sceneReplayId||S?.entryId!==I.entryId)return!1}return E(()=>{let S=t.selectCurrentPointer()?.pointer,O=t.selectRollbackCursor?.()??null,_=l,L=jt(S,O),Y=t.selectCurrentLine(),Q=!1;if(Y?.actions){try{co(Y.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:L})}catch(ee){throw l=_,ee}Q=!0}return fp(S),Q})},getNamespace:k}}var no=()=>{let e=0,t=null;return{getElapsed:()=>e,setElapsed:n=>{e=n},addElapsed:n=>{e+=n},getCallback:()=>t,setCallback:n=>{t=n}}},b0=80,w0="music-room:player",Wu=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Gu=(e,t)=>Wu.has(e)&&t?._event?.id===w0,Hu=({engine:e,routeGraphics:t,trackRenderDispatch:n},i)=>{if(e.selectHasPendingRenderWork?.())return;let a=e.prepareRenderState?.(i)??e.selectRenderState(i);n?.(a),t.render(a),e.commitRenderState?.(a)},I0=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:i},a)=>{let r=i?.()??0,s=e.handleLineActions(a);(i?.()??0)===r&&Hu({engine:e,routeGraphics:t,trackRenderDispatch:n},a)},v0=({engine:e,ticker:t,autoTimer:n},i)=>{let a=n.getCallback();a&&t.remove(a),n.setElapsed(0);let r=s=>{n.addElapsed(s.deltaMS);let o=i.delay??1e3;n.getElapsed()>=o&&(t.remove(r),n.setCallback(null),n.setElapsed(0),$t(e,"nextLineFromSystem",{}))};n.setCallback(r),t.add(r)},A0=({ticker:e,autoTimer:t},n)=>{let i=t.getCallback();i&&(e.remove(i),t.setCallback(null)),t.setElapsed(0)},k0=({engine:e,ticker:t,skipTimer:n},i)=>{let a=n.getCallback();a&&t.remove(a),n.setElapsed(0);let r=s=>{n.addElapsed(s.deltaMS);let o=i?.delay??b0;n.getElapsed()>=o&&(n.setElapsed(0),$t(e,"nextLineFromSystem",{}))};n.setCallback(r),t.add(r)},P0=({ticker:e,skipTimer:t},n)=>{let i=t.getCallback();i&&(e.remove(i),t.setCallback(null)),t.setElapsed(0)},x0=({engine:e,ticker:t,nextLineConfigTimerState:n},i)=>{let a=n.getCallback();a&&t.remove(a),n.setElapsed(0);let r=s=>{n.addElapsed(s.deltaMS);let o=i.delay??1e3;n.getElapsed()>=o&&(n.setElapsed(0),$t(e,"nextLineFromSystem",{}),t.remove(r),n.getCallback()===r&&n.setCallback(null))};n.setCallback(r),t.add(r)},E0=({ticker:e,nextLineConfigTimerState:t},n)=>{let i=t.getCallback();i&&(e.remove(i),t.setCallback(null)),t.setElapsed(0)},S0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},O0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},R0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},C0=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},_0=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Xu={render:Hu,saveSlots:S0,saveGlobalDeviceVariables:O0,saveGlobalAccountVariables:R0,saveGlobalRuntime:C0,applyScopedDataUpdates:_0,handleLineActions:I0,startAutoNextTimer:v0,clearAutoNextTimer:A0,startSkipNextTimer:k0,clearSkipNextTimer:P0,nextLineConfigTimer:x0,clearNextLineConfigTimer:E0},$0=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),$t=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},j0=(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(!$0.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},N0=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:i,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:o})=>{let l=no(),c=no(),u=no(),p=s??null,m=Promise.resolve(),d=null,f=null,y=!1,g=0,h=R=>{if(a){a(R);return}console.error("RouteEngine persistence write failed.",R)},w=()=>{if(p)return p;let R=e();return p=Ki({indexedDB:r,namespace:o??R?.getNamespace?.()}),p},b=R=>{m=m.catch(()=>{}).then(()=>{let j=w();return R(j)}).catch(j=>{h(j)})},E=R=>{let j=typeof R?.id=="string"&&R.id.length>0?R.id:null;g+=1,d=j,y=!1},v=()=>g,k=(R={})=>{if(R?.aborted===!0)return!1;let j=typeof R?.id=="string"&&R.id.length>0?R.id:null;return j?j!==d||j===f?!1:(f=j,!0):d!==null||y?!1:(y=!0,!0)},x=(R,j={})=>{if(Gu(R,j)){let Z=Wu.get(R),ge=e();return $t(ge,Z,j?._event),!0}if(R!=="renderComplete"||!k(j))return!1;let M=e();return $t(M,"markLineCompleted",{}),!0},C=new Set(["updateFormField","submitForm","cancelForm"]),N=new Set(["updateVariable"]),P=R=>typeof R?.selectActiveInteraction=="function"?R.selectActiveInteraction():typeof R?.selectIsChoiceVisible=="function"&&R.selectIsChoiceVisible()?{source:"choice"}:null,T=R=>R?._formKey??R?.formKey,q=(R,j)=>T(R)===j?.formKey,ae=(R,j)=>!R||typeof R!="object"||Array.isArray(R)?!1:R._interactionSource===j?.source,B=(R,j)=>ae(R,j)?j.source==="form"?q(R,j):!0:!1,ne=(R,j)=>!R||typeof R!="object"||Array.isArray(R)||j?.source!=="form"?!1:q(R,j),ie=(R={})=>Object.keys(R).some(j=>C.has(j)),fe=(R={},j)=>Object.entries(R).some(([M,Z])=>C.has(M)&&ne(Z,j)),ve=(R={})=>Object.keys(R).length>0&&Object.keys(R).every(j=>N.has(j)),le=(R={},j)=>{let M=R?.actions;return j?.source==="form"?!M||typeof M!="object"||Array.isArray(M)?!1:fe(M,j)?!0:ie(M)?!1:ve(M):B(R,j)?!0:!M||typeof M!="object"||Array.isArray(M)?!1:Object.values(M).some(Z=>B(Z,j))},se=(R,j={})=>{if(!j?.actions)return!1;let M=P(R);return!M||M.source==="choice"?!1:!le(j,M)},ce=({preprocessPayload:R,onEvent:j}={})=>async(M,Z={})=>{if(Gu(M,Z))return x(M,Z),j?.(M,Z);let ge=e();if(se(ge,Z))return j?.(M,Z);let K=await R?.(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,me;K?.bypassChoice===!0?me={bypassChoice:!0}:K?._interactionSource&&(me={interactionSource:K._interactionSource}),me?ge.handleActions(K.actions,xe,me):ge.handleActions(K.actions,xe)}return j?.(M,K)},oe=R=>{let j=e(),M=j0(R),Z=M.some(K=>K.name==="handleLineActions");M.forEach(K=>{if(!Xu[K.name]&&!i)throw new Error(`Unhandled pending effect "${K.name}".`)});let ge={engine:j,routeGraphics:t,ticker:n,autoTimer:l,skipTimer:c,nextLineConfigTimerState:u,trackRenderDispatch:E,getRenderDispatchCount:v,enqueuePersistenceWrite:b};for(let K of M){if(Z&&K.name==="render")continue;let xe=Xu[K.name];if(xe){xe(ge,K.payload);continue}i(K,ge)}};return oe.handleRouteGraphicsEvent=x,oe.createRouteGraphicsEventHandler=ce,oe},D0=N0;var T0=(e,t={})=>{let{resources:n={}}=t;return hi(e,n)};var wI=to;export{Hs as DEFAULT_VISUAL_LAYER,Mr as RENDER_LAYER,Xe as VISUAL_LAYER,D0 as createEffectsHandler,wb as createIndexedDbPersistence,wI as default,Us as formatDate,qf as resolveComputedVariables,T0 as resolveLayoutReferences};
|
|
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};
|