route-engine-js 1.35.0 → 1.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var hp=Object.defineProperty;var gp=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),bp=(e,r)=>{for(var n in r)hp(e,n,{get:r[n],enumerable:!0})};var jc=gp(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});function $c(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}Qo.default=$c;$c.code='require("ajv/dist/runtime/ucs2length").default'});var hi=Symbol.for("immer-nothing"),pi=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 fr(e){return e?gi(e)||Array.isArray(e)||!!e[pi]||!!e.constructor?.[pi]||qt(e)||Vt(e):!1}var Ip=Object.prototype.constructor.toString();function gi(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)===Ip}function As(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 hs(e,r){return Mt(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function bi(e,r,n){let o=Mt(e);o===2?e.set(r,n):o===3?e.add(n):e[r]=n}function wp(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 pr(e){return e.copy_||e.base_}function gs(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=gi(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 ks(e,r=!1){return Ft(e)||he(e)||!fr(e)||(Mt(e)>1&&(e.set=e.add=e.clear=e.delete=vp),Object.freeze(e),r&&Object.entries(e).forEach(([n,o])=>ks(o,!0))),e}function vp(){$e(2)}function Ft(e){return Object.isFrozen(e)}var Ap={};function dr(e){let r=Ap[e];return r||$e(0,e),r}var rt;function Ii(){return rt}function kp(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function fi(e,r){r&&(dr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function bs(e){Is(e),e.drafts_.forEach(Pp),e.drafts_=null}function Is(e){e===rt&&(rt=e.parent_)}function di(e){return rt=kp(rt,e)}function Pp(e){let r=e[Ae];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function mi(e,r){r.unfinalizedDrafts_=r.drafts_.length;let n=r.drafts_[0];return e!==void 0&&e!==n?(n[Ae].modified_&&(bs(r),$e(4)),fr(e)&&(e=Tt(r,e),r.parent_||Lt(r,e)),r.patches_&&dr("Patches").generateReplacementPatches_(n[Ae].base_,e,r.patches_,r.inversePatches_)):e=Tt(r,n,[]),bs(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==hi?e:void 0}function Tt(e,r,n){if(Ft(r))return r;let o=r[Ae];if(!o)return Dt(r,(a,t)=>yi(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)=>yi(e,o,a,i,l,n,s)),Lt(e,a,!1),n&&e.patches_&&dr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function yi(e,r,n,o,a,t,s){if(he(a)){let i=t&&r&&r.type_!==3&&!hs(r.assigned_,o)?t.concat(o):void 0,l=Tt(e,a,i);if(bi(n,o,l),he(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),(!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_&&ks(r,n)}function xp(e,r){let n=Array.isArray(e),o={type_:n?1:0,scope_:r?r.scope_:Ii(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,t=Ps;n&&(a=[o],t=tt);let{revoke:s,proxy:i}=Proxy.revocable(a,t);return o.draft_=i,o.revoke_=s,i}var Ps={get(e,r){if(r===Ae)return e;let n=pr(e);if(!hs(n,r))return Ep(e,n,r);let o=n[r];return e.finalized_||!fr(o)?o:o===ms(e.base_,r)?(ys(e),e.copy_[r]=vs(o,e)):o},has(e,r){return r in pr(e)},ownKeys(e){return Reflect.ownKeys(pr(e))},set(e,r,n){let o=wi(pr(e),r);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=ms(pr(e),r),t=a?.[Ae];if(t&&t.base_===n)return e.copy_[r]=n,e.assigned_[r]=!1,!0;if(wp(n,a)&&(n!==void 0||hs(e.base_,r)))return!0;ys(e),ws(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 ms(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,ys(e),ws(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){let n=pr(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(Ps,(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 Ps.set.call(this,e[0],r,n,e[0])};function ms(e,r){let n=e[Ae];return(n?pr(n):e)[r]}function Ep(e,r,n){let o=wi(r,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function wi(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 ws(e){e.modified_||(e.modified_=!0,e.parent_&&ws(e.parent_))}function ys(e){e.copy_||(e.copy_=gs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Sp=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(fr(r)){let t=di(this),s=vs(r,void 0),i=!0;try{a=n(s),i=!1}finally{i?bs(t):Is(t)}return fi(t,o),mi(a,t)}else if(!r||typeof r!="object"){if(a=n(r),a===void 0&&(a=r),a===hi&&(a=void 0),this.autoFreeze_&&ks(a,!0),o){let t=[],s=[];dr("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){fr(e)||$e(8),he(e)&&(e=er(e));let r=di(this),n=vs(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 fi(o,r),mi(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=dr("Patches").applyPatches_;return he(e)?o(e,r):this.produce(e,a=>o(a,r))}};function vs(e,r){let n=qt(e)?dr("MapSet").proxyMap_(e,r):Vt(e)?dr("MapSet").proxySet_(e,r):xp(e,r);return(r?r.scope_:Ii()).drafts_.push(n),n}function er(e){return he(e)||$e(10,e),vi(e)}function vi(e){if(!fr(e)||Ft(e))return e;let r=e[Ae],n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=gs(e,r.scope_.immer_.useStrictShallowCopy_)}else n=gs(e,!0);return Dt(n,(o,a)=>{bi(n,o,vi(a))}),r&&(r.finalized_=!1),n}var Se=new Sp,xs=Se.produce,z0=Se.produceWithPatches.bind(Se),G0=Se.setAutoFreeze.bind(Se),X0=Se.setUseStrictShallowCopy.bind(Se),W0=Se.applyPatches.bind(Se),H0=Se.createDraft.bind(Se),K0=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"}},we=class extends Error{constructor(r){super(`Render Error: ${r}`),this.name="JemplRenderError"}};var Es=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}')`)},Ai=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 ki=(e,r,n=!1)=>{if(r===null)return new we(`Cannot iterate over null value at '$for ${e}'`);if(r===void 0)return new we(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof r;return n?new we(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new we(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Pi=(e,r)=>{let n=r&&Object.keys(r).length>0?Object.keys(r).join(", "):"no custom functions provided";return new we(`Unknown function '${e}' (${n})`)};var Rp=(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 Cp(e.parts,r,n,o);switch(e.type){case A.FUNCTION:return Ei(e,r,n,o);case A.BINARY:return Si(e,r,n,o);case A.UNARY:return Ri(e,r,n,o);case A.CONDITIONAL:return $p(e,r,n,o);case A.LOOP:return Lp(e,r,n,o);case A.OBJECT:return qp(e,r,n,o);case A.ARRAY:return Vp(e,r,n,o);case A.PARTIAL:return Fp(e,r,n,o);case A.PATH_REFERENCE:return Up(e,r,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},xi=new Map,Op=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=xi.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=Op(l.trim());o.push(...u)}xi.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},Cp=(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("")},Ei=(e,r,n,o)=>{let a=r.functions||r,t=a[e.name];if(!t)throw Pi(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 Si(e,r,n,o);case A.UNARY:return Ri(e,r,n,o);case A.FUNCTION:return Ei(e,r,n,o);default:return X(e,r,n,o)}},Si=(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 we(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof t}`);return a+t;case z.SUBTRACT:if(typeof a!="number"||typeof t!="number")throw new we(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof t}`);return a-t;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ri=(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}`)},_p=(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},$p=(e,r,n,o)=>{let a=_p(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 Oi},jp=(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 I=h.substring(o.length+1),b=u[I];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},Np=(e,r)=>{let n=e.body,o=e.itemVar,a=jp(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},Dp=(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 I=h.substring(i.length+1);!I.includes(".")&&!I.includes("[")?p[y]=c[I]: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 I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=I.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(I,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},Tp=(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},Lp=(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 ki(p,a,c)}if(!e.indexVar){let u=Tp(e,a,e.itemVar);if(u!==null)return u}if(!e.indexVar){let u=Np(e,a);if(u!==null)return u}let t=Dp(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},Mp=(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 I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=pe(I.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},qp=(e,r,n,o)=>{let a=r.functions||r;if(e.whenCondition&&!rr(e.whenCondition,a,n,o))return;let t=Mp(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},Oi={},Vp=(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!==Oi&&s!==void 0&&a.push(s)}return a},Fp=(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 we(`Partial '${a}' is not defined`);let u=o._partialStack||[];if(u.includes(a))throw new we(`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)},Up=(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 we(`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 we(`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 we(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Ss=Rp;var Bp=/\$\{([^}]*)\}/g,Yp=/#\{([^}]*)\}/g,_i=(e,r={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,t=zp(a,r);return{isFunction:!0,type:A.FUNCTION,name:o,args:t}},zp=(e,r={})=>e.trim()?Gp(e).map(o=>Xp(o.trim(),r)):[],Gp=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},Xp=(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=_i(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=mr(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}},$i=/^\w+\(.*\)$/,Wp=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Hp=e=>{if(!(!e||e.trim()===""||$i.test(e))&&Wp.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}"`)},Ci=e=>{let r=e.trim();if($i.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();Hp(n);let o=_i(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}},Rs=(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(Bp)],t=[...n.matchAll(Yp)],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):Ci(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=Ci(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),Di=e=>Object.keys(e),be=e=>e.join("."),tr=(e,r,n)=>{let o=Di(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"?Rs(e,r):typeof e=="object"&&e!==null?Array.isArray(e)?Jp(e,r):Qp(e,r):{type:A.LITERAL,value:e},Kp=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}},Jp=(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=Kp(t),u=Object.keys(l);if(u.length===1&&/^\$for(?::\w+)?\s/.test(u[0])){let c=Ni(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=Ni(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}},Qp=(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 I of l)if(h===I||h.startsWith(I+" ")||h.startsWith(I+"#")){u.push(I);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,I]of Object.entries(m)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),d[b]=I,f=!0}let y=null;if(f&&(y=nr(d,r),y.type===A.OBJECT)){let h=!1;for(let I of y.properties)if(I.value.type===A.VARIABLE||I.value.type===A.INTERPOLATION||I.value.type===A.FUNCTION||I.value.type===A.CONDITIONAL||I.value.type===A.OBJECT&&!I.value.fast||I.value.type===A.ARRAY&&!I.value.fast){h=!0;break}h&&(y.fast=!1)}let g={type:A.PARTIAL,name:c,data:y};return p!==void 0&&(g.whenCondition=ji(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=ji(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=Zp(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=Rs(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},Zp=(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());Es(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{Es(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}},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},Cs={all:z.AND,any:z.OR},ef=new Set(["var","literal","call","not",...Object.keys(Os),...Object.keys(Cs)]),rf=(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},tf=(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}))},nf=(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=Di(e);if(o.length===0)throw new $(`Condition JSON object at '${be(n)}' must contain an operator`);let a=o.filter(s=>ef.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 nf(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 Cs)return tr(e,new Set([t]),n),tf(e[t],t,Cs[t],r,[...n,t]);if(t in Os){tr(e,new Set([t]),n);let s=rf(e[t],t,[...n,t]);return{type:A.BINARY,op:Os[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)}'`)},ji=(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=mr(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=mr(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=mr(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=mr(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(mr(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)}:Ti(e,r)},mr=(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},sf=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}},Ti=(e,r)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return nt(n,r);let a=sf(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}},of=(e,r=!1)=>{let n=r?"$each":"$for";try{Ai(e)}catch(o){if(o instanceof $&&r){let a=o.message.replace(/\$for/g,"$each");throw new $(a.replace("Parse Error: ",""))}throw o}},Ni=(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();of(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=Ti(c,n),y=nr(r,n);return{type:A.LOOP,itemVar:p,indexVar:m,iterable:f,body:y,flatten:s!=="nested"}};var af=(e,r={})=>{let{functions:n={}}=r;return nr(e,n)},Ut=af;var st={};bp(st,{now:()=>lf});var lf=()=>Date.now();var cf=(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 Ss(s,r,{functions:t,partials:i})},yr=cf;var uf=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",pf=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,ff=(e,r)=>{if(uf(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new $("Empty condition expression");return me(e,r)}return ke(e,r)},df=(e,r={},n={})=>{let o=pf(n),a={...st,...o},t=ff(e,a);return!!rr(t,{functions:a,partials:{}},r,{})},$s=df;var Fs=Symbol("runStoreTransaction"),Ts="__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}),Bi=Object.freeze(Object.fromEntries(Object.keys(sr).map(e=>[e,`${Ts}${e}`]))),mf=Object.freeze(Object.fromEntries(Object.entries(Bi).map(([e,r])=>[r,sr[e]]))),Li=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),yf=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"||Li(e,"literal")||Li(e,"var"))return e;if(yf(e)?.startsWith(Ts))throw new Error(`Condition function names beginning with "${Ts}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,t=Bi[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),$s(Yt(e),r,{functions:mf})},hf=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Yi=(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=xs(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,[Fs]:l}},Wt=(e,r)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return xs(o,t=>{a.forEach(s=>{r.forEach(i=>{i(t,s)})})})};var gf=(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),Ls=(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),bf=new Set(["pageSize","groups"]),If=new Set(["id","variants"]),wf=new Set(["id","imageId"]),vf=new Set(["pageSize","tracks"]),Af=new Set(["id","soundId","title","artist","album","description","coverImageId"]),kf=new Set(["pageSize","replays"]),Pf=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),hr=(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(hr(r,bf,"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(hr(a,If,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(hr(l,wf,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(hr(r,vf,"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`);hr(a,Af,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}"`)}},xf=(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(hr(r,kf,"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`);hr(t,Pf,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}"`);xf(c,m,p)}}}},zi=e=>{let r=he(e)?er(e):e;return structuredClone(r)},Ef=({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=Ef({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)}`),Sf=(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},Gi=(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(Sf(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},js=(e,r)=>{let n=e;for(let o of r){if(n==null||!U(n,o))return;n=n[o]}return n},Xi=(e,r={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Gi(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 js(s,t)}return o==="runtime"?js(r.runtime,n.slice(1)):js(r,n)},Wi=(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)`)},Ms=(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`)},Rf=(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)=>(Wi(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=>Rf(e,t)),a},Of=(e,r,n)=>{switch(e){case"var":return Xi(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 Ms(e,r),r.every(o=>!!Xt(o,n));case"or":case"any":return Ms(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 zi(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 Of(o,a,r)},qs=(e,r)=>{if(e===null||typeof e!="object"||U(e,"literal"))return e;if(U(e,"var"))return{literal:Xi(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=>qs(a,r)):qs(o,r)]))},Cf=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return ke(e),it(qs(e,r))},Hi=(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`)},Ns=(e,r,n)=>(Hi(e,r),U(e,"value")?zi(e.value):Xt(e.expr,n)),_f=(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(Cf(i.when,r))return Ns(i,`Computed variable "${n}" branch ${s}`,r)}return Ns(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 Ns(e,`Computed variable "${n}"`,r)},Ki=(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}`)}},$f=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}),jf=new Set(["and","or","all","any"]),Nf=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Df=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Tf=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Lf=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Ji=new WeakMap,Mi=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}"`)},Mf=(e,r,n,o)=>{if(n!==void 0&&n!==r)throw new Error(`Computed variable "${e}" ${o} expected type ${r}, got ${n}`)},Qi=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{let t=`Computed variable "${r}" ${a} var`,[s,i,...l]=Gi(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},Zi=(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 Mi(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 Qi(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 Mi(i)}let l=$f[s];if(l===void 0&&!jf.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?Ms(s,i):Wi(s,i,l);let u=i.map((c,p)=>Zi(c,{variableId:r,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(Df.has(s)&&u.forEach(c=>{if(c!==void 0&&c!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Nf.has(s))return"number";if(Tf.has(s))return"boolean"},qf=(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")){Qi(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=>Lf.has(u));s[l].forEach((u,c)=>{t(u,`${i}.${l}[${c}]`)})};t(e,a)},Ds=(e,{variableId:r,variableConfig:n,variableConfigs:o,dependencies:a,path:t,allowedKeys:s=new Set(["expr","value"])})=>{if(Hi(e,`Computed variable "${r}" ${t}`),zt(e,s,t),U(e,"value")){Ki(r,n.type,e.value);return}let i=Zi(e.expr,{variableId:r,variableConfigs:o,dependencies:a,path:`${t}.expr`});Mf(r,n.type,i,`${t}.expr`)},Vf=(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`);qf(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${u}].when`}),Ds(l,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:`computed.branches[${u}]`,allowedKeys:new Set(["when","expr","value"])})}),Ds(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 Ds(o,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed"}),a},gr=(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,Vf(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 Ji.set(e,a),a},ut=({variables:e={},runtime:r={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=Ji.get(n)??gr(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 I=l.indexOf(g);if(I>=0){let b=[...l.slice(I),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=_f(h.computed,y,g);return Ki(g,h.type,b),Ls(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 I=u.get(g);if(o&&!p&&I!==void 0&&I>c){p=!0;try{for(let b=c+1;b<=I;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},Ff=({variables:e={},runtime:r={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return gr(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=gf(a,o);a.scope==="context"?Ls(r,o,t):Ls(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(", ")}`)},Uf=2,qi=12,ea=(e=Uf)=>{if(!Number.isInteger(e)||e<0||e>qi)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${qi}.`);return e},Bf=(e,r)=>{let n=10**r;return Math.round((e+Number.EPSILON)*n)/n},Gt=e=>typeof e=="number"&&Number.isFinite(e),Us=(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}".`);ea(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 Bf(a(e,0,"current value")/t(n),ea(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 Bs=(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:hf[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])},Yf=(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,zf=(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},Vi=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},Fi=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Ui=(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,Gf=(e,r)=>{let n={},o=Ui(Vi(e),Vi(r)),a=Ui(Fi(e),Fi(r));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},Ys=(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=Gf(e.background,r.background);t&&(n.background=t),a("screen"),a("bgm"),a("voice");let s=Yf(e.dialogue,r.dialogue);s&&(n.dialogue=s);let i=zf(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},zs=(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},Xf=(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},Wf=(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=Xf(r,n);if(o===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "_event".`);return o},Hf={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"])},Kf=(e,r)=>{let n=e[e.length-1];return n?Hf[n]?.has(r)===!0:!1},Vs=(e,r,n=[])=>Array.isArray(e)?e.map(o=>Vs(o,r,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Kf(n,o)?a:Vs(a,r,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Wf(e,r._event):yr(e,r):e,Gs=(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 Vs(e,r)};var re=e=>structuredClone(he(e)?er(e):e),H=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),ra=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},Jf=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"],Xs=["animationName","animationSpeed","loop"],Qf=e=>aa.some(r=>W(e,r)),ca=e=>e?.text&&W(e.text,"content")&&W(e.text,"textStyleId"),ua=e=>W(e,"text"),Zf=(e,r)=>e.resourceId?!0:ca(e)?!r?.text:!1,ed=(e,r)=>{let n={...re(e),...r};return r.text&&e.text&&(n.text={...re(e.text),...re(r.text)}),n},rd=(e,r)=>{if(ua(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!ca(e)&&!r?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},ta=e=>la.some(r=>W(e,r)),na=e=>Xs.some(r=>W(e,r)),td=(e,r,{hasAuthoredTransformId:n=!1}={})=>{if(!r)return e;for(let o of la)!n&&!W(e,o)&&W(r,o)&&(e[o]=r[o]),H(e,o)&&e[o]===void 0&&delete e[o];return e},pa=(e,r,n)=>{let o=e[n];return o?.id===r?.id?o:e.find(a=>a.id===r?.id)},nd=(e,r)=>{if(!r)return e;for(let n of aa)!W(e,n)&&W(r,n)&&(e[n]=r[n]),H(e,n)&&e[n]===void 0&&delete e[n];return e},sd=(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),fa=(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=pa(n,s,i),u=r(s,l),c=Jf(s),p=Qf(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),sd(nd(f,l),l)}).filter(s=>r(s)||s.animations);return{hasValidItems:t.length>0,processedItems:t}},od=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"),id=e=>{let r={},n=!1,o=od(e);return o!==void 0&&(r.name=o,n=!0),da(e)&&(r.sprite=re(e.character.sprite),n=!0),n?r:void 0},sa=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},oa=({dialogueState:e,dialogueAction:r,persistCharacter:n})=>H(r,"persistSprite")?r.persistSprite===!0:H(e,"persistSprite")?e.persistSprite===!0:n&&!H(r,"characterId"),ia=({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},ad=({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]},ld=()=>({}),cd=(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},ud=(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=ta(r.background),l=na(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")||ta(d)||na(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 Xs)!W(m,d)&&W(p,d)&&(m[d]=p[d])}td(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 Xs)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={})},pd=(e,r)=>{if(!r.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 c=e.dialogue.persistCharacter===!0,p=oa({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:c});c||delete e.dialogue.characterId,e.dialogue.character=ia({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&&ad({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=oa({dialogueState:e.dialogue,dialogueAction:r.dialogue,persistCharacter:a});H(r.dialogue,"persistSprite")&&(e.dialogue.persistSprite=t);let s=H(r.dialogue,"characterId"),i=id(r.dialogue),l=da(r.dialogue);s?r.dialogue.characterId?e.dialogue.characterId=r.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let u=ia({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||sa(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)}},fd=(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},dd=(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)}},md=(e,r)=>{if(r.visual){let n=e.visual?.items||[];r.visual.items?.forEach((t,s)=>{rd(t,pa(n,t,s))});let{hasValidItems:o,processedItems:a}=fa(r.visual.items,Zf,n,{hasPatchFn:ua,mergeItemFn:ed});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))},yd=(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}=fa(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},hd=(e,r)=>{r.animation?e.animation=r.animation:e.animation&&delete e.animation},gd=(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},bd=(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},Id=(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},wd=(e,r)=>{if(r.control){if(!r.control.resourceId){delete e.control;return}e.control=r.control}},vd=(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},Ad=(e,r)=>{r.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},br=e=>Wt(ld,[Ad,cd,ud,fd,dd,md,pd,yd,hd,gd,bd,Id,wd,vd])(e);var Lr=(e,r)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=yr(e,r);return n&&typeof n=="object"?e:n};var kd=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"}}),Ir=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:""}),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"}),Ws=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Hs=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Pd=(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]}},wr=e=>Object.fromEntries(Object.entries(kd).map(([r,n])=>{let o=Pd(e,n.source),a=o!==void 0?o:Ir[r]??dt[r];return[r,a]})),or=(e,r)=>wr(e)[r],ya=(e={})=>Object.fromEntries(Ws.map(r=>[r,e[r]??Ir[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}),Ks=Xe.BEHIND_DIALOGUE,Js=Object.freeze(Object.values(Xe).sort((e,r)=>e-r));var xd={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([r,n])=>({id:r,...n})),formatDate:Bs},Ed=/^\$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=Ed.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:xd};return yr(mt(e),r,n)},yo=({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".`)},Sd=({id:e,targetId:r,animation:n,playback:o,animationPath:a="animation"})=>{let t=structuredClone(n);if(yo({animationType:t.type,animationId:e,animationPath:a}),delete t.name,delete t.playback,t.id=e,t.targetId=r,o!==void 0){let s=_d(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?_a(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},Rd=(e,{animationId:r="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return yo({animationType:e.type,animationId:r,animationPath:n}),e.type},Od=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Cd=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},_d=(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},$d=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),Ra=e=>e?.playback?.continuity==="persistent",oo=e=>Array.isArray(e)?e.map(oo):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((r,n)=>(r[n]=oo(e[n]),r),{}),tn=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(oo(r))},Oa=(e=[])=>e.filter(r=>Ra(r)).map(r=>structuredClone(r)),Ca=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,Qs=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((r,n)=>Math.max(r,Ca(n)),0),_a=e=>Math.max(Qs(e?.tween),Qs(e?.prev?.tween),Qs(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)/$d(e),jd=e=>e.some(r=>r?.playback?.loop===!0),ha=({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(tn).filter(Boolean));return e.some(o=>{if(!Ra(o))return!1;let a=tn(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:jd(e)||t&&!r||ha({animationInstances:e,activePersistentAnimations:o})?!0:t?!1:ha({animationInstances:e,activePersistentAnimations:a}),Nd=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(r=>e[r]!==void 0),Dd=(e,r)=>{if(Nd(e))throw new Error(`[${r}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Td=({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?Sd({id:o,targetId:a,animation:s,playback:n,animationPath:t}):null},Ld=(e,{defaultTargetId:r,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return yo({animationType:a.type,animationId:a.id??n,animationPath:o}),a.id??=n,a.targetId??=r,a},ho=({animations:e,transitions:r,defaultTargetId:n,idPrefix:o,animationPathPrefix:a=o})=>{r.forEach((t,s)=>{e.push(Ld(t,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},io=(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},Md=({content:e,path:r,variables:n})=>io(e,r).reduce((o,a)=>{let t=Lr(a.text,{variables:n});return o+`${t??""}`.length},0),ga=(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))},Zt=(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},qd=(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},Vd=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Fd=(e={})=>Vd.some(r=>vr(e,r)),ja=(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"}},rn=({resourceId:e,kind:r})=>{if(e)return r?`bg-cg-background-${r}`:`bg-cg-${e}`},Ud=(e={})=>e.textStyles||{},Bd=(e={})=>e.images||{},Yd=.5,zd=(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]},Na=({id:e,resourceId:r,spritesheet:n,animationName:o,animationSpeed:a,loop:t,transform:s={}}={})=>{let i=zd(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??Yd,loop:t??l.loop??!0}}},Da=({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 Na({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}`)},Gd=(e={})=>e.colors||{},Xd=/^#(?:[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`)},Zs=(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},eo=(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},on=(e,r)=>{if(typeof e!="string"||!Xd.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},ba=(e,r,n)=>{let o=on(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})`},Wd=(e={},r)=>{let n=Ud(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=Zs(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:ba(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=Zs(n.strokeAlpha,"strokeAlpha",r);i.strokeColor=ba(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:on(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${r}"`),alpha:Zs(n.shadow.alpha,"shadow.alpha",r),blur:eo(n.shadow.blur,"blur",r,0,{minimum:0}),offsetX:eo(n.shadow.offsetX,"offsetX",r,2),offsetY:eo(n.shadow.offsetY,"offsetY",r,2)}}return i},ao=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>ao(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]=ao(t,r,gt(n,a)));return e.textStyleId!==void 0&&(Fr(e.textStyleId,n,"textStyleId"),o.textStyle=Wd(r,e.textStyleId)),o},go=(e={},r)=>{let n=Gd(e)?.[r];if(!n)throw new Error(`Color "${r}" not found`);return on(n.hex,`Color "${r}"`)},Ta=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",ro=(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 ${Ta(`${r}.fill`)} instead`)},Hd=(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=go(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 ${Ta("fill")} instead`);ro(e,"hover",n),ro(e,"click",n),ro(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]=Hd(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=go(r,e.colorId)),o},to=(e={},r)=>{let n=Bd(e)?.[r];return n||null},La=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Ia=(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 ${La(`${r}.${o}`)} instead`)},wa=(e,r,n)=>{let o=e[r];e[r]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},lo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>lo(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 ${La(a)} instead`);Ia(e,"hover",n,"src"),Ia(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]=lo(t,r,gt(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){Fr(e.imageId,n,"imageId");let a=to(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"),wa(o,"hover",to(r,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Fr(e.clickImageId,n,"clickImageId"),wa(o,"click",to(r,e.clickImageId)?.fileId??e.clickImageId)),o},bo=(e,r={},n="root")=>lo(bt(ao(e,r,n),r,n),r,n),Ke=bo,Ar=(e=[])=>e.find(r=>r.id==="story"),Kd="#000000",co="bg-cg-background-color",Jd=({resources:e={},background:r={},screen:n})=>r?.colorId===void 0?on(n?.backgroundColor??Kd,"screen.backgroundColor"):go(e,r.colorId),Ma=(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},va=(e={},{includeDefaultAlpha:r=!1}={})=>{let n=Ma(e),o=Qd(e),a={};return(r||n!==void 0)&&(a.alpha=n??1),o&&(a.blur=o),a},Zd=(e={})=>{if(vr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},em=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},qa=(e={})=>{let r=Zd(e),n=em(e),o={};return r!==void 0&&(o.alpha=r),n&&(o.blur=n),o},Vr=(e={})=>qa(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},rm=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],Io=(e={})=>e.text&&vr(e.text,"content")&&vr(e.text,"textStyleId"),Aa=(e={})=>{if(e.resourceId)return e.resourceId;if(Io(e))return"text"},ka=(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,tm=({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=ka(t,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(o,e)};return Object.assign(s,Vr(e)),s},nm=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!Io(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let r of rm)if(vr(e.text,r))throw new Error(`Visual item "${e.id}" text.${r} is reserved for the visual item`)}},sm=({resources:e,background:r,screen:n={width:1920,height:1080},includeOpacity:o=!1})=>{let a={id:co,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Jd({resources:e,background:r,screen:n})};if(o){let t=Ma(r);t!==void 0&&(a.alpha=t)}return a},om=(e={},r)=>r?!!(e.images?.[r]||e.videos?.[r]||e.spritesheets?.[r]||e.layouts?.[r]):!1,Pa=({resources:e={},resourceId:r,colorId:n})=>{let o=ja(e,r);return r&&(o||n===void 0)?{resourceId:r,targetId:rn({resourceId:r,kind:o})}:n!==void 0?{resourceId:co,targetId:co}:{resourceId:void 0,targetId:void 0}},Va=100,ir=Va,im="channel:bgm",am="channel:music-room",lm="music-room:player",cm="channel:voice",um="default",pm=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),ht=(...e)=>e.map(pm).join(":"),nn=(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)})},fm=(e,r)=>e*r/Va,Fa=(e={},r)=>e?.[r]??Ir[r],an=(e={},r,n=ir)=>fm(n,Fa(e,r)),ln=({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},en=(e,r,n,o)=>e[n]!==void 0?e[n]:r[n]!==void 0?r[n]:o,dm=["muted","pan","playbackRate","startAt","endAt"],cn=({id:e,sound:r,resource:n,defaultLoop:o=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:en(r,n,"loop",o),volume:en(r,n,"volume",ir),startDelayMs:en(r,n,"startDelayMs",0)};dm.forEach(s=>{let i=en(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:I,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??I??!1,isLineCompleted:a?.isLineCompleted??l??!1},k=bm({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},xa=100,sn=(e,r)=>{if(Array.isArray(e))return e.map(o=>sn(o,r));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=sn(n[o],r)}),n.type==="text-revealing"?r(n):n},mm=e=>sn(e,r=>({...r,revealEffect:"none"})),ym=e=>sn(e,r=>{let n=Number(r.speed??r.displaySpeed),o=Number.isFinite(n)?Math.max(n,xa):xa;return{...r,speed:o,...Object.prototype.hasOwnProperty.call(r,"displaySpeed")?{displaySpeed:o}:{}}}),ar=(e,{isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>r||o?mm(e):n?ym(e):e,Ua=({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:{}}}}),uo=e=>{if(Array.isArray(e))return e.map(uo);if(!e||typeof e!="object")return e;let r={};for(let[t,s]of Object.entries(e))r[t]=uo(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}}:{}}}}},hm=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Ea="submit",no=(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}}},po=(e,r,n={})=>{if(Array.isArray(e))return e.map(u=>po(u,r,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===Ea,t=o&&n.submitRoleAncestor,s=a||t?{submitRoleAncestor:!0}:{},i={};for(let[u,c]of Object.entries(e))i[u]=po(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:no(l.change,c),submit:no(l.submit,r.submitActions)}}}return l.formRole===Ea||t?{...l,click:no(l.click,r.submitActions,{replaceActions:!0})}:l},fo=(e,r)=>{if(Array.isArray(e))return e.map(o=>fo(o,r));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=fo(a,r);for(let o of hm){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},mo=({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}},Ba=(e=[],r={},n={})=>e.map(o=>{let a=mo({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}}),gm=e=>!(!e||e.mode==="adv"&&e.content===void 0),bm=({dialogueState:e,includeInactiveAdvDialogue:r=!1,characters:n={},variables:o,runtime:a}={})=>{if(!r&&!gm(e))return;let t=e.content===void 0?[{text:""}]:io(e.content,"dialogue.content"),s=e.content===void 0?0:Md({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??Ir.dialogueTextSpeed,l=e.textSpeed??i,u=(e.lines||[]).map((p,m)=>{let d=io(p.content,`dialogue.lines[${m}].content`),f=mo({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=mo({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}},Ya=({container:e,resources:r,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:t=!1})=>{let s=He(e,n);return Ke(ar(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:t}),r)},so=(e,r={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(r),Sa=({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:so(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:so(a.keyup)});return}e[o]={...t,[n]:{payload:so(a)}}})},Im=(e={},r={})=>{let n={};return Sa({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Sa({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:I})=>{let b=Td({resources:r,animationId:d,playback:f,instanceId:h,targetId:I,animationPath:s});b&&l.push(b)},c=n!=null&&n!==!1,p=o!=null&&o!==!1,m=a&&t&&a===t;Dd(e,s);let d=Od(e),f=Cd(e),y=r?.animations?.[d],g=Rd(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`,I=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:I,targetId:t})}return l},wm=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),vm=(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:I,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=qd(a,r.background),T=P||Fd(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=om(a,B),de={...r.background,colorId:ne};if((ne!==void 0||oe)&&N.children.push(sm({resources:a,background:de,screen:t,includeOpacity:!oe})),B){let{images:ue={},videos:ie={},spritesheets:O={}}=a,j=ja(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={...va(r.background,{includeDefaultAlpha:!0}),...We(K,r.background)},ye;ge?ye=Na({id:rn({resourceId:B,kind:j}),resourceId:B,spritesheet:M,animationName:r.background.animationName,animationSpeed:r.background.animationSpeed,loop:r.background.loop,transform:xe}):ye={id:rn({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:rn({resourceId:B,kind:"container"}),type:"container",children:ie.elements,...va(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:I,canRollback:b,form:E,characters:a.characters||{},skipTransitionsAndAnimations:i}));N.children.push(Ke(ar(j,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let ve=Pa({resources:a,resourceId:q,colorId:le}),ce=Pa({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},Am=(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=ga(c),d=ga(p);for(let f=0;f<c.length;f++){let y=c[f],{transformId:g,sprites:h}=y,I=p.find(T=>T.id===y.id),b=p.findIndex(T=>T.id===y.id),E=I?.sprites&&I.sprites.length>0,v=h&&h.length>0,k=b>=0?Zt(I,b,d):void 0,x=Je({animationsDef:y.animations,resources:o,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: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=Zt(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=Da({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},za=(e,r)=>{if(!Js.includes(e))throw new Error(`${r} must be one of: ${Js.join(", ")}.`)},km=(e,r)=>{let n=!!e.resourceId||Io(e),o=e.layer??(n?void 0:r?.layer)??Ks;return za(o,`Visual item "${e.id}" layer`),o},Pm=(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:I=[],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:I,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&&za(b,"visualLayer");for(let P of x){let T=C.find(oe=>oe.id===P.id),q=km(P,T);if(b!==void 0&&q!==b)continue;if(nm(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(tm({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(ar(se,{isLineCompleted:a,skipMode:d,skipTransitionsAndAnimations:t}),o))}}let le=Aa(T),B=Aa(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",xm=(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=Da({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},Em=(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:I,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:I,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(ar(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)}}xm(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},Sm=(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:I,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=uo(Ke(ar(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:I})&&v.push(...C)}return e},Rm=(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:I=[],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:I,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=fo(Ke(ar(po(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},Om=(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 I=Im(h.keyboard,h.keyup);if(I&&Object.keys(I).length>0&&(e.global.keyboard=I),!Array.isArray(h.elements)||h.elements.length===0)return e;let b=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(Ya({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},Cm=(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||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: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(ln({id:im,volume:an(f,"musicVolume",c?ir:u.volume??ir),muted:u.muted,pan:u.pan,loop:c?void 0:u.loop,playback:t?.bgmPlayback,interruption:u.interruption,children:d,runtime:f}))}return e},_m=(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=cn({id:lm,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i});return e.audio.push(ln({id:am,volume:an(l,"musicVolume",ir),children:[u],runtime:l})),e},$m=(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:um,sounds:t.items??[]}]:t.channels;s||nn(i,"SFX channel"),i.forEach(l=>{let u=!s&&l.loop===!0,c=[];if(s||nn(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(cn({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(ln({id:ht("channel","sfx",l.id),volume:an(o,"soundVolume",l.volume??ir),muted:l.muted,pan:l.pan,loop:s?void 0:l.loop,interruption:s?void 0:l.interruption,children:c,runtime:o}))})}return e},jm=(e,r,n)=>{if(!(!r||!n))return e?.voices?.[r]?.[n]},Nm=(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:ir,startDelayMs:i.startDelayMs??0}]:[]:i.sounds,c=!l&&i.loop===!0,p=[];if(l||nn(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=jm(n,o,d.resourceId);if(!f)return;let y=c?{...d,loop:d.loop??!1}:d;p.push(cn({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(ln({id:cm,volume:l?i.volume??Fa(m,"soundVolume"):an(m,"soundVolume",i.volume??ir),muted:i.muted,pan:i.pan,loop:l?void 0:i.loop,interruption:i.interruption,children:p,runtime:m})),e},Dm=(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:I})=>{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&&ho({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(Ya({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:I})&&E.push(...x),e},Tm=(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},Lm=(e,{presentationState:r})=>{let n=Ar(e.elements);return!n||!r?.screen||Object.assign(n,qa(r.screen)),e},Mm=(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:I,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||ho({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,o),T=Te({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:r?.dialogue,isLineCompleted:I,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(ar({...q,children:B},{isLineCompleted:I,skipMode:u,skipTransitionsAndAnimations:b}),n);E.push({...ne,children:le?[le,...ne.children||[]]:ne.children})}),e},qm=(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:I,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&&ho({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,o),N=He(x,Te({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:r?.dialogue,isLineCompleted:I,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(ar({...N,children:T},{isLineCompleted:I,skipMode:c,skipTransitionsAndAnimations:b}),n);return E.push({...q,children:P?[P,...q.children||[]]:q.children}),e},It=e=>(r,n)=>Pm(r,{...n,visualLayer:e}),Vm=It(Xe.BEHIND_BACKGROUND),Fm=It(Xe.BEHIND_CHARACTER),Um=It(Xe.BEHIND_DIALOGUE),Bm=It(Xe.BEHIND_CHOICE),Ym=It(Xe.FOREGROUND),Ga=e=>Wt(wm,[Om,Vm,vm,Fm,Am,Um,Em,Bm,Sm,Rm,Dm,Ym,Lm,Tm,Cm,_m,$m,Nm,Mm,qm])(e);function Xa(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 Wa(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 Ha="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Ka="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Ja="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Qa=65535,wo=40960,un=126976,rl=new Uint8Array(12288),tl=new Uint8Array(3072),nl=new Uint8Array(2816),sl,ol;{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 Xa(Ha,Ka))e(rl,0,a,t,s),e(tl,wo,a,t,s),e(nl,un,a,t,s),t>=65040&&!(a>=un&&t<=129791)&&(r[o]=a,n[o++]=t<<5|s);sl=r.slice(0,o),ol=n.slice(0,o)}function Za(e){return e<12288?rl[e]:e<wo?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-wo]: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,ol)}var il=Uint8Array.from(Ja,Number);function zm(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,r,n){switch(r){case 3:return e&24?n===8204?e&6:(e&24)===16||zm(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 r=e.length;if(r===0)return;let n=e.codePointAt(0),o=n>Qa?2:1,a=Za(n),t=50200>>a&1?el(0,a,n):0,s=0,i=n,l=a;for(;o<r;){n=e.codePointAt(o);let u=n>Qa?2:1,c=Za(n),p=il[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)?el(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*ll(e){for(let r of al(e))yield r.segment}{let e=al("_");il._keep=[e,e.next()]}var cl=1e3,dl=50,Gm=0,ul=100,pl=50,Xm=60,Wm=3,Hm=.5,Km=2e4,Jm=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Qm=/^\s+$/u,fl,Zm=e=>{let r=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(ll(r)):(fl??=new n(void 0,{granularity:"grapheme"}),Array.from(fl.segment(r),({segment:o})=>o))},ey=e=>Zm(e).reduce((r,n)=>Qm.test(n)?r+Hm:Jm.test(n)?r+Wm:r+1,0),ry=e=>2**(((Number.isFinite(e)?Math.min(ul,Math.max(Gm,e)):dl)-pl)/(ul-pl)),ml=({text:e="",baseDelay:r=cl,speed:n=dl}={})=>{let o=Number.isFinite(r)?Math.max(0,r):cl,a=ry(n),t=ey(e)*Xm/a,s=Math.max(o,Km);return Math.min(o+t,s)};var pn={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},vl=1,Po=1,Br="choice",lr="form",At=()=>({manual:{...pn.manual},auto:{...pn.auto},applyMode:pn.applyMode}),xo=()=>({groupId:null,variantId:null,pageIndex:0}),ty="music-room:player",ny=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}),Eo=new Set,sy=new Set(["groupId","variantId"]),oy=new Set(["pageIndex"]),Yr=new Set,iy=new Set(["trackId"]),ay=new Set(["positionMs"]),ly=new Set(["pageIndex"]),So=new Set,cy=new Set(["sceneId"]),uy=new Set(["pageIndex"]),Ro=()=>({pageIndex:0}),Oo=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),yn=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},Al=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:yn(e),operation:r,...n===void 0?{}:{positionMs:n}}),Co=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let r=e.global.musicRoomPlayer,n=r.bgmPlayback;r.trackId!==null&&(n={commandId:yn(e),operation:"resume"}),e.global.musicRoomPlayer=mn({bgmPlayback:n})},kl=(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),Pl=()=>({sections:[],resources:[]}),xl=()=>({sceneIds:[]}),py=e=>V(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Pl(),fy=e=>V(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):xl(),dy=e=>Array.isArray(e)?e.map(r=>r?.text??"").join(""):"",my=({sectionId:e,lineId:r,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:r,content:n,text:dy(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),yy=()=>({resourceId:void 0}),hy=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}},El=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)}}},Sl=e=>{if(typeof e=="number"||typeof e!="string")return e;let r=Number(e);return Number.isFinite(r)?r:e},Rl=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},gy=(e,r={})=>{let n;try{n=Rl(r.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...r,formatVersion:n,slotId:Sl(r.slotId??r.slotKey??e),savedAt:typeof r.savedAt=="number"?r.savedAt:r.date};return delete o.slotKey,delete o.date,o},by=(e={})=>Object.fromEntries(Object.entries(e).map(([r,n])=>[r,gy(r,n)])),Ol=e=>{if(!Array.isArray(e))return;let r=e.filter(({type:n})=>ob(n));return r.length>0?r:void 0},Iy=e=>{!V(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=Po,e.timeline.forEach(r=>{if(!V(r))return;typeof r.returnable!="boolean"&&delete r.returnable;let n=Ol(r.executedActions);if(n){r.executedActions=n;return}delete r.executedActions}))},yl=(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}},wy=(e,r="viewedRegistry")=>{if(e===void 0)return Pl();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=yl(a,"sections",t,r);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,t)=>{let s=yl(a,"resources",t,r);return[s.resourceId,s]})))}},vy=(e,r="accountReplayRegistry")=>{if(e===void 0)return xl();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}))]}},Cl=(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}},_l=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,Ay=(e,r)=>{let{section:n}=Er(e,r?.sectionId);return n?.lines?.find(o=>o.id===r?.lineId)},ky=(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},$l=(e,r,n)=>{if(typeof r?.sectionId!="string")return!1;let{section:o}=Er(e,r.sectionId);return _l({sectionId:r.sectionId,lineId:o?.lines?.[0]?.id},n)},Py=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),Ur={always:"always",maybe:"maybe",never:"never"},xy=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},jl=(e,r)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let o=xy(n);if(o!==Ur.never){if(r(n))return!0;if(o===Ur.always)return!1}}return!1},Nl=e=>jl(e,r=>Object.entries(r?.actions??{}).some(([n,o])=>n==="conditional"?Nl(o):Py.has(n))),Dl=(e,r,n)=>jl(r,o=>Object.entries(o?.actions??{}).some(([a,t])=>a==="sectionTransition"?$l(e,t,n):a==="conditional"?Dl(e,t,n):!1)),Ey=(e,r,n)=>{if(!r)return!0;let o=Ay(n,e)?.actions;if(!V(o))return!0;if($l(n,o.sectionTransition,r))return!1;let a=o.conditional;return a?!(Dl(n,a,r)||!(o.choice?.resourceId||o.form?.resourceId)&&!Nl(a)&&_l(ky(n,e),r)):!0},Sy=(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=Cl(u,n,`rollback.timeline[${c}]`),m=dn({sectionId:p.sectionId,lineId:p.lineId,rollbackPolicy:u.rollbackPolicy,returnable:u.returnable});typeof u.returnable=="boolean"&&o.add(m);let d=Ol(D(u.executedActions));return d&&(m.executedActions=d),[m]}catch{return[]}});if(a.length===0)return vt({pointer:r,replayStartIndex:1});e.returnabilityVersion!==Po&&a.forEach((u,c)=>{!o.has(u)&&!Ey(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(dn({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}},Ry=(e,r,n)=>{if(!V(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=jo(r),a=Cl(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=Fy({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:Sy(e.rollback,a,r)};return s&&(i.runtime=s),i},Oy=(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)=>Ry(n,r,o))}},Cy=(e,r)=>{if(!V(e))throw new Error("Malformed save slot.");let n=Rl(e.formatVersion);return{...e,formatVersion:n,state:Oy(e.state,r)}},hl=(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}},_y=(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)},$y=e=>(V(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Gr=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Tl=e=>{if(!(!V(e)||!e.animations))return{animations:D(e.animations)}},jy=(e,r)=>{let n=Tl(r);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Ny=e=>{let r=e?.id??e?.resourceId;return typeof r=="string"&&r.length>0?r:void 0},Dy=(e,r)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!r))return`${n}:${o}:${r}`},fn=e=>String(e??""),Ll=(e,r)=>{let n=fn(r);return e?.trim===!0?n.trim():n},Ty=e=>V(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,r])=>V(r)).map(([r,n])=>[r,{id:r,...D(n)}])):{},Ly=(e,r)=>{if(!r||!V(e.global.formDrafts))return;let n=e.global.formDrafts[r];return V(n)?n:void 0},Ml=(e,r)=>{let n=$y(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},_o=(e,r)=>{let n=Ll(e,r);return e?.required===!0&&n.length===0?"required":null},My=({state:e,pointer:r})=>{if(!r?.sectionId||!r?.lineId)return{};let o=Ie({state:e},{sectionId:r.sectionId})?.lines||[],a=o.findIndex(t=>t.id===r.lineId);return a<0?{}:br(o.slice(0,a+1).map(t=>t.actions||{}))},qy=({state:e,form:r,pointer:n})=>{if(!r?.resourceId)return null;let o=Ny(r),a=Dy(n,o);if(!o||!a)return null;let t=Ly(e,a),s=Ty(r),i=hn({state:e}),l={},u=[],c={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=fn(i?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(t?.values??{},m)?fn(t.values[m]):f,g=t?.touched?.[m]===!0,h=_o(d,y),I=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:I,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[m]=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=[],gl="line",$o="interaction",dn=({sectionId:e,lineId:r,rollbackPolicy:n,returnable:o})=>({sectionId:e,lineId:r,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{}}),jo=e=>{let r=he(e)?er(e):e,{contextVariableDefaultValues:n}=Kt(r??{});return D(n)},ql=()=>({...D(dt)}),Vl=({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]=Bl(s,D(e[s])),t=!0)}),{runtimeState:a,hasLoadedValues:t}},Vy=({loadedGlobalRuntime:e={}})=>Vl({loadedRuntime:e,runtimeIds:Ws,defaults:Ir,path:"global.runtime"}).runtimeState,Fy=({loadedContextRuntime:e={}})=>{let{runtimeState:r,hasLoadedValues:n}=Vl({loadedRuntime:e,runtimeIds:Hs,defaults:ql(),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},Fl=(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)})},Uy=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)}}),By=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"})},Yy=(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}})},zy=e=>e.runtime?(Hs.forEach(r=>{e.runtime[r]===void 0&&(e.runtime[r]=D(dt[r]))}),e.runtime):(e.runtime=ql(),e.runtime),Gy=e=>ya(e.global),Ul=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Gy(e)}})},Xy=e=>ma[e],Wy=(e,r)=>{let n=Xy(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}"`)},Bl=(e,r)=>{if(Wy(e,r),e==="autoForwardSpeed"&&(r<0||r>100))throw new Error("autoForwardSpeed requires a value between 0 and 100");return e==="saveLoadPagination"?Math.max(1,Math.trunc(r)):r},No=(e,r,n)=>{let o=Bl(r,n);if(r in dt){let a=Xr(e);if(!a)return o;let t=zy(a);return t[r]=o,o}return e.global[r]=o,o},Do=({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:yy(),variables:jo(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,Hy=(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=Do({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Ky(e,{queueRender:r}),a},Ky=(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,Co(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),r&&e.global.pendingEffects.push({name:"render"})},Yl=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?[dn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Sr=(e,r={})=>{if(e?.rollback)return Yl(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},To=(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(dn(r)),o.currentIndex=o.timeline.length-1)},Jy=({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}},Qy=({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)?As(l):l)!==o||l?.sectionId!==a||l?.lineId!==t||(l.returnable=!1),e},Zy=({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)?As(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=Po,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},eh=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)},rh=({state:e},r={})=>{let n=r?.source===gl?gl:$o,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)},th=({state:e})=>(Pr.pop(),e),Be=(e,r,n)=>{let a=Pr[Pr.length-1]?.source??$o;if(!ib(r,a))return;let t=eh(e);t&&(Array.isArray(t.executedActions)||(t.executedActions=[]),t.executedActions.push({type:r,payload:D(n)}))},bl=(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),Us(c,t,s,a,{roundTo:i}),u==="context"&&(n.variables[a]=Qt(n.variables[a],t,s,{roundTo:i}))}},nh=(e,r)=>{Array.isArray(r?.executedActions)&&r.executedActions.forEach(({type:n,payload:o})=>{ab(e,n,o)})},sh=(e,r)=>{let{sectionId:n,lineId:o}=r,s=Ie({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Object.entries(s).forEach(([i,l])=>{Pc(e,i,l)})},zl=(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&&cr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=r;try{n.variables=jo(e.projectData),n.kind==="sceneReplay"&&(Fl(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 t=o.replayStartIndex??0;for(let i=t;i<=r;i++)i>t&&Oo(e),sh(e,o.timeline[i]),nh(e,o.timeline[i]);let s=Wr(n);s.read={sectionId:a.sectionId,lineId:a.lineId},n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Al(e)),e.global.pendingEffects=e.global.pendingEffects.filter(i=>i?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},oh=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;El(r),at(r),lt(r),ct(r),gr(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:wy(s,"accountViewedRegistry"),accountReplayRegistry:vy(i),nextLineConfig:At(),imageGalleryNavigation:xo(),sceneReplayNavigation:Ro(),sceneReplayEntryId:0,audioCommandId:0,musicRoomPlayer:mn(),saveSlots:by(o),localizationPackages:D(l),overlayStack:[],variables:y,...Vy({loadedGlobalRuntime:t})},contexts:[Do({pointer:d,projectData:r})]}},ih=({state:e})=>e.global.overlayStack||[],ah=({state:e})=>e.global.pendingEffects,Gl=({state:e})=>e.global.skipMode,lh=({state:e})=>e.global.autoMode,Xl=({state:e})=>e.global.dialogueUIHidden,Wl=({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=Ie({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:wr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});for(let p of i){let m=p.actions||{};if(u=br([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=my({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},ch=({state:e})=>e.global.confirmDialog??null,xt=({state:e},{pointer:r}={})=>{let n=r??Re({state:e})?.pointer,o=My({state:e,pointer:n});return qy({state:e,form:o.form,pointer:n})},uh=({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:lr,formId:n.id,formKey:n.key};let o=ec({state:e,pointer:r});return o?{source:Br,resourceId:o}:null},ph=({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=Ie({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},Lo=({registry:e},r)=>{let{resourceId:n}=r;return!!(Array.isArray(e?.resources)?e.resources:[]).find(t=>t.resourceId===n)},Mo=({state:e},r)=>ph({state:e,registry:e.global.accountViewedRegistry},r),fh=({state:e},r)=>Lo({registry:e.global.accountViewedRegistry},r),wt=(e,r)=>!Lo({registry:e.global.accountViewedRegistry},{resourceId:r.imageId}),qo=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Vo=(e,r)=>{let n=qo(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},vo=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!wt(e,r[a]))return r[a]},dh=({state:e})=>{let r=e.projectData?.resources?.imageGallery;return r===void 0?void 0:D(r)},Hl=({state:e})=>{let r=e.projectData?.resources?.imageGallery;if(r===void 0)return null;let n=e.global.imageGalleryNavigation??xo(),o=qo(r),a=Vo(r,n),t=a*r.pageSize,s=r.groups.slice(t,t+r.pageSize).map(l=>({groupId:l.id,locked:wt(e,l.variants[0]),variants:l.variants.map(u=>({variantId:u.id,imageId:u.imageId,locked:wt(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&&!wt(e,p)&&(i={groupId:u.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:vo(e,u.variants,c,-1)!==void 0,canMoveToNextVariant:vo(e,u.variants,c,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Fo=(e,r)=>!Lo({registry:e.global.accountViewedRegistry},{resourceId:r.soundId}),Uo=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Bo=(e,r)=>{let n=Uo(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Ao=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!Fo(e,r[a]))return r[a]},Kl=e=>({trackId:e.id,soundId:e.soundId,title:e.title,artist:e.artist??null,album:e.album??null,description:e.description??null,coverImageId:e.coverImageId??null}),mh=(e,r)=>({...Kl(r),locked:Fo(e,r)}),Il=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")}`},yh=({state:e})=>{let r=e.projectData?.resources?.musicRoom;return r===void 0?void 0:D(r)},Jl=({state:e})=>{let r=e.projectData?.resources?.musicRoom;if(r===void 0)return null;let n=e.global.musicRoomPlayer??mn(),o=Uo(r),a=Bo(r,n),t=a*r.pageSize,s=r.tracks.slice(t,t+r.pageSize).map(c=>mh(e,c)),i=r.tracks.findIndex(c=>c.id===n.trackId),l=r.tracks[i],u=l?{...Kl(l),canPlayPreviousTrack:Ao(e,r.tracks,i,-1)!==void 0,canPlayNextTrack:Ao(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:Il(n.positionMs),durationText:n.durationMs===null?null:Il(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}}},Yo=e=>e.replays.length===0?0:Math.ceil(e.replays.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)},hh=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;return r===void 0?void 0:D(r)},gh=({state:e})=>te(e)!==null,bh=({state:e})=>{let r=te(e);return r?{sceneId:r.sceneReplay.sceneId,entryId:r.sceneReplay.entryId}:null},Ql=(e,r)=>e.global.accountReplayRegistry?.sceneIds?.includes(r)===!0,Zl=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;if(r===void 0)return null;let n=e.global.sceneReplayNavigation??Ro(),o=Yo(r),a=zo(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:!Ql(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}}},Ih=({state:e})=>e.global.nextLineConfig,ec=({state:e,pointer:r}={})=>{let n=r??Re({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=Ie({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},rc=({state:e})=>!!ec({state:e}),wh=({state:e})=>structuredClone(e),vh=({state:e})=>D(e.projectData.resources?.achievements??{}),Ah=({state:e},r)=>{let n=e.projectData.resources?.achievements?.[r?.resourceId];return n===void 0?void 0:D(n)},tc=({state:e})=>e.global.saveSlots,kh=({state:e},r)=>{let n=r?.slotId,o=Pt(n);return e.global.saveSlots[o]},nc=({state:e})=>D(e.global.localizationPackages),Go=({state:e})=>wr(e),Ph=({state:e},r)=>or(e,r?.runtimeId),hn=({state:e})=>{let r={...e.global?.variables??{},...Xr(e)?.variables??{}};return ut({variables:r,runtime:wr(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}},Ie=({state:e},r)=>{let{sectionId:n}=r;return Er(e.projectData,n).section},gn=({state:e})=>{let r=Re({state:e});if(!r?.pointer)return;let{sectionId:n,lineId:o}=r.pointer,a=Ie({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(t=>t.id===o)},sc=({state:e})=>{let{sectionId:r,lineId:n}=Re({state:e}).pointer,a=Ie({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 br(i)},xh=e=>{let r=gn({state:e})?.actions?.dialogue;if(r?.clear===!0||!Array.isArray(r?.content))return"";let n=hn({state:e});return r.content.map(o=>`${Lr(o?.text,{variables:n})??""}`).join("")},Hr=({state:e})=>ml({text:xh(e),baseDelay:or(e,"autoForwardDelay"),speed:or(e,"autoForwardSpeed")}),Eh=({state:e})=>{let r=oc({state:e}),o=gn({state:e})?.actions??{},a=br([r??{},o]);return Ys(r??{},a??{})},Sh=({state:e},{sectionId:r})=>{let n=Ie({state:e},{sectionId:r});if(!n?.lines)return[];let o=[],a={};for(let t of n.lines){let s=t.actions||{},i=br([a,s]),l=Ys(a,i);o.push({id:t.id,changes:l,presentationState:i}),a=zs(i)}return o},Rh=({state:e},{sectionId:r,includePresentationState:n=!1})=>{let o=Sh({state:e},{sectionId:r});return n?{lines:o}:{lines:o.map(({presentationState:a,...t})=>t)}},oc=({state:e})=>{let{sectionId:r,lineId:n}=Re({state:e}).pointer,a=Ie({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 zs(br(i))},Xo=({state:e},{slotsPerPage:r=6}={})=>{let a=((Go({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}},Oh=tc,Ch=Xo,_h=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},$h=({state:e},r={})=>{let n=sc({state:e}),o=oc({state:e}),a=gn({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={...Go({state:e}),localizationPackages:nc({state:e})},p=r?.activePersistentAnimations??[],m=r?.restoredPersistentAnimations??[],d=xt({state:e}),f=rc({state:e}),y=Hl({state:e}),g=Jl({state:e}),h=Zl({state:e}),I=hn({state:e}),{saveSlots:b}=Xo({state:e}),E=_h(e);return Ga({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:Sc({state:e}),skipOnlyViewedLines:!c.skipUnseenText,isLineCompleted:c.isLineCompleted,skipTransitionsAndAnimations:!!c.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:Wl({state:e}),saveSlots:b,variables:I,runtime:c,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:D(e.global.musicRoomPlayer)})},jh=({state:e},r)=>(e.global.confirmDialog=_y(r),e.global.pendingEffects.push({name:"render"}),e),Nh=({state:e})=>(e.global.confirmDialog&&(zr(e),e.global.pendingEffects.push({name:"render"})),e),Dh=({state:e},r)=>(e.global.overlayStack.push(r),e.global.pendingEffects.push({name:"render"}),Be(e,"pushOverlay",r),e),Th=({state:e})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),Be(e,"popOverlay",void 0),e),Lh=({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),Mh=({state:e})=>(e.global.overlayStack=[],zr(e),Gr(e),e.global.pendingEffects.push({name:"render"}),Be(e,"clearOverlays",void 0),e),qh=(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,jy(e,n),Gr(e);let o=Pe({state:e},{pointer:r}),a=o?.source===Br,t=o?.source===lr;qh(e,{activeInteraction:o});let s=te(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Al(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}},bn=(e,r,n)=>{!(r?.source===Br||r?.source===lr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},ic=({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),Vh=({state:e})=>{let r=e.global.autoMode;return Pe({state:e})&&!r||(r?St({state:e}):ic({state:e})),e},ac=({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),Fh=({state:e})=>{let r=Gl({state:e});return Pe({state:e})&&!r||(r?cr({state:e}):ac({state:e})),e},In=({state:e})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),Be(e,"showDialogueUI",void 0),e),lc=({state:e})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),Be(e,"hideDialogueUI",void 0),e),Uh=({state:e})=>(Xl({state:e})?In({state:e}):lc({state:e}),e),ur=(e,r,n)=>(No(e,r,n),Ul(e),e.global.pendingEffects.push({name:"render"}),e),Rt=(e,r,n,o)=>{let a=No(e,r,n);return e.global.pendingEffects.push({name:"render"}),Be(e,o,{value:a}),e},Bh=({state:e},r)=>ur(e,"dialogueTextSpeed",r?.value),Yh=({state:e},r)=>ur(e,"autoForwardDelay",r?.value),zh=({state:e},r)=>ur(e,"autoForwardSpeed",r?.value),Gh=({state:e},r)=>ur(e,"skipUnseenText",r?.value),Xh=({state:e},r)=>ur(e,"skipTransitionsAndAnimations",r?.value),Wh=({state:e},r)=>ur(e,"soundVolume",r?.value),Hh=({state:e},r)=>ur(e,"musicVolume",r?.value),Kh=({state:e},r)=>ur(e,"muteAll",r?.value),Jh=({state:e},r)=>Rt(e,"saveLoadPagination",r?.value,"setSaveLoadPagination"),Qh=({state:e})=>{let r=or(e,"saveLoadPagination")+1;return Rt(e,"saveLoadPagination",r,"incrementSaveLoadPagination"),e},Zh=({state:e})=>{let r=or(e,"saveLoadPagination")-1;return Rt(e,"saveLoadPagination",r,"decrementSaveLoadPagination"),e},eg=({state:e},r)=>Rt(e,"menuPage",r?.value,"setMenuPage"),rg=({state:e},r)=>Rt(e,"menuEntryPoint",r?.value,"setMenuEntryPoint"),tg=({state:e})=>(e.global.pendingEffects=[],e),ng=({state:e},r)=>(e.global.pendingEffects.push(r),e),sg=({state:e},r)=>{if(te(e))return e;let n=r?.resourceId;return kl(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},og=({state:e},r)=>{if(te(e))return e;let n=r?.resourceId,o=kl(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},cc=(e,{sectionId:r,resetStoryState:n=!1,screen:o})=>{let a=!!Tl(o),t=Ie({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&&!Hy(e,{queueRender:!a}))return e;let i=Pe({state:e});n&&e.global.skipMode&&cr({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}):To(e,{sectionId:r,lineId:s.id})}let{activeInteraction:u}=Et(e,l?.pointers?.read,{screenTransition:o});return bn(e,i,u),e},ig=({state:e},r)=>{if(te(e))throw new Error("Cannot reset the story while a scene replay is active");return cc(e,{sectionId:r?.sectionId,resetStoryState:!0,screen:r?.screen})},uc=e=>(e.global.accountViewedRegistry=py(e.global.accountViewedRegistry),e.global.accountViewedRegistry),wn=(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)}))}})},pc=(e,r)=>{wn(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:[]}}])},ag=(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=Ie({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;ag(e,uc(e),r)&&pc(e,{sections:[{sectionId:r.sectionId,lastLineId:r.lineId}],resources:[]})},lg=({state:e},r)=>(xr(e,r),e.global.pendingEffects.push({name:"render"}),e),cg=({state:e},r)=>{if(te(e))return e;let{resourceId:n}=r;if(e.global.accountViewedRegistry!==void 0){let o=uc(e);o.resources.find(t=>t.resourceId===n)||(o.resources.push({resourceId:n}),pc(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}"`)})},ko=(e,r,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${r}`)},vn=(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"}))},ug=({state:e},r)=>{let n="showImageGalleryVariant";Ye(n,r,sy),ko(n,"groupId",r.groupId),Object.prototype.hasOwnProperty.call(r,"variantId")&&ko(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||wt(e,s)||vn(e,{groupId:t.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},fc=(e,r,n,o)=>{Ye(o,r,Eo);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=vo(e,s.variants,i,n);return l&&vn(e,{...t,variantId:l.id}),e},pg=({state:e},r)=>fc(e,r,-1,"moveToPreviousImageGalleryVariant"),fg=({state:e},r)=>fc(e,r,1,"moveToNextImageGalleryVariant"),dg=({state:e},r)=>{if(Ye("clearImageGallerySelection",r,Eo),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return vn(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},dc=(e,r)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=qo(n);if(r>=o)return e;let a=e.global.imageGalleryNavigation,t=Vo(n,a);return r===t||vn(e,{groupId:null,variantId:null,pageIndex:r}),e},mg=({state:e},r)=>{if(Ye("moveToImageGalleryPage",r,oy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return dc(e,r.pageIndex)},mc=(e,r,n,o)=>{Ye(o,r,Eo);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Vo(a,e.global.imageGalleryNavigation)+n;return s<0?e:dc(e,s)},yg=({state:e},r)=>mc(e,r,1,"moveToNextImageGalleryPage"),hg=({state:e},r)=>mc(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}"`)})},gg=(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"})},yc=(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:yn(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)},bg=({state:e},r)=>{let n="playMusicRoomTrack";Qe(n,r,iy),gg(n,r.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(t=>t.id===r.trackId);return!a||Fo(e,a)||yc(e,a),e},Ig=({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},wg=({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},vg=({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},Ag=({state:e},r)=>{if(Qe("seekMusicRoom",r,ay),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},hc=(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=Ao(e,a.tracks,s,n);return i&&yc(e,i),e},kg=({state:e},r)=>hc(e,r,-1,"playPreviousMusicRoomTrack"),Pg=({state:e},r)=>hc(e,r,1,"playNextMusicRoomTrack"),xg=({state:e},r)=>{Qe("clearMusicRoomSelection",r,Yr);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,t={commandId:yn(e),operation:"resume"};return e.global.musicRoomPlayer={...mn({bgmPlayback:t}),pageIndex:a},Ve(e),e},gc=(e,r)=>{let n=e.projectData?.resources?.musicRoom;if(!n||r>=Uo(n))return e;let o=e.global.musicRoomPlayer,a=Bo(n,o);return r===a||(o.pageIndex=r,Ve(e)),e},Eg=({state:e},r)=>{if(Qe("moveToMusicRoomPage",r,ly),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return gc(e,r.pageIndex)},bc=(e,r,n,o)=>{Qe(o,r,Yr);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let t=Bo(a,e.global.musicRoomPlayer)+n;return t<0?e:gc(e,t)},Sg=({state:e},r)=>bc(e,r,1,"moveToNextMusicRoomPage"),Rg=({state:e},r)=>bc(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(),Yy(e,n),e.global.pendingEffects.push({name:"render"}),!0},Og=({state:e},r)=>{let n="startSceneReplay";if(Ye(n,r,cy),ko(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||!Ql(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=Uy(e);By(e);let c=Do({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 Fl(e,c),e.contexts.push(c),Et(e,c.pointers.read),e},Ic=({state:e},r)=>{Ye("finishSceneReplay",r,So);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=fy(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),wn(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},Cg=({state:e},r)=>(Ye("exitSceneReplay",r,So),kr(e),e),wc=(e,r)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||r>=Yo(n))return e;let o=zo(n,e.global.sceneReplayNavigation);return r===o||(e.global.sceneReplayNavigation.pageIndex=r,e.global.pendingEffects.push({name:"render"})),e},_g=({state:e},r)=>{if(Ye("moveToSceneReplayPage",r,uy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return wc(e,r.pageIndex)},vc=(e,r,n,o)=>{Ye(o,r,So);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let t=zo(a,e.global.sceneReplayNavigation)+n;return t<0?e:wc(e,t)},$g=({state:e},r)=>vc(e,r,1,"moveToNextSceneReplayPage"),jg=({state:e},r)=>vc(e,r,-1,"moveToPreviousSceneReplayPage"),An=(e,r)=>{let n=e.global.musicRoomPlayer;return!V(r)||r.id!==ty||n.trackId===null||!n.playback||r.commandId!==n.playback.commandId?null:n},Wo=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,Ac=(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),Ng=({state:e},r)=>{let n=An(e,r);return!n||n.readiness!=="loading"||!Wo(r)?e:Ac(e,n,r,{readiness:"ready"})},Dg=({state:e},r)=>{let n=An(e,r);return!n||n.readiness!=="ready"||!Wo(r)||n.status==="stopped"&&r.positionMs!==0||n.status==="ended"&&r.positionMs!==r.durationMs?e:Ac(e,n,r)},Tg=({state:e},r)=>{let n=An(e,r);return!n||n.readiness!=="ready"||n.status!=="playing"||!Wo(r)||r.positionMs!==r.durationMs||(n.status="ended",n.positionMs=r.positionMs,n.durationMs=r.durationMs,n.seekFallback=null,Ve(e)),e},Lg=({state:e},r)=>{let n=An(e,r);if(!n||typeof r.errorCode!="string"||!ny.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},kc=({state:e},r)=>{let n=hy(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},Mg=({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),Yl(u.rollback),Iy(u.rollback)});let i={contexts:s},l={formatVersion:vl,slotId:Sl(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},qg=({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=Cy(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),Co(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},Vg=({state:e},r)=>{if(te(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=r;El(n),at(n),lt(n),ct(n),gr(n?.resources?.variables??{}),e.projectData=n,e.global.imageGalleryNavigation=xo(),e.global.sceneReplayNavigation=Ro(),Co(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},Fg=({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,No(e,"localizationPackageId",n),Ul(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},Ug=({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&&!Ie({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Ie({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 bn(e,l,c),e},Bg=({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===lr&&r?._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=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=Ie({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=!or(e,"skipUnseenText");if(e.global.skipMode&&m&&!Mo({state:e},{sectionId:t,lineId:p.id}))return cr({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}}To(e,{sectionId:t,lineId:p.id}),Oo(e);let{activeInteraction:d}=Et(e,{sectionId:t,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},Yg=({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},zg=({state:e},r)=>cc(e,{sectionId:r?.sectionId,screen:r?.screen}),Gg=({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===lr&&r?._interactionSource!==lr||o&&o.source!==Br&&o.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 t=Re({state:e})?.pointer,s=t?.sectionId,i=Ie({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=!or(e,"skipUnseenText");if(e.global.skipMode&&d&&!Mo({state:e},{sectionId:s,lineId:m.id})&&(cr({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}}To(e,{sectionId:s,lineId:m.id}),Oo(e);let{activeInteraction:f}=Et(e,{sectionId:s,lineId:m.id});bn(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&&cr({state:e}),e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))}return e},Ho=(e,r={})=>{let n=xt({state:e});return!n||r.formKey&&r.formKey!==n.key||r.formId&&r.formId!==n.id?null:n},Xg=(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}},Wg=(e,r)=>({id:e.id,key:e.key,valid:!0,values:D(r),fields:D(e.fields),fieldList:D(e.fieldList)}),Hg=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})},Kg=({state:e},r={})=>{let n=Ho(e,r),o=r.field;if(!n?.fields?.[o])return e;let a=Ml(e,n.key),t=fn(r.value),s=n.fields[o],i=_o(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},Jg=({state:e},r={})=>{let n=Ho(e,r);if(!n)return{submitted:!1,valid:!1,reason:"inactive"};let o=Ml(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=_o(m,d);o.touched[p]=!0,f&&(t[p]=f),a[p]=Ll(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}=Xg(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}),wn(e,l);let c=Wg(n,a);return Hg(e),delete e.global.formDrafts[n.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:c}},Qg=({state:e},r={})=>{let n=Ho(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"}},Zg=({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),Us(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}),wn(e,s),e.global.pendingEffects.push({name:"render"}),e},wl=e=>(r,n)=>e({state:r},n),eb=e=>({variables:ut({variables:{...e.global?.variables??{},...Xr(e)?.variables??{}},runtime:wr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:wr(e)}),rb=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")},tb=(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")},nb=(e,r)=>{rb(r);for(let n=0;n<r.branches.length;n+=1){let o=r.branches[n];if(tb(o,n,r.branches.length),!(Object.prototype.hasOwnProperty.call(o,"when")&&!it(o.when,eb(e)))){Object.entries(o.actions).forEach(([t,s])=>{Pc(e,t,s)});return}}},sb={conditional:{replayLine:nb},updateVariable:{recordSources:[$o],replayLine:bl,replayRecorded:bl,persistInSaveSlot:!0},setNextLineConfig:{replayLine:wl(kc)},finishSceneReplay:{replayLine:wl(Ic)}},kn=e=>sb[e]??null,ob=e=>kn(e)?.persistInSaveSlot===!0,ib=(e,r)=>{let n=kn(e)?.recordSources;return Array.isArray(n)&&n.includes(r)},ab=(e,r,n)=>{kn(r)?.replayRecorded?.(e,n)},Pc=(e,r,n)=>{kn(r)?.replayLine?.(e,n)},lb=e=>e?.returnable!==!1,xc=(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(lb(e.timeline[o])&&(n-=1,n===0))return o;return-1},Ec=({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=xc(a,n);if(t<0||t>=a.timeline.length)return null;let s=a.timeline[t];return{sectionId:s.sectionId,lineId:s.lineId}},Sc=({state:e})=>Ec({state:e},{offset:-1})!==null,cb=({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=xc(a,n);return t<0||t>=a.timeline.length?e:zl(e,t)},ub=({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:zl(e,i)},Rc=e=>{let r=oh(e);return Yi(r,{selectPendingEffects:ah,selectSkipMode:Gl,selectAutoMode:lh,selectIsChoiceVisible:rc,selectIsFormVisible:uh,selectActiveInteraction:Pe,selectActiveForm:xt,selectDialogueUIHidden:Xl,selectDialogueHistory:Wl,selectConfirmDialog:ch,selectIsLineAccountViewed:Mo,selectIsResourceAccountViewed:fh,selectImageGalleryConfig:dh,selectImageGallery:Hl,selectMusicRoomConfig:yh,selectMusicRoom:Jl,selectSceneReplayConfig:hh,selectSceneReplay:Zl,selectIsSceneReplayActive:gh,selectActiveSceneReplayEntry:bh,selectNextLineConfig:Ih,selectSystemState:wh,selectAchievements:vh,selectAchievement:Ah,selectSaveSlotMap:tc,selectSaveSlots:Oh,selectSaveSlot:kh,selectLocalizationPackages:nc,selectRuntime:Go,selectRuntimeValue:Ph,selectAllVariables:hn,selectCurrentPointer:Re,selectSection:Ie,selectCurrentLine:gn,selectPresentationState:sc,selectAutoForwardTimerDelay:Hr,selectPresentationChanges:Eh,selectSectionLineChanges:Rh,selectSaveSlotPage:Xo,selectCurrentPageSlots:Ch,selectRenderState:$h,selectOverlayStack:ih,selectLineIdByOffset:Ec,selectCanRollback:Sc,selectRollbackCursor:Jy,startAutoMode:ic,stopAutoMode:St,toggleAutoMode:Vh,startSkipMode:ac,stopSkipMode:cr,toggleSkipMode:Fh,showDialogueUI:In,hideDialogueUI:lc,toggleDialogueUI:Uh,setDialogueTextSpeed:Bh,setAutoForwardDelay:Yh,setAutoForwardSpeed:zh,setSkipUnseenText:Gh,setSkipTransitionsAndAnimations:Xh,setSoundVolume:Wh,setMusicVolume:Hh,setMuteAll:Kh,setSaveLoadPagination:Jh,incrementSaveLoadPagination:Qh,decrementSaveLoadPagination:Zh,setMenuPage:eg,setMenuEntryPoint:rg,showConfirmDialog:jh,hideConfirmDialog:Nh,resetStoryAtSection:ig,clearPendingEffects:tg,appendPendingEffect:ng,completeAchievement:sg,setAchievementProgress:og,beginRollbackActionBatch:rh,endRollbackActionBatch:th,markRollbackCheckpointTransient:Qy,markSavedRollbackCheckpointTransient:Zy,addViewedLine:lg,addViewedResource:cg,showImageGalleryVariant:ug,moveToPreviousImageGalleryVariant:pg,moveToNextImageGalleryVariant:fg,clearImageGallerySelection:dg,moveToImageGalleryPage:mg,moveToNextImageGalleryPage:yg,moveToPreviousImageGalleryPage:hg,playMusicRoomTrack:bg,playMusicRoom:Ig,pauseMusicRoom:wg,stopMusicRoom:vg,seekMusicRoom:Ag,playPreviousMusicRoomTrack:kg,playNextMusicRoomTrack:Pg,clearMusicRoomSelection:xg,moveToMusicRoomPage:Eg,moveToNextMusicRoomPage:Sg,moveToPreviousMusicRoomPage:Rg,musicRoomSoundReady:Ng,musicRoomSoundProgress:Dg,musicRoomSoundComplete:Tg,musicRoomSoundError:Lg,startSceneReplay:Og,finishSceneReplay:Ic,exitSceneReplay:Cg,moveToSceneReplayPage:_g,moveToNextSceneReplayPage:$g,moveToPreviousSceneReplayPage:jg,setNextLineConfig:kc,saveSlot:Mg,loadSlot:qg,updateProjectData:Vg,updateLocalizationPackage:Fg,sectionTransition:zg,jumpToLine:Ug,nextLine:Bg,markLineCompleted:Yg,rollbackToLine:ub,rollbackByOffset:cb,pushOverlay:Dh,popOverlay:Th,replaceLastOverlay:Lh,clearOverlays:Mh,updateFormField:Kg,submitForm:Jg,cancelForm:Qg,updateVariable:Zg,nextLineFromSystem:Gg},{transformActionFirstArgument:o=>({state:o}),transformSelectorFirstArgument:o=>({state:o})})};var pb="route-engine",fb="projectPersistence";var Cc=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),ae=e=>Object.prototype.toString.call(e)==="[object Object]",Oc="variables.",db=(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)}},mb=(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)}},yb=(e,r)=>{let n=mb(e),o=db(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}},hb=(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))]}},gb=(e,r)=>{let n=hb(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)])]}},_c=(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:{}}},bb=(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(Oc)?r.path.slice(Oc.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}].`)})},Ib=(e,r)=>{let n={};return bb(r).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=yb(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=gb(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},Ko=e=>{if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null},wb=e=>{let r=Ko(e);if(!r)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return r},vb=e=>{let r=e??globalThis.indexedDB;if(!r)throw new Error("IndexedDB is not available in this environment.");return r},Ab=({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}".`))}}),kb=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=_c(u.result),f=typeof o=="function"?o(d):o,y={namespace:n,version:1,...Cc(),...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}".`))}})},Pb=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}".`))}})},Jo=(e={})=>{let{indexedDB:r,databaseName:n=pb,objectStoreName:o=fb,namespace:a}=e,t=vb(r),s=wb(a),i=Ab({indexedDB:t,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await kb({databasePromise:i,objectStoreName:o,namespace:s});return{...Cc(),..._c(l)}},clear:async()=>Pb({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=>Ib(u,l)})}},xb=Jo;var qc=Vc;var Eb={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,Sb={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:Sb.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 Rb={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function xn(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:Rb.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 xn.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&&(xn(e.playback,{instancePath:r+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(t=t===null?xn.errors:t.concat(xn.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 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(!Ze.call(Eb.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 En.errors=t,s===0}function Vc(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return En(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?En.errors:t.concat(En.errors),s=t.length),Vc.errors=t,s===0}var Fc=Uc;var Ob={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},Nc={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=jc().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(Nc.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:Nc.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 Sn(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:Ob.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 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 Cb={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 Rn(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(Cb.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 I=y[h];if(I&&typeof I=="object"&&!Array.isArray(I)){for(let b in I)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let 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(I.id!==void 0&&typeof I.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(I.resourceId!==void 0&&typeof I.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(I.animationName!==void 0&&typeof I.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(I.animationSpeed!==void 0&&typeof I.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(I.loop!==void 0&&typeof I.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 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;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 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 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!=="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 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)){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 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;var Dc={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: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(Dc.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:Dc.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 $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;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(!(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 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==="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 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==="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 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;var _b={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 Tn(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:_b.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 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 Tc={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 Ln(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 Ln.errors=t,s===0}function Mn(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 I;if(e.id===void 0&&(I="id")){let b={};t===null?t=[b]:t.push(b),s++}}var m=p===s;if(c=c||m,!c){let I=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=I===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 us;if(e.animations===void 0&&(us="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 I={};t===null?t=[I]:t.push(I),s++}var d=l===s;if(d){let I={instancePath:r,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[I]:t.push(I),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 I={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};t===null?t=[I]:t.push(I),s++}var h=g===s;if(y=y||h,!y){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let 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=I===s;y=y||h}if(y)s=f,t!==null&&(f?t.length=f:t=null);else{let I={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[I]:t.push(I),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Ln(e.content,{instancePath:r+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(t=t===null?Ln.errors:t.concat(Ln.errors),s=t.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let I={instancePath:r+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[I]:t.push(I),s++}if(e.width!==void 0&&typeof e.width!="number"){let I={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[I]:t.push(I),s++}if(e.height!==void 0&&typeof e.height!="number"){let I={instancePath:r+"/height",schemaPath:"#/properties/height/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 Mn.errors=t,s===0}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)){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(Tc.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&&(Mn(p.text,{instancePath:r+"/items/"+c+"/text",parentData:p,parentDataProperty:"text",rootData:a})||(t=t===null?Mn.errors:t.concat(Mn.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:Tc.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 qn.errors=t,s===0}function lu(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),lu.errors=t,s===0}var cu=uu;var $b={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 Vn(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 I={};t===null?t=[I]:t.push(I),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 I={};t===null?t=[I]:t.push(I),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 I={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};t===null?t=[I]:t.push(I),s++}if(e.sounds!==void 0){let h=e.sounds;if(Array.isArray(h)){let I=h.length;for(let b=0;b<I;b++)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 I={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[I]:t.push(I),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 I={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[I]:t.push(I),s++}if(h<0||isNaN(h)){let I={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[I]:t.push(I),s++}}else{let I={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[I]:t.push(I),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 I={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[I]:t.push(I),s++}if(h<-1||isNaN(h)){let I={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[I]:t.push(I),s++}}else{let I={instancePath:r+"/pan",schemaPath:"#/properties/pan/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 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 I={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[I]:t.push(I),s++}if(!(h==="immediate"||h==="loopEnd")){let I={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=[I]:t.push(I),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let I={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[I]:t.push(I),s++}}else{let I={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[I]:t.push(I),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 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 jb={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 Fn(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 I={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};t===null?t=[I]:t.push(I),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,I=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=I===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:jb.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 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 Nb={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 Db={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:Db.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 Un(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 Un.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==="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 Bn.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&&(Bn(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Bn.errors:t.concat(Bn.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 Pn={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"]}}]},Tb={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};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(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:Tb.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 Yn.errors=t,s===0}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.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 zn.errors=t,s===0}function Gn(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 I=h===s;if(s=y,t!==null&&(y?t.length=y:t=null),I){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 I=b===s;g=I}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(Pn.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:Pn.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++)Yn(b[v],{instancePath:r+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(t=t===null?Yn.errors:t.concat(Yn.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:Pn.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:Pn.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&&(zn(e.progress,{instancePath:r+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(t=t===null?zn.errors:t.concat(zn.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 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.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 I=C===s;if(x=x||I,!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 I=P===s;if(x=x||I,!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 I=q===s;x=x||I}}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:Nb.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&&(Un(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Un.errors:t.concat(Un.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&&(Gn(e.mask,{instancePath:r+"/mask",parentData:e,parentDataProperty:"mask",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 mu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Xn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Xn.errors:t.concat(Xn.errors),s=t.length),mu.errors=t,s===0}var yu=hu;function Wn(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 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;var Lb=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");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)){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(!Lb.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 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 Iu=wu;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.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 Kn.errors=t,s===0}function wu(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),wu.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.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 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++}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 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.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 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,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 I=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=I===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 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;var Lc={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 rs(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(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.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:Lc.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 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 Mb=new RegExp("^.+$","u");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++}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(Mb.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 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 Mc={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 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.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(Mc.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 I=l[h];if(typeof I=="string"){if(Ce(I)<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 I=l[y];if(typeof I=="string"){if(typeof h[I]=="number"){g=h[I];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[I]=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:Mc.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 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 qb={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 ss(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(qb.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 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;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)){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 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 as=(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),Vb=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"}),Fb=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Ub=Object.freeze({background:qc,bgm:Fc,character:Bc,choice:zc,cleanAll:Xc,control:Hc,dialogue:Jc,form:Zc,layout:ru,screen:nu,sfx:ou,visual:au,voice:cu}),Bb=Object.freeze({achievement:pu,animation:du,character:yu,color:gu,control:Iu,font:vu,image:ku,layout:xu,particle:Su,sound:Ou,spritesheet:_u,textStyle:ju,transform:Du,video:Lu}),Yb=new Set(["files","language","patches"]),zb=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Gb=new Set(["lineId","mode","payload","type"]),Xb=new Set(["mode","payload","sceneId","type"]),Wb=new Set(["mode","operation","payload","resourceId","type"]),Hb=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")},Zo=(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")},Fu=(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)as(e,o)||F(n,`missing required field "${o}"`)},Kb=e=>e.replaceAll("~1","/").replaceAll("~0","~"),Jb=(e,r)=>{let n=(r?.instancePath??"").split("/").slice(1).map(Kb);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)},Qb=(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],Uu=({value:e,validator:r,path:n,contract:o})=>{if(r(e))return;let a=Qb(r.errors);F(Jb(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`)},Zb=(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]))},is=(e,r=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>is(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),is(a,r,n);return r},e0=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},Bu=(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]},Yu=(e,r)=>e.story.scenes[r.sceneId].sections[r.sectionId].lines[r.lineIndex],qu=e=>({items:(e?.items??[]).map(r=>({id:r?.id,events:r?.events}))}),Vu=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},r0=(e,r,n,o)=>{e==="choice"&&!Ct(qu(r),qu(n))&&F(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Ct(Vu(r),Vu(n))&&F(o,"form behavior must remain identical; only presentation fields and placeholders may change")},t0=({patch:e,path:r,lineIndex:n})=>{ze(e,zb,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"'),Fb.has(e.actionType)||F(`${r}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=Bu(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"]'),as(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"),r0(e.actionType,a,e.payload,`${r}.payload`),Uu({value:e.payload,validator:Ub[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}},n0=(e,r)=>{Zo(e,r),e.forEach((n,o)=>{Fe(n,`${r}[${o}]`),ze(n,new Set(["text"]),`${r}[${o}]`),Ge(n,["text"],`${r}[${o}]`),Fu(n.text,`${r}[${o}].text`)})},s0=({patch:e,path:r,lineIndex:n})=>{ze(e,Gb,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`),n0(e.payload.content,`${r}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&F(`${r}.mode`,'line.dialogue supports only "replace"');let o=Bu(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}},o0=({patch:e,path:r,projectData:n})=>(ze(e,Xb,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`),Fu(e.payload.name,`${r}.payload.name`),e.mode!=="patch"&&F(`${r}.mode`,'story.scene requires "patch"'),as(n?.story?.scenes??{},e.sceneId)||F(`${r}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),i0=(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"),Uu({value:r,validator:Bb[e],path:n,contract:`the resource.${e} schema`})},a0=({patch:e,path:r,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{ze(e,Wb,r),Ge(e,["type","resourceId","payload"],r),Jr(e.resourceId,`${r}.resourceId`);let t=e.type.slice(9),s=Vb[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"'),i0(t,e.payload,`${r}.payload`);let i=n?.resources?.[s]??{},l=as(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 is(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}},l0=({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 t0({patch:e,path:r,lineIndex:o});if(e.type==="line.dialogue")return s0({patch:e,path:r,lineIndex:o});if(e.type==="story.scene")return o0({patch:e,path:r,projectData:n});if(e.type.startsWith("resource."))return a0({patch:e,path:r,projectData:n,packageFileIds:a,canonicalFileIds:t});F(`${r}.type`,`unsupported patch type "${e.type}"`)},c0=(e,r)=>{Zo(e,r);let n=new Set;return e.forEach((o,a)=>{let t=`${r}[${a}]`;Fe(o,t),ze(o,Hb,t),Ge(o,["fileId"],t),Zb(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},u0=({packageId:e,packageData:r,path:n,projectData:o,lineIndex:a,canonicalFileIds:t})=>{Fe(r,n),ze(r,Yb,n),Ge(r,["language","files","patches"],n),Kr(r.language,`${n}.language`);let s=c0(r.files,`${n}.files`);Zo(r.patches,`${n}.patches`);let i=new Set,l=r.patches.map((u,c)=>{let p=l0({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}},zu=({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=e0(e),o=is(e?.resources??{}),a=new Map,t=new Map;for(let[s,i]of Object.entries(r.packages)){Jr(s,`l10nData.packages.${s}`);let l=u0({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}},p0=(e,r)=>{let{collectionName:n,patch:o}=r;e.resources[n]??={},e.resources[n][o.resourceId]=Cr(o.payload)},f0=(e,r)=>{let{patch:n}=r,o=e.story.scenes[n.sceneId];o.name=n.payload.name},d0=(e,r)=>{let{location:n,patch:o}=r,a=Yu(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)},m0=(e,r)=>{let{location:n,patch:o}=r,a=Yu(e,n);a.actions.dialogue.content=Cr(o.payload.content)},Gu=({projectData:e,l10nData:r})=>{let n=zu({projectData:e,l10nData:r});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},ls=({projectData:e,l10nData:r,l10nId:n=null})=>{let o=zu({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=>p0(a,s)),t.filter(s=>s.kind==="story.scene").forEach(s=>f0(a,s)),t.filter(s=>s.kind==="line.action").forEach(s=>d0(a,s)),t.filter(s=>s.kind==="line.dialogue").forEach(s=>m0(a,s)),a};var y0=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),h0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Xu="conditional",ti=Symbol("conditionalAutoContinue"),g0=new Set(["sectionTransition","resetStoryAtSection"]),b0=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),I0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),ei="form",w0=new Set(["submitForm","cancelForm"]),v0="showImageGalleryVariant",A0="playMusicRoomTrack",k0="startSceneReplay",Ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),cs=e=>e?.type===ti,ri=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId;function ni(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=(w=new Map,S=Date.now())=>new Map(Array.from(w.entries()).filter(([,R])=>S<R.expiresAt).map(([R,_])=>[R,{animation:structuredClone(_.animation),startedAt:_.startedAt,expiresAt:_.expiresAt}])),h=(w=new Map)=>Array.from(w.values()).map(S=>structuredClone(S.animation)),I=(w=Date.now())=>{u=new Map(Array.from(u.entries()).filter(([,S])=>w<S.expiresAt))},b=()=>{if(!(a>0||t)){t=!0;try{for(;r.selectPendingEffects().length>0;){let w=[...r.selectPendingEffects()];r.clearPendingEffects();try{y(w)}catch(S){throw r.clearPendingEffects(),w.forEach(R=>{r.appendPendingEffect(R)}),S}}}finally{t=!1}}},E=w=>{a+=1;let S=!1;try{let R=w();return S=!0,R}finally{a-=1,S&&b()}},v=({initialState:w,namespace:S})=>{let{l10nData:R,..._}=w,L=R===void 0?void 0:structuredClone(R),Y=structuredClone(w.projectData),Q=Gu({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:ds})=>ds).filter(ds=>ds!==null)),$r=typeof Le=="string"&&_r.has(Le)?Le:null,yp=ls({projectData:Y,l10nData:L,l10nId:$r});r=Rc({..._,global:{...ee,localizationPackages:Q,runtime:{...Ee,localizationPackageId:$r}},projectData:yp}),n=0,o=Ko(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=w=>r.selectSectionLineChanges(w),P=(w={})=>{n+=1;let S=Date.now();I(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=(w={})=>P(w),q=(w={})=>P(w),le=w=>{let S=typeof w?.id=="string"&&w.id.length>0?w.id:null,R=S?p.get(S):null;S&&p.delete(S);let _=new Map;Oa(w?.animations).forEach(L=>{let Y=tn(L);if(!Y)return;let Q=R?.persistentAnimationSessions?.get(Y)??u.get(Y),ee=Math.max(0,$a(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=w=>r.selectAchievement(w),de=()=>r.selectSaveSlotMap(),ve=w=>r.selectSaveSlot(w),ce=w=>r.selectSaveSlotPage(w),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(w=>w?.name==="handleLineActions"||w?.name==="render"),Qr=(w,S,R={})=>!Ue(S)||w!=="nextLine"?S:R.bypassChoice===!0?{...S,bypassChoice:!0}:R.interactionSource===ei?{...S,_interactionSource:ei}:S,Zr=(w={})=>({type:ti,payload:Qr("nextLine",{_conditionalContinuation:!0},w)}),et=(w,S)=>cs(w)?{type:ti,payload:{...w.payload,...S.payload}}:S,us=w=>{w.savedCheckpointOccurrences.forEach(S=>{r.markSavedRollbackCheckpointTransient(S)}),w.savedCheckpointOccurrences=[]},jt=(w,S)=>{let R=l;return l=null,!R||!ri(R.pointer,w)||R.checkpointIndex!==S?.checkpointIndex||R.checkpointIdentity!==S?.checkpoint?[]:R.savedCheckpointOccurrences},oi=w=>{w.markCurrentCheckpointTransient&&(r.markRollbackCheckpointTransient({checkpointIndex:w.rollbackCursor?.checkpointIndex,checkpointIdentity:w.rollbackCursor?.checkpoint,sectionId:w.pointer?.sectionId,lineId:w.pointer?.lineId}),us(w))},Qu=(w,S,R)=>b0.has(w)?w==="resetStoryAtSection"?R?.checkpoint!==S?.checkpoint:R?.checkpoint!==S?.checkpoint&&R?.checkpointIndex>S?.checkpointIndex:!1,Zu=w=>{let S=i.at(-1);if(!S?.markCurrentCheckpointTransient)return;let R=r.selectSaveSlot({slotId:w?.slotId});R&&S.savedCheckpointOccurrences.push({slotId:w.slotId,saveSlotIdentity:R,checkpointIndex:S.rollbackCursor?.checkpointIndex,sectionId:S.pointer?.sectionId,lineId:S.pointer?.lineId})},ep=(w,S,R)=>{let _=i.at(-1);if(!_)return;let L=r.selectCurrentPointer()?.pointer,Y=Qu(w,S,R);if(ri(_.pointer,L)){let Q=R?.checkpoint!==S?.checkpoint||R?.checkpointIndex!==S?.checkpointIndex;(Y||Q&&I0.has(w))&&(oi(_),_.pointer=L,_.rollbackCursor=R,_.markCurrentCheckpointTransient=Y,_.savedCheckpointOccurrences=[]);return}oi(_),_.pointer=L,_.rollbackCursor=r.selectRollbackCursor?.()??null,_.markCurrentCheckpointTransient=Y,_.savedCheckpointOccurrences=[]},Nt=(w,S)=>{if(!r[w])return;let R=S,_,L;if(w==="updateProjectData")ii(S),_=structuredClone(S.projectData),R={...S,projectData:ls({projectData:_,l10nData:d,l10nId:f})},ii(R);else if(w==="updateLocalizationPackage"){if(L=rp(S),L===f)return;R={l10nId:L,projectData:ls({projectData:m,l10nData:d,l10nId:L})}}g0.has(w)&&(s+=1);let Y=r.selectIsSceneReplayActive?.()===!0,Q=h0.has(w)?g(u):null,ee=r.selectRollbackCursor?.()??null,Ee=r[w](R);_!==void 0&&(m=_),L!==void 0&&(f=L),y0.has(w)&&(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 w==="saveSlot"&&Zu(S),ep(w,ee,_r),b(),Ee},ii=w=>{if(!Object.prototype.hasOwnProperty.call(w??{},"projectData"))throw new Error("updateProjectData requires projectData");gr(w?.projectData?.resources?.variables??{}),at(w.projectData),lt(w.projectData),ct(w.projectData)},rp=w=>{if(!Ue(w))throw new Error("updateLocalizationPackage requires an object payload");let S=Object.keys(w);if(S.length!==1||S[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(w.l10nId!==null&&(typeof w.l10nId!="string"||w.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return w.l10nId},tp=(w,S,R)=>{let _=r.selectCurrentPointer()?.pointer;S!==_||R!==s||(r.appendPendingEffect({name:"clearAutoNextTimer"}),r.appendPendingEffect({name:"clearNextLineConfigTimer"}),Nt("nextLineFromSystem",w.payload))},np=()=>({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}),sp=w=>{n=w.renderSequence,s=w.conditionalRoutingSequence,i=w.rollbackNavigationContexts.slice(),l=w.pendingRollbackLineEntrySaveHandoff,u=new Map(w.persistentAnimationSessions),c=new Map(w.restoredPersistentAnimationSessions),p=new Map(w.renderPersistentAnimationMetadata),m=w.canonicalProjectData,f=w.localizationPackageId},ai=(w,S={})=>E(()=>{let R=np();try{return r[Fs](()=>{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{_=w()}finally{r.endRollbackActionBatch({})}cs(_)&&tp(_,L,Q)}finally{i.pop(),(!ri(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 sp(R),_}}),li=(w,S,R,_={})=>{if(w===Xu)return ai(()=>{let L=ps(R),Y=Gs({[w]:S},L);return ci(Y[w],R,_)},_);Nt(w,S)},op=(w,S)=>{li(w,S)},ps=w=>{if(!w)return{variables:r.selectAllVariables?r.selectAllVariables():void 0,runtime:r.selectRuntime?r.selectRuntime():{}};if(Object.prototype.hasOwnProperty.call(w,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".');let{_event:S,...R}=w,_=r.selectAllVariables?r.selectAllVariables():void 0;return{...R,_event:S,variables:_,runtime:r.selectRuntime?r.selectRuntime():{}}},ip=w=>{if(!Ue(w))return{templatePayload:w,literalTargetIds:null};let S=r.selectImageGalleryConfig();if(!Array.isArray(S?.groups))return{templatePayload:w,literalTargetIds:null};let R=typeof w.groupId=="string"?S.groups.find(L=>L.id===w.groupId):void 0;if(!R)return{templatePayload:w,literalTargetIds:null};let _=typeof w.variantId=="string"&&R.variants.some(L=>L.id===w.variantId);return{templatePayload:{...w,groupId:null,..._?{variantId:null}:{}},literalTargetIds:{groupId:w.groupId,..._?{variantId:w.variantId}:{}}}},ap=w=>!Ue(w)||typeof w.trackId!="string"?{templatePayload:w,literalTargetIds:null}:r.selectMusicRoomConfig()?.tracks?.some(_=>_.id===w.trackId)?{templatePayload:{...w,trackId:null},literalTargetIds:{trackId:w.trackId}}:{templatePayload:w,literalTargetIds:null},lp=w=>!Ue(w)||typeof w.sceneId!="string"?{templatePayload:w,literalTargetIds:null}:r.selectSceneReplayConfig()?.replays?.some(_=>_.sceneId===w.sceneId)?{templatePayload:{...w,sceneId:null},literalTargetIds:{sceneId:w.sceneId}}:{templatePayload:w,literalTargetIds:null},cp=w=>{if(!Ue(w))throw new Error("conditional action payload must be an object");if(!Array.isArray(w.branches))throw new Error("conditional action requires branches array");if(w.branches.length===0)throw new Error("conditional action requires at least one branch")},up=(w,S,R)=>{if(!Ue(w))throw new Error(`conditional branch at index ${S} must be an object`);if(!Ue(w.actions))throw new Error(`conditional branch at index ${S} requires actions object`);if(!Object.prototype.hasOwnProperty.call(w,"when")&&S!==R-1)throw new Error("conditional else branch must be the last branch")},ci=(w,S,R)=>{cp(w);let _=Zr(R);for(let L=0;L<w.branches.length;L+=1){let Y=w.branches[L];up(Y,L,w.branches.length);let Q=ps(S);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!it(Y.when,Q))continue;let Ee=fs(Y.actions,S,R);return cs(Ee)?et(_,Ee):_}return _},pp=(w,S)=>({...w??{},_form:S}),fp=(w,S,R,_)=>{let L=Nt(w,S),Y=L?.submitted===!0&&L.valid===!0,Q=L?.cancelled===!0;if(!(!Y&&!Q)&&Ue(S.actions))return fs(S.actions,pp(R,L.form),{..._,interactionSource:ei})},dp=(w,S,R,_)=>{let L=ps(R),Y={templatePayload:S,literalTargetIds:null};w===v0?Y=ip(S):w===A0?Y=ap(S):w===k0&&(Y=lp(S));let{templatePayload:Q,literalTargetIds:ee}=Y,Le=Gs({[w]:Q},L)[w],_r=ee?{...Le,...ee}:Le;if(w===Xu)return ci(_r,R,_);let $r=Qr(w,_r,_);if(w0.has(w))return fp(w,$r,R,_);Nt(w,$r)},fs=(w,S,R)=>{let _;return Object.entries(w).forEach(([L,Y])=>{let Q=dp(L,Y,S,R);cs(Q)&&(_=et(_,Q))}),_},ui=(w,S,R={})=>ai(()=>fs(w,S,R),R),mp=w=>{let S=r.selectCurrentPointer()?.pointer;if(w!==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:li,handleInternalAction:op,handleActions:ui,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:w=>{if(typeof w?.sceneReplaySceneId=="string"){let S=r.selectActiveSceneReplayEntry?.();if(S?.sceneId!==w.sceneReplaySceneId||S?.entryId!==w.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{ui(Y.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:L})}catch(ee){throw l=_,ee}Q=!0}return mp(S),Q})},getNamespace:k}}var si=()=>{let e=0,r=null;return{getElapsed:()=>e,setElapsed:n=>{e=n},addElapsed:n=>{e+=n},getCallback:()=>r,setCallback:n=>{r=n}}},P0=80,x0="music-room:player",Ku=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Wu=(e,r)=>Ku.has(e)&&r?._event?.id===x0,Ju=({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)},E0=({engine:e,routeGraphics:r,trackRenderDispatch:n,getRenderDispatchCount:o},a)=>{let t=o?.()??0,s=e.handleLineActions(a);(o?.()??0)===t&&Ju({engine:e,routeGraphics:r,trackRenderDispatch:n},a)},S0=({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)},R0=({ticker:e,autoTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},O0=({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??P0;n.getElapsed()>=i&&(n.setElapsed(0),$t(e,"nextLineFromSystem",{}))};n.setCallback(t),r.add(t)},C0=({ticker:e,skipTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},_0=({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)},$0=({ticker:e,nextLineConfigTimerState:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},j0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveSlots(r?.saveSlots))},N0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalDeviceVariables(r?.globalDeviceVariables))},D0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalAccountVariables(r?.globalAccountVariables))},T0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalRuntime(r?.globalRuntime))},L0=({enqueuePersistenceWrite:e},r)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(r?.updates)})},Hu={render:Ju,saveSlots:j0,saveGlobalDeviceVariables:N0,saveGlobalAccountVariables:D0,saveGlobalRuntime:T0,applyScopedDataUpdates:L0,handleLineActions:E0,startAutoNextTimer:S0,clearAutoNextTimer:R0,startSkipNextTimer:O0,clearSkipNextTimer:C0,nextLineConfigTimer:_0,clearNextLineConfigTimer:$0},M0=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)},q0=(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(!M0.has(a.name)){n.unshift(a);continue}r.has(a.name)||(r.add(a.name),n.unshift(a))}return n},V0=({getEngine:e,routeGraphics:r,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:t,persistence:s,namespace:i})=>{let l=si(),u=si(),c=si(),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)},I=()=>{if(p)return p;let O=e();return p=Jo({indexedDB:t,namespace:i??O?.getNamespace?.()}),p},b=O=>{m=m.catch(()=>{}).then(()=>{let j=I();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(Wu(O,j)){let Z=Ku.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(Wu(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=q0(O),Z=M.some(K=>K.name==="handleLineActions");M.forEach(K=>{if(!Hu[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=Hu[K.name];if(xe){xe(ge,K.payload);continue}o(K,ge)}};return ie.handleRouteGraphicsEvent=x,ie.createRouteGraphicsEventHandler=ue,ie},F0=V0;var U0=(e,r={})=>{let{resources:n={}}=r;return bo(e,n)};var xw=ni;export{Ks as DEFAULT_VISUAL_LAYER,Mr as RENDER_LAYER,Xe as VISUAL_LAYER,F0 as createEffectsHandler,xb as createIndexedDbPersistence,xw as default,Bs as formatDate,Ff as resolveComputedVariables,U0 as resolveLayoutReferences};
1
+ var Ep=Object.defineProperty;var Sp=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Rp=(e,r)=>{for(var n in r)Ep(e,n,{get:r[n],enumerable:!0})};var Fc=Sp(oi=>{"use strict";Object.defineProperty(oi,"__esModule",{value:!0});function Vc(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}oi.default=Vc;Vc.code='require("ajv/dist/runtime/ucs2length").default'});var Ai=Symbol.for("immer-nothing"),gi=Symbol.for("immer-draftable"),ke=Symbol.for("immer-state");function je(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Dr=Object.getPrototypeOf;function me(e){return!!e&&!!e[ke]}function gr(e){return e?ki(e)||Array.isArray(e)||!!e[gi]||!!e.constructor?.[gi]||Yt(e)||zt(e):!1}var Op=Object.prototype.constructor.toString();function ki(e){if(!e||typeof e!="object")return!1;let r=Dr(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)===Op}function Ut(e){return me(e)||je(15,e),e[ke].base_}function qt(e,r){Bt(e)===0?Reflect.ownKeys(e).forEach(n=>{r(n,e[n],e)}):e.forEach((n,o)=>r(o,n,e))}function Bt(e){let r=e[ke];return r?r.type_:Array.isArray(e)?1:Yt(e)?2:zt(e)?3:0}function ws(e,r){return Bt(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function Pi(e,r,n){let o=Bt(e);o===2?e.set(r,n):o===3?e.add(n):e[r]=n}function Cp(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}function Yt(e){return e instanceof Map}function zt(e){return e instanceof Set}function hr(e){return e.copy_||e.base_}function vs(e,r){if(Yt(e))return new Map(e);if(zt(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=ki(e);if(r===!0||r==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[ke];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(Dr(e),o)}else{let o=Dr(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Es(e,r=!1){return Ht(e)||me(e)||!gr(e)||(Bt(e)>1&&(e.set=e.add=e.clear=e.delete=$p),Object.freeze(e),r&&Object.entries(e).forEach(([n,o])=>Es(o,!0))),e}function $p(){je(2)}function Ht(e){return Object.isFrozen(e)}var _p={};function br(e){let r=_p[e];return r||je(0,e),r}var rt;function xi(){return rt}function jp(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function bi(e,r){r&&(br("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function As(e){ks(e),e.drafts_.forEach(Np),e.drafts_=null}function ks(e){e===rt&&(rt=e.parent_)}function Ii(e){return rt=jp(rt,e)}function Np(e){let r=e[ke];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function wi(e,r){r.unfinalizedDrafts_=r.drafts_.length;let n=r.drafts_[0];return e!==void 0&&e!==n?(n[ke].modified_&&(As(r),je(4)),gr(e)&&(e=Vt(r,e),r.parent_||Ft(r,e)),r.patches_&&br("Patches").generateReplacementPatches_(n[ke].base_,e,r.patches_,r.inversePatches_)):e=Vt(r,n,[]),As(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==Ai?e:void 0}function Vt(e,r,n){if(Ht(r))return r;let o=r[ke];if(!o)return qt(r,(a,t)=>vi(e,o,r,a,t,n)),r;if(o.scope_!==e)return r;if(!o.modified_)return Ft(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),qt(t,(i,l)=>vi(e,o,a,i,l,n,s)),Ft(e,a,!1),n&&e.patches_&&br("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function vi(e,r,n,o,a,t,s){if(me(a)){let i=t&&r&&r.type_!==3&&!ws(r.assigned_,o)?t.concat(o):void 0,l=Vt(e,a,i);if(Pi(n,o,l),me(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(gr(a)&&!Ht(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Vt(e,a),(!r||!r.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&Ft(e,a)}}function Ft(e,r,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Es(r,n)}function Dp(e,r){let n=Array.isArray(e),o={type_:n?1:0,scope_:r?r.scope_:xi(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,t=Ss;n&&(a=[o],t=tt);let{revoke:s,proxy:i}=Proxy.revocable(a,t);return o.draft_=i,o.revoke_=s,i}var Ss={get(e,r){if(r===ke)return e;let n=hr(e);if(!ws(n,r))return Tp(e,n,r);let o=n[r];return e.finalized_||!gr(o)?o:o===bs(e.base_,r)?(Is(e),e.copy_[r]=xs(o,e)):o},has(e,r){return r in hr(e)},ownKeys(e){return Reflect.ownKeys(hr(e))},set(e,r,n){let o=Ei(hr(e),r);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=bs(hr(e),r),t=a?.[ke];if(t&&t.base_===n)return e.copy_[r]=n,e.assigned_[r]=!1,!0;if(Cp(n,a)&&(n!==void 0||ws(e.base_,r)))return!0;Is(e),Ps(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 bs(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,Is(e),Ps(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){let n=hr(e),o=Reflect.getOwnPropertyDescriptor(n,r);return o&&{writable:!0,configurable:e.type_!==1||r!=="length",enumerable:o.enumerable,value:n[r]}},defineProperty(){je(11)},getPrototypeOf(e){return Dr(e.base_)},setPrototypeOf(){je(12)}},tt={};qt(Ss,(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 Ss.set.call(this,e[0],r,n,e[0])};function bs(e,r){let n=e[ke];return(n?hr(n):e)[r]}function Tp(e,r,n){let o=Ei(r,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Ei(e,r){if(!(r in e))return;let n=Dr(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return o;n=Dr(n)}}function Ps(e){e.modified_||(e.modified_=!0,e.parent_&&Ps(e.parent_))}function Is(e){e.copy_||(e.copy_=vs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var Lp=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"&&je(6),o!==void 0&&typeof o!="function"&&je(7);let a;if(gr(r)){let t=Ii(this),s=xs(r,void 0),i=!0;try{a=n(s),i=!1}finally{i?As(t):ks(t)}return bi(t,o),wi(a,t)}else if(!r||typeof r!="object"){if(a=n(r),a===void 0&&(a=r),a===Ai&&(a=void 0),this.autoFreeze_&&Es(a,!0),o){let t=[],s=[];br("Patches").generateReplacementPatches_(r,a,t,s),o(t,s)}return a}else je(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){gr(e)||je(8),me(e)&&(e=tr(e));let r=Ii(this),n=xs(e,void 0);return n[ke].isManual_=!0,ks(r),n}finishDraft(e,r){let n=e&&e[ke];(!n||!n.isManual_)&&je(9);let{scope_:o}=n;return bi(o,r),wi(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=br("Patches").applyPatches_;return me(e)?o(e,r):this.produce(e,a=>o(a,r))}};function xs(e,r){let n=Yt(e)?br("MapSet").proxyMap_(e,r):zt(e)?br("MapSet").proxySet_(e,r):Dp(e,r);return(r?r.scope_:xi()).drafts_.push(n),n}function tr(e){return me(e)||je(10,e),Si(e)}function Si(e){if(!gr(e)||Ht(e))return e;let r=e[ke],n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=vs(e,r.scope_.immer_.useStrictShallowCopy_)}else n=vs(e,!0);return qt(n,(o,a)=>{Pi(n,o,Si(a))}),r&&(r.finalized_=!1),n}var Re=new Lp,Rs=Re.produce,u0=Re.produceWithPatches.bind(Re),p0=Re.setAutoFreeze.bind(Re),d0=Re.setUseStrictShallowCopy.bind(Re),f0=Re.applyPatches.bind(Re),m0=Re.createDraft.bind(Re),y0=Re.finishDraft.bind(Re);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},Tr={NOT:0};var j=class extends Error{constructor(r){super(`Parse Error: ${r}`),this.name="JemplParseError"}},Ae=class extends Error{constructor(r){super(`Render Error: ${r}`),this.name="JemplRenderError"}};var Os=e=>{if(!e||e.trim()==="")throw new j("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new j(`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 j(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Ri=e=>{if(e.trim().endsWith(" in"))throw new j(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new j(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[r,n]=e.split(" in ");if(!n||n.trim()==="")throw new j(`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 j(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new j(`Invalid loop syntax (got: '$for ${e}')`)}};var Oi=(e,r,n=!1)=>{if(r===null)return new Ae(`Cannot iterate over null value at '$for ${e}'`);if(r===void 0)return new Ae(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof r;return n?new Ae(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ae(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Ci=(e,r)=>{let n=r&&Object.keys(r).length>0?Object.keys(r).join(", "):"no custom functions provided";return new Ae(`Unknown function '${e}' (${n})`)};var Mp=(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=G(e,{functions:o,partials:a},r,{});return s===void 0?{}:s},G=(e,r,n,o)=>{let a=r.functions||r;if(e.var&&!e.type)return de(e.var,n,o);if(e.type===A.LITERAL)return e.value;if(e.type===A.VARIABLE)return de(e.path,n,o);if(e.type===A.INTERPOLATION)return Vp(e.parts,r,n,o);switch(e.type){case A.FUNCTION:return _i(e,r,n,o);case A.BINARY:return ji(e,r,n,o);case A.UNARY:return Ni(e,r,n,o);case A.CONDITIONAL:return Up(e,r,n,o);case A.LOOP:return Gp(e,r,n,o);case A.OBJECT:return Wp(e,r,n,o);case A.ARRAY:return Kp(e,r,n,o);case A.PARTIAL:return Jp(e,r,n,o);case A.PATH_REFERENCE:return Qp(e,r,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},$i=new Map,qp=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},de=(e,r,n)=>{if(!e)return;if(e in n)return n[e];let o=$i.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=qp(l.trim());o.push(...u)}$i.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},Vp=(e,r,n,o)=>{let a=[];for(let t of e)if(typeof t=="string")a.push(t);else{let s=G(t,r,n,o);a.push(s!=null?String(s):"")}return a.join("")},_i=(e,r,n,o)=>{let a=r.functions||r,t=a[e.name];if(!t)throw Ci(e.name,a);let s=e.args.map(i=>G(i,r,n,o));return t(...s)},nr=(e,r,n,o)=>{if(e.var&&!e.type)return de(e.var,n,o);switch(e.type){case A.VARIABLE:return de(e.path,n,o);case A.LITERAL:return e.value;case A.BINARY:return ji(e,r,n,o);case A.UNARY:return Ni(e,r,n,o);case A.FUNCTION:return _i(e,r,n,o);default:return G(e,r,n,o)}},ji=(e,r,n,o)=>{if(e.op===z.AND||e.op===z.OR){let s=nr(e.left,r,n,o),i=nr(e.right,r,n,o);switch(e.op){case z.AND:return s&&i;case z.OR:return s||i}}let a=G(e.left,r,n,o),t=G(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 Ae(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof t}`);return a+t;case z.SUBTRACT:if(typeof a!="number"||typeof t!="number")throw new Ae(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof t}`);return a-t;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ni=(e,r,n,o)=>{let a=e.op===Tr.NOT?nr(e.operand,r,n,o):G(e.operand,r,n,o);if(e.op===Tr.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Fp=(e,r,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===A.VARIABLE)if(de(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?G(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]=de(c.path,n,o);else if(c.type===A.INTERPOLATION){let p=[];for(let d of c.parts)if(typeof d=="string")p.push(d);else if(d.type===A.VARIABLE){let f=de(d.path,n,o);p.push(f!=null?String(f):"")}else{let f=G(d,r,n,o);p.push(f!=null?String(f):"")}i[u]=p.join("")}else i[u]=G(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?G(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]=de(c.path,n,o);else if(c.type===A.INTERPOLATION){let p=[];for(let d of c.parts)if(typeof d=="string")p.push(d);else if(d.type===A.VARIABLE){let f=de(d.path,n,o);p.push(f!=null?String(f):"")}else{let f=G(d,r,n,o);p.push(f!=null?String(f):"")}i[u]=p.join("")}else i[u]=G(c,r,n,o)}return i}}}return null},Up=(e,r,n,o)=>{let a=Fp(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||nr(s,r,n,o))return G(e.bodies[t],r,n,o)}return Di},Bp=(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 d=p.key,f=p.value;if(f.type===A.LITERAL)c[d]=f.value;else if(f.type===A.VARIABLE){let m=f.path;if(m===o)c[d]=u;else if(m.startsWith(o+".")){let y=m.substring(o.length+1);c[d]=u[y]}else return null}else if(f.type===A.INTERPOLATION){let m=[],y=!0;for(let g of f.parts)if(typeof g=="string")m.push(g);else if(g.type===A.VARIABLE){let h=g.path;if(h===o)m.push(u!=null?String(u):"");else if(h.startsWith(o+".")){let I=h.substring(o.length+1),b=u[I];m.push(b!=null?String(b):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[d]=m.join("")}else return null}i.push(c)}}return i}}}return null},Yp=(e,r)=>{let n=e.body,o=e.itemVar,a=Bp(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 d=p.substring(o.length+1);if(!d.includes(".")&&!d.includes("["))t.push({key:l,type:"prop_string",prop:d});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let i=new Array(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 d=u[p.prop];c[p.key]=d!=null?String(d):""}i[l]=c}return i}}return null},zp=(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={},d={...o,[i]:c,...l&&{[l]:u}};d.__paths__||(d.__paths__=o.__paths__||{});let f=e.iterable.path||"";if(o&&o.__paths__&&f){let m=f.split("."),y=m[0];y in o.__paths__&&(f=o.__paths__[y],m.length>1&&(f+="."+m.slice(1).join(".")))}d.__paths__={...d.__paths__,[i]:`${f}[${u}]`,...l&&{[l]:u}};for(let m of s.properties){let y=m.parsedKey?G(m.parsedKey,r,n,d):m.key,g=m.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 I=h.substring(i.length+1);!I.includes(".")&&!I.includes("[")?p[y]=c[I]:p[y]=de(h,n,{...o,[i]:c,...l&&{[l]:u}})}else p[y]=de(h,n,{...o,[i]:c,...l&&{[l]:u}})}else if(g.type===A.INTERPOLATION){let h=[];for(let I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=I.path,x;if(b===i)x=c;else if(b===l)x=u;else if(b.startsWith(i+".")){let v=b.substring(i.length+1);!v.includes(".")&&!v.includes("[")?x=c[v]:x=de(b,n,{...o,[i]:c,...l&&{[l]:u}})}else x=de(b,n,{...o,[i]:c,...l&&{[l]:u}});h.push(x!=null?String(x):"")}else{let b={...o,[i]:c,...l&&{[l]:u}},x=G(I,r,n,b);h.push(x!=null?String(x):"")}p[y]=h.join("")}else{let h={...o,[i]:c,...l&&{[l]:u}};p[y]=G(g,r,n,h)}}t.push(p)}return t}return null},Hp=(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 d={id:p.id};p.highlighted?(d.highlight=!0,d.message=`This item is highlighted: ${p.name}`):(d.highlight=!1,d.message=p.name),u.push(d)}}return u}}}}return null},Gp=(e,r,n,o)=>{let a=G(e.iterable,r,n,o);if(!Array.isArray(a)){let u,c=!1;if(e.iterable.type===A.FUNCTION){c=!0;let d=e.iterable.args.map(f=>f.type===A.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===A.VARIABLE?f.path:f.type===A.FUNCTION?`${f.name}(...)`:"?").join(", ");u=`${e.iterable.name}(${d})`}else u=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${u}`;throw Oi(p,a,c)}if(!e.indexVar){let u=Hp(e,a,e.itemVar);if(u!==null)return u}if(!e.indexVar){let u=Yp(e,a);if(u!==null)return u}let t=zp(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=G(e.body,r,n,c);if(Array.isArray(p)&&p.length===1&&!l){let d=p[0];s.push(d===void 0?{}:d)}else s.push(p===void 0?{}:p)}return s},Xp=(e,r,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],t=a.parsedKey?G(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?G(c.parsedKey,r,n,o):c.key,d=c.value;if(d.type===A.LITERAL)l[p]=d.value;else if(d.type===A.VARIABLE)l[p]=de(d.path,n,o);else if(d.type===A.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===A.VARIABLE){let y=de(m.path,n,o);f.push(y!=null?String(y):"")}else{u=!1;break}if(!u)break;l[p]=f.join("")}else if(d.type===A.OBJECT&&d.properties.length<=5){let f={};for(let m of d.properties){let y=m.key,g=m.value;if(g.type===A.LITERAL)f[y]=g.value;else if(g.type===A.VARIABLE)f[y]=de(g.path,n,o);else if(g.type===A.INTERPOLATION){let h=[];for(let I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=de(I.path,n,o);h.push(b!=null?String(b):"")}else{u=!1;break}if(!u)break;f[y]=h.join("")}else{u=!1;break}}if(!u)break;l[p]=f}else{u=!1;break}}if(u)return i[t]=l,i}}return null},Wp=(e,r,n,o)=>{let a=r.functions||r;if(e.whenCondition&&!nr(e.whenCondition,a,n,o))return;let t=Xp(e,r,n,o);if(t!==null)return t;if(e.fast){let u={};for(let c of e.properties){let p=c.parsedKey?G(c.parsedKey,r,n,o):c.key,d=c.value;if(d.type===A.LITERAL)u[p]=d.value;else if(d.type===A.VARIABLE)u[p]=de(d.path,n,o);else if(d.type===A.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===A.VARIABLE){let y=de(m.path,n,o);f.push(y!=null?String(y):"")}else{let y=G(m,r,n,o);f.push(y!=null?String(y):"")}u[p]=f.join("")}else u[p]=G(d,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=G(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 G(u.value,r,n,o)}else{let c=u.value;if(c&&c.type===A.OBJECT&&c.properties){let p=c.properties.find(d=>d.key.startsWith("$for "));if(p){let d=G(p.value,r,n,o);d!==void 0&&(s[u.key]=d)}else{let d=G(u.value,r,n,o);d!==void 0&&(s[u.key]=d)}}else{let p=u.parsedKey?G(u.parsedKey,r,n,o):u.key,d=G(u.value,r,n,o);d!==void 0&&(s[p]=d)}}return s},Di={},Kp=(e,r,n,o)=>{let a=[];for(let t of e.items)if(t.type===A.LOOP){let s=G(t,r,n,o);Array.isArray(s)&&t.flatten!==!1?a.push(...s):a.push(s)}else{let s=G(t,r,n,o);s!==Di&&s!==void 0&&a.push(s)}return a},Jp=(e,r,n,o)=>{let{name:a,data:t,whenCondition:s}=e,i=r.partials||{},l=r.functions||r;if(s&&!nr(s,l,n,o))return;if(!i[a])throw new Ae(`Partial '${a}' is not defined`);let u=o._partialStack||[];if(u.includes(a))throw new Ae(`Circular partial reference detected: ${a}`);let c=i[a],p=n,d={...o,_partialStack:[...u,a]};if(o){p={...n};for(let f of Object.keys(o))f.startsWith("_")||(p[f]=o[f])}if(t){let f=G(t,r,n,o);p={...p,...f}}return G(c,r,p,d)},Qp=(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 Ae(`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 Ae(`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 Ae(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Cs=Mp;var Zp=/\$\{([^}]*)\}/g,ed=/#\{([^}]*)\}/g,Li=(e,r={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,t=rd(a,r);return{isFunction:!0,type:A.FUNCTION,name:o,args:t}},rd=(e,r={})=>e.trim()?td(e).map(o=>nd(o.trim(),r)):[],td=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},nd=(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=Li(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=Ir(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 ye(o,r)}catch{return{type:A.VARIABLE,path:o}}return{type:A.VARIABLE,path:o}},Mi=/^\w+\(.*\)$/,sd=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,od=e=>{if(!(!e||e.trim()===""||Mi.test(e))&&sd.test(e))throw e.includes("?")&&e.includes(":")?new j(`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 j(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new j(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Ti=e=>{let r=e.trim();if(Mi.test(r))throw new j(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(r.includes("["))throw new j(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(r))throw new j(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(r))throw new j(`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 j(`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();od(n);let o=Li(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}},$s=(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(ed)],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):Ti(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,d]=u,f=u.index;if(f>l){let m=n.substring(l,f);for(let y=0;y<o.length;y++)m=m.replace(`__ESCAPED_${y}__`,o[y]);m&&i.push(m)}try{let m;c==="variable"?m=nt(d.trim(),r):m=Ti(d.trim()),i.push(m)}catch(m){if(m.message==="Invalid array index syntax")i.push(p);else throw m}l=f+p.length}if(l<n.length){let 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 Ns=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Fi=e=>Object.keys(e),we=e=>e.join("."),sr=(e,r,n)=>{let o=Fi(e).filter(a=>!r.has(a));if(o.length>0)throw new j(`Unexpected key '${o[0]}' in condition JSON at '${we(n)}'`)},or=(e,r)=>typeof e=="string"?$s(e,r):typeof e=="object"&&e!==null?Array.isArray(e)?ad(e,r):ld(e,r):{type:A.LITERAL,value:e},id=e=>{let{$each:r,...n}=e;if(typeof r!="string")throw new j("$each value must be a non-empty string");let o=r.trim();if(o==="")throw new j("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new j("Empty $each body not allowed");if(n.$partial!==void 0)throw new j("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},ad=(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=id(t),u=Object.keys(l);if(u.length===1&&/^\$for(?::\w+)?\s/.test(u[0])){let c=Vi(u[0],l[u[0]],r,!0);n.push(c),o=!0;continue}}catch(l){throw l instanceof j?l:new j(l.message)}let i=Object.keys(t);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Vi(i[0],t[i[0]],r);n.push(l),o=!0;continue}}let s=or(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}},ld=(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 j("$partial value must be a string");if(e.$partial.trim()==="")throw new j("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],u=[];for(let[h]of t)for(let I of l)if(h===I||h.startsWith(I+" ")||h.startsWith(I+"#")){u.push(I);break}if(u.length>0)throw new j(`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,...d}=e,f={},m=!1;for(let[h,I]of Object.entries(d)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),f[b]=I,m=!0}let y=null;if(m&&(y=or(f,r),y.type===A.OBJECT)){let h=!1;for(let I of y.properties)if(I.value.type===A.VARIABLE||I.value.type===A.INTERPOLATION||I.value.type===A.FUNCTION||I.value.type===A.CONDITIONAL||I.value.type===A.OBJECT&&!I.value.fast||I.value.type===A.ARRAY&&!I.value.fast){h=!0;break}h&&(y.fast=!1)}let g={type:A.PARTIAL,name:c,data:y};return p!==void 0&&(g.whenCondition=qi(p,r)),g}for(let[l,u]of t)if(l==="$when"){if(a!==null)throw new j("Multiple '$when' directives on the same object are not allowed");if(u==null)throw new j("Missing condition expression after '$when'");a=qi(u,r),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new j("'$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 j("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=cd(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 j(`$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 j(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new j("Missing condition expression after '$if'");{let c=or(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=$s(l,r),d={key:l,value:c};(p.type!==A.LITERAL||p.value!==l)&&(d.parsedKey=p),n.push(d),s++}}}let i={type:A.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},cd=(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 j(`Invalid conditional syntax: ${s}`)}else u=s.substring(4),u.endsWith(":")&&(u=u.slice(0,-1).trim());Os(u);let c=ye(u,n);for(o.push(c),a.push(or(i,n)),t++;t<e.length;){let[p,d]=e[t],f=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(f=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p==="$else"||p==="$else:")&&(f=!0,m=null),f){if(m===null)o.push(null);else{Os(m);let y=ye(m,n);o.push(y)}if(a.push(or(d,n)),t++,m===null)break}else break}return{node:{type:A.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:t}},_s={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},js={all:z.AND,any:z.OR},ud=new Set(["var","literal","call","not",...Object.keys(_s),...Object.keys(js)]),pd=(e,r,n)=>{if(!Array.isArray(e))throw new j(`Condition JSON operator '${r}' at '${we(n)}' requires an array`);if(e.length!==2)throw new j(`Condition JSON operator '${r}' at '${we(n)}' requires exactly 2 operands`);return e},dd=(e,r,n,o,a)=>{if(!Array.isArray(e))throw new j(`Condition JSON operator '${r}' at '${we(a)}' requires an array`);if(e.length===0)throw new j(`Condition JSON operator '${r}' at '${we(a)}' requires at least 1 condition`);return e.map((s,i)=>Pe(s,o,[...a,i])).reduce((s,i)=>({type:A.BINARY,op:n,left:s,right:i}))},fd=(e,r,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],sr(e,new Set(["call","args"]),n);else if(Ns(e.call))o=e.call.name,a=e.call.args??[],sr(e,new Set(["call"]),n),sr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new j(`Condition JSON call at '${we(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new j(`Condition JSON call at '${we(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new j(`Invalid condition JSON function name '${o}' at '${we(n)}'`);if(!Array.isArray(a))throw new j(`Condition JSON call '${o}' at '${we(n)}' requires args to be an array`);return{type:A.FUNCTION,name:o,args:a.map((t,s)=>Pe(t,r,[...n,"args",s]))}},Pe=(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 j(`Condition JSON array at '${we(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Ns(e))throw new j(`Invalid condition JSON value at '${we(n)}'`);let o=Fi(e);if(o.length===0)throw new j(`Condition JSON object at '${we(n)}' must contain an operator`);let a=o.filter(s=>ud.has(s));if(a.length===0)throw new j(`Unknown condition JSON operator '${o[0]}' at '${we(n)}'`);if(a.length>1)throw new j(`Condition JSON at '${we(n)}' must contain exactly one operator`);let t=a.includes("call")?"call":a[0];if(t==="var"){if(sr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new j(`Condition JSON var at '${we(n)}' requires a non-empty path`);return{type:A.VARIABLE,path:e.var}}if(t==="literal")return sr(e,new Set(["literal"]),n),{type:A.LITERAL,value:e.literal};if(t==="call")return fd(e,r,n);if(t==="not")return sr(e,new Set(["not"]),n),{type:A.UNARY,op:Tr.NOT,operand:Pe(e.not,r,[...n,"not"])};if(t in js)return sr(e,new Set([t]),n),dd(e[t],t,js[t],r,[...n,t]);if(t in _s){sr(e,new Set([t]),n);let s=pd(e[t],t,[...n,t]);return{type:A.BINARY,op:_s[t],left:Pe(s[0],r,[...n,t,0]),right:Pe(s[1],r,[...n,t,1])}}throw new j(`Unknown condition JSON operator '${t}' at '${we(n)}'`)},qi=(e,r={})=>{if(e==null)throw new j("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new j("Empty condition expression after '$when'");return ye(e,r)}return Ns(e)||Array.isArray(e)?Pe(e,r):{type:A.LITERAL,value:e}},ye=(e,r={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let u=e.slice(1,-1),c=0,p=!0;for(let d=0;d<u.length;d++)if(u[d]==="("?c++:u[d]===")"&&c--,c<0){p=!1;break}if(p&&c===0)return ye(u,r)}let n=Ir(e,"||");if(n!==-1)return{type:A.BINARY,op:z.OR,left:ye(e.substring(0,n).trim(),r),right:ye(e.substring(n+2).trim(),r)};let o=Ir(e,"&&");if(o!==-1)return{type:A.BINARY,op:z.AND,left:ye(e.substring(0,o).trim(),r),right:ye(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=Ir(e,u);if(p!==-1)return{type:A.BINARY,op:c,left:ye(e.substring(0,p).trim(),r),right:ye(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 d=Ir(e.substring(p),u);if(d===-1)break;let f=p+d;f>t&&(t=f,s={op:u,type:c}),p=f+u.length}}if(t!==-1&&s)return{type:A.BINARY,op:s.type,left:ye(e.substring(0,t).trim(),r),right:ye(e.substring(t+s.op.length).trim(),r)};let l=[" * "," / "," % "];for(let u of l)if(Ir(e,u)!==-1)throw new j(`Arithmetic operations are not allowed in conditionals: "${u}"`);return e.startsWith("!")?{type:A.UNARY,op:Tr.NOT,operand:ye(e.substring(1).trim(),r)}:Ui(e,r)},Ir=(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},md=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}},Ui=(e,r)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return nt(n,r);let a=md(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}},yd=(e,r=!1)=>{let n=r?"$each":"$for";try{Ri(e)}catch(o){if(o instanceof j&&r){let a=o.message.replace(/\$for/g,"$each");throw new j(a.replace("Parse Error: ",""))}throw o}},Vi=(e,r,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,t=e.match(a);if(!t){let g=o?"$each":"$for";throw new j(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=t[1],i=t[2].trim();yd(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new j(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${i}')`)}let u=l[1].trim(),c=l[2].trim(),p,d=null;if(u.includes(",")){let g=u.split(",").map(h=>h.trim());if(g.length!==2)throw new j(`Invalid loop variables: ${u}. Expected format: "item" or "item, index"`);p=g[0],d=g[1]}else p=u;let f=["this","undefined","null","true","false"];if(f.includes(p))throw new j(`Reserved variable name: ${p}`);if(d&&f.includes(d))throw new j(`Reserved variable name: ${d}`);let m=Ui(c,n),y=or(r,n);return{type:A.LOOP,itemVar:p,indexVar:d,iterable:m,body:y,flatten:s!=="nested"}};var hd=(e,r={})=>{let{functions:n={}}=r;return or(e,n)},Gt=hd;var st={};Rp(st,{now:()=>gd});var gd=()=>Date.now();var bd=(e,r,n={})=>{let{functions:o={},partials:a={}}=n,t={...st,...o},s=Gt(e,{functions:t}),i={};for(let[l,u]of Object.entries(a))i[l]=Gt(u,{functions:t});return Cs(s,r,{functions:t,partials:i})},wr=bd;var Id=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",wd=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,vd=(e,r)=>{if(Id(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new j("Empty condition expression");return ye(e,r)}return Pe(e,r)},Ad=(e,r={},n={})=>{let o=wd(n),a={...st,...o},t=vd(e,a);return!!nr(t,{functions:a,partials:{}},r,{})},Ds=Ad;var Ys=Symbol("runStoreTransaction"),qs="__routeEngineConditionComparison",Xt=(e,r)=>typeof e=="number"&&typeof r=="number"&&Number.isFinite(e)&&Number.isFinite(r)||typeof e=="string"&&typeof r=="string",ir=Object.freeze({eq:(e,r)=>e===r,neq:(e,r)=>e!==r,gt:(e,r)=>Xt(e,r)&&e>r,gte:(e,r)=>Xt(e,r)&&e>=r,lt:(e,r)=>Xt(e,r)&&e<r,lte:(e,r)=>Xt(e,r)&&e<=r}),Wi=Object.freeze(Object.fromEntries(Object.keys(ir).map(e=>[e,`${qs}${e}`]))),kd=Object.freeze(Object.fromEntries(Object.entries(Wi).map(([e,r])=>[r,ir[e]]))),Bi=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),Pd=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},Wt=e=>{if(Array.isArray(e))return e.map(Wt);if(e===null||typeof e!="object"||Bi(e,"literal")||Bi(e,"var"))return e;if(Pd(e)?.startsWith(qs))throw new Error(`Condition function names beginning with "${qs}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,t=Wi[o];if(t)return{call:t,args:a.map(Wt)}}return Object.fromEntries(n.map(([o,a])=>[o,Wt(a)]))},it=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Pe(e),Ds(Wt(e),r,{functions:kd})},xd=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ki=(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 d;return o=Rs(o,m=>{let y=c(i(m),...p);d=y!==void 0&&!me(y)?y:void 0}),d});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,[Ys]:l}},Zt=(e,r)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return Rs(o,t=>{a.forEach(s=>{r.forEach(i=>{i(t,s)})})})};var Ed=(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{}}},B=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),Vs=(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),Sd=new Set(["pageSize","groups"]),Rd=new Set(["id","variants"]),Od=new Set(["id","imageId"]),Cd=new Set(["pageSize","tracks"]),$d=new Set(["id","soundId","title","artist","album","description","coverImageId"]),_d=new Set(["pageSize","replays"]),jd=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),vr=(e,r,n)=>{Object.keys(e).forEach(o=>{if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},Lr=(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(vr(r,Sd,"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(vr(a,Rd,t),Lr(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(vr(l,Od,u),Lr(l.id,`${u}.id`),Lr(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),!B(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(vr(r,Cd,"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`);vr(a,$d,t);for(let l of["id","soundId","title"])Lr(a[l],`${t}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&Lr(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(!B(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&&!B(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Nd=(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(vr(r,_d,"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`);vr(t,jd,s);for(let c of["sceneId","title","thumbnailImageId"])Lr(t[c],`${s}.${c}`);if(o.has(t.sceneId))throw new Error(`Duplicate scene replay sceneId "${t.sceneId}"`);if(o.add(t.sceneId),!B(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 d=e?.resources?.variables?.[c];if(!d)throw new Error(`Scene replay scene "${t.sceneId}" initialVariables references unknown variable "${c}"`);if(Te(d))throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize computed variable "${c}"`);if(d.readonly===!0)throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize readonly variable "${c}"`);if(d.scope!=="context")throw new Error(`Scene replay scene "${t.sceneId}" can only initialize context variable "${c}"`);Nd(c,d,p)}}}},Ji=e=>{let r=me(e)?tr(e):e;return structuredClone(r)},Dd=({characterId:e,resourceCharacter:r,variables:n={}}={})=>{if(!B(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},en=({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=Dd({characterId:e,resourceCharacter:t,variables:a});return s!==void 0?s:t?.name||""},Te=e=>B(e,"computed"),Mr=(e={},r={})=>Object.fromEntries(Object.entries(e??{}).filter(([n])=>!Te(r[n]))),De=(e,r)=>new Error(`${r} has invalid path: ${JSON.stringify(e)}`),Td=(e,r,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw De(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 De(r,n);a+=s;continue}if(t+=1,t>=e.length-1)throw De(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 De(r,n);a+=String.fromCharCode(Number.parseInt(u,16)),t+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
+ `,r:"\r",t:" ",b:"\b",f:"\f"};if(!B(l,i))throw De(r,n);a+=l[i]}return a},Qi=(e,r="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw De(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 De(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 De(e,r);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw De(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 De(e,r);o+=1,n.push(Td(p,e,r));return}o+=1}if(u||o>=e.length)throw De(e,r)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){t();continue}throw De(e,r)}return n},Ts=(e,r)=>{let n=e;for(let o of r){if(n==null||!B(n,o))return;n=n[o]}return n},Zi=(e,r={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Qi(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 Ts(s,t)}return o==="runtime"?Ts(r.runtime,n.slice(1)):Ts(r,n)},ea=(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)`)},Fs=(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`)},Ld=(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)=>(ea(e,r,o),r.map(a=>Qt(a,n))),Ne=(e,r,n,o)=>{let a=Me(e,r,n,o);return a.forEach(t=>Ld(e,t)),a},Md=(e,r,n)=>{switch(e){case"var":return Zi(r,n);case"add":{let[o,a]=Ne(e,r,n,2);return o+a}case"sub":{let[o,a]=Ne(e,r,n,2);return o-a}case"mul":{let[o,a]=Ne(e,r,n,2);return o*a}case"div":{let[o,a]=Ne(e,r,n,2);return o/a}case"mod":{let[o,a]=Ne(e,r,n,2);return o%a}case"neg":{let[o]=Ne(e,r,n,1);return-o}case"round":{let[o]=Ne(e,r,n,1);return Math.round(o)}case"floor":{let[o]=Ne(e,r,n,1);return Math.floor(o)}case"ceil":{let[o]=Ne(e,r,n,1);return Math.ceil(o)}case"min":{let[o,a]=Ne(e,r,n,2);return Math.min(o,a)}case"max":{let[o,a]=Ne(e,r,n,2);return Math.max(o,a)}case"clamp":{let[o,a,t]=Ne(e,r,n,3);return Math.min(t,Math.max(a,o))}case"eq":{let[o,a]=Me(e,r,n,2);return ir.eq(o,a)}case"neq":{let[o,a]=Me(e,r,n,2);return ir.neq(o,a)}case"gt":{let[o,a]=Me(e,r,n,2);return ir.gt(o,a)}case"gte":{let[o,a]=Me(e,r,n,2);return ir.gte(o,a)}case"lt":{let[o,a]=Me(e,r,n,2);return ir.lt(o,a)}case"lte":{let[o,a]=Me(e,r,n,2);return ir.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 Fs(e,r),r.every(o=>!!Qt(o,n));case"or":case"any":return Fs(e,r),r.some(o=>!!Qt(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 Ji(r);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Qt=(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 Md(o,a,r)},Us=(e,r)=>{if(e===null||typeof e!="object"||B(e,"literal"))return e;if(B(e,"var"))return{literal:Zi(e.var,r)};if(B(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=>Us(a,r)):Us(o,r)]))},qd=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Pe(e),it(Us(e,r))},ra=(e,r)=>{if(!fe(e))throw new Error(`${r} must be an object`);let n=B(e,"expr"),o=B(e,"value");if(n===o)throw new Error(`${r} must contain exactly one of expr or value`)},Ls=(e,r,n)=>(ra(e,r),B(e,"value")?Ji(e.value):Qt(e.expr,n)),Vd=(e,r={},n="unknown")=>{if(!fe(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=B(e,"expr"),a=B(e,"value");if(B(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(!B(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(qd(i.when,r))return Ls(i,`Computed variable "${n}" branch ${s}`,r)}return Ls(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 Ls(e,`Computed variable "${n}"`,r)},ta=(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}`)}},Fd=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}),Ud=new Set(["and","or","all","any"]),Bd=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Yd=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),zd=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Hd=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),na=new WeakMap,Yi=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Kt=(e,r,n)=>{for(let o of Object.keys(e))if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},Gd=(e,r,n,o)=>{if(n!==void 0&&n!==r)throw new Error(`Computed variable "${e}" ${o} expected type ${r}, got ${n}`)},sa=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{let t=`Computed variable "${r}" ${a} var`,[s,i,...l]=Qi(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(!B(n,i))throw new Error(`Computed variable "${r}" ${a} references unknown variable "${i}"`);let u=n[i];return Te(u)&&o.add(i),l.length===0?u?.type:void 0},oa=(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 Yi(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 sa(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 Yi(i)}let l=Fd[s];if(l===void 0&&!Ud.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?Fs(s,i):ea(s,i,l);let u=i.map((c,p)=>oa(c,{variableId:r,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(Yd.has(s)&&u.forEach(c=>{if(c!==void 0&&c!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Bd.has(s))return"number";if(zd.has(s))return"boolean"},Xd=(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{Pe(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"||B(s,"literal"))return;if(B(s,"var")){sa(s.var,{variableId:r,variableConfigs:n,dependencies:o,path:i});return}if(B(s,"call"))throw new Error(`Computed variable "${r}" ${i} function calls are not supported`);if(B(s,"not")){t(s.not,`${i}.not`);return}let l=Object.keys(s).find(u=>Hd.has(u));s[l].forEach((u,c)=>{t(u,`${i}.${l}[${c}]`)})};t(e,a)},Ms=(e,{variableId:r,variableConfig:n,variableConfigs:o,dependencies:a,path:t,allowedKeys:s=new Set(["expr","value"])})=>{if(ra(e,`Computed variable "${r}" ${t}`),Kt(e,s,t),B(e,"value")){ta(r,n.type,e.value);return}let i=oa(e.expr,{variableId:r,variableConfigs:o,dependencies:a,path:`${t}.expr`});Gd(r,n.type,i,`${t}.expr`)},Wd=(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=B(o,"expr"),s=B(o,"value");if(B(o,"branches")){if(Kt(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(Kt(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${u}`),!B(l,"when"))throw new Error(`Computed variable "${e}" branch ${u} requires when`);Xd(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${u}].when`}),Ms(l,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:`computed.branches[${u}]`,allowedKeys:new Set(["when","expr","value"])})}),Ms(o.default,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Kt(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 Ms(o,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed"}),a},Ar=(e={})=>{if(!fe(e))throw new Error("Variable configs must be an object");if(B(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(B(e,""))throw new Error("Variable ids must not be empty");let r=new Map;Object.entries(e).forEach(([t,s])=>{if(Te(s)){if(!fe(s))throw new Error(`Computed variable "${t}" must be an object`);if(!B(s,"type"))throw new Error(`Computed variable "${t}" requires type`);if(!B(s,"scope"))throw new Error(`Computed variable "${t}" requires scope`);if(B(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,Wd(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 d=[...i.slice(p).map(({variableId:f})=>f),c].join(" -> ");throw new Error(`Computed variable cycle detected: ${d}`)}l.set(c,i.length),i.push({variableId:c,dependencies:[...r.get(c)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return na.set(e,a),a},ut=({variables:e={},runtime:r={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=na.get(n)??Ar(n),t=Mr(e,n),s=Object.entries(n).filter(([,g])=>Te(g)).map(([g])=>g),i=Object.create(null),l=[],u=new Map(a.map((g,h)=>[g,h])),c=-1,p=!1,d=g=>{if(B(i,g))return i[g];let h=n[g];if(!Te(h))return B(t,g)?t[g]:void 0;let I=l.indexOf(g);if(I>=0){let b=[...l.slice(I),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=Vd(h.computed,y,g);return ta(g,h.type,b),Vs(i,g,b),b}finally{l.pop()}},f=g=>{if(B(i,g))return i[g];let h=n[g];if(!Te(h))return B(t,g)?t[g]:void 0;let I=u.get(g);if(o&&!p&&I!==void 0&&I>c){p=!0;try{for(let b=c+1;b<=I;b+=1)d(a[b]),c=b}finally{p=!1}return i[g]}return d(g)},m=new Proxy({},{get:(g,h)=>{if(typeof h=="string")return f(h)},has:(g,h)=>typeof h=="string"&&(B(t,h)||s.includes(h)),ownKeys:()=>[...new Set([...Object.keys(t),...s])],getOwnPropertyDescriptor:(g,h)=>{if(!(typeof h!="string"||!B(t,h)&&!s.includes(h)))return{enumerable:!0,configurable:!0}}}),y={variables:m,runtime:r,resolveVariable:f};return o?(s.forEach(g=>{f(g)}),{...t,...i}):m},Kd=({variables:e={},runtime:r={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return Ar(a),ut({variables:e,runtime:r,variableConfigs:a,eager:!0})},rn=e=>{let r={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(Te(a))return;let t=Ed(a,o);a.scope==="context"?Vs(r,o,t):Vs(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(", ")}`)},tn=(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(", ")}`)},Jd=2,zi=12,ia=(e=Jd)=>{if(!Number.isInteger(e)||e<0||e>zi)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${zi}.`);return e},Qd=(e,r)=>{let n=10**r;return Math.round((e+Number.EPSILON)*n)/n},Jt=e=>typeof e=="number"&&Number.isFinite(e),zs=(e,r,n,o,a={})=>{if(e==="number"){if(r==="set"&&!Jt(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(r==="multiply"&&!Jt(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(r==="divide"&&!Jt(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}".`);ia(a.roundTo)}}},nn=(e,r,n,o={})=>{let a=(s,i,l)=>{let u=s??i;if(!Jt(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 Qd(a(e,0,"current value")/t(n),ia(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 Hs=(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:xd[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])},Zd=(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,ef=(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},Hi=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},Gi=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Xi=(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,rf=(e,r)=>{let n={},o=Xi(Hi(e),Hi(r)),a=Xi(Gi(e),Gi(r));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},Gs=(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=rf(e.background,r.background);t&&(n.background=t),a("screen"),a("bgm"),a("voice");let s=Zd(e.dialogue,r.dialogue);s&&(n.dialogue=s);let i=ef(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},Xs=(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},tf=(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},nf=(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=tf(r,n);if(o===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "_event".`);return o},sf={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"])},of=(e,r)=>{let n=e[e.length-1];return n?sf[n]?.has(r)===!0:!1},Bs=(e,r,n=[])=>Array.isArray(e)?e.map(o=>Bs(o,r,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,of(n,o)?a:Bs(a,r,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?nf(e,r._event):wr(e,r):e,Ws=(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 Bs(e,r)};var re=e=>structuredClone(me(e)?tr(e):e),W=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),aa=e=>e?.animations?.playback?.continuity==="persistent",X=(e,r)=>W(e??{},r)&&e[r]!==void 0,dt=(e,r)=>e?!r(e)&&e.animations?{animationsOnly:!0,state:{animations:re(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},af=e=>X(e,"opacity")||X(e,"blur"),fa=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],ma=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Ks=["animationName","animationSpeed","loop"],lf=e=>fa.some(r=>X(e,r)),ya=e=>e?.text&&X(e.text,"content")&&X(e.text,"textStyleId"),ha=e=>X(e,"text"),cf=(e,r)=>e.resourceId?!0:ya(e)?!r?.text:!1,uf=(e,r)=>{let n={...re(e),...r};return r.text&&e.text&&(n.text={...re(e.text),...re(r.text)}),n},pf=(e,r)=>{if(ha(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!ya(e)&&!r?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},la=e=>ma.some(r=>X(e,r)),ca=e=>Ks.some(r=>X(e,r)),df=(e,r,{hasAuthoredTransformId:n=!1}={})=>{if(!r)return e;for(let o of ma)!n&&!X(e,o)&&X(r,o)&&(e[o]=r[o]),W(e,o)&&e[o]===void 0&&delete e[o];return e},ga=(e,r,n)=>{let o=e[n];return o?.id===r?.id?o:e.find(a=>a.id===r?.id)},ff=(e,r)=>{if(!r)return e;for(let n of fa)!X(e,n)&&X(r,n)&&(e[n]=r[n]),W(e,n)&&e[n]===void 0&&delete e[n];return e},mf=(e,r)=>(r&&(!X(e,"opacity")&&X(r,"opacity")&&(e.opacity=r.opacity),!X(e,"blur")&&X(r,"blur")&&(e.blur=re(r.blur)),W(e,"opacity")&&e.opacity===void 0&&delete e.opacity,W(e,"blur")&&e.blur===void 0&&delete e.blur),e),ba=(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=ga(n,s,i),u=r(s,l),c=af(s),p=lf(s),d=o(s),f=W(s,"animations"),m=re(s);return!u&&(c||p||d)&&l&&(m=a?a(l,m):{...re(l),...m},f||delete m.animations),mf(ff(m,l),l)}).filter(s=>r(s)||s.animations);return{hasValidItems:t.length>0,processedItems:t}},yf=e=>{if(e){if(e.character&&W(e.character,"name"))return e.character.name;if(W(e,"characterName"))return e.characterName}},Ia=e=>!!e?.character&&W(e.character,"sprite"),hf=e=>{let r={},n=!1,o=yf(e);return o!==void 0&&(r.name=o,n=!0),Ia(e)&&(r.sprite=re(e.character.sprite),n=!0),n?r:void 0},ua=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},pa=({dialogueState:e,dialogueAction:r,persistCharacter:n})=>W(r,"persistSprite")?r.persistSprite===!0:W(e,"persistSprite")?e.persistSprite===!0:n&&!W(r,"characterId"),da=({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 W(u,"name")?i.name=u.name:(o&&!n||c)&&W(l,"name")&&(i.name=re(l.name)),W(u,"sprite")?i.sprite=re(u.sprite):(a||p)&&W(l,"sprite")&&(i.sprite=re(l.sprite)),Object.keys(i).length>0?i:void 0},gf=({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]},bf=()=>({}),If=(e,r)=>{if(!r.screen)return;let n=X(r.screen,"opacity"),o=X(r.screen,"blur"),a=W(r.screen,"animations");if(!n&&!o){a||delete e.screen;return}let t=e.screen,s={};if(n?s.opacity=r.screen.opacity:X(t,"opacity")&&(s.opacity=t.opacity),o?s.blur=re(r.screen.blur):X(t,"blur")&&(s.blur=re(t.blur)),W(s,"opacity")&&s.opacity===void 0&&delete s.opacity,W(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},wf=(e,r)=>{if(r.background){let n=X(r.background,"resourceId"),o=X(r.background,"colorId"),a=X(r.background,"opacity"),t=X(r.background,"blur"),s=X(r.background,"transformId"),i=la(r.background),l=ca(r.background),{animationsOnly:u,state:c}=dt(r.background,f=>X(f,"resourceId")||X(f,"colorId")||X(f,"opacity")||X(f,"blur")||X(f,"transformId")||la(f)||ca(f));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,d=re(r.background);if(!n&&p?.resourceId){d.resourceId=p.resourceId,!W(d,"transformId")&&p.transformId&&(d.transformId=p.transformId);for(let f of Ks)!X(d,f)&&X(p,f)&&(d[f]=p[f])}df(d,p,{hasAuthoredTransformId:s}),!o&&p?.colorId&&(d.colorId=p.colorId),!a&&X(p,"opacity")&&(d.opacity=p.opacity),!t&&X(p,"blur")&&(d.blur=re(p.blur)),W(d,"resourceId")&&d.resourceId===void 0&&delete d.resourceId,W(d,"colorId")&&d.colorId===void 0&&delete d.colorId,W(d,"animations")&&d.animations===void 0&&delete d.animations,W(d,"transformId")&&d.transformId===void 0&&delete d.transformId,W(d,"opacity")&&d.opacity===void 0&&delete d.opacity,W(d,"blur")&&d.blur===void 0&&delete d.blur;for(let f of Ks)W(d,f)&&d[f]===void 0&&delete d[f];if(!d.resourceId&&!d.colorId){delete e.background;return}p?.resourceId===d.resourceId&&p?.transformId===d.transformId&&!W(d,"animations")&&aa(p)&&(d.animations=re(p.animations)),e.background=d}else e.background?.animations&&!aa(e.background)&&(e.background.animations={})},vf=(e,r)=>{if(!r.dialogue){if(e.dialogue&&(ua(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=pa({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:c});c||delete e.dialogue.characterId,e.dialogue.character=da({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}=dt(r.dialogue.ui,d=>!!d.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&&gf({dialogueState:e.dialogue,content:r.dialogue.content,append:o}),W(r.dialogue,"textSpeed")?e.dialogue.textSpeed=r.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=W(r.dialogue,"persistCharacter")?r.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let t=pa({dialogueState:e.dialogue,dialogueAction:r.dialogue,persistCharacter:a});W(r.dialogue,"persistSprite")&&(e.dialogue.persistSprite=t);let s=W(r.dialogue,"characterId"),i=hf(r.dialogue),l=Ia(r.dialogue);s?r.dialogue.characterId?e.dialogue.characterId=r.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let u=da({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:t,hasExplicitPersistSprite:W(r.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(u?e.dialogue.character=u:delete e.dialogue.character,l||ua(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)}},Af=(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},kf=(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)}},Pf=(e,r)=>{if(r.visual){let n=e.visual?.items||[];r.visual.items?.forEach((t,s)=>{pf(t,ga(n,t,s))});let{hasValidItems:o,processedItems:a}=ba(r.visual.items,cf,n,{hasPatchFn:ha,mergeItemFn:uf});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))},xf=(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}=ba(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},Ef=(e,r)=>{r.animation?e.animation=r.animation:e.animation&&delete e.animation},Sf=(e,r)=>{if(r.layout){let{animationsOnly:n,state:o}=dt(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},Rf=(e,r)=>{if(r.choice){let{animationsOnly:n,state:o}=dt(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},Of=(e,r)=>{if(r.form){let{animationsOnly:n,state:o}=dt(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},Cf=(e,r)=>{if(r.control){if(!r.control.resourceId){delete e.control;return}e.control=r.control}},$f=(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},_f=(e,r)=>{r.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},kr=e=>Zt(bf,[_f,If,wf,Af,kf,Pf,vf,xf,Ef,Sf,Rf,Of,Cf,$f])(e);var qr=(e,r)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=wr(e,r);return n&&typeof n=="object"?e:n};var jf=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"}}),ar=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:""}),Nf=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"}),Js=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),wa=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),Qs=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),va=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Df=(e,r)=>{let n=Nf[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}"`)},sn=(e,r)=>{if(Df(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},Zs=(e={})=>{let r=e?.config;if(r===void 0)return{...ar};if(!va(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{...ar};if(!va(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(wa),t=Object.keys(o).find(i=>!a.has(i));if(t)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${t}"`);let s={...ar};return wa.forEach(i=>{o[i]!==void 0&&(s[i]=sn(i,o[i]))}),s},Tf=(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]}},Pr=e=>Object.fromEntries(Object.entries(jf).map(([r,n])=>{let o=Tf(e,n.source),a=o!==void 0?o:ar[r]??ft[r];return[r,a]})),lr=(e,r)=>Pr(e)[r],Aa=(e={})=>Object.fromEntries(Js.map(r=>[r,e[r]??ar[r]]));var Vr=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}),Ge=Object.freeze({BEHIND_BACKGROUND:Vr.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:Vr.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:Vr.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:Vr.VISUAL_BEHIND_CHOICE,FOREGROUND:Vr.VISUAL_FOREGROUND}),eo=Ge.BEHIND_DIALOGUE,ro=Object.freeze(Object.values(Ge).sort((e,r)=>e-r));var Lf={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([r,n])=>({id:r,...n})),formatDate:Hs},Mf=/^\$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=Mf.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)])),We=(e,r)=>{let n={functions:Lf};return wr(mt(e),r,n)},Io=({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".`)},qf=({id:e,targetId:r,animation:n,playback:o,animationPath:a="animation"})=>{let t=structuredClone(n);if(Io({animationType:t.type,animationId:e,animationPath:a}),delete t.name,delete t.playback,t.id=e,t.targetId=r,o!==void 0){let s=Bf(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?Ma(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},Vf=(e,{animationId:r="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Io({animationType:e.type,animationId:r,animationPath:n}),e.type},Ff=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Uf=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Bf=(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},Yf=e=>{let r=e?.playback?.speed;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:1},xr=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Da=e=>e?.playback?.continuity==="persistent",co=e=>Array.isArray(e)?e.map(co):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((r,n)=>(r[n]=co(e[n]),r),{}),cn=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(co(r))},Ta=(e=[])=>e.filter(r=>Da(r)).map(r=>structuredClone(r)),La=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,to=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((r,n)=>Math.max(r,La(n)),0),Ma=e=>Math.max(to(e?.tween),to(e?.prev?.tween),to(e?.next?.tween),La(e?.mask?.progress)),qa=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Ma(e)/Yf(e),zf=e=>e.some(r=>r?.playback?.loop===!0),ka=({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(cn).filter(Boolean));return e.some(o=>{if(!Da(o))return!1;let a=cn(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:zf(e)||t&&!r||ka({animationInstances:e,activePersistentAnimations:o})?!0:t?!1:ka({animationInstances:e,activePersistentAnimations:a}),Hf=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(r=>e[r]!==void 0),Gf=(e,r)=>{if(Hf(e))throw new Error(`[${r}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Xf=({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?qf({id:o,targetId:a,animation:s,playback:n,animationPath:t}):null},Wf=(e,{defaultTargetId:r,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return Io({animationType:a.type,animationId:a.id??n,animationPath:o}),a.id??=n,a.targetId??=r,a},wo=({animations:e,transitions:r,defaultTargetId:n,idPrefix:o,animationPathPrefix:a=o})=>{r.forEach((t,s)=>{e.push(Wf(t,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},uo=(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},Kf=({content:e,path:r,variables:n})=>uo(e,r).reduce((o,a)=>{let t=qr(a.text,{variables:n});return o+`${t??""}`.length},0),Pa=(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))},on=(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},Jf=(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},Qf=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Zf=(e={})=>Qf.some(r=>xr(e,r)),Va=(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"}},ln=({resourceId:e,kind:r})=>{if(e)return r?`bg-cg-background-${r}`:`bg-cg-${e}`},em=(e={})=>e.textStyles||{},rm=(e={})=>e.images||{},tm=.5,nm=(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]},Fa=({id:e,resourceId:r,spritesheet:n,animationName:o,animationSpeed:a,loop:t,transform:s={}}={})=>{let i=nm(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??tm,loop:t??l.loop??!0}}},Ua=({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 Fa({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}`)},sm=(e={})=>e.colors||{},om=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,gt=(e,r)=>e==="root"?`${r}`:`${e}.${r}`,Br=(e,r,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${r}" must resolve to a non-empty string`)},no=(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},so=(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},dn=(e,r)=>{if(typeof e!="string"||!om.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},xa=(e,r,n)=>{let o=dn(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})`},im=(e={},r)=>{let n=em(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=no(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:xa(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=no(n.strokeAlpha,"strokeAlpha",r);i.strokeColor=xa(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:dn(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${r}"`),alpha:no(n.shadow.alpha,"shadow.alpha",r),blur:so(n.shadow.blur,"blur",r,0,{minimum:0}),offsetX:so(n.shadow.offsetX,"offsetX",r,2),offsetY:so(n.shadow.offsetY,"offsetY",r,2)}}return i},po=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>po(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]=po(t,r,gt(n,a)));return e.textStyleId!==void 0&&(Br(e.textStyleId,n,"textStyleId"),o.textStyle=im(r,e.textStyleId)),o},vo=(e={},r)=>{let n=sm(e)?.[r];if(!n)throw new Error(`Color "${r}" not found`);return dn(n.hex,`Color "${r}"`)},Ba=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",oo=(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 ${Ba(`${r}.fill`)} instead`)},am=(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&&(Br(e.colorId,n,"colorId"),o.fill=vo(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 ${Ba("fill")} instead`);oo(e,"hover",n),oo(e,"click",n),oo(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]=am(t,r,gt(n,a));continue}o[a]=bt(t,r,gt(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(Br(e.colorId,n,"colorId"),o.fill=vo(r,e.colorId)),o},io=(e={},r)=>{let n=rm(e)?.[r];return n||null},Ya=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Ea=(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 ${Ya(`${r}.${o}`)} instead`)},Sa=(e,r,n)=>{let o=e[r];e[r]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},fo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>fo(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 ${Ya(a)} instead`);Ea(e,"hover",n,"src"),Ea(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]=fo(t,r,gt(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){Br(e.imageId,n,"imageId");let a=io(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&&(Br(e.hoverImageId,n,"hoverImageId"),Sa(o,"hover",io(r,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Br(e.clickImageId,n,"clickImageId"),Sa(o,"click",io(r,e.clickImageId)?.fileId??e.clickImageId)),o},Ao=(e,r={},n="root")=>fo(bt(po(e,r,n),r,n),r,n),Ke=Ao,Er=(e=[])=>e.find(r=>r.id==="story"),lm="#000000",mo="bg-cg-background-color",cm=({resources:e={},background:r={},screen:n})=>r?.colorId===void 0?dn(n?.backgroundColor??lm,"screen.backgroundColor"):vo(e,r.colorId),za=(e={})=>{if(xr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},um=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ra=(e={},{includeDefaultAlpha:r=!1}={})=>{let n=za(e),o=um(e),a={};return(r||n!==void 0)&&(a.alpha=n??1),o&&(a.blur=o),a},pm=(e={})=>{if(xr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},dm=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ha=(e={})=>{let r=pm(e),n=dm(e),o={};return r!==void 0&&(o.alpha=r),n&&(o.blur=n),o},Ur=(e={})=>Ha(e),Xe=(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},fm=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],ko=(e={})=>e.text&&xr(e.text,"content")&&xr(e.text,"textStyleId"),Oa=(e={})=>{if(e.resourceId)return e.resourceId;if(ko(e))return"text"},Ca=(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,mm=({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=Ca(t,n)),a.texture!==void 0&&(a.texture=Ca(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...Xe(o,e)};return Object.assign(s,Ur(e)),s},ym=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!ko(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let r of fm)if(xr(e.text,r))throw new Error(`Visual item "${e.id}" text.${r} is reserved for the visual item`)}},hm=({resources:e,background:r,screen:n={width:1920,height:1080},includeOpacity:o=!1})=>{let a={id:mo,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:cm({resources:e,background:r,screen:n})};if(o){let t=za(r);t!==void 0&&(a.alpha=t)}return a},gm=(e={},r)=>r?!!(e.images?.[r]||e.videos?.[r]||e.spritesheets?.[r]||e.layouts?.[r]):!1,$a=({resources:e={},resourceId:r,colorId:n})=>{let o=Va(e,r);return r&&(o||n===void 0)?{resourceId:r,targetId:ln({resourceId:r,kind:o})}:n!==void 0?{resourceId:mo,targetId:mo}:{resourceId:void 0,targetId:void 0}},Ga=100,cr=Ga,bm="channel:bgm",Im="channel:music-room",wm="music-room:player",vm="channel:voice",Am="default",km=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),ht=(...e)=>e.map(km).join(":"),un=(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)})},Pm=(e,r)=>e*r/Ga,Xa=(e={},r)=>e?.[r]??ar[r],fn=(e={},r,n=cr)=>Pm(n,Xa(e,r)),mn=({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},an=(e,r,n,o)=>e[n]!==void 0?e[n]:r[n]!==void 0?r[n]:o,xm=["muted","pan","playbackRate","startAt","endAt"],yn=({id:e,sound:r,resource:n,defaultLoop:o=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:an(r,n,"loop",o),volume:an(r,n,"volume",cr),startDelayMs:an(r,n,"startDelayMs",0)};xm.forEach(s=>{let i=an(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},Le=({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:d,canRollback:f,confirmDialog:m,form:y,historyDialogue:g=[],characters:h={},dialogueUIHidden:I,skipOnlyViewedLines:b,skipTransitionsAndAnimations:x}={})=>{let v={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??u??!1,skipMode:a?.skipMode??c??!1,dialogueUIHidden:a?.dialogueUIHidden??I??!1,isLineCompleted:a?.isLineCompleted??l??!1},k=Cm({dialogueState:s,includeInactiveAdvDialogue:i,characters:h,variables:e,runtime:v}),E={variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:v.localizationPackageId,runtime:v,saveSlots:t,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:y,historyDialogue:g,characters:h};return k&&(E.dialogue=k,E.dialogueLines=k.lines),E},_a=100,pn=(e,r)=>{if(Array.isArray(e))return e.map(o=>pn(o,r));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=pn(n[o],r)}),n.type==="text-revealing"?r(n):n},Em=e=>pn(e,r=>({...r,revealEffect:"none"})),Sm=e=>pn(e,r=>{let n=Number(r.speed??r.displaySpeed),o=Number.isFinite(n)?Math.max(n,_a):_a;return{...r,speed:o,...Object.prototype.hasOwnProperty.call(r,"displaySpeed")?{displaySpeed:o}:{}}}),ur=(e,{isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>r||o?Em(e):n?Sm(e):e,Wa=({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:{}}}}),yo=e=>{if(Array.isArray(e))return e.map(yo);if(!e||typeof e!="object")return e;let r={};for(let[t,s]of Object.entries(e))r[t]=yo(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}}:{}}}}},Rm=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),ja="submit",ao=(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}}},ho=(e,r,n={})=>{if(Array.isArray(e))return e.map(u=>ho(u,r,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===ja,t=o&&n.submitRoleAncestor,s=a||t?{submitRoleAncestor:!0}:{},i={};for(let[u,c]of Object.entries(e))i[u]=ho(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:ao(l.change,c),submit:ao(l.submit,r.submitActions)}}}return l.formRole===ja||t?{...l,click:ao(l.click,r.submitActions,{replaceActions:!0})}:l},go=(e,r)=>{if(Array.isArray(e))return e.map(o=>go(o,r));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=go(a,r);for(let o of Rm){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},bo=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0,s=en({characterId:e,character:r,characterName:n,characters:o,variables:a});return{...t||{},...r||{},name:s}},Ka=(e=[],r={},n={})=>e.map(o=>{let a=bo({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}}),Om=e=>!(!e||e.mode==="adv"&&e.content===void 0),Cm=({dialogueState:e,includeInactiveAdvDialogue:r=!1,characters:n={},variables:o,runtime:a}={})=>{if(!r&&!Om(e))return;let t=e.content===void 0?[{text:""}]:uo(e.content,"dialogue.content"),s=e.content===void 0?0:Kf({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??ar.dialogueTextSpeed,l=e.textSpeed??i,u=(e.lines||[]).map((p,d)=>{let f=uo(p.content,`dialogue.lines[${d}].content`),m=bo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:f.map(y=>({...y,text:qr(y.text,{variables:o})})),character:m,characterName:m.name}}),c=bo({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:qr(p.text,{variables:o})})),initialRevealedCharacters:s,lines:u}},Ja=({container:e,resources:r,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:t=!1})=>{let s=We(e,n);return Ke(ur(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:t}),r)},lo=(e,r={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(r),Na=({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:lo(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:lo(a.keyup)});return}e[o]={...t,[n]:{payload:lo(a)}}})},$m=(e={},r={})=>{let n={};return Na({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Na({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:I})=>{let b=Xf({resources:r,animationId:f,playback:m,instanceId:h,targetId:I,animationPath:s});b&&l.push(b)},c=n!=null&&n!==!1,p=o!=null&&o!==!1,d=a&&t&&a===t;Gf(e,s);let f=Ff(e),m=Uf(e),y=r?.animations?.[f],g=Vf(y,{animationId:f,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`,I=m?.continuity==="persistent"?h:`${i}-animation-in`;if(c&&p&&d)return u({instanceId:h,targetId:t}),l;c&&u({instanceId:`${i}-animation-out`,targetId:a}),p&&u({instanceId:I,targetId:t})}return l},_m=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),jm=(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:d,activePersistentAnimations:f,restoredPersistentAnimations:m,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:I,canRollback:b,form:x,saveSlots:v=[]})=>{let{elements:k,animations:E}=e;if(r.background){let $=o===void 0?!0:xr(o?.background??{},"animations"),N=k.find(ue=>ue.id==="story");if(!N)return e;let S=Jf(a,r.background),T=S||Zf(r.background),V=n?.background?.resourceId,le=n?.background?.colorId,Y=r.background.resourceId??(r.background.animations?V:void 0),ne=r.background.colorId??(r.background.animations?le:void 0),oe=gm(a,Y),he={...r.background,colorId:ne};if((ne!==void 0||oe)&&N.children.push(hm({resources:a,background:he,screen:t,includeOpacity:!oe})),Y){let{images:ue={},videos:ie={},spritesheets:O={}}=a,_=Va(a,Y),q;if(_==="sprite"?q=ue[Y]:_==="video"?q=ie[Y]:_==="spritesheet-animation"&&(q=O[Y]),q){let ee=_==="video",Ie=_==="spritesheet-animation",K={x:(t?.width??1920)/2,y:(t?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...S},Ee={...Ra(r.background,{includeDefaultAlpha:!0}),...Xe(K,r.background)},ge;Ie?ge=Fa({id:ln({resourceId:Y,kind:_}),resourceId:Y,spritesheet:q,animationName:r.background.animationName,animationSpeed:r.background.animationSpeed,loop:r.background.loop,transform:Ee}):ge={id:ln({resourceId:Y,kind:_}),type:ee?"video":"sprite",src:q.fileId,width:q.width,height:q.height,...Ee},ee&&(ge.loop=r.background.loop??!1,ge.volume=q.volume??50),ge&&N.children.push(ge)}}if(Y){let{layouts:ue={}}=a,ie=ue[Y];if(ie){let O={id:ln({resourceId:Y,kind:"container"}),type:"container",children:ie.elements,...Ra(r.background)};T&&Object.assign(O,Xe({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...S},r.background));let _=We(O,Le({variables:l,imageGallery:u,musicRoom:c,sceneReplay:p,runtime:d,saveSlots:v,dialogueState:r.dialogue,isLineCompleted:s,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:I,canRollback:b,form:x,characters:a.characters||{},skipTransitionsAndAnimations:i}));N.children.push(Ke(ur(_,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let ve=$a({resources:a,resourceId:V,colorId:le}),ce=$a({resources:a,resourceId:Y,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:f,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:$})&&E.push(...se)}return e},Nm=(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(m=>m.id==="story");if(!u)return e;let c=r.character.items||[],p=n?.character?.items||[],d=Pa(c),f=Pa(p);for(let m=0;m<c.length;m++){let y=c[m],{transformId:g,sprites:h}=y,I=p.find(T=>T.id===y.id),b=p.findIndex(T=>T.id===y.id),x=I?.sprites&&I.sprites.length>0,v=h&&h.length>0,k=b>=0?on(I,b,f):void 0,E=Je({animationsDef:y.animations,resources:o,previousResourceId:k,currentResourceId:v?on(y,m,d):void 0,previousTargetId:k,currentTargetId:v?on(y,m,d):void 0,animationPath:`character.items[${m}].animations`,idPrefix:"character"});if(y.animations&&!h&&!g&&x&&qe({animationInstances:E,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})){l.push(...E);continue}if(y.animations&&!h&&!g)continue;if(!h||h.length===0||!g){console.warn("Character item missing sprites or transformId:",y);continue}let $=on(y,m,d),N=o.transforms[g];if(!N){console.warn("Transform not found:",g);continue}let S={type:"container",id:$,...Xe(N,y),...Ur(y),children:[]};for(let T of h){let V=Ua({id:`${$}-${T.id}`,item:T,resources:o});V&&S.children.push(V)}u.children.push(S),qe({animationInstances:E,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&l.push(...E)}}return e},Qa=(e,r)=>{if(!ro.includes(e))throw new Error(`${r} must be one of: ${ro.join(", ")}.`)},Dm=(e,r)=>{let n=!!e.resourceId||ko(e),o=e.layer??(n?void 0:r?.layer)??eo;return Qa(o,`Visual item "${e.id}" layer`),o},Tm=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:a,skipTransitionsAndAnimations:t,variables:s,imageGallery:i,musicRoom:l,sceneReplay:u,runtime:c,activePersistentAnimations:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:y,canRollback:g,form:h,saveSlots:I=[],visualLayer:b})=>{let{elements:x,animations:v}=e;if(r.visual&&o){let k=x.find(S=>S.id==="story");if(!k)return e;let E=r.visual.items,$=n?.visual?.items||[],N=Le({variables:s,imageGallery:i,musicRoom:l,sceneReplay:u,runtime:c,saveSlots:I,dialogueState:r.dialogue,isLineCompleted:a,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:y,canRollback:g,form:h,characters:o.characters||{},skipTransitionsAndAnimations:t});b!==void 0&&Qa(b,"visualLayer");for(let S of E){let T=$.find(oe=>oe.id===S.id),V=Dm(S,T);if(b!==void 0&&V!==b)continue;if(ym(S),S.text){let oe=yt(o,S),he={...structuredClone(S.text),id:`visual-${S.id}`,type:"text",...Xe(oe,S)};Object.assign(he,Ur(S)),k.children.push(Ke(We(he,N),o))}if(S.resourceId){let{images:oe={},videos:he={},spritesheets:ve={}}=o,ce=ve[S.resourceId];if(ce){let se=yt(o,S),ue=S.animationName;if(ue){let ie=ce.animations?.[ue];if(!ie)throw new Error(`Animation '${ue}' not found in spritesheet resource '${S.resourceId}'`);let O=Ur(S),_={id:`visual-${S.id}`,type:"spritesheet-animation",...Xe(se,S),width:S.width??ce.width,height:S.height??ce.height,alpha:O.alpha??S.alpha??1,src:ce.fileId,atlas:ce.jsonData,playback:{frames:ie.frames,animationSpeed:S.animationSpeed??ie.animationSpeed??.5,loop:S.loop??ie.loop??!0}};O.blur&&(_.blur=O.blur),k.children.push(structuredClone(_))}}else{let se=oe[S.resourceId]||he[S.resourceId];if(se){let ue=he[S.resourceId]!==void 0,ie=yt(o,S),O={id:`visual-${S.id}`,type:ue?"video":"sprite",src:se.fileId,width:se.width,height:se.height,...Xe(ie,S)};Object.assign(O,Ur(S)),ue&&(O.loop=se.loop??!1,O.volume=se.volume??50),k.children.push(O)}}}if(S.resourceId){let oe=o.particles?.[S.resourceId];oe&&k.children.push(mm({item:S,particle:oe,resources:o}))}if(S.resourceId){let{layouts:oe={}}=o,he=oe[S.resourceId];if(he){let ve=yt(o,S),ce={id:`visual-${S.id}`,type:"container",children:structuredClone(he.elements),...Xe(ve,S)};Object.assign(ce,Ur(S));let se=We(ce,N);k.children.push(Ke(ur(se,{isLineCompleted:a,skipMode:f,skipTransitionsAndAnimations:t}),o))}}let le=Oa(T),Y=Oa(S),ne=Je({animationsDef:S.animations,resources:o,previousResourceId:le,currentResourceId:Y,previousTargetId:le?`visual-${S.id}`:void 0,currentTargetId:Y?`visual-${S.id}`:void 0,animationPath:`visual.items[${S.id}].animations`,idPrefix:S.id});qe({animationInstances:ne,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:p})&&v.push(...ne)}}return e},Fr="dialogue-character-sprite",Lm=(e,{presentationState:r,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:i}=e,l=Er(e.elements);if(!l)return e;let u=r.dialogue?.character?.sprite,c=n?.dialogue?.character?.sprite,p=ot(u),d=ot(c),f=Je({animationsDef:u?.animations,resources:o,previousResourceId:d?Fr:void 0,currentResourceId:p?Fr:void 0,previousTargetId:d?Fr:void 0,currentTargetId:p?Fr:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return u?.animations&&d&&qe({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...f),e;let m=o.transforms?.[u.transformId];if(!m)return console.warn("Transform not found:",u.transformId),e;let y={type:"container",id:Fr,...Xe(m),children:[]};for(let g of u.items){let h=Ua({id:`${Fr}-${g.id}`,item:g,resources:o});h&&y.children.push(h)}return l.children.push(y),qe({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...f),e},Mm=(e,{presentationState:r,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:u,form:c,skipOnlyViewedLines:p,isLineCompleted:d,skipTransitionsAndAnimations:f,variables:m,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:I,activePersistentAnimations:b,saveSlots:x=[]})=>{let{elements:v,animations:k}=e;if(!r.dialogue||a)return e;let E=v.find(N=>N.id==="story");if(!E)return e;if(r.dialogue.ui&&r.dialogue.ui.resourceId){let{layouts:N={}}=o,S=N[r.dialogue.ui.resourceId];if(S){let T={elements:S.elements},V=Le({variables:m,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:I,saveSlots:x,dialogueState:r.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:d,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:u,form:c,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:f}),le=We(T,V),Y=Ke(ur(le?.elements,{isLineCompleted:d,skipMode:s,skipTransitionsAndAnimations:f}),o);if(Array.isArray(Y))for(let ne of Y)E.children.push(ne);else Y&&E.children.push(Y)}}Lm(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:b});let $=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:$,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:b})&&k.push(...$),e},qm=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:y,canRollback:g,form:h,activePersistentAnimations:I,saveSlots:b=[]})=>{let{elements:x,animations:v}=e;if(r.choice&&o){let k=Er(x);if(!k)return e;let E=o?.layouts[r.choice.resourceId];if(E&&E.elements){let N={elements:E.elements},S=We(N,{...Le({variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,saveSlots:b,dialogueState:r.dialogue,isLineCompleted:t,autoMode:d,skipMode:f,isChoiceVisible:m??!!r.choice,isFormVisible:y,canRollback:g,form:h,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:r.choice?.items??[]}}),T=yo(Ke(ur(S?.elements,{isLineCompleted:t,skipMode:f,skipTransitionsAndAnimations:s}),o));if(Array.isArray(T))for(let V of T)k.children.push(V);else T&&k.children.push(T)}let $=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:$,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:I})&&v.push(...$)}return e},Vm=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:y,canRollback:g,activePersistentAnimations:h,saveSlots:I=[],form:b})=>{let{elements:x,animations:v}=e;if(!b?.resourceId||!o)return e;let k=Er(x);if(!k)return e;let E=o?.layouts?.[b.resourceId];if(!E)return console.warn(`Form layout not found: ${b.resourceId}`),e;let $={id:"form-container",type:"container",x:0,y:0,children:E.elements||[]},N={...Le({variables:i,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,saveSlots:I,dialogueState:r.dialogue,isLineCompleted:t,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:y,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},S=We($,N),T=go(Ke(ur(ho(S,b),{isLineCompleted:t,skipMode:f,skipTransitionsAndAnimations:s}),o),b);T&&k.children.push(T);let V=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:V,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&v.push(...V),e},Fm=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:y=[],skipTransitionsAndAnimations:g})=>{if(!r.control?.resourceId)return e;let h=n.controls?.[r.control.resourceId];if(!h)return e;let I=$m(h.keyboard,h.keyup);if(I&&Object.keys(I).length>0&&(e.global.keyboard=I),!Array.isArray(h.elements)||h.elements.length===0)return e;let b=Er(e.elements);if(!b)return e;let x={id:`control-${r.control.resourceId}`,type:"container",x:0,y:0,children:h.elements};return b.children.push(Ja({container:x,resources:n,templateData:Le({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:c,skipTransitionsAndAnimations:g})),e},Um=(e,{presentationState:r,resources:n,runtime:o,variables:a,musicRoomPlayer:t})=>{let{elements:s,audio:i}=e;if(r.bgm&&n){if(!Er(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,d=!c&&u.loop===!0,f=[];if(c||un(p,"BGM sound"),d){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=d?{...y,loop:y.loop??!1}:y;f.push(yn({id:ht("bgm",c?"default":y.id),sound:h,resource:g,defaultLoop:!d}))}),f.length===0)return e;let m=Le({variables:a,runtime:o}).runtime;i.push(mn({id:bm,volume:fn(m,"musicVolume",c?cr:u.volume??cr),muted:u.muted,pan:u.pan,loop:c?void 0:u.loop,playback:t?.bgmPlayback,interruption:u.interruption,children:f,runtime:m}))}return e},Bm=(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=Le({variables:o,runtime:n}).runtime,u=yn({id:wm,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i});return e.audio.push(mn({id:Im,volume:fn(l,"musicVolume",cr),children:[u],runtime:l})),e},Ym=(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:Am,sounds:t.items??[]}]:t.channels;s||un(i,"SFX channel"),i.forEach(l=>{let u=!s&&l.loop===!0,c=[];if(s||un(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let p=l.sounds.find(d=>d.loop===!0);if(p)throw new Error(`SFX sound "${p.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((p,d)=>{let f=n.sounds?.[p.resourceId];if(!f)return;let m=u?{...p,loop:p.loop??!1}:p;c.push(yn({id:s?ht("sfx","default",d,p.id):ht("sfx",l.id,p.id),sound:m,resource:f,defaultLoop:u?!1:void 0}))}),c.length!==0&&a.push(mn({id:ht("channel","sfx",l.id),volume:fn(o,"soundVolume",l.volume??cr),muted:l.muted,pan:l.pan,loop:s?void 0:l.loop,interruption:s?void 0:l.interruption,children:c,runtime:o}))})}return e},zm=(e,r,n)=>{if(!(!r||!n))return e?.voices?.[r]?.[n]},Hm=(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:cr,startDelayMs:i.startDelayMs??0}]:[]:i.sounds,c=!l&&i.loop===!0,p=[];if(l||un(u,"Voice sound"),c){let f=u.find(m=>m.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(f=>{let m=zm(n,o,f.resourceId);if(!m)return;let y=c?{...f,loop:f.loop??!1}:f;p.push(yn({id:ht("voice",o,l?"default":f.id),sound:y,resource:m,defaultLoop:c?!1:void 0}))}),p.length===0)return e;let d=Le({variables:t,runtime:a}).runtime;return s.push(mn({id:vm,volume:l?i.volume??Xa(d,"soundVolume"):fn(d,"soundVolume",i.volume??cr),muted:i.muted,pan:i.pan,loop:l?void 0:i.loop,interruption:i.interruption,children:p,runtime:d})),e},Gm=(e,{presentationState:r,previousPresentationState:n,resources:o={},variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:y=[],isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:I})=>{let{elements:b,animations:x}=e;if(r.layout){let $=Er(b);if(!$)return e;let N=o.layouts[r.layout.resourceId];if(!N)return e;Array.isArray(N.transitions)&&!g&&!h&&wo({animations:x,transitions:N.transitions,defaultTargetId:`layout-${r.layout.resourceId}`,idPrefix:`layout-${r.layout.resourceId}`,animationPathPrefix:"layout"});let S={id:`layout-${r.layout.resourceId}`,type:"container",x:0,y:0,children:N.elements||[]};$.children.push(Ja({container:S,resources:o,templateData:Le({variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:g,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:o.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:g,skipMode:c,skipTransitionsAndAnimations:h}))}let v=n?.layout?.resourceId,k=r.layout?.resourceId,E=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:E,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:I})&&x.push(...E),e},Xm=(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},Wm=(e,{presentationState:r})=>{let n=Er(e.elements);return!n||!r?.screen||Object.assign(n,Ha(r.screen)),e},Km=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,autoMode:l,skipMode:u,isChoiceVisible:c,isFormVisible:p,canRollback:d,form:f,overlayStack:m=[],dialogueHistory:y=[],saveSlots:g=[],screen:h,isLineCompleted:I,skipTransitionsAndAnimations:b})=>{let{elements:x,animations:v}=e;return m&&m.length>0&&m.forEach((k,E)=>{let $=n.layouts[k.resourceId];if(!$){console.warn(`Overlay layout not found: ${k.resourceId}`);return}Array.isArray($.transitions)&&(b||wo({animations:v,transitions:$.transitions,defaultTargetId:`overlayStack-${E}`,idPrefix:`overlayStack-${E}`,animationPathPrefix:`overlayStack[${E}]`}));let N={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[Wa({id:`overlayStack-${E}-blocker`,screen:h}),...$.elements||[]]},S=Ka(y,n.characters,o),T=Le({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:r?.dialogue,isLineCompleted:I,autoMode:l,skipMode:u,isChoiceVisible:c,isFormVisible:p,canRollback:d,form:f,historyDialogue:S,characters:n.characters||{},skipTransitionsAndAnimations:b}),V=We(N,T),[le,...Y]=V.children||[],ne=Ke(ur({...V,children:Y},{isLineCompleted:I,skipMode:u,skipTransitionsAndAnimations:b}),n);x.push({...ne,children:le?[le,...ne.children||[]]:ne.children})}),e},Jm=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:y,dialogueHistory:g=[],screen:h,isLineCompleted:I,skipTransitionsAndAnimations:b})=>{let{elements:x,animations:v}=e;if(!y?.resourceId)return e;let k=n.layouts?.[y.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${y.resourceId}`),e;Array.isArray(k.transitions)&&!b&&wo({animations:v,transitions:k.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let E={id:"confirmDialog",type:"container",x:0,y:0,children:[Wa({id:"confirmDialog-blocker",screen:h}),...k.elements||[]]},$=Ka(g,n.characters,o),N=We(E,Le({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:r?.dialogue,isLineCompleted:I,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:y,historyDialogue:$,characters:n.characters||{},skipTransitionsAndAnimations:b})),[S,...T]=N.children||[],V=Ke(ur({...N,children:T},{isLineCompleted:I,skipMode:c,skipTransitionsAndAnimations:b}),n);return x.push({...V,children:S?[S,...V.children||[]]:V.children}),e},It=e=>(r,n)=>Tm(r,{...n,visualLayer:e}),Qm=It(Ge.BEHIND_BACKGROUND),Zm=It(Ge.BEHIND_CHARACTER),ey=It(Ge.BEHIND_DIALOGUE),ry=It(Ge.BEHIND_CHOICE),ty=It(Ge.FOREGROUND),Za=e=>Zt(_m,[Fm,Qm,jm,Zm,Nm,ey,Mm,ry,qm,Vm,Gm,ty,Wm,Xm,Um,Bm,Ym,Hm,Km,Jm])(e);function el(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 rl(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 tl="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",nl="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",sl="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var ol=65535,Po=40960,hn=126976,ll=new Uint8Array(12288),cl=new Uint8Array(3072),ul=new Uint8Array(2816),pl,dl;{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 el(tl,nl))e(ll,0,a,t,s),e(cl,Po,a,t,s),e(ul,hn,a,t,s),t>=65040&&!(a>=hn&&t<=129791)&&(r[o]=a,n[o++]=t<<5|s);pl=r.slice(0,o),dl=n.slice(0,o)}function il(e){return e<12288?ll[e]:e<Po?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?cl[e-Po]: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>=hn&&e<129792?ul[e-hn]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:rl(e,pl,dl)}var fl=Uint8Array.from(sl,Number);function ny(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 al(e,r,n){switch(r){case 3:return e&24?n===8204?e&6:(e&24)===16||ny(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*ml(e){let r=e.length;if(r===0)return;let n=e.codePointAt(0),o=n>ol?2:1,a=il(n),t=50200>>a&1?al(0,a,n):0,s=0,i=n,l=a;for(;o<r;){n=e.codePointAt(o);let u=n>ol?2:1,c=il(n),p=fl[a<<4|c],d;p===0?d=!0:p===1?d=!1:p===2?d=!(t&1):p===3?d=!(t&4):d=(t&24)!==16,t=50200>>c&1&&(t!==0||c!==3)?al(t,c,n):0,d&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=o,i=n,l=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*yl(e){for(let r of ml(e))yield r.segment}{let e=ml("_");fl._keep=[e,e.next()]}var hl=1e3,wl=50,sy=0,gl=100,bl=50,oy=60,iy=3,ay=.5,ly=2e4,cy=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,uy=/^\s+$/u,Il,py=e=>{let r=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(yl(r)):(Il??=new n(void 0,{granularity:"grapheme"}),Array.from(Il.segment(r),({segment:o})=>o))},dy=e=>py(e).reduce((r,n)=>uy.test(n)?r+ay:cy.test(n)?r+iy:r+1,0),fy=e=>2**(((Number.isFinite(e)?Math.min(gl,Math.max(sy,e)):wl)-bl)/(gl-bl)),vl=({text:e="",baseDelay:r=hl,speed:n=wl}={})=>{let o=Number.isFinite(r)?Math.max(0,r):hl,a=fy(n),t=dy(e)*oy/a,s=Math.max(o,ly);return Math.min(o+t,s)};var gn={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Rl=1,Ro=1,zr="choice",pr="form",At=()=>({manual:{...gn.manual},auto:{...gn.auto},applyMode:gn.applyMode}),Oo=()=>({groupId:null,variantId:null,pageIndex:0}),my="music-room:player",yy=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),wn=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Co=new Set,hy=new Set(["groupId","variantId"]),gy=new Set(["pageIndex"]),Hr=new Set,by=new Set(["trackId"]),Iy=new Set(["positionMs"]),wy=new Set(["pageIndex"]),$o=new Set,vy=new Set(["sceneId"]),Ay=new Set(["pageIndex"]),_o=()=>({pageIndex:0}),jo=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=me(e)?tr(e):e;return structuredClone(r)},M=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),vn=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},Ol=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:vn(e),operation:r,...n===void 0?{}:{positionMs:n}}),No=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let r=e.global.musicRoomPlayer,n=r.bgmPlayback;r.trackId!==null&&(n={commandId:vn(e),operation:"resume"}),e.global.musicRoomPlayer=wn({bgmPlayback:n})},Cl=(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},Gr=e=>String(e),$l=()=>({sections:[],resources:[]}),_l=()=>({sceneIds:[]}),ky=e=>M(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):$l(),Py=e=>M(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):_l(),xy=e=>Array.isArray(e)?e.map(r=>r?.text??"").join(""):"",Ey=({sectionId:e,lineId:r,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:r,content:n,text:xy(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),jl=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),Sy=e=>M(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,Do=e=>{if(!M(e?.dialogueHistory))return null;let r=e.dialogueHistory;return!Array.isArray(r.entries)||!Number.isInteger(r.currentLength)||!Array.isArray(r.checkpointLengths)?null:r},Ry=e=>{if(!M(e?.dialogueHistory))return e.dialogueHistory=jl(e?.rollback?.timeline?.length??0),e.dialogueHistory;let r=e.dialogueHistory;return Array.isArray(r.entries)||(r.entries=[]),Number.isInteger(r.currentLength)||(r.currentLength=r.entries.length),Array.isArray(r.checkpointLengths)||(r.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),r.currentLength=Math.min(Math.max(r.currentLength,0),r.entries.length),r},To=e=>{let r=Do(e);return r?(r.currentLength<r.entries.length&&(r.entries=r.entries.slice(0,r.currentLength)),r):null},Oy=()=>({resourceId:void 0}),Cy=e=>{if(!M(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},Qe=(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}},Nl=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)}}},Dl=e=>{if(typeof e=="number"||typeof e!="string")return e;let r=Number(e);return Number.isFinite(r)?r:e},Tl=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Rl)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},$y=(e,r={})=>{let n;try{n=Tl(r.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...r,formatVersion:n,slotId:Dl(r.slotId??r.slotKey??e),savedAt:typeof r.savedAt=="number"?r.savedAt:r.date};return delete o.slotKey,delete o.date,o},_y=(e={})=>Object.fromEntries(Object.entries(e).map(([r,n])=>[r,$y(r,n)])),Ll=e=>{if(!Array.isArray(e))return;let r=e.filter(({type:n})=>Ab(n));return r.length>0?r:void 0},jy=e=>{!M(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=Ro,e.timeline.forEach(r=>{if(!M(r))return;typeof r.returnable!="boolean"&&delete r.returnable;let n=Ll(r.executedActions);if(n){r.executedActions=n;return}delete r.executedActions}))},Al=(e,r,n,o="viewedRegistry")=>{let a=r==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!M(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}},Ny=(e,r="viewedRegistry")=>{if(e===void 0)return $l();if(!M(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=Al(a,"sections",t,r);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,t)=>{let s=Al(a,"resources",t,r);return[s.resourceId,s]})))}},Dy=(e,r="accountReplayRegistry")=>{if(e===void 0)return _l();if(!M(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}))]}},Ml=(e,r,n)=>{if(!M(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}=Qe(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}},ql=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,Lo=(e,r)=>{let{section:n}=Qe(e,r?.sectionId);return n?.lines?.find(o=>o.id===r?.lineId)},Ty=(e,r,n)=>{if(!M(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],t=!1;if(e.entries.forEach((i,l)=>{if(!M(i))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:u}=Qe(r,i.sectionId);if(!u?.lines?.some(p=>p.id===i.lineId)){t=!1,a.push(o.length);return}o.push({sectionId:i.sectionId,lineId:i.lineId,...i.appendToPrevious===!0&&t&&o.length>0?{appendToPrevious:!0}:{}}),t=!0,a.push(o.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:s}},Ly=(e,r)=>M(Lo(e,r)?.actions?.dialogue),Vl=(e,r,n)=>{if(!r||r.sectionId!==n.sectionId)return!1;let{section:o}=Qe(e,n.sectionId),a=o?.lines?.findIndex(s=>s.id===n.lineId);return typeof a!="number"||a<=0?!1:o.lines.slice(0,a).findLast(s=>M(s.actions?.dialogue))?.id===r.lineId},My=(e,r)=>{let n=jl();return e.timeline.forEach(o=>{if(o.returnable!==!1&&Ly(r,o)){let a=Lo(r,o),t=n.entries.at(-1),s=a.actions.dialogue.append===!0&&Vl(r,t,o);n.entries.push({sectionId:o.sectionId,lineId:o.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},qy=(e,r,n,o)=>{if(n.length!==r.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==o)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(t=>t===null?e.currentLength:e.checkpointLengths[t]);let a=0;return e.checkpointLengths.forEach((t,s)=>{if(t<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=t}),e},Vy=(e,r)=>{let{section:n}=Qe(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},Fl=(e,r,n)=>{if(typeof r?.sectionId!="string")return!1;let{section:o}=Qe(e,r.sectionId);return ql({sectionId:r.sectionId,lineId:o?.lines?.[0]?.id},n)},Fy=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),Yr={always:"always",maybe:"maybe",never:"never"},Uy=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return Yr.always;let r=e.when,n;if(r===null||typeof r=="boolean"||typeof r=="number")n=r;else if(M(r)&&Object.keys(r).length===1&&Object.prototype.hasOwnProperty.call(r,"literal"))n=r.literal;else return Yr.maybe;return n?Yr.always:Yr.never},Ul=(e,r)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let o=Uy(n);if(o!==Yr.never){if(r(n))return!0;if(o===Yr.always)return!1}}return!1},Bl=e=>Ul(e,r=>Object.entries(r?.actions??{}).some(([n,o])=>n==="conditional"?Bl(o):Fy.has(n))),Yl=(e,r,n)=>Ul(r,o=>Object.entries(o?.actions??{}).some(([a,t])=>a==="sectionTransition"?Fl(e,t,n):a==="conditional"?Yl(e,t,n):!1)),By=(e,r,n)=>{if(!r)return!0;let o=Lo(n,e)?.actions;if(!M(o))return!0;if(Fl(n,o.sectionTransition,r))return!1;let a=o.conditional;return a?!(Yl(n,a,r)||!(o.choice?.resourceId||o.form?.resourceId)&&!Bl(a)&&ql(Vy(n,e),r)):!0},Yy=(e,r,n)=>{if(!M(e)||!Array.isArray(e.timeline))return{rollback:vt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=new WeakSet,a=[],t=e.timeline.flatMap((p,d)=>{if(!M(p))return[];try{let f=Ml(p,n,`rollback.timeline[${d}]`),m=In({sectionId:f.sectionId,lineId:f.lineId,rollbackPolicy:p.rollbackPolicy,returnable:p.returnable});typeof p.returnable=="boolean"&&o.add(m);let y=Ll(D(p.executedActions));return y&&(m.executedActions=y),a.push(d),[m]}catch{return[]}});if(t.length===0)return{rollback:vt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};e.returnabilityVersion!==Ro&&t.forEach((p,d)=>{!o.has(p)&&!By(p,t[d+1],n)&&(p.returnable=!1)});let i=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,l=a.indexOf(i);l<0&&(l=t.length-1);let u=t[l];if(u?.sectionId!==r.sectionId||u?.lineId!==r.lineId){let p=t.findLastIndex(d=>d.sectionId===r.sectionId&&d.lineId===r.lineId);p>=0?l=p:(t.push(In({sectionId:r.sectionId,lineId:r.lineId})),a.push(null),l=t.length-1)}let c=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),l):0;return{rollback:{currentIndex:l,isRestoring:!1,replayStartIndex:c,timeline:t},sourceCheckpointIndexes:a,sourceTimelineLength:e.timeline.length}},zy=(e,r,n)=>{if(!M(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Vo(r),a=Ml(e.pointers?.read,r,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!M(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!M(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let t=e.variables?Mr(D(e.variables),r.resources?.variables??{}):{},s=sh({loadedContextRuntime:M(e.runtime)?D(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:u}=Yy(e.rollback,a,r),c=e.dialogueHistory===void 0?My(i,r):qy(Ty(e.dialogueHistory,r,`contexts[${n}].dialogueHistory`),i,l,u),p={currentPointerMode:"read",pointers:{read:a},configuration:M(e.configuration)?D(e.configuration):{},views:Array.isArray(e.views)?D(e.views):[],bgm:M(e.bgm)?D(e.bgm):{resourceId:void 0},variables:{...o,...t},...c?{dialogueHistory:c}:{},rollback:i};return s&&(p.runtime=s),p},Hy=(e,r)=>{if(!M(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)=>zy(n,r,o))}},Gy=(e,r)=>{if(!M(e))throw new Error("Malformed save slot.");let n=Tl(e.formatVersion);return{...e,formatVersion:n,state:Hy(e.state,r)}},kl=(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}},Xy=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:kl(e.confirmActions,"confirmActions",{required:!0}),cancelActions:kl(e.cancelActions,"cancelActions")}},Xr=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Wy=e=>(M(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Wr=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},zl=e=>{if(!(!M(e)||!e.animations))return{animations:D(e.animations)}},Ky=(e,r)=>{let n=zl(r);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Jy=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}`},bn=e=>String(e??""),Hl=(e,r)=>{let n=bn(r);return e?.trim===!0?n.trim():n},Zy=e=>M(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,r])=>M(r)).map(([r,n])=>[r,{id:r,...D(n)}])):{},eh=(e,r)=>{if(!r||!M(e.global.formDrafts))return;let n=e.global.formDrafts[r];return M(n)?n:void 0},Gl=(e,r)=>{let n=Wy(e);M(n[r])||(n[r]={values:{},touched:{},errors:{},submitted:!1});let o=n[r];return M(o.values)||(o.values={}),M(o.touched)||(o.touched={}),M(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},Mo=(e,r)=>{let n=Hl(e,r);return e?.required===!0&&n.length===0?"required":null},rh=({state:e,pointer:r})=>{if(!r?.sectionId||!r?.lineId)return{};let o=be({state:e},{sectionId:r.sectionId})?.lines||[],a=o.findIndex(t=>t.id===r.lineId);return a<0?{}:kr(o.slice(0,a+1).map(t=>t.actions||{}))},th=({state:e,form:r,pointer:n})=>{if(!r?.resourceId)return null;let o=Jy(r),a=Qy(n,o);if(!o||!a)return null;let t=eh(e,a),s=Zy(r),i=An({state:e}),l={},u=[],c={},p=!0;return Object.entries(s).forEach(([d,f])=>{let m=bn(i?.[f.variableId]),y=Object.prototype.hasOwnProperty.call(t?.values??{},d)?bn(t.values[d]):m,g=t?.touched?.[d]===!0,h=Mo(f,y),I=t?.submitted||g?h:null,b=typeof f.maxLength=="number"?Math.max(0,Math.round(f.maxLength)):void 0,x={id:d,variableId:f.variableId,value:y,initialValue:m,valid:!h,error:I,touched:g,required:f.required===!0,trim:f.trim===!0,placeholder:f.placeholder===void 0?"":String(f.placeholder),multiline:f.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[d]=x,u.push(x),c[d]=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??{})}}}},Rr=[],Pl="line",qo="interaction",In=({sectionId:e,lineId:r,rollbackPolicy:n,returnable:o})=>({sectionId:e,lineId:r,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{}}),Vo=e=>{let r=me(e)?tr(e):e,{contextVariableDefaultValues:n}=rn(r??{});return D(n)},Xl=()=>({...D(ft)}),Wl=({loadedRuntime:e,runtimeIds:r,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:D(n),hasLoadedValues:!1};if(!M(e))throw new Error(`Malformed ${o}.`);let a=D(n),t=!1;return r.forEach(s=>{e[s]!==void 0&&(a[s]=sn(s,D(e[s])),t=!0)}),{runtimeState:a,hasLoadedValues:t}},nh=({projectData:e,loadedGlobalRuntime:r={}})=>Wl({loadedRuntime:r,runtimeIds:Js,defaults:Zs(e),path:"global.runtime"}).runtimeState,sh=({loadedContextRuntime:e={}})=>{let{runtimeState:r,hasLoadedValues:n}=Wl({loadedRuntime:e,runtimeIds:Qs,defaults:Xl(),path:"context.runtime"});return n?r:void 0},Cr=e=>{let r=Array.isArray(e?.contexts)?e.contexts:[];return r[r.length-1]},te=e=>{let r=Cr(e);return r?.kind==="sceneReplay"&&M(r.sceneReplay)?r:null},Kl=(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)})},oh=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)}}),ih=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"})},ah=(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=xe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Jr({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}})},lh=e=>e.runtime?(Qs.forEach(r=>{e.runtime[r]===void 0&&(e.runtime[r]=D(ft[r]))}),e.runtime):(e.runtime=Xl(),e.runtime),ch=e=>Aa(e.global),Jl=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:ch(e)}})},Fo=(e,r,n)=>{let o=sn(r,n);if(r in ft){let a=Cr(e);if(!a)return o;let t=lh(a);return t[r]=o,o}return e.global[r]=o,o},Uo=({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:Oy(),variables:Vo(r),rollback:vt({pointer:e})}),Kr=e=>e?(e.currentPointerMode="read",M(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,uh=(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=Uo({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,ph(e,{queueRender:r}),a},ph=(e,{queueRender:r=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,Xr(e),Wr(e),e.global.nextLineConfig=At(),e.global.overlayStack=[],e.global.isLineCompleted=!0,No(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),r&&e.global.pendingEffects.push({name:"render"})},Ql=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?[In({sectionId:e.sectionId,lineId:e.lineId})]:[]}},fr=(e,r={})=>{if(e?.rollback)return Ql(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},Bo=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=fr(n);if(o.isRestoring)return;let a=To(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(In(r)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},dh=({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}},fh=({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(me(l)?Ut(l):l)!==o||l?.sectionId!==a||l?.lineId!==t||(l.returnable=!1),e},mh=({state:e},r={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:t,lineId:s}=r,i=Gr(n),l=e.global.saveSlots?.[i],u=me(l)?Ut(l):l;if(!l||u!==o)return e;let c=l.state?.contexts,p=Array.isArray(c)?c.at(-1):null,d=p?.rollback,f=d?.timeline?.[a];return!Number.isInteger(a)||d?.currentIndex!==a||p?.pointers?.read?.sectionId!==t||p?.pointers?.read?.lineId!==s||f?.sectionId!==t||f?.lineId!==s||(f.returnable=!1,d.returnabilityVersion=Ro,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},yh=e=>{let r=e.contexts?.[e.contexts.length-1],n=r?.rollback;if(!n||n.isRestoring||!Array.isArray(n.timeline)||typeof n.currentIndex!="number")return null;let o=Rr[Rr.length-1],a=typeof o?.checkpointIndex=="number"?o.checkpointIndex:n.currentIndex;if(a<0||a>=n.timeline.length)return null;if(typeof o?.checkpointIndex!="number"&&a<n.timeline.length-1){n.timeline=n.timeline.slice(0,a+1);let t=To(r);t&&(t.checkpointLengths=t.checkpointLengths.slice(0,a+1))}return n.timeline[a]??null},hh=({state:e},r={})=>{let n=r?.source===Pl?Pl:qo,o=e.contexts?.[e.contexts.length-1],a=o?.rollback;if(!a||a.isRestoring||!Array.isArray(a.timeline)||typeof a.currentIndex!="number"||a.currentIndex<0||a.currentIndex>=a.timeline.length)return Rr.push({checkpointIndex:null,source:n}),e;if(a.currentIndex<a.timeline.length-1){a.timeline=a.timeline.slice(0,a.currentIndex+1);let t=To(o);t&&(t.checkpointLengths=t.checkpointLengths.slice(0,a.currentIndex+1))}return Rr.push({checkpointIndex:a.currentIndex,source:n}),e},gh=({state:e})=>(Rr.pop(),e),Be=(e,r,n)=>{let a=Rr[Rr.length-1]?.source??qo;if(!kb(r,a))return;let t=yh(e);t&&(Array.isArray(t.executedActions)||(t.executedActions=[]),t.executedActions.push({type:r,payload:D(n)}))},xl=(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(Te(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);pt(u,a),tn(c,t,a),zs(c,t,s,a,{roundTo:i}),u==="context"&&(n.variables[a]=nn(n.variables[a],t,s,{roundTo:i}))}},bh=(e,r)=>{Array.isArray(r?.executedActions)&&r.executedActions.forEach(({type:n,payload:o})=>{Pb(e,n,o)})},Ih=(e,r)=>{let{sectionId:n,lineId:o}=r,s=be({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Object.entries(s).forEach(([i,l])=>{_c(e,i,l)})},Zl=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=fr(n),a=o.timeline[r];if(!a)return e;e.global.autoMode&&St({state:e}),e.global.skipMode&&dr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=r;try{n.variables=Vo(e.projectData),n.kind==="sceneReplay"&&(Kl(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(gn),e.global.overlayStack=[],Xr(e),Wr(e),e.global.isLineCompleted=!0;let t=o.replayStartIndex??0;for(let l=t;l<=r;l++)l>t&&jo(e),Ih(e,o.timeline[l]),bh(e,o.timeline[l]);let s=Kr(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=Do(n);i&&(i.currentLength=Math.min(i.checkpointLengths[r]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Ol(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},wh=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;Nl(r),at(r),lt(r),ct(r),Ar(r?.resources?.variables??{});let u=r.story.initialSceneId,c=r.story.scenes[u],p=c.initialSectionId,d=c.sections[p],f={sceneId:u,sectionId:p,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:m}=rn(r),y={...m,...Mr(a,r.resources?.variables??{})};return{projectData:r,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Ny(s,"accountViewedRegistry"),accountReplayRegistry:Dy(i),nextLineConfig:At(),imageGalleryNavigation:Oo(),sceneReplayNavigation:_o(),sceneReplayEntryId:0,audioCommandId:0,musicRoomPlayer:wn(),saveSlots:_y(o),localizationPackages:D(l),overlayStack:[],variables:y,...nh({projectData:r,loadedGlobalRuntime:t})},contexts:[Uo({pointer:f,projectData:r})]}},vh=({state:e})=>e.global.overlayStack||[],Ah=({state:e})=>e.global.pendingEffects,ec=({state:e})=>e.global.skipMode,kh=({state:e})=>e.global.autoMode,rc=({state:e})=>e.global.dialogueUIHidden,tc=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(!n)return[];let o,a=M(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)o=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:u,lineId:c}=n.pointers.read,p=be({state:e},{sectionId:u});if(!p?.lines||!Array.isArray(p.lines))return[];let d=p.lines.findIndex(f=>f.id===c);o=p.lines.slice(0,d+1).map(f=>({sectionId:u,lineId:f.id}))}let t=[],s=ut({variables:{...e.global?.variables??{},...Cr(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=u=>{let c=i.get(u.sectionId);if(!c){let d=be({state:e},{sectionId:u.sectionId}),f=Array.isArray(d?.lines)?d.lines:[];c={lines:f,lineIndexes:new Map(f.map((m,y)=>[m.id,y])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(u.sectionId,c)}let p=c.lineIndexes.get(u.lineId);if(p===void 0)return null;for(;c.nextLineIndex<=p;){let d=c.lines[c.nextLineIndex],f=d.actions||{};c.presentationState=kr([c.presentationState,f]),c.projections.set(d.id,{line:d,lineActions:f,dialogueState:c.presentationState.dialogue||{}}),c.nextLineIndex+=1}return c.projections.get(u.lineId)??null};for(let u of o){if(!Sy(u))continue;let c=l(u);if(!c)continue;let{line:p,lineActions:d,dialogueState:f}=c;if(!d.dialogue)continue;let m=en({characterId:f.characterId,character:f.character,characters:e.projectData.resources?.characters??{},variables:s}),y=Ey({sectionId:u.sectionId,lineId:p.id,content:d.dialogue.append===!0?f.content:d.dialogue.content,dialogueState:f,characterName:m}),g=t[t.length-1];if((a?u.appendToPrevious===!0:d.dialogue.append===!0)&&g?.sectionId===u.sectionId){t[t.length-1]={...t[t.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}t.push(y)}return t},Ph=(e,r,n)=>{let o=!1;for(let a of r??[]){let{slotId:t,saveSlotIdentity:s,sectionId:i,lineId:l}=a,u=e.global.saveSlots?.[Gr(t)],c=me(u)?Ut(u):u,p=u?.state?.contexts?.at(-1);!u||c!==s||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=D(n),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},xh=({state:e},r={})=>{let n=Cr(e),o=n?.pointers?.read,a=xt({state:e});if(!n||!M(a?.actions?.dialogue))return e;let t=fr(n),s=t.timeline?.[t.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=Do(n),u=l?.checkpointLengths?.[t.currentIndex],c=t.currentIndex>0?l?.checkpointLengths?.[t.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(r.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||r.forceNewOccurrence!==!0&&i&&l&&u===l.currentLength&&u>c&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let d=Ry(n);d.currentLength<d.entries.length&&(d.entries=d.entries.slice(0,d.currentLength));let f=a.actions.dialogue.append===!0&&r.appendToPrevious===!0&&Vl(e.projectData,p,o);if(d.entries.push({sectionId:o.sectionId,lineId:o.lineId,...f?{appendToPrevious:!0}:{}}),d.currentLength=d.entries.length,i){for(;d.checkpointLengths.length<t.timeline.length;)d.checkpointLengths.push(d.checkpointLengths.at(-1)??0);d.checkpointLengths[t.currentIndex]=d.currentLength}return Ph(e,r.savedCheckpointOccurrences,d),e},Eh=({state:e})=>e.global.confirmDialog??null,Pt=({state:e},{pointer:r}={})=>{let n=r??Oe({state:e})?.pointer,o=rh({state:e,pointer:n});return th({state:e,form:o.form,pointer:n})},Sh=({state:e},{pointer:r}={})=>!!Pt({state:e},{pointer:r}),xe=({state:e},{pointer:r}={})=>{let n=Pt({state:e},{pointer:r});if(n)return{source:pr,formId:n.id,formKey:n.key};let o=lc({state:e,pointer:r});return o?{source:zr,resourceId:o}:null},Rh=({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=be({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},Yo=({registry:e},r)=>{let{resourceId:n}=r;return!!(Array.isArray(e?.resources)?e.resources:[]).find(t=>t.resourceId===n)},zo=({state:e},r)=>Rh({state:e,registry:e.global.accountViewedRegistry},r),Oh=({state:e},r)=>Yo({registry:e.global.accountViewedRegistry},r),wt=(e,r)=>!Yo({registry:e.global.accountViewedRegistry},{resourceId:r.imageId}),Ho=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Go=(e,r)=>{let n=Ho(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},xo=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!wt(e,r[a]))return r[a]},Ch=({state:e})=>{let r=e.projectData?.resources?.imageGallery;return r===void 0?void 0:D(r)},nc=({state:e})=>{let r=e.projectData?.resources?.imageGallery;if(r===void 0)return null;let n=e.global.imageGalleryNavigation??Oo(),o=Ho(r),a=Go(r,n),t=a*r.pageSize,s=r.groups.slice(t,t+r.pageSize).map(l=>({groupId:l.id,locked:wt(e,l.variants[0]),variants:l.variants.map(u=>({variantId:u.id,imageId:u.imageId,locked:wt(e,u)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=r.groups.findIndex(f=>f.id===n.groupId),u=r.groups[l],c=u?.variants.findIndex(f=>f.id===n.variantId),p=c===void 0||c<0?void 0:u.variants[c],d=l<0?-1:Math.floor(l/r.pageSize);p&&d===a&&!wt(e,p)&&(i={groupId:u.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:xo(e,u.variants,c,-1)!==void 0,canMoveToNextVariant:xo(e,u.variants,c,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Xo=(e,r)=>!Yo({registry:e.global.accountViewedRegistry},{resourceId:r.soundId}),Wo=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ko=(e,r)=>{let n=Wo(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Eo=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!Xo(e,r[a]))return r[a]},sc=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}),$h=(e,r)=>({...sc(r),locked:Xo(e,r)}),El=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")}`},_h=({state:e})=>{let r=e.projectData?.resources?.musicRoom;return r===void 0?void 0:D(r)},oc=({state:e})=>{let r=e.projectData?.resources?.musicRoom;if(r===void 0)return null;let n=e.global.musicRoomPlayer??wn(),o=Wo(r),a=Ko(r,n),t=a*r.pageSize,s=r.tracks.slice(t,t+r.pageSize).map(c=>$h(e,c)),i=r.tracks.findIndex(c=>c.id===n.trackId),l=r.tracks[i],u=l?{...sc(l),canPlayPreviousTrack:Eo(e,r.tracks,i,-1)!==void 0,canPlayNextTrack:Eo(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:El(n.positionMs),durationText:n.durationMs===null?null:El(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}}},Jo=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Qo=(e,r)=>{let n=Jo(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},jh=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;return r===void 0?void 0:D(r)},Nh=({state:e})=>te(e)!==null,Dh=({state:e})=>{let r=te(e);return r?{sceneId:r.sceneReplay.sceneId,entryId:r.sceneReplay.entryId}:null},ic=(e,r)=>e.global.accountReplayRegistry?.sceneIds?.includes(r)===!0,ac=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;if(r===void 0)return null;let n=e.global.sceneReplayNavigation??_o(),o=Jo(r),a=Qo(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:!ic(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}}},Th=({state:e})=>e.global.nextLineConfig,lc=({state:e,pointer:r}={})=>{let n=r??Oe({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=be({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},cc=({state:e})=>!!lc({state:e}),Lh=({state:e})=>structuredClone(e),Mh=({state:e})=>D(e.projectData.resources?.achievements??{}),qh=({state:e},r)=>{let n=e.projectData.resources?.achievements?.[r?.resourceId];return n===void 0?void 0:D(n)},uc=({state:e})=>e.global.saveSlots,Vh=({state:e},r)=>{let n=r?.slotId,o=Gr(n);return e.global.saveSlots[o]},pc=({state:e})=>D(e.global.localizationPackages),Zo=({state:e})=>Pr(e),Fh=({state:e},r)=>lr(e,r?.runtimeId),An=({state:e})=>{let r={...e.global?.variables??{},...Cr(e)?.variables??{}};return ut({variables:r,runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{}})},Oe=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},be=({state:e},r)=>{let{sectionId:n}=r;return Qe(e.projectData,n).section},xt=({state:e})=>{let r=Oe({state:e});if(!r?.pointer)return;let{sectionId:n,lineId:o}=r.pointer,a=be({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(t=>t.id===o)},dc=({state:e})=>{let{sectionId:r,lineId:n}=Oe({state:e}).pointer,a=be({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(d=>{p[d]=c[d]}),p});return kr(i)},Uh=e=>{let r=xt({state:e})?.actions?.dialogue;if(r?.clear===!0||!Array.isArray(r?.content))return"";let n=An({state:e});return r.content.map(o=>`${qr(o?.text,{variables:n})??""}`).join("")},Jr=({state:e})=>vl({text:Uh(e),baseDelay:lr(e,"autoForwardDelay"),speed:lr(e,"autoForwardSpeed")}),Bh=({state:e})=>{let r=fc({state:e}),o=xt({state:e})?.actions??{},a=kr([r??{},o]);return Gs(r??{},a??{})},Yh=({state:e},{sectionId:r})=>{let n=be({state:e},{sectionId:r});if(!n?.lines)return[];let o=[],a={};for(let t of n.lines){let s=t.actions||{},i=kr([a,s]),l=Gs(a,i);o.push({id:t.id,changes:l,presentationState:i}),a=Xs(i)}return o},zh=({state:e},{sectionId:r,includePresentationState:n=!1})=>{let o=Yh({state:e},{sectionId:r});return n?{lines:o}:{lines:o.map(({presentationState:a,...t})=>t)}},fc=({state:e})=>{let{sectionId:r,lineId:n}=Oe({state:e}).pointer,a=be({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 Xs(kr(i))},ei=({state:e},{slotsPerPage:r=6}={})=>{let a=((Zo({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[Gr(i)]||{};t.push({...l,slotId:i})}return{saveSlots:t}},Hh=uc,Gh=ei,Xh=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},Wh=({state:e},r={})=>{let n=dc({state:e}),o=fc({state:e}),a=xt({state:e})?.actions??{},t=e.global.pendingScreenTransition,s=t?.animations?{...a,screen:D(t)}:a,i=t?.animations&&o===null?{}:o,{sectionId:l}=Oe({state:e}).pointer,{sceneId:u}=Qe(e.projectData,l),c={...Zo({state:e}),localizationPackages:pc({state:e})},p=r?.activePersistentAnimations??[],d=r?.restoredPersistentAnimations??[],f=Pt({state:e}),m=cc({state:e}),y=nc({state:e}),g=oc({state:e}),h=ac({state:e}),I=An({state:e}),{saveSlots:b}=ei({state:e}),x=Xh(e);return Za({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:m,isFormVisible:!!f,canRollback:Dc({state:e}),skipOnlyViewedLines:!c.skipUnseenText,isLineCompleted:c.isLineCompleted,skipTransitionsAndAnimations:!!c.skipTransitionsAndAnimations||x,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:f,dialogueHistory:tc({state:e}),saveSlots:b,variables:I,runtime:c,activePersistentAnimations:p,restoredPersistentAnimations:d,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:D(e.global.musicRoomPlayer)})},Kh=({state:e},r)=>(e.global.confirmDialog=Xy(r),e.global.pendingEffects.push({name:"render"}),e),Jh=({state:e})=>(e.global.confirmDialog&&(Xr(e),e.global.pendingEffects.push({name:"render"})),e),Qh=({state:e},r)=>(e.global.overlayStack.push(r),e.global.pendingEffects.push({name:"render"}),Be(e,"pushOverlay",r),e),Zh=({state:e})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),Be(e,"popOverlay",void 0),e),eg=({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),rg=({state:e})=>(e.global.overlayStack=[],Xr(e),Wr(e),e.global.pendingEffects.push({name:"render"}),Be(e,"clearOverlays",void 0),e),tg=(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,Ky(e,n),Wr(e);let o=xe({state:e},{pointer:r}),a=o?.source===zr,t=o?.source===pr;tg(e,{activeInteraction:o});let s=te(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Ol(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}},kn=(e,r,n)=>{!(r?.source===zr||r?.source===pr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},mc=({state:e})=>(xe({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:Jr({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),ng=({state:e})=>{let r=e.global.autoMode;return xe({state:e})&&!r||(r?St({state:e}):mc({state:e})),e},yc=({state:e})=>(xe({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),dr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),sg=({state:e})=>{let r=ec({state:e});return xe({state:e})&&!r||(r?dr({state:e}):yc({state:e})),e},Pn=({state:e})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),Be(e,"showDialogueUI",void 0),e),hc=({state:e})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),Be(e,"hideDialogueUI",void 0),e),og=({state:e})=>(rc({state:e})?Pn({state:e}):hc({state:e}),e),mr=(e,r,n)=>(Fo(e,r,n),Jl(e),e.global.pendingEffects.push({name:"render"}),e),Rt=(e,r,n,o)=>{let a=Fo(e,r,n);return e.global.pendingEffects.push({name:"render"}),Be(e,o,{value:a}),e},ig=({state:e},r)=>mr(e,"dialogueTextSpeed",r?.value),ag=({state:e},r)=>mr(e,"autoForwardDelay",r?.value),lg=({state:e},r)=>mr(e,"autoForwardSpeed",r?.value),cg=({state:e},r)=>mr(e,"skipUnseenText",r?.value),ug=({state:e},r)=>mr(e,"skipTransitionsAndAnimations",r?.value),pg=({state:e},r)=>mr(e,"soundVolume",r?.value),dg=({state:e},r)=>mr(e,"musicVolume",r?.value),fg=({state:e},r)=>mr(e,"muteAll",r?.value),mg=({state:e},r)=>Rt(e,"saveLoadPagination",r?.value,"setSaveLoadPagination"),yg=({state:e})=>{let r=lr(e,"saveLoadPagination")+1;return Rt(e,"saveLoadPagination",r,"incrementSaveLoadPagination"),e},hg=({state:e})=>{let r=lr(e,"saveLoadPagination")-1;return Rt(e,"saveLoadPagination",r,"decrementSaveLoadPagination"),e},gg=({state:e},r)=>Rt(e,"menuPage",r?.value,"setMenuPage"),bg=({state:e},r)=>Rt(e,"menuEntryPoint",r?.value,"setMenuEntryPoint"),Ig=({state:e})=>(e.global.pendingEffects=[],e),wg=({state:e},r)=>(e.global.pendingEffects.push(r),e),vg=({state:e},r)=>{if(te(e))return e;let n=r?.resourceId;return Cl(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=Cl(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},gc=(e,{sectionId:r,resetStoryState:n=!1,screen:o})=>{let a=!!zl(o),t=be({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&&!uh(e,{queueRender:!a}))return e;let i=xe({state:e});n&&e.global.skipMode&&dr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let c=Kr(l),p=c.read;n||Or(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||fr(l,{compatibilityAnchor:!0}),c.read={sectionId:r,lineId:s.id},n?l.rollback=vt({pointer:c.read}):Bo(e,{sectionId:r,lineId:s.id})}let{activeInteraction:u}=Et(e,l?.pointers?.read,{screenTransition:o});return kn(e,i,u),e},kg=({state:e},r)=>{if(te(e))throw new Error("Cannot reset the story while a scene replay is active");return gc(e,{sectionId:r?.sectionId,resetStoryState:!0,screen:r?.screen})},bc=e=>(e.global.accountViewedRegistry=ky(e.global.accountViewedRegistry),e.global.accountViewedRegistry),xn=(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)}))}})},Ic=(e,r)=>{xn(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:[]}}])},Pg=(e,r,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=M(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=be({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},Or=(e,r)=>{if(te(e)||e.global.accountViewedRegistry===void 0)return;Pg(e,bc(e),r)&&Ic(e,{sections:[{sectionId:r.sectionId,lastLineId:r.lineId}],resources:[]})},xg=({state:e},r)=>(Or(e,r),e.global.pendingEffects.push({name:"render"}),e),Eg=({state:e},r)=>{if(te(e))return e;let{resourceId:n}=r;if(e.global.accountViewedRegistry!==void 0){let o=bc(e);o.resources.find(t=>t.resourceId===n)||(o.resources.push({resourceId:n}),Ic(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Ye=(e,r,n)=>{if(!M(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}"`)})},So=(e,r,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${r}`)},En=(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"}))},Sg=({state:e},r)=>{let n="showImageGalleryVariant";Ye(n,r,hy),So(n,"groupId",r.groupId),Object.prototype.hasOwnProperty.call(r,"variantId")&&So(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||wt(e,s)||En(e,{groupId:t.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},wc=(e,r,n,o)=>{Ye(o,r,Co);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=xo(e,s.variants,i,n);return l&&En(e,{...t,variantId:l.id}),e},Rg=({state:e},r)=>wc(e,r,-1,"moveToPreviousImageGalleryVariant"),Og=({state:e},r)=>wc(e,r,1,"moveToNextImageGalleryVariant"),Cg=({state:e},r)=>{if(Ye("clearImageGallerySelection",r,Co),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return En(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},vc=(e,r)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=Ho(n);if(r>=o)return e;let a=e.global.imageGalleryNavigation,t=Go(n,a);return r===t||En(e,{groupId:null,variantId:null,pageIndex:r}),e},$g=({state:e},r)=>{if(Ye("moveToImageGalleryPage",r,gy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return vc(e,r.pageIndex)},Ac=(e,r,n,o)=>{Ye(o,r,Co);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Go(a,e.global.imageGalleryNavigation)+n;return s<0?e:vc(e,s)},_g=({state:e},r)=>Ac(e,r,1,"moveToNextImageGalleryPage"),jg=({state:e},r)=>Ac(e,r,-1,"moveToPreviousImageGalleryPage"),Ze=(e,r,n)=>{if(!M(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}"`)})},Ng=(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"})},kc=(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:vn(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)},Dg=({state:e},r)=>{let n="playMusicRoomTrack";Ze(n,r,by),Ng(n,r.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(t=>t.id===r.trackId);return!a||Xo(e,a)||kc(e,a),e},Tg=({state:e},r)=>{Ze("playMusicRoom",r,Hr);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},Lg=({state:e},r)=>{Ze("pauseMusicRoom",r,Hr);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},Mg=({state:e},r)=>{Ze("stopMusicRoom",r,Hr);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},qg=({state:e},r)=>{if(Ze("seekMusicRoom",r,Iy),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},Pc=(e,r,n,o)=>{Ze(o,r,Hr);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=Eo(e,a.tracks,s,n);return i&&kc(e,i),e},Vg=({state:e},r)=>Pc(e,r,-1,"playPreviousMusicRoomTrack"),Fg=({state:e},r)=>Pc(e,r,1,"playNextMusicRoomTrack"),Ug=({state:e},r)=>{Ze("clearMusicRoomSelection",r,Hr);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,t={commandId:vn(e),operation:"resume"};return e.global.musicRoomPlayer={...wn({bgmPlayback:t}),pageIndex:a},Ve(e),e},xc=(e,r)=>{let n=e.projectData?.resources?.musicRoom;if(!n||r>=Wo(n))return e;let o=e.global.musicRoomPlayer,a=Ko(n,o);return r===a||(o.pageIndex=r,Ve(e)),e},Bg=({state:e},r)=>{if(Ze("moveToMusicRoomPage",r,wy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return xc(e,r.pageIndex)},Ec=(e,r,n,o)=>{Ze(o,r,Hr);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let t=Ko(a,e.global.musicRoomPlayer)+n;return t<0?e:xc(e,t)},Yg=({state:e},r)=>Ec(e,r,1,"moveToNextMusicRoomPage"),zg=({state:e},r)=>Ec(e,r,-1,"moveToPreviousMusicRoomPage"),Sr=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(),ah(e,n),e.global.pendingEffects.push({name:"render"}),!0},Hg=({state:e},r)=>{let n="startSceneReplay";if(Ye(n,r,vy),So(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||!ic(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=oh(e);ih(e);let c=Uo({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 Kl(e,c),e.contexts.push(c),Et(e,c.pointers.read),e},Sc=({state:e},r)=>{Ye("finishSceneReplay",r,$o);let o=te(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Cr(e)?.rollback?.isRestoring===!0)return e;let t=Oe({state:e})?.pointer,{sceneId:s}=Qe(e.projectData,t?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=Py(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),xn(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},Gg=({state:e},r)=>(Ye("exitSceneReplay",r,$o),Sr(e),e),Rc=(e,r)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||r>=Jo(n))return e;let o=Qo(n,e.global.sceneReplayNavigation);return r===o||(e.global.sceneReplayNavigation.pageIndex=r,e.global.pendingEffects.push({name:"render"})),e},Xg=({state:e},r)=>{if(Ye("moveToSceneReplayPage",r,Ay),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Rc(e,r.pageIndex)},Oc=(e,r,n,o)=>{Ye(o,r,$o);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let t=Qo(a,e.global.sceneReplayNavigation)+n;return t<0?e:Rc(e,t)},Wg=({state:e},r)=>Oc(e,r,1,"moveToNextSceneReplayPage"),Kg=({state:e},r)=>Oc(e,r,-1,"moveToPreviousSceneReplayPage"),Sn=(e,r)=>{let n=e.global.musicRoomPlayer;return!M(r)||r.id!==my||n.trackId===null||!n.playback||r.commandId!==n.playback.commandId?null:n},ri=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,Cc=(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),Jg=({state:e},r)=>{let n=Sn(e,r);return!n||n.readiness!=="loading"||!ri(r)?e:Cc(e,n,r,{readiness:"ready"})},Qg=({state:e},r)=>{let n=Sn(e,r);return!n||n.readiness!=="ready"||!ri(r)||n.status==="stopped"&&r.positionMs!==0||n.status==="ended"&&r.positionMs!==r.durationMs?e:Cc(e,n,r)},Zg=({state:e},r)=>{let n=Sn(e,r);return!n||n.readiness!=="ready"||n.status!=="playing"||!ri(r)||r.positionMs!==r.durationMs||(n.status="ended",n.positionMs=r.positionMs,n.durationMs=r.durationMs,n.seekFallback=null,Ve(e)),e},eb=({state:e},r)=>{let n=Sn(e,r);if(!n||typeof r.errorCode!="string"||!yy.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},$c=({state:e},r)=>{let n=Cy(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=xe({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},rb=({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=Gr(n),s=D(e.contexts);s?.forEach(u=>{Kr(u),Ql(u.rollback),jy(u.rollback)});let i={contexts:s},l={formatVersion:Rl,slotId:Dl(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},tb=({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=Gr(n),a=e.global.saveSlots[o];if(a){let t=Gy(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,Xr(e),Wr(e),No(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},nb=({state:e},r)=>{if(te(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=r;Nl(n),at(n),lt(n),ct(n),Ar(n?.resources?.variables??{}),Zs(n),e.projectData=n,e.global.imageGalleryNavigation=Oo(),e.global.sceneReplayNavigation=_o(),No(e);let o=n?.resources?.variables??{},{contextVariableDefaultValues:a,globalVariablesDefaultValues:t}=rn(n??{});return Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...t,...Mr(e.global.variables,o)}),e.contexts?.forEach(s=>{Object.prototype.hasOwnProperty.call(s??{},"variables")&&(s.variables={...a,...Mr(s.variables,o)})}),Xr(e),Wr(e),e.global.pendingEffects.push({name:"render"}),e},sb=({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(!M(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,Fo(e,"localizationPackageId",n),Jl(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Jr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},ob=({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&&!be({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=be({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=xe({state:e}),u=Kr(a);u.read={sectionId:t,lineId:o};let{activeInteraction:c}=Et(e,u.read);return kn(e,l,c),e},ib=({state:e},r)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Pn({state:e}),e;let n=xe({state:e});if(n?.source===zr&&r?.bypassChoice!==!0||n?.source===pr&&r?._interactionSource!==pr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,te(e)?.sceneReplay.exitOnLineCompleted)return Sr(e),e;let d=Oe({state:e})?.pointer,f=d?.sectionId,m=d?.lineId;f&&m&&Or(e,{sectionId:f,lineId:m}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Jr({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 Sr(e),e;let a=Oe({state:e})?.pointer,t=a?.sectionId,s=be({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],d=!lr(e,"skipUnseenText");if(e.global.skipMode&&d&&!zo({state:e},{sectionId:t,lineId:p.id}))return dr({state:e}),e;if(i&&!i.rollback&&fr(i,{compatibilityAnchor:!0}),i){let m=Kr(i),y=m.read?.lineId;y&&t&&Or(e,{sectionId:t,lineId:y}),m.read={sectionId:t,lineId:p.id}}Bo(e,{sectionId:t,lineId:p.id}),jo(e);let{activeInteraction:f}=Et(e,{sectionId:t,lineId:p.id});kn(e,n,f)}else{if(te(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Sr(e),e;e.global.autoMode&&St({state:e}),e.global.skipMode&&dr({state:e})}return e},ab=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,te(e)?.sceneReplay.exitOnLineCompleted)return Sr(e),e;let n=xe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Jr({state:e})}});let o=Oe({state:e})?.pointer,a=o?.sectionId,t=o?.lineId;a&&t&&Or(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},lb=({state:e},r)=>gc(e,{sectionId:r?.sectionId,screen:r?.screen}),cb=({state:e},r)=>{let n=r?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!n)return Pn({state:e}),e;let o=xe({state:e});if(o?.source===zr&&r?.bypassChoice!==!0||o?.source===pr&&r?._interactionSource!==pr||o&&o.source!==zr&&o.source!==pr)return e;let a=te(e);if(a?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(Sr(e),e):(a.sceneReplay.exitOnLineCompleted=!0,e);let t=Oe({state:e})?.pointer,s=t?.sectionId,i=be({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],u=i?.lines||[],p=u.findIndex(d=>d.id===t?.lineId)+1;if(p<u.length){let d=u[p],f=!lr(e,"skipUnseenText");if(e.global.skipMode&&f&&!zo({state:e},{sectionId:s,lineId:d.id})&&(dr({state:e}),!n))return e;if(l&&!l.rollback&&fr(l,{compatibilityAnchor:!0}),l){let y=Kr(l),g=y.read?.lineId;g&&s&&Or(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:d.id}}Bo(e,{sectionId:s,lineId:d.id}),jo(e);let{activeInteraction:m}=Et(e,{sectionId:s,lineId:d.id});kn(e,o,m)}else{if(te(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Sr(e),e;e.global.autoMode&&St({state:e}),e.global.skipMode&&dr({state:e}),e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))}return e},ti=(e,r={})=>{let n=Pt({state:e});return!n||r.formKey&&r.formKey!==n.key||r.formId&&r.formId!==n.id?null:n},ub=(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(Te(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),tn(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}},pb=(e,r)=>({id:e.id,key:e.key,valid:!0,values:D(r),fields:D(e.fields),fieldList:D(e.fieldList)}),db=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let r=Oe({state:e})?.pointer,n=r?.sectionId,o=r?.lineId;n&&o&&Or(e,{sectionId:n,lineId:o})},fb=({state:e},r={})=>{let n=ti(e,r),o=r.field;if(!n?.fields?.[o])return e;let a=Gl(e,n.key),t=bn(r.value),s=n.fields[o],i=Mo(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},mb=({state:e},r={})=>{let n=ti(e,r);if(!n)return{submitted:!1,valid:!1,reason:"inactive"};let o=Gl(e,n.key);o.submitted=!0;let a={},t={};if(Object.entries(n.fields).forEach(([p,d])=>{let f=Object.prototype.hasOwnProperty.call(o.values,p)?o.values[p]:d.value,m=Mo(d,f);o.touched[p]=!0,m&&(t[p]=m),a[p]=Hl(d,f)}),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,d])=>{let{scope:f}=ub(e,d),m=f==="context"?s.variables:e.global.variables,y=a[p];m[d.variableId]=nn(m[d.variableId],"set",y),f==="context"&&(i=!0,u.push({variableId:d.variableId,op:"set",value:y})),(f==="device"||f==="account")&&l.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:D(m[d.variableId])})}),i&&Be(e,"updateVariable",{id:"submitForm",operations:u}),xn(e,l);let c=pb(n,a);return db(e),delete e.global.formDrafts[n.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:c}},yb=({state:e},r={})=>{let n=ti(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"}},hb=({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 d=e.projectData.resources?.variables?.[l],f=d?.scope,m=d?.type;if(Te(d))throw new Error(`Cannot update computed variable: ${l}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${l}`);if(pt(f,l),tn(m,u,l),zs(m,u,c,l,{roundTo:p}),te(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${l}" while a scene replay is active`);let y=f==="context"?a.variables:e.global.variables;if(f==="context"){t=!0;let g={variableId:l,op:u,value:c};p!==void 0&&(g.roundTo=p),i.push(g)}y[l]=nn(y[l],u,c,{roundTo:p}),(f==="device"||f==="account")&&s.push({scope:f,path:`variables.${l}`,op:"set",value:D(y[l])})}),t&&Be(e,"updateVariable",{id:n,operations:i}),xn(e,s),e.global.pendingEffects.push({name:"render"}),e},Sl=e=>(r,n)=>e({state:r},n),gb=e=>({variables:ut({variables:{...e.global?.variables??{},...Cr(e)?.variables??{}},runtime:Pr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Pr(e)}),bb=e=>{if(!M(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")},Ib=(e,r,n)=>{if(!M(e))throw new Error(`conditional branch at index ${r} must be an object`);if(!M(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")},wb=(e,r)=>{bb(r);for(let n=0;n<r.branches.length;n+=1){let o=r.branches[n];if(Ib(o,n,r.branches.length),!(Object.prototype.hasOwnProperty.call(o,"when")&&!it(o.when,gb(e)))){Object.entries(o.actions).forEach(([t,s])=>{_c(e,t,s)});return}}},vb={conditional:{replayLine:wb},updateVariable:{recordSources:[qo],replayLine:xl,replayRecorded:xl,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Sl($c)},finishSceneReplay:{replayLine:Sl(Sc)}},Rn=e=>vb[e]??null,Ab=e=>Rn(e)?.persistInSaveSlot===!0,kb=(e,r)=>{let n=Rn(e)?.recordSources;return Array.isArray(n)&&n.includes(r)},Pb=(e,r,n)=>{Rn(r)?.replayRecorded?.(e,n)},_c=(e,r,n)=>{Rn(r)?.replayLine?.(e,n)},xb=e=>e?.returnable!==!1,jc=(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(xb(e.timeline[o])&&(n-=1,n===0))return o;return-1},Nc=({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=jc(a,n);if(t<0||t>=a.timeline.length)return null;let s=a.timeline[t];return{sectionId:s.sectionId,lineId:s.lineId}},Dc=({state:e})=>Nc({state:e},{offset:-1})!==null,Eb=({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=fr(o,{compatibilityAnchor:!o.rollback}),t=jc(a,n);return t<0||t>=a.timeline.length?e:Zl(e,t)},Sb=({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=fr(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:Zl(e,i)},Tc=e=>{let r=wh(e);return Ki(r,{selectPendingEffects:Ah,selectSkipMode:ec,selectAutoMode:kh,selectIsChoiceVisible:cc,selectIsFormVisible:Sh,selectActiveInteraction:xe,selectActiveForm:Pt,selectDialogueUIHidden:rc,selectDialogueHistory:tc,selectConfirmDialog:Eh,selectIsLineAccountViewed:zo,selectIsResourceAccountViewed:Oh,selectImageGalleryConfig:Ch,selectImageGallery:nc,selectMusicRoomConfig:_h,selectMusicRoom:oc,selectSceneReplayConfig:jh,selectSceneReplay:ac,selectIsSceneReplayActive:Nh,selectActiveSceneReplayEntry:Dh,selectNextLineConfig:Th,selectSystemState:Lh,selectAchievements:Mh,selectAchievement:qh,selectSaveSlotMap:uc,selectSaveSlots:Hh,selectSaveSlot:Vh,selectLocalizationPackages:pc,selectRuntime:Zo,selectRuntimeValue:Fh,selectAllVariables:An,selectCurrentPointer:Oe,selectSection:be,selectCurrentLine:xt,selectPresentationState:dc,selectAutoForwardTimerDelay:Jr,selectPresentationChanges:Bh,selectSectionLineChanges:zh,selectSaveSlotPage:ei,selectCurrentPageSlots:Gh,selectRenderState:Wh,selectOverlayStack:vh,selectLineIdByOffset:Nc,selectCanRollback:Dc,selectRollbackCursor:dh,startAutoMode:mc,stopAutoMode:St,toggleAutoMode:ng,startSkipMode:yc,stopSkipMode:dr,toggleSkipMode:sg,showDialogueUI:Pn,hideDialogueUI:hc,toggleDialogueUI:og,setDialogueTextSpeed:ig,setAutoForwardDelay:ag,setAutoForwardSpeed:lg,setSkipUnseenText:cg,setSkipTransitionsAndAnimations:ug,setSoundVolume:pg,setMusicVolume:dg,setMuteAll:fg,setSaveLoadPagination:mg,incrementSaveLoadPagination:yg,decrementSaveLoadPagination:hg,setMenuPage:gg,setMenuEntryPoint:bg,showConfirmDialog:Kh,hideConfirmDialog:Jh,resetStoryAtSection:kg,clearPendingEffects:Ig,appendPendingEffect:wg,completeAchievement:vg,setAchievementProgress:Ag,beginRollbackActionBatch:hh,endRollbackActionBatch:gh,markRollbackCheckpointTransient:fh,markSavedRollbackCheckpointTransient:mh,recordCurrentDialogueHistory:xh,addViewedLine:xg,addViewedResource:Eg,showImageGalleryVariant:Sg,moveToPreviousImageGalleryVariant:Rg,moveToNextImageGalleryVariant:Og,clearImageGallerySelection:Cg,moveToImageGalleryPage:$g,moveToNextImageGalleryPage:_g,moveToPreviousImageGalleryPage:jg,playMusicRoomTrack:Dg,playMusicRoom:Tg,pauseMusicRoom:Lg,stopMusicRoom:Mg,seekMusicRoom:qg,playPreviousMusicRoomTrack:Vg,playNextMusicRoomTrack:Fg,clearMusicRoomSelection:Ug,moveToMusicRoomPage:Bg,moveToNextMusicRoomPage:Yg,moveToPreviousMusicRoomPage:zg,musicRoomSoundReady:Jg,musicRoomSoundProgress:Qg,musicRoomSoundComplete:Zg,musicRoomSoundError:eb,startSceneReplay:Hg,finishSceneReplay:Sc,exitSceneReplay:Gg,moveToSceneReplayPage:Xg,moveToNextSceneReplayPage:Wg,moveToPreviousSceneReplayPage:Kg,setNextLineConfig:$c,saveSlot:rb,loadSlot:tb,updateProjectData:nb,updateLocalizationPackage:sb,sectionTransition:lb,jumpToLine:ob,nextLine:ib,markLineCompleted:ab,rollbackToLine:Sb,rollbackByOffset:Eb,pushOverlay:Qh,popOverlay:Zh,replaceLastOverlay:eg,clearOverlays:rg,updateFormField:fb,submitForm:mb,cancelForm:yb,updateVariable:hb,nextLineFromSystem:cb},{transformActionFirstArgument:o=>({state:o}),transformSelectorFirstArgument:o=>({state:o})})};var Rb="route-engine",Ob="projectPersistence";var Mc=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),ae=e=>Object.prototype.toString.call(e)==="[object Object]",Lc="variables.",Cb=(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)}},$b=(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)}},_b=(e,r)=>{let n=$b(e),o=Cb(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}},jb=(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))]}},Nb=(e,r)=>{let n=jb(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)])]}},qc=(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:{}}},Db=(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(Lc)?r.path.slice(Lc.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}].`)})},Tb=(e,r)=>{let n={};return Db(r).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=_b(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=Nb(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},ni=e=>{if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null},Lb=e=>{let r=ni(e);if(!r)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return r},Mb=e=>{let r=e??globalThis.indexedDB;if(!r)throw new Error("IndexedDB is not available in this environment.");return r},qb=({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}".`))}}),Vb=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=f=>{c||(c=!0,s(f))},d=()=>{c||(c=!0,t())};u.onerror=()=>{p(u.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},u.onsuccess=()=>{let f=qc(u.result),m=typeof o=="function"?o(f):o,y={namespace:n,version:1,...Mc(),...f,...m},g=l.put(y);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},i.oncomplete=()=>{d()},i.onerror=()=>{p(i.error??new Error(`IndexedDB transaction failed while updating namespace "${n}".`))},i.onabort=()=>{p(i.error??new Error(`IndexedDB transaction aborted while updating namespace "${n}".`))}})},Fb=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=d=>{u||(u=!0,t(d))},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}".`))}})},si=(e={})=>{let{indexedDB:r,databaseName:n=Rb,objectStoreName:o=Ob,namespace:a}=e,t=Mb(r),s=Lb(a),i=qb({indexedDB:t,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await Vb({databasePromise:i,objectStoreName:o,namespace:s});return{...Mc(),...qc(l)}},clear:async()=>Fb({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=>Tb(u,l)})}},Ub=si;var Gc=Xc;var Bb={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},er=Object.prototype.hasOwnProperty,Yb={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 f={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};t===null?t=[f]:t.push(f),s++}if(e.y===void 0){let f={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};t===null?t=[f]:t.push(f),s++}for(let f in e)if(!(f==="x"||f==="y"||f==="quality"||f==="kernelSize"||f==="repeatEdgePixels")){let m={instancePath:r,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(e.x!==void 0){let f=e.x;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:r+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.y!==void 0){let f=e.y;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:r+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.quality!==void 0){let f=e.quality;if(typeof f=="number"){if(f<1||isNaN(f)){let m={instancePath:r+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.kernelSize!==void 0){let f=e.kernelSize;if(!(typeof f=="number"&&!(f%1)&&!isNaN(f))){let m={instancePath:r+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[m]:t.push(m),s++}if(!(f===5||f===7||f===9||f===11||f===13||f===15)){let m={instancePath:r+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Yb.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};t===null?t=[m]:t.push(m),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let f={instancePath:r+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[f]:t.push(f),s++}}else{let f={instancePath:r,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),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 zb={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};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==="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:zb.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 Cn.errors=t,s===0}function Q(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&&(Cn(e.playback,{instancePath:r+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(t=t===null?Cn.errors:t.concat(Cn.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 Q.errors=t,s===0}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(!er.call(Bb.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&&(Q(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 $n.errors=t,s===0}function Xc(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),Xc.errors=t,s===0}var Wc=Kc;var Hb={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},Uc={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},$e=Fc().default;function Ce(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(!er.call(Uc.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($e(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($e(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:Uc.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 Ce.errors=t,s===0}function _n(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 f;if(e.resourceId===void 0&&(f="resourceId")||e.sounds===void 0&&(f="sounds")){let m={};t===null?t=[m]:t.push(m),s++}}var u=l===s;if(u){let f={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[f]:t.push(f),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 f;if(e.startDelayMs===void 0&&(f="startDelayMs")||e.sounds===void 0&&(f="sounds")){let m={};t===null?t=[m]:t.push(m),s++}}var d=p===s;if(d){let f={instancePath:r,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[f]:t.push(f),s++}else s=c,t!==null&&(c?t.length=c:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let f in e)if(!(f==="sounds"||f==="resourceId"||f==="loop"||f==="interruption"||f==="volume"||f==="muted"||f==="pan"||f==="startDelayMs")){let m={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(e.sounds!==void 0){let f=e.sounds;if(Array.isArray(f)){let m=f.length;for(let y=0;y<m;y++)Ce(f[y],{instancePath:r+"/sounds/"+y,parentData:f,parentDataProperty:y,rootData:a})||(t=t===null?Ce.errors:t.concat(Ce.errors),s=t.length)}else{let m={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[m]:t.push(m),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let f={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let f={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[f]:t.push(f),s++}if(e.interruption!==void 0){let f=e.interruption;if(typeof f!="string"){let m={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}if(!(f==="immediate"||f==="loopEnd")){let m={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Hb.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[m]:t.push(m),s++}}if(e.volume!==void 0){let f=e.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let m={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[m]:t.push(m),s++}if(f<0||isNaN(f)){let m={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let f={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[f]:t.push(f),s++}if(e.pan!==void 0){let f=e.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let m={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[m]:t.push(m),s++}if(f<-1||isNaN(f)){let m={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.startDelayMs!==void 0){let f=e.startDelayMs;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}}else{let f={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),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;var Gb={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 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 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],d=s,f=!0,m=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=m===s;if(s=d,t!==null&&(d?t.length=d: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;f=i}if(!f){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(!er.call(Gb.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 I=y[h];if(I&&typeof I=="object"&&!Array.isArray(I)){for(let b in I)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let x={instancePath: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=[x]:t.push(x),s++}if(I.id!==void 0&&typeof I.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(I.resourceId!==void 0&&typeof I.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(I.animationName!==void 0&&typeof I.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(I.animationSpeed!==void 0&&typeof I.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(I.loop!==void 0&&typeof I.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&&(Q(p.animations,{instancePath:r+"/items/"+c+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 jn.errors=t,s===0}function Qc(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),Qc.errors=t,s===0}var Zc=eu;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==="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 d={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};t===null?t=[d]:t.push(d),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 d=p.click;if(!(d&&typeof d=="object"&&!Array.isArray(d))){let f={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=[f]:t.push(f),s++}}}else{let d={instancePath:r+"/items/"+u+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),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&&(Q(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 eu(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),eu.errors=t,s===0}var ru=tu;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!=="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 Dn.errors=t,s===0}function tu(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),tu.errors=t,s===0}var nu=su;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)){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 Tn.errors=t,s===0}function su(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),su.errors=t,s===0}var ou=iu;var Bc={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 Ln(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(!er.call(Bc.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&&(Q(i.animations,{instancePath:r+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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:Bc.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 d=u[p];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={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=[f]:t.push(f),s++}if(d.resourceId===void 0){let f={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=[f]:t.push(f),s++}for(let f in d)if(!(f==="id"||f==="resourceId"||f==="animationName"||f==="animationSpeed"||f==="loop")){let m={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(d.id!==void 0&&typeof d.id!="string"){let f={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=[f]:t.push(f),s++}if(d.resourceId!==void 0&&typeof d.resourceId!="string"){let f={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=[f]:t.push(f),s++}if(d.animationName!==void 0&&typeof d.animationName!="string"){let f={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=[f]:t.push(f),s++}if(d.animationSpeed!==void 0&&typeof d.animationSpeed!="number"){let f={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=[f]:t.push(f),s++}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={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=[f]:t.push(f),s++}}else{let f={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=[f]:t.push(f),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&&(Q(l.animations,{instancePath:r+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 Ln.errors=t,s===0}function iu(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),iu.errors=t,s===0}var au=lu;function Mn(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&&(Q(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 Mn.errors=t,s===0}function lu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Mn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Mn.errors:t.concat(Mn.errors),s=t.length),lu.errors=t,s===0}var cu=uu;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)){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&&(Q(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 qn.errors=t,s===0}function uu(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),uu.errors=t,s===0}var pu=du;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 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&&(Q(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.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 Vn.errors=t,s===0}function du(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),du.errors=t,s===0}var fu=mu;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 Fn(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 d=0;d<p;d++)Ce(c[d],{instancePath:r+"/items/"+d,parentData:c,parentDataProperty:d,rootData:a})||(t=t===null?Ce.errors:t.concat(Ce.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 d=0;d<p;d++){let f=c[d];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let m={instancePath:r+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[m]:t.push(m),s++}if(f.sounds===void 0){let m={instancePath:r+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};t===null?t=[m]:t.push(m),s++}for(let m in f)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="sounds")){let y={instancePath:r+"/channels/"+d,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};t===null?t=[y]:t.push(y),s++}if(f.id!==void 0){let m=f.id;if(typeof m=="string"){if($e(m)<1){let y={instancePath:r+"/channels/"+d+"/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/"+d+"/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(f.volume!==void 0){let m=f.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let y={instancePath:r+"/channels/"+d+"/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(m<0||isNaN(m)){let y={instancePath:r+"/channels/"+d+"/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/"+d+"/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(f.muted!==void 0&&typeof f.muted!="boolean"){let m={instancePath:r+"/channels/"+d+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[m]:t.push(m),s++}if(f.pan!==void 0){let m=f.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let y={instancePath:r+"/channels/"+d+"/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(m<-1||isNaN(m)){let y={instancePath:r+"/channels/"+d+"/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/"+d+"/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(f.loop!==void 0&&typeof f.loop!="boolean"){let m={instancePath:r+"/channels/"+d+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[m]:t.push(m),s++}if(f.interruption!==void 0){let m=f.interruption;if(typeof m!="string"){let y={instancePath:r+"/channels/"+d+"/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(!(m==="immediate"||m==="loopEnd")){let y={instancePath:r+"/channels/"+d+"/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"};t===null?t=[y]:t.push(y),s++}}if(f.sounds!==void 0){let m=f.sounds;if(Array.isArray(m)){let y=m.length;for(let g=0;g<y;g++)Ce(m[g],{instancePath:r+"/channels/"+d+"/sounds/"+g,parentData:m,parentDataProperty:g,rootData:a})||(t=t===null?Ce.errors:t.concat(Ce.errors),s=t.length)}else{let y={instancePath:r+"/channels/"+d+"/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 m={instancePath:r+"/channels/"+d,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[m]:t.push(m),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 Fn.errors=t,s===0}function mu(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),mu.errors=t,s===0}var yu=hu;var Yc={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 Un(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 f=e.length;for(let m=0;m<f;m++){let y=e[m];if(y&&typeof y=="object"&&!Array.isArray(y)){if(y.text!==void 0&&typeof y.text!="string"){let g={instancePath:r+"/"+m+"/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+"/"+m+"/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+"/"+m+"/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+"/"+m+"/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+"/"+m+"/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+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[g]:t.push(g),s++}}}else{let f={instancePath:r,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[f]:t.push(f),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 Un.errors=t,s===0}function Bn(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 I;if(e.id===void 0&&(I="id")){let b={};t===null?t=[b]:t.push(b),s++}}var d=p===s;if(c=c||d,!c){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.type===void 0&&(x="type")){let v={};t===null?t=[v]:t.push(v),s++}}var d=I===s;if(c=c||d,!c){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.resourceId===void 0&&(k="resourceId")){let E={};t===null?t=[E]:t.push(E),s++}}var d=x===s;if(c=c||d,!c){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let N={};t===null?t=[N]:t.push(N),s++}}var d=k===s;if(c=c||d,!c){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let S;if(e.x===void 0&&(S="x")){let T={};t===null?t=[T]:t.push(T),s++}}var d=$===s;if(c=c||d,!c){let S=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let V;if(e.y===void 0&&(V="y")){let le={};t===null?t=[le]:t.push(le),s++}}var d=S===s;if(c=c||d,!c){let V=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Y;if(e.anchorX===void 0&&(Y="anchorX")){let ne={};t===null?t=[ne]:t.push(ne),s++}}var d=V===s;if(c=c||d,!c){let Y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.anchorY===void 0&&(oe="anchorY")){let he={};t===null?t=[he]:t.push(he),s++}}var d=Y===s;if(c=c||d,!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 d=oe===s;if(c=c||d,!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 d=ve===s;if(c=c||d,!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 d=se===s;if(c=c||d,!c){let ie=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let _;if(e.originX===void 0&&(_="originX")){let q={};t===null?t=[q]:t.push(q),s++}}var d=ie===s;if(c=c||d,!c){let _=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ee;if(e.originY===void 0&&(ee="originY")){let Ie={};t===null?t=[Ie]:t.push(Ie),s++}}var d=_===s;if(c=c||d,!c){let ee=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.layer===void 0&&(K="layer")){let Ee={};t===null?t=[Ee]:t.push(Ee),s++}}var d=ee===s;if(c=c||d,!c){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ge;if(e.opacity===void 0&&(ge="opacity")){let jt={};t===null?t=[jt]:t.push(jt),s++}}var d=K===s;if(c=c||d,!c){let ge=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Nr;if(e.blur===void 0&&(Nr="blur")){let Nt={};t===null?t=[Nt]:t.push(Nt),s++}}var d=ge===s;if(c=c||d,!c){let Nr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Dt;if(e.animations===void 0&&(Dt="animations")){let Tt={};t===null?t=[Tt]:t.push(Tt),s++}}var d=Nr===s;c=c||d}}}}}}}}}}}}}}}}if(c)s=u,t!==null&&(u?t.length=u:t=null);else{let I={};t===null?t=[I]:t.push(I),s++}var f=l===s;if(f){let I={instancePath:r,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[I]:t.push(I),s++}else s=i,t!==null&&(i?t.length=i:t=null);let m=s,y=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let I={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};t===null?t=[I]:t.push(I),s++}var h=g===s;if(y=y||h,!y){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let x={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};t===null?t=[x]:t.push(x),s++}var h=I===s;y=y||h}if(y)s=m,t!==null&&(m?t.length=m:t=null);else{let I={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[I]:t.push(I),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Un(e.content,{instancePath:r+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(t=t===null?Un.errors:t.concat(Un.errors),s=t.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let I={instancePath:r+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[I]:t.push(I),s++}if(e.width!==void 0&&typeof e.width!="number"){let I={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[I]:t.push(I),s++}if(e.height!==void 0&&typeof e.height!="number"){let I={instancePath:r+"/height",schemaPath:"#/properties/height/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 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)){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],d=s,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let m;if(p.resourceId===void 0&&(m="resourceId")||p.text===void 0&&(m="text")){let y={};t===null?t=[y]:t.push(y),s++}}var i=f===s;if(i){let m={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[m]:t.push(m),s++}else s=d,t!==null&&(d?t.length=d:t=null);if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let m={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[m]:t.push(m),s++}for(let m in p)if(!er.call(Yc.properties.items.items.properties,m)){let y={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};t===null?t=[y]:t.push(y),s++}if(p.id!==void 0&&typeof p.id!="string"){let m={instancePath:r+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}if(p.animationName!==void 0&&typeof p.animationName!="string"){let m={instancePath:r+"/items/"+c+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}if(p.animationSpeed!==void 0&&typeof p.animationSpeed!="number"){let m={instancePath:r+"/items/"+c+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.resourceId!==void 0&&typeof p.resourceId!="string"){let m={instancePath:r+"/items/"+c+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}if(p.text!==void 0&&(Bn(p.text,{instancePath:r+"/items/"+c+"/text",parentData:p,parentDataProperty:"text",rootData:a})||(t=t===null?Bn.errors:t.concat(Bn.errors),s=t.length)),p.transformId!==void 0&&typeof p.transformId!="string"){let m={instancePath:r+"/items/"+c+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}if(p.x!==void 0&&typeof p.x!="number"){let m={instancePath:r+"/items/"+c+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.y!==void 0&&typeof p.y!="number"){let m={instancePath:r+"/items/"+c+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let m={instancePath:r+"/items/"+c+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let m={instancePath:r+"/items/"+c+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let m={instancePath:r+"/items/"+c+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let m={instancePath:r+"/items/"+c+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let m={instancePath:r+"/items/"+c+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let m={instancePath:r+"/items/"+c+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let m={instancePath:r+"/items/"+c+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}if(p.layer!==void 0){let m=p.layer;if(typeof m!="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(!(m===10||m===30||m===50||m===70||m===90)){let y={instancePath:r+"/items/"+c+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:Yc.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 m=p.opacity;if(typeof m=="number"){if(m>1||isNaN(m)){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(m<0||isNaN(m)){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&&(Q(p.animations,{instancePath:r+"/items/"+c+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length))}else{let m={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[m]:t.push(m),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 Yn.errors=t,s===0}function hu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Yn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Yn.errors:t.concat(Yn.errors),s=t.length),hu.errors=t,s===0}var gu=bu;var Wb={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 zn(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,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.resourceId===void 0&&(h="resourceId")||e.sounds===void 0&&(h="sounds")){let I={};t===null?t=[I]:t.push(I),s++}}var f=d===s;if(f){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 m=s,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.startDelayMs===void 0&&(h="startDelayMs")||e.sounds===void 0&&(h="sounds")){let I={};t===null?t=[I]:t.push(I),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=m,t!==null&&(m?t.length=m: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 I={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};t===null?t=[I]:t.push(I),s++}if(e.sounds!==void 0){let h=e.sounds;if(Array.isArray(h)){let I=h.length;for(let b=0;b<I;b++)Ce(h[b],{instancePath:r+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:a})||(t=t===null?Ce.errors:t.concat(Ce.errors),s=t.length)}else{let I={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[I]:t.push(I),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 I={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[I]:t.push(I),s++}if(h<0||isNaN(h)){let I={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[I]:t.push(I),s++}}else{let I={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[I]:t.push(I),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 I={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[I]:t.push(I),s++}if(h<-1||isNaN(h)){let I={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[I]:t.push(I),s++}}else{let I={instancePath:r+"/pan",schemaPath:"#/properties/pan/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 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 I={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[I]:t.push(I),s++}if(!(h==="immediate"||h==="loopEnd")){let I={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Wb.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[I]:t.push(I),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let I={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[I]:t.push(I),s++}}else{let I={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[I]:t.push(I),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 zn.errors=t,s===0}function bu(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),bu.errors=t,s===0}var Iu=wu;var Kb={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 Hn(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 I={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};t===null?t=[I]:t.push(I),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,d=!0,f=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 m=f===s;if(s=p,t!==null&&(p?t.length=p:t=null),m){let g=s,h=s,I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.target===void 0&&(x="target")){let v={};t===null?t=[v]:t.push(v),s++}}var y=I===s;if(y){let x={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[x]:t.push(x),s++}else s=h,t!==null&&(h?t.length=h:t=null);var m=g===s;d=m}if(!d){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:Kb.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($e(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($e(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($e(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($e(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 Hn.errors=t,s===0}function wu(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),wu.errors=t,s===0}var vu=Au;var Jb={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 Qb={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 _r(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:Qb.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 _r.errors=t,s===0}function H(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++)_r(i[u],{instancePath:r+"/keyframes/"+u,parentData:i,parentDataProperty:u,rootData:a})||(t=t===null?_r.errors:t.concat(_r.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 H.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(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&&(H(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.x!==void 0&&(H(e.x,{instancePath:r+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.y!==void 0&&(H(e.y,{instancePath:r+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.scaleX!==void 0&&(H(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.scaleY!==void 0&&(H(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.rotation!==void 0&&(H(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?H.errors:t.concat(H.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 Gn.errors=t,s===0}function Xn(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&&(H(e.translateX,{instancePath:r+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.translateY!==void 0&&(H(e.translateY,{instancePath:r+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.alpha!==void 0&&(H(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.scaleX!==void 0&&(H(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.scaleY!==void 0&&(H(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?H.errors:t.concat(H.errors),s=t.length)),e.rotation!==void 0&&(H(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?H.errors:t.concat(H.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 Xn.errors=t,s===0}function $r(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&&(Xn(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Xn.errors:t.concat(Xn.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 $r.errors=t,s===0}var On={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"]}}]},Zb={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function Wn(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:Zb.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 Wn.errors=t,s===0}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.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++)_r(i[u],{instancePath:r+"/keyframes/"+u,parentData:i,parentDataProperty:u,rootData:a})||(t=t===null?_r.errors:t.concat(_r.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 Kn.errors=t,s===0}function Jn(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,d=!0,f=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 m=f===s;if(s=p,t!==null&&(p?t.length=p:t=null),m){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 m=b===s;d=m}if(!d){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 I=h===s;if(s=y,t!==null&&(y?t.length=y:t=null),I){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 I=b===s;g=I}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(!er.call(On.properties,b)){let x={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[x]:t.push(x),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let x={instancePath:r+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[x]:t.push(x),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let x={instancePath:r+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:On.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[x]:t.push(x),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 x=b.length;for(let v=0;v<x;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 x={instancePath:r+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[x]:t.push(x),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 x=b.length;for(let v=0;v<x;v++)Wn(b[v],{instancePath:r+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(t=t===null?Wn.errors:t.concat(Wn.errors),s=t.length)}else{let x={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[x]:t.push(x),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let x={instancePath:r+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[x]:t.push(x),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let x={instancePath:r+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:On.properties.combine.enum},message:"must be equal to one of the allowed values"};t===null?t=[x]:t.push(x),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let x={instancePath:r+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[x]:t.push(x),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let x={instancePath:r+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:On.properties.channel.enum},message:"must be equal to one of the allowed values"};t===null?t=[x]:t.push(x),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&&(Kn(e.progress,{instancePath:r+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(t=t===null?Kn.errors:t.concat(Kn.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 Jn.errors=t,s===0}function Qn(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,x=s,v=s,k=s,E=!1,$=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let S;if(e.prev===void 0&&(S="prev")){let T={};t===null?t=[T]:t.push(T),s++}}var p=$===s;if(E=E||p,!E){let S=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let V;if(e.next===void 0&&(V="next")){let le={};t===null?t=[le]:t.push(le),s++}}var p=S===s;if(E=E||p,!E){let V=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Y;if(e.mask===void 0&&(Y="mask")){let ne={};t===null?t=[ne]:t.push(ne),s++}}var p=V===s;E=E||p}}if(E)s=k,t!==null&&(k?t.length=k:t=null);else{let S={};t===null?t=[S]:t.push(S),s++}var d=v===s;if(d){let S={instancePath:r,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[S]:t.push(S),s++}else s=x,t!==null&&(x?t.length=x:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let S={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[S]:t.push(S),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 f=s,m=!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=f,t!==null&&(f?t.length=f:t=null),g){let b=s,x=s,v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let S;if(e.tween===void 0&&(S="tween")){let T={};t===null?t=[T]:t.push(T),s++}}var h=v===s;if(h){let S={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[S]:t.push(S),s++}else s=x,t!==null&&(x?t.length=x:t=null);let k=s,E=!1,$=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let S={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};t===null?t=[S]:t.push(S),s++}var I=$===s;if(E=E||I,!E){let S=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let V={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};t===null?t=[V]:t.push(V),s++}var I=S===s;if(E=E||I,!E){let V=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let Y={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};t===null?t=[Y]:t.push(Y),s++}var I=V===s;E=E||I}}if(E)s=k,t!==null&&(k?t.length=k:t=null);else{let S={instancePath:r,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[S]:t.push(S),s++}var g=b===s;m=g}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++}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 x={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[x]:t.push(x),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 x={instancePath:r+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[x]:t.push(x),s++}if(!(b==="update"||b==="transition")){let x={instancePath:r+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Jb.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[x]:t.push(x),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let x=b.payload;if(!(x&&typeof x=="object"&&!Array.isArray(x))){let v={instancePath: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 x={instancePath:r+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}e.tween!==void 0&&(Gn(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Gn.errors:t.concat(Gn.errors),s=t.length)),e.prev!==void 0&&($r(e.prev,{instancePath:r+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(t=t===null?$r.errors:t.concat($r.errors),s=t.length)),e.next!==void 0&&($r(e.next,{instancePath:r+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(t=t===null?$r.errors:t.concat($r.errors),s=t.length)),e.mask!==void 0&&(Jn(e.mask,{instancePath:r+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(t=t===null?Jn.errors:t.concat(Jn.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 Qn.errors=t,s===0}function Au(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),Au.errors=t,s===0}var ku=Pu;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)){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($e(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 Zn.errors=t,s===0}function Pu(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),Pu.errors=t,s===0}var xu=Eu;var eI=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");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.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(!eI.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 es.errors=t,s===0}function Eu(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),Eu.errors=t,s===0}var Su=Ru;function rs(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 d={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=[d]:t.push(d),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 d={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=[d]:t.push(d),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 rs.errors=t,s===0}function Ru(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),Ru.errors=t,s===0}var Ou=Cu;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(!(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 ts.errors=t,s===0}function Cu(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),Cu.errors=t,s===0}var $u=_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.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 ns.errors=t,s===0}function _u(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),_u.errors=t,s===0}var ju=Nu;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.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 ss.errors=t,s===0}function Nu(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),Nu.errors=t,s===0}var Du=Tu;function os(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,d=s,f=s,m=!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(m=m||g,!m){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.texture===void 0&&(E="texture")){let $={};t===null?t=[$]:t.push($),s++}}var g=v===s;if(m=m||g,!m){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let N;if(e.behaviors===void 0&&(N="behaviors")){let S={};t===null?t=[S]:t.push(S),s++}}var g=E===s;if(m=m||g,!m){let N=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.emitter===void 0&&(T="emitter")){let V={};t===null?t=[V]:t.push(V),s++}}var g=N===s;m=m||g}}}if(m)s=f,t!==null&&(f?t.length=f:t=null);else{let v={};t===null?t=[v]:t.push(v),s++}var h=d===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 I=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=I===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 E={instancePath:r+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(v.emission!==void 0){let k=v.emission;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let E={instancePath:r+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),s++}}if(v.movement!==void 0){let k=v.movement;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let E={instancePath:r+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),s++}}if(v.appearance!==void 0){let k=v.appearance;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let E={instancePath:r+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),s++}}if(v.bounds!==void 0){let k=v.bounds;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let E={instancePath:r+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),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,E=!1,$=null,N=s;if(typeof v=="string"){if($e(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 x=N===s;x&&(E=!0,$=0);let S=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 x=S===s;if(x&&E?(E=!1,$=[$,1]):x&&(E=!0,$=1),E)s=k,t!==null&&(k?t.length=k:t=null);else{let T={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:$},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 E={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[E]:t.push(E),s++}let k=v.length;for(let E=0;E<k;E++){let $=v[E];if($&&typeof $=="object"&&!Array.isArray($)){if($.type===void 0){let N={instancePath:r+"/behaviors/"+E,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 $)if(!(N==="type"||N==="config")){let S={instancePath:r+"/behaviors/"+E,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:N},message:"must NOT have additional properties"};t===null?t=[S]:t.push(S),s++}if($.type!==void 0){let N=$.type;if(typeof N=="string"){if($e(N)<1){let S={instancePath:r+"/behaviors/"+E+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[S]:t.push(S),s++}}else{let S={instancePath:r+"/behaviors/"+E+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[S]:t.push(S),s++}}if($.config!==void 0){let N=$.config;if(!(N&&typeof N=="object"&&!Array.isArray(N))){let S={instancePath:r+"/behaviors/"+E+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[S]:t.push(S),s++}}}else{let N={instancePath:r+"/behaviors/"+E,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 E={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};t===null?t=[E]:t.push(E),s++}if(k.max===void 0){let E={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};t===null?t=[E]:t.push(E),s++}if(k.min!==void 0){let E=k.min;if(typeof E=="number"){if(E<0||isNaN(E)){let $={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=[$]:t.push($),s++}}else{let $={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=[$]:t.push($),s++}}if(k.max!==void 0){let E=k.max;if(typeof E=="number"){if(E<0||isNaN(E)){let $={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=[$]:t.push($),s++}}else{let $={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=[$]:t.push($),s++}}}else{let E={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),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 os.errors=t,s===0}function Tu(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),Tu.errors=t,s===0}var Lu=Mu;var zc={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 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++}for(let i in e)if(!er.call(zc.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:zc.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 is.errors=t,s===0}function Mu(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),Mu.errors=t,s===0}var qu=Vu;var rI=new RegExp("^.+$","u");function as(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(rI.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 d=0;d<p;d++)if(typeof c[d]!="number"){let f={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[f]:t.push(f),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 as.errors=t,s===0}function Vu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return as(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?as.errors:t.concat(as.errors),s=t.length),Vu.errors=t,s===0}var Fu=Uu;var Hc={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 ls(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(!er.call(Hc.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,d=s;if(typeof l=="string"){if($e(l)<1){let m={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=[m]:t.push(m),s++}}else{let m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}var i=d===s;i&&(c=!0,p=0);let f=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 m=l.length;for(let h=0;h<m;h++){let I=l[h];if(typeof I=="string"){if($e(I)<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 I=l[y];if(typeof I=="string"){if(typeof h[I]=="number"){g=h[I];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[I]=y}}}}else{let m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[m]:t.push(m),s++}var i=f===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 m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};t===null?t=[m]:t.push(m),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:Hc.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($e(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 ls.errors=t,s===0}function Uu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ls(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ls.errors:t.concat(ls.errors),s=t.length),Uu.errors=t,s===0}var Bu=Yu;var tI={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 cs(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(!er.call(tI.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 cs.errors=t,s===0}function Yu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return cs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?cs.errors:t.concat(cs.errors),s=t.length),Yu.errors=t,s===0}var zu=Hu;function us(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 us.errors=t,s===0}function Hu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return us(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?us.errors:t.concat(us.errors),s=t.length),Hu.errors=t,s===0}var ds=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),$t=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),jr=e=>e===void 0?void 0:structuredClone(e),nI=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"}),sI=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),oI=Object.freeze({background:Gc,bgm:Wc,character:Jc,choice:Zc,cleanAll:ru,control:nu,dialogue:ou,form:au,layout:cu,screen:pu,sfx:fu,visual:yu,voice:gu}),iI=Object.freeze({achievement:Iu,animation:vu,character:ku,color:xu,control:Su,font:Ou,image:$u,layout:ju,particle:Du,sound:Lu,spritesheet:qu,textStyle:Fu,transform:Bu,video:zu}),aI=new Set(["files","language","patches"]),lI=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),cI=new Set(["lineId","mode","payload","type"]),uI=new Set(["mode","payload","sceneId","type"]),pI=new Set(["mode","operation","payload","resourceId","type"]),dI=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")},ii=(e,r)=>{Array.isArray(e)||F(r,"expected an array")},Qr=(e,r)=>{(typeof e!="string"||e.length===0)&&F(r,"expected a non-empty string")},Wu=(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")},He=(e,r,n)=>{for(let o of r)ds(e,o)||F(n,`missing required field "${o}"`)},fI=e=>e.replaceAll("~1","/").replaceAll("~0","~"),mI=(e,r)=>{let n=(r?.instancePath??"").split("/").slice(1).map(fI);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)},yI=(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],Ku=({value:e,validator:r,path:n,contract:o})=>{if(r(e))return;let a=yI(r.errors);F(mI(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Zr=(e,r)=>{Qr(e,r),(e==="__proto__"||e==="constructor"||e==="prototype")&&F(r,`"${e}" is not a safe ID`)},hI=(e,r)=>{Qr(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]))},ps=(e,r=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>ps(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),ps(a,r,n);return r},gI=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},Ju=(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]},Qu=(e,r)=>e.story.scenes[r.sceneId].sections[r.sectionId].lines[r.lineIndex],Gu=e=>({items:(e?.items??[]).map(r=>({id:r?.id,events:r?.events}))}),Xu=e=>{let r=jr(e??{});delete r.resourceId,delete r.animations;for(let n of Object.values(r.fields??{}))$t(n)&&delete n.placeholder;return r},bI=(e,r,n,o)=>{e==="choice"&&!Ct(Gu(r),Gu(n))&&F(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Ct(Xu(r),Xu(n))&&F(o,"form behavior must remain identical; only presentation fields and placeholders may change")},II=({patch:e,path:r,lineIndex:n})=>{ze(e,lI,r),He(e,["type","lineId","actionType","payload"],r),Zr(e.lineId,`${r}.lineId`),Qr(e.actionType,`${r}.actionType`),Fe(e.payload,`${r}.payload`),e.mode!==void 0&&e.mode!=="replace"&&F(`${r}.mode`,'line.action supports only "replace"'),sI.has(e.actionType)||F(`${r}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=Ju(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"]'),ds(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"),bI(e.actionType,a,e.payload,`${r}.payload`),Ku({value:e.payload,validator:oI[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}},wI=(e,r)=>{ii(e,r),e.forEach((n,o)=>{Fe(n,`${r}[${o}]`),ze(n,new Set(["text"]),`${r}[${o}]`),He(n,["text"],`${r}[${o}]`),Wu(n.text,`${r}[${o}].text`)})},vI=({patch:e,path:r,lineIndex:n})=>{ze(e,cI,r),He(e,["type","lineId","payload"],r),Zr(e.lineId,`${r}.lineId`),Fe(e.payload,`${r}.payload`),ze(e.payload,new Set(["content"]),`${r}.payload`),He(e.payload,["content"],`${r}.payload`),wI(e.payload.content,`${r}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&F(`${r}.mode`,'line.dialogue supports only "replace"');let o=Ju(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}},AI=({patch:e,path:r,projectData:n})=>(ze(e,uI,r),He(e,["type","mode","sceneId","payload"],r),Zr(e.sceneId,`${r}.sceneId`),Fe(e.payload,`${r}.payload`),ze(e.payload,new Set(["name"]),`${r}.payload`),He(e.payload,["name"],`${r}.payload`),Wu(e.payload.name,`${r}.payload.name`),e.mode!=="patch"&&F(`${r}.mode`,'story.scene requires "patch"'),ds(n?.story?.scenes??{},e.sceneId)||F(`${r}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),kI=(e,r,n)=>{Fe(r,n),["font","image","sound","spritesheet","video"].includes(e)&&Qr(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"),Ku({value:r,validator:iI[e],path:n,contract:`the resource.${e} schema`})},PI=({patch:e,path:r,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{ze(e,pI,r),He(e,["type","resourceId","payload"],r),Zr(e.resourceId,`${r}.resourceId`);let t=e.type.slice(9),s=nI[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"'),kI(t,e.payload,`${r}.payload`);let i=n?.resources?.[s]??{},l=ds(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 ps(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}},xI=({patch:e,path:r,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:t})=>{if(Fe(e,r),Qr(e.type,`${r}.type`),e.type==="line.action")return II({patch:e,path:r,lineIndex:o});if(e.type==="line.dialogue")return vI({patch:e,path:r,lineIndex:o});if(e.type==="story.scene")return AI({patch:e,path:r,projectData:n});if(e.type.startsWith("resource."))return PI({patch:e,path:r,projectData:n,packageFileIds:a,canonicalFileIds:t});F(`${r}.type`,`unsupported patch type "${e.type}"`)},EI=(e,r)=>{ii(e,r);let n=new Set;return e.forEach((o,a)=>{let t=`${r}[${a}]`;Fe(o,t),ze(o,dI,t),He(o,["fileId"],t),hI(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},SI=({packageId:e,packageData:r,path:n,projectData:o,lineIndex:a,canonicalFileIds:t})=>{Fe(r,n),ze(r,aI,n),He(r,["language","files","patches"],n),Qr(r.language,`${n}.language`);let s=EI(r.files,`${n}.files`);ii(r.patches,`${n}.patches`);let i=new Set,l=r.patches.map((u,c)=>{let p=xI({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}},Zu=({projectData:e,l10nData:r})=>{if(r===void 0)return{packages:new Map};Fe(r,"l10nData"),ze(r,new Set(["packages"]),"l10nData"),He(r,["packages"],"l10nData"),Fe(r.packages,"l10nData.packages");let n=gI(e),o=ps(e?.resources??{}),a=new Map,t=new Map;for(let[s,i]of Object.entries(r.packages)){Zr(s,`l10nData.packages.${s}`);let l=SI({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}},RI=(e,r)=>{let{collectionName:n,patch:o}=r;e.resources[n]??={},e.resources[n][o.resourceId]=jr(o.payload)},OI=(e,r)=>{let{patch:n}=r,o=e.story.scenes[n.sceneId];o.name=n.payload.name},CI=(e,r)=>{let{location:n,patch:o}=r,a=Qu(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=jr(o.payload);return}let t=jr(n.line.actions.dialogue.content);a.actions.dialogue=jr(o.payload),t!==void 0&&(a.actions.dialogue.content=t)},$I=(e,r)=>{let{location:n,patch:o}=r,a=Qu(e,n);a.actions.dialogue.content=jr(o.payload.content)},ep=({projectData:e,l10nData:r})=>{let n=Zu({projectData:e,l10nData:r});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},fs=({projectData:e,l10nData:r,l10nId:n=null})=>{let o=Zu({projectData:e,l10nData:r});if(n!==null&&(Zr(n,"l10nId"),o.packages.has(n)||F("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=jr(e),t=o.packages.get(n).patches;return t.filter(s=>s.kind==="resource").forEach(s=>RI(a,s)),t.filter(s=>s.kind==="story.scene").forEach(s=>OI(a,s)),t.filter(s=>s.kind==="line.action").forEach(s=>CI(a,s)),t.filter(s=>s.kind==="line.dialogue").forEach(s=>$I(a,s)),a};var _I=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),jI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),rp="conditional",li=Symbol("conditionalAutoContinue"),NI=new Set(["sectionTransition","resetStoryAtSection"]),DI=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),TI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),LI=new Set(["nextLine","nextLineFromSystem"]),MI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),ai="form",qI=new Set(["submitForm","cancelForm"]),VI="showImageGalleryVariant",FI="playMusicRoomTrack",UI="startSceneReplay",Ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ms=e=>e?.type===li,et=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId;function ci(e){let r,n=0,o=null,a=0,t=!1,s=0,i=[],l=null,u=null,c=new Map,p=new Map,d=new Map,f,m,y=null,{handlePendingEffects:g}=e,h=(w=new Map,P=Date.now())=>new Map(Array.from(w.entries()).filter(([,R])=>P<R.expiresAt).map(([R,C])=>[R,{animation:structuredClone(C.animation),startedAt:C.startedAt,expiresAt:C.expiresAt}])),I=(w=new Map)=>Array.from(w.values()).map(P=>structuredClone(P.animation)),b=(w=Date.now())=>{c=new Map(Array.from(c.entries()).filter(([,P])=>w<P.expiresAt))},x=()=>{if(!(a>0||t)){t=!0;try{for(;r.selectPendingEffects().length>0;){let w=[...r.selectPendingEffects()];r.clearPendingEffects();try{g(w)}catch(P){throw r.clearPendingEffects(),w.forEach(R=>{r.appendPendingEffect(R)}),P}}}finally{t=!1}}},v=w=>{a+=1;let P=!1;try{let R=w();return P=!0,R}finally{a-=1,P&&x()}},k=({initialState:w,namespace:P})=>{let{l10nData:R,...C}=w,L=R===void 0?void 0:structuredClone(R),U=structuredClone(w.projectData),J=ep({projectData:U,l10nData:L}),Z=C.global??{};if(!Ue(Z))throw new Error("Malformed global state.");let pe=Z.runtime??{};if(!Ue(pe))throw new Error("Malformed global.runtime.");let Se=pe.localizationPackageId;if(Se!=null&&typeof Se!="string")throw new Error("localizationPackageId requires a string or null value");let yr=new Set(J.map(({l10nId:gs})=>gs).filter(gs=>gs!==null)),rr=typeof Se=="string"&&yr.has(Se)?Se:null,Mt=fs({projectData:U,l10nData:L,l10nId:rr});r=Tc({...C,global:{...Z,localizationPackages:J,runtime:{...pe,localizationPackageId:rr}},projectData:Mt}),n=0,o=ni(P),a=0,t=!1,s=0,i=[],l=null,u=null,c=new Map,p=new Map,d=new Map,f=U,m=L,y=rr,r.appendPendingEffect({name:"handleLineActions"}),x()},E=()=>o,$=()=>r.selectPresentationState(),N=()=>r.selectPresentationChanges(),S=w=>r.selectSectionLineChanges(w),T=(w={})=>{n+=1;let P=Date.now();b(P);let R=p.size>0,C=h(c,P),L=R?h(p,P):new Map,J={...r.selectRenderState({activePersistentAnimations:I(C),restoredPersistentAnimations:I(L)}),id:`render-${n}`};return d.set(J.id,{builtAt:P,persistentAnimationSessions:new Map([...L.entries(),...C.entries()]),usedRestoredPersistentAnimationSessions:R}),J},V=(w={})=>T(w),le=(w={})=>T(w),Y=w=>{let P=typeof w?.id=="string"&&w.id.length>0?w.id:null,R=P?d.get(P):null;P&&d.delete(P);let C=new Map;Ta(w?.animations).forEach(L=>{let U=cn(L);if(!U)return;let J=R?.persistentAnimationSessions?.get(U)??c.get(U),Z=Math.max(0,qa(L)),pe=J?.startedAt??R?.builtAt??Date.now();C.set(U,{animation:structuredClone(L),startedAt:pe,expiresAt:pe+Z})}),c=C,R?.usedRestoredPersistentAnimationSessions&&(p=new Map)},ne=()=>r.selectSystemState(),oe=()=>r.selectAchievements(),he=w=>r.selectAchievement(w),ve=()=>r.selectSaveSlotMap(),ce=w=>r.selectSaveSlot(w),se=w=>r.selectSaveSlotPage(w),ue=()=>r.selectImageGallery(),ie=()=>r.selectMusicRoom(),O=()=>r.selectSceneReplay(),_=()=>r.selectIsSceneReplayActive(),q=()=>r.selectSkipMode(),ee=()=>r.selectAutoMode(),Ie=()=>r.selectRuntime(),K=()=>r.selectIsChoiceVisible(),Ee=()=>r.selectIsFormVisible(),ge=()=>r.selectActiveInteraction(),jt=()=>r.selectPendingEffects().some(w=>w?.name==="handleLineActions"||w?.name==="render"),Nr=(w,P,R={})=>!Ue(P)||w!=="nextLine"?P:R.bypassChoice===!0?{...P,bypassChoice:!0}:R.interactionSource===ai?{...P,_interactionSource:ai}:P,Nt=(w={})=>({type:li,payload:Nr("nextLine",{_conditionalContinuation:!0},w)}),Dt=(w,P)=>ms(w)?{type:li,payload:{...w.payload,...P.payload}}:P,Tt=w=>{w.savedCheckpointOccurrences.forEach(P=>{r.markSavedRollbackCheckpointTransient(P)}),w.savedCheckpointOccurrences=[]},ip=(w,P)=>{let R=l;return l=null,!R||!et(R.pointer,w)||R.checkpointIndex!==P?.checkpointIndex||R.checkpointIdentity!==P?.checkpoint?[]:R.savedCheckpointOccurrences},ap=w=>{let P=u;return!P||!et(P.pointer,w)?null:(u=null,P)},lp=({actionType:w,pointerBeforeAction:P,pointerAfterAction:R,cursorBeforeAction:C,cursorAfterAction:L,wasSceneReplayActive:U,isSceneReplayActive:J})=>{!R||!(!et(P,R)||C?.checkpoint!==L?.checkpoint||C?.checkpointIndex!==L?.checkpointIndex||w==="jumpToLine")||(u={pointer:R,appendToPrevious:LI.has(w)&&U===J&&P?.sectionId===R.sectionId&&P?.lineId!==R.lineId,reuseExistingOccurrence:MI.has(w),forceNewOccurrence:w==="jumpToLine"})},pi=w=>{w.markCurrentCheckpointTransient&&(r.markRollbackCheckpointTransient({checkpointIndex:w.rollbackCursor?.checkpointIndex,checkpointIdentity:w.rollbackCursor?.checkpoint,sectionId:w.pointer?.sectionId,lineId:w.pointer?.lineId}),Tt(w))},cp=(w,P,R)=>DI.has(w)?w==="resetStoryAtSection"?R?.checkpoint!==P?.checkpoint:R?.checkpoint!==P?.checkpoint&&R?.checkpointIndex>P?.checkpointIndex:!1,up=w=>{let P=i.at(-1);if(!P?.markCurrentCheckpointTransient)return;let R=r.selectSaveSlot({slotId:w?.slotId});R&&P.savedCheckpointOccurrences.push({slotId:w.slotId,saveSlotIdentity:R,checkpointIndex:P.rollbackCursor?.checkpointIndex,sectionId:P.pointer?.sectionId,lineId:P.pointer?.lineId})},pp=(w,P,R)=>{let C=i.at(-1);if(!C)return;let L=r.selectCurrentPointer()?.pointer,U=cp(w,P,R);if(et(C.pointer,L)){let J=R?.checkpoint!==P?.checkpoint||R?.checkpointIndex!==P?.checkpointIndex;(U||J&&TI.has(w))&&(pi(C),C.pointer=L,C.rollbackCursor=R,C.markCurrentCheckpointTransient=U,C.savedCheckpointOccurrences=[]);return}pi(C),C.pointer=L,C.rollbackCursor=r.selectRollbackCursor?.()??null,C.markCurrentCheckpointTransient=U,C.savedCheckpointOccurrences=[]},Lt=(w,P)=>{if(!r[w])return;let R=P,C,L;if(w==="updateProjectData")di(P),C=structuredClone(P.projectData),R={...P,projectData:fs({projectData:C,l10nData:m,l10nId:y})},di(R);else if(w==="updateLocalizationPackage"){if(L=dp(P),L===y)return;R={l10nId:L,projectData:fs({projectData:f,l10nData:m,l10nId:L})}}NI.has(w)&&(s+=1);let U=r.selectIsSceneReplayActive?.()===!0,J=jI.has(w)?h(c):null,Z=r.selectCurrentPointer()?.pointer??null,pe=r.selectRollbackCursor?.()??null,Se=r[w](R);C!==void 0&&(f=C),L!==void 0&&(y=L),_I.has(w)&&(p=J??new Map,c=new Map);let yr=r.selectIsSceneReplayActive?.()===!0;U!==yr&&(c=new Map,p=new Map);let rr=r.selectCurrentPointer()?.pointer??null,Mt=r.selectRollbackCursor?.()??null;return w==="saveSlot"&&up(P),pp(w,pe,Mt),lp({actionType:w,pointerBeforeAction:Z,pointerAfterAction:rr,cursorBeforeAction:pe,cursorAfterAction:Mt,wasSceneReplayActive:U,isSceneReplayActive:yr}),x(),Se},di=w=>{if(!Object.prototype.hasOwnProperty.call(w??{},"projectData"))throw new Error("updateProjectData requires projectData");Ar(w?.projectData?.resources?.variables??{}),at(w.projectData),lt(w.projectData),ct(w.projectData)},dp=w=>{if(!Ue(w))throw new Error("updateLocalizationPackage requires an object payload");let P=Object.keys(w);if(P.length!==1||P[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(w.l10nId!==null&&(typeof w.l10nId!="string"||w.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return w.l10nId},fp=(w,P,R)=>{let C=r.selectCurrentPointer()?.pointer;P!==C||R!==s||(r.appendPendingEffect({name:"clearAutoNextTimer"}),r.appendPendingEffect({name:"clearNextLineConfigTimer"}),Lt("nextLineFromSystem",w.payload))},mp=()=>({renderSequence:n,conditionalRoutingSequence:s,rollbackNavigationContexts:i.slice(),pendingRollbackLineEntrySaveHandoff:l,pendingDialogueHistoryLineEntry:u,persistentAnimationSessions:new Map(c),restoredPersistentAnimationSessions:new Map(p),renderPersistentAnimationMetadata:new Map(d),canonicalProjectData:f,localizationPackageId:y}),yp=w=>{n=w.renderSequence,s=w.conditionalRoutingSequence,i=w.rollbackNavigationContexts.slice(),l=w.pendingRollbackLineEntrySaveHandoff,u=w.pendingDialogueHistoryLineEntry,c=new Map(w.persistentAnimationSessions),p=new Map(w.restoredPersistentAnimationSessions),d=new Map(w.renderPersistentAnimationMetadata),f=w.canonicalProjectData,y=w.localizationPackageId},fi=(w,P={})=>v(()=>{let R=mp();try{return r[Ys](()=>{let C,L=r.selectCurrentPointer()?.pointer??null,U=r.selectRollbackCursor?.()??null,J=s,Z={pointer:L,rollbackCursor:U,markCurrentCheckpointTransient:P.rollbackSource==="line",savedCheckpointOccurrences:P.savedCheckpointOccurrences?.slice()??[]};i.push(Z);try{r.beginRollbackActionBatch({source:P.rollbackSource});try{C=w()}finally{r.endRollbackActionBatch({})}ms(C)&&fp(C,L,J);let pe=r.selectCurrentPointer()?.pointer??null;P.rollbackSource==="line"&&et(L,pe)&&r.recordCurrentDialogueHistory({savedCheckpointOccurrences:Z.savedCheckpointOccurrences,appendToPrevious:P.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:P.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:P.dialogueHistoryForceNewOccurrence===!0})}finally{i.pop(),(!et(L,Z.pointer)||U?.checkpoint!==Z.rollbackCursor?.checkpoint)&&Z.markCurrentCheckpointTransient&&Z.savedCheckpointOccurrences.length>0&&(l={pointer:Z.pointer,checkpointIndex:Z.rollbackCursor?.checkpointIndex,checkpointIdentity:Z.rollbackCursor?.checkpoint,savedCheckpointOccurrences:Z.savedCheckpointOccurrences})}})}catch(C){throw yp(R),C}}),mi=(w,P,R,C={})=>{if(w===rp)return fi(()=>{let L=ys(R),U=Ws({[w]:P},L);return yi(U[w],R,C)},C);Lt(w,P)},hp=(w,P)=>{mi(w,P)},ys=w=>{if(!w)return{variables:r.selectAllVariables?r.selectAllVariables():void 0,runtime:r.selectRuntime?r.selectRuntime():{}};if(Object.prototype.hasOwnProperty.call(w,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".');let{_event:P,...R}=w,C=r.selectAllVariables?r.selectAllVariables():void 0;return{...R,_event:P,variables:C,runtime:r.selectRuntime?r.selectRuntime():{}}},gp=w=>{if(!Ue(w))return{templatePayload:w,literalTargetIds:null};let P=r.selectImageGalleryConfig();if(!Array.isArray(P?.groups))return{templatePayload:w,literalTargetIds:null};let R=typeof w.groupId=="string"?P.groups.find(L=>L.id===w.groupId):void 0;if(!R)return{templatePayload:w,literalTargetIds:null};let C=typeof w.variantId=="string"&&R.variants.some(L=>L.id===w.variantId);return{templatePayload:{...w,groupId:null,...C?{variantId:null}:{}},literalTargetIds:{groupId:w.groupId,...C?{variantId:w.variantId}:{}}}},bp=w=>!Ue(w)||typeof w.trackId!="string"?{templatePayload:w,literalTargetIds:null}:r.selectMusicRoomConfig()?.tracks?.some(C=>C.id===w.trackId)?{templatePayload:{...w,trackId:null},literalTargetIds:{trackId:w.trackId}}:{templatePayload:w,literalTargetIds:null},Ip=w=>!Ue(w)||typeof w.sceneId!="string"?{templatePayload:w,literalTargetIds:null}:r.selectSceneReplayConfig()?.replays?.some(C=>C.sceneId===w.sceneId)?{templatePayload:{...w,sceneId:null},literalTargetIds:{sceneId:w.sceneId}}:{templatePayload:w,literalTargetIds:null},wp=w=>{if(!Ue(w))throw new Error("conditional action payload must be an object");if(!Array.isArray(w.branches))throw new Error("conditional action requires branches array");if(w.branches.length===0)throw new Error("conditional action requires at least one branch")},vp=(w,P,R)=>{if(!Ue(w))throw new Error(`conditional branch at index ${P} must be an object`);if(!Ue(w.actions))throw new Error(`conditional branch at index ${P} requires actions object`);if(!Object.prototype.hasOwnProperty.call(w,"when")&&P!==R-1)throw new Error("conditional else branch must be the last branch")},yi=(w,P,R)=>{wp(w);let C=Nt(R);for(let L=0;L<w.branches.length;L+=1){let U=w.branches[L];vp(U,L,w.branches.length);let J=ys(P);if(Object.prototype.hasOwnProperty.call(U,"when")&&!it(U.when,J))continue;let pe=hs(U.actions,P,R);return ms(pe)?Dt(C,pe):C}return C},Ap=(w,P)=>({...w??{},_form:P}),kp=(w,P,R,C)=>{let L=Lt(w,P),U=L?.submitted===!0&&L.valid===!0,J=L?.cancelled===!0;if(!(!U&&!J)&&Ue(P.actions))return hs(P.actions,Ap(R,L.form),{...C,interactionSource:ai})},Pp=(w,P,R,C)=>{let L=ys(R),U={templatePayload:P,literalTargetIds:null};w===VI?U=gp(P):w===FI?U=bp(P):w===UI&&(U=Ip(P));let{templatePayload:J,literalTargetIds:Z}=U,Se=Ws({[w]:J},L)[w],yr=Z?{...Se,...Z}:Se;if(w===rp)return yi(yr,R,C);let rr=Nr(w,yr,C);if(qI.has(w))return kp(w,rr,R,C);Lt(w,rr)},hs=(w,P,R)=>{let C;return Object.entries(w).forEach(([L,U])=>{let J=Pp(L,U,P,R);ms(J)&&(C=Dt(C,J))}),C},hi=(w,P,R={})=>fi(()=>hs(w,P,R),R),xp=w=>{let P=r.selectCurrentPointer()?.pointer;if(w!==P||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:k,handleAction:mi,handleInternalAction:hp,handleActions:hi,selectRenderState:V,prepareRenderState:le,commitRenderState:Y,selectPresentationState:$,selectPresentationChanges:N,selectSectionLineChanges:S,selectSystemState:ne,selectAchievements:oe,selectAchievement:he,selectSaveSlotMap:ve,selectSaveSlot:ce,selectSaveSlotPage:se,selectSaveSlots:ve,selectImageGallery:ue,selectMusicRoom:ie,selectSceneReplay:O,selectIsSceneReplayActive:_,selectRuntime:Ie,selectIsChoiceVisible:K,selectIsFormVisible:Ee,selectActiveInteraction:ge,selectHasPendingRenderWork:jt,handleLineActions:w=>{if(typeof w?.sceneReplaySceneId=="string"){let P=r.selectActiveSceneReplayEntry?.();if(P?.sceneId!==w.sceneReplaySceneId||P?.entryId!==w.entryId)return!1}return v(()=>{let P=r.selectCurrentPointer()?.pointer,R=r.selectRollbackCursor?.()??null,C=l,L=u,U=ip(P,R),J=ap(P),Z=r.selectCurrentLine(),pe=!1;if(Z?.actions){try{hi(Z.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:U,dialogueHistoryAppendToPrevious:J?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:J?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:J?.forceNewOccurrence===!0})}catch(Se){throw l=C,u=L,Se}pe=!0}return xp(P),pe})},getNamespace:E}}var ui=()=>{let e=0,r=null;return{getElapsed:()=>e,setElapsed:n=>{e=n},addElapsed:n=>{e+=n},getCallback:()=>r,setCallback:n=>{r=n}}},BI=80,YI="music-room:player",sp=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),tp=(e,r)=>sp.has(e)&&r?._event?.id===YI,op=({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)},zI=({engine:e,routeGraphics:r,trackRenderDispatch:n,getRenderDispatchCount:o},a)=>{let t=o?.()??0,s=e.handleLineActions(a);(o?.()??0)===t&&op({engine:e,routeGraphics:r,trackRenderDispatch:n},a)},HI=({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)},GI=({ticker:e,autoTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},XI=({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??BI;n.getElapsed()>=i&&(n.setElapsed(0),_t(e,"nextLineFromSystem",{}))};n.setCallback(t),r.add(t)},WI=({ticker:e,skipTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},KI=({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)},JI=({ticker:e,nextLineConfigTimerState:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},QI=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveSlots(r?.saveSlots))},ZI=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalDeviceVariables(r?.globalDeviceVariables))},e0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalAccountVariables(r?.globalAccountVariables))},r0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalRuntime(r?.globalRuntime))},t0=({enqueuePersistenceWrite:e},r)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(r?.updates)})},np={render:op,saveSlots:QI,saveGlobalDeviceVariables:ZI,saveGlobalAccountVariables:e0,saveGlobalRuntime:r0,applyScopedDataUpdates:t0,handleLineActions:zI,startAutoNextTimer:HI,clearAutoNextTimer:GI,startSkipNextTimer:XI,clearSkipNextTimer:WI,nextLineConfigTimer:KI,clearNextLineConfigTimer:JI},n0=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)},s0=(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(!n0.has(a.name)){n.unshift(a);continue}r.has(a.name)||(r.add(a.name),n.unshift(a))}return n},o0=({getEngine:e,routeGraphics:r,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:t,persistence:s,namespace:i})=>{let l=ui(),u=ui(),c=ui(),p=s??null,d=Promise.resolve(),f=null,m=null,y=!1,g=0,h=O=>{if(a){a(O);return}console.error("RouteEngine persistence write failed.",O)},I=()=>{if(p)return p;let O=e();return p=si({indexedDB:t,namespace:i??O?.getNamespace?.()}),p},b=O=>{d=d.catch(()=>{}).then(()=>{let _=I();return O(_)}).catch(_=>{h(_)})},x=O=>{let _=typeof O?.id=="string"&&O.id.length>0?O.id:null;g+=1,f=_,y=!1},v=()=>g,k=(O={})=>{if(O?.aborted===!0)return!1;let _=typeof O?.id=="string"&&O.id.length>0?O.id:null;return _?_!==f||_===m?!1:(m=_,!0):f!==null||y?!1:(y=!0,!0)},E=(O,_={})=>{if(tp(O,_)){let ee=sp.get(O),Ie=e();return _t(Ie,ee,_?._event),!0}if(O!=="renderComplete"||!k(_))return!1;let q=e();return _t(q,"markLineCompleted",{}),!0},$=new Set(["updateFormField","submitForm","cancelForm"]),N=new Set(["updateVariable"]),S=O=>typeof O?.selectActiveInteraction=="function"?O.selectActiveInteraction():typeof O?.selectIsChoiceVisible=="function"&&O.selectIsChoiceVisible()?{source:"choice"}:null,T=O=>O?._formKey??O?.formKey,V=(O,_)=>T(O)===_?.formKey,le=(O,_)=>!O||typeof O!="object"||Array.isArray(O)?!1:O._interactionSource===_?.source,Y=(O,_)=>le(O,_)?_.source==="form"?V(O,_):!0:!1,ne=(O,_)=>!O||typeof O!="object"||Array.isArray(O)||_?.source!=="form"?!1:V(O,_),oe=(O={})=>Object.keys(O).some(_=>$.has(_)),he=(O={},_)=>Object.entries(O).some(([q,ee])=>$.has(q)&&ne(ee,_)),ve=(O={})=>Object.keys(O).length>0&&Object.keys(O).every(_=>N.has(_)),ce=(O={},_)=>{let q=O?.actions;return _?.source==="form"?!q||typeof q!="object"||Array.isArray(q)?!1:he(q,_)?!0:oe(q)?!1:ve(q):Y(O,_)?!0:!q||typeof q!="object"||Array.isArray(q)?!1:Object.values(q).some(ee=>Y(ee,_))},se=(O,_={})=>{if(!_?.actions)return!1;let q=S(O);return!q||q.source==="choice"?!1:!ce(_,q)},ue=({preprocessPayload:O,onEvent:_}={})=>async(q,ee={})=>{if(tp(q,ee))return E(q,ee),_?.(q,ee);let Ie=e();if(se(Ie,ee))return _?.(q,ee);let K=await O?.(q,ee)??ee;if(se(Ie,K))return _?.(q,K);if(E(q,K),K?.actions){let Ee=K?._event?{_event:K._event}:K?.event?{_event:K.event}:void 0,ge;K?.bypassChoice===!0?ge={bypassChoice:!0}:K?._interactionSource&&(ge={interactionSource:K._interactionSource}),ge?Ie.handleActions(K.actions,Ee,ge):Ie.handleActions(K.actions,Ee)}return _?.(q,K)},ie=O=>{let _=e(),q=s0(O),ee=q.some(K=>K.name==="handleLineActions");q.forEach(K=>{if(!np[K.name]&&!o)throw new Error(`Unhandled pending effect "${K.name}".`)});let Ie={engine:_,routeGraphics:r,ticker:n,autoTimer:l,skipTimer:u,nextLineConfigTimerState:c,trackRenderDispatch:x,getRenderDispatchCount:v,enqueuePersistenceWrite:b};for(let K of q){if(ee&&K.name==="render")continue;let Ee=np[K.name];if(Ee){Ee(Ie,K.payload);continue}o(K,Ie)}};return ie.handleRouteGraphicsEvent=E,ie.createRouteGraphicsEventHandler=ue,ie},i0=o0;var a0=(e,r={})=>{let{resources:n={}}=r;return Ao(e,n)};var Yw=ci;export{eo as DEFAULT_VISUAL_LAYER,Vr as RENDER_LAYER,Ge as VISUAL_LAYER,i0 as createEffectsHandler,Ub as createIndexedDbPersistence,Yw as default,Hs as formatDate,Kd as resolveComputedVariables,a0 as resolveLayoutReferences};