route-engine-js 1.36.3 → 1.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var Gp=Object.defineProperty;var Hp=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Xp=(e,r)=>{for(var n in r)Gp(e,n,{get:r[n],enumerable:!0})};var nu=Hp(Ii=>{"use strict";Object.defineProperty(Ii,"__esModule",{value:!0});function tu(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}Ii.default=tu;tu.code='require("ajv/dist/runtime/ucs2length").default'});var Mi=Symbol.for("immer-nothing"),ji=Symbol.for("immer-draftable"),Se=Symbol.for("immer-state");function Le(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Gr=Object.getPrototypeOf;function he(e){return!!e&&!!e[Se]}function Sr(e){return e?qi(e)||Array.isArray(e)||!!e[ji]||!!e.constructor?.[ji]||Zt(e)||en(e):!1}var Wp=Object.prototype.constructor.toString();function qi(e){if(!e||typeof e!="object")return!1;let r=Gr(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)===Wp}function Jt(e){return he(e)||Le(15,e),e[Se].base_}function Xt(e,r){Qt(e)===0?Reflect.ownKeys(e).forEach(n=>{r(n,e[n],e)}):e.forEach((n,o)=>r(o,n,e))}function Qt(e){let r=e[Se];return r?r.type_:Array.isArray(e)?1:Zt(e)?2:en(e)?3:0}function Os(e,r){return Qt(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function Vi(e,r,n){let o=Qt(e);o===2?e.set(r,n):o===3?e.add(n):e[r]=n}function Kp(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}function Zt(e){return e instanceof Map}function en(e){return e instanceof Set}function Er(e){return e.copy_||e.base_}function Cs(e,r){if(Zt(e))return new Map(e);if(en(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=qi(e);if(r===!0||r==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Se];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(Gr(e),o)}else{let o=Gr(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Ds(e,r=!1){return rn(e)||he(e)||!Sr(e)||(Qt(e)>1&&(e.set=e.add=e.clear=e.delete=Jp),Object.freeze(e),r&&Object.entries(e).forEach(([n,o])=>Ds(o,!0))),e}function Jp(){Le(2)}function rn(e){return Object.isFrozen(e)}var Qp={};function Rr(e){let r=Qp[e];return r||Le(0,e),r}var pt;function Fi(){return pt}function Zp(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ni(e,r){r&&(Rr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function $s(e){_s(e),e.drafts_.forEach(ed),e.drafts_=null}function _s(e){e===pt&&(pt=e.parent_)}function Di(e){return pt=Zp(pt,e)}function ed(e){let r=e[Se];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function Li(e,r){r.unfinalizedDrafts_=r.drafts_.length;let n=r.drafts_[0];return e!==void 0&&e!==n?(n[Se].modified_&&($s(r),Le(4)),Sr(e)&&(e=Wt(r,e),r.parent_||Kt(r,e)),r.patches_&&Rr("Patches").generateReplacementPatches_(n[Se].base_,e,r.patches_,r.inversePatches_)):e=Wt(r,n,[]),$s(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==Mi?e:void 0}function Wt(e,r,n){if(rn(r))return r;let o=r[Se];if(!o)return Xt(r,(a,t)=>Ti(e,o,r,a,t,n)),r;if(o.scope_!==e)return r;if(!o.modified_)return Kt(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),Xt(t,(i,l)=>Ti(e,o,a,i,l,n,s)),Kt(e,a,!1),n&&e.patches_&&Rr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Ti(e,r,n,o,a,t,s){if(he(a)){let i=t&&r&&r.type_!==3&&!Os(r.assigned_,o)?t.concat(o):void 0,l=Wt(e,a,i);if(Vi(n,o,l),he(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Sr(a)&&!rn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Wt(e,a),(!r||!r.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&Kt(e,a)}}function Kt(e,r,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Ds(r,n)}function rd(e,r){let n=Array.isArray(e),o={type_:n?1:0,scope_:r?r.scope_:Fi(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,t=Ls;n&&(a=[o],t=dt);let{revoke:s,proxy:i}=Proxy.revocable(a,t);return o.draft_=i,o.revoke_=s,i}var Ls={get(e,r){if(r===Se)return e;let n=Er(e);if(!Os(n,r))return td(e,n,r);let o=n[r];return e.finalized_||!Sr(o)?o:o===Ss(e.base_,r)?(Rs(e),e.copy_[r]=Ns(o,e)):o},has(e,r){return r in Er(e)},ownKeys(e){return Reflect.ownKeys(Er(e))},set(e,r,n){let o=Ui(Er(e),r);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=Ss(Er(e),r),t=a?.[Se];if(t&&t.base_===n)return e.copy_[r]=n,e.assigned_[r]=!1,!0;if(Kp(n,a)&&(n!==void 0||Os(e.base_,r)))return!0;Rs(e),js(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 Ss(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,Rs(e),js(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){let n=Er(e),o=Reflect.getOwnPropertyDescriptor(n,r);return o&&{writable:!0,configurable:e.type_!==1||r!=="length",enumerable:o.enumerable,value:n[r]}},defineProperty(){Le(11)},getPrototypeOf(e){return Gr(e.base_)},setPrototypeOf(){Le(12)}},dt={};Xt(Ls,(e,r)=>{dt[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}});dt.deleteProperty=function(e,r){return dt.set.call(this,e,r,void 0)};dt.set=function(e,r,n){return Ls.set.call(this,e[0],r,n,e[0])};function Ss(e,r){let n=e[Se];return(n?Er(n):e)[r]}function td(e,r,n){let o=Ui(r,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Ui(e,r){if(!(r in e))return;let n=Gr(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return o;n=Gr(n)}}function js(e){e.modified_||(e.modified_=!0,e.parent_&&js(e.parent_))}function Rs(e){e.copy_||(e.copy_=Cs(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var nd=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,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Le(6),o!==void 0&&typeof o!="function"&&Le(7);let a;if(Sr(r)){let t=Di(this),s=Ns(r,void 0),i=!0;try{a=n(s),i=!1}finally{i?$s(t):_s(t)}return Ni(t,o),Li(a,t)}else if(!r||typeof r!="object"){if(a=n(r),a===void 0&&(a=r),a===Mi&&(a=void 0),this.autoFreeze_&&Ds(a,!0),o){let t=[],s=[];Rr("Patches").generateReplacementPatches_(r,a,t,s),o(t,s)}return a}else Le(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){Sr(e)||Le(8),he(e)&&(e=dr(e));let r=Di(this),n=Ns(e,void 0);return n[Se].isManual_=!0,_s(r),n}finishDraft(e,r){let n=e&&e[Se];(!n||!n.isManual_)&&Le(9);let{scope_:o}=n;return Ni(o,r),Li(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=Rr("Patches").applyPatches_;return he(e)?o(e,r):this.produce(e,a=>o(a,r))}};function Ns(e,r){let n=Zt(e)?Rr("MapSet").proxyMap_(e,r):en(e)?Rr("MapSet").proxySet_(e,r):rd(e,r);return(r?r.scope_:Fi()).drafts_.push(n),n}function dr(e){return he(e)||Le(10,e),Bi(e)}function Bi(e){if(!Sr(e)||rn(e))return e;let r=e[Se],n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=Cs(e,r.scope_.immer_.useStrictShallowCopy_)}else n=Cs(e,!0);return Xt(n,(o,a)=>{Vi(n,o,Bi(a))}),r&&(r.finalized_=!1),n}var Ce=new nd,Ts=Ce.produce,C0=Ce.produceWithPatches.bind(Ce),$0=Ce.setAutoFreeze.bind(Ce),_0=Ce.setUseStrictShallowCopy.bind(Ce),j0=Ce.applyPatches.bind(Ce),N0=Ce.createDraft.bind(Ce),D0=Ce.finishDraft.bind(Ce);var A={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},Y={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Hr={NOT:0};var _=class extends Error{constructor(r){super(`Parse Error: ${r}`),this.name="JemplParseError"}},ke=class extends Error{constructor(r){super(`Render Error: ${r}`),this.name="JemplRenderError"}};var Ms=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}')`)},Yi=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 zi=(e,r,n=!1)=>{if(r===null)return new ke(`Cannot iterate over null value at '$for ${e}'`);if(r===void 0)return new ke(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof r;return n?new ke(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new ke(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Gi=(e,r)=>{let n=r&&Object.keys(r).length>0?Object.keys(r).join(", "):"no custom functions provided";return new ke(`Unknown function '${e}' (${n})`)};var sd=(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=H(e,{functions:o,partials:a},r,{});return s===void 0?{}:s},H=(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 id(e.parts,r,n,o);switch(e.type){case A.FUNCTION:return Xi(e,r,n,o);case A.BINARY:return Wi(e,r,n,o);case A.UNARY:return Ki(e,r,n,o);case A.CONDITIONAL:return ld(e,r,n,o);case A.LOOP:return fd(e,r,n,o);case A.OBJECT:return yd(e,r,n,o);case A.ARRAY:return hd(e,r,n,o);case A.PARTIAL:return gd(e,r,n,o);case A.PATH_REFERENCE:return bd(e,r,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Hi=new Map,od=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=Hi.get(e);if(!o){let t=[],s="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,s+=c):c==="]"?(i--,s+=c):c==="."&&i===0?s&&(t.push(s),s=""):s+=c}s&&t.push(s),o=[];for(let l of t){let c=od(l.trim());o.push(...c)}Hi.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},id=(e,r,n,o)=>{let a=[];for(let t of e)if(typeof t=="string")a.push(t);else{let s=H(t,r,n,o);a.push(s!=null?String(s):"")}return a.join("")},Xi=(e,r,n,o)=>{let a=r.functions||r,t=a[e.name];if(!t)throw Gi(e.name,a);let s=e.args.map(i=>H(i,r,n,o));return t(...s)},fr=(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 Wi(e,r,n,o);case A.UNARY:return Ki(e,r,n,o);case A.FUNCTION:return Xi(e,r,n,o);default:return H(e,r,n,o)}},Wi=(e,r,n,o)=>{if(e.op===Y.AND||e.op===Y.OR){let s=fr(e.left,r,n,o),i=fr(e.right,r,n,o);switch(e.op){case Y.AND:return s&&i;case Y.OR:return s||i}}let a=H(e.left,r,n,o),t=H(e.right,r,n,o);switch(e.op){case Y.EQ:return a==t;case Y.NEQ:return a!=t;case Y.GT:return a>t;case Y.LT:return a<t;case Y.GTE:return a>=t;case Y.LTE:return a<=t;case Y.IN:return Array.isArray(t)?t.includes(a):!1;case Y.ADD:if(typeof a!="number"||typeof t!="number")throw new ke(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof t}`);return a+t;case Y.SUBTRACT:if(typeof a!="number"||typeof t!="number")throw new ke(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof t}`);return a-t;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ki=(e,r,n,o)=>{let a=e.op===Hr.NOT?fr(e.operand,r,n,o):H(e.operand,r,n,o);if(e.op===Hr.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},ad=(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 c=l.parsedKey?H(l.parsedKey,r,n,o):l.key,u=l.value;if(u.type===A.LITERAL)i[c]=u.value;else if(u.type===A.VARIABLE)i[c]=de(u.path,n,o);else if(u.type===A.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===A.VARIABLE){let d=de(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=H(m,r,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=H(u,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 c=l.parsedKey?H(l.parsedKey,r,n,o):l.key,u=l.value;if(u.type===A.LITERAL)i[c]=u.value;else if(u.type===A.VARIABLE)i[c]=de(u.path,n,o);else if(u.type===A.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===A.VARIABLE){let d=de(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=H(m,r,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=H(u,r,n,o)}return i}}}return null},ld=(e,r,n,o)=>{let a=ad(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||fr(s,r,n,o))return H(e.bodies[t],r,n,o)}return Ji},cd=(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 c=r[l];if(c[s]){let u={};for(let p of t.properties){let m=p.key,d=p.value;if(d.type===A.LITERAL)u[m]=d.value;else if(d.type===A.VARIABLE){let f=d.path;if(f===o)u[m]=c;else if(f.startsWith(o+".")){let y=f.substring(o.length+1);u[m]=c[y]}else return null}else if(d.type===A.INTERPOLATION){let f=[],y=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===A.VARIABLE){let h=g.path;if(h===o)f.push(c!=null?String(c):"");else if(h.startsWith(o+".")){let I=h.substring(o.length+1),b=c[I];f.push(b!=null?String(b):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;u[m]=f.join("")}else return null}i.push(u)}}return i}}}return null},ud=(e,r)=>{let n=e.body,o=e.itemVar,a=cd(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,c=i.value;if(c.type===A.LITERAL)t.push({key:l,type:"literal",value:c.value});else if(c.type===A.VARIABLE){let u=c.path;if(u===o)t.push({key:l,type:"item"});else if(u.startsWith(o+".")){let p=u.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(c.type===A.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===A.VARIABLE){let p=u.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 c=r[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<r.length;l++){let c=r[l],u={};for(let p of t)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}i[l]=u}return i}}return null},pd=(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 c=0;c<a.length;c++){let u=a[c],p={},m={...o,[i]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let f=d.split("."),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}[${c}]`,...l&&{[l]:c}};for(let f of s.properties){let y=f.parsedKey?H(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]=u;else if(h===l)p[y]=c;else if(h.startsWith(i+".")){let I=h.substring(i.length+1);!I.includes(".")&&!I.includes("[")?p[y]=u[I]:p[y]=de(h,n,{...o,[i]:u,...l&&{[l]:c}})}else p[y]=de(h,n,{...o,[i]:u,...l&&{[l]:c}})}else if(g.type===A.INTERPOLATION){let h=[];for(let I of g.parts)if(typeof I=="string")h.push(I);else if(I.type===A.VARIABLE){let b=I.path,x;if(b===i)x=u;else if(b===l)x=c;else if(b.startsWith(i+".")){let v=b.substring(i.length+1);!v.includes(".")&&!v.includes("[")?x=u[v]:x=de(b,n,{...o,[i]:u,...l&&{[l]:c}})}else x=de(b,n,{...o,[i]:u,...l&&{[l]:c}});h.push(x!=null?String(x):"")}else{let b={...o,[i]:u,...l&&{[l]:c}},x=H(I,r,n,b);h.push(x!=null?String(x):"")}p[y]=h.join("")}else{let h={...o,[i]:u,...l&&{[l]:c}};p[y]=H(g,r,n,h)}}t.push(p)}return t}return null},dd=(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 c=[];for(let u=0;u<r.length;u++){let p=r[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},fd=(e,r,n,o)=>{let a=H(e.iterable,r,n,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===A.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===A.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===A.VARIABLE?d.path:d.type===A.FUNCTION?`${d.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw zi(p,a,u)}if(!e.indexVar){let c=dd(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=ud(e,a);if(c!==null)return c}let t=pd(e,r,n,o,a);if(t!==null)return t;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let c=i.split("."),u=c[0];u in o.__paths__&&(i=o.__paths__[u],c.length>1&&(i+="."+c.slice(1).join(".")))}let l=!1;e.body.type===A.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===A.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...o,[e.itemVar]:a[c],[e.indexVar]:c}:{...o,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=o.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${i}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=H(e.body,r,n,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];s.push(m===void 0?{}:m)}else s.push(p===void 0?{}:p)}return s},md=(e,r,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],t=a.parsedKey?H(a.parsedKey,r,n,o):a.key,s=a.value;if(s.type===A.OBJECT&&s.properties.length<=10&&!s.whenCondition){let i={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?H(u.parsedKey,r,n,o):u.key,m=u.value;if(m.type===A.LITERAL)l[p]=m.value;else if(m.type===A.VARIABLE)l[p]=de(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=de(f.path,n,o);d.push(y!=null?String(y):"")}else{c=!1;break}if(!c)break;l[p]=d.join("")}else if(m.type===A.OBJECT&&m.properties.length<=5){let d={};for(let f of m.properties){let y=f.key,g=f.value;if(g.type===A.LITERAL)d[y]=g.value;else if(g.type===A.VARIABLE)d[y]=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{c=!1;break}if(!c)break;d[y]=h.join("")}else{c=!1;break}}if(!c)break;l[p]=d}else{c=!1;break}}if(c)return i[t]=l,i}}return null},yd=(e,r,n,o)=>{let a=r.functions||r;if(e.whenCondition&&!fr(e.whenCondition,a,n,o))return;let t=md(e,r,n,o);if(t!==null)return t;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?H(u.parsedKey,r,n,o):u.key,m=u.value;if(m.type===A.LITERAL)c[p]=m.value;else if(m.type===A.VARIABLE)c[p]=de(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=de(f.path,n,o);d.push(y!=null?String(y):"")}else{let y=H(f,r,n,o);d.push(y!=null?String(y):"")}c[p]=d.join("")}else c[p]=H(m,r,n,o)}return c}let s={},i=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=H(c.value,r,n,o);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return H(c.value,r,n,o)}else{let u=c.value;if(u&&u.type===A.OBJECT&&u.properties){let p=u.properties.find(m=>m.key.startsWith("$for "));if(p){let m=H(p.value,r,n,o);m!==void 0&&(s[c.key]=m)}else{let m=H(c.value,r,n,o);m!==void 0&&(s[c.key]=m)}}else{let p=c.parsedKey?H(c.parsedKey,r,n,o):c.key,m=H(c.value,r,n,o);m!==void 0&&(s[p]=m)}}return s},Ji={},hd=(e,r,n,o)=>{let a=[];for(let t of e.items)if(t.type===A.LOOP){let s=H(t,r,n,o);Array.isArray(s)&&t.flatten!==!1?a.push(...s):a.push(s)}else{let s=H(t,r,n,o);s!==Ji&&s!==void 0&&a.push(s)}return a},gd=(e,r,n,o)=>{let{name:a,data:t,whenCondition:s}=e,i=r.partials||{},l=r.functions||r;if(s&&!fr(s,l,n,o))return;if(!i[a])throw new ke(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new ke(`Circular partial reference detected: ${a}`);let u=i[a],p=n,m={...o,_partialStack:[...c,a]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(t){let d=H(t,r,n,o);p={...p,...d}}return H(u,r,p,m)},bd=(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 ke(`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 ke(`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 ke(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var qs=sd;var Id=/\$\{([^}]*)\}/g,wd=/#\{([^}]*)\}/g,Zi=(e,r={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,t=vd(a,r);return{isFunction:!0,type:A.FUNCTION,name:o,args:t}},vd=(e,r={})=>e.trim()?Ad(e).map(o=>kd(o.trim(),r)):[],Ad=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},kd=(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=Zi(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 c=0;for(;c<o.length;){let u=Or(o.substring(c),i);if(u===-1)break;let p=c+u;p>t&&(t=p,s={op:i,type:l}),c=p+i.length}}if(t!==-1)try{return ge(o,r)}catch{return{type:A.VARIABLE,path:o}}return{type:A.VARIABLE,path:o}},ea=/^\w+\(.*\)$/,Pd=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,xd=e=>{if(!(!e||e.trim()===""||ea.test(e))&&Pd.test(e))throw e.includes("?")&&e.includes(":")?new _(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new _(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new _(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Qi=e=>{let r=e.trim();if(ea.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}},ft=(e,r={})=>{let n=e.trim();xd(n);let o=Zi(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}},Vs=(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,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(Id)],t=[...n.matchAll(wd)],s=[...a.map(c=>({match:c,type:"variable"})),...t.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:A.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&o.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?ft(c[1],r):Qi(c[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:c,type:u}of s){let[p,m]=c,d=c.index;if(d>l){let f=n.substring(l,d);for(let y=0;y<o.length;y++)f=f.replace(`__ESCAPED_${y}__`,o[y]);f&&i.push(f)}try{let f;u==="variable"?f=ft(m.trim(),r):f=Qi(m.trim()),i.push(f)}catch(f){if(f.message==="Invalid array index syntax")i.push(p);else throw f}l=d+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);c&&i.push(c)}return{type:A.INTERPOLATION,parts:i}};var Bs=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),na=e=>Object.keys(e),we=e=>e.join("."),mr=(e,r,n)=>{let o=na(e).filter(a=>!r.has(a));if(o.length>0)throw new _(`Unexpected key '${o[0]}' in condition JSON at '${we(n)}'`)},yr=(e,r)=>typeof e=="string"?Vs(e,r):typeof e=="object"&&e!==null?Array.isArray(e)?Sd(e,r):Rd(e,r):{type:A.LITERAL,value:e},Ed=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}},Sd=(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=Ed(t),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=ta(c[0],l[c[0]],r,!0);n.push(u),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=ta(i[0],t[i[0]],r);n.push(l),o=!0;continue}}let s=yr(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}},Rd=(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"],c=[];for(let[h]of t)for(let I of l)if(h===I||h.startsWith(I+" ")||h.startsWith(I+"#")){c.push(I);break}if(c.length>0)throw new _(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,d={},f=!1;for(let[h,I]of Object.entries(m)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),d[b]=I,f=!0}let y=null;if(f&&(y=yr(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:u,data:y};return p!==void 0&&(g.whenCondition=ra(p,r)),g}for(let[l,c]of t)if(l==="$when"){if(a!==null)throw new _("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new _("Missing condition expression after '$when'");a=ra(c,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,c]=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 u=Od(t,s,r);n.push({key:l,value:u.node}),o=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new _(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new _(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new _("Missing condition expression after '$if'");{let u=yr(c,r);(u.type===A.FUNCTION||u.type===A.CONDITIONAL||u.type===A.PARTIAL||u.type===A.OBJECT&&!u.fast||u.type===A.ARRAY&&!u.fast)&&(o=!0);let p=Vs(l,r),m={key:l,value:u};(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},Od=(e,r,n={})=>{let o=[],a=[],t=r,[s,i]=e[t],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new _(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Ms(c);let u=ge(c,n);for(o.push(u),a.push(yr(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{Ms(f);let y=ge(f,n);o.push(y)}if(a.push(yr(m,n)),t++,f===null)break}else break}return{node:{type:A.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:t}},Fs={eq:Y.EQ,neq:Y.NEQ,gt:Y.GT,gte:Y.GTE,lt:Y.LT,lte:Y.LTE,in:Y.IN,add:Y.ADD,sub:Y.SUBTRACT},Us={all:Y.AND,any:Y.OR},Cd=new Set(["var","literal","call","not",...Object.keys(Fs),...Object.keys(Us)]),$d=(e,r,n)=>{if(!Array.isArray(e))throw new _(`Condition JSON operator '${r}' at '${we(n)}' requires an array`);if(e.length!==2)throw new _(`Condition JSON operator '${r}' at '${we(n)}' requires exactly 2 operands`);return e},_d=(e,r,n,o,a)=>{if(!Array.isArray(e))throw new _(`Condition JSON operator '${r}' at '${we(a)}' requires an array`);if(e.length===0)throw new _(`Condition JSON operator '${r}' at '${we(a)}' requires at least 1 condition`);return e.map((s,i)=>Re(s,o,[...a,i])).reduce((s,i)=>({type:A.BINARY,op:n,left:s,right:i}))},jd=(e,r,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],mr(e,new Set(["call","args"]),n);else if(Bs(e.call))o=e.call.name,a=e.call.args??[],mr(e,new Set(["call"]),n),mr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new _(`Condition JSON call at '${we(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new _(`Condition JSON call at '${we(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new _(`Invalid condition JSON function name '${o}' at '${we(n)}'`);if(!Array.isArray(a))throw new _(`Condition JSON call '${o}' at '${we(n)}' requires args to be an array`);return{type:A.FUNCTION,name:o,args:a.map((t,s)=>Re(t,r,[...n,"args",s]))}},Re=(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 '${we(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Bs(e))throw new _(`Invalid condition JSON value at '${we(n)}'`);let o=na(e);if(o.length===0)throw new _(`Condition JSON object at '${we(n)}' must contain an operator`);let a=o.filter(s=>Cd.has(s));if(a.length===0)throw new _(`Unknown condition JSON operator '${o[0]}' at '${we(n)}'`);if(a.length>1)throw new _(`Condition JSON at '${we(n)}' must contain exactly one operator`);let t=a.includes("call")?"call":a[0];if(t==="var"){if(mr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new _(`Condition JSON var at '${we(n)}' requires a non-empty path`);return{type:A.VARIABLE,path:e.var}}if(t==="literal")return mr(e,new Set(["literal"]),n),{type:A.LITERAL,value:e.literal};if(t==="call")return jd(e,r,n);if(t==="not")return mr(e,new Set(["not"]),n),{type:A.UNARY,op:Hr.NOT,operand:Re(e.not,r,[...n,"not"])};if(t in Us)return mr(e,new Set([t]),n),_d(e[t],t,Us[t],r,[...n,t]);if(t in Fs){mr(e,new Set([t]),n);let s=$d(e[t],t,[...n,t]);return{type:A.BINARY,op:Fs[t],left:Re(s[0],r,[...n,t,0]),right:Re(s[1],r,[...n,t,1])}}throw new _(`Unknown condition JSON operator '${t}' at '${we(n)}'`)},ra=(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 ge(e,r)}return Bs(e)||Array.isArray(e)?Re(e,r):{type:A.LITERAL,value:e}},ge=(e,r={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return ge(c,r)}let n=Or(e,"||");if(n!==-1)return{type:A.BINARY,op:Y.OR,left:ge(e.substring(0,n).trim(),r),right:ge(e.substring(n+2).trim(),r)};let o=Or(e,"&&");if(o!==-1)return{type:A.BINARY,op:Y.AND,left:ge(e.substring(0,o).trim(),r),right:ge(e.substring(o+2).trim(),r)};let a=[{op:">=",type:Y.GTE},{op:"<=",type:Y.LTE},{op:"==",type:Y.EQ},{op:"!=",type:Y.NEQ},{op:">",type:Y.GT},{op:"<",type:Y.LT},{op:" in ",type:Y.IN}];for(let{op:c,type:u}of a){let p=Or(e,c);if(p!==-1)return{type:A.BINARY,op:u,left:ge(e.substring(0,p).trim(),r),right:ge(e.substring(p+c.length).trim(),r)}}let t=-1,s=null,i=[{op:" + ",type:Y.ADD},{op:" - ",type:Y.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let m=Or(e.substring(p),c);if(m===-1)break;let d=p+m;d>t&&(t=d,s={op:c,type:u}),p=d+c.length}}if(t!==-1&&s)return{type:A.BINARY,op:s.type,left:ge(e.substring(0,t).trim(),r),right:ge(e.substring(t+s.op.length).trim(),r)};let l=[" * "," / "," % "];for(let c of l)if(Or(e,c)!==-1)throw new _(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:A.UNARY,op:Hr.NOT,operand:ge(e.substring(1).trim(),r)}:sa(e,r)},Or=(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},Nd=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}},sa=(e,r)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return ft(n,r);let a=Nd(n);if(a.type===A.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:A.VARIABLE,path:n};try{return ft(n,r)}catch(t){if(t.message&&t.message.includes("not supported"))return a;throw t}},Dd=(e,r=!1)=>{let n=r?"$each":"$for";try{Yi(e)}catch(o){if(o instanceof _&&r){let a=o.message.replace(/\$for/g,"$each");throw new _(a.replace("Parse Error: ",""))}throw o}},ta=(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();Dd(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 c=l[1].trim(),u=l[2].trim(),p,m=null;if(c.includes(",")){let g=c.split(",").map(h=>h.trim());if(g.length!==2)throw new _(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=g[0],m=g[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new _(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new _(`Reserved variable name: ${m}`);let f=sa(u,n),y=yr(r,n);return{type:A.LOOP,itemVar:p,indexVar:m,iterable:f,body:y,flatten:s!=="nested"}};var Ld=(e,r={})=>{let{functions:n={}}=r;return yr(e,n)},tn=Ld;var mt={};Xp(mt,{now:()=>Td});var Td=()=>Date.now();var Md=(e,r,n={})=>{let{functions:o={},partials:a={}}=n,t={...mt,...o},s=tn(e,{functions:t}),i={};for(let[l,c]of Object.entries(a))i[l]=tn(c,{functions:t});return qs(s,r,{functions:t,partials:i})},Cr=Md;var qd=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Vd=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Fd=(e,r)=>{if(qd(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new _("Empty condition expression");return ge(e,r)}return Re(e,r)},Ud=(e,r={},n={})=>{let o=Vd(n),a={...mt,...o},t=Fd(e,a);return!!fr(t,{functions:a,partials:{}},r,{})},Ys=Ud;var Zs=Symbol("runStoreTransaction"),Xs="__routeEngineConditionComparison",nn=(e,r)=>typeof e=="number"&&typeof r=="number"&&Number.isFinite(e)&&Number.isFinite(r)||typeof e=="string"&&typeof r=="string",hr=Object.freeze({eq:(e,r)=>e===r,neq:(e,r)=>e!==r,gt:(e,r)=>nn(e,r)&&e>r,gte:(e,r)=>nn(e,r)&&e>=r,lt:(e,r)=>nn(e,r)&&e<r,lte:(e,r)=>nn(e,r)&&e<=r}),pa=Object.freeze(Object.fromEntries(Object.keys(hr).map(e=>[e,`${Xs}${e}`]))),Bd=Object.freeze(Object.fromEntries(Object.entries(pa).map(([e,r])=>[r,hr[e]]))),oa=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),Yd=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},sn=e=>{if(Array.isArray(e))return e.map(sn);if(e===null||typeof e!="object"||oa(e,"literal")||oa(e,"var"))return e;if(Yd(e)?.startsWith(Xs))throw new Error(`Condition function names beginning with "${Xs}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,t=pa[o];if(t)return{call:t,args:a.map(sn)}}return Object.fromEntries(n.map(([o,a])=>[o,sn(a)]))},ht=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Re(e),Ys(sn(e),r,{functions:Bd})},zd=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],da=(e,r,n={})=>{let o=structuredClone(e),a={},t={},{transformSelectorFirstArgument:s=c=>c,transformActionFirstArgument:i=c=>c}=n;for(let[c,u]of Object.entries(r))c!=="createInitialState"&&(c.startsWith("select")?a[c]=(...p)=>u(s(o),...p):t[c]=(...p)=>{let m;return o=Ts(o,f=>{let y=u(i(f),...p);m=y!==void 0&&!he(y)?y:void 0}),m});let l=c=>{if(typeof c!="function")throw new Error("Store transaction requires a callback");let u=o;try{return c()}catch(p){throw o=u,p}};return{...a,...t,[Zs]:l}},cn=(e,r)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return Ts(o,t=>{a.forEach(s=>{r.forEach(i=>{i(t,s)})})})};var Gd=(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),Ws=(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),Hd=new Set(["pageSize","groups"]),Xd=new Set(["id","variants"]),Wd=new Set(["id","imageId"]),Kd=new Set(["pageSize","tracks"]),Jd=new Set(["id","soundId","title","artist","album","description","coverImageId"]),Qd=new Set(["pageSize","replays"]),Zd=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),$r=(e,r,n)=>{Object.keys(e).forEach(o=>{if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},Xr=(e,r)=>{if(typeof e!="string"||e.length===0)throw new Error(`${r} must be a non-empty string`)},gt=(e={})=>{let r=e?.resources?.imageGallery;if(r===void 0)return;if(!fe(r))throw new Error("resources.imageGallery must be an object");if($r(r,Hd,"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($r(a,Xd,t),Xr(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 c=`${t}.variants[${i}]`;if(!fe(l))throw new Error(`${c} must be an object`);if($r(l,Wd,c),Xr(l.id,`${c}.id`),Xr(l.imageId,`${c}.imageId`),s.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(s.add(l.id),!B(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},bt=(e={})=>{let r=e?.resources?.musicRoom;if(r===void 0)return;if(!fe(r))throw new Error("resources.musicRoom must be an object");if($r(r,Kd,"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`);$r(a,Jd,t);for(let l of["id","soundId","title"])Xr(a[l],`${t}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&Xr(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}"`)}},ef=(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}"`)}},It=(e={})=>{let r=e?.resources?.sceneReplay;if(r===void 0)return;if(!fe(r))throw new Error("resources.sceneReplay must be an object");if($r(r,Qd,"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`);$r(t,Zd,s);for(let u of["sceneId","title","thumbnailImageId"])Xr(t[u],`${s}.${u}`);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,c=i.sections?.[l];if(!c)throw new Error(`Scene replay scene "${t.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${t.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(t.initialVariables!==void 0){if(!fe(t.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(t.initialVariables)){let m=e?.resources?.variables?.[u];if(!m)throw new Error(`Scene replay scene "${t.sceneId}" initialVariables references unknown variable "${u}"`);if($e(m))throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${t.sceneId}" can only initialize context variable "${u}"`);ef(u,m,p)}}}},fa=e=>{let r=he(e)?dr(e):e;return structuredClone(r)},rf=({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},un=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0;if(r?.name!==void 0)return r.name;if(n!==void 0)return n;let s=rf({characterId:e,resourceCharacter:t,variables:a});return s!==void 0?s:t?.name||""},$e=e=>B(e,"computed"),eo=(e,r)=>{switch(e?.type){case"number":return typeof r=="number"&&Number.isFinite(r);case"boolean":return typeof r=="boolean";case"string":return typeof r=="string";case"object":return r!==null&&typeof r=="object"&&!Array.isArray(r);default:return!1}},wt=(e={},r={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,t])=>{let s=r[a];return s===void 0?o:!$e(s)&&(!n||n.includes(s.scope))&&eo(s,t)})),Me=(e,r)=>new Error(`${r} has invalid path: ${JSON.stringify(e)}`),tf=(e,r,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Me(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 Me(r,n);a+=s;continue}if(t+=1,t>=e.length-1)throw Me(r,n);let i=e[t];if(i==="u"){let c=e.slice(t+1,t+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Me(r,n);a+=String.fromCharCode(Number.parseInt(c,16)),t+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
- `,r:"\r",t:" ",b:"\b",f:"\f"};if(!B(l,i))throw Me(r,n);a+=l[i]}return a},ma=(e,r="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Me(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 Me(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 u=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(u,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw Me(e,r);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Me(e,r);let i=s,l=o;o+=1;let c=!1;for(;o<e.length;){let u=e[o];if(c)c=!1;else if(u==="\\")c=!0;else if(u===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw Me(e,r);o+=1,n.push(tf(p,e,r));return}o+=1}if(c||o>=e.length)throw Me(e,r)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){t();continue}throw Me(e,r)}return n},zs=(e,r)=>{let n=e;for(let o of r){if(n==null||!B(n,o))return;n=n[o]}return n},ya=(e,r={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=ma(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 zs(s,t)}return o==="runtime"?zs(r.runtime,n.slice(1)):zs(r,n)},ha=(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)`)},Ks=(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`)},nf=(e,r)=>{if(typeof r!="number"||!Number.isFinite(r))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Ye=(e,r,n,o)=>(ha(e,r,o),r.map(a=>ln(a,n))),Te=(e,r,n,o)=>{let a=Ye(e,r,n,o);return a.forEach(t=>nf(e,t)),a},sf=(e,r,n)=>{switch(e){case"var":return ya(r,n);case"add":{let[o,a]=Te(e,r,n,2);return o+a}case"sub":{let[o,a]=Te(e,r,n,2);return o-a}case"mul":{let[o,a]=Te(e,r,n,2);return o*a}case"div":{let[o,a]=Te(e,r,n,2);return o/a}case"mod":{let[o,a]=Te(e,r,n,2);return o%a}case"neg":{let[o]=Te(e,r,n,1);return-o}case"round":{let[o]=Te(e,r,n,1);return Math.round(o)}case"floor":{let[o]=Te(e,r,n,1);return Math.floor(o)}case"ceil":{let[o]=Te(e,r,n,1);return Math.ceil(o)}case"min":{let[o,a]=Te(e,r,n,2);return Math.min(o,a)}case"max":{let[o,a]=Te(e,r,n,2);return Math.max(o,a)}case"clamp":{let[o,a,t]=Te(e,r,n,3);return Math.min(t,Math.max(a,o))}case"eq":{let[o,a]=Ye(e,r,n,2);return hr.eq(o,a)}case"neq":{let[o,a]=Ye(e,r,n,2);return hr.neq(o,a)}case"gt":{let[o,a]=Ye(e,r,n,2);return hr.gt(o,a)}case"gte":{let[o,a]=Ye(e,r,n,2);return hr.gte(o,a)}case"lt":{let[o,a]=Ye(e,r,n,2);return hr.lt(o,a)}case"lte":{let[o,a]=Ye(e,r,n,2);return hr.lte(o,a)}case"in":{let[o,a]=Ye(e,r,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return Ks(e,r),r.every(o=>!!ln(o,n));case"or":case"any":return Ks(e,r),r.some(o=>!!ln(o,n));case"not":{let[o]=Ye(e,r,n,1);return!o}case"length":{let[o]=Ye(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]=Ye(e,r,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return fa(r);default:throw new Error(`Unknown computed expression operator: ${e}`)}},ln=(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 sf(o,a,r)},Js=(e,r)=>{if(e===null||typeof e!="object"||B(e,"literal"))return e;if(B(e,"var"))return{literal:ya(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=>Js(a,r)):Js(o,r)]))},of=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Re(e),ht(Js(e,r))},ga=(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`)},Gs=(e,r,n)=>(ga(e,r),B(e,"value")?fa(e.value):ln(e.expr,n)),af=(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(of(i.when,r))return Gs(i,`Computed variable "${n}" branch ${s}`,r)}return Gs(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 Gs(e,`Computed variable "${n}"`,r)},ba=(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}`)}},lf=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}),cf=new Set(["and","or","all","any"]),uf=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),pf=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),df=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),ff=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Ia=new WeakMap,ia=e=>e===null?"null":Array.isArray(e)?"object":typeof e,on=(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}`)},wa=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{let t=`Computed variable "${r}" ${a} var`,[s,i,...l]=ma(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 c=n[i];return $e(c)&&o.add(i),l.length===0?c?.type:void 0},va=(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 ia(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 wa(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 ia(i)}let l=lf[s];if(l===void 0&&!cf.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?Ks(s,i):ha(s,i,l);let c=i.map((u,p)=>va(u,{variableId:r,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(pf.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),uf.has(s))return"number";if(df.has(s))return"boolean"},yf=(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{Re(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")){wa(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(c=>ff.has(c));s[l].forEach((c,u)=>{t(c,`${i}.${l}[${u}]`)})};t(e,a)},Hs=(e,{variableId:r,variableConfig:n,variableConfigs:o,dependencies:a,path:t,allowedKeys:s=new Set(["expr","value"])})=>{if(ga(e,`Computed variable "${r}" ${t}`),on(e,s,t),B(e,"value")){ba(r,n.type,e.value);return}let i=va(e.expr,{variableId:r,variableConfigs:o,dependencies:a,path:`${t}.expr`});mf(r,n.type,i,`${t}.expr`)},hf=(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(on(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,c)=>{if(!fe(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(on(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!B(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);yf(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Hs(l,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Hs(o.default,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(on(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 Hs(o,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed"}),a},_r=(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($e(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(At(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,hf(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 c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),n.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...i.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...r.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return Ia.set(e,a),a},vt=({variables:e={},runtime:r={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=Ia.get(n)??_r(n),t=wt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>$e(g)).map(([g])=>g),i=Object.create(null),l=[],c=new Map(a.map((g,h)=>[g,h])),u=-1,p=!1,m=g=>{if(B(i,g))return i[g];let h=n[g];if(!$e(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=af(h.computed,y,g);return ba(g,h.type,b),Ws(i,g,b),b}finally{l.pop()}},d=g=>{if(B(i,g))return i[g];let h=n[g];if(!$e(h))return B(t,g)?t[g]:void 0;let I=c.get(g);if(o&&!p&&I!==void 0&&I>u){p=!0;try{for(let b=u+1;b<=I;b+=1)m(a[b]),u=b}finally{p=!1}return i[g]}return m(g)},f=new Proxy({},{get:(g,h)=>{if(typeof h=="string")return d(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:f,runtime:r,resolveVariable:d};return o?(s.forEach(g=>{d(g)}),{...t,...i}):f},gf=({variables:e={},runtime:r={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return _r(a),vt({variables:e,runtime:r,variableConfigs:a,eager:!0})},pn=e=>{let r={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if($e(a))return;let t=Gd(a,o);a.scope==="context"?Ws(r,o,t):Ws(n,o,t)}),{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}},At=(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(", ")}`)},kt=(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(", ")}`)},bf=2,aa=12,Aa=(e=bf)=>{if(!Number.isInteger(e)||e<0||e>aa)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${aa}.`);return e},If=(e,r)=>{let n=10**r;return Math.round((e+Number.EPSILON)*n)/n},an=e=>typeof e=="number"&&Number.isFinite(e),dn=(e,r,n,o,a={})=>{if(e==="number"){if(r==="set"&&!an(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(r==="multiply"&&!an(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(r==="divide"&&!an(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}".`);Aa(a.roundTo)}}},fn=(e,r,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!an(c))throw new Error(`Operation "${r}" requires ${l} to be a number.`);return c},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 If(a(e,0,"current value")/t(n),Aa(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 ro=(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:zd[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])},wf=(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},yt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,vf=(e,r)=>{let n=e?.character?.sprite,o=r?.character?.sprite,a=yt(n)?n:void 0,t=yt(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},la=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},ca=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},ua=(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,Af=(e,r)=>{let n={},o=ua(la(e),la(r)),a=ua(ca(e),ca(r));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},to=(e={},r={})=>{let n={},o=["sfx","voice"],a=l=>{let c=e[l],u=r[l];u&&!c?n[l]={changeType:"add",data:u}:c&&!u?o.includes(l)||(n[l]={changeType:"delete",data:c}):c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},t=Af(e.background,r.background);t&&(n.background=t),a("screen"),a("bgm"),a("voice");let s=wf(e.dialogue,r.dialogue);s&&(n.dialogue=s);let i=vf(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},no=(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},kf=(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},Pf=(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=kf(r,n);if(o===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "_event".`);return o},xf={conditional:new Set(["branches"]),updateProjectData:new Set(["projectData"]),showConfirmDialog:new Set(["confirmActions","cancelActions"]),form:new Set(["submitActions","cancelActions"]),submitForm:new Set(["actions"]),cancelForm:new Set(["actions"])},Ef=(e,r)=>{let n=e[e.length-1];return n?xf[n]?.has(r)===!0:!1},Qs=(e,r,n=[])=>Array.isArray(e)?e.map(o=>Qs(o,r,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Ef(n,o)?a:Qs(a,r,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Pf(e,r._event):Cr(e,r):e,so=(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 Qs(e,r)};var te=e=>structuredClone(he(e)?dr(e):e),W=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),ka=e=>e?.animations?.playback?.continuity==="persistent",X=(e,r)=>W(e??{},r)&&e[r]!==void 0,Pt=(e,r)=>e?!r(e)&&e.animations?{animationsOnly:!0,state:{animations:te(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Sf=e=>X(e,"opacity")||X(e,"blur"),Oa=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Ca=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],oo=["animationName","animationSpeed","loop"],Rf=e=>Oa.some(r=>X(e,r)),$a=e=>e?.text&&X(e.text,"content")&&X(e.text,"textStyleId"),_a=e=>X(e,"text"),Of=(e,r)=>e.resourceId?!0:$a(e)?!r?.text:!1,Cf=(e,r)=>{let n={...te(e),...r};return r.text&&e.text&&(n.text={...te(e.text),...te(r.text)}),n},$f=(e,r)=>{if(_a(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!$a(e)&&!r?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},Pa=e=>Ca.some(r=>X(e,r)),xa=e=>oo.some(r=>X(e,r)),_f=(e,r,{hasAuthoredTransformId:n=!1}={})=>{if(!r)return e;for(let o of Ca)!n&&!X(e,o)&&X(r,o)&&(e[o]=r[o]),W(e,o)&&e[o]===void 0&&delete e[o];return e},ja=(e,r,n)=>{let o=e[n];return o?.id===r?.id?o:e.find(a=>a.id===r?.id)},jf=(e,r)=>{if(!r)return e;for(let n of Oa)!X(e,n)&&X(r,n)&&(e[n]=r[n]),W(e,n)&&e[n]===void 0&&delete e[n];return e},Nf=(e,r)=>(r&&(!X(e,"opacity")&&X(r,"opacity")&&(e.opacity=r.opacity),!X(e,"blur")&&X(r,"blur")&&(e.blur=te(r.blur)),W(e,"opacity")&&e.opacity===void 0&&delete e.opacity,W(e,"blur")&&e.blur===void 0&&delete e.blur),e),Na=(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=ja(n,s,i),c=r(s,l),u=Sf(s),p=Rf(s),m=o(s),d=W(s,"animations"),f=te(s);return!c&&(u||p||m)&&l&&(f=a?a(l,f):{...te(l),...f},d||delete f.animations),Nf(jf(f,l),l)}).filter(s=>r(s)||s.animations);return{hasValidItems:t.length>0,processedItems:t}},Df=e=>{if(e){if(e.character&&W(e.character,"name"))return e.character.name;if(W(e,"characterName"))return e.characterName}},Da=e=>!!e?.character&&W(e.character,"sprite"),Lf=e=>{let r={},n=!1,o=Df(e);return o!==void 0&&(r.name=o,n=!0),Da(e)&&(r.sprite=te(e.character.sprite),n=!0),n?r:void 0},Ea=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Sa=({dialogueState:e,dialogueAction:r,persistCharacter:n})=>W(r,"persistSprite")?r.persistSprite===!0:W(e,"persistSprite")?e.persistSprite===!0:n&&!W(r,"characterId"),Ra=({previousCharacter:e,characterFields:r,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:t,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},c=r??{},u=s&&!n,p=u&&!t;return W(c,"name")?i.name=c.name:(o&&!n||u)&&W(l,"name")&&(i.name=te(l.name)),W(c,"sprite")?i.sprite=te(c.sprite):(a||p)&&W(l,"sprite")&&(i.sprite=te(l.sprite)),Object.keys(i).length>0?i:void 0},Tf=({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=>te(a)):delete e.initialRevealedContent,e.content=[...o,...r]},Mf=()=>({}),qf=(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=te(r.screen.blur):X(t,"blur")&&(s.blur=te(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},Vf=(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=Pa(r.background),l=xa(r.background),{animationsOnly:c,state:u}=Pt(r.background,d=>X(d,"resourceId")||X(d,"colorId")||X(d,"opacity")||X(d,"blur")||X(d,"transformId")||Pa(d)||xa(d));if(c){e.background=e.background?{...te(e.background),...u}:u;return}if(!n&&!o&&!a&&!t&&!s&&!i&&!l){delete e.background;return}let p=e.background,m=te(r.background);if(!n&&p?.resourceId){m.resourceId=p.resourceId,!W(m,"transformId")&&p.transformId&&(m.transformId=p.transformId);for(let d of oo)!X(m,d)&&X(p,d)&&(m[d]=p[d])}_f(m,p,{hasAuthoredTransformId:s}),!o&&p?.colorId&&(m.colorId=p.colorId),!a&&X(p,"opacity")&&(m.opacity=p.opacity),!t&&X(p,"blur")&&(m.blur=te(p.blur)),W(m,"resourceId")&&m.resourceId===void 0&&delete m.resourceId,W(m,"colorId")&&m.colorId===void 0&&delete m.colorId,W(m,"animations")&&m.animations===void 0&&delete m.animations,W(m,"transformId")&&m.transformId===void 0&&delete m.transformId,W(m,"opacity")&&m.opacity===void 0&&delete m.opacity,W(m,"blur")&&m.blur===void 0&&delete m.blur;for(let d of oo)W(m,d)&&m[d]===void 0&&delete m[d];if(!m.resourceId&&!m.colorId){delete e.background;return}p?.resourceId===m.resourceId&&p?.transformId===m.transformId&&!W(m,"animations")&&ka(p)&&(m.animations=te(p.animations)),e.background=m}else e.background?.animations&&!ka(e.background)&&(e.background.animations={})},Ff=(e,r)=>{if(!r.dialogue){if(e.dialogue&&(Ea(e.dialogue),e.dialogue.mode==="adv")){e.dialogue.content=void 0,delete e.dialogue.initialRevealedContent,delete e.dialogue.textSpeed;let u=e.dialogue.persistCharacter===!0,p=Sa({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=Ra({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(r.dialogue.ui){let{animationsOnly:u,state:p}=Pt(r.dialogue.ui,m=>!!m.resourceId);u?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&&Tf({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=Sa({dialogueState:e.dialogue,dialogueAction:r.dialogue,persistCharacter:a});W(r.dialogue,"persistSprite")&&(e.dialogue.persistSprite=t);let s=W(r.dialogue,"characterId"),i=Lf(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 c=Ra({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:t,hasExplicitPersistSprite:W(r.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Ea(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 u={content:r.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=te(e.dialogue.character)),e.dialogue.lines.push(u)}},Uf=(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=te(r.sfx)}else e.sfx&&delete e.sfx},Bf=(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=te(r.bgm),r.bgm.resourceId&&(e.bgm.loop=r.bgm.loop??!0)}},Yf=(e,r)=>{if(r.visual){let n=e.visual?.items||[];r.visual.items?.forEach((t,s)=>{$f(t,ja(n,t,s))});let{hasValidItems:o,processedItems:a}=Na(r.visual.items,Of,n,{hasPatchFn:_a,mergeItemFn:Cf});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))},zf=(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}=Na(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},Gf=(e,r)=>{r.animation?e.animation=r.animation:e.animation&&delete e.animation},Hf=(e,r)=>{if(r.layout){let{animationsOnly:n,state:o}=Pt(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},Xf=(e,r)=>{if(r.choice){let{animationsOnly:n,state:o}=Pt(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},Wf=(e,r)=>{if(r.form){let{animationsOnly:n,state:o}=Pt(r.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!r.form.resourceId){delete e.form;return}e.form=te(r.form)}else e.form&&delete e.form},Kf=(e,r)=>{if(r.control){if(!r.control.resourceId){delete e.control;return}e.control=r.control}},Jf=(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=te(r.voice)}else e.voice&&delete e.voice},Qf=(e,r)=>{r.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},jr=e=>cn(Mf,[Qf,qf,Vf,Uf,Bf,Yf,Ff,zf,Gf,Hf,Xf,Wf,Kf,Jf])(e);var Wr=(e,r)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Cr(e,r);return n&&typeof n=="object"?e:n};var Zf=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"}}),gr=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}),xt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),em=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),io=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),La=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),ao=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Ta=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),rm=(e,r)=>{let n=em[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}"`)},mn=(e,r)=>{if(rm(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},lo=(e={})=>{let r=e?.config;if(r===void 0)return{...gr};if(!Ta(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{...gr};if(!Ta(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(La),t=Object.keys(o).find(i=>!a.has(i));if(t)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${t}"`);let s={...gr};return La.forEach(i=>{o[i]!==void 0&&(s[i]=mn(i,o[i]))}),s},tm=(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]}},Nr=e=>Object.fromEntries(Object.entries(Zf).map(([r,n])=>{let o=tm(e,n.source),a=o!==void 0?o:gr[r]??xt[r];return[r,a]})),br=(e,r)=>Nr(e)[r],Ma=(e={})=>Object.fromEntries(io.map(r=>[r,e[r]??gr[r]]));var Kr=Object.freeze({VISUAL_BEHIND_BACKGROUND:10,BACKGROUND:20,VISUAL_BEHIND_CHARACTER:30,CHARACTER:40,VISUAL_BEHIND_DIALOGUE:50,DIALOGUE:60,VISUAL_BEHIND_CHOICE:70,CHOICE:80,VISUAL_FOREGROUND:90}),er=Object.freeze({BEHIND_BACKGROUND:Kr.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:Kr.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:Kr.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:Kr.VISUAL_BEHIND_CHOICE,FOREGROUND:Kr.VISUAL_FOREGROUND}),co=er.BEHIND_DIALOGUE,uo=Object.freeze(Object.values(er).sort((e,r)=>e-r));var nm={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([r,n])=>({id:r,...n})),formatDate:ro},sm=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Et=e=>Array.isArray(e)?e.map(r=>{if(!r||typeof r!="object"||Array.isArray(r)||Object.keys(r).length!==1)return Et(r);let[n]=Object.keys(r),o=sm.exec(n);if(!o)return Et(r);let[,a,t,s]=o,i=`$for ${a}${t?`, ${t}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(r[n])?r[n]:[];return{[i]:Et(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Et(n)])),tr=(e,r)=>{let n={functions:nm};return Cr(Et(e),r,n)},Ro=({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".`)},om=({id:e,targetId:r,animation:n,playback:o,animationPath:a="animation"})=>{let t=structuredClone(n);if(Ro({animationType:t.type,animationId:e,animationPath:a}),delete t.name,delete t.playback,t.id=e,t.targetId=r,o!==void 0){let s=cm(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?el(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},im=(e,{animationId:r="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Ro({animationType:e.type,animationId:r,animationPath:n}),e.type},am=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},lm=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},cm=(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},um=e=>{let r=e?.playback?.speed;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:1},Dr=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Ja=e=>e?.playback?.continuity==="persistent",Io=e=>Array.isArray(e)?e.map(Io):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((r,n)=>(r[n]=Io(e[n]),r),{}),bn=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(Io(r))},Qa=(e=[])=>e.filter(r=>Ja(r)).map(r=>structuredClone(r)),Za=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,po=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((r,n)=>Math.max(r,Za(n)),0),el=e=>Math.max(po(e?.tween),po(e?.prev?.tween),po(e?.next?.tween),Za(e?.mask?.progress)),rl=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:el(e)/um(e),pm=e=>e.some(r=>r?.playback?.loop===!0),qa=({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(bn).filter(Boolean));return e.some(o=>{if(!Ja(o))return!1;let a=bn(o);return a?n.has(a):!1})},ze=({animationInstances:e,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:t=!0})=>!Array.isArray(e)||e.length===0||n?!1:pm(e)||t&&!r||qa({animationInstances:e,activePersistentAnimations:o})?!0:t?!1:qa({animationInstances:e,activePersistentAnimations:a}),dm=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(r=>e[r]!==void 0),fm=(e,r)=>{if(dm(e))throw new Error(`[${r}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},mm=({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?om({id:o,targetId:a,animation:s,playback:n,animationPath:t}):null},ym=(e,{defaultTargetId:r,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return Ro({animationType:a.type,animationId:a.id??n,animationPath:o}),a.id??=n,a.targetId??=r,a},Oo=({animations:e,transitions:r,defaultTargetId:n,idPrefix:o,animationPathPrefix:a=o})=>{r.forEach((t,s)=>{e.push(ym(t,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},wo=(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},hm=({content:e,path:r,variables:n})=>wo(e,r).reduce((o,a)=>{let t=Wr(a.text,{variables:n});return o+`${t??""}`.length},0),Va=(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))},yn=(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("-")}`},St=(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},gm=(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},bm=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Im=(e={})=>bm.some(r=>Dr(e,r)),tl=(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"}},gn=({resourceId:e,kind:r})=>{if(e)return r?`bg-cg-background-${r}`:`bg-cg-${e}`},wm=(e={})=>e.textStyles||{},vm=(e={})=>e.images||{},Am=.5,km=(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]},Co=({id:e,resourceId:r,spritesheet:n,animationName:o,animationSpeed:a,loop:t,width:s,height:i,transform:l={}}={})=>{let c=km(n,o,r),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${r}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:i??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Am,loop:t??u.loop??!0}}},nl=({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 Co({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}`)},Pm=(e={})=>e.colors||{},xm=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Ot=(e,r)=>e==="root"?`${r}`:`${e}.${r}`,Zr=(e,r,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${r}" must resolve to a non-empty string`)},fo=(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},mo=(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},vn=(e,r)=>{if(typeof e!="string"||!xm.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},Fa=(e,r,n)=>{let o=vn(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})`},Em=(e={},r)=>{let n=wm(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 c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${r}"`);return c.fileId}),t=e.colors?.[n.colorId];if(!t)throw new Error(`Color "${n.colorId}" not found for text style "${r}"`);let s=fo(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:Fa(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 c=fo(n.strokeAlpha,"strokeAlpha",r);i.strokeColor=Fa(l.hex,c,`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:vn(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${r}"`),alpha:fo(n.shadow.alpha,"shadow.alpha",r),blur:mo(n.shadow.blur,"blur",r,0,{minimum:0}),offsetX:mo(n.shadow.offsetX,"offsetX",r,2),offsetY:mo(n.shadow.offsetY,"offsetY",r,2)}}return i},vo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>vo(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]=vo(t,r,Ot(n,a)));return e.textStyleId!==void 0&&(Zr(e.textStyleId,n,"textStyleId"),o.textStyle=Em(r,e.textStyleId)),o},$o=(e={},r)=>{let n=Pm(e)?.[r];if(!n)throw new Error(`Color "${r}" not found`);return vn(n.hex,`Color "${r}"`)},sl=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",yo=(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 ${sl(`${r}.fill`)} instead`)},Sm=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>Ct(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]=Ct(t,r,Ot(n,a)));return e.colorId!==void 0&&(Zr(e.colorId,n,"colorId"),o.fill=$o(r,e.colorId)),o},Ct=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>Ct(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 ${sl("fill")} instead`);yo(e,"hover",n),yo(e,"click",n),yo(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]=Sm(t,r,Ot(n,a));continue}o[a]=Ct(t,r,Ot(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(Zr(e.colorId,n,"colorId"),o.fill=$o(r,e.colorId)),o},ho=(e={},r)=>{let n=vm(e)?.[r];return n||null},ol=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Ua=(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 ${ol(`${r}.${o}`)} instead`)},Ba=(e,r,n)=>{let o=e[r];e[r]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},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(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 ${ol(a)} instead`);Ua(e,"hover",n,"src"),Ua(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]=Ao(t,r,Ot(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){Zr(e.imageId,n,"imageId");let a=ho(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&&(Zr(e.hoverImageId,n,"hoverImageId"),Ba(o,"hover",ho(r,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Zr(e.clickImageId,n,"clickImageId"),Ba(o,"click",ho(r,e.clickImageId)?.fileId??e.clickImageId)),o},_o=(e,r={},n="root")=>Ao(Ct(vo(e,r,n),r,n),r,n),nr=_o,Lr=(e=[])=>e.find(r=>r.id==="story"),Rm="#000000",ko="bg-cg-background-color",Om=({resources:e={},background:r={},screen:n})=>r?.colorId===void 0?vn(n?.backgroundColor??Rm,"screen.backgroundColor"):$o(e,r.colorId),il=(e={})=>{if(Dr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},Cm=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ya=(e={},{includeDefaultAlpha:r=!1}={})=>{let n=il(e),o=Cm(e),a={};return(r||n!==void 0)&&(a.alpha=n??1),o&&(a.blur=o),a},$m=(e={})=>{if(Dr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},_m=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},al=(e={})=>{let r=$m(e),n=_m(e),o={};return r!==void 0&&(o.alpha=r),n&&(o.blur=n),o},Qr=(e={})=>al(e),rr=(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},jm=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],jo=(e={})=>e.text&&Dr(e.text,"content")&&Dr(e.text,"textStyleId"),za=(e={})=>{if(e.resourceId)return e.resourceId;if(jo(e))return"text"},Ga=(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,Nm=({item:e,particle:r,resources:n})=>{let o=St(n,e),a=structuredClone(r),t=a.modules?.appearance?.texture;t!==void 0&&(a.modules.appearance.texture=Ga(t,n)),a.texture!==void 0&&(a.texture=Ga(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...rr(o,e)};return Object.assign(s,Qr(e)),s},Dm=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!jo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let r of jm)if(Dr(e.text,r))throw new Error(`Visual item "${e.id}" text.${r} is reserved for the visual item`)}},Lm=({resources:e,background:r,screen:n={width:1920,height:1080},includeOpacity:o=!1})=>{let a={id:ko,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Om({resources:e,background:r,screen:n})};if(o){let t=il(r);t!==void 0&&(a.alpha=t)}return a},Tm=(e={},r)=>r?!!(e.images?.[r]||e.videos?.[r]||e.spritesheets?.[r]||e.layouts?.[r]):!1,Ha=({resources:e={},resourceId:r,colorId:n})=>{let o=tl(e,r);return r&&(o||n===void 0)?{resourceId:r,targetId:gn({resourceId:r,kind:o})}:n!==void 0?{resourceId:ko,targetId:ko}:{resourceId:void 0,targetId:void 0}},ll=100,Ir=ll,Mm="channel:bgm",qm="channel:music-room",Vm="music-room:player",Fm="channel:voice",Um="default",Bm=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Rt=(...e)=>e.map(Bm).join(":"),In=(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)})},Ym=(e,r)=>e*r/ll,cl=(e={},r)=>e?.[r]??gr[r],An=(e={},r,n=Ir)=>Ym(n,cl(e,r)),kn=({id:e,volume:r,muted:n,pan:o,loop:a,playback:t,interruption:s,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:r,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),t!==void 0&&(c.playback=structuredClone(t)),s!==void 0&&(c.interruption=s),c},hn=(e,r,n,o)=>e[n]!==void 0?e[n]:r[n]!==void 0?r[n]:o,zm=["muted","pan","playbackRate","startAt","endAt"],Pn=({id:e,sound:r,resource:n,defaultLoop:o=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:hn(r,n,"loop",o),volume:hn(r,n,"volume",Ir),startDelayMs:hn(r,n,"startDelayMs",0)};zm.forEach(s=>{let i=hn(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},qe=({variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:t=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g=[],characters:h={},dialogueUIHidden:I,skipOnlyViewedLines:b,skipTransitionsAndAnimations:x}={})=>{let v={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??I??!1,isLineCompleted:a?.isLineCompleted??l??!1},k=Km({dialogueState:s,includeInactiveAdvDialogue:i,characters:h,variables:e,runtime:v}),S={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&&(S.dialogue=k,S.dialogueLines=k.lines),S},Xa=100,wn=(e,r)=>{if(Array.isArray(e))return e.map(o=>wn(o,r));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=wn(n[o],r)}),n.type==="text-revealing"?r(n):n},Gm=e=>wn(e,r=>({...r,revealEffect:"none"})),Hm=e=>wn(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}:{}}}),wr=(e,{isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>r||o?Gm(e):n?Hm(e):e,ul=({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:{}}}}),Po=e=>{if(Array.isArray(e))return e.map(Po);if(!e||typeof e!="object")return e;let r={};for(let[t,s]of Object.entries(e))r[t]=Po(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}}:{}}}}},Xm=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Wa="submit",go=(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}}},xo=(e,r,n={})=>{if(Array.isArray(e))return e.map(c=>xo(c,r,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===Wa,t=o&&n.submitRoleAncestor,s=a||t?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=xo(u,r,c==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let c=r?.fields?.[l.field];if(c){let u={updateFormField:{formKey:r.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:go(l.change,u),submit:go(l.submit,r.submitActions)}}}return l.formRole===Wa||t?{...l,click:go(l.click,r.submitActions,{replaceActions:!0})}:l},Eo=(e,r)=>{if(Array.isArray(e))return e.map(o=>Eo(o,r));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=Eo(a,r);for(let o of Xm){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},So=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0,s=un({characterId:e,character:r,characterName:n,characters:o,variables:a});return{...t||{},...r||{},name:s}},pl=(e=[],r={},n={})=>e.map(o=>{let a=So({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}}),Wm=e=>!(!e||e.mode==="adv"&&e.content===void 0),Km=({dialogueState:e,includeInactiveAdvDialogue:r=!1,characters:n={},variables:o,runtime:a}={})=>{if(!r&&!Wm(e))return;let t=e.content===void 0?[{text:""}]:wo(e.content,"dialogue.content"),s=e.content===void 0?0:hm({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??gr.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,m)=>{let d=wo(p.content,`dialogue.lines[${m}].content`),f=So({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:Wr(y.text,{variables:o})})),character:f,characterName:f.name}}),u=So({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:t.map(p=>({...p,text:Wr(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},dl=({container:e,resources:r,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:t=!1})=>{let s=tr(e,n);return nr(wr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:t}),r)},bo=(e,r={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(r),Ka=({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:bo(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:bo(a.keyup)});return}e[o]={...t,[n]:{payload:bo(a)}}})},Jm=(e={},r={})=>{let n={};return Ka({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Ka({renderStateKeyboard:n,keyboard:r,phase:"keyup"}),Object.keys(n).length>0?n:void 0},sr=({animationsDef:e,resources:r,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:t,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:h,targetId:I})=>{let b=mm({resources:r,animationId:d,playback:f,instanceId:h,targetId:I,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,m=a&&t&&a===t;fm(e,s);let d=am(e),f=lm(e),y=r?.animations?.[d],g=im(y,{animationId:d,animationPath:s});if(g==="update")return p&&t?c({instanceId:`${i}-animation-update`,targetId:t}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(g==="transition"){let h=`${i}-animation-transition`,I=f?.continuity==="persistent"?h:`${i}-animation-in`;if(u&&p&&m)return c({instanceId:h,targetId:t}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:I,targetId:t})}return l},Qm=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Zm=(e,{presentationState:r,previousPresentationState:n,currentLineActions:o,resources:a={},screen:t={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:I,canRollback:b,form:x,saveSlots:v=[]})=>{let{elements:k,animations:S}=e;if(r.background){let C=o===void 0?!0:Dr(o?.background??{},"animations"),N=k.find(ye=>ye.id==="story");if(!N)return e;let P=gm(a,r.background),T=P||Im(r.background),V=n?.background?.resourceId,le=n?.background?.colorId,G=r.background.resourceId??(r.background.animations?V:void 0),ee=r.background.colorId??(r.background.animations?le:void 0),Pe=Tm(a,G),Fe={...r.background,colorId:ee};if((ee!==void 0||Pe)&&N.children.push(Lm({resources:a,background:Fe,screen:t,includeOpacity:!Pe})),G){let{images:ye={},videos:re={},spritesheets:ce={}}=a,se=tl(a,G),ie;if(se==="sprite"?ie=ye[G]:se==="video"?ie=re[G]:se==="spritesheet-animation"&&(ie=ce[G]),ie){let Ue=se==="video",ur=se==="spritesheet-animation",Oe={x:(t?.width??1920)/2,y:(t?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...P},$={...Ya(r.background,{includeDefaultAlpha:!0}),...rr(Oe,r.background)},j;ur?j=Co({id:gn({resourceId:G,kind:se}),resourceId:G,spritesheet:ie,animationName:r.background.animationName,animationSpeed:r.background.animationSpeed,loop:r.background.loop,transform:$}):j={id:gn({resourceId:G,kind:se}),type:Ue?"video":"sprite",src:ie.fileId,width:ie.width,height:ie.height,...$},Ue&&(j.loop=r.background.loop??!1,j.volume=ie.volume??50),j&&N.children.push(j)}}if(G){let{layouts:ye={}}=a,re=ye[G];if(re){let ce={id:gn({resourceId:G,kind:"container"}),type:"container",children:re.elements,...Ya(r.background)};T&&Object.assign(ce,rr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...P},r.background));let se=tr(ce,qe({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,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(nr(wr(se,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let oe=Ha({resources:a,resourceId:V,colorId:le}),me=Ha({resources:a,resourceId:G,colorId:ee}),Ae=sr({animationsDef:r.background.animations,resources:a,previousResourceId:oe.resourceId,currentResourceId:me.resourceId,previousTargetId:oe.targetId,currentTargetId:me.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});ze({animationInstances:Ae,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:C})&&S.push(...Ae)}return e},ey=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{elements:i,animations:l}=e;if(r.character&&o){let c=i.find(f=>f.id==="story");if(!c)return e;let u=r.character.items||[],p=n?.character?.items||[],m=Va(u),d=Va(p);for(let f=0;f<u.length;f++){let y=u[f],{transformId:g,sprites:h}=y,I=p.find(T=>T.id===y.id),b=p.findIndex(T=>T.id===y.id),x=I?.sprites&&I.sprites.length>0,v=h&&h.length>0,k=b>=0?yn(I,b,d):void 0,S=sr({animationsDef:y.animations,resources:o,previousResourceId:k,currentResourceId:v?yn(y,f,m):void 0,previousTargetId:k,currentTargetId:v?yn(y,f,m):void 0,animationPath:`character.items[${f}].animations`,idPrefix:"character"});if(y.animations&&!h&&!g&&x&&ze({animationInstances:S,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})){l.push(...S);continue}if(y.animations&&!h&&!g)continue;if(!h||h.length===0||!g){console.warn("Character item missing sprites or transformId:",y);continue}let C=yn(y,f,m),N=o.transforms[g];if(!N){console.warn("Transform not found:",g);continue}let P={type:"container",id:C,...rr(N,y),...Qr(y),children:[]};for(let T of h){let V=nl({id:`${C}-${T.id}`,item:T,resources:o});V&&P.children.push(V)}c.children.push(P),ze({animationInstances:S,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&l.push(...S)}}return e},fl=(e,r)=>{if(!uo.includes(e))throw new Error(`${r} must be one of: ${uo.join(", ")}.`)},ry=(e,r)=>{let n=!!e.resourceId||jo(e),o=e.layer??(n?void 0:r?.layer)??co;return fl(o,`Visual item "${e.id}" layer`),o},ty=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:a,skipTransitionsAndAnimations:t,variables:s,imageGallery:i,musicRoom:l,sceneReplay:c,runtime:u,activePersistentAnimations:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,saveSlots:I=[],visualLayer:b})=>{let{elements:x,animations:v}=e;if(r.visual&&o){let k=x.find(P=>P.id==="story");if(!k)return e;let S=r.visual.items,C=n?.visual?.items||[],N=qe({variables:s,imageGallery:i,musicRoom:l,sceneReplay:c,runtime:u,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&&fl(b,"visualLayer");for(let P of S){let T=C.find(oe=>oe.id===P.id),V=ry(P,T);if(b!==void 0&&V!==b)continue;if(Dm(P),P.text){let oe=St(o,P),me={...structuredClone(P.text),id:`visual-${P.id}`,type:"text",...rr(oe,P)};Object.assign(me,Qr(P)),k.children.push(nr(tr(me,N),o))}if(P.resourceId){let{images:oe={},videos:me={},spritesheets:Ae={}}=o,ye=Ae[P.resourceId];if(ye){let re=St(o,P),ce=Qr(P),se=Co({id:`visual-${P.id}`,resourceId:P.resourceId,spritesheet:ye,animationName:P.animationName,animationSpeed:P.animationSpeed,loop:P.loop,width:P.width,height:P.height,transform:{...rr(re,P),alpha:ce.alpha??P.alpha??1,...ce.blur?{blur:ce.blur}:{}}});se&&k.children.push(structuredClone(se))}else{let re=oe[P.resourceId]||me[P.resourceId];if(re){let ce=me[P.resourceId]!==void 0,se=St(o,P),ie={id:`visual-${P.id}`,type:ce?"video":"sprite",src:re.fileId,width:re.width,height:re.height,...rr(se,P)};Object.assign(ie,Qr(P)),ce&&(ie.loop=re.loop??!1,ie.volume=re.volume??50),k.children.push(ie)}}}let le=!!(o.spritesheets?.[P.resourceId]||o.images?.[P.resourceId]||o.videos?.[P.resourceId]);if(P.resourceId&&!le){let oe=o.particles?.[P.resourceId];oe&&k.children.push(Nm({item:P,particle:oe,resources:o}))}let G=!!o.particles?.[P.resourceId];if(P.resourceId&&!le&&!G){let{layouts:oe={}}=o,me=oe[P.resourceId];if(me){let Ae=St(o,P),ye={id:`visual-${P.id}`,type:"container",children:structuredClone(me.elements),...rr(Ae,P)};Object.assign(ye,Qr(P));let re=tr(ye,N);k.children.push(nr(wr(re,{isLineCompleted:a,skipMode:d,skipTransitionsAndAnimations:t}),o))}}let ee=za(T),Pe=za(P),Fe=sr({animationsDef:P.animations,resources:o,previousResourceId:ee,currentResourceId:Pe,previousTargetId:ee?`visual-${P.id}`:void 0,currentTargetId:Pe?`visual-${P.id}`:void 0,animationPath:`visual.items[${P.id}].animations`,idPrefix:P.id});ze({animationInstances:Fe,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:p})&&v.push(...Fe)}}return e},Jr="dialogue-character-sprite",ny=(e,{presentationState:r,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:i}=e,l=Lr(e.elements);if(!l)return e;let c=r.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=yt(c),m=yt(u),d=sr({animationsDef:c?.animations,resources:o,previousResourceId:m?Jr:void 0,currentResourceId:p?Jr:void 0,previousTargetId:m?Jr:void 0,currentTargetId:p?Jr:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&ze({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...d),e;let f=o.transforms?.[c.transformId];if(!f)return console.warn("Transform not found:",c.transformId),e;let y={type:"container",id:Jr,...rr(f),children:[]};for(let g of c.items){let h=nl({id:`${Jr}-${g.id}`,item:g,resources:o});h&&y.children.push(h)}return l.children.push(y),ze({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...d),e},sy=(e,{presentationState:r,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:I,activePersistentAnimations:b,saveSlots:x=[]})=>{let{elements:v,animations:k}=e;if(!r.dialogue||a)return e;let S=v.find(N=>N.id==="story");if(!S)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},V=qe({variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:I,saveSlots:x,dialogueState:r.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),le=tr(T,V),G=nr(wr(le?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(G))for(let ee of G)S.children.push(ee);else G&&S.children.push(G)}}ny(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let C=sr({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 ze({animationInstances:C,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&k.push(...C),e},oy=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,activePersistentAnimations:I,saveSlots:b=[]})=>{let{elements:x,animations:v}=e;if(r.choice&&o){let k=Lr(x);if(!k)return e;let S=o?.layouts?.[r.choice.resourceId];if(S&&S.elements){let N={elements:S.elements},P=tr(N,{...qe({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,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=Po(nr(wr(P?.elements,{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(T))for(let V of T)k.children.push(V);else T&&k.children.push(T)}let C=sr({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"});ze({animationInstances:C,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:I})&&v.push(...C)}return e},iy=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,activePersistentAnimations:h,saveSlots:I=[],form:b})=>{let{elements:x,animations:v}=e;if(!b?.resourceId||!o)return e;let k=Lr(x);if(!k)return e;let S=o?.layouts?.[b.resourceId];if(!S)return console.warn(`Form layout not found: ${b.resourceId}`),e;let C={id:"form-container",type:"container",x:0,y:0,children:S.elements||[]},N={...qe({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,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=tr(C,N),T=Eo(nr(wr(xo(P,b),{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o),b);T&&k.children.push(T);let V=sr({animationsDef:b.animations,resources:o,previousResourceId:n?.form?.resourceId,currentResourceId:b.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:b.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return ze({animationInstances:V,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&v.push(...V),e},ay=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,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=Jm(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=Lr(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(dl({container:x,resources:n,templateData:qe({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},ly=(e,{presentationState:r,resources:n,runtime:o,variables:a,musicRoomPlayer:t})=>{let{elements:s,audio:i}=e;if(r.bgm&&n){if(!Lr(s))return e;let c=r.bgm,u=!Array.isArray(c.sounds),p=u?c.resourceId?[{id:"default",resourceId:c.resourceId,loop:c.loop??!0,volume:c.volume,startDelayMs:c.startDelayMs??0}]:[]:c.sounds,m=!u&&c.loop===!0,d=[];if(u||In(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(Pn({id:Rt("bgm",u?"default":y.id),sound:h,resource:g,defaultLoop:!m}))}),d.length===0)return e;let f=qe({variables:a,runtime:o}).runtime;i.push(kn({id:Mm,volume:An(f,"musicVolume",u?Ir:c.volume??Ir),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,playback:t?.bgmPlayback,interruption:c.interruption,children:d,runtime:f}))}return e},cy=(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(u=>u.id===a.trackId),i=s?r.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=qe({variables:o,runtime:n}).runtime,c=Pn({id:Vm,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i});return e.audio.push(kn({id:qm,volume:An(l,"musicVolume",Ir),children:[c],runtime:l})),e},uy=(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||In(i,"SFX channel"),i.forEach(l=>{let c=!s&&l.loop===!0,u=[];if(s||In(l.sounds,"SFX sound",`SFX channel "${l.id}"`),c){let p=l.sounds.find(m=>m.loop===!0);if(p)throw new Error(`SFX sound "${p.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((p,m)=>{let d=n.sounds?.[p.resourceId];if(!d)return;let f=c?{...p,loop:p.loop??!1}:p;u.push(Pn({id:s?Rt("sfx","default",m,p.id):Rt("sfx",l.id,p.id),sound:f,resource:d,defaultLoop:c?!1:void 0}))}),u.length!==0&&a.push(kn({id:Rt("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:u,runtime:o}))})}return e},py=(e,r,n)=>{if(!(!r||!n))return e?.voices?.[r]?.[n]},dy=(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),c=l?i.resourceId?[{id:"default",resourceId:i.resourceId,loop:i.loop??!1,volume:Ir,startDelayMs:i.startDelayMs??0}]:[]:i.sounds,u=!l&&i.loop===!0,p=[];if(l||In(c,"Voice sound"),u){let d=c.find(f=>f.loop===!0);if(d)throw new Error(`Voice sound "${d.id}" cannot loop inside a looping Voice channel.`)}if(c.forEach(d=>{let f=py(n,o,d.resourceId);if(!f)return;let y=u?{...d,loop:d.loop??!1}:d;p.push(Pn({id:Rt("voice",o,l?"default":d.id),sound:y,resource:f,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let m=qe({variables:t,runtime:a}).runtime;return s.push(kn({id:Fm,volume:l?i.volume??cl(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},fy=(e,{presentationState:r,previousPresentationState:n,resources:o={},variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:I})=>{let{elements:b,animations:x}=e;if(r.layout){let C=Lr(b);if(!C)return e;let N=o.layouts?.[r.layout.resourceId];if(!N)return e;Array.isArray(N.transitions)&&!g&&!h&&Oo({animations:x,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(dl({container:P,resources:o,templateData:qe({variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:o.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:h}))}let v=n?.layout?.resourceId,k=r.layout?.resourceId,S=sr({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 ze({animationInstances:S,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:I})&&x.push(...S),e},my=(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 c=n!=null,u=sr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return ze({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...u),e},yy=(e,{presentationState:r})=>{let n=Lr(e.elements);return!n||!r?.screen||Object.assign(n,al(r.screen)),e},hy=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:y=[],saveSlots:g=[],screen:h,isLineCompleted:I,skipTransitionsAndAnimations:b})=>{let{elements:x,animations:v}=e;return f&&f.length>0&&f.forEach((k,S)=>{let C=n.layouts?.[k.resourceId];if(!C){console.warn(`Overlay layout not found: ${k.resourceId}`);return}Array.isArray(C.transitions)&&(b||Oo({animations:v,transitions:C.transitions,defaultTargetId:`overlayStack-${S}`,idPrefix:`overlayStack-${S}`,animationPathPrefix:`overlayStack[${S}]`}));let N={id:`overlayStack-${S}`,type:"container",x:0,y:0,children:[ul({id:`overlayStack-${S}-blocker`,screen:h}),...C.elements||[]]},P=pl(y,n.characters,o),T=qe({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:r?.dialogue,isLineCompleted:I,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:P,characters:n.characters||{},skipTransitionsAndAnimations:b}),V=tr(N,T),[le,...G]=V.children||[],ee=nr(wr({...V,children:G},{isLineCompleted:I,skipMode:c,skipTransitionsAndAnimations:b}),n);x.push({...ee,children:le?[le,...ee.children||[]]:ee.children})}),e},gy=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,dialogueHistory:g=[],screen:h,isLineCompleted:I,skipTransitionsAndAnimations:b})=>{let{elements:x,animations:v}=e;if(!y?.resourceId)return e;let k=n.layouts?.[y.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${y.resourceId}`),e;Array.isArray(k.transitions)&&!b&&Oo({animations:v,transitions:k.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let S={id:"confirmDialog",type:"container",x:0,y:0,children:[ul({id:"confirmDialog-blocker",screen:h}),...k.elements||[]]},C=pl(g,n.characters,o),N=tr(S,qe({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:r?.dialogue,isLineCompleted:I,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,historyDialogue:C,characters:n.characters||{},skipTransitionsAndAnimations:b})),[P,...T]=N.children||[],V=nr(wr({...N,children:T},{isLineCompleted:I,skipMode:u,skipTransitionsAndAnimations:b}),n);return x.push({...V,children:P?[P,...V.children||[]]:V.children}),e},$t=e=>(r,n)=>ty(r,{...n,visualLayer:e}),by=$t(er.BEHIND_BACKGROUND),Iy=$t(er.BEHIND_CHARACTER),wy=$t(er.BEHIND_DIALOGUE),vy=$t(er.BEHIND_CHOICE),Ay=$t(er.FOREGROUND),ml=e=>cn(Qm,[ay,by,Zm,Iy,ey,wy,sy,vy,oy,iy,fy,Ay,yy,my,ly,cy,uy,dy,hy,gy])(e);function yl(e,r=""){let n=[],o=e.length,a=0,t=0,s=-1,i=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,r?parseInt(r[t++],36):0])}return n}function hl(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 gl="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",bl="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Il="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var wl=65535,No=40960,xn=126976,kl=new Uint8Array(12288),Pl=new Uint8Array(3072),xl=new Uint8Array(2816),El,Sl;{let e=(a,t,s,i,l)=>{let c=t+a.length-1;for(let u=s<t?t:s,p=i>c?c:i;u<=p;u++)a[u-t]=l},r=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,t,s]of yl(gl,bl))e(kl,0,a,t,s),e(Pl,No,a,t,s),e(xl,xn,a,t,s),t>=65040&&!(a>=xn&&t<=129791)&&(r[o]=a,n[o++]=t<<5|s);El=r.slice(0,o),Sl=n.slice(0,o)}function vl(e){return e<12288?kl[e]:e<No?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?Pl[e-No]: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>=xn&&e<129792?xl[e-xn]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:hl(e,El,Sl)}var Rl=Uint8Array.from(Il,Number);function ky(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||ky(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*Ol(e){let r=e.length;if(r===0)return;let n=e.codePointAt(0),o=n>wl?2:1,a=vl(n),t=50200>>a&1?Al(0,a,n):0,s=0,i=n,l=a;for(;o<r;){n=e.codePointAt(o);let c=n>wl?2:1,u=vl(n),p=Rl[a<<4|u],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>>u&1&&(t!==0||u!==3)?Al(t,u,n):0,m&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=o,i=n,l=u),o+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Cl(e){for(let r of Ol(e))yield r.segment}{let e=Ol("_");Rl._keep=[e,e.next()]}var $l=1e3,Dl=50,Py=0,_l=100,jl=50,xy=60,Ey=3,Sy=.5,Ry=2e4,Oy=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Cy=/^\s+$/u,Nl,$y=e=>{let r=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Cl(r)):(Nl??=new n(void 0,{granularity:"grapheme"}),Array.from(Nl.segment(r),({segment:o})=>o))},_y=e=>$y(e).reduce((r,n)=>Cy.test(n)?r+Sy:Oy.test(n)?r+Ey:r+1,0),jy=e=>2**(((Number.isFinite(e)?Math.min(_l,Math.max(Py,e)):Dl)-jl)/(_l-jl)),Ll=({text:e="",baseDelay:r=$l,speed:n=Dl}={})=>{let o=Number.isFinite(r)?Math.max(0,r):$l,a=jy(n),t=_y(e)*xy/a,s=Math.max(o,Ry);return Math.min(o+t,s)};var En={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Ul=1,Yo=1,rt="choice",Ar="form",Dt=()=>({manual:{...En.manual},auto:{...En.auto},applyMode:En.applyMode}),zo=()=>({groupId:null,variantId:null,pageIndex:0}),Ny="music-room:player",Dy=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),On=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Go=new Set,Ly=new Set(["groupId","variantId"]),Ty=new Set(["pageIndex"]),tt=new Set,My=new Set(["trackId"]),qy=new Set(["positionMs"]),Vy=new Set(["pageIndex"]),Ho=new Set,Fy=new Set(["sceneId"]),Uy=new Set(["pageIndex"]),Xo=()=>({pageIndex:0}),Wo=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...Dt()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},Do=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},D=e=>{let r=he(e)?dr(e):e;return structuredClone(r)},L=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Cn=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},Bl=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},Lt=(e,r,n)=>({commandId:Cn(e),operation:r,...n===void 0?{}:{positionMs:n}}),Ko=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let r=e.global.musicRoomPlayer,n=r.bgmPlayback;r.trackId!==null&&(n={commandId:Cn(e),operation:"resume"}),e.global.musicRoomPlayer=On({bgmPlayback:n})},Yl=(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},zl=(e,r)=>{if(e==null||e==="")throw new Error(`${r} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${r} requires a non-empty string or finite number slotId`)},nt=e=>String(e),Gl=()=>({sections:[],resources:[]}),Hl=()=>({sceneIds:[]}),By=e=>L(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Gl(),Yy=e=>L(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Hl(),zy=e=>Array.isArray(e)?e.map(r=>r?.text??"").join(""):"",Gy=({sectionId:e,lineId:r,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:r,content:n,text:zy(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),Xl=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),Hy=e=>L(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,Jo=e=>{if(!L(e?.dialogueHistory))return null;let r=e.dialogueHistory;return!Array.isArray(r.entries)||!Number.isInteger(r.currentLength)||!Array.isArray(r.checkpointLengths)?null:r},Xy=e=>{if(!L(e?.dialogueHistory))return e.dialogueHistory=Xl(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},Qo=e=>{let r=Jo(e);return r?(r.currentLength<r.entries.length&&(r.entries=r.entries.slice(0,r.currentLength)),r):null},Wy=()=>({resourceId:void 0}),Ky=e=>{if(!L(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},or=(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}},Wl=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)}}},Kl=e=>e,Jl=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Ul)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},Jy=(e,r={})=>{let n;try{n=Jl(r.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...r,formatVersion:n,slotId:Kl(r.slotId??r.slotKey??e),savedAt:typeof r.savedAt=="number"?r.savedAt:r.date};return delete o.slotKey,delete o.date,o},Qy=(e={})=>Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Jy(r,n)])),Zy=(e,r)=>{if(!L(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!L(o))return!1;let{variableId:a,op:t,value:s,roundTo:i}=o,l=r?.resources?.variables?.[a];if(!l||$e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return kt(l.type,t,a),dn(l.type,t,s,a,{roundTo:i}),t!=="set"||eo(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},Ql=(e,r)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!L(o)||!qb(o.type))return[];if(o.type!=="updateVariable"||r===void 0)return[o];let a=Zy(o.payload,r);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},eh=(e,r)=>{!L(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=Yo,e.timeline.forEach(n=>{if(!L(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=Ql(n.executedActions,r);if(o){n.executedActions=o;return}delete n.executedActions}))},Tl=(e,r,n,o="viewedRegistry")=>{let a=r==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!L(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}},rh=(e,r="viewedRegistry")=>{if(e===void 0)return Gl();if(!L(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=Tl(a,"sections",t,r);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,t)=>{let s=Tl(a,"resources",t,r);return[s.resourceId,s]})))}},th=(e,r="accountReplayRegistry")=>{if(e===void 0)return Hl();if(!L(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}))]}},_t=(e,r,n)=>{if(!L(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}=or(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}},Zl=e=>{let r=e.story.initialSceneId,n=e.story.scenes[r],o=n.initialSectionId,a=n.sections[o];return _t({sceneId:r,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},nh=e=>{try{return Zl(e),!0}catch{return!1}},sh=(e,r,n)=>{let o=e?.pointers?.read;if(!L(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return _t(o,r,n);try{return _t(o,r,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],t=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=t;s>=0;s-=1)try{return _t(a[s],r,`${n} compatibility checkpoint`)}catch{}return Zl(r)}},ec=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,Zo=(e,r)=>{let{section:n}=or(e,r?.sectionId);return n?.lines?.find(o=>o.id===r?.lineId)},oh=(e,r,n)=>{if(!L(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],t=!1;if(e.entries.forEach((i,l)=>{if(!L(i))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:c}=or(r,i.sectionId);if(!c?.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}},ih=(e,r)=>L(Zo(e,r)?.actions?.dialogue),rc=(e,r,n)=>{if(!r||r.sectionId!==n.sectionId)return!1;let{section:o}=or(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=>L(s.actions?.dialogue))?.id===r.lineId},ah=(e,r)=>{let n=Xl();return e.timeline.forEach(o=>{if(o.returnable!==!1&&ih(r,o)){let a=Zo(r,o),t=n.entries.at(-1),s=a.actions.dialogue.append===!0&&rc(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},lh=(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},ch=(e,r)=>{let{section:n}=or(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},tc=(e,r,n)=>{if(typeof r?.sectionId!="string")return!1;let{section:o}=or(e,r.sectionId);return ec({sectionId:r.sectionId,lineId:o?.lines?.[0]?.id},n)},uh=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),et={always:"always",maybe:"maybe",never:"never"},ph=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return et.always;let r=e.when,n;if(r===null||typeof r=="boolean"||typeof r=="number")n=r;else if(L(r)&&Object.keys(r).length===1&&Object.prototype.hasOwnProperty.call(r,"literal"))n=r.literal;else return et.maybe;return n?et.always:et.never},nc=(e,r)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let o=ph(n);if(o!==et.never){if(r(n))return!0;if(o===et.always)return!1}}return!1},sc=e=>nc(e,r=>Object.entries(r?.actions??{}).some(([n,o])=>n==="conditional"?sc(o):uh.has(n))),oc=(e,r,n)=>nc(r,o=>Object.entries(o?.actions??{}).some(([a,t])=>a==="sectionTransition"?tc(e,t,n):a==="conditional"?oc(e,t,n):!1)),dh=(e,r,n)=>{if(!r)return!0;let o=Zo(n,e)?.actions;if(!L(o))return!0;if(tc(n,o.sectionTransition,r))return!1;let a=o.conditional;return a?!(oc(n,a,r)||!(o.choice?.resourceId||o.form?.resourceId)&&!sc(a)&&ec(ch(n,e),r)):!0},fh=(e,r,n)=>{if(!L(e)||!Array.isArray(e.timeline))return{rollback:Nt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=new WeakSet,a=[],t=e.timeline.flatMap((p,m)=>{if(!L(p))return[];try{let d=_t(p,n,`rollback.timeline[${m}]`),f=Rn({sectionId:d.sectionId,lineId:d.lineId,rollbackPolicy:p.rollbackPolicy,returnable:p.returnable});typeof p.returnable=="boolean"&&o.add(f);let y=Ql(D(p.executedActions),n);return y&&(f.executedActions=y),a.push(m),[f]}catch{return[]}});if(t.length===0)return{rollback:Nt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};e.returnabilityVersion!==Yo&&t.forEach((p,m)=>{!o.has(p)&&!dh(p,t[m+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 c=t[l];if(c?.sectionId!==r.sectionId||c?.lineId!==r.lineId){let p=t.findLastIndex(m=>m.sectionId===r.sectionId&&m.lineId===r.lineId);p>=0?l=p:(t.push(Rn({sectionId:r.sectionId,lineId:r.lineId})),a.push(null),l=t.length-1)}let u=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),l):0;return{rollback:{currentIndex:l,isRestoring:!1,replayStartIndex:u,timeline:t},sourceCheckpointIndexes:a,sourceTimelineLength:e.timeline.length}},ic=(e,r,n)=>{if(!L(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=ri(r),a=sh(e,r,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!L(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!L(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let t=e.variables?wt(D(e.variables),r.resources?.variables??{},{allowedScopes:["context"]}):{},s=Eh({loadedContextRuntime:L(e.runtime)?D(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=fh(e.rollback,a,r),u=e.dialogueHistory===void 0?ah(i,r):lh(oh(e.dialogueHistory,r,`contexts[${n}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:L(e.configuration)?D(e.configuration):{},views:Array.isArray(e.views)?D(e.views):[],bgm:L(e.bgm)?D(e.bgm):{resourceId:void 0},variables:{...o,...t},...u?{dialogueHistory:u}:{},rollback:i};return s&&(p.runtime=s),p},mh=(e,r)=>{if(!L(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((n,o)=>ic(n,r,o))}},yh=(e,r)=>{if(!L(e))throw new Error("Malformed save slot.");let n=Jl(e.formatVersion);return{...e,formatVersion:n,state:mh(e.state,r)}},Ml=(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}},hh=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:Ml(e.confirmActions,"confirmActions",{required:!0}),cancelActions:Ml(e.cancelActions,"cancelActions")}},st=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},gh=e=>(L(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),ot=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},ac=e=>{if(!(!L(e)||!e.animations))return{animations:D(e.animations)}},bh=(e,r)=>{let n=ac(r);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Ih=e=>{let r=e?.id??e?.resourceId;return typeof r=="string"&&r.length>0?r:void 0},wh=(e,r)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!r))return`${n}:${o}:${r}`},Sn=e=>String(e??""),lc=(e,r)=>{let n=Sn(r);return e?.trim===!0?n.trim():n},vh=e=>L(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,r])=>L(r)).map(([r,n])=>[r,{id:r,...D(n)}])):{},Ah=(e,r)=>{if(!r||!L(e.global.formDrafts))return;let n=e.global.formDrafts[r];return L(n)?n:void 0},cc=(e,r)=>{let n=gh(e);L(n[r])||(n[r]={values:{},touched:{},errors:{},submitted:!1});let o=n[r];return L(o.values)||(o.values={}),L(o.touched)||(o.touched={}),L(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},ei=(e,r)=>{let n=lc(e,r);return e?.required===!0&&n.length===0?"required":null},kh=({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?{}:jr(o.slice(0,a+1).map(t=>t.actions||{}))},Ph=({state:e,form:r,pointer:n})=>{if(!r?.resourceId)return null;let o=Ih(r),a=wh(n,o);if(!o||!a)return null;let t=Ah(e,a),s=vh(r),i=$n({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=Sn(i?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(t?.values??{},m)?Sn(t.values[m]):f,g=t?.touched?.[m]===!0,h=ei(d,y),I=t?.submitted||g?h:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,x={id:m,variableId:d.variableId,value:y,initialValue:f,valid:!h,error:I,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[m]=x,c.push(x),u[m]=y}),{id:o,key:a,resourceId:r.resourceId,animations:r.animations,valid:p,submitted:t?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:D(r.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:D(r.cancelActions??{})}}}},ql="line",vr="interaction",Rn=({sectionId:e,lineId:r,rollbackPolicy:n,returnable:o})=>({sectionId:e,lineId:r,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{}}),ri=e=>{let r=he(e)?dr(e):e,{contextVariableDefaultValues:n}=pn(r??{});return D(n)},uc=()=>({...D(xt)}),pc=({loadedRuntime:e,runtimeIds:r,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:D(n),hasLoadedValues:!1};if(!L(e))throw new Error(`Malformed ${o}.`);let a=D(n),t=!1;return r.forEach(s=>{e[s]!==void 0&&(a[s]=mn(s,D(e[s])),t=!0)}),{runtimeState:a,hasLoadedValues:t}},xh=({projectData:e,loadedGlobalRuntime:r={}})=>pc({loadedRuntime:r,runtimeIds:io,defaults:lo(e),path:"global.runtime"}).runtimeState,Eh=({loadedContextRuntime:e={}})=>{let{runtimeState:r,hasLoadedValues:n}=pc({loadedRuntime:e,runtimeIds:ao,defaults:uc(),path:"context.runtime"});return n?r:void 0},qr=e=>{let r=Array.isArray(e?.contexts)?e.contexts:[];return r[r.length-1]},ne=e=>{let r=qr(e);return r?.kind==="sceneReplay"&&L(r.sceneReplay)?r:null},dc=(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)})},Sh=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)}}),Rh=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=Dt(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Oh=(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=ve({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e.global.skipMode&&!n&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!n&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Ch=e=>e.runtime?(ao.forEach(r=>{e.runtime[r]===void 0&&(e.runtime[r]=D(xt[r]))}),e.runtime):(e.runtime=uc(),e.runtime),$h=e=>Ma(e.global),fc=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:$h(e)}})},ti=(e,r,n)=>{let o=mn(r,n);if(r in xt){let a=qr(e);if(!a)return o;let t=Ch(a);return t[r]=o,o}return e.global[r]=o,o},ni=({pointer:e,projectData:r,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:D(o)},currentPointerMode:"read",pointers:{read:D(e)},configuration:{},views:[],bgm:Wy(),variables:ri(r),rollback:Nt({pointer:e})}),it=e=>e?(e.currentPointerMode="read",L(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,_h=(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=ni({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,jh(e,{queueRender:r}),a},jh=(e,{queueRender:r=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,st(e),ot(e),e.global.nextLineConfig=Dt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Ko(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),r&&e.global.pendingEffects.push({name:"render"})},mc=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},Nt=({pointer:e,replayStartIndex:r=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:r,timeline:n?[Rn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Pr=(e,r={})=>{if(e?.rollback)return mc(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=Nt({pointer:n,replayStartIndex:r.compatibilityAnchor?1:0}),e.rollback},si=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=Pr(n);if(o.isRestoring)return;let a=Qo(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(Rn(r)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},Nh=({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}},Dh=({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)?Jt(l):l)!==o||l?.sectionId!==a||l?.lineId!==t||(l.returnable=!1),e},Lh=({state:e},r={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:t,lineId:s}=r,i=nt(n),l=e.global.saveSlots?.[i],c=he(l)?Jt(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==t||p?.pointers?.read?.lineId!==s||d?.sectionId!==t||d?.lineId!==s||(d.returnable=!1,m.returnabilityVersion=Yo,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Th=(e,r)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let a=r?.at(-1),t=typeof a?.checkpointIndex=="number"?a.checkpointIndex:o.currentIndex;if(t<0||t>=o.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&t<o.timeline.length-1){o.timeline=o.timeline.slice(0,t+1);let s=Qo(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,t+1))}return o.timeline[t]??null},Mh=({state:e,rollbackActionBatchStack:r},n={})=>{let o=n?.source===ql?ql:vr,a=e.contexts?.[e.contexts.length-1],t=a?.rollback;if(!t||t.isRestoring||!Array.isArray(t.timeline)||typeof t.currentIndex!="number"||t.currentIndex<0||t.currentIndex>=t.timeline.length)return r.push({checkpointIndex:null,source:o}),e;if(t.currentIndex<t.timeline.length-1){t.timeline=t.timeline.slice(0,t.currentIndex+1);let s=Qo(a);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,t.currentIndex+1))}return r.push({checkpointIndex:t.currentIndex,source:o}),e},qh=({state:e,rollbackActionBatchStack:r})=>(r.pop(),e),We=(e,r,n,o)=>{let t=o?.at(-1)?.source??vr;if(!Vb(r,t))return;let s=Th(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:r,payload:D(n)}))},Vl=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=r?.operations??[];for(let{variableId:a,op:t,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if($e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);At(c,a),kt(u,t,a),dn(u,t,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=fn(n.variables[a],t,s,{roundTo:i}))}},Vh=(e,r)=>{Array.isArray(r?.executedActions)&&r.executedActions.forEach(({type:n,payload:o})=>{Fb(e,n,o)})},Fh=(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])=>{Xc(e,i,l)})},yc=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=Pr(n),a=o.timeline[r];if(!a)return e;e.global.autoMode&&Vt({state:e}),e.global.skipMode&&kr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=r;try{n.variables=ri(e.projectData),n.kind==="sceneReplay"&&(dc(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(En),e.global.overlayStack=[],st(e),ot(e),e.global.isLineCompleted=!0;let t=o.replayStartIndex??0;for(let l=t;l<=r;l++)l>t&&Wo(e),Fh(e,o.timeline[l]),Vh(e,o.timeline[l]);let s=it(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=Jo(n);i&&(i.currentLength=Math.min(i.checkpointLengths[r]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=Bl(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},Uh=e=>{let{projectData:r}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:t={},runtime:s={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;Wl(r),gt(r),bt(r),It(r),_r(r?.resources?.variables??{});let u=r.story.initialSceneId,p=r.story.scenes[u],m=p.initialSectionId,d=p.sections[m],f={sceneId:u,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:y}=pn(r),g={...y,...wt(t,r.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:r,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:rh(i,"accountViewedRegistry"),accountReplayRegistry:th(l),nextLineConfig:Dt(),imageGalleryNavigation:zo(),sceneReplayNavigation:Xo(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:On(),saveSlots:Qy(a),localizationPackages:D(c),overlayStack:[],variables:g,...xh({projectData:r,loadedGlobalRuntime:s})},contexts:[ni({pointer:f,projectData:r})]}},Bh=({state:e})=>e.global.overlayStack||[],Yh=({state:e})=>e.global.pendingEffects,hc=({state:e})=>e.global.skipMode,zh=({state:e})=>e.global.autoMode,gc=({state:e})=>e.global.dialogueUIHidden,bc=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(!n)return[];let o,a=L(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)o=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=n.pointers.read,p=be({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let m=p.lines.findIndex(d=>d.id===u);o=p.lines.slice(0,m+1).map(d=>({sectionId:c,lineId:d.id}))}let t=[],s=vt({variables:{...e.global?.variables??{},...qr(e)?.variables??{}},runtime:Nr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let m=be({state:e},{sectionId:c.sectionId}),d=Array.isArray(m?.lines)?m.lines:[];u={lines:d,lineIndexes:new Map(d.map((f,y)=>[f.id,y])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let m=u.lines[u.nextLineIndex],d=m.actions||{};u.presentationState=jr([u.presentationState,d]),u.projections.set(m.id,{line:m,lineActions:d,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!Hy(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:m,dialogueState:d}=u;if(!m.dialogue)continue;let f=un({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:s}),y=Gy({sectionId:c.sectionId,lineId:p.id,content:m.dialogue.append===!0?d.content:m.dialogue.content,dialogueState:d,characterName:f}),g=t[t.length-1];if((a?c.appendToPrevious===!0:m.dialogue.append===!0)&&g?.sectionId===c.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},Gh=(e,r,n)=>{let o=!1;for(let a of r??[]){let{slotId:t,saveSlotIdentity:s,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[nt(t)],u=he(c)?Jt(c):c,p=c?.state?.contexts?.at(-1);!c||u!==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}}})},Hh=({state:e},r={})=>{let n=qr(e),o=n?.pointers?.read,a=Mt({state:e});if(!n||!L(a?.actions?.dialogue))return e;let t=Pr(n),s=t.timeline?.[t.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=Jo(n),c=l?.checkpointLengths?.[t.currentIndex],u=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&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let m=Xy(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&r.appendToPrevious===!0&&rc(e.projectData,p,o);if(m.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,i){for(;m.checkpointLengths.length<t.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[t.currentIndex]=m.currentLength}return Gh(e,r.savedCheckpointOccurrences,m),e},Xh=({state:e})=>e.global.confirmDialog??null,Tt=({state:e},{pointer:r}={})=>{let n=r??_e({state:e})?.pointer,o=kh({state:e,pointer:n});return Ph({state:e,form:o.form,pointer:n})},Wh=({state:e},{pointer:r}={})=>!!Tt({state:e},{pointer:r}),ve=({state:e},{pointer:r}={})=>{let n=Tt({state:e},{pointer:r});if(n)return{source:Ar,formId:n.id,formKey:n.key};let o=Pc({state:e,pointer:r});return o?{source:rt,resourceId:o}:null},Kh=({state:e,registry:r},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(r?.sections)?r.sections:[]).find(u=>u.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(u=>u.id===s.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},oi=({registry:e},r)=>{let{resourceId:n}=r;return!!(Array.isArray(e?.resources)?e.resources:[]).find(t=>t.resourceId===n)},ii=({state:e},r)=>Kh({state:e,registry:e.global.accountViewedRegistry},r),Jh=({state:e},r)=>oi({registry:e.global.accountViewedRegistry},r),jt=(e,r)=>!oi({registry:e.global.accountViewedRegistry},{resourceId:r.imageId}),ai=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),li=(e,r)=>{let n=ai(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Lo=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!jt(e,r[a]))return r[a]},Qh=({state:e})=>{let r=e.projectData?.resources?.imageGallery;return r===void 0?void 0:D(r)},Ic=({state:e})=>{let r=e.projectData?.resources?.imageGallery;if(r===void 0)return null;let n=e.global.imageGalleryNavigation??zo(),o=ai(r),a=li(r,n),t=a*r.pageSize,s=r.groups.slice(t,t+r.pageSize).map(l=>({groupId:l.id,locked:jt(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:jt(e,c)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=r.groups.findIndex(d=>d.id===n.groupId),c=r.groups[l],u=c?.variants.findIndex(d=>d.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/r.pageSize);p&&m===a&&!jt(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:Lo(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:Lo(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},ci=(e,r)=>!oi({registry:e.global.accountViewedRegistry},{resourceId:r.soundId}),ui=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),pi=(e,r)=>{let n=ui(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},To=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!ci(e,r[a]))return r[a]},wc=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}),Zh=(e,r)=>({...wc(r),locked:ci(e,r)}),Fl=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")}`},eg=({state:e})=>{let r=e.projectData?.resources?.musicRoom;return r===void 0?void 0:D(r)},vc=({state:e})=>{let r=e.projectData?.resources?.musicRoom;if(r===void 0)return null;let n=e.global.musicRoomPlayer??On(),o=ui(r),a=pi(r,n),t=a*r.pageSize,s=r.tracks.slice(t,t+r.pageSize).map(u=>Zh(e,u)),i=r.tracks.findIndex(u=>u.id===n.trackId),l=r.tracks[i],c=l?{...wc(l),canPlayPreviousTrack:To(e,r.tracks,i,-1)!==void 0,canPlayNextTrack:To(e,r.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Fl(n.positionMs),durationText:n.durationMs===null?null:Fl(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}}},di=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),fi=(e,r)=>{let n=di(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},rg=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;return r===void 0?void 0:D(r)},tg=({state:e})=>ne(e)!==null,ng=({state:e})=>{let r=ne(e);return r?{sceneId:r.sceneReplay.sceneId,entryId:r.sceneReplay.entryId}:null},Ac=(e,r)=>e.global.accountReplayRegistry?.sceneIds?.includes(r)===!0,kc=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;if(r===void 0)return null;let n=e.global.sceneReplayNavigation??Xo(),o=di(r),a=fi(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:!Ac(e,l.sceneId)})),i=ne(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},sg=({state:e})=>e.global.nextLineConfig,Pc=({state:e,pointer:r}={})=>{let n=r??_e({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=be({state:e},{sectionId:o})?.lines||[],i=s.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of s.slice(0,i+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},xc=({state:e})=>!!Pc({state:e}),og=({state:e})=>structuredClone(e),ig=({state:e})=>D(e.projectData.resources?.achievements??{}),ag=({state:e},r)=>{let n=e.projectData.resources?.achievements?.[r?.resourceId];return n===void 0?void 0:D(n)},Ec=({state:e})=>e.global.saveSlots,lg=({state:e},r)=>{let n=r?.slotId,o=nt(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Sc=({state:e})=>D(e.global.localizationPackages),mi=({state:e})=>Nr(e),cg=({state:e},r)=>br(e,r?.runtimeId),$n=({state:e})=>{let r={...e.global?.variables??{},...qr(e)?.variables??{}};return vt({variables:r,runtime:Nr(e),variableConfigs:e.projectData.resources?.variables??{}})},_e=({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 or(e.projectData,n).section},Mt=({state:e})=>{let r=_e({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)},Rc=({state:e})=>{let{sectionId:r,lineId:n}=_e({state:e}).pointer,a=be({state:e},{sectionId:r})?.lines||[],t=a.findIndex(c=>c.id===n),i=a.slice(0,t+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(m=>{p[m]=u[m]}),p});return jr(i)},ug=e=>{let r=Mt({state:e})?.actions?.dialogue;if(r?.clear===!0||!Array.isArray(r?.content))return"";let n=$n({state:e});return r.content.map(o=>`${Wr(o?.text,{variables:n})??""}`).join("")},ir=({state:e})=>Ll({text:ug(e),baseDelay:br(e,"autoForwardDelay"),speed:br(e,"autoForwardSpeed")}),pg=({state:e})=>{let r=Oc({state:e}),o=Mt({state:e})?.actions??{},a=jr([r??{},o]);return to(r??{},a??{})},dg=({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=jr([a,s]),l=to(a,i);o.push({id:t.id,changes:l,presentationState:i}),a=no(i)}return o},fg=({state:e},{sectionId:r,includePresentationState:n=!1})=>{let o=dg({state:e},{sectionId:r});return n?{lines:o}:{lines:o.map(({presentationState:a,...t})=>t)}},Oc=({state:e})=>{let{sectionId:r,lineId:n}=_e({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 c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return no(jr(i))},yi=({state:e},{slotsPerPage:r=6}={})=>{let a=((mi({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[nt(i)]||{};t.push({...l,slotId:i})}return{saveSlots:t}},mg=Ec,yg=yi,hg=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},gg=({state:e},r={})=>{let n=Rc({state:e}),o=Oc({state:e}),a=Mt({state:e})?.actions??{},t=e.global.pendingScreenTransition,s=t?.animations?{...a,screen:D(t)}:a,i=t?.animations&&o===null?{}:o,{sectionId:l}=_e({state:e}).pointer,{sceneId:c}=or(e.projectData,l),u={...mi({state:e}),localizationPackages:Sc({state:e})},p=r?.activePersistentAnimations??[],m=r?.restoredPersistentAnimations??[],d=Tt({state:e}),f=xc({state:e}),y=Ic({state:e}),g=vc({state:e}),h=kc({state:e}),I=$n({state:e}),{saveSlots:b}=yi({state:e}),x=hg(e);return ml({presentationState:n,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:Jc({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||x,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:bc({state:e}),saveSlots:b,variables:I,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:D(e.global.musicRoomPlayer)})},bg=({state:e},r)=>(e.global.confirmDialog=hh(r),e.global.pendingEffects.push({name:"render"}),e),Ig=({state:e})=>(e.global.confirmDialog&&(st(e),e.global.pendingEffects.push({name:"render"})),e),wg=({state:e,rollbackActionBatchStack:r},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),We(e,"pushOverlay",n,r),e),vg=({state:e,rollbackActionBatchStack:r})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),We(e,"popOverlay",void 0,r),e),Ag=({state:e,rollbackActionBatchStack:r},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),We(e,"replaceLastOverlay",n,r),e),kg=({state:e,rollbackActionBatchStack:r})=>(e.global.overlayStack=[],st(e),ot(e),e.global.pendingEffects.push({name:"render"}),We(e,"clearOverlays",void 0,r),e),Pg=(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"})},qt=(e,r,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,bh(e,n),ot(e);let o=ve({state:e},{pointer:r}),a=o?.source===rt,t=o?.source===Ar;Pg(e,{activeInteraction:o});let s=ne(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=Bl(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}},_n=(e,r,n)=>{!(r?.source===rt||r?.source===Ar)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Cc=({state:e})=>(ve({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),Vt=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),xg=({state:e})=>{let r=e.global.autoMode;return ve({state:e})&&!r||(r?Vt({state:e}):Cc({state:e})),e},$c=({state:e})=>(ve({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),kr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Eg=({state:e})=>{let r=hc({state:e});return ve({state:e})&&!r||(r?kr({state:e}):$c({state:e})),e},jn=({state:e,rollbackActionBatchStack:r})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),We(e,"showDialogueUI",void 0,r),e),_c=({state:e,rollbackActionBatchStack:r})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),We(e,"hideDialogueUI",void 0,r),e),Sg=e=>{let{state:r}=e;return gc({state:r})?jn(e):_c(e),r},xr=(e,r,n)=>(ti(e,r,n),fc(e),e.global.pendingEffects.push({name:"render"}),e),Ft=(e,r,n,o,a)=>{let t=ti(e,r,n);return e.global.pendingEffects.push({name:"render"}),We(e,o,{value:t},a),e},Rg=({state:e},r)=>xr(e,"dialogueTextSpeed",r?.value),Og=({state:e},r)=>(xr(e,"autoForwardDelay",r?.value),e.global.autoMode&&e.global.isLineCompleted&&!ve({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e),Cg=({state:e},r)=>(xr(e,"autoForwardSpeed",r?.value),e.global.autoMode&&e.global.isLineCompleted&&!ve({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e),$g=({state:e},r)=>xr(e,"skipUnseenText",r?.value),_g=({state:e},r)=>xr(e,"skipTransitionsAndAnimations",r?.value),jg=({state:e},r)=>xr(e,"soundVolume",r?.value),Ng=({state:e},r)=>xr(e,"musicVolume",r?.value),Dg=({state:e},r)=>xr(e,"muteAll",r?.value),Mo=({state:e,rollbackActionBatchStack:r},n)=>Ft(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",r),qo=({state:e,rollbackActionBatchStack:r})=>{let n=br(e,"saveLoadPagination")+1;return Ft(e,"saveLoadPagination",n,"incrementSaveLoadPagination",r),e},Vo=({state:e,rollbackActionBatchStack:r})=>{let n=br(e,"saveLoadPagination")-1;return Ft(e,"saveLoadPagination",n,"decrementSaveLoadPagination",r),e},Fo=({state:e,rollbackActionBatchStack:r},n)=>Ft(e,"menuPage",n?.value,"setMenuPage",r),Uo=({state:e,rollbackActionBatchStack:r},n)=>Ft(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",r),Lg=({state:e})=>(e.global.pendingEffects=[],e),Tg=({state:e},r)=>(e.global.pendingEffects.push(r),e),Mg=({state:e},r)=>{if(ne(e))return e;let n=r?.resourceId;return Yl(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},qg=({state:e},r)=>{if(ne(e))return e;let n=r?.resourceId,o=Yl(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},jc=(e,{sectionId:r,resetStoryState:n=!1,screen:o})=>{let a=!!ac(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&&!_h(e,{queueRender:!a}))return e;let i=ve({state:e});n&&e.global.skipMode&&kr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=it(l),p=u.read;n||Mr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Pr(l,{compatibilityAnchor:!0}),u.read={sectionId:r,lineId:s.id},n?l.rollback=Nt({pointer:u.read}):si(e,{sectionId:r,lineId:s.id})}let{activeInteraction:c}=qt(e,l?.pointers?.read,{screenTransition:o});return _n(e,i,c),e},Vg=({state:e},r)=>{if(ne(e))throw new Error("Cannot reset the story while a scene replay is active");return jc(e,{sectionId:r?.sectionId,resetStoryState:!0,screen:r?.screen})},Nc=e=>(e.global.accountViewedRegistry=By(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Nn=(e,r)=>{!Array.isArray(r)||r.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:r.map(n=>({scope:n.scope,path:n.path,op:n.op,value:D(n.value)}))}})},Dc=(e,r)=>{Nn(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:[]}}])},Fg=(e,r,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=L(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(c=>c.id===t.lastLineId),l=s.lines.findIndex(c=>c.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},Mr=(e,r)=>{if(ne(e)||e.global.accountViewedRegistry===void 0)return;Fg(e,Nc(e),r)&&Dc(e,{sections:[{sectionId:r.sectionId,lastLineId:r.lineId}],resources:[]})},Ug=({state:e},r)=>(Mr(e,r),e.global.pendingEffects.push({name:"render"}),e),Bg=({state:e},r)=>{if(ne(e))return e;let{resourceId:n}=r;if(e.global.accountViewedRegistry!==void 0){let o=Nc(e);o.resources.find(t=>t.resourceId===n)||(o.resources.push({resourceId:n}),Dc(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Ke=(e,r,n)=>{if(!L(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}"`)})},Bo=(e,r,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${r}`)},Dn=(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"}))},Yg=({state:e},r)=>{let n="showImageGalleryVariant";Ke(n,r,Ly),Bo(n,"groupId",r.groupId),Object.prototype.hasOwnProperty.call(r,"variantId")&&Bo(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||jt(e,s)||Dn(e,{groupId:t.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},Lc=(e,r,n,o)=>{Ke(o,r,Go);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(c=>c.id===t.groupId),i=s?.variants.findIndex(c=>c.id===t.variantId);if(!s||i===void 0||i<0)return e;let l=Lo(e,s.variants,i,n);return l&&Dn(e,{...t,variantId:l.id}),e},zg=({state:e},r)=>Lc(e,r,-1,"moveToPreviousImageGalleryVariant"),Gg=({state:e},r)=>Lc(e,r,1,"moveToNextImageGalleryVariant"),Hg=({state:e},r)=>{if(Ke("clearImageGallerySelection",r,Go),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return Dn(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},Tc=(e,r)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=ai(n);if(r>=o)return e;let a=e.global.imageGalleryNavigation,t=li(n,a);return r===t||Dn(e,{groupId:null,variantId:null,pageIndex:r}),e},Xg=({state:e},r)=>{if(Ke("moveToImageGalleryPage",r,Ty),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Tc(e,r.pageIndex)},Mc=(e,r,n,o)=>{Ke(o,r,Go);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=li(a,e.global.imageGalleryNavigation)+n;return s<0?e:Tc(e,s)},Wg=({state:e},r)=>Mc(e,r,1,"moveToNextImageGalleryPage"),Kg=({state:e},r)=>Mc(e,r,-1,"moveToPreviousImageGalleryPage"),ar=(e,r,n)=>{if(!L(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}"`)})},Jg=(e,r)=>{if(typeof r!="string"||r.length===0)throw new Error(`${e} requires a non-empty trackId`)},Ge=e=>{e.global.pendingEffects.push({name:"render"})},qc=(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:Cn(e),operation:"pause"});let i=Lt(e,"play",0),l=n.tracks.indexOf(r),c=t?o.durationMs:null;e.global.musicRoomPlayer={trackId:r.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:s},Ge(e)},Qg=({state:e},r)=>{let n="playMusicRoomTrack";ar(n,r,My),Jg(n,r.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(t=>t.id===r.trackId);return!a||ci(e,a)||qc(e,a),e},Zg=({state:e},r)=>{ar("playMusicRoom",r,tt);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=Lt(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,t&&(o.readiness=o.durationMs===null?"loading":"ready"),Ge(e),e},eb=({state:e},r)=>{ar("pauseMusicRoom",r,tt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=Lt(e,"pause"),o.seekFallback=null,o.status="paused",Ge(e)),e},rb=({state:e},r)=>{ar("stopMusicRoom",r,tt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=Lt(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,Ge(e)),e},tb=({state:e},r)=>{if(ar("seekMusicRoom",r,qy),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=Lt(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"),Ge(e),e},Vc=(e,r,n,o)=>{ar(o,r,tt);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=To(e,a.tracks,s,n);return i&&qc(e,i),e},nb=({state:e},r)=>Vc(e,r,-1,"playPreviousMusicRoomTrack"),sb=({state:e},r)=>Vc(e,r,1,"playNextMusicRoomTrack"),ob=({state:e},r)=>{ar("clearMusicRoomSelection",r,tt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,t={commandId:Cn(e),operation:"resume"};return e.global.musicRoomPlayer={...On({bgmPlayback:t}),pageIndex:a},Ge(e),e},Fc=(e,r)=>{let n=e.projectData?.resources?.musicRoom;if(!n||r>=ui(n))return e;let o=e.global.musicRoomPlayer,a=pi(n,o);return r===a||(o.pageIndex=r,Ge(e)),e},ib=({state:e},r)=>{if(ar("moveToMusicRoomPage",r,Vy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Fc(e,r.pageIndex)},Uc=(e,r,n,o)=>{ar(o,r,tt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let t=pi(a,e.global.musicRoomPlayer)+n;return t<0?e:Fc(e,t)},ab=({state:e},r)=>Uc(e,r,1,"moveToNextMusicRoomPage"),lb=({state:e},r)=>Uc(e,r,-1,"moveToPreviousMusicRoomPage"),Tr=e=>{let r=ne(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(),Oh(e,n),e.global.pendingEffects.push({name:"render"}),!0},cb=({state:e},r)=>{let n="startSceneReplay";if(Ke(n,r,Fy),Bo(n,"sceneId",r.sceneId),ne(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===r.sceneId);if(!a||!Ac(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 c=Sh(e);Rh(e);let u=ni({pointer:{sceneId:a.sceneId,sectionId:s,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return dc(e,u),e.contexts.push(u),qt(e,u.pointers.read),e},Bc=({state:e},r)=>{Ke("finishSceneReplay",r,Ho);let o=ne(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(qr(e)?.rollback?.isRestoring===!0)return e;let t=_e({state:e})?.pointer,{sceneId:s}=or(e.projectData,t?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=Yy(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Nn(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},ub=({state:e},r)=>(Ke("exitSceneReplay",r,Ho),Tr(e),e),Yc=(e,r)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||r>=di(n))return e;let o=fi(n,e.global.sceneReplayNavigation);return r===o||(e.global.sceneReplayNavigation.pageIndex=r,e.global.pendingEffects.push({name:"render"})),e},pb=({state:e},r)=>{if(Ke("moveToSceneReplayPage",r,Uy),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Yc(e,r.pageIndex)},zc=(e,r,n,o)=>{Ke(o,r,Ho);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let t=fi(a,e.global.sceneReplayNavigation)+n;return t<0?e:Yc(e,t)},db=({state:e},r)=>zc(e,r,1,"moveToNextSceneReplayPage"),fb=({state:e},r)=>zc(e,r,-1,"moveToPreviousSceneReplayPage"),Ln=(e,r)=>{let n=e.global.musicRoomPlayer;return!L(r)||r.id!==Ny||n.trackId===null||!n.playback||r.commandId!==n.playback.commandId?null:n},hi=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,Gc=(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,Ge(e)),e),mb=({state:e},r)=>{let n=Ln(e,r);return!n||n.readiness!=="loading"||!hi(r)?e:Gc(e,n,r,{readiness:"ready"})},yb=({state:e},r)=>{let n=Ln(e,r);return!n||n.readiness!=="ready"||!hi(r)||n.status==="stopped"&&r.positionMs!==0||n.status==="ended"&&r.positionMs!==r.durationMs?e:Gc(e,n,r)},hb=({state:e},r)=>{let n=Ln(e,r);return!n||n.readiness!=="ready"||n.status!=="playing"||!hi(r)||r.positionMs!==r.durationMs||(n.status="ended",n.positionMs=r.positionMs,n.durationMs=r.durationMs,n.seekFallback=null,Ge(e)),e},gb=({state:e},r)=>{let n=Ln(e,r);if(!n||typeof r.errorCode!="string"||!Dy.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&&Ge(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,Ge(e),e},Hc=({state:e,rollbackActionBatchStack:r},n)=>{let o=Ky(n.manual),{auto:a,applyMode:t}=n,s=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},t!==void 0?e.global.nextLineConfig.applyMode=t:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),t!==void 0&&(e.global.nextLineConfig.applyMode=t));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=ve({state:e});return!u&&(a!==void 0&&(p!==s||m!==i||d!==l))&&(!f&&p===!0&&(m==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:d}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),We(e,"setNextLineConfig",n,r),e},bb=({state:e},r)=>{if(ne(e))throw new Error("Cannot save while a scene replay is active");let n=r?.slotId;zl(n,"saveSlot");let{thumbnailImage:o}=r,a=r?.savedAt,t=nt(n),s=D(e.contexts);s?.forEach(c=>{it(c),mc(c.rollback),eh(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:Ul,slotId:Kl(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},Ib=({state:e},r)=>{if(ne(e))throw new Error("Cannot load while a scene replay is active");let n=r?.slotId;zl(n,"loadSlot");let o=nt(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let t=yh(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=Dt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,st(e),ot(e),Ko(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},wb=({state:e},r)=>{if(ne(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=r;Wl(n),gt(n),bt(n),It(n),_r(n?.resources?.variables??{}),lo(n);let o=nh(n),a=o?e.contexts?.map((t,s)=>ic(D(t),n,s)):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=zo(),e.global.sceneReplayNavigation=Xo(),Ko(e),o){let t=n?.resources?.variables??{},{globalVariablesDefaultValues:s}=pn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...s,...wt(e.global.variables,t,{allowedScopes:["device","account"]})}),e.contexts=a}return st(e),ot(e),e.global.pendingEffects.push({name:"render"}),e},vb=({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(!L(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,ti(e,"localizationPackageId",n),fc(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!ve({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},Ab=({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=ve({state:e}),c=it(a);c.read={sectionId:t,lineId:o};let{activeInteraction:u}=qt(e,c.read);return _n(e,l,u),e},kb=({state:e,rollbackActionBatchStack:r},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return jn({state:e,rollbackActionBatchStack:r}),e;let o=ve({state:e});if(o?.source===rt&&n?.bypassChoice!==!0||o?.source===Ar&&n?._interactionSource!==Ar)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ne(e)?.sceneReplay.exitOnLineCompleted)return Tr(e),e;let d=_e({state:e})?.pointer,f=d?.sectionId,y=d?.lineId;f&&y&&Mr(e,{sectionId:f,lineId:y}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}});let g=e.global.nextLineConfig,h=be({state:e},{sectionId:f});return Array.isArray(h?.lines)&&h.lines.at(-1)?.id===y?Do(e):g?.auto?.enabled&&!o&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ne(e)?.sceneReplay.finishOnNextAdvance)return Tr(e),e;let t=_e({state:e})?.pointer,s=t?.sectionId,i=be({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(m=>m.id===t?.lineId)+1;if(p<c.length){let m=c[p],d=!br(e,"skipUnseenText");if(e.global.skipMode&&d&&!ii({state:e},{sectionId:s,lineId:m.id}))return kr({state:e}),e;if(l&&!l.rollback&&Pr(l,{compatibilityAnchor:!0}),l){let y=it(l),g=y.read?.lineId;g&&s&&Mr(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:m.id}}si(e,{sectionId:s,lineId:m.id}),Wo(e);let{activeInteraction:f}=qt(e,{sectionId:s,lineId:m.id});_n(e,o,f)}else{if(ne(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Tr(e),e;e.global.autoMode&&Vt({state:e}),e.global.skipMode&&kr({state:e}),Do(e)}return e},Pb=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ne(e)?.sceneReplay.exitOnLineCompleted)return Tr(e),e;let n=ve({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}});let o=_e({state:e})?.pointer,a=o?.sectionId,t=o?.lineId;a&&t&&Mr(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},xb=({state:e},r)=>jc(e,{sectionId:r?.sectionId,screen:r?.screen}),Eb=({state:e,rollbackActionBatchStack:r},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return jn({state:e,rollbackActionBatchStack:r}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e;let a=ve({state:e});if(a?.source===rt&&n?.bypassChoice!==!0||a?.source===Ar&&n?._interactionSource!==Ar||a&&a.source!==rt&&a.source!==Ar)return e;let t=ne(e);if(t?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(Tr(e),e):(t.sceneReplay.exitOnLineCompleted=!0,e);let s=_e({state:e})?.pointer,i=s?.sectionId,l=be({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=u.findIndex(d=>d.id===s?.lineId)+1;if(m<u.length){let d=u[m],f=!br(e,"skipUnseenText");if(e.global.skipMode&&f&&!ii({state:e},{sectionId:i,lineId:d.id})&&(kr({state:e}),!o))return e;if(c&&!c.rollback&&Pr(c,{compatibilityAnchor:!0}),c){let g=it(c),h=g.read?.lineId;h&&i&&Mr(e,{sectionId:i,lineId:h}),g.read={sectionId:i,lineId:d.id}}si(e,{sectionId:i,lineId:d.id}),Wo(e);let{activeInteraction:y}=qt(e,{sectionId:i,lineId:d.id});_n(e,a,y)}else{if(ne(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Tr(e),e;e.global.autoMode&&Vt({state:e}),e.global.skipMode&&kr({state:e}),Do(e)}return e},gi=(e,r={})=>{let n=Tt({state:e});return!n||r.formKey&&r.formKey!==n.key||r.formId&&r.formId!==n.id?null:n},Sb=(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($e(n))throw new Error(`Cannot update computed variable: ${r.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${r.variableId}`);if(At(o,r.variableId),kt(a,"set",r.variableId),ne(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${r.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},Rb=(e,r)=>({id:e.id,key:e.key,valid:!0,values:D(r),fields:D(e.fields),fieldList:D(e.fieldList)}),Ob=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let r=_e({state:e})?.pointer,n=r?.sectionId,o=r?.lineId;n&&o&&Mr(e,{sectionId:n,lineId:o})},Cb=({state:e},r={})=>{let n=gi(e,r),o=r.field;if(!n?.fields?.[o])return e;let a=cc(e,n.key),t=Sn(r.value),s=n.fields[o],i=ei(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},$b=({state:e,rollbackActionBatchStack:r},n={})=>{let o=gi(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=cc(e,o.key);a.submitted=!0;let t={},s={};if(Object.entries(o.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,y=ei(d,f);a.touched[m]=!0,y&&(s[m]=y),t[m]=lc(d,f)}),a.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:D(s),form:{id:o.id,key:o.key,values:D(t)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([m,d])=>{let{scope:f}=Sb(e,d),y=f==="context"?i.variables:e.global.variables,g=t[m];y[d.variableId]=fn(y[d.variableId],"set",g),f==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:g})),(f==="device"||f==="account")&&c.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:D(y[d.variableId])})}),l&&We(e,"updateVariable",{id:"submitForm",operations:u},r),Nn(e,c);let p=Rb(o,t);return Ob(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},_b=({state:e},r={})=>{let n=gi(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"}},jb=({state:e,rollbackActionBatchStack:r},n)=>{let{id:o,operations:a=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let t=e.contexts[e.contexts.length-1];if(t?.rollback?.isRestoring)return e;let s=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=e.projectData.resources?.variables?.[c],f=d?.scope,y=d?.type;if($e(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(At(f,c),kt(y,u,c),dn(y,u,p,c,{roundTo:m}),ne(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let g=f==="context"?t.variables:e.global.variables;if(f==="context"){s=!0;let h={variableId:c,op:u,value:p};m!==void 0&&(h.roundTo=m),l.push(h)}g[c]=fn(g[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&i.push({scope:f,path:`variables.${c}`,op:"set",value:D(g[c])})}),s&&We(e,"updateVariable",{id:o,operations:l},r),Nn(e,i),e.global.pendingEffects.push({name:"render"}),e},Ve=e=>(r,n)=>e({state:r},n),Nb=e=>({variables:vt({variables:{...e.global?.variables??{},...qr(e)?.variables??{}},runtime:Nr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Nr(e)}),Db=e=>{if(!L(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},Lb=(e,r,n)=>{if(!L(e))throw new Error(`conditional branch at index ${r} must be an object`);if(!L(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")},Tb=(e,r)=>{Db(r);for(let n=0;n<r.branches.length;n+=1){let o=r.branches[n];if(Lb(o,n,r.branches.length),!(Object.prototype.hasOwnProperty.call(o,"when")&&!ht(o.when,Nb(e)))){Object.entries(o.actions).forEach(([t,s])=>{Xc(e,t,s)});return}}},Mb={conditional:{replayLine:Tb},updateVariable:{recordSources:[vr],replayLine:Vl,replayRecorded:Vl,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Ve(Hc)},setSaveLoadPagination:{recordSources:[vr],replayLine:Ve(Mo),replayRecorded:Ve(Mo),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[vr],replayLine:Ve(qo),replayRecorded:Ve(qo),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[vr],replayLine:Ve(Vo),replayRecorded:Ve(Vo),persistInSaveSlot:!0},setMenuPage:{recordSources:[vr],replayLine:Ve(Fo),replayRecorded:Ve(Fo),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[vr],replayLine:Ve(Uo),replayRecorded:Ve(Uo),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Ve(Bc)}},Tn=e=>Mb[e]??null,qb=e=>Tn(e)?.persistInSaveSlot===!0,Vb=(e,r)=>{let n=Tn(e)?.recordSources;return Array.isArray(n)&&n.includes(r)},Fb=(e,r,n)=>{Tn(r)?.replayRecorded?.(e,n)},Xc=(e,r,n)=>{Tn(r)?.replayLine?.(e,n)},Ub=e=>e?.returnable!==!1,Wc=(e,r)=>{if(r>=0)return e.currentIndex+r;let n=Math.abs(r);for(let o=e.currentIndex-1;o>=0;o-=1)if(Ub(e.timeline[o])&&(n-=1,n===0))return o;return-1},Kc=({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=Wc(a,n);if(t<0||t>=a.timeline.length)return null;let s=a.timeline[t];return{sectionId:s.sectionId,lineId:s.lineId}},Jc=({state:e})=>Kc({state:e},{offset:-1})!==null,Bb=({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=Pr(o,{compatibilityAnchor:!o.rollback}),t=Wc(a,n);return t<0||t>=a.timeline.length?e:yc(e,t)},Yb=({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=Pr(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:yc(e,i)},Qc=e=>{let r=Uh(e),n=[];return da(r,{selectPendingEffects:Yh,selectSkipMode:hc,selectAutoMode:zh,selectIsChoiceVisible:xc,selectIsFormVisible:Wh,selectActiveInteraction:ve,selectActiveForm:Tt,selectDialogueUIHidden:gc,selectDialogueHistory:bc,selectConfirmDialog:Xh,selectIsLineAccountViewed:ii,selectIsResourceAccountViewed:Jh,selectImageGalleryConfig:Qh,selectImageGallery:Ic,selectMusicRoomConfig:eg,selectMusicRoom:vc,selectSceneReplayConfig:rg,selectSceneReplay:kc,selectIsSceneReplayActive:tg,selectActiveSceneReplayEntry:ng,selectNextLineConfig:sg,selectSystemState:og,selectAchievements:ig,selectAchievement:ag,selectSaveSlotMap:Ec,selectSaveSlots:mg,selectSaveSlot:lg,selectLocalizationPackages:Sc,selectRuntime:mi,selectRuntimeValue:cg,selectAllVariables:$n,selectCurrentPointer:_e,selectSection:be,selectCurrentLine:Mt,selectPresentationState:Rc,selectAutoForwardTimerDelay:ir,selectPresentationChanges:pg,selectSectionLineChanges:fg,selectSaveSlotPage:yi,selectCurrentPageSlots:yg,selectRenderState:gg,selectOverlayStack:Bh,selectLineIdByOffset:Kc,selectCanRollback:Jc,selectRollbackCursor:Nh,startAutoMode:Cc,stopAutoMode:Vt,toggleAutoMode:xg,startSkipMode:$c,stopSkipMode:kr,toggleSkipMode:Eg,showDialogueUI:jn,hideDialogueUI:_c,toggleDialogueUI:Sg,setDialogueTextSpeed:Rg,setAutoForwardDelay:Og,setAutoForwardSpeed:Cg,setSkipUnseenText:$g,setSkipTransitionsAndAnimations:_g,setSoundVolume:jg,setMusicVolume:Ng,setMuteAll:Dg,setSaveLoadPagination:Mo,incrementSaveLoadPagination:qo,decrementSaveLoadPagination:Vo,setMenuPage:Fo,setMenuEntryPoint:Uo,showConfirmDialog:bg,hideConfirmDialog:Ig,resetStoryAtSection:Vg,clearPendingEffects:Lg,appendPendingEffect:Tg,completeAchievement:Mg,setAchievementProgress:qg,beginRollbackActionBatch:Mh,endRollbackActionBatch:qh,markRollbackCheckpointTransient:Dh,markSavedRollbackCheckpointTransient:Lh,recordCurrentDialogueHistory:Hh,addViewedLine:Ug,addViewedResource:Bg,showImageGalleryVariant:Yg,moveToPreviousImageGalleryVariant:zg,moveToNextImageGalleryVariant:Gg,clearImageGallerySelection:Hg,moveToImageGalleryPage:Xg,moveToNextImageGalleryPage:Wg,moveToPreviousImageGalleryPage:Kg,playMusicRoomTrack:Qg,playMusicRoom:Zg,pauseMusicRoom:eb,stopMusicRoom:rb,seekMusicRoom:tb,playPreviousMusicRoomTrack:nb,playNextMusicRoomTrack:sb,clearMusicRoomSelection:ob,moveToMusicRoomPage:ib,moveToNextMusicRoomPage:ab,moveToPreviousMusicRoomPage:lb,musicRoomSoundReady:mb,musicRoomSoundProgress:yb,musicRoomSoundComplete:hb,musicRoomSoundError:gb,startSceneReplay:cb,finishSceneReplay:Bc,exitSceneReplay:ub,moveToSceneReplayPage:pb,moveToNextSceneReplayPage:db,moveToPreviousSceneReplayPage:fb,setNextLineConfig:Hc,saveSlot:bb,loadSlot:Ib,updateProjectData:wb,updateLocalizationPackage:vb,sectionTransition:xb,jumpToLine:Ab,nextLine:kb,markLineCompleted:Pb,rollbackToLine:Yb,rollbackByOffset:Bb,pushOverlay:wg,popOverlay:vg,replaceLastOverlay:Ag,clearOverlays:kg,updateFormField:Cb,submitForm:$b,cancelForm:_b,updateVariable:jb,nextLineFromSystem:Eb},{transformActionFirstArgument:a=>({state:a,rollbackActionBatchStack:n}),transformSelectorFirstArgument:a=>({state:a})})};var zb="route-engine",Gb="projectPersistence";var eu=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),ae=e=>Object.prototype.toString.call(e)==="[object Object]",Zc="variables.",Hb=(e={})=>{let r=ae(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!ae(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.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)}},Xb=(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)}},Wb=(e,r)=>{let n=Xb(e),o=Hb(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}},Kb=(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))]}},Jb=(e,r)=>{let n=Kb(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)])]}},ru=(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:{}}},Qb=(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(Zc)?r.path.slice(Zc.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}].`)})},Zb=(e,r)=>{let n={};return Qb(r).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=Wb(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=Jb(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},at=e=>{if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null},eI=e=>{let r=at(e);if(!r)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return r},rI=e=>{let r=e??globalThis.indexedDB;if(!r)throw new Error("IndexedDB is not available in this environment.");return r},tI=({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}".`))}}),nI=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.`))}})},Ut=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),c=l.get(n),u=!1,p=d=>{u||(u=!0,s(d))},m=()=>{u||(u=!0,t())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=ru(c.result),f=typeof o=="function"?o(d):o,y={namespace:n,version:1,...eu(),...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}".`))}})},sI=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),c=!1,u=m=>{c||(c=!0,t(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{u(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{u(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},bi=(e={})=>{let{indexedDB:r,databaseName:n=zb,objectStoreName:o=Gb,namespace:a}=e,t=rI(r),s=eI(a),i=tI({indexedDB:t,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await nI({databasePromise:i,objectStoreName:o,namespace:s});return{...eu(),...ru(l)}},clear:async()=>sI({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>Ut({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:ae(l)?l:{}}}),saveGlobalDeviceVariables:async l=>Ut({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:ae(l)?l:{}}}),saveGlobalAccountVariables:async l=>Ut({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:ae(l)?l:{}}}),saveGlobalRuntime:async l=>Ut({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:ae(l)?l:{}}}),applyScopedDataUpdates:async l=>Ut({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>Zb(c,l)})}},oI=bi;var cu=uu;var iI={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},lr=Object.prototype.hasOwnProperty,aI={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 De(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=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 u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath: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:aI.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 u=p===s;l=l||u}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 De.errors=t,s===0}var lI={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};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==="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:lI.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 qn.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&&(qn(e.playback,{instancePath:r+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(t=t===null?qn.errors:t.concat(qn.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 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(!lr.call(iI.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&&(De(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.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 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=du;var cI={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},su={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},Ne=nu().default;function je(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(!lr.call(su.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(Ne(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(Ne(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:su.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 je.errors=t,s===0}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 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 c=l===s;if(c){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 u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.startDelayMs===void 0&&(d="startDelayMs")||e.sounds===void 0&&(d="sounds")){let f={};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=u,t!==null&&(u?t.length=u: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++)je(d[y],{instancePath:r+"/sounds/"+y,parentData:d,parentDataProperty:y,rootData:a})||(t=t===null?je.errors:t.concat(je.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:cI.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 Fn.errors=t,s===0}function du(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),du.errors=t,s===0}var fu=mu;var uI={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 Un(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 c={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=s,d=!0,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let y;if(p.sprites===void 0&&(y="sprites")){let g={};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/"+u,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/"+u,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/"+u,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(!lr.call(uI.properties.items.items.properties,y)){let g={instancePath:r+"/items/"+u,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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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&&(De(p.blur,{instancePath:r+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[y]:t.push(y),s++}}}else{let c={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[c]:t.push(c),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 Un.errors=t,s===0}function mu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Un(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Un.errors:t.concat(Un.errors),s=t.length),mu.errors=t,s===0}var yu=hu;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)){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 c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:r+"/items/"+c,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(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:r+"/items/"+c+"/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(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:r+"/items/"+c+"/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(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let d={instancePath:r+"/items/"+c+"/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/"+c+"/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/"+c,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 Bn.errors=t,s===0}function hu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Bn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Bn.errors:t.concat(Bn.errors),s=t.length),hu.errors=t,s===0}var gu=bu;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 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 Yn.errors=t,s===0}function bu(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),bu.errors=t,s===0}var Iu=wu;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.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 zn.errors=t,s===0}function wu(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),wu.errors=t,s===0}var vu=Au;var ou={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 Gn(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(!lr.call(ou.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 c={instancePath:r+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),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:ou.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 c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:r+"/content/"+c+"/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/"+c,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 c={instancePath:r+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),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 c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:r+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={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=[c]:t.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath: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 u={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=[u]:t.push(u),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 c={instancePath:r+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),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 Gn.errors=t,s===0}function Au(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Gn(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Gn.errors:t.concat(Gn.errors),s=t.length),Au.errors=t,s===0}var ku=Pu;function Hn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="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 c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={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=[u]:t.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={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=[u]:t.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={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=[u]:t.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={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=[u]:t.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={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=[u]:t.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={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=[u]:t.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){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 u=="number"&&(u<0||isNaN(u))){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 u={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=[u]:t.push(u),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 Hn.errors=t,s===0}function Pu(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),Pu.errors=t,s===0}var xu=Eu;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==="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 Xn.errors=t,s===0}function Eu(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),Eu.errors=t,s===0}var Su=Ru;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==="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&&(De(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.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 Wn.errors=t,s===0}function Ru(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),Ru.errors=t,s===0}var Ou=Cu;var pI={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 Kn(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 u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};t===null?t=[p]:t.push(p),s++}}var c=l===s;if(c){let u={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[u]:t.push(u),s++}else s=i,t!==null&&(i?t.length=i:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)je(u[m],{instancePath:r+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(t=t===null?je.errors:t.concat(je.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 u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let d=u[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath: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(Ne(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:pI.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++)je(f[g],{instancePath:r+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(t=t===null?je.errors:t.concat(je.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 u={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}return Kn.errors=t,s===0}function Cu(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),Cu.errors=t,s===0}var $u=_u;var iu={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 Jn(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=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 u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let y=e[f];if(y&&typeof y=="object"&&!Array.isArray(y)){if(y.text!==void 0&&typeof y.text!="string"){let g={instancePath: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 u=p===s;l=l||u}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 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=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let I;if(e.id===void 0&&(I="id")){let b={};t===null?t=[b]:t.push(b),s++}}var m=p===s;if(u=u||m,!u){let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.type===void 0&&(x="type")){let v={};t===null?t=[v]:t.push(v),s++}}var m=I===s;if(u=u||m,!u){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.resourceId===void 0&&(k="resourceId")){let S={};t===null?t=[S]:t.push(S),s++}}var m=x===s;if(u=u||m,!u){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let C;if(e.transformId===void 0&&(C="transformId")){let N={};t===null?t=[N]:t.push(N),s++}}var m=k===s;if(u=u||m,!u){let C=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.x===void 0&&(P="x")){let T={};t===null?t=[T]:t.push(T),s++}}var m=C===s;if(u=u||m,!u){let P=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 m=P===s;if(u=u||m,!u){let V=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.anchorX===void 0&&(G="anchorX")){let ee={};t===null?t=[ee]:t.push(ee),s++}}var m=V===s;if(u=u||m,!u){let G=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Pe;if(e.anchorY===void 0&&(Pe="anchorY")){let Fe={};t===null?t=[Fe]:t.push(Fe),s++}}var m=G===s;if(u=u||m,!u){let Pe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.scaleX===void 0&&(oe="scaleX")){let me={};t===null?t=[me]:t.push(me),s++}}var m=Pe===s;if(u=u||m,!u){let oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ae;if(e.scaleY===void 0&&(Ae="scaleY")){let ye={};t===null?t=[ye]:t.push(ye),s++}}var m=oe===s;if(u=u||m,!u){let Ae=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let re;if(e.rotation===void 0&&(re="rotation")){let ce={};t===null?t=[ce]:t.push(ce),s++}}var m=Ae===s;if(u=u||m,!u){let re=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.originX===void 0&&(se="originX")){let ie={};t===null?t=[ie]:t.push(ie),s++}}var m=re===s;if(u=u||m,!u){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ue;if(e.originY===void 0&&(Ue="originY")){let ur={};t===null?t=[ur]:t.push(ur),s++}}var m=se===s;if(u=u||m,!u){let Ue=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Oe;if(e.layer===void 0&&(Oe="layer")){let $={};t===null?t=[$]:t.push($),s++}}var m=Ue===s;if(u=u||m,!u){let Oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.opacity===void 0&&(j="opacity")){let F={};t===null?t=[F]:t.push(F),s++}}var m=Oe===s;if(u=u||m,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.blur===void 0&&(K="blur")){let xe={};t===null?t=[xe]:t.push(xe),s++}}var m=j===s;if(u=u||m,!u){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let pr;if(e.animations===void 0&&(pr="animations")){let Ie={};t===null?t=[Ie]:t.push(Ie),s++}}var m=K===s;u=u||m}}}}}}}}}}}}}}}}if(u)s=c,t!==null&&(c?t.length=c: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 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=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&&(Jn(e.content,{instancePath:r+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(t=t===null?Jn.errors:t.concat(Jn.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 Qn.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)){for(let l in e)if(l!=="items"){let c={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=s,d=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let f;if(p.resourceId===void 0&&(f="resourceId")||p.text===void 0&&(f="text")){let y={};t===null?t=[y]:t.push(y),s++}}var i=d===s;if(i){let f={instancePath:r+"/items/"+u,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/"+u,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(!lr.call(iu.properties.items.items.properties,f)){let y={instancePath:r+"/items/"+u,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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[f]:t.push(f),s++}if(p.text!==void 0&&(Qn(p.text,{instancePath:r+"/items/"+u+"/text",parentData:p,parentDataProperty:"text",rootData:a})||(t=t===null?Qn.errors:t.concat(Qn.errors),s=t.length)),p.transformId!==void 0&&typeof p.transformId!="string"){let f={instancePath:r+"/items/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/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/"+u+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:iu.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/"+u+"/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/"+u+"/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/"+u+"/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&&(De(p.blur,{instancePath:r+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),p.animations!==void 0&&(Q(p.animations,{instancePath:r+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length))}else{let f={instancePath:r+"/items/"+u,schemaPath:"#/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+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[c]:t.push(c),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 Zn.errors=t,s===0}function _u(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),_u.errors=t,s===0}var ju=Nu;var dI={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 es(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=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 u=c===s;if(l=l||u,!l){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath: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 u=h===s;l=l||u}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++)je(h[b],{instancePath:r+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:a})||(t=t===null?je.errors:t.concat(je.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:dI.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 es.errors=t,s===0}function Nu(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),Nu.errors=t,s===0}var Du=Lu;var fI={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 rs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};t===null?t=[g]:t.push(g),s++}var u=c===s;if(s=i,t!==null&&(i?t.length=i:t=null),u){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 u=g===s;l=u}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 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 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:fI.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(Ne(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(Ne(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(Ne(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(Ne(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 rs.errors=t,s===0}function Lu(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),Lu.errors=t,s===0}var Tu=Mu;var mI={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 yI={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 Fr(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:yI.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 Fr.errors=t,s===0}function z(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 c={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[c]:t.push(c),s++}let l=i.length;for(let c=0;c<l;c++)Fr(i[c],{instancePath:r+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(t=t===null?Fr.errors:t.concat(Fr.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 z.errors=t,s===0}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(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&&(z(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.x!==void 0&&(z(e.x,{instancePath:r+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.y!==void 0&&(z(e.y,{instancePath:r+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.scaleX!==void 0&&(z(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.scaleY!==void 0&&(z(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.rotation!==void 0&&(z(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?z.errors:t.concat(z.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 ts.errors=t,s===0}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(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&&(z(e.translateX,{instancePath:r+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.translateY!==void 0&&(z(e.translateY,{instancePath:r+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.alpha!==void 0&&(z(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.scaleX!==void 0&&(z(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.scaleY!==void 0&&(z(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?z.errors:t.concat(z.errors),s=t.length)),e.rotation!==void 0&&(z(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?z.errors:t.concat(z.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 ns.errors=t,s===0}function Vr(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&&(ns(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?ns.errors:t.concat(ns.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 Vr.errors=t,s===0}var Mn={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"]}}]},hI={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function ss(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.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:hI.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 ss.errors=t,s===0}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.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 c={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[c]:t.push(c),s++}let l=i.length;for(let c=0;c<l;c++)Fr(i[c],{instancePath:r+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(t=t===null?Fr.errors:t.concat(Fr.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 os.errors=t,s===0}function is(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let b={};t===null?t=[b]:t.push(b),s++}var u=c===s;if(s=i,t!==null&&(i?t.length=i:t=null),u){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 u=b===s;l=u}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(!lr.call(Mn.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:Mn.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++)ss(b[v],{instancePath:r+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(t=t===null?ss.errors:t.concat(ss.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:Mn.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:Mn.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&&(os(e.progress,{instancePath:r+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(t=t===null?os.errors:t.concat(os.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 is.errors=t,s===0}function as(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};t===null?t=[b]:t.push(b),s++}var u=c===s;if(s=i,t!==null&&(i?t.length=i:t=null),u){let b=s,x=s,v=s,k=s,S=!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(S=S||p,!S){let P=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=P===s;if(S=S||p,!S){let V=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let ee={};t===null?t=[ee]:t.push(ee),s++}}var p=V===s;S=S||p}}if(S)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=x,t!==null&&(x?t.length=x: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 u=b===s;l=u}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,x=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=x,t!==null&&(x?t.length=x:t=null);let k=s,S=!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(S=S||I,!S){let P=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=P===s;if(S=S||I,!S){let V=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};t===null?t=[G]:t.push(G),s++}var I=V===s;S=S||I}}if(S)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 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:mI.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&&(ts(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?ts.errors:t.concat(ts.errors),s=t.length)),e.prev!==void 0&&(Vr(e.prev,{instancePath:r+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(t=t===null?Vr.errors:t.concat(Vr.errors),s=t.length)),e.next!==void 0&&(Vr(e.next,{instancePath:r+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(t=t===null?Vr.errors:t.concat(Vr.errors),s=t.length)),e.mask!==void 0&&(is(e.mask,{instancePath:r+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(t=t===null?is.errors:t.concat(is.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 as.errors=t,s===0}function Mu(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),Mu.errors=t,s===0}var qu=Vu;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)){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(Ne(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 ls.errors=t,s===0}function Vu(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),Vu.errors=t,s===0}var Fu=Uu;var gI=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");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)){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(!gI.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 cs.errors=t,s===0}function Uu(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),Uu.errors=t,s===0}var Bu=Yu;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.keyboard!==void 0){let i=e.keyboard;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath: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(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){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(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath: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(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath: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 u={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=[u]:t.push(u),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 c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath: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(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){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 u={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=[u]:t.push(u),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 c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/elements/"+c,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 us.errors=t,s===0}function Yu(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),Yu.errors=t,s===0}var zu=Gu;function ps(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 ps.errors=t,s===0}function Gu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ps(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ps.errors:t.concat(ps.errors),s=t.length),Gu.errors=t,s===0}var Hu=Xu;function ds(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 ds.errors=t,s===0}function Xu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ds(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ds.errors:t.concat(ds.errors),s=t.length),Xu.errors=t,s===0}var Wu=Ku;function fs(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 c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/elements/"+c,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 fs.errors=t,s===0}function Ku(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return fs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?fs.errors:t.concat(fs.errors),s=t.length),Ku.errors=t,s===0}var Ju=Qu;function ms(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=null,u=s,p=s,m=s,d=s,f=!1,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.count===void 0&&(v="count")){let k={};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 S;if(e.texture===void 0&&(S="texture")){let C={};t===null?t=[C]:t.push(C),s++}}var g=v===s;if(f=f||g,!f){let S=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=S===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 V={};t===null?t=[V]:t.push(V),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=u===s;b&&(l=!0,c=0);let I=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let v={instancePath: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,c=[c,1]):b&&(l=!0,c=1),l)s=i,t!==null&&(i?t.length=i:t=null);else{let v={instancePath:r,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},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 S={instancePath:r+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};t===null?t=[S]:t.push(S),s++}if(v.emission!==void 0){let k=v.emission;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:r+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[S]:t.push(S),s++}}if(v.movement!==void 0){let k=v.movement;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:r+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[S]:t.push(S),s++}}if(v.appearance!==void 0){let k=v.appearance;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:r+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[S]:t.push(S),s++}}if(v.bounds!==void 0){let k=v.bounds;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let S={instancePath:r+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[S]:t.push(S),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,S=!1,C=null,N=s;if(typeof v=="string"){if(Ne(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&&(S=!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 x=P===s;if(x&&S?(S=!1,C=[C,1]):x&&(S=!0,C=1),S)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 S={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[S]:t.push(S),s++}let k=v.length;for(let S=0;S<k;S++){let C=v[S];if(C&&typeof C=="object"&&!Array.isArray(C)){if(C.type===void 0){let N={instancePath:r+"/behaviors/"+S,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/"+S,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(Ne(N)<1){let P={instancePath:r+"/behaviors/"+S+"/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/"+S+"/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/"+S+"/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/"+S,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 S={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};t===null?t=[S]:t.push(S),s++}if(k.max===void 0){let S={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};t===null?t=[S]:t.push(S),s++}if(k.min!==void 0){let S=k.min;if(typeof S=="number"){if(S<0||isNaN(S)){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 S=k.max;if(typeof S=="number"){if(S<0||isNaN(S)){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 S={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[S]:t.push(S),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 ms.errors=t,s===0}function Qu(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ms(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ms.errors:t.concat(ms.errors),s=t.length),Qu.errors=t,s===0}var Zu=ep;var au={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 ys(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(!lr.call(au.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:au.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 ys.errors=t,s===0}function ep(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ys(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ys.errors:t.concat(ys.errors),s=t.length),ep.errors=t,s===0}var rp=tp;var bI=new RegExp("^.+$","u");function hs(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(bI.test(l)){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={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=[u]:t.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="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:u},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)if(typeof u[m]!="number"){let d={instancePath: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(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={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=[u]:t.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={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=[u]:t.push(u),s++}}else{let u={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=[u]:t.push(u),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 hs.errors=t,s===0}function tp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return hs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?hs.errors:t.concat(hs.errors),s=t.length),tp.errors=t,s===0}var np=sp;var lu={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 gs(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(!lr.call(lu.properties,l)){let c={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,m=s;if(typeof l=="string"){if(Ne(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&&(u=!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(Ne(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&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)s=c,t!==null&&(c?t.length=c: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 c={instancePath:r+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[c]:t.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:r+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:lu.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};t===null?t=[c]:t.push(c),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 c={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};t===null?t=[c]:t.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Ne(c)<1){let u={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=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[u]:t.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[u]:t.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:r+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:r+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[c]:t.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:r+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[c]:t.push(c),s++}}else{let c={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),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 gs.errors=t,s===0}function sp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return gs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?gs.errors:t.concat(gs.errors),s=t.length),sp.errors=t,s===0}var op=ip;var II={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 bs(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(!lr.call(II.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 bs.errors=t,s===0}function ip(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return bs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?bs.errors:t.concat(bs.errors),s=t.length),ip.errors=t,s===0}var ap=lp;function Is(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Is.errors=t,s===0}function lp(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),lp.errors=t,s===0}var zt=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Yt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),cr=e=>e===void 0?void 0:structuredClone(e),wI=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"}),vI=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),AI=Object.freeze({background:cu,bgm:pu,character:fu,choice:yu,cleanAll:gu,control:Iu,dialogue:vu,form:ku,layout:xu,screen:Su,sfx:Ou,visual:$u,voice:ju}),kI=Object.freeze({achievement:Du,animation:Tu,character:qu,color:Fu,control:Bu,font:zu,image:Hu,layout:Wu,particle:Ju,sound:Zu,spritesheet:rp,textStyle:np,transform:op,video:ap}),PI=new Set(["files","language","patches"]),xI=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),EI=new Set(["lineId","mode","payload","type"]),SI=new Set(["mode","payload","sceneId","type"]),RI=new Set(["mode","operation","payload","resourceId","type"]),OI=new Set(["fileId","mimeType"]),q=(e,r)=>{throw new Error(`Invalid l10nData at ${e}: ${r}`)},He=(e,r)=>{Yt(e)||q(r,"expected an object")},wi=(e,r)=>{Array.isArray(e)||q(r,"expected an array")},lt=(e,r)=>{(typeof e!="string"||e.length===0)&&q(r,"expected a non-empty string")},dp=(e,r)=>{typeof e!="string"&&q(r,"expected a string")},Qe=(e,r,n)=>{for(let o of Object.keys(e))r.has(o)||q(`${n}.${o}`,"unknown field")},Ze=(e,r,n)=>{for(let o of r)zt(e,o)||q(n,`missing required field "${o}"`)},CI=e=>e.replaceAll("~1","/").replaceAll("~0","~"),$I=(e,r)=>{let n=(r?.instancePath??"").split("/").slice(1).map(CI);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)},_I=(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],fp=({value:e,validator:r,path:n,contract:o})=>{if(r(e))return;let a=_I(r.errors);q($I(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},ws=(e,r,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||q(r,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,a)=>ws(o,`${r}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>ws(a,`${r}.${o}`,n))}},Je=(e,r)=>{e===""&&q(r,"expected a non-empty resourceId")},jI=(e,r,n)=>{let o=(s,i)=>Je(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>Je(l?.resourceId,`${i}[${c}].resourceId`)),t=(s,i)=>{Je(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":Je(r.resourceId,`${n}.resourceId`),o(r.animations,`${n}.animations`);break;case"bgm":case"voice":t(r,n);break;case"sfx":a(r.items,`${n}.items`),(r.channels??[]).forEach((s,i)=>a(s?.sounds,`${n}.channels[${i}].sounds`));break;case"character":(r.items??[]).forEach((s,i)=>{(s.sprites??[]).forEach((l,c)=>Je(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":Je(r.resourceId,`${n}.resourceId`),o(r.animations,`${n}.animations`);break;case"control":Je(r.resourceId,`${n}.resourceId`);break;case"dialogue":Je(r.ui?.resourceId,`${n}.ui.resourceId`),o(r.ui?.animations,`${n}.ui.animations`),(r.character?.sprite?.items??[]).forEach((s,i)=>Je(s?.resourceId,`${n}.character.sprite.items[${i}].resourceId`)),o(r.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(r.animations,`${n}.animations`);break;case"visual":(r.items??[]).forEach((s,i)=>{Je(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},ct=(e,r)=>{lt(e,r),(e==="__proto__"||e==="constructor"||e==="prototype")&&q(r,`"${e}" is not a safe ID`)},NI=(e,r)=>{lt(e,r),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&q(r,"must be a safe single filename")},Bt=(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)=>Bt(a,r[t]));if(!Yt(e)||!Yt(r))return!1;let n=Object.keys(e).sort(),o=Object.keys(r).sort();return Bt(n,o)&&n.every(a=>Bt(e[a],r[a]))},vs=(e,r=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>vs(o,r,n)),r;if(!Yt(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),vs(a,r,n);return r},DI=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},mp=(e,r,n)=>{let o=e.get(r)??[];return o.length===0&&q(n,`lineId "${r}" does not exist in projectData`),o.length>1&&q(n,`lineId "${r}" is not globally unique in projectData`),o[0]},yp=(e,r)=>e.story.scenes[r.sceneId].sections[r.sectionId].lines[r.lineIndex],cp=e=>({items:(e?.items??[]).map(r=>({id:r?.id,events:r?.events}))}),up=e=>{let r=cr(e??{});delete r.resourceId,delete r.animations;for(let n of Object.values(r.fields??{}))Yt(n)&&delete n.placeholder;return r},LI=(e,r,n,o)=>{e==="choice"&&!Bt(cp(r),cp(n))&&q(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Bt(up(r),up(n))&&q(o,"form behavior must remain identical; only presentation fields and placeholders may change")},TI=({patch:e,path:r,lineIndex:n})=>{Qe(e,xI,r),Ze(e,["type","lineId","actionType","payload"],r),ct(e.lineId,`${r}.lineId`),lt(e.actionType,`${r}.actionType`),He(e.payload,`${r}.payload`),e.mode!==void 0&&e.mode!=="replace"&&q(`${r}.mode`,'line.action supports only "replace"'),vI.has(e.actionType)||q(`${r}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=mp(n,e.lineId,`${r}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&q(`${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")&&q(`${r}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),zt(e.payload,"content")&&q(`${r}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&q(`${r}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),LI(e.actionType,a,e.payload,`${r}.payload`),fp({value:e.payload,validator:AI[e.actionType],path:`${r}.payload`,contract:`the ${e.actionType} presentation-action schema`}),ws(e.payload,`${r}.payload`),jI(e.actionType,e.payload,`${r}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},MI=(e,r)=>{wi(e,r),e.forEach((n,o)=>{He(n,`${r}[${o}]`),Qe(n,new Set(["text"]),`${r}[${o}]`),Ze(n,["text"],`${r}[${o}]`),dp(n.text,`${r}[${o}].text`)})},qI=({patch:e,path:r,lineIndex:n})=>{Qe(e,EI,r),Ze(e,["type","lineId","payload"],r),ct(e.lineId,`${r}.lineId`),He(e.payload,`${r}.payload`),Qe(e.payload,new Set(["content"]),`${r}.payload`),Ze(e.payload,["content"],`${r}.payload`),MI(e.payload.content,`${r}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&q(`${r}.mode`,'line.dialogue supports only "replace"');let o=mp(n,e.lineId,`${r}.lineId`);return o.line?.actions?.dialogue===void 0&&q(`${r}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},VI=({patch:e,path:r,projectData:n})=>(Qe(e,SI,r),Ze(e,["type","mode","sceneId","payload"],r),ct(e.sceneId,`${r}.sceneId`),He(e.payload,`${r}.payload`),Qe(e.payload,new Set(["name"]),`${r}.payload`),Ze(e.payload,["name"],`${r}.payload`),dp(e.payload.name,`${r}.payload.name`),e.mode!=="patch"&&q(`${r}.mode`,'story.scene requires "patch"'),zt(n?.story?.scenes??{},e.sceneId)||q(`${r}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),FI=(e,r,n)=>{He(r,n),["font","image","sound","spritesheet","video"].includes(e)&&lt(r.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(r.width)||q(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||q(`${n}.height`,"expected an integer")),e==="spritesheet"&&(He(r.jsonData,`${n}.jsonData`),Number.isInteger(r.width)||q(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||q(`${n}.height`,"expected an integer")),e==="color"&&(typeof r.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r.hex))&&q(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),fp({value:r,validator:kI[e],path:n,contract:`the resource.${e} schema`}),ws(r,n)},UI=({patch:e,path:r,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{Qe(e,RI,r),Ze(e,["type","resourceId","payload"],r),ct(e.resourceId,`${r}.resourceId`);let t=e.type.slice(9),s=wI[t];s||q(`${r}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&q(`${r}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&q(`${r}.operation`,'the only resource operation is "add"'),FI(t,e.payload,`${r}.payload`);let i=n?.resources?.[s]??{},l=zt(i,e.resourceId);e.operation==="add"&&l&&q(`${r}.resourceId`,`cannot add existing ${t} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&q(`${r}.resourceId`,`cannot replace missing ${t} resource "${e.resourceId}"`);for(let c of vs(e.payload))!o.has(c)&&!a.has(c)&&q(`${r}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:r,patch:e}},pp=({resources:e,collectionName:r,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!zt(e?.[r]??{},n))&&q(o,`${a} resource "${n}" was not found`)},BI=(e,r)=>{let n=cr(e);for(let a of r.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=cr(a.patch.payload));let o=n.resources??{};for(let a of r.patches){if(a.patch.type!=="resource.textStyle")continue;let t=a.patch.payload,s=Array.isArray(t.fontId)?t.fontId:[t.fontId];s.forEach((i,l)=>pp({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",t.colorId],["strokeColorId",t.strokeColorId],["shadow.colorId",t.shadow?.colorId]])pp({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},YI=({patch:e,path:r,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:t})=>{if(He(e,r),lt(e.type,`${r}.type`),e.type==="line.action")return TI({patch:e,path:r,lineIndex:o});if(e.type==="line.dialogue")return qI({patch:e,path:r,lineIndex:o});if(e.type==="story.scene")return VI({patch:e,path:r,projectData:n});if(e.type.startsWith("resource."))return UI({patch:e,path:r,projectData:n,packageFileIds:a,canonicalFileIds:t});q(`${r}.type`,`unsupported patch type "${e.type}"`)},zI=(e,r)=>{wi(e,r);let n=new Set;return e.forEach((o,a)=>{let t=`${r}[${a}]`;He(o,t),Qe(o,OI,t),Ze(o,["fileId"],t),NI(o.fileId,`${t}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&q(`${t}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&q(`${t}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},GI=({packageId:e,packageData:r,path:n,projectData:o,lineIndex:a,canonicalFileIds:t})=>{He(r,n),Qe(r,PI,n),Ze(r,["language","files","patches"],n),lt(r.language,`${n}.language`);let s=zI(r.files,`${n}.files`);wi(r.patches,`${n}.patches`);let i=new Set,l=r.patches.map((c,u)=>{let p=YI({patch:c,path:`${n}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:t});return i.has(p.key)&&q(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:r,fileIds:s,patches:l}},hp=({projectData:e,l10nData:r})=>{if(r===void 0)return{packages:new Map};He(r,"l10nData"),Qe(r,new Set(["packages"]),"l10nData"),Ze(r,["packages"],"l10nData"),He(r.packages,"l10nData.packages");let n=DI(e),o=vs(e?.resources??{}),a=new Map,t=new Map;for(let[s,i]of Object.entries(r.packages)){ct(s,`l10nData.packages.${s}`);let l=GI({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&q(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=t.get(c);u!==void 0&&q(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),t.set(c,s)}BI(e,l),a.set(s,l)}return{packages:a}},HI=(e,r)=>{let{collectionName:n,patch:o}=r;e.resources[n]??={},e.resources[n][o.resourceId]=cr(o.payload)},XI=(e,r)=>{let{patch:n}=r,o=e.story.scenes[n.sceneId];o.name=n.payload.name},WI=(e,r)=>{let{location:n,patch:o}=r,a=yp(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)},KI=(e,r)=>{let{location:n,patch:o}=r,a=yp(e,n);a.actions.dialogue.content=cr(o.payload.content)},gp=({projectData:e,l10nData:r})=>{let n=hp({projectData:e,l10nData:r});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},As=({projectData:e,l10nData:r,l10nId:n=null})=>{let o=hp({projectData:e,l10nData:r});if(n!==null&&(ct(n,"l10nId"),o.packages.has(n)||q("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=>HI(a,s)),t.filter(s=>s.kind==="story.scene").forEach(s=>XI(a,s)),t.filter(s=>s.kind==="line.action").forEach(s=>WI(a,s)),t.filter(s=>s.kind==="line.dialogue").forEach(s=>KI(a,s)),a};var JI=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),QI=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),bp="conditional",Ai=Symbol("conditionalAutoContinue"),ZI=new Set(["sectionTransition","resetStoryAtSection"]),e0=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),r0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),t0=new Set(["nextLine","nextLineFromSystem"]),n0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),vi="form",s0=new Set(["submitForm","cancelForm"]),o0="showImageGalleryVariant",i0="playMusicRoomTrack",a0="startSceneReplay",Xe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),l0=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,ks=e=>e?.type===Ai,Ur=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId;function ki(e){let r=l0(),n,o=0,a=!1,t=0,s=null,i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,y=new Map,g,h,I=null,{handlePendingEffects:b}=e,x=w=>{if(!a||!n)throw new Error(`RouteEngine ${w} requires an active engine`)},v=(w=new Map,E=Date.now())=>new Map(Array.from(w.entries()).filter(([,R])=>E<R.expiresAt).map(([R,O])=>[R,{animation:structuredClone(O.animation),startedAt:O.startedAt,expiresAt:O.expiresAt}])),k=(w=new Map)=>Array.from(w.values()).map(E=>structuredClone(E.animation)),S=(w=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,E])=>w<E.expiresAt))},C=()=>{if(a&&!(i>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let w=n.selectCurrentPointer()?.pointer??null,E=[...n.selectPendingEffects()],R=E.map(O=>O.name!=="handleLineActions"?O:{...O,payload:{...O.payload,pointer:structuredClone(w)}});n.clearPendingEffects();try{b(R)}catch(O){throw n.clearPendingEffects(),E.forEach(M=>{n.appendPendingEffect(M)}),O}}}finally{l=!1}}},N=w=>{i+=1;let E=!1;try{let R=w();return E=!0,R}finally{i-=1,E&&C()}},P=({initialState:w,namespace:E})=>{let R=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:O,...M}=w,U=O===void 0?void 0:structuredClone(O),J=structuredClone(w.projectData),Z=gp({projectData:J,l10nData:U}),pe=M.global??{};if(!Xe(pe))throw new Error("Malformed global state.");let Be=pe.runtime??{};if(!Xe(Be))throw new Error("Malformed global.runtime.");let Ee=Be.localizationPackageId;if(Ee!=null&&typeof Ee!="string")throw new Error("localizationPackageId requires a string or null value");let Yr=new Set(Z.map(({l10nId:Es})=>Es).filter(Es=>Es!==null)),zr=typeof Ee=="string"&&Yr.has(Ee)?Ee:null,Yp=As({projectData:J,l10nData:U,l10nId:zr}),zp=Qc({...M,global:{...pe,localizationPackages:Z,runtime:{...Be,localizationPackageId:zr}},projectData:Yp,initialAudioCommandId:R});b.reset?.(),n=zp,o+=1,a=!0,t=0,s=at(E),i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,y=new Map,g=J,h=U,I=zr,n.appendPendingEffect({name:"handleLineActions"}),C()},T=()=>{a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,y=new Map,b.dispose?.())},V=()=>s,le=()=>n.selectPresentationState(),G=()=>n.selectPresentationChanges(),ee=w=>n.selectSectionLineChanges(w),Pe=(w={})=>{x("rendering"),t+=1;let E=Date.now();S(E);let R=f.size>0,O=v(d,E),M=R?v(f,E):new Map,J={...n.selectRenderState({activePersistentAnimations:k(O),restoredPersistentAnimations:k(M)}),id:`render-${r}-${o}-${t}`};return y.set(J.id,{builtAt:E,persistentAnimationSessions:new Map([...M.entries(),...O.entries()]),usedRestoredPersistentAnimationSessions:R}),J},Fe=(w={})=>Pe(w),oe=(w={})=>Pe(w),me=w=>{if(!a||!n)return;let E=typeof w?.id=="string"&&w.id.length>0?w.id:null,R=E?y.get(E):null;E&&y.delete(E);let O=new Map;Qa(w?.animations).forEach(M=>{let U=bn(M);if(!U)return;let J=R?.persistentAnimationSessions?.get(U)??d.get(U),Z=Math.max(0,rl(M)),pe=J?.startedAt??R?.builtAt??Date.now();O.set(U,{animation:structuredClone(M),startedAt:pe,expiresAt:pe+Z})}),d=O,R?.usedRestoredPersistentAnimationSessions&&(f=new Map)},Ae=()=>n.selectSystemState(),ye=()=>n.selectAchievements(),re=w=>n.selectAchievement(w),ce=()=>n.selectSaveSlotMap(),se=w=>n.selectSaveSlot(w),ie=w=>n.selectSaveSlotPage(w),Ue=()=>n.selectImageGallery(),ur=()=>n.selectMusicRoom(),Oe=()=>n.selectSceneReplay(),$=()=>n.selectIsSceneReplayActive(),j=()=>n.selectSkipMode(),F=()=>n.selectAutoMode(),K=()=>n.selectRuntime(),xe=()=>n.selectIsChoiceVisible(),pr=()=>n.selectIsFormVisible(),Ie=()=>n.selectActiveInteraction(),ue=()=>n.selectPendingEffects().some(w=>w?.name==="handleLineActions"||w?.name==="render"),ut=(w,E,R={})=>!Xe(E)||w!=="nextLine"?E:R.bypassChoice===!0?{...E,bypassChoice:!0}:R.interactionSource===vi?{...E,_interactionSource:vi}:E,Br=(w={})=>({type:Ai,payload:ut("nextLine",{_conditionalContinuation:!0},w)}),Ei=(w,E)=>ks(w)?{type:Ai,payload:{...w.payload,...E.payload}}:E,kp=w=>{w.savedCheckpointOccurrences.forEach(E=>{n.markSavedRollbackCheckpointTransient(E)}),w.savedCheckpointOccurrences=[]},Pp=(w,E)=>{let R=p;return p=null,!R||!Ur(R.pointer,w)||R.checkpointIndex!==E?.checkpointIndex||R.checkpointIdentity!==E?.checkpoint?[]:R.savedCheckpointOccurrences},xp=w=>{let E=m;return!E||!Ur(E.pointer,w)?null:(m=null,E)},Ep=({actionType:w,pointerBeforeAction:E,pointerAfterAction:R,cursorBeforeAction:O,cursorAfterAction:M,wasSceneReplayActive:U,isSceneReplayActive:J})=>{!R||!(!Ur(E,R)||O?.checkpoint!==M?.checkpoint||O?.checkpointIndex!==M?.checkpointIndex||w==="jumpToLine")||(m={pointer:R,appendToPrevious:t0.has(w)&&U===J&&E?.sectionId===R.sectionId&&E?.lineId!==R.lineId,reuseExistingOccurrence:n0.has(w),forceNewOccurrence:w==="jumpToLine"})},Si=w=>{w.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:w.rollbackCursor?.checkpointIndex,checkpointIdentity:w.rollbackCursor?.checkpoint,sectionId:w.pointer?.sectionId,lineId:w.pointer?.lineId}),kp(w))},Sp=(w,E,R)=>e0.has(w)?w==="resetStoryAtSection"?R?.checkpoint!==E?.checkpoint:R?.checkpoint!==E?.checkpoint&&R?.checkpointIndex>E?.checkpointIndex:!1,Rp=w=>{let E=u.at(-1);if(!E?.markCurrentCheckpointTransient)return;let R=n.selectSaveSlot({slotId:w?.slotId});R&&E.savedCheckpointOccurrences.push({slotId:w.slotId,saveSlotIdentity:R,checkpointIndex:E.rollbackCursor?.checkpointIndex,sectionId:E.pointer?.sectionId,lineId:E.pointer?.lineId})},Op=(w,E,R)=>{let O=u.at(-1);if(!O)return;let M=n.selectCurrentPointer()?.pointer,U=Sp(w,E,R);if(Ur(O.pointer,M)){let J=R?.checkpoint!==E?.checkpoint||R?.checkpointIndex!==E?.checkpointIndex;U||J&&r0.has(w)?(Si(O),O.pointer=M,O.rollbackCursor=R,O.markCurrentCheckpointTransient=U,O.savedCheckpointOccurrences=[]):J&&w==="updateProjectData"&&(O.rollbackCursor=R);return}Si(O),O.pointer=M,O.rollbackCursor=n.selectRollbackCursor?.()??null,O.markCurrentCheckpointTransient=U,O.savedCheckpointOccurrences=[]},Ht=(w,E)=>{if(x(`action "${w}"`),!n[w])return;let R=E,O,M;if(w==="updateProjectData")Ri(E),O=structuredClone(E.projectData),R={...E,projectData:As({projectData:O,l10nData:h,l10nId:I})},Ri(R);else if(w==="updateLocalizationPackage"){if(M=Cp(E),M===I)return;R={l10nId:M,projectData:As({projectData:g,l10nData:h,l10nId:M})}}ZI.has(w)&&(c+=1);let U=n.selectIsSceneReplayActive?.()===!0,J=QI.has(w)?v(d):null,Z=n.selectCurrentPointer()?.pointer??null,pe=n.selectRollbackCursor?.()??null,Be=n[w](R);O!==void 0&&(g=O),M!==void 0&&(I=M),JI.has(w)&&(f=J??new Map,d=new Map);let Ee=n.selectIsSceneReplayActive?.()===!0;U!==Ee&&(d=new Map,f=new Map);let Yr=n.selectCurrentPointer()?.pointer??null,zr=n.selectRollbackCursor?.()??null;return w==="saveSlot"&&Rp(E),Op(w,pe,zr),Ep({actionType:w,pointerBeforeAction:Z,pointerAfterAction:Yr,cursorBeforeAction:pe,cursorAfterAction:zr,wasSceneReplayActive:U,isSceneReplayActive:Ee}),C(),Be},Ri=w=>{if(!Object.prototype.hasOwnProperty.call(w??{},"projectData"))throw new Error("updateProjectData requires projectData");_r(w?.projectData?.resources?.variables??{}),gt(w.projectData),bt(w.projectData),It(w.projectData)},Cp=w=>{if(!Xe(w))throw new Error("updateLocalizationPackage requires an object payload");let E=Object.keys(w);if(E.length!==1||E[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},$p=(w,E,R)=>{let O=n.selectCurrentPointer()?.pointer;E!==O||R!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),Ht("nextLineFromSystem",w.payload))},_p=()=>({renderSequence:t,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(y),canonicalProjectData:g,localizationPackageId:I}),jp=w=>{t=w.renderSequence,c=w.conditionalRoutingSequence,u=w.rollbackNavigationContexts.slice(),p=w.pendingRollbackLineEntrySaveHandoff,m=w.pendingDialogueHistoryLineEntry,d=new Map(w.persistentAnimationSessions),f=new Map(w.restoredPersistentAnimationSessions),y=new Map(w.renderPersistentAnimationMetadata),g=w.canonicalProjectData,I=w.localizationPackageId},Oi=(w,E={})=>(x("action batch"),N(()=>{let R=_p();try{return n[Zs](()=>{let O,M=n.selectCurrentPointer()?.pointer??null,U=n.selectRollbackCursor?.()??null,J=c,Z={pointer:M,rollbackCursor:U,markCurrentCheckpointTransient:E.rollbackSource==="line",savedCheckpointOccurrences:E.savedCheckpointOccurrences?.slice()??[]};u.push(Z);try{n.beginRollbackActionBatch({source:E.rollbackSource});try{O=w()}finally{n.endRollbackActionBatch({})}ks(O)&&$p(O,M,J);let pe=n.selectCurrentPointer()?.pointer??null;E.rollbackSource==="line"&&Ur(M,pe)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:Z.savedCheckpointOccurrences,appendToPrevious:E.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:E.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:E.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!Ur(M,Z.pointer)||U?.checkpoint!==Z.rollbackCursor?.checkpoint)&&Z.markCurrentCheckpointTransient&&Z.savedCheckpointOccurrences.length>0&&(p={pointer:Z.pointer,checkpointIndex:Z.rollbackCursor?.checkpointIndex,checkpointIdentity:Z.rollbackCursor?.checkpoint,savedCheckpointOccurrences:Z.savedCheckpointOccurrences})}})}catch(O){throw jp(R),O}})),Ci=(w,E,R,O={})=>{if(w===bp)return Oi(()=>{let M=Ps(R),U=so({[w]:E},M);return $i(U[w],R,O)},O);Ht(w,E)},Np=(w,E)=>{Ci(w,E)},Ps=w=>{if(!w)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};if(Object.prototype.hasOwnProperty.call(w,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".');let{_event:E,...R}=w,O=n.selectAllVariables?n.selectAllVariables():void 0;return{...R,_event:E,variables:O,runtime:n.selectRuntime?n.selectRuntime():{}}},Dp=w=>{if(!Xe(w))return{templatePayload:w,literalTargetIds:null};let E=n.selectImageGalleryConfig();if(!Array.isArray(E?.groups))return{templatePayload:w,literalTargetIds:null};let R=typeof w.groupId=="string"?E.groups.find(M=>M.id===w.groupId):void 0;if(!R)return{templatePayload:w,literalTargetIds:null};let O=typeof w.variantId=="string"&&R.variants.some(M=>M.id===w.variantId);return{templatePayload:{...w,groupId:null,...O?{variantId:null}:{}},literalTargetIds:{groupId:w.groupId,...O?{variantId:w.variantId}:{}}}},Lp=w=>!Xe(w)||typeof w.trackId!="string"?{templatePayload:w,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(O=>O.id===w.trackId)?{templatePayload:{...w,trackId:null},literalTargetIds:{trackId:w.trackId}}:{templatePayload:w,literalTargetIds:null},Tp=w=>!Xe(w)||typeof w.sceneId!="string"?{templatePayload:w,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(O=>O.sceneId===w.sceneId)?{templatePayload:{...w,sceneId:null},literalTargetIds:{sceneId:w.sceneId}}:{templatePayload:w,literalTargetIds:null},Mp=w=>{if(!Xe(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")},qp=(w,E,R)=>{if(!Xe(w))throw new Error(`conditional branch at index ${E} must be an object`);if(!Xe(w.actions))throw new Error(`conditional branch at index ${E} requires actions object`);if(!Object.prototype.hasOwnProperty.call(w,"when")&&E!==R-1)throw new Error("conditional else branch must be the last branch")},$i=(w,E,R)=>{Mp(w);let O=Br(R);for(let M=0;M<w.branches.length;M+=1){let U=w.branches[M];qp(U,M,w.branches.length);let J=Ps(E);if(Object.prototype.hasOwnProperty.call(U,"when")&&!ht(U.when,J))continue;let pe=xs(U.actions,E,R);return ks(pe)?Ei(O,pe):O}return O},Vp=(w,E)=>({...w??{},_form:E}),Fp=(w,E,R,O)=>{let M=Ht(w,E),U=M?.submitted===!0&&M.valid===!0,J=M?.cancelled===!0;if(!(!U&&!J)&&Xe(E.actions))return xs(E.actions,Vp(R,M.form),{...O,interactionSource:vi})},Up=(w,E,R,O)=>{let M=Ps(R),U={templatePayload:E,literalTargetIds:null};w===o0?U=Dp(E):w===i0?U=Lp(E):w===a0&&(U=Tp(E));let{templatePayload:J,literalTargetIds:Z}=U,Be=so({[w]:J},M)[w],Ee=Z?{...Be,...Z}:Be;if(w===bp)return $i(Ee,R,O);let Yr=ut(w,Ee,O);if(s0.has(w))return Fp(w,Yr,R,O);Ht(w,Yr)},xs=(w,E,R)=>{let O;return Object.entries(w).forEach(([M,U])=>{let J=Up(M,U,E,R);ks(J)&&(O=Ei(O,J))}),O},_i=(w,E,R={})=>Oi(()=>xs(w,E,R),R),Bp=w=>{let E=n.selectCurrentPointer()?.pointer;if(w!==E||n.selectActiveInteraction())return;let R=n.selectNextLineConfig();R?.auto?.enabled&&R.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:R.auto.delay}})};return{init:P,dispose:T,handleAction:Ci,handleInternalAction:Np,handleActions:_i,selectRenderState:Fe,prepareRenderState:oe,commitRenderState:me,selectPresentationState:le,selectPresentationChanges:G,selectSectionLineChanges:ee,selectSystemState:Ae,selectAchievements:ye,selectAchievement:re,selectSaveSlotMap:ce,selectSaveSlot:se,selectSaveSlotPage:ie,selectSaveSlots:ce,selectImageGallery:Ue,selectMusicRoom:ur,selectSceneReplay:Oe,selectIsSceneReplayActive:$,selectRuntime:K,selectIsChoiceVisible:xe,selectIsFormVisible:pr,selectActiveInteraction:Ie,selectHasPendingRenderWork:ue,handleLineActions:w=>{x("line action handling");let E=n.selectCurrentPointer()?.pointer;if(w?.pointer&&!Ur(w.pointer,E))return!1;if(typeof w?.sceneReplaySceneId=="string"){let R=n.selectActiveSceneReplayEntry?.();if(R?.sceneId!==w.sceneReplaySceneId||R?.entryId!==w.entryId)return!1}return N(()=>{let R=n.selectCurrentPointer()?.pointer,O=n.selectRollbackCursor?.()??null,M=p,U=m,J=Pp(R,O),Z=xp(R),pe=n.selectCurrentLine(),Be=!1;if(pe?.actions){try{_i(pe.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:J,dialogueHistoryAppendToPrevious:Z?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:Z?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:Z?.forceNewOccurrence===!0})}catch(Ee){throw p=M,m=U,Ee}Be=!0}return Bp(R),Be})},getNamespace:V}}var Pi=()=>{let e=0,r=null;return{getElapsed:()=>e,setElapsed:n=>{e=n},addElapsed:n=>{e+=n},getCallback:()=>r,setCallback:n=>{r=n}}},c0=80,u0="music-room:player",vp=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Ip=(e,r)=>vp.has(e)&&r?._event?.id===u0,Ap=({engine:e,routeGraphics:r,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:a},t)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(t)??e.selectRenderState(t);n?.(s),r.render(s),a(o)&&e.commitRenderState?.(s)},p0=({engine:e,routeGraphics:r,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:t},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&Ap({engine:e,routeGraphics:r,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:t},s)},xi=({ticker:e,timerState:r,callback:n})=>{e.remove(n),r.getCallback()===n&&(r.setCallback(null),r.setElapsed(0))},d0=({engine:e,ticker:r,autoTimer:n,lifecycleGeneration:o,isCurrentLifecycle:a},t)=>{let s=n.getCallback();s&&r.remove(s),n.setElapsed(0);let i=l=>{if(!a(o)){xi({ticker:r,timerState:n,callback:i});return}n.addElapsed(l.deltaMS);let c=t.delay??1e3;n.getElapsed()>=c&&(r.remove(i),n.setCallback(null),n.setElapsed(0),Gt(e,"nextLineFromSystem",{}))};n.setCallback(i),r.add(i)},f0=({ticker:e,autoTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},m0=({engine:e,ticker:r,skipTimer:n,lifecycleGeneration:o,isCurrentLifecycle:a},t)=>{let s=n.getCallback();s&&r.remove(s),n.setElapsed(0);let i=l=>{if(!a(o)){xi({ticker:r,timerState:n,callback:i});return}n.addElapsed(l.deltaMS);let c=t?.delay??c0;n.getElapsed()>=c&&(n.setElapsed(0),Gt(e,"nextLineFromSystem",{}))};n.setCallback(i),r.add(i)},y0=({ticker:e,skipTimer:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},h0=({engine:e,ticker:r,nextLineConfigTimerState:n,lifecycleGeneration:o,isCurrentLifecycle:a},t)=>{let s=n.getCallback();s&&r.remove(s),n.setElapsed(0);let i=l=>{if(!a(o)){xi({ticker:r,timerState:n,callback:i});return}n.addElapsed(l.deltaMS);let c=t.delay??1e3;n.getElapsed()>=c&&(n.setElapsed(0),Gt(e,"nextLineFromSystem",{}),r.remove(i),n.getCallback()===i&&n.setCallback(null))};n.setCallback(i),r.add(i)},g0=({ticker:e,nextLineConfigTimerState:r},n)=>{let o=r.getCallback();o&&(e.remove(o),r.setCallback(null)),r.setElapsed(0)},b0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveSlots(r?.saveSlots))},I0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalDeviceVariables(r?.globalDeviceVariables))},w0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalAccountVariables(r?.globalAccountVariables))},v0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalRuntime(r?.globalRuntime))},A0=({enqueuePersistenceWrite:e},r)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(r?.updates)})},wp={render:Ap,saveSlots:b0,saveGlobalDeviceVariables:I0,saveGlobalAccountVariables:w0,saveGlobalRuntime:v0,applyScopedDataUpdates:A0,handleLineActions:p0,startAutoNextTimer:d0,clearAutoNextTimer:f0,startSkipNextTimer:m0,clearSkipNextTimer:y0,nextLineConfigTimer:h0,clearNextLineConfigTimer:g0},k0=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Gt=(e,r,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(r,n)},P0=(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(!k0.has(a.name)){n.unshift(a);continue}r.has(a.name)||(r.add(a.name),n.unshift(a))}return n},x0=({getEngine:e,routeGraphics:r,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:t,persistence:s,namespace:i})=>{let l=Pi(),c=Pi(),u=Pi(),p=new Map,m=Promise.resolve(),d=null,f=null,y=!1,g=0,h=0,I=!0,b=$=>{let j=$.getCallback();j&&n.remove(j),$.setCallback(null),$.setElapsed(0)},x=()=>{b(l),b(c),b(u)},v=()=>{d=null,f=null,y=!1,g=0},k=()=>{h+=1,x(),v(),I=!0},S=()=>{h+=1,I=!1,x(),v()},C=$=>I&&$===h,N=$=>{if(a){a($);return}console.error("RouteEngine persistence write failed.",$)},P=$=>{if(s)return s;let j=at($),F=p.get(j);if(F)return F;let K=bi({indexedDB:t,namespace:j});return p.set(j,K),K},T=$=>{let j=s?null:at(i??e()?.getNamespace?.()),F;m=m.catch(()=>{}).then(()=>(F=P(j),$(F))).catch(K=>{!s&&p.get(j)===F&&p.delete(j),N(K)})},V=$=>{if(!I)return;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;g+=1,d=j,y=!1},le=()=>g,G=($={})=>{if(!I||$?.aborted===!0)return!1;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;return j?j!==d||j===f?!1:(f=j,!0):d!==null||y?!1:(y=!0,!0)},ee=($,j={})=>{if(!I)return!1;if(Ip($,j)){let K=vp.get($),xe=e();return Gt(xe,K,j?._event),!0}if($!=="renderComplete"||!G(j))return!1;let F=e();return Gt(F,"markLineCompleted",{}),!0},Pe=new Set(["updateFormField","submitForm","cancelForm"]),Fe=new Set(["updateVariable"]),oe=$=>typeof $?.selectActiveInteraction=="function"?$.selectActiveInteraction():typeof $?.selectIsChoiceVisible=="function"&&$.selectIsChoiceVisible()?{source:"choice"}:null,me=$=>$?._formKey??$?.formKey,Ae=($,j)=>me($)===j?.formKey,ye=($,j)=>!$||typeof $!="object"||Array.isArray($)?!1:$._interactionSource===j?.source,re=($,j)=>ye($,j)?j.source==="form"?Ae($,j):!0:!1,ce=($,j)=>!$||typeof $!="object"||Array.isArray($)||j?.source!=="form"?!1:Ae($,j),se=($={},j)=>Object.keys($).length>0&&Object.entries($).every(([F,K])=>Pe.has(F)?ce(K,j):Fe.has(F)),ie=($={},j)=>{let F=$?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:se(F,j):re($,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(K=>re(K,j))},Ue=($,j={})=>{if(!j?.actions)return!1;let F=oe($);return!F||F.source==="choice"?!1:!ie(j,F)},ur=({preprocessPayload:$,onEvent:j}={})=>async(F,K={})=>{if(!I)return!1;if(Ip(F,K))return ee(F,K),j?.(F,K);let xe=e(),pr=h,Ie=g;if(Ue(xe,K))return j?.(F,K);let ue=await $?.(F,K)??K;if(!C(pr)||e()!==xe||g!==Ie)return!1;if(Ue(xe,ue))return j?.(F,ue);if(ee(F,ue),ue?.actions){let ut=ue?._event?{_event:ue._event}:ue?.event?{_event:ue.event}:void 0,Br;ue?.bypassChoice===!0?Br={bypassChoice:!0}:ue?._interactionSource&&(Br={interactionSource:ue._interactionSource}),Br?xe.handleActions(ue.actions,ut,Br):xe.handleActions(ue.actions,ut)}return j?.(F,ue)},Oe=$=>{if(!I)return;let j=h,F=e(),K=P0($),xe=K.some(Ie=>Ie.name==="handleLineActions");K.forEach(Ie=>{if(!wp[Ie.name]&&!o)throw new Error(`Unhandled pending effect "${Ie.name}".`)});let pr={engine:F,routeGraphics:r,ticker:n,autoTimer:l,skipTimer:c,nextLineConfigTimerState:u,trackRenderDispatch:V,getRenderDispatchCount:le,enqueuePersistenceWrite:T,lifecycleGeneration:h,isCurrentLifecycle:C};for(let Ie of K){if(!C(j))break;if(xe&&Ie.name==="render")continue;let ue=wp[Ie.name];if(ue){ue(pr,Ie.payload);continue}o(Ie,pr)}};return Oe.handleRouteGraphicsEvent=ee,Oe.createRouteGraphicsEventHandler=ur,Oe.reset=k,Oe.dispose=S,Oe},E0=x0;var S0=(e,r={})=>{let{resources:n={}}=r;return _o(e,n)};var uv=ki;export{co as DEFAULT_VISUAL_LAYER,Kr as RENDER_LAYER,er as VISUAL_LAYER,E0 as createEffectsHandler,oI as createIndexedDbPersistence,uv as default,ro as formatDate,gf as resolveComputedVariables,S0 as resolveLayoutReferences};
1
+ var nf=Object.defineProperty;var sf=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),of=(e,r)=>{for(var n in r)nf(e,n,{get:r[n],enumerable:!0})};var Ju=sf(zi=>{"use strict";Object.defineProperty(zi,"__esModule",{value:!0});function Ku(e){let r=e.length,n=0,o=0,i;for(;o<r;)n++,i=e.charCodeAt(o++),i>=55296&&i<=56319&&o<r&&(i=e.charCodeAt(o),(i&64512)===56320&&o++);return n}zi.default=Ku;Ku.code='require("ajv/dist/runtime/ucs2length").default'});var ba=Symbol.for("immer-nothing"),fa=Symbol.for("immer-draftable"),Ce=Symbol.for("immer-state");function Me(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Xr=Object.getPrototypeOf;function we(e){return!!e&&!!e[Ce]}function Cr(e){return e?Ia(e)||Array.isArray(e)||!!e[fa]||!!e.constructor?.[fa]||dn(e)||fn(e):!1}var af=Object.prototype.constructor.toString();function Ia(e){if(!e||typeof e!="object")return!1;let r=Xr(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)===af}function un(e){return we(e)||Me(15,e),e[Ce].base_}function an(e,r){pn(e)===0?Reflect.ownKeys(e).forEach(n=>{r(n,e[n],e)}):e.forEach((n,o)=>r(o,n,e))}function pn(e){let r=e[Ce];return r?r.type_:Array.isArray(e)?1:dn(e)?2:fn(e)?3:0}function Xs(e,r){return pn(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function wa(e,r,n){let o=pn(e);o===2?e.set(r,n):o===3?e.add(n):e[r]=n}function lf(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}function dn(e){return e instanceof Map}function fn(e){return e instanceof Set}function Or(e){return e.copy_||e.base_}function Ws(e,r){if(dn(e))return new Map(e);if(fn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Ia(e);if(r===!0||r==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Ce];let i=Reflect.ownKeys(o);for(let t=0;t<i.length;t++){let s=i[t],a=o[s];a.writable===!1&&(a.writable=!0,a.configurable=!0),(a.get||a.set)&&(o[s]={configurable:!0,writable:!0,enumerable:a.enumerable,value:e[s]})}return Object.create(Xr(e),o)}else{let o=Xr(e);if(o!==null&&n)return{...e};let i=Object.create(o);return Object.assign(i,e)}}function eo(e,r=!1){return mn(e)||we(e)||!Cr(e)||(pn(e)>1&&(e.set=e.add=e.clear=e.delete=cf),Object.freeze(e),r&&Object.entries(e).forEach(([n,o])=>eo(o,!0))),e}function cf(){Me(2)}function mn(e){return Object.isFrozen(e)}var uf={};function $r(e){let r=uf[e];return r||Me(0,e),r}var ht;function ka(){return ht}function pf(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function ma(e,r){r&&($r("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function Ks(e){Js(e),e.drafts_.forEach(df),e.drafts_=null}function Js(e){e===ht&&(ht=e.parent_)}function ya(e){return ht=pf(ht,e)}function df(e){let r=e[Ce];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function ha(e,r){r.unfinalizedDrafts_=r.drafts_.length;let n=r.drafts_[0];return e!==void 0&&e!==n?(n[Ce].modified_&&(Ks(r),Me(4)),Cr(e)&&(e=ln(r,e),r.parent_||cn(r,e)),r.patches_&&$r("Patches").generateReplacementPatches_(n[Ce].base_,e,r.patches_,r.inversePatches_)):e=ln(r,n,[]),Ks(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==ba?e:void 0}function ln(e,r,n){if(mn(r))return r;let o=r[Ce];if(!o)return an(r,(i,t)=>ga(e,o,r,i,t,n)),r;if(o.scope_!==e)return r;if(!o.modified_)return cn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let i=o.copy_,t=i,s=!1;o.type_===3&&(t=new Set(i),i.clear(),s=!0),an(t,(a,l)=>ga(e,o,i,a,l,n,s)),cn(e,i,!1),n&&e.patches_&&$r("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function ga(e,r,n,o,i,t,s){if(we(i)){let a=t&&r&&r.type_!==3&&!Xs(r.assigned_,o)?t.concat(o):void 0,l=ln(e,i,a);if(wa(n,o,l),we(l))e.canAutoFreeze_=!1;else return}else s&&n.add(i);if(Cr(i)&&!mn(i)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;ln(e,i),(!r||!r.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&cn(e,i)}}function cn(e,r,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&eo(r,n)}function ff(e,r){let n=Array.isArray(e),o={type_:n?1:0,scope_:r?r.scope_:ka(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},i=o,t=ro;n&&(i=[o],t=gt);let{revoke:s,proxy:a}=Proxy.revocable(i,t);return o.draft_=a,o.revoke_=s,a}var ro={get(e,r){if(r===Ce)return e;let n=Or(e);if(!Xs(n,r))return mf(e,n,r);let o=n[r];return e.finalized_||!Cr(o)?o:o===Gs(e.base_,r)?(Hs(e),e.copy_[r]=Zs(o,e)):o},has(e,r){return r in Or(e)},ownKeys(e){return Reflect.ownKeys(Or(e))},set(e,r,n){let o=va(Or(e),r);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let i=Gs(Or(e),r),t=i?.[Ce];if(t&&t.base_===n)return e.copy_[r]=n,e.assigned_[r]=!1,!0;if(lf(n,i)&&(n!==void 0||Xs(e.base_,r)))return!0;Hs(e),Qs(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 Gs(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,Hs(e),Qs(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){let n=Or(e),o=Reflect.getOwnPropertyDescriptor(n,r);return o&&{writable:!0,configurable:e.type_!==1||r!=="length",enumerable:o.enumerable,value:n[r]}},defineProperty(){Me(11)},getPrototypeOf(e){return Xr(e.base_)},setPrototypeOf(){Me(12)}},gt={};an(ro,(e,r)=>{gt[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}});gt.deleteProperty=function(e,r){return gt.set.call(this,e,r,void 0)};gt.set=function(e,r,n){return ro.set.call(this,e[0],r,n,e[0])};function Gs(e,r){let n=e[Ce];return(n?Or(n):e)[r]}function mf(e,r,n){let o=va(r,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function va(e,r){if(!(r in e))return;let n=Xr(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return o;n=Xr(n)}}function Qs(e){e.modified_||(e.modified_=!0,e.parent_&&Qs(e.parent_))}function Hs(e){e.copy_||(e.copy_=Ws(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var yf=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"&&Me(6),o!==void 0&&typeof o!="function"&&Me(7);let i;if(Cr(r)){let t=ya(this),s=Zs(r,void 0),a=!0;try{i=n(s),a=!1}finally{a?Ks(t):Js(t)}return ma(t,o),ha(i,t)}else if(!r||typeof r!="object"){if(i=n(r),i===void 0&&(i=r),i===ba&&(i=void 0),this.autoFreeze_&&eo(i,!0),o){let t=[],s=[];$r("Patches").generateReplacementPatches_(r,i,t,s),o(t,s)}return i}else Me(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(s,...a)=>this.produceWithPatches(s,l=>r(l,...a));let o,i;return[this.produce(r,n,(s,a)=>{o=s,i=a}),o,i]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Cr(e)||Me(8),we(e)&&(e=pr(e));let r=ya(this),n=Zs(e,void 0);return n[Ce].isManual_=!0,Js(r),n}finishDraft(e,r){let n=e&&e[Ce];(!n||!n.isManual_)&&Me(9);let{scope_:o}=n;return ma(o,r),ha(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 i=r[n];if(i.path.length===0&&i.op==="replace"){e=i.value;break}}n>-1&&(r=r.slice(n+1));let o=$r("Patches").applyPatches_;return we(e)?o(e,r):this.produce(e,i=>o(i,r))}};function Zs(e,r){let n=dn(e)?$r("MapSet").proxyMap_(e,r):fn(e)?$r("MapSet").proxySet_(e,r):ff(e,r);return(r?r.scope_:ka()).drafts_.push(n),n}function pr(e){return we(e)||Me(10,e),Aa(e)}function Aa(e){if(!Cr(e)||mn(e))return e;let r=e[Ce],n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=Ws(e,r.scope_.immer_.useStrictShallowCopy_)}else n=Ws(e,!0);return an(n,(o,i)=>{wa(n,o,Aa(i))}),r&&(r.finalized_=!1),n}var _e=new yf,yn=_e.produce,uk=_e.produceWithPatches.bind(_e),pk=_e.setAutoFreeze.bind(_e),dk=_e.setUseStrictShallowCopy.bind(_e),fk=_e.applyPatches.bind(_e),mk=_e.createDraft.bind(_e),yk=_e.finishDraft.bind(_e);var P={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},X={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Wr={NOT:0};var N=class extends Error{constructor(r){super(`Parse Error: ${r}`),this.name="JemplParseError"}},Re=class extends Error{constructor(r){super(`Render Error: ${r}`),this.name="JemplRenderError"}};var to=e=>{if(!e||e.trim()==="")throw new N("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new N(`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 N(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Pa=e=>{if(e.trim().endsWith(" in"))throw new N(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new N(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[r,n]=e.split(" in ");if(!n||n.trim()==="")throw new N(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=r.includes(",")?r.split(",").map(i=>i.trim()):[r.trim()];for(let i of o){if(!i)throw new N(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(i))throw new N(`Invalid loop syntax (got: '$for ${e}')`)}};var xa=(e,r,n=!1)=>{if(r===null)return new Re(`Cannot iterate over null value at '$for ${e}'`);if(r===void 0)return new Re(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof r;return n?new Re(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Re(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Ea=(e,r)=>{let n=r&&Object.keys(r).length>0?Object.keys(r).join(", "):"no custom functions provided";return new Re(`Unknown function '${e}' (${n})`)};var hf=(e,r,n={})=>{let o={},i={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(o=n.functions||{},i=n.partials||{}):typeof n=="object"&&(o=n));let s=ee(e,{functions:o,partials:i},r,{});return s===void 0?{}:s},ee=(e,r,n,o)=>{let i=r.functions||r;if(e.var&&!e.type)return be(e.var,n,o);if(e.type===P.LITERAL)return e.value;if(e.type===P.VARIABLE)return be(e.path,n,o);if(e.type===P.INTERPOLATION)return bf(e.parts,r,n,o);switch(e.type){case P.FUNCTION:return Ra(e,r,n,o);case P.BINARY:return Oa(e,r,n,o);case P.UNARY:return Ca(e,r,n,o);case P.CONDITIONAL:return wf(e,r,n,o);case P.LOOP:return xf(e,r,n,o);case P.OBJECT:return Sf(e,r,n,o);case P.ARRAY:return Rf(e,r,n,o);case P.PARTIAL:return Of(e,r,n,o);case P.PATH_REFERENCE:return Cf(e,r,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Sa=new Map,gf=e=>{let r=[],n="",o=!1;for(let i=0;i<e.length;i++){let t=e[i];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 a=s.slice(1,-1);r.push({type:"property",value:a})}else r.push({type:"property",value:s});n=""}o=!1}else n+=t}return n&&r.push({type:"property",value:n}),r},be=(e,r,n)=>{if(!e)return;if(e in n)return n[e];let o=Sa.get(e);if(!o){let t=[],s="",a=0;for(let l=0;l<e.length;l++){let u=e[l];u==="["?(a++,s+=u):u==="]"?(a--,s+=u):u==="."&&a===0?s&&(t.push(s),s=""):s+=u}s&&t.push(s),o=[];for(let l of t){let u=gf(l.trim());o.push(...u)}Sa.set(e,o)}let i=r;for(let t=0;t<o.length;t++){let s=o[t];if(s.type==="property"&&s.value in n){i=n[s.value];continue}if(i==null)return;(s.type==="property"||s.type==="index")&&(i=i[s.value])}return i},bf=(e,r,n,o)=>{let i=[];for(let t of e)if(typeof t=="string")i.push(t);else{let s=ee(t,r,n,o);i.push(s!=null?String(s):"")}return i.join("")},Ra=(e,r,n,o)=>{let i=r.functions||r,t=i[e.name];if(!t)throw Ea(e.name,i);let s=e.args.map(a=>ee(a,r,n,o));return t(...s)},dr=(e,r,n,o)=>{if(e.var&&!e.type)return be(e.var,n,o);switch(e.type){case P.VARIABLE:return be(e.path,n,o);case P.LITERAL:return e.value;case P.BINARY:return Oa(e,r,n,o);case P.UNARY:return Ca(e,r,n,o);case P.FUNCTION:return Ra(e,r,n,o);default:return ee(e,r,n,o)}},Oa=(e,r,n,o)=>{if(e.op===X.AND||e.op===X.OR){let s=dr(e.left,r,n,o),a=dr(e.right,r,n,o);switch(e.op){case X.AND:return s&&a;case X.OR:return s||a}}let i=ee(e.left,r,n,o),t=ee(e.right,r,n,o);switch(e.op){case X.EQ:return i==t;case X.NEQ:return i!=t;case X.GT:return i>t;case X.LT:return i<t;case X.GTE:return i>=t;case X.LTE:return i<=t;case X.IN:return Array.isArray(t)?t.includes(i):!1;case X.ADD:if(typeof i!="number"||typeof t!="number")throw new Re(`Arithmetic operations require numbers. Got ${typeof i} + ${typeof t}`);return i+t;case X.SUBTRACT:if(typeof i!="number"||typeof t!="number")throw new Re(`Arithmetic operations require numbers. Got ${typeof i} - ${typeof t}`);return i-t;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ca=(e,r,n,o)=>{let i=e.op===Wr.NOT?dr(e.operand,r,n,o):ee(e.operand,r,n,o);if(e.op===Wr.NOT)return!i;throw new Error(`Unknown unary operator: ${e.op}`)},If=(e,r,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let i=e.conditions[0];if(i.type===P.VARIABLE)if(be(i.path,n,o)){let s=e.bodies[0];if(s.type===P.OBJECT&&s.properties.length<=5){let a={};for(let l of s.properties){let u=l.parsedKey?ee(l.parsedKey,r,n,o):l.key,c=l.value;if(c.type===P.LITERAL)a[u]=c.value;else if(c.type===P.VARIABLE)a[u]=be(c.path,n,o);else if(c.type===P.INTERPOLATION){let p=[];for(let m of c.parts)if(typeof m=="string")p.push(m);else if(m.type===P.VARIABLE){let d=be(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=ee(m,r,n,o);p.push(d!=null?String(d):"")}a[u]=p.join("")}else a[u]=ee(c,r,n,o)}return a}}else{let s=e.bodies[1];if(s.type===P.OBJECT&&s.properties.length<=5){let a={};for(let l of s.properties){let u=l.parsedKey?ee(l.parsedKey,r,n,o):l.key,c=l.value;if(c.type===P.LITERAL)a[u]=c.value;else if(c.type===P.VARIABLE)a[u]=be(c.path,n,o);else if(c.type===P.INTERPOLATION){let p=[];for(let m of c.parts)if(typeof m=="string")p.push(m);else if(m.type===P.VARIABLE){let d=be(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=ee(m,r,n,o);p.push(d!=null?String(d):"")}a[u]=p.join("")}else a[u]=ee(c,r,n,o)}return a}}}return null},wf=(e,r,n,o)=>{let i=If(e,r,n,o);if(i!==null)return i;for(let t=0;t<e.conditions.length;t++){let s=e.conditions[t];if(s===null||dr(s,r,n,o))return ee(e.bodies[t],r,n,o)}return $a},kf=(e,r)=>{let n=e.body,o=e.itemVar;if(n.type===P.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===P.VARIABLE){let i=n.conditions[0].path,t=n.bodies[0];if(i.startsWith(o+".")){let s=i.substring(o.length+1);if(t.type===P.OBJECT&&t.properties.length<=5){for(let l of t.properties)if(l.parsedKey)return null;let a=[];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===P.LITERAL)c[m]=d.value;else if(d.type===P.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===P.INTERPOLATION){let f=[],y=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===P.VARIABLE){let h=g.path;if(h===o)f.push(u!=null?String(u):"");else if(h.startsWith(o+".")){let w=h.substring(o.length+1),b=u[w];f.push(b!=null?String(b):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;c[m]=f.join("")}else return null}a.push(c)}}return a}}}return null},vf=(e,r)=>{let n=e.body,o=e.itemVar,i=kf(e,r);if(i!==null)return i;if(n.type===P.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let a of n.properties)if(a.parsedKey)return null;let t=[],s=!0;for(let a of n.properties){let l=a.key,u=a.value;if(u.type===P.LITERAL)t.push({key:l,type:"literal",value:u.value});else if(u.type===P.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===P.INTERPOLATION&&u.parts.length===1){let c=u.parts[0];if(c.type===P.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 a=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];a[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):""}a[l]=c}return a}}return null},Af=(e,r,n,o,i)=>{let t=[],s=e.body;if(s.type===P.OBJECT&&s.fast!==!1){let a=e.itemVar,l=e.indexVar;for(let u=0;u<i.length;u++){let c=i[u],p={},m={...o,[a]: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__,[a]:`${d}[${u}]`,...l&&{[l]:u}};for(let f of s.properties){let y=f.parsedKey?ee(f.parsedKey,r,n,m):f.key,g=f.value;if(g.type===P.LITERAL)p[y]=g.value;else if(g.type===P.VARIABLE){let h=g.path;if(h===a)p[y]=c;else if(h===l)p[y]=u;else if(h.startsWith(a+".")){let w=h.substring(a.length+1);!w.includes(".")&&!w.includes("[")?p[y]=c[w]:p[y]=be(h,n,{...o,[a]:c,...l&&{[l]:u}})}else p[y]=be(h,n,{...o,[a]:c,...l&&{[l]:u}})}else if(g.type===P.INTERPOLATION){let h=[];for(let w of g.parts)if(typeof w=="string")h.push(w);else if(w.type===P.VARIABLE){let b=w.path,E;if(b===a)E=c;else if(b===l)E=u;else if(b.startsWith(a+".")){let k=b.substring(a.length+1);!k.includes(".")&&!k.includes("[")?E=c[k]:E=be(b,n,{...o,[a]:c,...l&&{[l]:u}})}else E=be(b,n,{...o,[a]:c,...l&&{[l]:u}});h.push(E!=null?String(E):"")}else{let b={...o,[a]:c,...l&&{[l]:u}},E=ee(w,r,n,b);h.push(E!=null?String(E):"")}p[y]=h.join("")}else{let h={...o,[a]:c,...l&&{[l]:u}};p[y]=ee(g,r,n,h)}}t.push(p)}return t}return null},Pf=(e,r,n)=>{let o=e.body;if(o.type===P.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let t=o.properties[0].value;if(t.type===P.CONDITIONAL&&t.conditions.length===1&&t.conditions[0].type===P.VARIABLE&&t.conditions[0].path==="item.visible"){let s=t.bodies[0];if(s.type===P.OBJECT&&s.properties.length===2){let a=s.properties[0],l=s.properties[1];if(a.key==="id"&&a.value.type===P.VARIABLE&&a.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===P.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},xf=(e,r,n,o)=>{let i=ee(e.iterable,r,n,o);if(!Array.isArray(i)){let u,c=!1;if(e.iterable.type===P.FUNCTION){c=!0;let m=e.iterable.args.map(d=>d.type===P.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===P.VARIABLE?d.path:d.type===P.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 xa(p,i,c)}if(!e.indexVar){let u=Pf(e,i,e.itemVar);if(u!==null)return u}if(!e.indexVar){let u=vf(e,i);if(u!==null)return u}let t=Af(e,r,n,o,i);if(t!==null)return t;let s=[],a=e.iterable.path||"";if(o&&o.__paths__&&a){let u=a.split("."),c=u[0];c in o.__paths__&&(a=o.__paths__[c],u.length>1&&(a+="."+u.slice(1).join(".")))}let l=!1;e.body.type===P.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(u=>u.type===P.OBJECT&&u.properties.some(c=>c.key.startsWith("$if ")||c.key.startsWith("$when "))));for(let u=0;u<i.length;u++){let c=e.indexVar?{...o,[e.itemVar]:i[u],[e.indexVar]:u}:{...o,[e.itemVar]:i[u]};c.__paths__||(c.__paths__=o.__paths__||{}),c.__paths__={...c.__paths__,[e.itemVar]:`${a}[${u}]`},e.indexVar&&(c.__paths__[e.indexVar]=u);let p=ee(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},Ef=(e,r,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let i=e.properties[0],t=i.parsedKey?ee(i.parsedKey,r,n,o):i.key,s=i.value;if(s.type===P.OBJECT&&s.properties.length<=10&&!s.whenCondition){let a={},l={},u=!0;for(let c of s.properties){let p=c.parsedKey?ee(c.parsedKey,r,n,o):c.key,m=c.value;if(m.type===P.LITERAL)l[p]=m.value;else if(m.type===P.VARIABLE)l[p]=be(m.path,n,o);else if(m.type===P.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===P.VARIABLE){let y=be(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===P.OBJECT&&m.properties.length<=5){let d={};for(let f of m.properties){let y=f.key,g=f.value;if(g.type===P.LITERAL)d[y]=g.value;else if(g.type===P.VARIABLE)d[y]=be(g.path,n,o);else if(g.type===P.INTERPOLATION){let h=[];for(let w of g.parts)if(typeof w=="string")h.push(w);else if(w.type===P.VARIABLE){let b=be(w.path,n,o);h.push(b!=null?String(b):"")}else{u=!1;break}if(!u)break;d[y]=h.join("")}else{u=!1;break}}if(!u)break;l[p]=d}else{u=!1;break}}if(u)return a[t]=l,a}}return null},Sf=(e,r,n,o)=>{let i=r.functions||r;if(e.whenCondition&&!dr(e.whenCondition,i,n,o))return;let t=Ef(e,r,n,o);if(t!==null)return t;if(e.fast){let u={};for(let c of e.properties){let p=c.parsedKey?ee(c.parsedKey,r,n,o):c.key,m=c.value;if(m.type===P.LITERAL)u[p]=m.value;else if(m.type===P.VARIABLE)u[p]=be(m.path,n,o);else if(m.type===P.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===P.VARIABLE){let y=be(f.path,n,o);d.push(y!=null?String(y):"")}else{let y=ee(f,r,n,o);d.push(y!=null?String(y):"")}u[p]=d.join("")}else u[p]=ee(m,r,n,o)}return u}let s={},a=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=ee(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 ee(u.value,r,n,o)}else{let c=u.value;if(c&&c.type===P.OBJECT&&c.properties){let p=c.properties.find(m=>m.key.startsWith("$for "));if(p){let m=ee(p.value,r,n,o);m!==void 0&&(s[u.key]=m)}else{let m=ee(u.value,r,n,o);m!==void 0&&(s[u.key]=m)}}else{let p=u.parsedKey?ee(u.parsedKey,r,n,o):u.key,m=ee(u.value,r,n,o);m!==void 0&&(s[p]=m)}}return s},$a={},Rf=(e,r,n,o)=>{let i=[];for(let t of e.items)if(t.type===P.LOOP){let s=ee(t,r,n,o);Array.isArray(s)&&t.flatten!==!1?i.push(...s):i.push(s)}else{let s=ee(t,r,n,o);s!==$a&&s!==void 0&&i.push(s)}return i},Of=(e,r,n,o)=>{let{name:i,data:t,whenCondition:s}=e,a=r.partials||{},l=r.functions||r;if(s&&!dr(s,l,n,o))return;if(!a[i])throw new Re(`Partial '${i}' is not defined`);let u=o._partialStack||[];if(u.includes(i))throw new Re(`Circular partial reference detected: ${i}`);let c=a[i],p=n,m={...o,_partialStack:[...u,i]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(t){let d=ee(t,r,n,o);p={...p,...d}}return ee(c,r,p,m)},Cf=(e,r,n,o)=>{let{path:i}=e,t=i.split("."),s=t[0],a=t.slice(1);if(!o||!(s in o))throw new Re(`Path reference '#{${i}}' refers to '${s}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(s in o.__paths__))throw new Re(`Path reference '#{${i}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[s];if(typeof l=="number"){if(a.length>0)throw new Re(`Path reference '#{${i}}' - cannot access properties on index variable '${s}'`);return String(l)}return a.length>0&&(l+="."+a.join(".")),l};var no=hf;var $f=/\$\{([^}]*)\}/g,_f=/#\{([^}]*)\}/g,Ta=(e,r={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,i]=n,t=Tf(i,r);return{isFunction:!0,type:P.FUNCTION,name:o,args:t}},Tf=(e,r={})=>e.trim()?Nf(e).map(o=>jf(o.trim(),r)):[],Nf=e=>{let r=[],n="",o=0,i=!1,t="";for(let s=0;s<e.length;s++){let a=e[s],l=s>0?e[s-1]:"";!i&&(a==='"'||a==="'")?(i=!0,t=a,n+=a):i&&a===t&&l!=="\\"?(i=!1,t="",n+=a):!i&&a==="("?(o++,n+=a):!i&&a===")"?(o--,n+=a):!i&&a===","&&o===0?(r.push(n),n=""):n+=a}return n&&r.push(n),r},jf=(e,r={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:P.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:P.LITERAL,value:parseFloat(e)};if(e==="true")return{type:P.LITERAL,value:!0};if(e==="false")return{type:P.LITERAL,value:!1};if(e==="null")return{type:P.LITERAL,value:null};let n=Ta(e,r);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),i=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],t=-1,s=null;for(let{op:a,type:l}of i){let u=0;for(;u<o.length;){let c=_r(o.substring(u),a);if(c===-1)break;let p=u+c;p>t&&(t=p,s={op:a,type:l}),u=p+a.length}}if(t!==-1)try{return ke(o,r)}catch{return{type:P.VARIABLE,path:o}}return{type:P.VARIABLE,path:o}},Na=/^\w+\(.*\)$/,Df=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Lf=e=>{if(!(!e||e.trim()===""||Na.test(e))&&Df.test(e))throw e.includes("?")&&e.includes(":")?new N(`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 N(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new N(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},_a=e=>{let r=e.trim();if(Na.test(r))throw new N(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(r.includes("["))throw new N(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(r))throw new N(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(r))throw new N(`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 N(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:P.PATH_REFERENCE,path:r}},bt=(e,r={})=>{let n=e.trim();Lf(n);let o=Ta(n,r);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let i=0;for(let t of n)t==="["?i++:t==="]"&&i--;if(i!==0)throw new Error("Invalid array index syntax")}return{type:P.VARIABLE,path:n}},so=(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 i=[...n.matchAll($f)],t=[...n.matchAll(_f)],s=[...i.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:P.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"?bt(u[1],r):_a(u[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:P.LITERAL,value:n};throw p}}let a=[],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&&a.push(f)}try{let f;c==="variable"?f=bt(m.trim(),r):f=_a(m.trim()),a.push(f)}catch(f){if(f.message==="Invalid array index syntax")a.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&&a.push(u)}return{type:P.INTERPOLATION,parts:a}};var ao=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),La=e=>Object.keys(e),Ee=e=>e.join("."),fr=(e,r,n)=>{let o=La(e).filter(i=>!r.has(i));if(o.length>0)throw new N(`Unexpected key '${o[0]}' in condition JSON at '${Ee(n)}'`)},mr=(e,r)=>typeof e=="string"?so(e,r):typeof e=="object"&&e!==null?Array.isArray(e)?Vf(e,r):qf(e,r):{type:P.LITERAL,value:e},Mf=e=>{let{$each:r,...n}=e;if(typeof r!="string")throw new N("$each value must be a non-empty string");let o=r.trim();if(o==="")throw new N("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new N("Empty $each body not allowed");if(n.$partial!==void 0)throw new N("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},Vf=(e,r)=>{let n=[],o=!1;for(let i=0;i<e.length;i++){let t=e[i];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(t.$each!==void 0)try{let l=Mf(t),u=Object.keys(l);if(u.length===1&&/^\$for(?::\w+)?\s/.test(u[0])){let c=Da(u[0],l[u[0]],r,!0);n.push(c),o=!0;continue}}catch(l){throw l instanceof N?l:new N(l.message)}let a=Object.keys(t);if(a.length===1&&/^\$for(?::\w+)?\s/.test(a[0])){let l=Da(a[0],t[a[0]],r);n.push(l),o=!0;continue}}let s=mr(t,r);n.push(s),(s.type===P.FUNCTION||s.type===P.CONDITIONAL||s.type===P.LOOP||s.type===P.PARTIAL||s.type===P.OBJECT&&!s.fast||s.type===P.ARRAY&&!s.fast)&&(o=!0)}return{type:P.ARRAY,items:n,fast:!o}},qf=(e,r)=>{let n=[],o=!1,i=null,t=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new N("$partial value must be a string");if(e.$partial.trim()==="")throw new N("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],u=[];for(let[h]of t)for(let w of l)if(h===w||h.startsWith(w+" ")||h.startsWith(w+"#")){u.push(w);break}if(u.length>0)throw new N(`Cannot use $partial with ${u.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:c,$when:p,...m}=e,d={},f=!1;for(let[h,w]of Object.entries(m)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),d[b]=w,f=!0}let y=null;if(f&&(y=mr(d,r),y.type===P.OBJECT)){let h=!1;for(let w of y.properties)if(w.value.type===P.VARIABLE||w.value.type===P.INTERPOLATION||w.value.type===P.FUNCTION||w.value.type===P.CONDITIONAL||w.value.type===P.OBJECT&&!w.value.fast||w.value.type===P.ARRAY&&!w.value.fast){h=!0;break}h&&(y.fast=!1)}let g={type:P.PARTIAL,name:c,data:y};return p!==void 0&&(g.whenCondition=ja(p,r)),g}for(let[l,u]of t)if(l==="$when"){if(i!==null)throw new N("Multiple '$when' directives on the same object are not allowed");if(u==null)throw new N("Missing condition expression after '$when'");i=ja(u,r),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new N("'$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 N("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let c=Ff(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 N(`$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 N(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new N("Missing condition expression after '$if'");{let c=mr(u,r);(c.type===P.FUNCTION||c.type===P.CONDITIONAL||c.type===P.PARTIAL||c.type===P.OBJECT&&!c.fast||c.type===P.ARRAY&&!c.fast)&&(o=!0);let p=so(l,r),m={key:l,value:c};(p.type!==P.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let a={type:P.OBJECT,properties:n,fast:!o};return i&&(a.whenCondition=i),a},Ff=(e,r,n={})=>{let o=[],i=[],t=r,[s,a]=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 N(`Invalid conditional syntax: ${s}`)}else u=s.substring(4),u.endsWith(":")&&(u=u.slice(0,-1).trim());to(u);let c=ke(u,n);for(o.push(c),i.push(mr(a,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{to(f);let y=ke(f,n);o.push(y)}if(i.push(mr(m,n)),t++,f===null)break}else break}return{node:{type:P.CONDITIONAL,conditions:o,bodies:i,id:l},nextIndex:t}},oo={eq:X.EQ,neq:X.NEQ,gt:X.GT,gte:X.GTE,lt:X.LT,lte:X.LTE,in:X.IN,add:X.ADD,sub:X.SUBTRACT},io={all:X.AND,any:X.OR},Uf=new Set(["var","literal","call","not",...Object.keys(oo),...Object.keys(io)]),Bf=(e,r,n)=>{if(!Array.isArray(e))throw new N(`Condition JSON operator '${r}' at '${Ee(n)}' requires an array`);if(e.length!==2)throw new N(`Condition JSON operator '${r}' at '${Ee(n)}' requires exactly 2 operands`);return e},zf=(e,r,n,o,i)=>{if(!Array.isArray(e))throw new N(`Condition JSON operator '${r}' at '${Ee(i)}' requires an array`);if(e.length===0)throw new N(`Condition JSON operator '${r}' at '${Ee(i)}' requires at least 1 condition`);return e.map((s,a)=>$e(s,o,[...i,a])).reduce((s,a)=>({type:P.BINARY,op:n,left:s,right:a}))},Yf=(e,r,n)=>{let o,i;if(typeof e.call=="string")o=e.call,i=e.args??[],fr(e,new Set(["call","args"]),n);else if(ao(e.call))o=e.call.name,i=e.call.args??[],fr(e,new Set(["call"]),n),fr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new N(`Condition JSON call at '${Ee(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new N(`Condition JSON call at '${Ee(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new N(`Invalid condition JSON function name '${o}' at '${Ee(n)}'`);if(!Array.isArray(i))throw new N(`Condition JSON call '${o}' at '${Ee(n)}' requires args to be an array`);return{type:P.FUNCTION,name:o,args:i.map((t,s)=>$e(t,r,[...n,"args",s]))}},$e=(e,r={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:P.LITERAL,value:e};if(Array.isArray(e))throw new N(`Condition JSON array at '${Ee(n)}' must be wrapped in an operator or { literal: [...] }`);if(!ao(e))throw new N(`Invalid condition JSON value at '${Ee(n)}'`);let o=La(e);if(o.length===0)throw new N(`Condition JSON object at '${Ee(n)}' must contain an operator`);let i=o.filter(s=>Uf.has(s));if(i.length===0)throw new N(`Unknown condition JSON operator '${o[0]}' at '${Ee(n)}'`);if(i.length>1)throw new N(`Condition JSON at '${Ee(n)}' must contain exactly one operator`);let t=i.includes("call")?"call":i[0];if(t==="var"){if(fr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new N(`Condition JSON var at '${Ee(n)}' requires a non-empty path`);return{type:P.VARIABLE,path:e.var}}if(t==="literal")return fr(e,new Set(["literal"]),n),{type:P.LITERAL,value:e.literal};if(t==="call")return Yf(e,r,n);if(t==="not")return fr(e,new Set(["not"]),n),{type:P.UNARY,op:Wr.NOT,operand:$e(e.not,r,[...n,"not"])};if(t in io)return fr(e,new Set([t]),n),zf(e[t],t,io[t],r,[...n,t]);if(t in oo){fr(e,new Set([t]),n);let s=Bf(e[t],t,[...n,t]);return{type:P.BINARY,op:oo[t],left:$e(s[0],r,[...n,t,0]),right:$e(s[1],r,[...n,t,1])}}throw new N(`Unknown condition JSON operator '${t}' at '${Ee(n)}'`)},ja=(e,r={})=>{if(e==null)throw new N("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new N("Empty condition expression after '$when'");return ke(e,r)}return ao(e)||Array.isArray(e)?$e(e,r):{type:P.LITERAL,value:e}},ke=(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 ke(u,r)}let n=_r(e,"||");if(n!==-1)return{type:P.BINARY,op:X.OR,left:ke(e.substring(0,n).trim(),r),right:ke(e.substring(n+2).trim(),r)};let o=_r(e,"&&");if(o!==-1)return{type:P.BINARY,op:X.AND,left:ke(e.substring(0,o).trim(),r),right:ke(e.substring(o+2).trim(),r)};let i=[{op:">=",type:X.GTE},{op:"<=",type:X.LTE},{op:"==",type:X.EQ},{op:"!=",type:X.NEQ},{op:">",type:X.GT},{op:"<",type:X.LT},{op:" in ",type:X.IN}];for(let{op:u,type:c}of i){let p=_r(e,u);if(p!==-1)return{type:P.BINARY,op:c,left:ke(e.substring(0,p).trim(),r),right:ke(e.substring(p+u.length).trim(),r)}}let t=-1,s=null,a=[{op:" + ",type:X.ADD},{op:" - ",type:X.SUBTRACT}];for(let{op:u,type:c}of a){let p=0;for(;p<e.length;){let m=_r(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:P.BINARY,op:s.type,left:ke(e.substring(0,t).trim(),r),right:ke(e.substring(t+s.op.length).trim(),r)};let l=[" * "," / "," % "];for(let u of l)if(_r(e,u)!==-1)throw new N(`Arithmetic operations are not allowed in conditionals: "${u}"`);return e.startsWith("!")?{type:P.UNARY,op:Wr.NOT,operand:ke(e.substring(1).trim(),r)}:Ma(e,r)},_r=(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},Gf=e=>{if(e=e.trim(),e==="true")return{type:P.LITERAL,value:!0};if(e==="false")return{type:P.LITERAL,value:!1};if(e==="null")return{type:P.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:P.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:P.LITERAL,value:""};if(e==="{}")return{type:P.LITERAL,value:{}};if(e==="[]")return{type:P.LITERAL,value:[]};let r=Number(e);return!isNaN(r)&&isFinite(r)?{type:P.LITERAL,value:r}:{type:P.VARIABLE,path:e}},Ma=(e,r)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return bt(n,r);let i=Gf(n);if(i.type===P.LITERAL)return i;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:P.VARIABLE,path:n};try{return bt(n,r)}catch(t){if(t.message&&t.message.includes("not supported"))return i;throw t}},Hf=(e,r=!1)=>{let n=r?"$each":"$for";try{Pa(e)}catch(o){if(o instanceof N&&r){let i=o.message.replace(/\$for/g,"$each");throw new N(i.replace("Parse Error: ",""))}throw o}},Da=(e,r,n,o=!1)=>{let i=/^\$for(?::(\w+))?\s+(.+)$/,t=e.match(i);if(!t){let g=o?"$each":"$for";throw new N(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=t[1],a=t[2].trim();Hf(a,o);let l=a.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new N(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${a}')`)}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 N(`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 N(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new N(`Reserved variable name: ${m}`);let f=Ma(c,n),y=mr(r,n);return{type:P.LOOP,itemVar:p,indexVar:m,iterable:f,body:y,flatten:s!=="nested"}};var Xf=(e,r={})=>{let{functions:n={}}=r;return mr(e,n)},hn=Xf;var It={};of(It,{now:()=>Wf});var Wf=()=>Date.now();var Kf=(e,r,n={})=>{let{functions:o={},partials:i={}}=n,t={...It,...o},s=hn(e,{functions:t}),a={};for(let[l,u]of Object.entries(i))a[l]=hn(u,{functions:t});return no(s,r,{functions:t,partials:a})},Tr=Kf;var Jf=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Qf=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Zf=(e,r)=>{if(Jf(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new N("Empty condition expression");return ke(e,r)}return $e(e,r)},em=(e,r={},n={})=>{let o=Qf(n),i={...It,...o},t=Zf(e,i);return!!dr(t,{functions:i,partials:{}},r,{})},lo=em;var bo=Symbol("runStoreTransaction"),fo="__routeEngineConditionComparison",gn=(e,r)=>typeof e=="number"&&typeof r=="number"&&Number.isFinite(e)&&Number.isFinite(r)||typeof e=="string"&&typeof r=="string",yr=Object.freeze({eq:(e,r)=>e===r,neq:(e,r)=>e!==r,gt:(e,r)=>gn(e,r)&&e>r,gte:(e,r)=>gn(e,r)&&e>=r,lt:(e,r)=>gn(e,r)&&e<r,lte:(e,r)=>gn(e,r)&&e<=r}),Ga=Object.freeze(Object.fromEntries(Object.keys(yr).map(e=>[e,`${fo}${e}`]))),rm=Object.freeze(Object.fromEntries(Object.entries(Ga).map(([e,r])=>[r,yr[e]]))),Va=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),tm=e=>{if(typeof e?.call=="string")return e.call;if(e?.call!==null&&typeof e?.call=="object"&&!Array.isArray(e.call))return e.call.name},bn=e=>{if(Array.isArray(e))return e.map(bn);if(e===null||typeof e!="object"||Va(e,"literal")||Va(e,"var"))return e;if(tm(e)?.startsWith(fo))throw new Error(`Condition function names beginning with "${fo}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,i]]=n,t=Ga[o];if(t)return{call:t,args:i.map(bn)}}return Object.fromEntries(n.map(([o,i])=>[o,bn(i)]))},kt=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return $e(e),lo(bn(e),r,{functions:rm})},nm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Ha=(e,r,n={})=>{let o={},i={},{transformSelectorFirstArgument:t=y=>y,transformActionFirstArgument:s=y=>y,createTransactionalMetadata:a,updateTransactionalMetadata:l,finalizeTransactionalMetadata:u}=n,c=typeof a=="function",p={state:structuredClone(e),...c?{transactionalMetadata:structuredClone(a())}:{}},m=0,d=(y,g)=>!c||!u?y:yn(y,h=>{u({state:h.state,transactionalMetadata:h.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[y,g]of Object.entries(r))y!=="createInitialState"&&(y.startsWith("select")?o[y]=(...h)=>g(t(p.state,p.transactionalMetadata),...h):i[y]=(...h)=>{let w,b=p,E=yn(p,k=>{let A=g(s(k.state,k.transactionalMetadata),...h);w=A!==void 0&&!we(A)?A:void 0,c&&l&&l({actionName:y,args:h,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});return m===0&&(E=d(E,b)),p=E,w});let f=y=>{if(typeof y!="function")throw new Error("Store transaction requires a callback");let g=p,h=m===0;m+=1;let w;try{w=y()}catch(b){throw m-=1,p=g,b}if(m-=1,h)try{p=d(p,g)}catch(b){throw p=g,b}return w};return{...o,...i,[bo]:f}},vn=(e,r)=>n=>{let o=e(),i=Array.isArray(n)?n:[n];return yn(o,t=>{i.forEach(s=>{r.forEach(a=>{a(t,s)})})})};var sm=(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{}}},H=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),mo=(e,r,n)=>{Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0})},Ie=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),om=new Set(["pageSize","groups"]),im=new Set(["id","variants"]),am=new Set(["id","imageId"]),lm=new Set(["pageSize","tracks"]),cm=new Set(["id","soundId","title","artist","album","description","coverImageId"]),um=new Set(["pageSize","replays"]),pm=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Nr=(e,r,n)=>{Object.keys(e).forEach(o=>{if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},Kr=(e,r)=>{if(typeof e!="string"||e.length===0)throw new Error(`${r} must be a non-empty string`)},vt=(e={})=>{let r=e?.resources?.imageGallery;if(r===void 0)return;if(!Ie(r))throw new Error("resources.imageGallery must be an object");if(Nr(r,om,"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,i]of r.groups.entries()){let t=`resources.imageGallery.groups[${o}]`;if(!Ie(i))throw new Error(`${t} must be an object`);if(Nr(i,im,t),Kr(i.id,`${t}.id`),n.has(i.id))throw new Error(`Duplicate image gallery group id "${i.id}"`);if(n.add(i.id),!Array.isArray(i.variants)||i.variants.length===0)throw new Error(`${t}.variants must be a non-empty array`);let s=new Set;for(let[a,l]of i.variants.entries()){let u=`${t}.variants[${a}]`;if(!Ie(l))throw new Error(`${u} must be an object`);if(Nr(l,am,u),Kr(l.id,`${u}.id`),Kr(l.imageId,`${u}.imageId`),s.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${i.id}"`);if(s.add(l.id),!H(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${i.id}.${l.id}" references unknown image "${l.imageId}"`)}}},At=(e={})=>{let r=e?.resources?.musicRoom;if(r===void 0)return;if(!Ie(r))throw new Error("resources.musicRoom must be an object");if(Nr(r,lm,"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,i]of r.tracks.entries()){let t=`resources.musicRoom.tracks[${o}]`;if(!Ie(i))throw new Error(`${t} must be an object`);Nr(i,cm,t);for(let l of["id","soundId","title"])Kr(i[l],`${t}.${l}`);for(let l of["artist","album","description","coverImageId"])i[l]!==void 0&&Kr(i[l],`${t}.${l}`);if(n.has(i.id))throw new Error(`Duplicate music room track id "${i.id}"`);n.add(i.id);let s=e?.resources?.sounds?.[i.soundId];if(!H(e?.resources?.sounds,i.soundId))throw new Error(`Music room track "${i.id}" references unknown sound "${i.soundId}"`);if(!Ie(s))throw new Error(`Music room track "${i.id}" references invalid sound "${i.soundId}"`);if(s.playbackRate!==void 0&&(typeof s.playbackRate!="number"||!Number.isFinite(s.playbackRate)||s.playbackRate<=0))throw new Error(`Music room sound "${i.soundId}" playbackRate must be a finite number greater than 0`);let a=s.startAt??0;if(typeof a!="number"||!Number.isFinite(a)||a<0)throw new Error(`Music room sound "${i.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<=a))throw new Error(`Music room sound "${i.soundId}" endAt must be a finite number greater than startAt`);if(i.coverImageId!==void 0&&!H(e?.resources?.images,i.coverImageId))throw new Error(`Music room track "${i.id}" references unknown cover image "${i.coverImageId}"`)}},dm=(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}"`)}},Pt=(e={})=>{let r=e?.resources?.sceneReplay;if(r===void 0)return;if(!Ie(r))throw new Error("resources.sceneReplay must be an object");if(Nr(r,um,"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[i,t]of r.replays.entries()){let s=`resources.sceneReplay.replays[${i}]`;if(!Ie(t))throw new Error(`${s} must be an object`);Nr(t,pm,s);for(let c of["sceneId","title","thumbnailImageId"])Kr(t[c],`${s}.${c}`);if(o.has(t.sceneId))throw new Error(`Duplicate scene replay sceneId "${t.sceneId}"`);if(o.add(t.sceneId),!H(e?.resources?.images,t.thumbnailImageId))throw new Error(`Scene replay scene "${t.sceneId}" references unknown thumbnail image "${t.thumbnailImageId}"`);let a=n[t.sceneId];if(!a)throw new Error(`Scene replay references unknown scene "${t.sceneId}"`);let l=a.initialSectionId,u=a.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(!Ie(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(Se(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}"`);dm(c,m,p)}}}},Xa=e=>{let r=we(e)?pr(e):e;return structuredClone(r)},fm=({characterId:e,resourceCharacter:r,variables:n={}}={})=>{if(!H(r,"nameVariableId"))return;let o=r.nameVariableId,i=n?.[o];if(typeof i!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return i},An=({characterId:e,character:r,characterName:n,characters:o={},variables:i={}}={})=>{let t=e?o?.[e]:void 0;if(r?.name!==void 0)return r.name;if(n!==void 0)return n;let s=fm({characterId:e,resourceCharacter:t,variables:i});return s!==void 0?s:t?.name||""},Se=e=>H(e,"computed"),Io=(e,r)=>{switch(e?.type){case"number":return typeof r=="number"&&Number.isFinite(r);case"boolean":return typeof r=="boolean";case"string":return typeof r=="string";case"object":return r!==null&&typeof r=="object"&&!Array.isArray(r);default:return!1}},xt=(e={},r={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([i,t])=>{let s=r[i];return s===void 0?o:!Se(s)&&(!n||n.includes(s.scope))&&Io(s,t)})),qe=(e,r)=>new Error(`${r} has invalid path: ${JSON.stringify(e)}`),mm=(e,r,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw qe(r,n)}let i="";for(let t=1;t<e.length-1;t+=1){let s=e[t];if(s!=="\\"){if(s.charCodeAt(0)<32)throw qe(r,n);i+=s;continue}if(t+=1,t>=e.length-1)throw qe(r,n);let a=e[t];if(a==="u"){let u=e.slice(t+1,t+5);if(u.length!==4||!/^[0-9a-fA-F]{4}$/.test(u))throw qe(r,n);i+=String.fromCharCode(Number.parseInt(u,16)),t+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
+ `,r:"\r",t:" ",b:"\b",f:"\f"};if(!H(l,a))throw qe(r,n);i+=l[a]}return i},Wa=(e,r="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw qe(e,r);let n=[],o=0,i=()=>{let s=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let a=e.slice(s,o);if(a.length===0||a.trim()!==a||/\s/.test(a))throw qe(e,r);n.push(a)},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 qe(e,r);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw qe(e,r);let a=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===a){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw qe(e,r);o+=1,n.push(mm(p,e,r));return}o+=1}if(u||o>=e.length)throw qe(e,r)};for(i();o<e.length;){if(e[o]==="."){o+=1,i();continue}if(e[o]==="["){t();continue}throw qe(e,r)}return n},co=(e,r)=>{let n=e;for(let o of r){if(n==null||!H(n,o))return;n=n[o]}return n},Ka=(e,r={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=Wa(e),[o,i,...t]=n;if(o==="variables"){if(!i)return r.variables;let s=typeof r.resolveVariable=="function"?r.resolveVariable(i):r.variables?.[i];return co(s,t)}return o==="runtime"?co(r.runtime,n.slice(1)):co(r,n)},Ja=(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)`)},yo=(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`)},ym=(e,r)=>{if(typeof r!="number"||!Number.isFinite(r))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Be=(e,r,n,o)=>(Ja(e,r,o),r.map(i=>kn(i,n))),Ve=(e,r,n,o)=>{let i=Be(e,r,n,o);return i.forEach(t=>ym(e,t)),i},hm=(e,r,n)=>{switch(e){case"var":return Ka(r,n);case"add":{let[o,i]=Ve(e,r,n,2);return o+i}case"sub":{let[o,i]=Ve(e,r,n,2);return o-i}case"mul":{let[o,i]=Ve(e,r,n,2);return o*i}case"div":{let[o,i]=Ve(e,r,n,2);return o/i}case"mod":{let[o,i]=Ve(e,r,n,2);return o%i}case"neg":{let[o]=Ve(e,r,n,1);return-o}case"round":{let[o]=Ve(e,r,n,1);return Math.round(o)}case"floor":{let[o]=Ve(e,r,n,1);return Math.floor(o)}case"ceil":{let[o]=Ve(e,r,n,1);return Math.ceil(o)}case"min":{let[o,i]=Ve(e,r,n,2);return Math.min(o,i)}case"max":{let[o,i]=Ve(e,r,n,2);return Math.max(o,i)}case"clamp":{let[o,i,t]=Ve(e,r,n,3);return Math.min(t,Math.max(i,o))}case"eq":{let[o,i]=Be(e,r,n,2);return yr.eq(o,i)}case"neq":{let[o,i]=Be(e,r,n,2);return yr.neq(o,i)}case"gt":{let[o,i]=Be(e,r,n,2);return yr.gt(o,i)}case"gte":{let[o,i]=Be(e,r,n,2);return yr.gte(o,i)}case"lt":{let[o,i]=Be(e,r,n,2);return yr.lt(o,i)}case"lte":{let[o,i]=Be(e,r,n,2);return yr.lte(o,i)}case"in":{let[o,i]=Be(e,r,n,2);return Array.isArray(i)?i.includes(o):!1}case"and":case"all":return yo(e,r),r.every(o=>!!kn(o,n));case"or":case"any":return yo(e,r),r.some(o=>!!kn(o,n));case"not":{let[o]=Be(e,r,n,1);return!o}case"length":{let[o]=Be(e,r,n,1);return typeof o=="string"||Array.isArray(o)?o.length:Ie(o)?Object.keys(o).length:0}case"includes":{let[o,i]=Be(e,r,n,2);return typeof o=="string"?typeof i=="string"&&o.includes(i):Array.isArray(o)?o.includes(i):!1}case"literal":return Xa(r);default:throw new Error(`Unknown computed expression operator: ${e}`)}},kn=(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,i]]=n;return hm(o,i,r)},ho=(e,r)=>{if(e===null||typeof e!="object"||H(e,"literal"))return e;if(H(e,"var"))return{literal:Ka(e.var,r)};if(H(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(i=>ho(i,r)):ho(o,r)]))},gm=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return $e(e),kt(ho(e,r))},Qa=(e,r)=>{if(!Ie(e))throw new Error(`${r} must be an object`);let n=H(e,"expr"),o=H(e,"value");if(n===o)throw new Error(`${r} must contain exactly one of expr or value`)},uo=(e,r,n)=>(Qa(e,r),H(e,"value")?Xa(e.value):kn(e.expr,n)),bm=(e,r={},n="unknown")=>{if(!Ie(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=H(e,"expr"),i=H(e,"value");if(H(e,"branches")){if(o||i)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(!Ie(e.default))throw new Error(`Computed variable "${n}" requires default`);for(let s=0;s<e.branches.length;s+=1){let a=e.branches[s];if(!Ie(a))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!H(a,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(gm(a.when,r))return uo(a,`Computed variable "${n}" branch ${s}`,r)}return uo(e.default,`Computed variable "${n}" default`,r)}if(o===i)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return uo(e,`Computed variable "${n}"`,r)},Za=(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}`)}},Im=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}),wm=new Set(["and","or","all","any"]),km=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),vm=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Am=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),Pm=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),el=new WeakMap,qa=e=>e===null?"null":Array.isArray(e)?"object":typeof e,In=(e,r,n)=>{for(let o of Object.keys(e))if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},xm=(e,r,n,o)=>{if(n!==void 0&&n!==r)throw new Error(`Computed variable "${e}" ${o} expected type ${r}, got ${n}`)},rl=(e,{variableId:r,variableConfigs:n,dependencies:o,path:i})=>{let t=`Computed variable "${r}" ${i} var`,[s,a,...l]=Wa(e,t);if(s!=="variables"&&s!=="runtime")throw new Error(`${t} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!a)throw new Error(`${t} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!H(n,a))throw new Error(`Computed variable "${r}" ${i} references unknown variable "${a}"`);let u=n[a];return Se(u)&&o.add(a),l.length===0?u?.type:void 0},tl=(e,{variableId:r,variableConfigs:n,dependencies:o,path:i})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${r}" ${i} must use finite numeric literals`);return qa(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,a]]=t;if(s==="var"){if(typeof a!="string"||a.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return rl(a,{variableId:r,variableConfigs:n,dependencies:o,path:i})}if(s==="literal"){if(typeof a=="number"&&!Number.isFinite(a))throw new Error(`Computed variable "${r}" ${i} must use finite numeric literals`);return qa(a)}let l=Im[s];if(l===void 0&&!wm.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?yo(s,a):Ja(s,a,l);let u=a.map((c,p)=>tl(c,{variableId:r,variableConfigs:n,dependencies:o,path:`${i}.${s}[${p}]`}));if(vm.has(s)&&u.forEach(c=>{if(c!==void 0&&c!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),km.has(s))return"number";if(Am.has(s))return"boolean"},Em=(e,{variableId:r,variableConfigs:n,dependencies:o,path:i})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{$e(e)}catch(s){throw new Error(`Computed variable "${r}" ${i} is invalid: ${s.message}`,{cause:s})}let t=(s,a)=>{if(s===null||typeof s!="object"||H(s,"literal"))return;if(H(s,"var")){rl(s.var,{variableId:r,variableConfigs:n,dependencies:o,path:a});return}if(H(s,"call"))throw new Error(`Computed variable "${r}" ${a} function calls are not supported`);if(H(s,"not")){t(s.not,`${a}.not`);return}let l=Object.keys(s).find(u=>Pm.has(u));s[l].forEach((u,c)=>{t(u,`${a}.${l}[${c}]`)})};t(e,i)},po=(e,{variableId:r,variableConfig:n,variableConfigs:o,dependencies:i,path:t,allowedKeys:s=new Set(["expr","value"])})=>{if(Qa(e,`Computed variable "${r}" ${t}`),In(e,s,t),H(e,"value")){Za(r,n.type,e.value);return}let a=tl(e.expr,{variableId:r,variableConfigs:o,dependencies:i,path:`${t}.expr`});xm(r,n.type,a,`${t}.expr`)},Sm=(e,r,n)=>{let o=r.computed;if(!Ie(o))throw new Error(`Computed variable "${e}" computed must be an object`);let i=new Set,t=H(o,"expr"),s=H(o,"value");if(H(o,"branches")){if(In(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(!Ie(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,u)=>{if(!Ie(l))throw new Error(`Computed variable "${e}" branch ${u} must be an object`);if(In(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${u}`),!H(l,"when"))throw new Error(`Computed variable "${e}" branch ${u} requires when`);Em(l.when,{variableId:e,variableConfigs:n,dependencies:i,path:`computed.branches[${u}].when`}),po(l,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:i,path:`computed.branches[${u}]`,allowedKeys:new Set(["when","expr","value"])})}),po(o.default,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:i,path:"computed.default"}),i}if(In(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 po(o,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:i,path:"computed"}),i},jr=(e={})=>{if(!Ie(e))throw new Error("Variable configs must be an object");if(H(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(H(e,""))throw new Error("Variable ids must not be empty");let r=new Map;Object.entries(e).forEach(([t,s])=>{if(Se(s)){if(!Ie(s))throw new Error(`Computed variable "${t}" must be an object`);if(!H(s,"type"))throw new Error(`Computed variable "${t}" requires type`);if(!H(s,"scope"))throw new Error(`Computed variable "${t}" requires scope`);if(H(s,"default"))throw new Error(`Computed variable "${t}" must not declare a top-level default`);if(Et(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,Sm(t,s,e))}});let n=new Set,o=[];r.forEach((t,s)=>{if(n.has(s))return;let a=[{variableId:s,dependencies:[...r.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;a.length>0;){let u=a.at(-1);if(u.nextDependencyIndex>=u.dependencies.length){a.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=[...a.slice(p).map(({variableId:d})=>d),c].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(c,a.length),a.push({variableId:c,dependencies:[...r.get(c)??[]],nextDependencyIndex:0})}});let i=Object.freeze({evaluationOrder:Object.freeze(o)});return el.set(e,i),i},Jr=({variables:e={},runtime:r={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:i}=el.get(n)??jr(n),t=xt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>Se(g)).map(([g])=>g),a=Object.create(null),l=[],u=new Map(i.map((g,h)=>[g,h])),c=-1,p=!1,m=g=>{if(H(a,g))return a[g];let h=n[g];if(!Se(h))return H(t,g)?t[g]:void 0;let w=l.indexOf(g);if(w>=0){let b=[...l.slice(w),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=bm(h.computed,y,g);return Za(g,h.type,b),mo(a,g,b),b}finally{l.pop()}},d=g=>{if(H(a,g))return a[g];let h=n[g];if(!Se(h))return H(t,g)?t[g]:void 0;let w=u.get(g);if(o&&!p&&w!==void 0&&w>c){p=!0;try{for(let b=c+1;b<=w;b+=1)m(i[b]),c=b}finally{p=!1}return a[g]}return m(g)},f=new Proxy({},{get:(g,h)=>{if(typeof h=="string")return d(h)},has:(g,h)=>typeof h=="string"&&(H(t,h)||s.includes(h)),ownKeys:()=>[...new Set([...Object.keys(t),...s])],getOwnPropertyDescriptor:(g,h)=>{if(!(typeof h!="string"||!H(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,...a}):f},Rm=({variables:e={},runtime:r={},variableConfigs:n,projectData:o}={})=>{let i=n??o?.resources?.variables??{};return jr(i),Jr({variables:e,runtime:r,variableConfigs:i,eager:!0})},Pn=e=>{let r={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,i])=>{if(Se(i))return;let t=sm(i,o);i.scope==="context"?mo(r,o,t):mo(n,o,t)}),{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}},Et=(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(", ")}`)},St=(e,r,n)=>{let o={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},i=o[e];if(!i)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(o).flat().includes(r))throw new Error(`Unknown operation: ${r}`);if(!i.includes(r))throw new Error(`Operation "${r}" is not valid for variable "${n}" of type "${e}". Valid operations: ${i.join(", ")}`)},Om=2,Fa=12,nl=(e=Om)=>{if(!Number.isInteger(e)||e<0||e>Fa)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Fa}.`);return e},Cm=(e,r)=>{let n=10**r;return Math.round((e+Number.EPSILON)*n)/n},wn=e=>typeof e=="number"&&Number.isFinite(e),xn=(e,r,n,o,i={})=>{if(e==="number"){if(r==="set"&&!wn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(r==="multiply"&&!wn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(r==="divide"&&!wn(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}".`);nl(i.roundTo)}}},En=(e,r,n,o={})=>{let i=(s,a,l)=>{let u=s??a;if(!wn(u))throw new Error(`Operation "${r}" requires ${l} to be a number.`);return u},t=s=>{let a=i(s,void 0,"value");if(a===0)throw new Error(`Operation "${r}" requires value to be a non-zero number.`);return a};switch(r){case"set":return n;case"multiply":return i(e,1,"current value")*i(n,void 0,"value");case"divide":return Cm(i(e,0,"current value")/t(n),nl(o.roundTo));case"increment":return i(e,0,"current value")+i(n,1,"value");case"decrement":return i(e,0,"current value")-i(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${r}`)}};var wo=(e,r="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),i=String(n.getFullYear()),t={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:nm[n.getMonth()],YYYY:i,YY:i.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])},$m=(e,r)=>{let n=t=>t?.ui,o=n(e),i=n(r);return JSON.stringify(o)===JSON.stringify(i)?null:o&&!i?{changeType:"delete",data:e}:i&&!o?{changeType:"add",data:r}:i&&o?{changeType:"update",data:r}:null},wt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,_m=(e,r)=>{let n=e?.character?.sprite,o=r?.character?.sprite,i=wt(n)?n:void 0,t=wt(o)?o:void 0;return JSON.stringify(i)===JSON.stringify(t)?null:i&&!t?{changeType:"delete",data:i}:t&&!i?{changeType:"add",data:t}:t&&i?{changeType:"update",data:t}:null},Ua=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},Ba=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},za=(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,Tm=(e,r)=>{let n={},o=za(Ua(e),Ua(r)),i=za(Ba(e),Ba(r));return o&&(n.resource=o),i&&(n.color=i),Object.keys(n).length>0?n:null},ko=(e={},r={})=>{let n={},o=["sfx","voice"],i=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=Tm(e.background,r.background);t&&(n.background=t),i("screen"),i("bgm"),i("voice");let s=$m(e.dialogue,r.dialogue);s&&(n.dialogue=s);let a=_m(e.dialogue,r.dialogue);return a&&(n.dialogueSprite=a),i("choice"),i("form"),i("layout"),i("animation"),i("control"),i("character"),i("visual"),i("sfx"),n},vo=(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=i=>{r[i]&&(delete r[i].animations,Object.keys(r[i]).length===0&&delete r[i])};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=(i,t)=>{let s=r[i]?.items;Array.isArray(s)&&(r[i].items=s.map(a=>{let l={...a};return delete l.animations,t(l)?l:null}).filter(Boolean),r[i].items.length===0&&delete r[i])};return o("character",i=>i.sprites&&i.sprites.length>0||i.transformId||i.resourceId),o("visual",i=>i.resourceId||i.transformId),r},Nm=(e,r)=>{if(!e||!r)return;let n=e;for(let o of r.split(".")){if(n==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),o))return;n=n[o]}return n},Ya=e=>e!==null&&typeof e=="object"?structuredClone(e):e,jm=(e,r,n)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(r??{},n)?r[n]:void 0;if(e===n){if(o==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return Ya(o)}if(!e.startsWith(`${n}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${n}".`);let i=e.slice(n.length+1),t=Nm(o,i);if(t===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return Ya(t)},Dm={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"])},Lm=(e,r)=>{let n=e[e.length-1];return n?Dm[n]?.has(r)===!0:!1},go=(e,r,n=[])=>Array.isArray(e)?e.map(o=>go(o,r,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,i])=>[o,Lm(n,o)?i:go(i,r,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?jm(e,r,"_event"):Tr(e,r):e,Rt=(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 go(e,r)};var Mm=11102230246251565e-32,sl=128,ol=1e3,il=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ot=(e,r,n)=>{let o=Object.keys(e).find(i=>!r.has(i));if(o!==void 0)throw new Error(`${n}.${o} is not supported`)},Sn=(e,r)=>{if(!il(e))throw new Error(`${r} must be an object`)},Rn=(e,r,{min:n,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${r} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${r} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${r} must be at most ${o}`);return e},Vm=(e,r,{min:n,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${r} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${r} must be at most ${o}`);return e},Ao=e=>{let r=structuredClone(e),n=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(n),Object.freeze(o)),o);return n(r)},qm=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),al=e=>{let r=e??qm();if(!il(r)||typeof r.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=r.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},Fm=(e,r)=>{let n=4294967296-4294967296%r;for(let o=0;o<sl;o+=1){let i=e.nextUint32();if(i<n)return i%r}throw new Error(`random source exhausted after ${sl} rejected samples`)},Um=e=>{let r=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(r*67108864+n)/9007199254740992},Bm=(e,r)=>{if(Ot(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let n=Rn(e.min,"random.distribution.min"),i=Rn(e.max,"random.distribution.max")-n+1;if(!Number.isSafeInteger(i)||i<1||i>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return Ao({type:"integer",value:i===1?n:n+Fm(r,i)})},zm=(e,r)=>{if(Ot(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>ol)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let n=e.outcomes.map((u,c)=>{let p=`random.distribution.outcomes[${c}]`;if(Sn(u,p),Ot(u,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(u,"weight"))throw new Error(`${p}.weight is required`);return Sn(u.actions,`${p}.actions`),{weight:Vm(u.weight,`${p}.weight`,{min:0})}}),o=Math.max(...n.map(({weight:u})=>u));if(o<=0)throw new Error("random weighted total weight must be positive");let i=n.map(u=>({...u,weight:u.weight/o})),t=i.reduce((u,c)=>u+c.weight,0);i.forEach((u,c)=>{if(n[c].weight>0&&(u.weight===0||u.weight/t<=Mm))throw new Error(`random.distribution.outcomes[${c}].weight is below the supported probability resolution`)});let s=Um(r)*t,a=0,l=i.findLastIndex(({weight:u})=>u>0);for(let u=0;u<i.length;u+=1){let c=i[u];if(a+=c.weight,s<a){l=u;break}}return Ao({type:"weighted",outcomeIndex:l})},ll=(e,{randomSource:r})=>{Sn(e,"random.distribution");let o={integer:Bm,weighted:zm}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,r)},On=(e,r)=>{if(Sn(e,"random result"),e.type!==r)throw new Error("random result type does not match its recorded type");if(r==="integer")Ot(e,new Set(["type","value"]),"random result"),Rn(e.value,"random result.value");else if(r==="weighted")Ot(e,new Set(["type","outcomeIndex"]),"random result"),Rn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:ol-1});else throw new Error(`unsupported recorded random result type: ${r}`);return Ao(e)};var Dr=(e,r)=>Object.freeze({name:e,actions:Object.freeze(r)}),pl=Object.freeze([Dr("cleanup",["clearPendingEffects","cleanAll"]),Dr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Dr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Dr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Dr("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),Dr("persistence",["saveSlot"]),Dr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),Qr=new Map;pl.forEach(e=>{e.actions.forEach(r=>{if(Qr.has(r))throw new Error(`duplicate action execution key: ${r}`);Qr.set(r,Qr.size)})});var Ym=new Set(pl.find(({name:e})=>e==="navigation").actions),cl=Qr.get("saveSlot")-.5,ul=(e,r)=>e!=="random"?e:r?.distribution?.type==="weighted"?"random:weighted":"random:integer",Gm=(e,r)=>e<r?-1:e>r?1:0,Cn=e=>Object.entries(e).sort((r,n)=>{let o=ul(...r),i=ul(...n),t=Qr.get(o),s=Qr.get(i),a=t??cl,l=s??cl;return a!==l?a-l:t!==void 0&&s!==void 0?0:Gm(o,i)}),Po=e=>Ym.has(e),$n=e=>{let r=e.map(([n])=>n).filter(Po);if(!(r.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${r.join(", ")}`)};var de=e=>structuredClone(we(e)?pr(e):e),ne=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),dl=e=>e?.animations?.playback?.continuity==="persistent",re=(e,r)=>ne(e??{},r)&&e[r]!==void 0,Ct=(e,r)=>e?!r(e)&&e.animations?{animationsOnly:!0,state:{animations:de(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Hm=e=>re(e,"opacity")||re(e,"blur"),bl=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Il=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],xo=["animationName","animationSpeed","loop"],Xm=e=>bl.some(r=>re(e,r)),wl=e=>e?.text&&re(e.text,"content")&&re(e.text,"textStyleId"),kl=e=>re(e,"text"),Wm=(e,r)=>e.resourceId?!0:wl(e)?!r?.text:!1,Km=(e,r)=>{let n={...de(e),...r};return r.text&&e.text&&(n.text={...de(e.text),...de(r.text)}),n},Jm=(e,r)=>{if(kl(e)){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!wl(e)&&!r?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`)}},fl=e=>Il.some(r=>re(e,r)),ml=e=>xo.some(r=>re(e,r)),Qm=(e,r,{hasAuthoredTransformId:n=!1}={})=>{if(!r)return e;for(let o of Il)!n&&!re(e,o)&&re(r,o)&&(e[o]=r[o]),ne(e,o)&&e[o]===void 0&&delete e[o];return e},vl=(e,r,n)=>{let o=e[n];return o?.id===r?.id?o:e.find(i=>i.id===r?.id)},Zm=(e,r)=>{if(!r)return e;for(let n of bl)!re(e,n)&&re(r,n)&&(e[n]=r[n]),ne(e,n)&&e[n]===void 0&&delete e[n];return e},ey=(e,r)=>(r&&(!re(e,"opacity")&&re(r,"opacity")&&(e.opacity=r.opacity),!re(e,"blur")&&re(r,"blur")&&(e.blur=de(r.blur)),ne(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ne(e,"blur")&&e.blur===void 0&&delete e.blur),e),Al=(e,r,n=[],{hasPatchFn:o=()=>!1,mergeItemFn:i}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let t=e.map((s,a)=>{let l=vl(n,s,a),u=r(s,l),c=Hm(s),p=Xm(s),m=o(s),d=ne(s,"animations"),f=de(s);return!u&&(c||p||m)&&l&&(f=i?i(l,f):{...de(l),...f},d||delete f.animations),ey(Zm(f,l),l)}).filter(s=>r(s)||s.animations);return{hasValidItems:t.length>0,processedItems:t}},ry=e=>{if(e){if(e.character&&ne(e.character,"name"))return e.character.name;if(ne(e,"characterName"))return e.characterName}},Pl=e=>!!e?.character&&ne(e.character,"sprite"),ty=e=>{let r={},n=!1,o=ry(e);return o!==void 0&&(r.name=o,n=!0),Pl(e)&&(r.sprite=de(e.character.sprite),n=!0),n?r:void 0},yl=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},hl=({dialogueState:e,dialogueAction:r,persistCharacter:n})=>ne(r,"persistSprite")?r.persistSprite===!0:ne(e,"persistSprite")?e.persistSprite===!0:n&&!ne(r,"characterId"),gl=({previousCharacter:e,characterFields:r,hasCharacterId:n,persistCharacter:o,persistSprite:i,hasExplicitPersistSprite:t,isAppendingAdvDialogueContent:s})=>{let a={},l=e??{},u=r??{},c=s&&!n,p=c&&!t;return ne(u,"name")?a.name=u.name:(o&&!n||c)&&ne(l,"name")&&(a.name=de(l.name)),ne(u,"sprite")?a.sprite=de(u.sprite):(i||p)&&ne(l,"sprite")&&(a.sprite=de(l.sprite)),Object.keys(a).length>0?a:void 0},ny=({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(i=>de(i)):delete e.initialRevealedContent,e.content=[...o,...r]},sy=()=>({}),oy=(e,r)=>{if(!r.screen)return;let n=re(r.screen,"opacity"),o=re(r.screen,"blur"),i=ne(r.screen,"animations");if(!n&&!o){i||delete e.screen;return}let t=e.screen,s={};if(n?s.opacity=r.screen.opacity:re(t,"opacity")&&(s.opacity=t.opacity),o?s.blur=de(r.screen.blur):re(t,"blur")&&(s.blur=de(t.blur)),ne(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ne(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},iy=(e,r)=>{if(r.background){let n=re(r.background,"resourceId"),o=re(r.background,"colorId"),i=re(r.background,"opacity"),t=re(r.background,"blur"),s=re(r.background,"transformId"),a=fl(r.background),l=ml(r.background),{animationsOnly:u,state:c}=Ct(r.background,d=>re(d,"resourceId")||re(d,"colorId")||re(d,"opacity")||re(d,"blur")||re(d,"transformId")||fl(d)||ml(d));if(u){e.background=e.background?{...de(e.background),...c}:c;return}if(!n&&!o&&!i&&!t&&!s&&!a&&!l){delete e.background;return}let p=e.background,m=de(r.background);if(!n&&p?.resourceId){m.resourceId=p.resourceId,!ne(m,"transformId")&&p.transformId&&(m.transformId=p.transformId);for(let d of xo)!re(m,d)&&re(p,d)&&(m[d]=p[d])}Qm(m,p,{hasAuthoredTransformId:s}),!o&&p?.colorId&&(m.colorId=p.colorId),!i&&re(p,"opacity")&&(m.opacity=p.opacity),!t&&re(p,"blur")&&(m.blur=de(p.blur)),ne(m,"resourceId")&&m.resourceId===void 0&&delete m.resourceId,ne(m,"colorId")&&m.colorId===void 0&&delete m.colorId,ne(m,"animations")&&m.animations===void 0&&delete m.animations,ne(m,"transformId")&&m.transformId===void 0&&delete m.transformId,ne(m,"opacity")&&m.opacity===void 0&&delete m.opacity,ne(m,"blur")&&m.blur===void 0&&delete m.blur;for(let d of xo)ne(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&&!ne(m,"animations")&&dl(p)&&(m.animations=de(p.animations)),e.background=m}else e.background?.animations&&!dl(e.background)&&(e.background.animations={})},ay=(e,r)=>{if(!r.dialogue){if(e.dialogue&&(yl(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=hl({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:c});c||delete e.dialogue.characterId,e.dialogue.character=gl({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}=Ct(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&&ny({dialogueState:e.dialogue,content:r.dialogue.content,append:o}),ne(r.dialogue,"textSpeed")?e.dialogue.textSpeed=r.dialogue.textSpeed:delete e.dialogue.textSpeed;let i=ne(r.dialogue,"persistCharacter")?r.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;i?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let t=hl({dialogueState:e.dialogue,dialogueAction:r.dialogue,persistCharacter:i});ne(r.dialogue,"persistSprite")&&(e.dialogue.persistSprite=t);let s=ne(r.dialogue,"characterId"),a=ty(r.dialogue),l=Pl(r.dialogue);s?r.dialogue.characterId?e.dialogue.characterId=r.dialogue.characterId:delete e.dialogue.characterId:!i&&!o&&delete e.dialogue.characterId;let u=gl({previousCharacter:e.dialogue.character,characterFields:a,hasCharacterId:s,persistCharacter:i,persistSprite:t,hasExplicitPersistSprite:ne(r.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(u?e.dialogue.character=u:delete e.dialogue.character,l||yl(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=de(e.dialogue.character)),e.dialogue.lines.push(c)}},ly=(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=de(r.sfx)}else e.sfx&&delete e.sfx},cy=(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=de(r.bgm),r.bgm.resourceId&&(e.bgm.loop=r.bgm.loop??!0)}},uy=(e,r)=>{if(r.visual){let n=e.visual?.items||[];r.visual.items?.forEach((t,s)=>{Jm(t,vl(n,t,s))});let{hasValidItems:o,processedItems:i}=Al(r.visual.items,Wm,n,{hasPatchFn:kl,mergeItemFn:Km});o?e.visual={items:i}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations?{...n,animations:{}}:n))},py=(e,r)=>{if(!r.character){e.character?.items&&(e.character.items=e.character.items.map(i=>i.animations?{...i,animations:{}}:i));return}let{hasValidItems:n,processedItems:o}=Al(r.character.items,i=>i.sprites&&i.sprites.length>0||i.transformId||i.resourceId,e.character?.items||[]);n?e.character={items:o}:delete e.character},dy=(e,r)=>{r.animation?e.animation=r.animation:e.animation&&delete e.animation},fy=(e,r)=>{if(r.layout){let{animationsOnly:n,state:o}=Ct(r.layout,i=>!!i.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},my=(e,r)=>{if(r.choice){let{animationsOnly:n,state:o}=Ct(r.choice,i=>!!i.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},yy=(e,r)=>{if(r.form){let{animationsOnly:n,state:o}=Ct(r.form,i=>!!i.resourceId);if(n){e.form={...e.form,...o};return}if(!r.form.resourceId){delete e.form;return}e.form=de(r.form)}else e.form&&delete e.form},hy=(e,r)=>{if(r.control){if(!r.control.resourceId){delete e.control;return}e.control=r.control}},gy=(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=de(r.voice)}else e.voice&&delete e.voice},by=(e,r)=>{r.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Lr=e=>vn(sy,[by,oy,iy,ly,cy,uy,ay,py,dy,fy,my,yy,hy,gy])(e);var Zr=(e,r)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Tr(e,r);return n&&typeof n=="object"?e:n};var Iy=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"}}),hr=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}),$t=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),wy=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"}),Eo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),xl=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),So=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),El=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ky=(e,r)=>{let n=wy[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}"`)},_n=(e,r)=>{if(ky(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},Ro=(e={})=>{let r=e?.config;if(r===void 0)return{...hr};if(!El(r))throw new Error("projectData.config must be an object");let n=Object.keys(r).find(a=>a!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=r.runtimeDefaults;if(o===void 0)return{...hr};if(!El(o))throw new Error("projectData.config.runtimeDefaults must be an object");let i=new Set(xl),t=Object.keys(o).find(a=>!i.has(a));if(t)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${t}"`);let s={...hr};return xl.forEach(a=>{o[a]!==void 0&&(s[a]=_n(a,o[a]))}),s},vy=(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]}},gr=e=>Object.fromEntries(Object.entries(Iy).map(([r,n])=>{let o=vy(e,n.source),i=o!==void 0?o:hr[r]??$t[r];return[r,i]})),Xe=(e,r)=>gr(e)[r],Sl=(e={})=>Object.fromEntries(Eo.map(r=>[r,e[r]??hr[r]]));var et=Object.freeze({VISUAL_BEHIND_BACKGROUND:10,BACKGROUND:20,VISUAL_BEHIND_CHARACTER:30,CHARACTER:40,VISUAL_BEHIND_DIALOGUE:50,DIALOGUE:60,VISUAL_BEHIND_CHOICE:70,CHOICE:80,VISUAL_FOREGROUND:90}),er=Object.freeze({BEHIND_BACKGROUND:et.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:et.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:et.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:et.VISUAL_BEHIND_CHOICE,FOREGROUND:et.VISUAL_FOREGROUND}),Oo=er.BEHIND_DIALOGUE,Co=Object.freeze(Object.values(er).sort((e,r)=>e-r));var Ay={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([r,n])=>({id:r,...n})),formatDate:wo},Py=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,_t=e=>Array.isArray(e)?e.map(r=>{if(!r||typeof r!="object"||Array.isArray(r)||Object.keys(r).length!==1)return _t(r);let[n]=Object.keys(r),o=Py.exec(n);if(!o)return _t(r);let[,i,t,s]=o,a=`$for ${i}${t?`, ${t}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(r[n])?r[n]:[];return{[a]:_t(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([r,n])=>[r,_t(n)])),tr=(e,r)=>{let n={functions:Ay};return Tr(_t(e),r,n)},Ho=({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".`)},xy=({id:e,targetId:r,animation:n,playback:o,animationPath:i="animation"})=>{let t=structuredClone(n);if(Ho({animationType:t.type,animationId:e,animationPath:i}),delete t.name,delete t.playback,t.id=e,t.targetId=r,o!==void 0){let s=Oy(o,`${i}.playback`);if(s!==void 0){let a=s.loop===!0?Bl(t):null;if(s.loop===!0&&t.type!=="update")throw new Error(`[${i}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&t.complete!==void 0)throw new Error(`[${i}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&(!Number.isFinite(a)||a<=0))throw new Error(`[${i}.playback] playback.loop requires an animation with a finite duration greater than 0.`);t.playback=s}}return t},Ey=(e,{animationId:r="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Ho({animationType:e.type,animationId:r,animationPath:n}),e.type},Sy=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Ry=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Oy=(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},Cy=e=>{let r=e?.playback?.speed;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:1},Mr=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),ql=e=>e?.playback?.continuity==="persistent",Mo=e=>Array.isArray(e)?e.map(Mo):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((r,n)=>(r[n]=Mo(e[n]),r),{}),Dn=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(Mo(r))},Fl=(e=[])=>e.filter(r=>ql(r)).map(r=>structuredClone(r)),Ul=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,$o=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((r,n)=>Math.max(r,Ul(n)),0),Bl=e=>Math.max($o(e?.tween),$o(e?.prev?.tween),$o(e?.next?.tween),Ul(e?.mask?.progress)),zl=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Bl(e)/Cy(e),$y=e=>e.some(r=>r?.playback?.loop===!0),Rl=({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(Dn).filter(Boolean));return e.some(o=>{if(!ql(o))return!1;let i=Dn(o);return i?n.has(i):!1})},ze=({animationInstances:e,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:i,isAuthoredOnCurrentLine:t=!0})=>!Array.isArray(e)||e.length===0||n?!1:$y(e)||t&&!r||Rl({animationInstances:e,activePersistentAnimations:o})?!0:t?!1:Rl({animationInstances:e,activePersistentAnimations:i}),_y=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(r=>e[r]!==void 0),Ty=(e,r)=>{if(_y(e))throw new Error(`[${r}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Ny=({resources:e,animationId:r,playback:n,instanceId:o,targetId:i,animationPath:t="animation"})=>{if(!r||!i)return!1;let s=e?.animations?.[r];return s?xy({id:o,targetId:i,animation:s,playback:n,animationPath:t}):null},jy=(e,{defaultTargetId:r,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let i=structuredClone(e);return Ho({animationType:i.type,animationId:i.id??n,animationPath:o}),i.id??=n,i.targetId??=r,i},Xo=({animations:e,transitions:r,defaultTargetId:n,idPrefix:o,animationPathPrefix:i=o})=>{r.forEach((t,s)=>{e.push(jy(t,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${i}.transitions[${s}]`}))})},Vo=(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},Dy=({content:e,path:r,variables:n})=>Vo(e,r).reduce((o,i)=>{let t=Zr(i.text,{variables:n});return o+`${t??""}`.length},0),Ol=(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))},Tn=(e,r=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let o=e?.sprites?.map(({resourceId:i})=>i)||[];return o.length===0?`character-container-${e.id}`:`character-container-${e.id}-${r}-${o.join("-")}`},Tt=(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},Ly=(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},My=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Vy=(e={})=>My.some(r=>Mr(e,r)),Yl=(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"}},jn=({resourceId:e,kind:r})=>{if(e)return r?`bg-cg-background-${r}`:`bg-cg-${e}`},qy=(e={})=>e.textStyles||{},Fy=(e={})=>e.images||{},Uy=.5,By=(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]},Wo=({id:e,resourceId:r,spritesheet:n,animationName:o,animationSpeed:i,loop:t,width:s,height:a,transform:l={}}={})=>{let u=By(n,o,r),c=u?n.animations?.[u]:void 0;if(!c){console.warn(`Spritesheet animation not found: ${r}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:a??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:c.frames,animationSpeed:i??c.animationSpeed??Uy,loop:t??c.loop??!0}}},Gl=({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 i=n.spritesheets?.[r.resourceId];if(i)return Wo({id:e,resourceId:r.resourceId,spritesheet:i,animationName:r.animationName,animationSpeed:r.animationSpeed,loop:r.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${r.resourceId}`)},zy=(e={})=>e.colors||{},Yy=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,jt=(e,r)=>e==="root"?`${r}`:`${e}.${r}`,nt=(e,r,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${r}" must resolve to a non-empty string`)},_o=(e,r,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${r} for text style "${n}" must be a number between 0 and 1`);return e},To=(e,r,n,o,{minimum:i}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||i!==void 0&&e<i){let t=i===void 0?"a finite number":`a finite number >= ${i}`;throw new Error(`shadow.${r} for text style "${n}" must be ${t}`)}return e},Vn=(e,r)=>{if(typeof e!="string"||!Yy.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},Cl=(e,r,n)=>{let o=Vn(e,n);if(r===1)return o;let i=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(${i}, ${t}, ${s}, ${r})`},Gy=(e={},r)=>{let n=qy(e)?.[r];if(!n)throw new Error(`Text style "${r}" not found`);let i=(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=_o(n.colorAlpha,"colorAlpha",r),a={fontFamily:Array.isArray(n.fontId)?i.join(", "):i[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:Cl(t.hex,s,`Color "${n.colorId}" for text style "${r}"`)};if(n.align!==void 0&&(a.align=n.align),n.wordWrap!==void 0&&(a.wordWrap=n.wordWrap),n.breakWords!==void 0&&(a.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(a.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=_o(n.strokeAlpha,"strokeAlpha",r);a.strokeColor=Cl(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&&(a.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}"`);a.shadow={color:Vn(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${r}"`),alpha:_o(n.shadow.alpha,"shadow.alpha",r),blur:To(n.shadow.blur,"blur",r,0,{minimum:0}),offsetX:To(n.shadow.offsetX,"offsetX",r,2),offsetY:To(n.shadow.offsetY,"offsetY",r,2)}}return a},qo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((i,t)=>qo(i,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[i,t]of Object.entries(e))i!=="textStyleId"&&(o[i]=qo(t,r,jt(n,i)));return e.textStyleId!==void 0&&(nt(e.textStyleId,n,"textStyleId"),o.textStyle=Gy(r,e.textStyleId)),o},Ko=(e={},r)=>{let n=zy(e)?.[r];if(!n)throw new Error(`Color "${r}" not found`);return Vn(n.hex,`Color "${r}"`)},Hl=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",No=(e,r,n)=>{let o=e?.[r];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${r}.fill is not allowed in rect layout elements at "${n}". Use ${Hl(`${r}.fill`)} instead`)},Hy=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((i,t)=>Dt(i,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;let o={};for(let[i,t]of Object.entries(e))i!=="colorId"&&(o[i]=Dt(t,r,jt(n,i)));return e.colorId!==void 0&&(nt(e.colorId,n,"colorId"),o.fill=Ko(r,e.colorId)),o},Dt=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((i,t)=>Dt(i,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 ${Hl("fill")} instead`);No(e,"hover",n),No(e,"click",n),No(e,"rightClick",n)}let o={};for(let[i,t]of Object.entries(e))if(!(e.type==="rect"&&i==="colorId")){if(e.type==="rect"&&(i==="hover"||i==="click"||i==="rightClick")){o[i]=Hy(t,r,jt(n,i));continue}o[i]=Dt(t,r,jt(n,i))}return e.type==="rect"&&e.colorId!==void 0&&(nt(e.colorId,n,"colorId"),o.fill=Ko(r,e.colorId)),o},jo=(e={},r)=>{let n=Fy(e)?.[r];return n||null},Xl=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",$l=(e,r,n,o)=>{let i=e?.[r];if(!(!i||typeof i!="object"||Array.isArray(i))&&Object.prototype.hasOwnProperty.call(i,o))throw new Error(`Inline ${r}.${o} is not allowed in sprite layout elements at "${n}". Use ${Xl(`${r}.${o}`)} instead`)},_l=(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((i,t)=>Fo(i,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let i of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,i))throw new Error(`Inline ${i} is not allowed in sprite layout elements at "${n}". Use ${Xl(i)} instead`);$l(e,"hover",n,"src"),$l(e,"click",n,"src")}let o={};for(let[i,t]of Object.entries(e))e.type==="sprite"&&(i==="imageId"||i==="hoverImageId"||i==="clickImageId")||(o[i]=Fo(t,r,jt(n,i)));if(e.type==="sprite"&&e.imageId!==void 0){nt(e.imageId,n,"imageId");let i=jo(r,e.imageId),t=i?.fileId??e.imageId;o.src=t,o.width===void 0&&i?.width!==void 0&&(o.width=i.width),o.height===void 0&&i?.height!==void 0&&(o.height=i.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(nt(e.hoverImageId,n,"hoverImageId"),_l(o,"hover",jo(r,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(nt(e.clickImageId,n,"clickImageId"),_l(o,"click",jo(r,e.clickImageId)?.fileId??e.clickImageId)),o},Jo=(e,r={},n="root")=>Fo(Dt(qo(e,r,n),r,n),r,n),nr=Jo,Vr=(e=[])=>e.find(r=>r.id==="story"),Xy="#000000",Uo="bg-cg-background-color",Wy=({resources:e={},background:r={},screen:n})=>r?.colorId===void 0?Vn(n?.backgroundColor??Xy,"screen.backgroundColor"):Ko(e,r.colorId),Wl=(e={})=>{if(Mr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},Ky=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Tl=(e={},{includeDefaultAlpha:r=!1}={})=>{let n=Wl(e),o=Ky(e),i={};return(r||n!==void 0)&&(i.alpha=n??1),o&&(i.blur=o),i},Jy=(e={})=>{if(Mr(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},Qy=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Kl=(e={})=>{let r=Jy(e),n=Qy(e),o={};return r!==void 0&&(o.alpha=r),n&&(o.blur=n),o},tt=(e={})=>Kl(e),rr=(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,i=r.originY??e.originY;return o!==void 0&&(n.originX=o),i!==void 0&&(n.originY=i),n},Zy=["id","type","resourceId","transformId","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],Qo=(e={})=>e.text&&Mr(e.text,"content")&&Mr(e.text,"textStyleId"),Nl=(e={})=>{if(e.resourceId)return e.resourceId;if(Qo(e))return"text"},jl=(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,...i}=n;return{...i,src:r.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:r.images?.[n.src]?.fileId??n.src}:n})}:e,eh=({item:e,particle:r,resources:n})=>{let o=Tt(n,e),i=structuredClone(r),t=i.modules?.appearance?.texture;t!==void 0&&(i.modules.appearance.texture=jl(t,n)),i.texture!==void 0&&(i.texture=jl(i.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...i,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...rr(o,e)};return Object.assign(s,tt(e)),s},rh=e=>{if(e.text){if(e.resourceId)throw new Error(`Visual item "${e.id}" cannot define both resourceId and text`);if(!Qo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);for(let r of Zy)if(Mr(e.text,r))throw new Error(`Visual item "${e.id}" text.${r} is reserved for the visual item`)}},th=({resources:e,background:r,screen:n={width:1920,height:1080},includeOpacity:o=!1})=>{let i={id:Uo,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Wy({resources:e,background:r,screen:n})};if(o){let t=Wl(r);t!==void 0&&(i.alpha=t)}return i},nh=(e={},r)=>r?!!(e.images?.[r]||e.videos?.[r]||e.spritesheets?.[r]||e.layouts?.[r]):!1,Dl=({resources:e={},resourceId:r,colorId:n})=>{let o=Yl(e,r);return r&&(o||n===void 0)?{resourceId:r,targetId:jn({resourceId:r,kind:o})}:n!==void 0?{resourceId:Uo,targetId:Uo}:{resourceId:void 0,targetId:void 0}},Jl=100,br=Jl,sh="channel:bgm",oh="channel:music-room",ih="music-room:player",ah="channel:voice",lh="default",ch=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Nt=(...e)=>e.map(ch).join(":"),Ln=(e,r,n)=>{let o=new Set;e.forEach(({id:i})=>{if(o.has(i)){let t=n?` in ${n}`:"";throw new Error(`Duplicate ${r} id "${i}"${t}.`)}o.add(i)})},uh=(e,r)=>e*r/Jl,Ql=(e={},r)=>e?.[r]??hr[r],qn=(e={},r,n=br)=>uh(n,Ql(e,r)),Fn=({id:e,volume:r,muted:n,pan:o,loop:i,playback:t,interruption:s,children:a,runtime:l})=>{let u={id:e,type:"audio-channel",volume:r,muted:!!l?.muteAll||(n??!1),pan:o??0,children:a};return i!==void 0&&(u.loop=i),t!==void 0&&(u.playback=structuredClone(t)),s!==void 0&&(u.interruption=s),u},Nn=(e,r,n,o)=>e[n]!==void 0?e[n]:r[n]!==void 0?r[n]:o,ph=["muted","pan","playbackRate","startAt","endAt"],Un=({id:e,sound:r,resource:n,defaultLoop:o=!1})=>{let i={id:e,type:"sound",src:n.fileId,loop:Nn(r,n,"loop",o),volume:Nn(r,n,"volume",br),startDelayMs:Nn(r,n,"startDelayMs",0)};ph.forEach(s=>{let a=Nn(r,n,s,void 0);a!==void 0&&(i[s]=a)}),r.playback!==void 0&&(i.playback=structuredClone(r.playback));let t=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<t)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${t}).`);return i},Fe=({variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,runtime:i,saveSlots:t=[],dialogueState:s,includeInactiveAdvDialogue:a=!1,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g=[],characters:h={},dialogueUIHidden:w,skipOnlyViewedLines:b,skipTransitionsAndAnimations:E}={})=>{let k={dialogueTextSpeed:i?.dialogueTextSpeed??50,autoForwardDelay:i?.autoForwardDelay??1e3,autoForwardSpeed:i?.autoForwardSpeed??50,skipUnseenText:i?.skipUnseenText??!1,skipTransitionsAndAnimations:i?.skipTransitionsAndAnimations??!1,soundVolume:i?.soundVolume??50,musicVolume:i?.musicVolume??50,muteAll:i?.muteAll??!1,localizationPackageId:i?.localizationPackageId??null,saveLoadPagination:i?.saveLoadPagination??1,menuPage:i?.menuPage??"",menuEntryPoint:i?.menuEntryPoint??"",autoMode:i?.autoMode??u??!1,skipMode:i?.skipMode??c??!1,dialogueUIHidden:i?.dialogueUIHidden??w??!1,isLineCompleted:i?.isLineCompleted??l??!1},A=hh({dialogueState:s,includeInactiveAdvDialogue:a,characters:h,variables:e,runtime:k}),R={variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,localizationPackages:i?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:t,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:y,historyDialogue:g,characters:h};return A&&(R.dialogue=A,R.dialogueLines=A.lines),R},Ll=100,Mn=(e,r)=>{if(Array.isArray(e))return e.map(o=>Mn(o,r));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=Mn(n[o],r)}),n.type==="text-revealing"?r(n):n},dh=e=>Mn(e,r=>({...r,revealEffect:"none"})),fh=e=>Mn(e,r=>{let n=Number(r.speed??r.displaySpeed),o=Number.isFinite(n)?Math.max(n,Ll):Ll;return{...r,speed:o,...Object.prototype.hasOwnProperty.call(r,"displaySpeed")?{displaySpeed:o}:{}}}),Ir=(e,{isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>r||o?dh(e):n?fh(e):e,Zl=({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:{}}}}),Bo=e=>{if(Array.isArray(e))return e.map(Bo);if(!e||typeof e!="object")return e;let r={};for(let[t,s]of Object.entries(e))r[t]=Bo(s);let n=r.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n.actions,i=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,...i?{actions:{...o,nextLine:i}}:{}}}}},mh=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Ml="submit",Do=(e,r,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},i=o.actions&&typeof o.actions=="object"?o.actions:{},t=n.replaceActions===!0?r:{...i,...r};return{...e||{},payload:{...o,actions:t}}},zo=(e,r,n={})=>{if(Array.isArray(e))return e.map(u=>zo(u,r,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",i=o&&e.formRole===Ml,t=o&&n.submitRoleAncestor,s=i||t?{submitRoleAncestor:!0}:{},a={};for(let[u,c]of Object.entries(e))a[u]=zo(c,r,u==="children"?s:{});let l=a;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:Do(l.change,c),submit:Do(l.submit,r.submitActions)}}}return l.formRole===Ml||t?{...l,click:Do(l.click,r.submitActions,{replaceActions:!0})}:l},Yo=(e,r)=>{if(Array.isArray(e))return e.map(o=>Yo(o,r));if(!e||typeof e!="object")return e;let n={};for(let[o,i]of Object.entries(e))n[o]=Yo(i,r);for(let o of mh){let i=n[o]?.payload;!i||typeof i!="object"||Array.isArray(i)||(n[o]={...n[o],payload:{...i,_interactionSource:"form"}})}return n},Go=({characterId:e,character:r,characterName:n,characters:o={},variables:i={}}={})=>{let t=e?o?.[e]:void 0,s=An({characterId:e,character:r,characterName:n,characters:o,variables:i});return{...t||{},...r||{},name:s}},ec=(e=[],r={},n={})=>e.map(o=>{let i=Go({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:i,characterName:i.name}}),yh=e=>!(!e||e.mode==="adv"&&e.content===void 0),hh=({dialogueState:e,includeInactiveAdvDialogue:r=!1,characters:n={},variables:o,runtime:i}={})=>{if(!r&&!yh(e))return;let t=e.content===void 0?[{text:""}]:Vo(e.content,"dialogue.content"),s=e.content===void 0?0:Dy({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),a=i?.dialogueTextSpeed??hr.dialogueTextSpeed,l=e.textSpeed??a,u=(e.lines||[]).map((p,m)=>{let d=Vo(p.content,`dialogue.lines[${m}].content`),f=Go({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??a,content:d.map(y=>({...y,text:Zr(y.text,{variables:o})})),character:f,characterName:f.name}}),c=Go({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:Zr(p.text,{variables:o})})),initialRevealedCharacters:s,lines:u}},rc=({container:e,resources:r,templateData:n,isLineCompleted:o=!1,skipMode:i=!1,skipTransitionsAndAnimations:t=!1})=>{let s=tr(e,n);return nr(Ir(s,{isLineCompleted:o,skipMode:i,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),Vl=({renderStateKeyboard:e,keyboard:r,phase:n})=>{!r||typeof r!="object"||Array.isArray(r)||Object.entries(r).forEach(([o,i])=>{let t=e[o]??{},s=n==="keydown"?i?.keydown:i?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...t,keydown:{payload:Lo(s)}},i?.keyup&&typeof i.keyup=="object"&&(e[o].keyup={payload:Lo(i.keyup)});return}e[o]={...t,[n]:{payload:Lo(i)}}})},gh=(e={},r={})=>{let n={};return Vl({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Vl({renderStateKeyboard:n,keyboard:r,phase:"keyup"}),Object.keys(n).length>0?n:void 0},sr=({animationsDef:e,resources:r,previousResourceId:n,currentResourceId:o,previousTargetId:i,currentTargetId:t,animationPath:s,idPrefix:a})=>{if(!e)return[];let l=[],u=({instanceId:h,targetId:w})=>{let b=Ny({resources:r,animationId:d,playback:f,instanceId:h,targetId:w,animationPath:s});b&&l.push(b)},c=n!=null&&n!==!1,p=o!=null&&o!==!1,m=i&&t&&i===t;Ty(e,s);let d=Sy(e),f=Ry(e),y=r?.animations?.[d],g=Ey(y,{animationId:d,animationPath:s});if(g==="update")return p&&t?u({instanceId:`${a}-animation-update`,targetId:t}):c&&i&&u({instanceId:`${a}-animation-update`,targetId:i}),l;if(g==="transition"){let h=`${a}-animation-transition`,w=f?.continuity==="persistent"?h:`${a}-animation-in`;if(c&&p&&m)return u({instanceId:h,targetId:t}),l;c&&u({instanceId:`${a}-animation-out`,targetId:i}),p&&u({instanceId:w,targetId:t})}return l},bh=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Ih=(e,{presentationState:r,previousPresentationState:n,currentLineActions:o,resources:i={},screen:t={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:a,variables:l,imageGallery:u,musicRoom:c,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,saveSlots:k=[]})=>{let{elements:A,animations:R}=e;if(r.background){let $=o===void 0?!0:Mr(o?.background??{},"animations"),j=A.find(Q=>Q.id==="story");if(!j)return e;let x=Ly(i,r.background),M=x||Vy(r.background),B=n?.background?.resourceId,pe=n?.background?.colorId,G=r.background.resourceId??(r.background.animations?B:void 0),ae=r.background.colorId??(r.background.animations?pe:void 0),D=nh(i,G),ie={...r.background,colorId:ae};if((ae!==void 0||D)&&j.children.push(th({resources:i,background:ie,screen:t,includeOpacity:!D})),G){let{images:Q={},videos:se={},spritesheets:ye={}}=i,Z=Yl(i,G),C;if(Z==="sprite"?C=Q[G]:Z==="video"?C=se[G]:Z==="spritesheet-animation"&&(C=ye[G]),C){let _=Z==="video",F=Z==="spritesheet-animation",oe={x:(t?.width??1920)/2,y:(t?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...x},he={...Tl(r.background,{includeDefaultAlpha:!0}),...rr(oe,r.background)},Pe;F?Pe=Wo({id:jn({resourceId:G,kind:Z}),resourceId:G,spritesheet:C,animationName:r.background.animationName,animationSpeed:r.background.animationSpeed,loop:r.background.loop,transform:he}):Pe={id:jn({resourceId:G,kind:Z}),type:_?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...he},_&&(Pe.loop=r.background.loop??!1,Pe.volume=C.volume??50),Pe&&j.children.push(Pe)}}if(G){let{layouts:Q={}}=i,se=Q[G];if(se){let ye={id:jn({resourceId:G,kind:"container"}),type:"container",children:se.elements,...Tl(r.background)};M&&Object.assign(ye,rr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...x},r.background));let Z=tr(ye,Fe({variables:l,imageGallery:u,musicRoom:c,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:r.dialogue,isLineCompleted:s,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,characters:i.characters||{},skipTransitionsAndAnimations:a}));j.children.push(nr(Ir(Z,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:a}),i))}}let J=Dl({resources:i,resourceId:B,colorId:pe}),q=Dl({resources:i,resourceId:G,colorId:ae}),K=sr({animationsDef:r.background.animations,resources:i,previousResourceId:J.resourceId,currentResourceId:q.resourceId,previousTargetId:J.targetId,currentTargetId:q.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});ze({animationInstances:K,isLineCompleted:s,skipTransitionsAndAnimations:a,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:$})&&R.push(...K)}return e},wh=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{elements:a,animations:l}=e;if(r.character&&o){let u=a.find(f=>f.id==="story");if(!u)return e;let c=r.character.items||[],p=n?.character?.items||[],m=Ol(c),d=Ol(p);for(let f=0;f<c.length;f++){let y=c[f],{transformId:g,sprites:h}=y,w=p.find(M=>M.id===y.id),b=p.findIndex(M=>M.id===y.id),E=w?.sprites&&w.sprites.length>0,k=h&&h.length>0,A=b>=0?Tn(w,b,d):void 0,R=sr({animationsDef:y.animations,resources:o,previousResourceId:A,currentResourceId:k?Tn(y,f,m):void 0,previousTargetId:A,currentTargetId:k?Tn(y,f,m):void 0,animationPath:`character.items[${f}].animations`,idPrefix:"character"});if(y.animations&&!h&&!g&&E&&ze({animationInstances:R,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})){l.push(...R);continue}if(y.animations&&!h&&!g)continue;if(!h||h.length===0||!g){console.warn("Character item missing sprites or transformId:",y);continue}let $=Tn(y,f,m),j=o.transforms[g];if(!j){console.warn("Transform not found:",g);continue}let x={type:"container",id:$,...rr(j,y),...tt(y),children:[]};for(let M of h){let B=Gl({id:`${$}-${M.id}`,item:M,resources:o});B&&x.children.push(B)}u.children.push(x),ze({animationInstances:R,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&l.push(...R)}}return e},tc=(e,r)=>{if(!Co.includes(e))throw new Error(`${r} must be one of: ${Co.join(", ")}.`)},kh=(e,r)=>{let n=!!e.resourceId||Qo(e),o=e.layer??(n?void 0:r?.layer)??Oo;return tc(o,`Visual item "${e.id}" layer`),o},vh=(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:i,skipTransitionsAndAnimations:t,variables:s,imageGallery:a,musicRoom:l,sceneReplay:u,runtime:c,activePersistentAnimations:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,saveSlots:w=[],visualLayer:b})=>{let{elements:E,animations:k}=e;if(r.visual&&o){let A=E.find(x=>x.id==="story");if(!A)return e;let R=r.visual.items,$=n?.visual?.items||[],j=Fe({variables:s,imageGallery:a,musicRoom:l,sceneReplay:u,runtime:c,saveSlots:w,dialogueState:r.dialogue,isLineCompleted:i,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,characters:o.characters||{},skipTransitionsAndAnimations:t});b!==void 0&&tc(b,"visualLayer");for(let x of R){let M=$.find(J=>J.id===x.id),B=kh(x,M);if(b!==void 0&&B!==b)continue;if(rh(x),x.text){let J=Tt(o,x),q={...structuredClone(x.text),id:`visual-${x.id}`,type:"text",...rr(J,x)};Object.assign(q,tt(x)),A.children.push(nr(tr(q,j),o))}if(x.resourceId){let{images:J={},videos:q={},spritesheets:K={}}=o,Q=K[x.resourceId];if(Q){let se=Tt(o,x),ye=tt(x),Z=Wo({id:`visual-${x.id}`,resourceId:x.resourceId,spritesheet:Q,animationName:x.animationName,animationSpeed:x.animationSpeed,loop:x.loop,width:x.width,height:x.height,transform:{...rr(se,x),alpha:ye.alpha??x.alpha??1,...ye.blur?{blur:ye.blur}:{}}});Z&&A.children.push(structuredClone(Z))}else{let se=J[x.resourceId]||q[x.resourceId];if(se){let ye=q[x.resourceId]!==void 0,Z=Tt(o,x),C={id:`visual-${x.id}`,type:ye?"video":"sprite",src:se.fileId,width:se.width,height:se.height,...rr(Z,x)};Object.assign(C,tt(x)),ye&&(C.loop=se.loop??!1,C.volume=se.volume??50),A.children.push(C)}}}let pe=!!(o.spritesheets?.[x.resourceId]||o.images?.[x.resourceId]||o.videos?.[x.resourceId]);if(x.resourceId&&!pe){let J=o.particles?.[x.resourceId];J&&A.children.push(eh({item:x,particle:J,resources:o}))}let G=!!o.particles?.[x.resourceId];if(x.resourceId&&!pe&&!G){let{layouts:J={}}=o,q=J[x.resourceId];if(q){let K=Tt(o,x),Q={id:`visual-${x.id}`,type:"container",children:structuredClone(q.elements),...rr(K,x)};Object.assign(Q,tt(x));let se=tr(Q,j);A.children.push(nr(Ir(se,{isLineCompleted:i,skipMode:d,skipTransitionsAndAnimations:t}),o))}}let ae=Nl(M),D=Nl(x),ie=sr({animationsDef:x.animations,resources:o,previousResourceId:ae,currentResourceId:D,previousTargetId:ae?`visual-${x.id}`:void 0,currentTargetId:D?`visual-${x.id}`:void 0,animationPath:`visual.items[${x.id}].animations`,idPrefix:x.id});ze({animationInstances:ie,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:p})&&k.push(...ie)}}return e},rt="dialogue-character-sprite",Ah=(e,{presentationState:r,previousPresentationState:n,resources:o={},isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:a}=e,l=Vr(e.elements);if(!l)return e;let u=r.dialogue?.character?.sprite,c=n?.dialogue?.character?.sprite,p=wt(u),m=wt(c),d=sr({animationsDef:u?.animations,resources:o,previousResourceId:m?rt:void 0,currentResourceId:p?rt:void 0,previousTargetId:m?rt:void 0,currentTargetId:p?rt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return u?.animations&&m&&ze({animationInstances:d,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&a.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:rt,...rr(f),children:[]};for(let g of u.items){let h=Gl({id:`${rt}-${g.id}`,item:g,resources:o});h&&y.children.push(h)}return l.children.push(y),ze({animationInstances:d,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&a.push(...d),e},Ph=(e,{presentationState:r,previousPresentationState:n,resources:o={},dialogueUIHidden:i,autoMode:t,skipMode:s,isChoiceVisible:a,isFormVisible:l,canRollback:u,form:c,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,activePersistentAnimations:b,saveSlots:E=[]})=>{let{elements:k,animations:A}=e;if(!r.dialogue||i)return e;let R=k.find(j=>j.id==="story");if(!R)return e;if(r.dialogue.ui&&r.dialogue.ui.resourceId){let{layouts:j={}}=o,x=j[r.dialogue.ui.resourceId];if(x){let M={elements:x.elements},B=Fe({variables:f,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,saveSlots:E,dialogueState:r.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:t,skipMode:s,isChoiceVisible:a,isFormVisible:l,canRollback:u,form:c,characters:o.characters||{},dialogueUIHidden:i,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),pe=tr(M,B),G=nr(Ir(pe?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(G))for(let ae of G)R.children.push(ae);else G&&R.children.push(G)}}Ah(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let $=sr({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 ze({animationInstances:$,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&A.push(...$),e},xh=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:i,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:a,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,form:h,activePersistentAnimations:w,saveSlots:b=[]})=>{let{elements:E,animations:k}=e;if(r.choice&&o){let A=Vr(E);if(!A)return e;let R=o?.layouts?.[r.choice.resourceId];if(R&&R.elements){let j={elements:R.elements},x=tr(j,{...Fe({variables:a,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??[]}}),M=Bo(nr(Ir(x?.elements,{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(M))for(let B of M)A.children.push(B);else M&&A.children.push(M)}let $=sr({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"});ze({animationInstances:$,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...$)}return e},Eh=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:i,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:a,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,activePersistentAnimations:h,saveSlots:w=[],form:b})=>{let{elements:E,animations:k}=e;if(!b?.resourceId||!o)return e;let A=Vr(E);if(!A)return e;let R=o?.layouts?.[b.resourceId];if(!R)return console.warn(`Form layout not found: ${b.resourceId}`),e;let $={id:"form-container",type:"container",x:0,y:0,children:R.elements||[]},j={...Fe({variables:a,imageGallery:l,musicRoom:u,sceneReplay:c,runtime:p,saveSlots:w,dialogueState:r.dialogue,isLineCompleted:t,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:y,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},x=tr($,j),M=Yo(nr(Ir(zo(x,b),{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o),b);M&&A.children.push(M);let B=sr({animationsDef:b.animations,resources:o,previousResourceId:n?.form?.resourceId,currentResourceId:b.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:b.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return ze({animationInstances:B,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&k.push(...B),e},Sh=(e,{presentationState:r,resources:n={},variables:o,imageGallery:i,musicRoom:t,sceneReplay:s,runtime:a,isLineCompleted:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],skipTransitionsAndAnimations:g})=>{if(!r.control?.resourceId)return e;let h=n.controls?.[r.control.resourceId];if(!h)return e;let w=gh(h.keyboard,h.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(h.elements)||h.elements.length===0)return e;let b=Vr(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(rc({container:E,resources:n,templateData:Fe({variables:o,imageGallery:i,musicRoom:t,sceneReplay:s,runtime:a,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},Rh=(e,{presentationState:r,resources:n,runtime:o,variables:i,musicRoomPlayer:t})=>{let{elements:s,audio:a}=e;if(r.bgm&&n){if(!Vr(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||Ln(p,"BGM sound"),m){let y=p.find(g=>g.loop===!0);if(y)throw new Error(`BGM sound "${y.id}" cannot loop inside a looping BGM channel.`)}if(p.forEach(y=>{let g=n.sounds?.[y.resourceId];if(!g)return;let h=m?{...y,loop:y.loop??!1}:y;d.push(Un({id:Nt("bgm",c?"default":y.id),sound:h,resource:g,defaultLoop:!m}))}),d.length===0)return e;let f=Fe({variables:i,runtime:o}).runtime;a.push(Fn({id:sh,volume:qn(f,"musicVolume",c?br:u.volume??br),muted:u.muted,pan:u.pan,loop:c?void 0:u.loop,playback:t?.bgmPlayback,interruption:u.interruption,children:d,runtime:f}))}return e},Oh=(e,{resources:r={},runtime:n,variables:o,musicRoomPlayer:i})=>{let t=r.musicRoom;if(!t||!i?.trackId||!i.playback)return e;let s=t.tracks.find(c=>c.id===i.trackId),a=s?r.sounds?.[s.soundId]:void 0;if(!s||!a)return e;let l=Fe({variables:o,runtime:n}).runtime,u=Un({id:ih,sound:{loop:!1,startDelayMs:0,playback:i.playback},resource:a});return e.audio.push(Fn({id:oh,volume:qn(l,"musicVolume",br),children:[u],runtime:l})),e},Ch=(e,{presentationState:r,resources:n,runtime:o})=>{let{audio:i}=e;if(r.sfx&&n){let t=r.sfx,s=!Array.isArray(t.channels),a=s?[{id:lh,sounds:t.items??[]}]:t.channels;s||Ln(a,"SFX channel"),a.forEach(l=>{let u=!s&&l.loop===!0,c=[];if(s||Ln(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let p=l.sounds.find(m=>m.loop===!0);if(p)throw new Error(`SFX sound "${p.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((p,m)=>{let d=n.sounds?.[p.resourceId];if(!d)return;let f=u?{...p,loop:p.loop??!1}:p;c.push(Un({id:s?Nt("sfx","default",m,p.id):Nt("sfx",l.id,p.id),sound:f,resource:d,defaultLoop:u?!1:void 0}))}),c.length!==0&&i.push(Fn({id:Nt("channel","sfx",l.id),volume:qn(o,"soundVolume",l.volume??br),muted:l.muted,pan:l.pan,loop:s?void 0:l.loop,interruption:s?void 0:l.interruption,children:c,runtime:o}))})}return e},$h=(e,r,n)=>{if(!(!r||!n))return e?.voices?.[r]?.[n]},_h=(e,{presentationState:r,resources:n,currentSceneId:o,runtime:i,variables:t})=>{let{audio:s}=e;if(!r?.voice)return e;let a=r.voice,l=!Array.isArray(a.sounds),u=l?a.resourceId?[{id:"default",resourceId:a.resourceId,loop:a.loop??!1,volume:br,startDelayMs:a.startDelayMs??0}]:[]:a.sounds,c=!l&&a.loop===!0,p=[];if(l||Ln(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=$h(n,o,d.resourceId);if(!f)return;let y=c?{...d,loop:d.loop??!1}:d;p.push(Un({id:Nt("voice",o,l?"default":d.id),sound:y,resource:f,defaultLoop:c?!1:void 0}))}),p.length===0)return e;let m=Fe({variables:t,runtime:i}).runtime;return s.push(Fn({id:ah,volume:l?a.volume??Ql(m,"soundVolume"):qn(m,"soundVolume",a.volume??br),muted:a.muted,pan:a.pan,loop:l?void 0:a.loop,interruption:a.interruption,children:p,runtime:m})),e},Th=(e,{presentationState:r,previousPresentationState:n,resources:o={},variables:i,imageGallery:t,musicRoom:s,sceneReplay:a,runtime:l,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:y=[],isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})=>{let{elements:b,animations:E}=e;if(r.layout){let $=Vr(b);if(!$)return e;let j=o.layouts?.[r.layout.resourceId];if(!j)return e;Array.isArray(j.transitions)&&!g&&!h&&Xo({animations:E,transitions:j.transitions,defaultTargetId:`layout-${r.layout.resourceId}`,idPrefix:`layout-${r.layout.resourceId}`,animationPathPrefix:"layout"});let x={id:`layout-${r.layout.resourceId}`,type:"container",x:0,y:0,children:j.elements||[]};$.children.push(rc({container:x,resources:o,templateData:Fe({variables:i,imageGallery:t,musicRoom:s,sceneReplay:a,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 k=n?.layout?.resourceId,A=r.layout?.resourceId,R=sr({animationsDef:r.layout?.animations,resources:o,previousResourceId:k,currentResourceId:A,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:A?`layout-${A}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return ze({animationInstances:R,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})&&E.push(...R),e},Nh=(e,{currentLineActions:r,previousPresentationState:n,resources:o={},isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:a}=e,l=r?.screen?.animations;if(!l)return e;let u=n!=null,c=sr({animationsDef:l,resources:o,previousResourceId:u?"story":void 0,currentResourceId:"story",previousTargetId:u?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return ze({animationInstances:c,isLineCompleted:i,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&a.push(...c),e},jh=(e,{presentationState:r})=>{let n=Vr(e.elements);return!n||!r?.screen||Object.assign(n,Kl(r.screen)),e},Dh=(e,{presentationState:r,resources:n={},variables:o,imageGallery:i,musicRoom:t,sceneReplay:s,runtime:a,autoMode:l,skipMode:u,isChoiceVisible:c,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:y=[],saveSlots:g=[],screen:h,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:E,animations:k}=e;return f&&f.length>0&&f.forEach((A,R)=>{let $=n.layouts?.[A.resourceId];if(!$){console.warn(`Overlay layout not found: ${A.resourceId}`);return}Array.isArray($.transitions)&&(b||Xo({animations:k,transitions:$.transitions,defaultTargetId:`overlayStack-${R}`,idPrefix:`overlayStack-${R}`,animationPathPrefix:`overlayStack[${R}]`}));let j={id:`overlayStack-${R}`,type:"container",x:0,y:0,children:[Zl({id:`overlayStack-${R}-blocker`,screen:h}),...$.elements||[]]},x=ec(y,n.characters,o),M=Fe({variables:o,imageGallery:i,musicRoom:t,sceneReplay:s,runtime:a,saveSlots:g,dialogueState:r?.dialogue,isLineCompleted:w,autoMode:l,skipMode:u,isChoiceVisible:c,isFormVisible:p,canRollback:m,form:d,historyDialogue:x,characters:n.characters||{},skipTransitionsAndAnimations:b}),B=tr(j,M),[pe,...G]=B.children||[],ae=nr(Ir({...B,children:G},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);E.push({...ae,children:pe?[pe,...ae.children||[]]:ae.children})}),e},Lh=(e,{presentationState:r,resources:n={},variables:o,imageGallery:i,musicRoom:t,sceneReplay:s,runtime:a,saveSlots:l=[],autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,dialogueHistory:g=[],screen:h,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:E,animations:k}=e;if(!y?.resourceId)return e;let A=n.layouts?.[y.resourceId];if(!A)return console.warn(`ConfirmDialog layout not found: ${y.resourceId}`),e;Array.isArray(A.transitions)&&!b&&Xo({animations:k,transitions:A.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let R={id:"confirmDialog",type:"container",x:0,y:0,children:[Zl({id:"confirmDialog-blocker",screen:h}),...A.elements||[]]},$=ec(g,n.characters,o),j=tr(R,Fe({variables:o,imageGallery:i,musicRoom:t,sceneReplay:s,runtime:a,saveSlots:l,dialogueState:r?.dialogue,isLineCompleted:w,autoMode:u,skipMode:c,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:y,historyDialogue:$,characters:n.characters||{},skipTransitionsAndAnimations:b})),[x,...M]=j.children||[],B=nr(Ir({...j,children:M},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);return E.push({...B,children:x?[x,...B.children||[]]:B.children}),e},Lt=e=>(r,n)=>vh(r,{...n,visualLayer:e}),Mh=Lt(er.BEHIND_BACKGROUND),Vh=Lt(er.BEHIND_CHARACTER),qh=Lt(er.BEHIND_DIALOGUE),Fh=Lt(er.BEHIND_CHOICE),Uh=Lt(er.FOREGROUND),nc=e=>vn(bh,[Sh,Mh,Ih,Vh,wh,qh,Ph,Fh,xh,Eh,Th,Uh,jh,Nh,Rh,Oh,Ch,_h,Dh,Lh])(e);function sc(e,r=""){let n=[],o=e.length,i=0,t=0,s=-1,a=()=>{let l=0,u=0,c;do c=parseInt(e[i++],36),l+=(c&15)<<u,u+=4;while(c&16);return l};for(;i<o;){let l=s+1+a();s=l+a(),n.push([l,s,r?parseInt(r[t++],36):0])}return n}function oc(e,r,n){let o=0,i=r.length-1;for(;o<=i;){let t=o+i>>>1,s=n[t];if(e<r[t])i=t-1;else if(e>s>>>5)o=t+1;else return s&31}return 0}var ic="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",ac="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",lc="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var cc=65535,Zo=40960,Bn=126976,dc=new Uint8Array(12288),fc=new Uint8Array(3072),mc=new Uint8Array(2816),yc,hc;{let e=(i,t,s,a,l)=>{let u=t+i.length-1;for(let c=s<t?t:s,p=a>u?u:a;c<=p;c++)i[c-t]=l},r=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[i,t,s]of sc(ic,ac))e(dc,0,i,t,s),e(fc,Zo,i,t,s),e(mc,Bn,i,t,s),t>=65040&&!(i>=Bn&&t<=129791)&&(r[o]=i,n[o++]=t<<5|s);yc=r.slice(0,o),hc=n.slice(0,o)}function uc(e){return e<12288?dc[e]:e<Zo?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?fc[e-Zo]: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>=Bn&&e<129792?mc[e-Bn]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:oc(e,yc,hc)}var gc=Uint8Array.from(lc,Number);function Bh(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 pc(e,r,n){switch(r){case 3:return e&24?n===8204?e&6:(e&24)===16||Bh(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*bc(e){let r=e.length;if(r===0)return;let n=e.codePointAt(0),o=n>cc?2:1,i=uc(n),t=50200>>i&1?pc(0,i,n):0,s=0,a=n,l=i;for(;o<r;){n=e.codePointAt(o);let u=n>cc?2:1,c=uc(n),p=gc[i<<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)?pc(t,c,n):0,m&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:a,_catBegin:l===15?0:l,_catEnd:i===15?0:i},s=o,a=n,l=c),o+=u,i=c}yield{segment:e.slice(s),index:s,input:e,_hd:a,_catBegin:l===15?0:l,_catEnd:i===15?0:i}}function*Ic(e){for(let r of bc(e))yield r.segment}{let e=bc("_");gc._keep=[e,e.next()]}var wc=1e3,Pc=50,zh=0,kc=100,vc=50,Yh=60,Gh=3,Hh=.5,Xh=2e4,Wh=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Kh=/^\s+$/u,Ac,Jh=e=>{let r=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Ic(r)):(Ac??=new n(void 0,{granularity:"grapheme"}),Array.from(Ac.segment(r),({segment:o})=>o))},Qh=e=>Jh(e).reduce((r,n)=>Kh.test(n)?r+Hh:Wh.test(n)?r+Gh:r+1,0),Zh=e=>2**(((Number.isFinite(e)?Math.min(kc,Math.max(zh,e)):Pc)-vc)/(kc-vc)),ei=({text:e="",baseDelay:r=wc,speed:n=Pc}={})=>{let o=Number.isFinite(r)?Math.max(0,r):wc,i=Zh(n),t=Qh(e)*Yh/i,s=Math.max(o,Xh);return Math.min(o+t,s)};var zn={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Cc=1,di=1,or=1,it="choice",kr="form",Ft=()=>({manual:{...zn.manual},auto:{...zn.auto},applyMode:zn.applyMode}),fi=()=>({groupId:null,variantId:null,pageIndex:0}),eg="music-room:player",rg=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Hn=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),mi=new Set,tg=new Set(["groupId","variantId"]),ng=new Set(["pageIndex"]),at=new Set,sg=new Set(["trackId"]),og=new Set(["positionMs"]),ig=new Set(["pageIndex"]),yi=new Set,ag=new Set(["sceneId"]),lg=new Set(["pageIndex"]),hi=()=>({pageIndex:0}),gi=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...Ft()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ti=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let r=we(e)?pr(e):e;return structuredClone(r)},L=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Xn=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},$c=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},Ut=(e,r,n)=>({commandId:Xn(e),operation:r,...n===void 0?{}:{positionMs:n}}),bi=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let r=e.global.musicRoomPlayer,n=r.bgmPlayback;r.trackId!==null&&(n={commandId:Xn(e),operation:"resume"}),e.global.musicRoomPlayer=Hn({bgmPlayback:n})},_c=(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},Tc=(e,r)=>{if(e==null||e==="")throw new Error(`${r} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${r} requires a non-empty string or finite number slotId`)},Ur=e=>String(e),Nc=()=>({sections:[],resources:[]}),jc=()=>({sceneIds:[]}),cg=e=>L(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Nc(),ug=e=>L(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):jc(),pg=e=>Array.isArray(e)?e.map(r=>r?.text??"").join(""):"",dg=({sectionId:e,lineId:r,content:n,dialogueState:o,characterName:i})=>({sectionId:e,lineId:r,content:n,text:pg(n),characterId:o.characterId,character:{...o.character||{},name:i},characterName:i}),Dc=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),fg=e=>L(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,Ii=e=>{if(!L(e?.dialogueHistory))return null;let r=e.dialogueHistory;return!Array.isArray(r.entries)||!Number.isInteger(r.currentLength)||!Array.isArray(r.checkpointLengths)?null:r},mg=e=>{if(!L(e?.dialogueHistory))return e.dialogueHistory=Dc(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},wi=e=>{let r=Ii(e);return r?(r.currentLength<r.entries.length&&(r.entries=r.entries.slice(0,r.currentLength)),r):null},yg=()=>({resourceId:void 0}),hg=e=>{if(!L(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},Ge=(e,r)=>{let n=e?.story?.scenes??{};for(let[o,i]of Object.entries(n))if(i?.sections?.[r])return{sceneId:o,section:i.sections[r]};return{sceneId:void 0,section:void 0}},Lc=e=>{let r=e?.story?.scenes??{},n=new Map;for(let[o,i]of Object.entries(r)){let t=i?.sections??{};for(let s of Object.keys(t)){let a=n.get(s);if(a!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${a}" and "${o}". Section IDs must be globally unique.`);n.set(s,o)}}},Mc=e=>e,Vc=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Cc)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},gg=(e,r={})=>{let n;try{n=Vc(r.formatVersion)}catch(i){throw new Error(`Hydrated save slot "${e}" failed validation: ${i.message}`)}let o={...r,formatVersion:n,slotId:Mc(r.slotId??r.slotKey??e),savedAt:typeof r.savedAt=="number"?r.savedAt:r.date};return delete o.slotKey,delete o.date,o},bg=(e={})=>Object.fromEntries(Object.entries(e).map(([r,n])=>[r,gg(r,n)])),Ig=(e,r)=>{if(!L(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!L(o))return!1;let{variableId:i,op:t,value:s,roundTo:a}=o,l=r?.resources?.variables?.[i];if(!l||Se(l)||l.readonly===!0||l.scope!=="context")return!1;try{return St(l.type,t,i),xn(l.type,t,s,i,{roundTo:a}),t!=="set"||Io(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},qc=(e,r)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!L(o)||!aw(o.type))return[];if(o.type!=="updateVariable"||r===void 0)return[o];let i=Ig(o.payload,r);return i?[{...o,payload:i}]:[]});return n.length>0?n:void 0},wg=(e,r,n)=>{let{section:o}=Ge(e,r?.sectionId),t=o?.lines?.find(({id:a})=>a===r?.lineId)?.actions,s=n.split(".");for(let a of s){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(a))return;let l=Number(a);if(!Object.prototype.hasOwnProperty.call(t,l))return;t=t[l];continue}if(!L(t)||!Object.prototype.hasOwnProperty.call(t,a))return;t=t[a]}return s.at(-1)==="random"&&L(t?.distribution)?t:void 0},Fc=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let r=e.max-e.min+1;return Number.isSafeInteger(r)&&r>=1&&r<=4294967296},Uc=(e,r,n)=>e.filter(({path:o,type:i,result:t})=>{let s=wg(n,r,o);if(s?.distribution?.type!==i)return!1;if(i==="weighted")return L(s.distribution.outcomes?.[t.outcomeIndex]?.actions);if(i==="integer"){let a=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&a?.type==="number"&&a.scope==="context"&&a.readonly!==!0&&!Se(a)&&Fc(s.distribution)&&t.value>=s.distribution.min&&t.value<=s.distribution.max}return!1}),ki=(e,r)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==or)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let n=new Set,o=e.randomOutcomes.map((i,t)=>{let s=`${i?.path}\0${i?.ordinal}`;if(!L(i)||typeof i.path!="string"||i.path.length===0||!Number.isSafeInteger(i.ordinal)||i.ordinal<0||n.has(s))throw new Error(`invalid rollback random outcome at index ${t}`);return n.add(s),{path:i.path,ordinal:i.ordinal,type:i.type,result:On(V(i.result),i.type)}});return r===void 0?o:Uc(o,e,r)},kg=(e,r)=>{!L(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=di,e.timeline.forEach(n=>{if(!L(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=qc(n.executedActions,r);o?n.executedActions=o:delete n.executedActions;let i=ki(n,r);i?(n.randomOutcomeVersion=or,n.randomOutcomes=i):(delete n.randomOutcomeVersion,delete n.randomOutcomes)}))},vg=(e,r)=>{let n=e??{};return Object.values(n).forEach(o=>{let i=o?.state?.contexts;Array.isArray(i)&&i.forEach(t=>{let s=t?.rollback?.timeline;Array.isArray(s)&&s.forEach(a=>{if(!L(a))return;let l=ki(a,r);l?(a.randomOutcomeVersion=or,JSON.stringify(a.randomOutcomes)!==JSON.stringify(l)&&(a.randomOutcomes=l)):(delete a.randomOutcomeVersion,delete a.randomOutcomes)})})}),n},xc=(e,r,n,o="viewedRegistry")=>{let i=r==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[i]:String(e)};if(!L(e))throw new Error(`Malformed ${o}.${r}[${n}] entry.`);if(typeof e[i]!="string"||e[i].length===0)throw new Error(`Malformed ${o}.${r}[${n}] entry: missing ${i}.`);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}},Ag=(e,r="viewedRegistry")=>{if(e===void 0)return Nc();if(!L(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((i,t)=>{let s=xc(i,"sections",t,r);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((i,t)=>{let s=xc(i,"resources",t,r);return[s.resourceId,s]})))}},Pg=(e,r="accountReplayRegistry")=>{if(e===void 0)return jc();if(!L(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,i)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${r}.sceneIds[${i}] entry.`);return o}))]}},Mt=(e,r,n)=>{if(!L(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:o,lineId:i}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof i!="string"||i.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:t,section:s}=Ge(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===i))throw new Error(`Malformed save slot ${n}: line "${i}" does not exist in section "${o}".`);return{sceneId:t,sectionId:o,lineId:i}},Bc=e=>{let r=e.story.initialSceneId,n=e.story.scenes[r],o=n.initialSectionId,i=n.sections[o];return Mt({sceneId:r,sectionId:o,lineId:i.initialLineId??i.lines[0].id},e,"projectData initial pointer")},xg=e=>{try{return Bc(e),!0}catch{return!1}},Eg=(e,r,n)=>{let o=e?.pointers?.read;if(!L(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return Mt(o,r,n);try{return Mt(o,r,n)}catch{let i=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],t=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,i.length-1):i.length-1;for(let s=t;s>=0;s-=1)try{return Mt(i[s],r,`${n} compatibility checkpoint`)}catch{}return Bc(r)}},zc=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,vi=(e,r)=>{let{section:n}=Ge(e,r?.sectionId);return n?.lines?.find(o=>o.id===r?.lineId)},Sg=(e,r,n)=>{if(!L(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],i=[0],t=!1;if(e.entries.forEach((a,l)=>{if(!L(a))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof a.sectionId!="string"||a.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof a.lineId!="string"||a.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(a.appendToPrevious!==void 0&&typeof a.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:u}=Ge(r,a.sectionId);if(!u?.lines?.some(p=>p.id===a.lineId)){t=!1,i.push(o.length);return}o.push({sectionId:a.sectionId,lineId:a.lineId,...a.appendToPrevious===!0&&t&&o.length>0?{appendToPrevious:!0}:{}}),t=!0,i.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((a,l)=>{if(!Number.isInteger(a)||a<0||a>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return i[a]});return{entries:o,currentLength:i[e.currentLength],checkpointLengths:s}},Rg=(e,r)=>L(vi(e,r)?.actions?.dialogue),Yc=(e,r,n)=>{if(!r||r.sectionId!==n.sectionId)return!1;let{section:o}=Ge(e,n.sectionId),i=o?.lines?.findIndex(s=>s.id===n.lineId);return typeof i!="number"||i<=0?!1:o.lines.slice(0,i).findLast(s=>L(s.actions?.dialogue))?.id===r.lineId},Og=(e,r)=>{let n=Dc();return e.timeline.forEach(o=>{if(o.returnable!==!1&&Rg(r,o)){let i=vi(r,o),t=n.entries.at(-1),s=i.actions.dialogue.append===!0&&Yc(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},Cg=(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 i=0;return e.checkpointLengths.forEach((t,s)=>{if(t<i)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);i=t}),e},$g=(e,r)=>{let{section:n}=Ge(e,r?.sectionId),o=n?.lines?.findIndex(t=>t.id===r?.lineId);if(typeof o!="number"||o<0)return null;let i=n.lines[o+1];return i?{sectionId:r.sectionId,lineId:i.id}:null},Gc=(e,r,n)=>{if(typeof r?.sectionId!="string")return!1;let{section:o}=Ge(e,r.sectionId);return zc({sectionId:r.sectionId,lineId:o?.lines?.[0]?.id},n)},_g=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),st={always:"always",maybe:"maybe",never:"never"},Tg=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return st.always;let r=e.when,n;if(r===null||typeof r=="boolean"||typeof r=="number")n=r;else if(L(r)&&Object.keys(r).length===1&&Object.prototype.hasOwnProperty.call(r,"literal"))n=r.literal;else return st.maybe;return n?st.always:st.never},Hc=(e,r)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let o=Tg(n);if(o!==st.never){if(r(n))return!0;if(o===st.always)return!1}}return!1},Xc=e=>Hc(e,r=>Object.entries(r?.actions??{}).some(([n,o])=>n==="conditional"?Xc(o):_g.has(n))),Wc=(e,r,n)=>Hc(r,o=>Object.entries(o?.actions??{}).some(([i,t])=>i==="sectionTransition"?Gc(e,t,n):i==="conditional"?Wc(e,t,n):!1)),Ng=(e,r,n)=>{if(!r)return!0;let o=vi(n,e)?.actions;if(!L(o))return!0;if(Gc(n,o.sectionTransition,r))return!1;let i=o.conditional;return i?!(Wc(n,i,r)||!(o.choice?.resourceId||o.form?.resourceId)&&!Xc(i)&&zc($g(n,e),r)):!0},jg=(e,r,n)=>{if(!L(e)||!Array.isArray(e.timeline))return{rollback:qt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=new WeakSet,i=[],t=e.timeline.flatMap((p,m)=>{if(!L(p))return[];let d=ki(p);try{let f=Mt(p,n,`rollback.timeline[${m}]`),y=d?Uc(d,f,n):void 0,g=Gn({sectionId:f.sectionId,lineId:f.lineId,rollbackPolicy:p.rollbackPolicy,returnable:p.returnable,...y?{randomOutcomeVersion:or,randomOutcomes:y}:{}});typeof p.returnable=="boolean"&&o.add(g);let h=qc(V(p.executedActions),n);return h&&(g.executedActions=h),i.push(m),[g]}catch{return[]}});if(t.length===0)return{rollback:qt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};e.returnabilityVersion!==di&&t.forEach((p,m)=>{!o.has(p)&&!Ng(p,t[m+1],n)&&(p.returnable=!1)});let a=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,l=i.indexOf(a);l<0&&(l=t.length-1);let u=t[l];if(u?.sectionId!==r.sectionId||u?.lineId!==r.lineId){let p=t.findLastIndex(m=>m.sectionId===r.sectionId&&m.lineId===r.lineId);p>=0?l=p:(t.push(Gn({sectionId:r.sectionId,lineId:r.lineId})),i.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:i,sourceTimelineLength:e.timeline.length}},Kc=(e,r,n)=>{if(!L(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Pi(r),i=Eg(e,r,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!L(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!L(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let t=e.variables?xt(V(e.variables),r.resources?.variables??{},{allowedScopes:["context"]}):{},s=Xg({loadedContextRuntime:L(e.runtime)?V(e.runtime):{}}),{rollback:a,sourceCheckpointIndexes:l,sourceTimelineLength:u}=jg(e.rollback,i,r),c=e.dialogueHistory===void 0?Og(a,r):Cg(Sg(e.dialogueHistory,r,`contexts[${n}].dialogueHistory`),a,l,u),p={currentPointerMode:"read",pointers:{read:i},configuration:L(e.configuration)?V(e.configuration):{},views:Array.isArray(e.views)?V(e.views):[],bgm:L(e.bgm)?V(e.bgm):{resourceId:void 0},variables:{...o,...t},...c?{dialogueHistory:c}:{},rollback:a};return s&&(p.runtime=s),p},Dg=(e,r)=>{if(!L(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((n,o)=>Kc(n,r,o))}},Lg=(e,r)=>{if(!L(e))throw new Error("Malformed save slot.");let n=Vc(e.formatVersion);return{...e,formatVersion:n,state:Dg(e.state,r)}},Ec=(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=V(e),i=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:i,...o}},Mg=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:Ec(e.confirmActions,"confirmActions",{required:!0}),cancelActions:Ec(e.cancelActions,"cancelActions")}},lt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Vg=e=>(L(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),ct=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Jc=e=>{if(!(!L(e)||!e.animations))return{animations:V(e.animations)}},qg=(e,r)=>{let n=Jc(r);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Fg=e=>{let r=e?.id??e?.resourceId;return typeof r=="string"&&r.length>0?r:void 0},Ug=(e,r)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!r))return`${n}:${o}:${r}`},Yn=e=>String(e??""),Qc=(e,r)=>{let n=Yn(r);return e?.trim===!0?n.trim():n},Bg=e=>L(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,r])=>L(r)).map(([r,n])=>[r,{id:r,...V(n)}])):{},zg=(e,r)=>{if(!r||!L(e.global.formDrafts))return;let n=e.global.formDrafts[r];return L(n)?n:void 0},Zc=(e,r)=>{let n=Vg(e);L(n[r])||(n[r]={values:{},touched:{},errors:{},submitted:!1});let o=n[r];return L(o.values)||(o.values={}),L(o.touched)||(o.touched={}),L(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},Ai=(e,r)=>{let n=Qc(e,r);return e?.required===!0&&n.length===0?"required":null},Yg=({state:e,pointer:r})=>{if(!r?.sectionId||!r?.lineId)return{};let o=ve({state:e},{sectionId:r.sectionId})?.lines||[],i=o.findIndex(t=>t.id===r.lineId);return i<0?{}:Lr(o.slice(0,i+1).map(t=>t.actions||{}))},Gg=({state:e,form:r,pointer:n})=>{if(!r?.resourceId)return null;let o=Fg(r),i=Ug(n,o);if(!o||!i)return null;let t=zg(e,i),s=Bg(r),a=Li({state:e}),l={},u=[],c={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=Yn(a?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(t?.values??{},m)?Yn(t.values[m]):f,g=t?.touched?.[m]===!0,h=Ai(d,y),w=t?.submitted||g?h:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,E={id:m,variableId:d.variableId,value:y,initialValue:f,valid:!h,error:w,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[m]=E,u.push(E),c[m]=y}),{id:o,key:i,resourceId:r.resourceId,animations:r.animations,valid:p,submitted:t?.submitted===!0,fields:l,fieldList:u,values:c,submitActions:{submitForm:{formKey:i,actions:V(r.submitActions??{})}},cancelActions:{cancelForm:{formKey:i,actions:V(r.cancelActions??{})}}}},ot="line",wr="interaction",Gn=({sectionId:e,lineId:r,rollbackPolicy:n,returnable:o,randomOutcomeVersion:i,randomOutcomes:t})=>({sectionId:e,lineId:r,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{},...i===or?{randomOutcomeVersion:or,randomOutcomes:V(t??[])}:{}}),Pi=e=>{let r=we(e)?pr(e):e,{contextVariableDefaultValues:n}=Pn(r??{});return V(n)},eu=()=>({...V($t)}),ru=({loadedRuntime:e,runtimeIds:r,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:V(n),hasLoadedValues:!1};if(!L(e))throw new Error(`Malformed ${o}.`);let i=V(n),t=!1;return r.forEach(s=>{e[s]!==void 0&&(i[s]=_n(s,V(e[s])),t=!0)}),{runtimeState:i,hasLoadedValues:t}},Hg=({projectData:e,loadedGlobalRuntime:r={}})=>ru({loadedRuntime:r,runtimeIds:Eo,defaults:Ro(e),path:"global.runtime"}).runtimeState,Xg=({loadedContextRuntime:e={}})=>{let{runtimeState:r,hasLoadedValues:n}=ru({loadedRuntime:e,runtimeIds:So,defaults:eu(),path:"context.runtime"});return n?r:void 0},Ar=e=>{let r=Array.isArray(e?.contexts)?e.contexts:[];return r[r.length-1]},fe=e=>{let r=Ar(e);return r?.kind==="sceneReplay"&&L(r.sceneReplay)?r:null},tu=(e,r)=>{let n=r?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(i=>i.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([i,t])=>{r.variables[i]=V(t)})},Wg=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:V(e.global.nextLineConfig),overlayStack:V(e.global.overlayStack),confirmDialog:V(e.global.confirmDialog),formDrafts:V(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:V(e.global.pendingScreenTransition)}}),Kg=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=Ft(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Jg=(e,r)=>{e.global.autoMode=r.autoMode,e.global.skipMode=r.skipMode,e.global.dialogueUIHidden=r.dialogueUIHidden,e.global.nextLineConfig=V(r.nextLineConfig),e.global.overlayStack=V(r.overlayStack),e.global.confirmDialog=V(r.confirmDialog),e.global.formDrafts=V(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=V(r.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Ae({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e.global.skipMode&&!n&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!n&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Qg=e=>e.runtime?(So.forEach(r=>{e.runtime[r]===void 0&&(e.runtime[r]=V($t[r]))}),e.runtime):(e.runtime=eu(),e.runtime),Zg=e=>Sl(e.global),nu=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Zg(e)}})},xi=(e,r,n)=>{let o=_n(r,n);if(r in $t){let i=Ar(e);if(!i)return o;let t=Qg(i);return t[r]=o,o}return e.global[r]=o,o},Ei=({pointer:e,projectData:r,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:V(o)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:yg(),variables:Pi(r),rollback:qt({pointer:e})}),ut=e=>e?(e.currentPointerMode="read",L(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,eb=(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 i=Ei({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=i,rb(e,{queueRender:r}),i},rb=(e,{queueRender:r=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,lt(e),ct(e),e.global.nextLineConfig=Ft(),e.global.overlayStack=[],e.global.isLineCompleted=!0,bi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),r&&e.global.pendingEffects.push({name:"render"})},su=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},qt=({pointer:e,replayStartIndex:r=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:r,timeline:n?[Gn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Pr=(e,r={})=>{if(e?.rollback)return su(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=qt({pointer:n,replayStartIndex:r.compatibilityAnchor?1:0}),e.rollback},Wn=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=Pr(n);if(o.isRestoring)return;let i=wi(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(Gn(r)),o.currentIndex=o.timeline.length-1,i&&(i.checkpointLengths=i.checkpointLengths.slice(0,o.currentIndex),i.checkpointLengths.push(i.currentLength))},tb=({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}},nb=({state:e},r={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:i,lineId:t}=r,a=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(a?.timeline)||typeof a.currentIndex!="number")return e;let l=a.timeline[n];return(we(l)?un(l):l)!==o||l?.sectionId!==i||l?.lineId!==t||(l.returnable=!1),e},sb=({state:e},r={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:i,sectionId:t,lineId:s}=r,a=Ur(n),l=e.global.saveSlots?.[a],u=we(l)?un(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?.[i];return!Number.isInteger(i)||m?.currentIndex!==i||p?.pointers?.read?.sectionId!==t||p?.pointers?.read?.lineId!==s||d?.sectionId!==t||d?.lineId!==s||(d.returnable=!1,m.returnabilityVersion=di,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},ou=(e,r)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let i=r?.at(-1),t=typeof i?.checkpointIndex=="number"?i.checkpointIndex:o.currentIndex;if(t<0||t>=o.timeline.length)return null;if(typeof i?.checkpointIndex!="number"&&t<o.timeline.length-1){o.timeline=o.timeline.slice(0,t+1);let s=wi(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,t+1))}return o.timeline[t]??null},ob=({state:e,rollbackActionBatchStack:r,playbackOwnership:n},o={})=>{let i=o?.source===ot?ot:wr,t=e.contexts?.[e.contexts.length-1],s=t?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return r.push({checkpointIndex:null,source:i}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let c=wi(t);c&&(c.checkpointLengths=c.checkpointLengths.slice(0,s.currentIndex+1))}let a=t?.pointers?.read,l=n?.lineEntryId,u=i===ot&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===a?.sectionId&&s.timeline[s.currentIndex]?.lineId===a?.lineId:n.rollbackCheckpointLineEntryId===l);return r.push({checkpointIndex:s.currentIndex,source:i,...i===ot?{lineEntryId:l,sourcePointer:a?{sectionId:a.sectionId,lineId:a.lineId}:null,hasTrackedLineEntryCheckpoint:u}:{}}),e},ib=({state:e,rollbackActionBatchStack:r})=>(r.pop(),e),ab=({state:e,rollbackActionBatchStack:r,playbackOwnership:n})=>{let o=r?.at(-1);if(o?.source!==ot||o.hasTrackedLineEntryCheckpoint)return e;let i=o.sourcePointer;if(!i)return e;Wn(e,{sectionId:i.sectionId,lineId:i.lineId,returnable:!1});let s=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=s.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,n?.lineEntryId===o.lineEntryId&&(n.rollbackCheckpointLineEntryId=o.lineEntryId),e},lb=({state:e,rollbackActionBatchStack:r},n)=>{if(r?.at(-1)?.source!==ot)return e;if(typeof n?.path!="string"||n.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(n.ordinal)||n.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let i=On(n.result,n.type),t=ou(e,r);if(!t)return e;if(t.randomOutcomeVersion!==or&&(t.randomOutcomeVersion=or,t.randomOutcomes=[]),t.randomOutcomes.some(({path:s,ordinal:a})=>s===n.path&&a===n.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${n.path}#${n.ordinal}`);return t.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:i}),e},We=(e,r,n,o)=>{let t=o?.at(-1)?.source??wr;if(!lw(r,t))return;let s=ou(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:r,payload:V(n)}))},ni=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=r?.operations??[];for(let{variableId:i,op:t,value:s,roundTo:a}of o){let l=e.projectData.resources?.variables?.[i],u=l?.scope,c=l?.type;if(Se(l))throw new Error(`Cannot update computed variable: ${i}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${i}`);Et(u,i),St(c,t,i),xn(c,t,s,i,{roundTo:a}),u==="context"&&(n.variables[i]=En(n.variables[i],t,s,{roundTo:a}))}},cb=(e,r)=>{Array.isArray(r?.executedActions)&&r.executedActions.forEach(({type:n,payload:o})=>{cw(e,n,o)})},ub=(e,r)=>{let{sectionId:n,lineId:o}=r,s=ve({state:e},{sectionId:n})?.lines?.find(a=>a.id===o)?.actions;s&&Fi(e,s,{checkpoint:r,bindings:{},randomOutcomeOrdinals:new Map},[])},iu=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=Pr(n),i=o.timeline[r];if(!i)return e;e.global.autoMode&&Gt({state:e}),e.global.skipMode&&vr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=r;try{n.variables=Pi(e.projectData),n.kind==="sceneReplay"&&(tu(e,n),n.sceneReplay.finishOnNextAdvance=!1,n.sceneReplay.exitOnLineCompleted=!1),delete n.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=V(zn),e.global.overlayStack=[],lt(e),ct(e),e.global.isLineCompleted=!0;let t=o.replayStartIndex??0;for(let l=t;l<=r;l++)l>t&&gi(e),ub(e,o.timeline[l]),cb(e,o.timeline[l]);let s=ut(n);s.read={sectionId:i.sectionId,lineId:i.lineId};let a=Ii(n);a&&(a.currentLength=Math.min(a.checkpointLengths[r]??0,a.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=$c(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},pb=e=>{let{projectData:r}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:i={},variables:t={},runtime:s={},accountViewedRegistry:a={},accountReplayRegistry:l={},localizationPackages:u=[{l10nId:null,language:null}]}=o;Lc(r),vt(r),At(r),Pt(r),jr(r?.resources?.variables??{});let c=r.story.initialSceneId,p=r.story.scenes[c],m=p.initialSectionId,d=p.sections[m],f={sceneId:c,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:y}=Pn(r),g={...y,...xt(t,r.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:r,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Ag(a,"accountViewedRegistry"),accountReplayRegistry:Pg(l),nextLineConfig:Ft(),imageGalleryNavigation:fi(),sceneReplayNavigation:hi(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:Hn(),saveSlots:bg(i),localizationPackages:V(u),overlayStack:[],variables:g,...Hg({projectData:r,loadedGlobalRuntime:s})},contexts:[Ei({pointer:f,projectData:r})]}},db=({state:e})=>e.global.overlayStack||[],fb=({state:e})=>e.global.pendingEffects,au=({state:e})=>e.global.skipMode,mb=({state:e})=>e.global.autoMode,lu=({state:e})=>e.global.dialogueUIHidden,cu=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(!n)return[];let o,i=L(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(i)o=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:u,lineId:c}=n.pointers.read,p=ve({state:e},{sectionId:u});if(!p?.lines||!Array.isArray(p.lines))return[];let m=p.lines.findIndex(d=>d.id===c);o=p.lines.slice(0,m+1).map(d=>({sectionId:u,lineId:d.id}))}let t=[],s=Jr({variables:{...e.global?.variables??{},...Ar(e)?.variables??{}},runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),a=new Map,l=u=>{let c=a.get(u.sectionId);if(!c){let m=ve({state:e},{sectionId:u.sectionId}),d=Array.isArray(m?.lines)?m.lines:[];c={lines:d,lineIndexes:new Map(d.map((f,y)=>[f.id,y])),projections:new Map,nextLineIndex:0,presentationState:{}},a.set(u.sectionId,c)}let p=c.lineIndexes.get(u.lineId);if(p===void 0)return null;for(;c.nextLineIndex<=p;){let m=c.lines[c.nextLineIndex],d=m.actions||{};c.presentationState=Lr([c.presentationState,d]),c.projections.set(m.id,{line:m,lineActions:d,dialogueState:c.presentationState.dialogue||{}}),c.nextLineIndex+=1}return c.projections.get(u.lineId)??null};for(let u of o){if(!fg(u))continue;let c=l(u);if(!c)continue;let{line:p,lineActions:m,dialogueState:d}=c;if(!m.dialogue)continue;let f=An({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:s}),y=dg({sectionId:u.sectionId,lineId:p.id,content:m.dialogue.append===!0?d.content:m.dialogue.content,dialogueState:d,characterName:f}),g=t[t.length-1];if((i?u.appendToPrevious===!0:m.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},yb=(e,r,n)=>{let o=!1;for(let i of r??[]){let{slotId:t,saveSlotIdentity:s,sectionId:a,lineId:l}=i,u=e.global.saveSlots?.[Ur(t)],c=we(u)?un(u):u,p=u?.state?.contexts?.at(-1);!u||c!==s||p?.pointers?.read?.sectionId!==a||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=V(n),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},hb=({state:e},r={})=>{let n=Ar(e),o=n?.pointers?.read,i=zt({state:e});if(!n||!L(i?.actions?.dialogue))return e;let t=Pr(n),s=t.timeline?.[t.currentIndex],a=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=Ii(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&&a&&l&&u===l.currentLength&&u>c&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let m=mg(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=i.actions.dialogue.append===!0&&r.appendToPrevious===!0&&Yc(e.projectData,p,o);if(m.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,a){for(;m.checkpointLengths.length<t.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[t.currentIndex]=m.currentLength}return yb(e,r.savedCheckpointOccurrences,m),e},gb=({state:e})=>e.global.confirmDialog??null,Bt=({state:e},{pointer:r}={})=>{let n=r??Te({state:e})?.pointer,o=Yg({state:e,pointer:n});return Gg({state:e,form:o.form,pointer:n})},bb=({state:e},{pointer:r}={})=>!!Bt({state:e},{pointer:r}),Ae=({state:e},{pointer:r}={})=>{let n=Bt({state:e},{pointer:r});if(n)return{source:kr,formId:n.id,formKey:n.key};let o=yu({state:e,pointer:r});return o?{source:it,resourceId:o}:null},Ib=({state:e,registry:r},n)=>{let{sectionId:o,lineId:i}=n,s=(Array.isArray(r?.sections)?r.sections:[]).find(c=>c.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||i===void 0)return!0;let a=ve({state:e},{sectionId:o});if(!a||!a.lines||!Array.isArray(a.lines))return s.lastLineId===i;let l=a.lines.findIndex(c=>c.id===s.lastLineId),u=a.lines.findIndex(c=>c.id===i);return l===-1||u===-1?s.lastLineId===i:u<=l},Si=({registry:e},r)=>{let{resourceId:n}=r;return!!(Array.isArray(e?.resources)?e.resources:[]).find(t=>t.resourceId===n)},Ri=({state:e},r)=>Ib({state:e,registry:e.global.accountViewedRegistry},r),wb=({state:e},r)=>Si({registry:e.global.accountViewedRegistry},r),Vt=(e,r)=>!Si({registry:e.global.accountViewedRegistry},{resourceId:r.imageId}),Oi=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Ci=(e,r)=>{let n=Oi(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},si=(e,r,n,o)=>{for(let i=n+o;i>=0&&i<r.length;i+=o)if(!Vt(e,r[i]))return r[i]},kb=({state:e})=>{let r=e.projectData?.resources?.imageGallery;return r===void 0?void 0:V(r)},uu=({state:e})=>{let r=e.projectData?.resources?.imageGallery;if(r===void 0)return null;let n=e.global.imageGalleryNavigation??fi(),o=Oi(r),i=Ci(r,n),t=i*r.pageSize,s=r.groups.slice(t,t+r.pageSize).map(l=>({groupId:l.id,locked:Vt(e,l.variants[0]),variants:l.variants.map(u=>({variantId:u.id,imageId:u.imageId,locked:Vt(e,u)}))})),a=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===i&&!Vt(e,p)&&(a={groupId:u.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:si(e,u.variants,c,-1)!==void 0,canMoveToNextVariant:si(e,u.variants,c,1)!==void 0})}return{pageGroups:s,selection:a,pagination:{pageIndex:i,pageCount:o,canMoveToPreviousPage:i>0,canMoveToNextPage:i+1<o}}},$i=(e,r)=>!Si({registry:e.global.accountViewedRegistry},{resourceId:r.soundId}),_i=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ti=(e,r)=>{let n=_i(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},oi=(e,r,n,o)=>{for(let i=n+o;i>=0&&i<r.length;i+=o)if(!$i(e,r[i]))return r[i]},pu=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}),vb=(e,r)=>({...pu(r),locked:$i(e,r)}),Sc=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 i=Math.floor(o/60),t=o%60;return`${i}:${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`},Ab=({state:e})=>{let r=e.projectData?.resources?.musicRoom;return r===void 0?void 0:V(r)},du=({state:e})=>{let r=e.projectData?.resources?.musicRoom;if(r===void 0)return null;let n=e.global.musicRoomPlayer??Hn(),o=_i(r),i=Ti(r,n),t=i*r.pageSize,s=r.tracks.slice(t,t+r.pageSize).map(c=>vb(e,c)),a=r.tracks.findIndex(c=>c.id===n.trackId),l=r.tracks[a],u=l?{...pu(l),canPlayPreviousTrack:oi(e,r.tracks,a,-1)!==void 0,canPlayNextTrack:oi(e,r.tracks,a,1)!==void 0}:null;return{pageTracks:s,selection:u,playback:u?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Sc(n.positionMs),durationText:n.durationMs===null?null:Sc(n.durationMs),canPlay:n.status!=="playing",canPause:n.status==="playing",canSeek:n.readiness==="ready"&&n.durationMs!==null}:null,pagination:{pageIndex:i,pageCount:o,canMoveToPreviousPage:i>0,canMoveToNextPage:i+1<o}}},Ni=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),ji=(e,r)=>{let n=Ni(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Pb=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;return r===void 0?void 0:V(r)},xb=({state:e})=>fe(e)!==null,Eb=({state:e})=>{let r=fe(e);return r?{sceneId:r.sceneReplay.sceneId,entryId:r.sceneReplay.entryId}:null},fu=(e,r)=>e.global.accountReplayRegistry?.sceneIds?.includes(r)===!0,mu=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;if(r===void 0)return null;let n=e.global.sceneReplayNavigation??hi(),o=Ni(r),i=ji(r,n),t=i*r.pageSize,s=r.replays.slice(t,t+r.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!fu(e,l.sceneId)})),a=fe(e);return{isActive:a!==null,activeSceneId:a?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:i,pageCount:o,canMoveToPreviousPage:i>0,canMoveToNextPage:i+1<o}}},Sb=({state:e})=>e.global.nextLineConfig,yu=({state:e,pointer:r}={})=>{let n=r??Te({state:e})?.pointer;if(!n)return;let o=n?.sectionId,i=n?.lineId,s=ve({state:e},{sectionId:o})?.lines||[],a=s.findIndex(u=>u.id===i);if(a<0)return;let l;for(let u of s.slice(0,a+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},hu=({state:e})=>!!yu({state:e}),Rb=({state:e})=>structuredClone(e),Ob=({state:e})=>V(e.projectData.resources?.achievements??{}),Cb=({state:e},r)=>{let n=e.projectData.resources?.achievements?.[r?.resourceId];return n===void 0?void 0:V(n)},gu=({state:e})=>e.global.saveSlots,$b=({state:e},r)=>{let n=r?.slotId,o=Ur(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},bu=({state:e})=>V(e.global.localizationPackages),Di=({state:e})=>gr(e),_b=({state:e},r)=>Xe(e,r?.runtimeId),Li=({state:e})=>{let r={...e.global?.variables??{},...Ar(e)?.variables??{}};return Jr({variables:r,runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{}})},Te=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},ve=({state:e},r)=>{let{sectionId:n}=r;return Ge(e.projectData,n).section},zt=({state:e})=>{let r=Te({state:e});if(!r?.pointer)return;let{sectionId:n,lineId:o}=r.pointer,i=ve({state:e},{sectionId:n});if(!(!i?.lines||!Array.isArray(i.lines)))return i.lines.find(t=>t.id===o)},Iu=({state:e})=>{let{sectionId:r,lineId:n}=Te({state:e}).pointer,i=ve({state:e},{sectionId:r})?.lines||[],t=i.findIndex(u=>u.id===n),a=i.slice(0,t+1).map(u=>{let c=u.actions||{},p={};return Object.keys(c).forEach(m=>{p[m]=c[m]}),p});return Lr(a)},wu=e=>{let r=zt({state:e})?.actions?.dialogue;if(r?.clear===!0||!Array.isArray(r?.content))return"";let n=Jr({variables:{...e.global?.variables??{},...Ar(e)?.variables??{}},runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return r.content.map(o=>`${Zr(o?.text,{variables:n})??""}`).join("")},ir=({state:e})=>ei({text:wu(e),baseDelay:Xe(e,"autoForwardDelay"),speed:Xe(e,"autoForwardSpeed")}),Tb=({state:e})=>{let r=ku({state:e}),o=zt({state:e})?.actions??{},i=Lr([r??{},o]);return ko(r??{},i??{})},Nb=({state:e},{sectionId:r})=>{let n=ve({state:e},{sectionId:r});if(!n?.lines)return[];let o=[],i={};for(let t of n.lines){let s=t.actions||{},a=Lr([i,s]),l=ko(i,a);o.push({id:t.id,changes:l,presentationState:a}),i=vo(a)}return o},jb=({state:e},{sectionId:r,includePresentationState:n=!1})=>{let o=Nb({state:e},{sectionId:r});return n?{lines:o}:{lines:o.map(({presentationState:i,...t})=>t)}},ku=({state:e})=>{let{sectionId:r,lineId:n}=Te({state:e}).pointer,i=ve({state:e},{sectionId:r})?.lines||[],t=i.findIndex(l=>l.id===n);if(t<=0)return null;let a=i.slice(0,t).map(l=>{let u=l.actions||{},c={};return Object.keys(u).forEach(p=>{c[p]=u[p]}),c});return vo(Lr(a))},Mi=({state:e},{slotsPerPage:r=6}={})=>{let i=((Di({state:e}).saveLoadPagination??1)-1)*r+1,t=[];for(let s=0;s<r;s++){let a=i+s,l=e.global.saveSlots&&e.global.saveSlots[Ur(a)]||{};t.push({...l,slotId:a})}return{saveSlots:t}},Db=gu,Lb=Mi,Mb=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},Vb=({state:e},r={})=>{let n=Iu({state:e}),o=ku({state:e}),i=zt({state:e})?.actions??{},t=e.global.pendingScreenTransition,s=t?.animations?{...i,screen:V(t)}:i,a=t?.animations&&o===null?{}:o,{sectionId:l}=Te({state:e}).pointer,{sceneId:u}=Ge(e.projectData,l),c={...Di({state:e}),localizationPackages:bu({state:e})},p=r?.activePersistentAnimations??[],m=r?.restoredPersistentAnimations??[],d=Bt({state:e}),f=hu({state:e}),y=uu({state:e}),g=du({state:e}),h=mu({state:e}),w=Li({state:e}),{saveSlots:b}=Mi({state:e}),E=Mb(e);return nc({presentationState:n,previousPresentationState:a,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:zu({state:e}),skipOnlyViewedLines:!c.skipUnseenText,isLineCompleted:c.isLineCompleted,skipTransitionsAndAnimations:!!c.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:cu({state:e}),saveSlots:b,variables:w,runtime:c,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:V(e.global.musicRoomPlayer)})},qb=({state:e},r)=>(e.global.confirmDialog=Mg(r),e.global.pendingEffects.push({name:"render"}),e),Fb=({state:e})=>(e.global.confirmDialog&&(lt(e),e.global.pendingEffects.push({name:"render"})),e),Ub=({state:e,rollbackActionBatchStack:r},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),We(e,"pushOverlay",n,r),e),Bb=({state:e,rollbackActionBatchStack:r})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),We(e,"popOverlay",void 0,r),e),zb=({state:e,rollbackActionBatchStack:r},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),We(e,"replaceLastOverlay",n,r),e),Yb=({state:e,rollbackActionBatchStack:r})=>(e.global.overlayStack=[],lt(e),ct(e),e.global.pendingEffects.push({name:"render"}),We(e,"clearOverlays",void 0,r),e),Gb=(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"})},Yt=(e,r,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,qg(e,n),ct(e);let o=Ae({state:e},{pointer:r}),i=o?.source===it,t=o?.source===kr;Gb(e,{activeInteraction:o});let s=fe(e),a={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=$c(e);s.sceneReplay.entryId=l,a.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(a),{isChoiceVisible:i,isFormVisible:t,activeInteraction:o}},Kn=(e,r,n)=>{!(r?.source===it||r?.source===kr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},vu=({state:e})=>(Ae({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),Gt=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Hb=({state:e})=>{let r=e.global.autoMode;return Ae({state:e})&&!r||(r?Gt({state:e}):vu({state:e})),e},Au=({state:e})=>(Ae({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),vr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Xb=({state:e})=>{let r=au({state:e});return Ae({state:e})&&!r||(r?vr({state:e}):Au({state:e})),e},Jn=({state:e,rollbackActionBatchStack:r})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),We(e,"showDialogueUI",void 0,r),e),Pu=({state:e,rollbackActionBatchStack:r})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),We(e,"hideDialogueUI",void 0,r),e),Wb=e=>{let{state:r}=e;return lu({state:r})?Jn(e):Pu(e),r},xr=(e,r,n)=>(xi(e,r,n),nu(e),e.global.pendingEffects.push({name:"render"}),e),Ht=(e,r,n,o,i)=>{let t=xi(e,r,n);return e.global.pendingEffects.push({name:"render"}),We(e,o,{value:t},i),e},Kb=({state:e},r)=>xr(e,"dialogueTextSpeed",r?.value),Jb=({state:e},r)=>(xr(e,"autoForwardDelay",r?.value),e.global.autoMode&&e.global.isLineCompleted&&!Ae({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e),Qb=({state:e},r)=>(xr(e,"autoForwardSpeed",r?.value),e.global.autoMode&&e.global.isLineCompleted&&!Ae({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e),Zb=({state:e},r)=>xr(e,"skipUnseenText",r?.value),eI=({state:e},r)=>xr(e,"skipTransitionsAndAnimations",r?.value),rI=({state:e},r)=>xr(e,"soundVolume",r?.value),tI=({state:e},r)=>xr(e,"musicVolume",r?.value),nI=({state:e},r)=>xr(e,"muteAll",r?.value),ii=({state:e,rollbackActionBatchStack:r},n)=>Ht(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",r),ai=({state:e,rollbackActionBatchStack:r})=>{let n=Xe(e,"saveLoadPagination")+1;return Ht(e,"saveLoadPagination",n,"incrementSaveLoadPagination",r),e},li=({state:e,rollbackActionBatchStack:r})=>{let n=Xe(e,"saveLoadPagination")-1;return Ht(e,"saveLoadPagination",n,"decrementSaveLoadPagination",r),e},ci=({state:e,rollbackActionBatchStack:r},n)=>Ht(e,"menuPage",n?.value,"setMenuPage",r),ui=({state:e,rollbackActionBatchStack:r},n)=>Ht(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",r),sI=({state:e})=>(e.global.pendingEffects=[],e),oI=({state:e},r)=>(e.global.pendingEffects.push(r),e),iI=({state:e},r)=>{if(fe(e))return e;let n=r?.resourceId;return _c(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},aI=({state:e},r)=>{if(fe(e))return e;let n=r?.resourceId,o=_c(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let i=r?.current;if(!Number.isInteger(i)||i<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(i,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:t,target:o.target,completed:t>=o.target}}),e},xu=e=>e?.lines?.[0],Eu=(e,{sectionId:r,resetStoryState:n=!1,screen:o})=>{let i=!!Jc(o),t=ve({state:e},{sectionId:r});if(!t)return console.warn(`Section not found: ${r}`),e;let s=xu(t);if(!s)return console.warn(`Section ${r} has no lines`),e;if(n&&!eb(e,{queueRender:!i}))return e;let a=Ae({state:e});n&&e.global.skipMode&&vr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let c=ut(l),p=c.read;n||Fr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Pr(l,{compatibilityAnchor:!0}),c.read={sectionId:r,lineId:s.id},n?l.rollback=qt({pointer:c.read}):Wn(e,{sectionId:r,lineId:s.id})}let{activeInteraction:u}=Yt(e,l?.pointers?.read,{screenTransition:o});return Kn(e,a,u),e},lI=({state:e},r)=>{if(fe(e))throw new Error("Cannot reset the story while a scene replay is active");return Eu(e,{sectionId:r?.sectionId,resetStoryState:!0,screen:r?.screen})},Su=e=>(e.global.accountViewedRegistry=cg(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Qn=(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:V(n.value)}))}})},Ru=(e,r)=>{Qn(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:[]}}])},cI=(e,r,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let i=L(r)?r:{};Array.isArray(i.sections)||(i.sections=[]);let t=i.sections.find(s=>s.sectionId===n);if(t){if(t.lastLineId===void 0)return!1;let s=ve({state:e},{sectionId:n});if(s?.lines){let a=s.lines.findIndex(u=>u.id===t.lastLineId),l=s.lines.findIndex(u=>u.id===o);if(a===-1||l>a)return t.lastLineId===o?!1:(t.lastLineId=o,!0)}else return t.lastLineId===o?!1:(t.lastLineId=o,!0);return!1}else return i.sections.push({sectionId:n,lastLineId:o}),!0},Fr=(e,r)=>{if(fe(e)||e.global.accountViewedRegistry===void 0)return;cI(e,Su(e),r)&&Ru(e,{sections:[{sectionId:r.sectionId,lastLineId:r.lineId}],resources:[]})},uI=({state:e},r)=>(Fr(e,r),e.global.pendingEffects.push({name:"render"}),e),pI=({state:e},r)=>{if(fe(e))return e;let{resourceId:n}=r;if(e.global.accountViewedRegistry!==void 0){let o=Su(e);o.resources.find(t=>t.resourceId===n)||(o.resources.push({resourceId:n}),Ru(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Ke=(e,r,n)=>{if(!L(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}"`)})},pi=(e,r,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${r}`)},Zn=(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"}))},dI=({state:e},r)=>{let n="showImageGalleryVariant";Ke(n,r,tg),pi(n,"groupId",r.groupId),Object.prototype.hasOwnProperty.call(r,"variantId")&&pi(n,"variantId",r.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let i=o.groups.findIndex(a=>a.id===r.groupId),t=o.groups[i];if(!t)return e;let s=r.variantId===void 0?t.variants[0]:t.variants.find(a=>a.id===r.variantId);return!s||Vt(e,s)||Zn(e,{groupId:t.id,variantId:s.id,pageIndex:Math.floor(i/o.pageSize)}),e},Ou=(e,r,n,o)=>{Ke(o,r,mi);let i=e.projectData?.resources?.imageGallery;if(i===void 0)return e;let t=e.global.imageGalleryNavigation;if(typeof t.groupId!="string"||typeof t.variantId!="string")return e;let s=i.groups.find(u=>u.id===t.groupId),a=s?.variants.findIndex(u=>u.id===t.variantId);if(!s||a===void 0||a<0)return e;let l=si(e,s.variants,a,n);return l&&Zn(e,{...t,variantId:l.id}),e},fI=({state:e},r)=>Ou(e,r,-1,"moveToPreviousImageGalleryVariant"),mI=({state:e},r)=>Ou(e,r,1,"moveToNextImageGalleryVariant"),yI=({state:e},r)=>{if(Ke("clearImageGallerySelection",r,mi),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return Zn(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},Cu=(e,r)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=Oi(n);if(r>=o)return e;let i=e.global.imageGalleryNavigation,t=Ci(n,i);return r===t||Zn(e,{groupId:null,variantId:null,pageIndex:r}),e},hI=({state:e},r)=>{if(Ke("moveToImageGalleryPage",r,ng),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Cu(e,r.pageIndex)},$u=(e,r,n,o)=>{Ke(o,r,mi);let i=e.projectData?.resources?.imageGallery;if(i===void 0)return e;let s=Ci(i,e.global.imageGalleryNavigation)+n;return s<0?e:Cu(e,s)},gI=({state:e},r)=>$u(e,r,1,"moveToNextImageGalleryPage"),bI=({state:e},r)=>$u(e,r,-1,"moveToPreviousImageGalleryPage"),ar=(e,r,n)=>{if(!L(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}"`)})},II=(e,r)=>{if(typeof r!="string"||r.length===0)throw new Error(`${e} requires a non-empty trackId`)},Ye=e=>{e.global.pendingEffects.push({name:"render"})},_u=(e,r)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,i=o.trackId!==null,t=o.trackId===r.id,s=o.bgmPlayback;i||(s={commandId:Xn(e),operation:"pause"});let a=Ut(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:a,seekFallback:null,bgmPlayback:s},Ye(e)},wI=({state:e},r)=>{let n="playMusicRoomTrack";ar(n,r,sg),II(n,r.trackId);let i=e.projectData?.resources?.musicRoom?.tracks.find(t=>t.id===r.trackId);return!i||$i(e,i)||_u(e,i),e},kI=({state:e},r)=>{ar("playMusicRoom",r,at);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let i=o.status==="ended",t=o.readiness==="error",s=o.status==="paused"&&!t?"resume":"play",a=i?0:o.positionMs;return o.playback=Ut(e,s,s==="play"?a:void 0),o.seekFallback=null,o.status="playing",o.positionMs=a,t&&(o.readiness=o.durationMs===null?"loading":"ready"),Ye(e),e},vI=({state:e},r)=>{ar("pauseMusicRoom",r,at);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=Ut(e,"pause"),o.seekFallback=null,o.status="paused",Ye(e)),e},AI=({state:e},r)=>{ar("stopMusicRoom",r,at);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=Ut(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,Ye(e)),e},PI=({state:e},r)=>{if(ar("seekMusicRoom",r,og),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 i=Ut(e,"seek",r.positionMs);return o.seekFallback={commandId:i.commandId,status:o.status,positionMs:o.positionMs},o.playback=i,o.positionMs=r.positionMs,r.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),Ye(e),e},Tu=(e,r,n,o)=>{ar(o,r,at);let i=e.projectData?.resources?.musicRoom,t=e.global.musicRoomPlayer;if(!i||t.trackId===null)return e;let s=i.tracks.findIndex(l=>l.id===t.trackId);if(s<0)return e;let a=oi(e,i.tracks,s,n);return a&&_u(e,a),e},xI=({state:e},r)=>Tu(e,r,-1,"playPreviousMusicRoomTrack"),EI=({state:e},r)=>Tu(e,r,1,"playNextMusicRoomTrack"),SI=({state:e},r)=>{ar("clearMusicRoomSelection",r,at);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let i=o.pageIndex,t={commandId:Xn(e),operation:"resume"};return e.global.musicRoomPlayer={...Hn({bgmPlayback:t}),pageIndex:i},Ye(e),e},Nu=(e,r)=>{let n=e.projectData?.resources?.musicRoom;if(!n||r>=_i(n))return e;let o=e.global.musicRoomPlayer,i=Ti(n,o);return r===i||(o.pageIndex=r,Ye(e)),e},RI=({state:e},r)=>{if(ar("moveToMusicRoomPage",r,ig),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Nu(e,r.pageIndex)},ju=(e,r,n,o)=>{ar(o,r,at);let i=e.projectData?.resources?.musicRoom;if(!i)return e;let t=Ti(i,e.global.musicRoomPlayer)+n;return t<0?e:Nu(e,t)},OI=({state:e},r)=>ju(e,r,1,"moveToNextMusicRoomPage"),CI=({state:e},r)=>ju(e,r,-1,"moveToPreviousMusicRoomPage"),qr=e=>{let r=fe(e);if(!r)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=V(r.sceneReplay.returnState),o=r.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(i=>i?.name!=="handleLineActions"||i?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),Jg(e,n),e.global.pendingEffects.push({name:"render"}),!0},$I=({state:e},r)=>{let n="startSceneReplay";if(Ke(n,r,ag),pi(n,"sceneId",r.sceneId),fe(e))throw new Error("Cannot start a scene replay while another replay is active");let i=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===r.sceneId);if(!i||!fu(e,i.sceneId))return e;let t=e.projectData.story.scenes[i.sceneId],s=t?.initialSectionId,a=t?.sections?.[s],l=a?.initialLineId??a?.lines?.[0]?.id;if(!a||!l||!a.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${i.sceneId}" has an invalid initial section`);let u=Wg(e);Kg(e);let c=Ei({pointer:{sceneId:i.sceneId,sectionId:s,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:i.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:u}});return tu(e,c),e.contexts.push(c),Yt(e,c.pointers.read),e},Du=({state:e},r)=>{Ke("finishSceneReplay",r,yi);let o=fe(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Ar(e)?.rollback?.isRestoring===!0)return e;let t=Te({state:e})?.pointer,{sceneId:s}=Ge(e.projectData,t?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=ug(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Qn(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},_I=({state:e},r)=>(Ke("exitSceneReplay",r,yi),qr(e),e),Lu=(e,r)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||r>=Ni(n))return e;let o=ji(n,e.global.sceneReplayNavigation);return r===o||(e.global.sceneReplayNavigation.pageIndex=r,e.global.pendingEffects.push({name:"render"})),e},TI=({state:e},r)=>{if(Ke("moveToSceneReplayPage",r,lg),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Lu(e,r.pageIndex)},Mu=(e,r,n,o)=>{Ke(o,r,yi);let i=e.projectData?.resources?.sceneReplay;if(!i)return e;let t=ji(i,e.global.sceneReplayNavigation)+n;return t<0?e:Lu(e,t)},NI=({state:e},r)=>Mu(e,r,1,"moveToNextSceneReplayPage"),jI=({state:e},r)=>Mu(e,r,-1,"moveToPreviousSceneReplayPage"),es=(e,r)=>{let n=e.global.musicRoomPlayer;return!L(r)||r.id!==eg||n.trackId===null||!n.playback||r.commandId!==n.playback.commandId?null:n},Vi=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,Vu=(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,Ye(e)),e),DI=({state:e},r)=>{let n=es(e,r);return!n||n.readiness!=="loading"||!Vi(r)?e:Vu(e,n,r,{readiness:"ready"})},LI=({state:e},r)=>{let n=es(e,r);return!n||n.readiness!=="ready"||!Vi(r)||n.status==="stopped"&&r.positionMs!==0||n.status==="ended"&&r.positionMs!==r.durationMs?e:Vu(e,n,r)},MI=({state:e},r)=>{let n=es(e,r);return!n||n.readiness!=="ready"||n.status!=="playing"||!Vi(r)||r.positionMs!==r.durationMs||(n.status="ended",n.positionMs=r.positionMs,n.durationMs=r.durationMs,n.seekFallback=null,Ye(e)),e},VI=({state:e},r)=>{let n=es(e,r);if(!n||typeof r.errorCode!="string"||!rg.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 i=n.status!==o.status||n.positionMs!==o.positionMs;return n.status=o.status,n.positionMs=o.positionMs,n.seekFallback=null,i&&Ye(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,Ye(e),e},qu=({state:e,rollbackActionBatchStack:r},n)=>{let o=hg(n.manual),{auto:i,applyMode:t}=n,s=e.global.nextLineConfig.auto?.enabled,a=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,u=e.global.nextLineConfig?.applyMode,c=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&i?(e.global.nextLineConfig={manual:o,auto:i},t!==void 0?e.global.nextLineConfig.applyMode=t:u!==void 0&&(e.global.nextLineConfig.applyMode=u)):(o&&(e.global.nextLineConfig.manual=o),i&&(e.global.nextLineConfig.auto=i),t!==void 0&&(e.global.nextLineConfig.applyMode=t));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=Ae({state:e});return!c&&(i!==void 0&&(p!==s||m!==a||d!==l))&&(!f&&p===!0&&(m==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:d}}):s===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),We(e,"setNextLineConfig",n,r),e},qI=({state:e},r)=>{if(fe(e))throw new Error("Cannot save while a scene replay is active");let n=r?.slotId;Tc(n,"saveSlot");let{thumbnailImage:o}=r,i=r?.savedAt,t=Ur(n),s=V(e.contexts);s?.forEach(u=>{ut(u),su(u.rollback),kg(u.rollback,e.projectData)});let a={contexts:s},l={formatVersion:Cc,slotId:Mc(n),savedAt:typeof i=="number"?i:Date.now(),image:o,state:a};return e.global.saveSlots[t]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},FI=({state:e},r)=>{if(fe(e))throw new Error("Cannot load while a scene replay is active");let n=r?.slotId;Tc(n,"loadSlot");let o=Ur(n),i=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(i){let t=Lg(i,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=Ft(),e.global.overlayStack=[],e.global.isLineCompleted=!0,lt(e),ct(e),bi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},UI=({state:e},r)=>{if(fe(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=r;Lc(n),vt(n),At(n),Pt(n),jr(n?.resources?.variables??{}),Ro(n);let o=xg(n),i=o?e.contexts?.map((s,a)=>Kc(V(s),n,a)):void 0,t=o?vg(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=fi(),e.global.sceneReplayNavigation=hi(),bi(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:a}=Pn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...a,...xt(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=i,e.global.saveSlots=t}return lt(e),ct(e),o&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},BI=({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(!L(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,xi(e,"localizationPackageId",n),nu(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Ae({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},zI=({state:e},r)=>{let{sectionId:n,lineId:o}=r;if(!o)return console.warn("jumpToLine requires lineId parameter"),e;let i=e.contexts[e.contexts.length-1];if(!i)return console.warn("No context available for jumpToLine"),e;let t=n||i.pointers.read?.sectionId;if(n&&!ve({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=ve({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=Ae({state:e}),u=ut(i);u.read={sectionId:t,lineId:o};let{activeInteraction:c}=Yt(e,u.read);return Kn(e,l,c),e},YI=({state:e,rollbackActionBatchStack:r},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Jn({state:e,rollbackActionBatchStack:r}),e;let o=Ae({state:e});if(o?.source===it&&n?.bypassChoice!==!0||o?.source===kr&&n?._interactionSource!==kr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,fe(e)?.sceneReplay.exitOnLineCompleted)return qr(e),e;let d=Te({state:e})?.pointer,f=d?.sectionId,y=d?.lineId;f&&y&&Fr(e,{sectionId:f,lineId:y}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}});let g=e.global.nextLineConfig,h=ve({state:e},{sectionId:f});return Array.isArray(h?.lines)&&h.lines.at(-1)?.id===y?ti(e):g?.auto?.enabled&&!o&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(fe(e)?.sceneReplay.finishOnNextAdvance)return qr(e),e;let t=Te({state:e})?.pointer,s=t?.sectionId,a=ve({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],u=a?.lines||[],p=u.findIndex(m=>m.id===t?.lineId)+1;if(p<u.length){let m=u[p],d=!Xe(e,"skipUnseenText");if(e.global.skipMode&&d&&!Ri({state:e},{sectionId:s,lineId:m.id}))return vr({state:e}),e;if(l&&!l.rollback&&Pr(l,{compatibilityAnchor:!0}),l){let y=ut(l),g=y.read?.lineId;g&&s&&Fr(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:m.id}}Wn(e,{sectionId:s,lineId:m.id}),gi(e);let{activeInteraction:f}=Yt(e,{sectionId:s,lineId:m.id});Kn(e,o,f)}else{if(fe(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),qr(e),e;e.global.autoMode&&Gt({state:e}),e.global.skipMode&&vr({state:e}),ti(e)}return e},GI=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,fe(e)?.sceneReplay.exitOnLineCompleted)return qr(e),e;let n=Ae({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}});let o=Te({state:e})?.pointer,i=o?.sectionId,t=o?.lineId;i&&t&&Fr(e,{sectionId:i,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},HI=({state:e},r)=>Eu(e,{sectionId:r?.sectionId,screen:r?.screen}),XI=({state:e,rollbackActionBatchStack:r},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return Jn({state:e,rollbackActionBatchStack:r}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:ir({state:e})}}),e;let i=Ae({state:e});if(i?.source===it&&n?.bypassChoice!==!0||i?.source===kr&&n?._interactionSource!==kr||i&&i.source!==it&&i.source!==kr)return e;let t=fe(e);if(t?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(qr(e),e):(t.sceneReplay.exitOnLineCompleted=!0,e);let s=Te({state:e})?.pointer,a=s?.sectionId,l=ve({state:e},{sectionId:a}),u=e.contexts[e.contexts.length-1],c=l?.lines||[],m=c.findIndex(d=>d.id===s?.lineId)+1;if(m<c.length){let d=c[m],f=!Xe(e,"skipUnseenText");if(e.global.skipMode&&f&&!Ri({state:e},{sectionId:a,lineId:d.id})&&(vr({state:e}),!o))return e;if(u&&!u.rollback&&Pr(u,{compatibilityAnchor:!0}),u){let g=ut(u),h=g.read?.lineId;h&&a&&Fr(e,{sectionId:a,lineId:h}),g.read={sectionId:a,lineId:d.id}}Wn(e,{sectionId:a,lineId:d.id}),gi(e);let{activeInteraction:y}=Yt(e,{sectionId:a,lineId:d.id});Kn(e,i,y)}else{if(fe(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),qr(e),e;e.global.autoMode&&Gt({state:e}),e.global.skipMode&&vr({state:e}),ti(e)}return e},qi=(e,r={})=>{let n=Bt({state:e});return!n||r.formKey&&r.formKey!==n.key||r.formId&&r.formId!==n.id?null:n},WI=(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,i=n?.type;if(Se(n))throw new Error(`Cannot update computed variable: ${r.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${r.variableId}`);if(Et(o,r.variableId),St(i,"set",r.variableId),fe(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${r.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},KI=(e,r)=>({id:e.id,key:e.key,valid:!0,values:V(r),fields:V(e.fields),fieldList:V(e.fieldList)}),JI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let r=Te({state:e})?.pointer,n=r?.sectionId,o=r?.lineId;n&&o&&Fr(e,{sectionId:n,lineId:o})},QI=({state:e},r={})=>{let n=qi(e,r),o=r.field;if(!n?.fields?.[o])return e;let i=Zc(e,n.key),t=Yn(r.value),s=n.fields[o],a=Ai(s,t);return i.values[o]=t,i.touched[o]=!0,a?i.errors[o]=a:delete i.errors[o],e.global.pendingEffects.push({name:"render"}),e},ZI=({state:e,rollbackActionBatchStack:r},n={})=>{let o=qi(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let i=Zc(e,o.key);i.submitted=!0;let t={},s={};if(Object.entries(o.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(i.values,m)?i.values[m]:d.value,y=Ai(d,f);i.touched[m]=!0,y&&(s[m]=y),t[m]=Qc(d,f)}),i.errors=s,Object.keys(s).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:V(s),form:{id:o.id,key:o.key,values:V(t)}};let a=e.contexts[e.contexts.length-1];if(a?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,u=[],c=[];Object.entries(o.fields).forEach(([m,d])=>{let{scope:f}=WI(e,d),y=f==="context"?a.variables:e.global.variables,g=t[m];y[d.variableId]=En(y[d.variableId],"set",g),f==="context"&&(l=!0,c.push({variableId:d.variableId,op:"set",value:g})),(f==="device"||f==="account")&&u.push({scope:f,path:`variables.${d.variableId}`,op:"set",value:V(y[d.variableId])})}),l&&We(e,"updateVariable",{id:"submitForm",operations:c},r),Qn(e,u);let p=KI(o,t);return JI(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},ew=({state:e},r={})=>{let n=qi(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:V(n.values),fields:V(n.fields),fieldList:V(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},rw=({state:e,rollbackActionBatchStack:r},n)=>{let{id:o,operations:i=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let t=e.contexts[e.contexts.length-1];if(t?.rollback?.isRestoring)return e;let s=!1,a=[],l=[];return i.forEach(({variableId:u,op:c,value:p,roundTo:m})=>{let d=e.projectData.resources?.variables?.[u],f=d?.scope,y=d?.type;if(Se(d))throw new Error(`Cannot update computed variable: ${u}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${u}`);if(Et(f,u),St(y,c,u),xn(y,c,p,u,{roundTo:m}),fe(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${u}" while a scene replay is active`);let g=f==="context"?t.variables:e.global.variables;if(f==="context"){s=!0;let h={variableId:u,op:c,value:p};m!==void 0&&(h.roundTo=m),l.push(h)}g[u]=En(g[u],c,p,{roundTo:m}),(f==="device"||f==="account")&&a.push({scope:f,path:`variables.${u}`,op:"set",value:V(g[u])})}),s&&We(e,"updateVariable",{id:o,operations:l},r),Qn(e,a),e.global.pendingEffects.push({name:"render"}),e},Ue=e=>(r,n)=>e({state:r},n),Fu=e=>({variables:Jr({variables:{...e.global?.variables??{},...Ar(e)?.variables??{}},runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:gr(e)}),tw=e=>{if(!L(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},nw=(e,r,n)=>{if(!L(e))throw new Error(`conditional branch at index ${r} must be an object`);if(!L(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")},sw=(e,r,n,o)=>{tw(r);for(let i=0;i<r.branches.length;i+=1){let t=r.branches[i];if(nw(t,i,r.branches.length),!(Object.prototype.hasOwnProperty.call(t,"when")&&!kt(t.when,{...Fu(e),...n?.bindings??{}}))){Fi(e,t.actions,n,[...o,"branches",String(i),"actions"]);return}}},ow=(e,r,n,o)=>{let i=n?.checkpoint;if(i?.randomOutcomeVersion!==or)return;let t=o.join("."),s=n.randomOutcomeOrdinals,a=s.get(t)??0;s.set(t,a+1);let l=i.randomOutcomes?.find(p=>p.path===t&&p.ordinal===a);if(!l)return;if(r?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${t}`);let u=On(V(l.result),l.type);if(u.type==="integer"){if(!Fc(r.distribution)||u.value<r.distribution.min||u.value>r.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${t}`);ni(e,{id:"randomResult",operations:[{variableId:r.variableId,op:"set",value:u.value}]});return}let c=r.distribution.outcomes?.[u.outcomeIndex]?.actions;if(!L(c))throw new Error(`recorded random outcome does not match canonical action at ${t}`);Fi(e,c,n,[...o,"distribution","outcomes",String(u.outcomeIndex),"actions"])},iw={conditional:{replayLine:sw},random:{replayLine:ow},updateVariable:{recordSources:[wr],replayLine:ni,replayRecorded:ni,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Ue(qu)},setSaveLoadPagination:{recordSources:[wr],replayLine:Ue(ii),replayRecorded:Ue(ii),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[wr],replayLine:Ue(ai),replayRecorded:Ue(ai),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[wr],replayLine:Ue(li),replayRecorded:Ue(li),persistInSaveSlot:!0},setMenuPage:{recordSources:[wr],replayLine:Ue(ci),replayRecorded:Ue(ci),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[wr],replayLine:Ue(ui),replayRecorded:Ue(ui),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Ue(Du)}},rs=e=>iw[e]??null,aw=e=>rs(e)?.persistInSaveSlot===!0,lw=(e,r)=>{let n=rs(e)?.recordSources;return Array.isArray(n)&&n.includes(r)},cw=(e,r,n)=>{rs(r)?.replayRecorded?.(e,n)},uw=(e,r,n,o,i)=>{let t=rs(r);if(!t?.replayLine)return;if(r==="conditional"||r==="random"){t.replayLine(e,n,o,i);return}let s=o?.bindings??{},a=Rt({[r]:n},{...Fu(e),...s})[r];t.replayLine(e,a)},Fi=(e,r,n,o)=>{let i=Cn(r);$n(i);for(let[t,s]of i)uw(e,t,s,n,[...o,t])},pw=e=>e?.returnable!==!1,Uu=(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(pw(e.timeline[o])&&(n-=1,n===0))return o;return-1},Bu=({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 i=o.rollback;if(!Array.isArray(i?.timeline)||typeof i?.currentIndex!="number")return null;let t=Uu(i,n);if(t<0||t>=i.timeline.length)return null;let s=i.timeline[t];return{sectionId:s.sectionId,lineId:s.lineId}},zu=({state:e})=>Bu({state:e},{offset:-1})!==null,dw=({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 i=Pr(o,{compatibilityAnchor:!o.rollback}),t=Uu(i,n);return t<0||t>=i.timeline.length?e:iu(e,t)},fw=({state:e},r)=>{let{sectionId:n,lineId:o}=r,i=e.contexts[e.contexts.length-1];if(!i)throw new Error("No context available for rollbackToLine");let t=Pr(i,{compatibilityAnchor:!i.rollback}),a=t.timeline.slice(0,t.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===o);if(a===-1)throw new Error(`Line ${o} not found in section ${n} rollback timeline`);return a===t.currentIndex?e:iu(e,a)},mw=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),ri=(e,r)=>{let n=e[r];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${r} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${r} is exhausted`);return e[r]=n+1,e[r]},Rc=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Oc=e=>{let r=e.contexts?.[e.contexts.length-1];return Number.isInteger(r?.rollback?.currentIndex)?r.rollback.currentIndex:null},yw=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,Yu=e=>{let r=e.global?.nextLineConfig?.auto;return r?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:r.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:r.delay??1e3}},Ui=e=>JSON.stringify(Yu(e)),hw=({actionName:e,args:r,state:n,previousState:o})=>{let i=Rc(o),t=Rc(n);if(!yw(i,t)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Oc(o)!==Oc(n))return!0;let s=r[0]??{};if(e==="jumpToLine"){let a=s.sectionId??i?.sectionId;return typeof s.lineId=="string"&&t?.sectionId===a&&t?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let a=Ge(n.projectData,s.sectionId).section,l=xu(a)?.id;return typeof l=="string"&&t?.sectionId===s.sectionId&&t?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let a=s.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},Ur(a))}return!1},gw=({actionName:e,args:r,state:n,transactionalMetadata:o,previousState:i})=>{if(hw({actionName:e,args:r,state:n,previousState:i})){let c=ri(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:c,configKey:Ui(n)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:c}let s=(i.contexts?.length??0)>(n.contexts?.length??0),a=e==="startAutoMode"||e==="startSkipMode"?Ae({state:i}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!a||e==="toggleAutoMode"&&i.global.autoMode!==!0||s&&i.global.autoMode!==!0)&&ri(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!a||e==="toggleSkipMode"&&i.global.skipMode!==!0||s&&i.global.skipMode!==!0)&&ri(o,"skipSessionId")},bw=({state:e,transactionalMetadata:r})=>{let n=r.rollbackAuthoredSuppression;n&&(n.lineEntryId!==r.lineEntryId||n.configKey!==Ui(e))&&(r.rollbackAuthoredSuppression=null)},Iw=({state:e,playbackOwnership:r})=>{let n=Ae({state:e}),o=r.lineEntryId,i=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,t=!n&&e.global.skipMode===!0,s=Yu(e),a=r.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(a?.lineEntryId===o&&a.configKey===Ui(e)),u=i?wu(e):null;return{auto:i?{owner:{sessionId:r.autoSessionId,lineEntryId:o},delayMs:ei({text:u,baseDelay:Xe(e,"autoForwardDelay"),speed:Xe(e,"autoForwardSpeed")}),contentKey:u}:null,skip:t?{owner:{sessionId:r.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:s.delayMs,trigger:s.trigger}:null}},ww=({playbackOwnership:e})=>e.lineEntryId,Gu=(e,r={})=>{let n=pb(e),o=[],i=r.createPlaybackOwnership??mw;if(typeof i!="function")throw new TypeError("createPlaybackOwnership must be a function");return Ha(n,{selectPendingEffects:fb,selectSkipMode:au,selectAutoMode:mb,selectIsChoiceVisible:hu,selectIsFormVisible:bb,selectActiveInteraction:Ae,selectActiveForm:Bt,selectDialogueUIHidden:lu,selectDialogueHistory:cu,selectConfirmDialog:gb,selectIsLineAccountViewed:Ri,selectIsResourceAccountViewed:wb,selectImageGalleryConfig:kb,selectImageGallery:uu,selectMusicRoomConfig:Ab,selectMusicRoom:du,selectSceneReplayConfig:Pb,selectSceneReplay:mu,selectIsSceneReplayActive:xb,selectActiveSceneReplayEntry:Eb,selectNextLineConfig:Sb,selectSystemState:Rb,selectAchievements:Ob,selectAchievement:Cb,selectSaveSlotMap:gu,selectSaveSlots:Db,selectSaveSlot:$b,selectLocalizationPackages:bu,selectRuntime:Di,selectRuntimeValue:_b,selectAllVariables:Li,selectCurrentPointer:Te,selectSection:ve,selectCurrentLine:zt,selectPresentationState:Iu,selectAutoForwardTimerDelay:ir,selectPresentationChanges:Tb,selectSectionLineChanges:jb,selectSaveSlotPage:Mi,selectCurrentPageSlots:Lb,selectRenderState:Vb,selectOverlayStack:db,selectLineIdByOffset:Bu,selectCanRollback:zu,selectRollbackCursor:tb,selectDesiredPlaybackTimers:Iw,selectPlaybackLineEntryId:ww,startAutoMode:vu,stopAutoMode:Gt,toggleAutoMode:Hb,startSkipMode:Au,stopSkipMode:vr,toggleSkipMode:Xb,showDialogueUI:Jn,hideDialogueUI:Pu,toggleDialogueUI:Wb,setDialogueTextSpeed:Kb,setAutoForwardDelay:Jb,setAutoForwardSpeed:Qb,setSkipUnseenText:Zb,setSkipTransitionsAndAnimations:eI,setSoundVolume:rI,setMusicVolume:tI,setMuteAll:nI,setSaveLoadPagination:ii,incrementSaveLoadPagination:ai,decrementSaveLoadPagination:li,setMenuPage:ci,setMenuEntryPoint:ui,showConfirmDialog:qb,hideConfirmDialog:Fb,resetStoryAtSection:lI,clearPendingEffects:sI,appendPendingEffect:oI,completeAchievement:iI,setAchievementProgress:aI,beginRollbackActionBatch:ob,endRollbackActionBatch:ib,ensureRandomReplayOccurrence:ab,recordRandomOutcome:lb,markRollbackCheckpointTransient:nb,markSavedRollbackCheckpointTransient:sb,recordCurrentDialogueHistory:hb,addViewedLine:uI,addViewedResource:pI,showImageGalleryVariant:dI,moveToPreviousImageGalleryVariant:fI,moveToNextImageGalleryVariant:mI,clearImageGallerySelection:yI,moveToImageGalleryPage:hI,moveToNextImageGalleryPage:gI,moveToPreviousImageGalleryPage:bI,playMusicRoomTrack:wI,playMusicRoom:kI,pauseMusicRoom:vI,stopMusicRoom:AI,seekMusicRoom:PI,playPreviousMusicRoomTrack:xI,playNextMusicRoomTrack:EI,clearMusicRoomSelection:SI,moveToMusicRoomPage:RI,moveToNextMusicRoomPage:OI,moveToPreviousMusicRoomPage:CI,musicRoomSoundReady:DI,musicRoomSoundProgress:LI,musicRoomSoundComplete:MI,musicRoomSoundError:VI,startSceneReplay:$I,finishSceneReplay:Du,exitSceneReplay:_I,moveToSceneReplayPage:TI,moveToNextSceneReplayPage:NI,moveToPreviousSceneReplayPage:jI,setNextLineConfig:qu,saveSlot:qI,loadSlot:FI,updateProjectData:UI,updateLocalizationPackage:BI,sectionTransition:HI,jumpToLine:zI,nextLine:YI,markLineCompleted:GI,rollbackToLine:fw,rollbackByOffset:dw,pushOverlay:Ub,popOverlay:Bb,replaceLastOverlay:zb,clearOverlays:Yb,updateFormField:QI,submitForm:ZI,cancelForm:ew,updateVariable:rw,nextLineFromSystem:XI},{createTransactionalMetadata:i,updateTransactionalMetadata:gw,finalizeTransactionalMetadata:bw,transformActionFirstArgument:(s,a)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:a}),transformSelectorFirstArgument:(s,a)=>({state:s,playbackOwnership:a})})};var kw="route-engine",vw="projectPersistence";var Xu=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),me=e=>Object.prototype.toString.call(e)==="[object Object]",Hu="variables.",Aw=(e={})=>{let r=me(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!me(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)}:!me(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Pw=(e={})=>{let r=me(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!me(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)}:!me(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},xw=(e,r)=>{let n=Pw(e),o=Aw(r),i=n.sections.map(s=>({...s})),t=n.resources.map(s=>({...s}));return o.sections.forEach(s=>{let a=i.find(l=>l.sectionId===s.sectionId);if(!a){i.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(a.lastLineId!==void 0){if(s.lineId===void 0){delete a.lastLineId;return}a.lastLineId=s.lineId}}),o.resources.forEach(s=>{t.find(l=>l.resourceId===s.resourceId)||t.push({...s})}),{sections:i,resources:t}},Ew=(e={})=>{let r=me(e)?e:{},n=Array.isArray(r.sceneIds)?r.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},Sw=(e,r)=>{let n=Ew(e),o=me(r)&&Array.isArray(r.sceneIds)?r.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(i=>typeof i=="string"&&i.length>0)])]}},Wu=(e={})=>{let r=me(e)?e:{};return{saveSlots:me(r.saveSlots)?r.saveSlots:{},globalDeviceVariables:me(r.globalDeviceVariables)?r.globalDeviceVariables:{},globalAccountVariables:me(r.globalAccountVariables)?r.globalAccountVariables:{},globalRuntime:me(r.globalRuntime)?r.globalRuntime:{},accountViewedRegistry:me(r.accountViewedRegistry)?r.accountViewedRegistry:{},accountReplayRegistry:me(r.accountReplayRegistry)?r.accountReplayRegistry:{}}},Rw=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((r,n)=>{if(!me(r))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=r.path?.startsWith(Hu)?r.path.slice(Hu.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(!me(r.value)||!Array.isArray(r.value.sceneIds)||r.value.sceneIds.length===0||r.value.sceneIds.some(i=>typeof i!="string"||i.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}].`)})},Ow=(e,r)=>{let n={};return Rw(r).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=xw(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=Sw(n.accountReplayRegistry??e.accountReplayRegistry,o.value);return}let i=o.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[i]={...e[i],...n[i],[o.variableId]:o.value}}),n},pt=e=>{if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null},Cw=e=>{let r=pt(e);if(!r)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return r},$w=e=>{let r=e??globalThis.indexedDB;if(!r)throw new Error("IndexedDB is not available in this environment.");return r},_w=({indexedDB:e,databaseName:r,objectStoreName:n})=>new Promise((o,i)=>{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=()=>{i(t.error??new Error(`Failed to open IndexedDB database "${r}".`))}}),Tw=async({databasePromise:e,objectStoreName:r,namespace:n})=>{let o=await e;return new Promise((i,t)=>{let l=o.transaction(r,"readonly").objectStore(r).get(n);l.onsuccess=()=>{i(l.result??null)},l.onerror=()=>{t(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},Xt=async({databasePromise:e,objectStoreName:r,namespace:n,patch:o})=>{let i=await e;return new Promise((t,s)=>{let a=i.transaction(r,"readwrite"),l=a.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=Wu(u.result),f=typeof o=="function"?o(d):o,y={namespace:n,version:1,...Xu(),...d,...f},g=l.put(y);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},a.oncomplete=()=>{m()},a.onerror=()=>{p(a.error??new Error(`IndexedDB transaction failed while updating namespace "${n}".`))},a.onabort=()=>{p(a.error??new Error(`IndexedDB transaction aborted while updating namespace "${n}".`))}})},Nw=async({databasePromise:e,objectStoreName:r,namespace:n})=>{let o=await e;return new Promise((i,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,i())};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}".`))}})},Bi=(e={})=>{let{indexedDB:r,databaseName:n=kw,objectStoreName:o=vw,namespace:i}=e,t=$w(r),s=Cw(i),a=_w({indexedDB:t,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await Tw({databasePromise:a,objectStoreName:o,namespace:s});return{...Xu(),...Wu(l)}},clear:async()=>Nw({databasePromise:a,objectStoreName:o,namespace:s}),saveSlots:async l=>Xt({databasePromise:a,objectStoreName:o,namespace:s,patch:{saveSlots:me(l)?l:{}}}),saveGlobalDeviceVariables:async l=>Xt({databasePromise:a,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:me(l)?l:{}}}),saveGlobalAccountVariables:async l=>Xt({databasePromise:a,objectStoreName:o,namespace:s,patch:{globalAccountVariables:me(l)?l:{}}}),saveGlobalRuntime:async l=>Xt({databasePromise:a,objectStoreName:o,namespace:s,patch:{globalRuntime:me(l)?l:{}}}),applyScopedDataUpdates:async l=>Xt({databasePromise:a,objectStoreName:o,namespace:s,patch:u=>Ow(u,l)})}},jw=Bi;var np=sp;var Dw={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},lr=Object.prototype.hasOwnProperty,Lw={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 De(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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:Lw.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=a,t!==null&&(a?t.length=a: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 De.errors=t,s===0}var Mw={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function ns(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!(a==="continuity"||a==="speed"||a==="loop")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.continuity!==void 0){let a=e.continuity;if(typeof a!="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(!(a==="render"||a==="persistent")){let l={instancePath:r+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Mw.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 a=e.speed;if(typeof a=="number"){if(a<=0||isNaN(a)){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 a={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ns.errors=t,s===0}function le(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="resourceId"||a==="playback")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let a={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}e.playback!==void 0&&(ns(e.playback,{instancePath:r+"/playback",parentData:e,parentDataProperty:"playback",rootData:i})||(t=t===null?ns.errors:t.concat(ns.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return le.errors=t,s===0}function ss(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!lr.call(Dw.properties,a)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let a={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let a={instancePath:r+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let a={instancePath:r+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let a={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let a={instancePath:r+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let a={instancePath:r+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.x!==void 0&&typeof e.x!="number"){let a={instancePath:r+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.y!==void 0&&typeof e.y!="number"){let a={instancePath:r+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let a={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let a={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let a={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let a={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let a={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let a={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let a={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.opacity!==void 0){let a=e.opacity;if(typeof a=="number"){if(a>1||isNaN(a)){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(a<0||isNaN(a)){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&&(De(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:i})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),e.animations!==void 0&&(le(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ss.errors=t,s===0}function sp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return ss(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?ss.errors:t.concat(ss.errors),s=t.length),sp.errors=t,s===0}var op=ip;var Vw={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},Qu={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["id","resourceId"],additionalProperties:!1},je=Ju().default;function Ne(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[a]:t.push(a),s++}if(e.resourceId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!lr.call(Qu.properties,a)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.id!==void 0){let a=e.id;if(typeof a=="string"){if(je(a)<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 a=e.resourceId;if(typeof a=="string"){if(je(a)<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 a={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.volume!==void 0){let a=e.volume;if(typeof a=="number"){if(a>100||isNaN(a)){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(a<0||isNaN(a)){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 a={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.pan!==void 0){let a=e.pan;if(typeof a=="number"){if(a>1||isNaN(a)){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(a<-1||isNaN(a)){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 a=e.startDelayMs;if(typeof a=="number"){if(a<0||isNaN(a)){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 a=e.playbackRate;if(typeof a=="number"){if(a<0||isNaN(a)){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 a=e.startAt;if(typeof a=="number"){if(a<0||isNaN(a)){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 a=e.endAt;if(typeof a!="number"&&a!==null){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Qu.properties.endAt.type},message:"must be number,null"};t===null?t=[l]:t.push(l),s++}if(typeof a=="number"&&(a<0||isNaN(a))){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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Ne.errors=t,s===0}function os(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a: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++)Ne(d[y],{instancePath:r+"/sounds/"+y,parentData:d,parentDataProperty:y,rootData:i})||(t=t===null?Ne.errors:t.concat(Ne.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:Vw.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 os.errors=t,s===0}function ip(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return os(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?os.errors:t.concat(os.errors),s=t.length),ip.errors=t,s===0}var ap=lp;var qw={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 is(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=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 a=f===s;if(s=m,t!==null&&(m?t.length=m:t=null),a){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 a=y===s;d=a}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(!lr.call(qw.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&&(De(p.blur,{instancePath:r+"/items/"+c+"/blur",parentData:p,parentDataProperty:"blur",rootData:i})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),p.sprites!==void 0){let y=p.sprites;if(Array.isArray(y)){let g=y.length;for(let h=0;h<g;h++){let w=y[h];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let b in w)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let E={instancePath:r+"/items/"+c+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(w.id!==void 0&&typeof w.id!="string"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[b]:t.push(b),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let b={instancePath:r+"/items/"+c+"/sprites/"+h+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[b]:t.push(b),s++}}else{let b={instancePath:r+"/items/"+c+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}}}else{let g={instancePath:r+"/items/"+c+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[g]:t.push(g),s++}}p.animations!==void 0&&(le(p.animations,{instancePath:r+"/items/"+c+"/animations",parentData:p,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.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 is.errors=t,s===0}function lp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return is(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?is.errors:t.concat(is.errors),s=t.length),lp.errors=t,s===0}var cp=up;function as(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!(a==="resourceId"||a==="items"||a==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let a={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.items!==void 0){let a=e.items;if(Array.isArray(a)){let l=a.length;for(let u=0;u<l;u++){let c=a[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&&(le(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return as.errors=t,s===0}function up(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return as(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?as.errors:t.concat(as.errors),s=t.length),up.errors=t,s===0}var pp=dp;function ls(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(a!=="mode"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let a={instancePath:r+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ls.errors=t,s===0}function dp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return ls(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?ls.errors:t.concat(ls.errors),s=t.length),dp.errors=t,s===0}var fp=mp;function cs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(a!=="resourceId"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let a={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return cs.errors=t,s===0}function mp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return cs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?cs.errors:t.concat(cs.errors),s=t.length),mp.errors=t,s===0}var yp=hp;var Zu={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 us(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!lr.call(Zu.properties,a)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.ui!==void 0){let a=e.ui;if(a&&typeof a=="object"&&!Array.isArray(a)){for(let l in a)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(a.resourceId!==void 0&&typeof a.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++}a.animations!==void 0&&(le(a.animations,{instancePath:r+"/ui/animations",parentData:a,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.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 a=e.mode;if(typeof a!="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(!(a==="adv"||a==="nvl")){let l={instancePath:r+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Zu.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 a=e.content;if(Array.isArray(a)){let l=a.length;for(let u=0;u<l;u++){let c=a[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 a={instancePath:r+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let a={instancePath:r+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let a={instancePath:r+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let a={instancePath:r+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let a={instancePath:r+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let a={instancePath:r+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.character!==void 0){let a=e.character;if(a&&typeof a=="object"&&!Array.isArray(a)){for(let l in a)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(a.name!==void 0&&typeof a.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(a.sprite!==void 0){let l=a.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&&(le(l.animations,{instancePath:r+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.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 a={instancePath:r+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let a={instancePath:r+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return us.errors=t,s===0}function hp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return us(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?us.errors:t.concat(us.errors),s=t.length),hp.errors=t,s===0}var gp=bp;function ps(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!(a==="id"||a==="resourceId"||a==="fields"||a==="submitActions"||a==="cancelActions"||a==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let a={instancePath:r+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let a={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.fields!==void 0){let a=e.fields;if(a&&typeof a=="object"&&!Array.isArray(a))for(let l in a){let u=a[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 a=e.submitActions;if(!(a&&typeof a=="object"&&!Array.isArray(a))){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 a=e.cancelActions;if(!(a&&typeof a=="object"&&!Array.isArray(a))){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&&(le(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ps.errors=t,s===0}function bp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return ps(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?ps.errors:t.concat(ps.errors),s=t.length),bp.errors=t,s===0}var Ip=wp;function ds(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!(a==="resourceId"||a==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let a={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}e.animations!==void 0&&(le(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ds.errors=t,s===0}function wp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return ds(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?ds.errors:t.concat(ds.errors),s=t.length),wp.errors=t,s===0}var kp=vp;function fs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!(a==="opacity"||a==="blur"||a==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.opacity!==void 0){let a=e.opacity;if(typeof a=="number"){if(a>1||isNaN(a)){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(a<0||isNaN(a)){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&&(De(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:i})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),e.animations!==void 0&&(le(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return fs.errors=t,s===0}function vp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return fs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?fs.errors:t.concat(fs.errors),s=t.length),vp.errors=t,s===0}var Ap=Pp;var Fw={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 ms(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a: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++)Ne(c[m],{instancePath:r+"/items/"+m,parentData:c,parentDataProperty:m,rootData:i})||(t=t===null?Ne.errors:t.concat(Ne.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(je(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:Fw.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++)Ne(f[g],{instancePath:r+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:i})||(t=t===null?Ne.errors:t.concat(Ne.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 ms.errors=t,s===0}function Pp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return ms(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?ms.errors:t.concat(ms.errors),s=t.length),Pp.errors=t,s===0}var xp=Ep;var ep={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 ys(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a: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 ys.errors=t,s===0}function hs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=s,l=s,u=s,c=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};t===null?t=[b]:t.push(b),s++}}var m=p===s;if(c=c||m,!c){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let k={};t===null?t=[k]:t.push(k),s++}}var m=w===s;if(c=c||m,!c){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.resourceId===void 0&&(A="resourceId")){let R={};t===null?t=[R]:t.push(R),s++}}var m=E===s;if(c=c||m,!c){let A=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let j={};t===null?t=[j]:t.push(j),s++}}var m=A===s;if(c=c||m,!c){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.x===void 0&&(x="x")){let M={};t===null?t=[M]:t.push(M),s++}}var m=$===s;if(c=c||m,!c){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.y===void 0&&(B="y")){let pe={};t===null?t=[pe]:t.push(pe),s++}}var m=x===s;if(c=c||m,!c){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.anchorX===void 0&&(G="anchorX")){let ae={};t===null?t=[ae]:t.push(ae),s++}}var m=B===s;if(c=c||m,!c){let G=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.anchorY===void 0&&(D="anchorY")){let ie={};t===null?t=[ie]:t.push(ie),s++}}var m=G===s;if(c=c||m,!c){let D=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let J;if(e.scaleX===void 0&&(J="scaleX")){let q={};t===null?t=[q]:t.push(q),s++}}var m=D===s;if(c=c||m,!c){let J=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.scaleY===void 0&&(K="scaleY")){let Q={};t===null?t=[Q]:t.push(Q),s++}}var m=J===s;if(c=c||m,!c){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.rotation===void 0&&(se="rotation")){let ye={};t===null?t=[ye]:t.push(ye),s++}}var m=K===s;if(c=c||m,!c){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.originX===void 0&&(Z="originX")){let C={};t===null?t=[C]:t.push(C),s++}}var m=se===s;if(c=c||m,!c){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let _;if(e.originY===void 0&&(_="originY")){let F={};t===null?t=[F]:t.push(F),s++}}var m=Z===s;if(c=c||m,!c){let _=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let oe;if(e.layer===void 0&&(oe="layer")){let he={};t===null?t=[he]:t.push(he),s++}}var m=_===s;if(c=c||m,!c){let oe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Pe;if(e.opacity===void 0&&(Pe="opacity")){let ge={};t===null?t=[ge]:t.push(ge),s++}}var m=oe===s;if(c=c||m,!c){let Pe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ce;if(e.blur===void 0&&(ce="blur")){let Sr={};t===null?t=[Sr]:t.push(Sr),s++}}var m=Pe===s;if(c=c||m,!c){let ce=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ur;if(e.animations===void 0&&(ur="animations")){let nn={};t===null?t=[nn]:t.push(nn),s++}}var m=ce===s;c=c||m}}}}}}}}}}}}}}}}if(c)s=u,t!==null&&(u?t.length=u:t=null);else{let w={};t===null?t=[w]:t.push(w),s++}var d=l===s;if(d){let w={instancePath:r,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[w]:t.push(w),s++}else s=a,t!==null&&(a?t.length=a:t=null);let f=s,y=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};t===null?t=[w]:t.push(w),s++}var h=g===s;if(y=y||h,!y){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let E={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};t===null?t=[E]:t.push(E),s++}var h=w===s;y=y||h}if(y)s=f,t!==null&&(f?t.length=f:t=null);else{let w={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[w]:t.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(ys(e.content,{instancePath:r+"/content",parentData:e,parentDataProperty:"content",rootData:i})||(t=t===null?ys.errors:t.concat(ys.errors),s=t.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:r+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[w]:t.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[w]:t.push(w),s++}return hs.errors=t,s===0}function gs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=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 a=d===s;if(a){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(!lr.call(ep.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&&(hs(p.text,{instancePath:r+"/items/"+c+"/text",parentData:p,parentDataProperty:"text",rootData:i})||(t=t===null?hs.errors:t.concat(hs.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:ep.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&&(De(p.blur,{instancePath:r+"/items/"+c+"/blur",parentData:p,parentDataProperty:"blur",rootData:i})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),p.animations!==void 0&&(le(p.animations,{instancePath:r+"/items/"+c+"/animations",parentData:p,parentDataProperty:"animations",rootData:i})||(t=t===null?le.errors:t.concat(le.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 gs.errors=t,s===0}function Ep(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return gs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?gs.errors:t.concat(gs.errors),s=t.length),Ep.errors=t,s===0}var Sp=Rp;var Uw={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 bs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a:t=null);else{let h={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[h]:t.push(h),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.resourceId===void 0&&(h="resourceId")||e.sounds===void 0&&(h="sounds")){let w={};t===null?t=[w]:t.push(w),s++}}var d=m===s;if(d){let h={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[h]:t.push(h),s++}else s=p,t!==null&&(p?t.length=p:t=null);let f=s,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.startDelayMs===void 0&&(h="startDelayMs")||e.sounds===void 0&&(h="sounds")){let w={};t===null?t=[w]:t.push(w),s++}}var g=y===s;if(g){let h={instancePath:r,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[h]:t.push(h),s++}else s=f,t!==null&&(f?t.length=f:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let h in e)if(!(h==="sounds"||h==="resourceId"||h==="volume"||h==="muted"||h==="pan"||h==="loop"||h==="interruption"||h==="startDelayMs")){let w={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};t===null?t=[w]:t.push(w),s++}if(e.sounds!==void 0){let h=e.sounds;if(Array.isArray(h)){let w=h.length;for(let b=0;b<w;b++)Ne(h[b],{instancePath:r+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:i})||(t=t===null?Ne.errors:t.concat(Ne.errors),s=t.length)}else{let w={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[w]:t.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let h={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(e.volume!==void 0){let h=e.volume;if(typeof h=="number"){if(h>100||isNaN(h)){let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[w]:t.push(w),s++}if(h<0||isNaN(h)){let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let h={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[h]:t.push(h),s++}if(e.pan!==void 0){let h=e.pan;if(typeof h=="number"){if(h>1||isNaN(h)){let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[w]:t.push(w),s++}if(h<-1||isNaN(h)){let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let h={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[h]:t.push(h),s++}if(e.interruption!==void 0){let h=e.interruption;if(typeof h!="string"){let w={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[w]:t.push(w),s++}if(!(h==="immediate"||h==="loopEnd")){let w={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Uw.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[w]:t.push(w),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let w={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}}else{let h={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[h]:t.push(h),s++}return bs.errors=t,s===0}function Rp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return bs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?bs.errors:t.concat(bs.errors),s=t.length),Rp.errors=t,s===0}var Op=Cp;var Bw={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 Is(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a:t=null),c){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};t===null?t=[w]:t.push(w),s++}var c=g===s;l=c}if(!l){let g={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[g]:t.push(g),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};t===null?t=[g]:t.push(g),s++}var f=d===s;if(s=p,t!==null&&(p?t.length=p:t=null),f){let g=s,h=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let k={};t===null?t=[k]:t.push(k),s++}}var y=w===s;if(y){let E={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[E]:t.push(E),s++}else s=h,t!==null&&(h?t.length=h:t=null);var f=g===s;m=f}if(!m){let g={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[g]:t.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[g]:t.push(g),s++}if(e.name===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};t===null?t=[g]:t.push(g),s++}if(e.description===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};t===null?t=[g]:t.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let h={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};t===null?t=[h]:t.push(h),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let h={instancePath:r+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(!(g==="boolean"||g==="number")){let h={instancePath:r+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Bw.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(je(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(je(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(je(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(je(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 Is.errors=t,s===0}function Cp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Is(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Is.errors:t.concat(Is.errors),s=t.length),Cp.errors=t,s===0}var $p=_p;var zw={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 Yw={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 zr(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};t===null?t=[a]:t.push(a),s++}if(e.duration===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="value"||a==="duration"||a==="easing"||a==="relative")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let a={instancePath:r+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let a={instancePath:r+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.easing!==void 0){let a=e.easing;if(typeof a!="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(!(a==="linear"||a==="easeInQuad"||a==="easeOutQuad"||a==="easeInOutQuad"||a==="easeInCubic"||a==="easeOutCubic"||a==="easeInOutCubic"||a==="easeInQuart"||a==="easeOutQuart"||a==="easeInOutQuart"||a==="easeInQuint"||a==="easeOutQuint"||a==="easeInOutQuint"||a==="easeInSine"||a==="easeOutSine"||a==="easeInOutSine"||a==="easeInExpo"||a==="easeOutExpo"||a==="easeInOutExpo"||a==="easeInCirc"||a==="easeOutCirc"||a==="easeInOutCirc"||a==="easeInBack"||a==="easeOutBack"||a==="easeInOutBack"||a==="easeInBounce"||a==="easeOutBounce"||a==="easeInOutBounce"||a==="easeInElastic"||a==="easeOutElastic"||a==="easeInOutElastic")){let l={instancePath:r+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:Yw.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 a={instancePath:r+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return zr.errors=t,s===0}function W(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="initialValue"||a==="keyframes")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let a={instancePath:r+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.keyframes!==void 0){let a=e.keyframes;if(Array.isArray(a)){if(a.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=a.length;for(let u=0;u<l;u++)zr(a[u],{instancePath:r+"/keyframes/"+u,parentData:a,parentDataProperty:u,rootData:i})||(t=t===null?zr.errors:t.concat(zr.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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return W.errors=t,s===0}function ws(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let a={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="alpha"||a==="x"||a==="y"||a==="scaleX"||a==="scaleY"||a==="rotation")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.alpha!==void 0&&(W(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.x!==void 0&&(W(e.x,{instancePath:r+"/x",parentData:e,parentDataProperty:"x",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.y!==void 0&&(W(e.y,{instancePath:r+"/y",parentData:e,parentDataProperty:"y",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.scaleX!==void 0&&(W(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.scaleY!==void 0&&(W(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.rotation!==void 0&&(W(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ws.errors=t,s===0}function ks(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let a={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="translateX"||a==="translateY"||a==="alpha"||a==="scaleX"||a==="scaleY"||a==="rotation")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.translateX!==void 0&&(W(e.translateX,{instancePath:r+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.translateY!==void 0&&(W(e.translateY,{instancePath:r+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.alpha!==void 0&&(W(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.scaleX!==void 0&&(W(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.scaleY!==void 0&&(W(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length)),e.rotation!==void 0&&(W(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:i})||(t=t===null?W.errors:t.concat(W.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return ks.errors=t,s===0}function Br(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(a!=="tween"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.tween!==void 0&&(ks(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:i})||(t=t===null?ks.errors:t.concat(ks.errors),s=t.length))}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Br.errors=t,s===0}var ts={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"]}}]},Gw={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function vs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="texture"||a==="channel"||a==="invert")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let a={instancePath:r+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.channel!==void 0){let a=e.channel;if(typeof a!="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(!(a==="red"||a==="green"||a==="blue"||a==="alpha")){let l={instancePath:r+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Gw.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 a={instancePath:r+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return vs.errors=t,s===0}function As(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="initialValue"||a==="keyframes")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let a={instancePath:r+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.keyframes!==void 0){let a=e.keyframes;if(Array.isArray(a)){if(a.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=a.length;for(let u=0;u<l;u++)zr(a[u],{instancePath:r+"/keyframes/"+u,parentData:a,parentDataProperty:u,rootData:i})||(t=t===null?zr.errors:t.concat(zr.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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return As.errors=t,s===0}function Ps(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a:t=null),c){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[k]:t.push(k),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 k={instancePath:r,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};t===null?t=[k]:t.push(k),s++}var f=b===s;m=f}if(!m){let b={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let y=s,g=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let b={};t===null?t=[b]:t.push(b),s++}var w=h===s;if(s=y,t!==null&&(y?t.length=y:t=null),w){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:r,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};t===null?t=[k]:t.push(k),s++}var w=b===s;g=w}if(!g){let b={instancePath:r,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[b]:t.push(b),s++}for(let b in e)if(!lr.call(ts.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:ts.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 k={instancePath:r+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[k]:t.push(k),s++}let E=b.length;for(let k=0;k<E;k++)if(typeof b[k]!="string"){let A={instancePath:r+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[A]:t.push(A),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 k={instancePath:r+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[k]:t.push(k),s++}let E=b.length;for(let k=0;k<E;k++)vs(b[k],{instancePath:r+"/items/"+k,parentData:b,parentDataProperty:k,rootData:i})||(t=t===null?vs.errors:t.concat(vs.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:ts.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:ts.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&&(As(e.progress,{instancePath:r+"/progress",parentData:e,parentDataProperty:"progress",rootData:i})||(t=t===null?As.errors:t.concat(As.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 Ps.errors=t,s===0}function xs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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=a,t!==null&&(a?t.length=a:t=null),c){let b=s,E=s,k=s,A=s,R=!1,$=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.prev===void 0&&(x="prev")){let M={};t===null?t=[M]:t.push(M),s++}}var p=$===s;if(R=R||p,!R){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let pe={};t===null?t=[pe]:t.push(pe),s++}}var p=x===s;if(R=R||p,!R){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let ae={};t===null?t=[ae]:t.push(ae),s++}}var p=B===s;R=R||p}}if(R)s=A,t!==null&&(A?t.length=A:t=null);else{let x={};t===null?t=[x]:t.push(x),s++}var m=k===s;if(m){let x={instancePath:r,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[x]:t.push(x),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 x={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[x]:t.push(x),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,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let x;if(e.tween===void 0&&(x="tween")){let M={};t===null?t=[M]:t.push(M),s++}}var h=k===s;if(h){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=E,t!==null&&(E?t.length=E:t=null);let A=s,R=!1,$=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let x={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};t===null?t=[x]:t.push(x),s++}var w=$===s;if(R=R||w,!R){let x=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};t===null?t=[B]:t.push(B),s++}var w=x===s;if(R=R||w,!R){let B=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};t===null?t=[G]:t.push(G),s++}var w=B===s;R=R||w}}if(R)s=A,t!==null&&(A?t.length=A:t=null);else{let x={instancePath:r,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[x]:t.push(x),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:zw.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 k={instancePath:r+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),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&&(ws(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:i})||(t=t===null?ws.errors:t.concat(ws.errors),s=t.length)),e.prev!==void 0&&(Br(e.prev,{instancePath:r+"/prev",parentData:e,parentDataProperty:"prev",rootData:i})||(t=t===null?Br.errors:t.concat(Br.errors),s=t.length)),e.next!==void 0&&(Br(e.next,{instancePath:r+"/next",parentData:e,parentDataProperty:"next",rootData:i})||(t=t===null?Br.errors:t.concat(Br.errors),s=t.length)),e.mask!==void 0&&(Ps(e.mask,{instancePath:r+"/mask",parentData:e,parentDataProperty:"mask",rootData:i})||(t=t===null?Ps.errors:t.concat(Ps.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 xs.errors=t,s===0}function _p(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return xs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?xs.errors:t.concat(xs.errors),s=t.length),_p.errors=t,s===0}var Tp=Np;function Es(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!(a==="name"||a==="nameVariableId")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let a={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.nameVariableId!==void 0){let a=e.nameVariableId;if(typeof a=="string"){if(je(a)<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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Es.errors=t,s===0}function Np(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Es(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Es.errors:t.concat(Es.errors),s=t.length),Np.errors=t,s===0}var jp=Dp;var Hw=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function Ss(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(a!=="hex"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.hex!==void 0){let a=e.hex;if(typeof a=="string"){if(!Hw.test(a)){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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Ss.errors=t,s===0}function Dp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Ss(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Ss.errors:t.concat(Ss.errors),s=t.length),Dp.errors=t,s===0}var Lp=Mp;function Rs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let a=e.keyboard;if(a&&typeof a=="object"&&!Array.isArray(a))for(let l in a){let u=a[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 a=e.keyup;if(a&&typeof a=="object"&&!Array.isArray(a))for(let l in a){let u=a[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 a=e.elements;if(Array.isArray(a)){let l=a.length;for(let u=0;u<l;u++){let c=a[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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Rs.errors=t,s===0}function Mp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Rs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Rs.errors:t.concat(Rs.errors),s=t.length),Mp.errors=t,s===0}var Vp=qp;function Os(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="fileId"||a==="fileType")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let a={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let a={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Os.errors=t,s===0}function qp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Os(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Os.errors:t.concat(Os.errors),s=t.length),qp.errors=t,s===0}var Fp=Up;function Cs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[a]:t.push(a),s++}if(e.width===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[a]:t.push(a),s++}if(e.height===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="fileId"||a==="fileType"||a==="width"||a==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let a={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let a={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.width!==void 0){let a=e.width;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a=e.height;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Cs.errors=t,s===0}function Up(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Cs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Cs.errors:t.concat(Cs.errors),s=t.length),Up.errors=t,s===0}var Bp=zp;function $s(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let a=e.elements;if(Array.isArray(a)){let l=a.length;for(let u=0;u<l;u++){let c=a[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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return $s.errors=t,s===0}function zp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return $s(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?$s.errors:t.concat($s.errors),s=t.length),zp.errors=t,s===0}var Yp=Gp;function _s(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0,a=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 k;if(e.count===void 0&&(k="count")){let A={};t===null?t=[A]:t.push(A),s++}}var g=y===s;if(f=f||g,!f){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.texture===void 0&&(R="texture")){let $={};t===null?t=[$]:t.push($),s++}}var g=k===s;if(f=f||g,!f){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.behaviors===void 0&&(j="behaviors")){let x={};t===null?t=[x]:t.push(x),s++}}var g=R===s;if(f=f||g,!f){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.emitter===void 0&&(M="emitter")){let B={};t===null?t=[B]:t.push(B),s++}}var g=j===s;f=f||g}}}if(f)s=d,t!==null&&(d?t.length=d:t=null);else{let k={};t===null?t=[k]:t.push(k),s++}var h=m===s;if(h){let k={instancePath:r,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[k]:t.push(k),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 k={instancePath:r,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};t===null?t=[k]:t.push(k),s++}var b=c===s;b&&(l=!0,u=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[k]:t.push(k),s++}if(e.behaviors===void 0){let k={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};t===null?t=[k]:t.push(k),s++}if(e.emitter===void 0){let k={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};t===null?t=[k]:t.push(k),s++}}var b=w===s;if(b&&l?(l=!1,u=[u,1]):b&&(l=!0,u=1),l)s=a,t!==null&&(a?t.length=a:t=null);else{let k={instancePath:r,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:u},message:"must match exactly one schema in oneOf"};t===null?t=[k]:t.push(k),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[k]:t.push(k),s++}if(e.height===void 0){let k={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[k]:t.push(k),s++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let A={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};t===null?t=[A]:t.push(A),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let A={instancePath:r+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[A]:t.push(A),s++}}else{let A={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[A]:t.push(A),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let A={instancePath:r+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[A]:t.push(A),s++}}else{let A={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[A]:t.push(A),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:r+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let A={instancePath:r+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};t===null?t=[A]:t.push(A),s++}if(k.appearance===void 0){let A={instancePath:r+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};t===null?t=[A]:t.push(A),s++}for(let A in k)if(!(A==="emission"||A==="movement"||A==="appearance"||A==="bounds")){let R={instancePath:r+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:A},message:"must NOT have additional properties"};t===null?t=[R]:t.push(R),s++}if(k.emission!==void 0){let A=k.emission;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let R={instancePath:r+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[R]:t.push(R),s++}}if(k.movement!==void 0){let A=k.movement;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let R={instancePath:r+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[R]:t.push(R),s++}}if(k.appearance!==void 0){let A=k.appearance;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let R={instancePath:r+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[R]:t.push(R),s++}}if(k.bounds!==void 0){let A=k.bounds;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let R={instancePath:r+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[R]:t.push(R),s++}}}else{let A={instancePath:r+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[A]:t.push(A),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let A={instancePath:r+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[A]:t.push(A),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let A={instancePath:r+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[A]:t.push(A),s++}}if(e.texture!==void 0){let k=e.texture,A=s,R=!1,$=null,j=s;if(typeof k=="string"){if(je(k)<1){let M={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=[M]:t.push(M),s++}}else{let M={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[M]:t.push(M),s++}var E=j===s;E&&(R=!0,$=0);let x=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let M={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[M]:t.push(M),s++}var E=x===s;if(E&&R?(R=!1,$=[$,1]):E&&(R=!0,$=1),R)s=A,t!==null&&(A?t.length=A:t=null);else{let M={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:$},message:"must match exactly one schema in oneOf"};t===null?t=[M]:t.push(M),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let R={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[R]:t.push(R),s++}let A=k.length;for(let R=0;R<A;R++){let $=k[R];if($&&typeof $=="object"&&!Array.isArray($)){if($.type===void 0){let j={instancePath:r+"/behaviors/"+R,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[j]:t.push(j),s++}for(let j in $)if(!(j==="type"||j==="config")){let x={instancePath:r+"/behaviors/"+R,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:j},message:"must NOT have additional properties"};t===null?t=[x]:t.push(x),s++}if($.type!==void 0){let j=$.type;if(typeof j=="string"){if(je(j)<1){let x={instancePath:r+"/behaviors/"+R+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[x]:t.push(x),s++}}else{let x={instancePath:r+"/behaviors/"+R+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[x]:t.push(x),s++}}if($.config!==void 0){let j=$.config;if(!(j&&typeof j=="object"&&!Array.isArray(j))){let x={instancePath:r+"/behaviors/"+R+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[x]:t.push(x),s++}}}else{let j={instancePath:r+"/behaviors/"+R,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[j]:t.push(j),s++}}}else{let A={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[A]:t.push(A),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let A={instancePath:r+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};t===null?t=[A]:t.push(A),s++}if(k.lifetime!==void 0){let A=k.lifetime;if(A&&typeof A=="object"&&!Array.isArray(A)){if(A.min===void 0){let R={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};t===null?t=[R]:t.push(R),s++}if(A.max===void 0){let R={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};t===null?t=[R]:t.push(R),s++}if(A.min!==void 0){let R=A.min;if(typeof R=="number"){if(R<0||isNaN(R)){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(A.max!==void 0){let R=A.max;if(typeof R=="number"){if(R<0||isNaN(R)){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 R={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[R]:t.push(R),s++}}}else{let A={instancePath:r+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[A]:t.push(A),s++}}}else{let k={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}return _s.errors=t,s===0}function Gp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return _s(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?_s.errors:t.concat(_s.errors),s=t.length),Gp.errors=t,s===0}var Hp=Xp;var rp={type:"object",properties:{fileId:{type:"string"},fileType:{type:"string"},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["fileId"],additionalProperties:!1};function Ts(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!lr.call(rp.properties,a)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let a={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let a={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let a={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.volume!==void 0){let a=e.volume;if(typeof a=="number"){if(a>100||isNaN(a)){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(a<0||isNaN(a)){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 a={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[a]:t.push(a),s++}if(e.pan!==void 0){let a=e.pan;if(typeof a=="number"){if(a>1||isNaN(a)){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(a<-1||isNaN(a)){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 a=e.startDelayMs;if(typeof a=="number"){if(a<0||isNaN(a)){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 a=e.playbackRate;if(typeof a=="number"){if(a<0||isNaN(a)){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 a=e.startAt;if(typeof a=="number"){if(a<0||isNaN(a)){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 a=e.endAt;if(typeof a!="number"&&a!==null){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:rp.properties.endAt.type},message:"must be number,null"};t===null?t=[l]:t.push(l),s++}if(typeof a=="number"&&(a<0||isNaN(a))){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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Ts.errors=t,s===0}function Xp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Ts(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Ts.errors:t.concat(Ts.errors),s=t.length),Xp.errors=t,s===0}var Wp=Kp;var Xw=new RegExp("^.+$","u");function Ns(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[a]:t.push(a),s++}if(e.jsonData===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};t===null?t=[a]:t.push(a),s++}if(e.width===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[a]:t.push(a),s++}if(e.height===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="fileId"||a==="jsonData"||a==="width"||a==="height"||a==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let a={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.jsonData!==void 0){let a=e.jsonData;if(!(a&&typeof a=="object"&&!Array.isArray(a))){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 a=e.width;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a=e.height;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a=e.animations;if(a&&typeof a=="object"&&!Array.isArray(a)){for(let l in a)if(Xw.test(l)){let u=a[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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Ns.errors=t,s===0}function Kp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Ns(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Ns.errors:t.concat(Ns.errors),s=t.length),Kp.errors=t,s===0}var Jp=Qp;var tp={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 js(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=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(!lr.call(tp.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(je(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 a=m===s;a&&(c=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let h={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[h]:t.push(h),s++}let f=l.length;for(let h=0;h<f;h++){let w=l[h];if(typeof w=="string"){if(je(w)<1){let b={instancePath:r+"/fontId/"+h,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[b]:t.push(b),s++}}else{let b={instancePath:r+"/fontId/"+h,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}}let y=l.length,g;if(y>1){let h={};for(;y--;){let w=l[y];if(typeof w=="string"){if(typeof h[w]=="number"){g=h[w];let b={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:y,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+y+" are identical)"};t===null?t=[b]:t.push(b),s++;break}h[w]=y}}}}else{let f={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[f]:t.push(f),s++}var a=d===s;if(a&&c?(c=!1,p=[p,1]):a&&(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:tp.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(je(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 js.errors=t,s===0}function Qp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return js(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?js.errors:t.concat(js.errors),s=t.length),Qp.errors=t,s===0}var Zp=ed;var Ww={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 Ds(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let a in e)if(!lr.call(Ww.properties,a)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.x!==void 0){let a=e.x;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a=e.y;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let a={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let a={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let a={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let a={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let a={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let a={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[a]:t.push(a),s++}}else{let a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Ds.errors=t,s===0}function ed(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Ds(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Ds.errors:t.concat(Ds.errors),s=t.length),ed.errors=t,s===0}var rd=td;function Ls(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[a]:t.push(a),s++}if(e.width===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[a]:t.push(a),s++}if(e.height===void 0){let a={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[a]:t.push(a),s++}for(let a in e)if(!(a==="fileId"||a==="fileType"||a==="width"||a==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:a},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let a={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let a={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[a]:t.push(a),s++}if(e.width!==void 0){let a=e.width;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a=e.height;if(!(typeof a=="number"&&!(a%1)&&!isNaN(a))){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 a={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[a]:t.push(a),s++}return Ls.errors=t,s===0}function td(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:i=e}={}){let t=null,s=0;return Ls(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:i})||(t=t===null?Ls.errors:t.concat(Ls.errors),s=t.length),td.errors=t,s===0}var Jt=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Kt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),cr=e=>e===void 0?void 0:structuredClone(e),Kw=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"}),Jw=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Qw=Object.freeze({background:np,bgm:op,character:ap,choice:cp,cleanAll:pp,control:fp,dialogue:yp,form:gp,layout:Ip,screen:kp,sfx:Ap,visual:xp,voice:Sp}),Zw=Object.freeze({achievement:Op,animation:$p,character:Tp,color:jp,control:Lp,font:Vp,image:Fp,layout:Bp,particle:Yp,sound:Hp,spritesheet:Wp,textStyle:Jp,transform:Zp,video:rd}),e0=new Set(["files","language","patches"]),r0=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),t0=new Set(["lineId","mode","payload","type"]),n0=new Set(["mode","payload","sceneId","type"]),s0=new Set(["mode","operation","payload","resourceId","type"]),o0=new Set(["fileId","mimeType"]),U=(e,r)=>{throw new Error(`Invalid l10nData at ${e}: ${r}`)},He=(e,r)=>{Kt(e)||U(r,"expected an object")},Yi=(e,r)=>{Array.isArray(e)||U(r,"expected an array")},dt=(e,r)=>{(typeof e!="string"||e.length===0)&&U(r,"expected a non-empty string")},id=(e,r)=>{typeof e!="string"&&U(r,"expected a string")},Qe=(e,r,n)=>{for(let o of Object.keys(e))r.has(o)||U(`${n}.${o}`,"unknown field")},Ze=(e,r,n)=>{for(let o of r)Jt(e,o)||U(n,`missing required field "${o}"`)},i0=e=>e.replaceAll("~1","/").replaceAll("~0","~"),a0=(e,r)=>{let n=(r?.instancePath??"").split("/").slice(1).map(i0);return r?.keyword==="required"?n.push(r.params.missingProperty):r?.keyword==="additionalProperties"&&n.push(r.params.additionalProperty),n.reduce((o,i)=>/^\d+$/.test(i)?`${o}[${i}]`:`${o}.${i}`,e)},l0=(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,i=r.instancePath.split("/").length;return o>i?n:r},void 0)??e[0],ad=({value:e,validator:r,path:n,contract:o})=>{if(r(e))return;let i=l0(r.errors);U(a0(n,i),`does not match ${o}: ${i?.message??"schema validation failed"}`)},Ms=(e,r,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||U(r,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,i)=>Ms(o,`${r}[${i}]`,n));return}Object.entries(e).forEach(([o,i])=>Ms(i,`${r}.${o}`,n))}},Je=(e,r)=>{e===""&&U(r,"expected a non-empty resourceId")},c0=(e,r,n)=>{let o=(s,a)=>Je(s?.resourceId,`${a}.resourceId`),i=(s,a)=>(s??[]).forEach((l,u)=>Je(l?.resourceId,`${a}[${u}].resourceId`)),t=(s,a)=>{Je(s?.resourceId,`${a}.resourceId`),i(s?.sounds,`${a}.sounds`)};switch(e){case"background":Je(r.resourceId,`${n}.resourceId`),o(r.animations,`${n}.animations`);break;case"bgm":case"voice":t(r,n);break;case"sfx":i(r.items,`${n}.items`),(r.channels??[]).forEach((s,a)=>i(s?.sounds,`${n}.channels[${a}].sounds`));break;case"character":(r.items??[]).forEach((s,a)=>{(s.sprites??[]).forEach((l,u)=>Je(l?.resourceId,`${n}.items[${a}].sprites[${u}].resourceId`)),o(s.animations,`${n}.items[${a}].animations`)});break;case"choice":case"form":case"layout":Je(r.resourceId,`${n}.resourceId`),o(r.animations,`${n}.animations`);break;case"control":Je(r.resourceId,`${n}.resourceId`);break;case"dialogue":Je(r.ui?.resourceId,`${n}.ui.resourceId`),o(r.ui?.animations,`${n}.ui.animations`),(r.character?.sprite?.items??[]).forEach((s,a)=>Je(s?.resourceId,`${n}.character.sprite.items[${a}].resourceId`)),o(r.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(r.animations,`${n}.animations`);break;case"visual":(r.items??[]).forEach((s,a)=>{Je(s?.resourceId,`${n}.items[${a}].resourceId`),o(s?.animations,`${n}.items[${a}].animations`)});break;default:break}},ft=(e,r)=>{dt(e,r),(e==="__proto__"||e==="constructor"||e==="prototype")&&U(r,`"${e}" is not a safe ID`)},u0=(e,r)=>{dt(e,r),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&U(r,"must be a safe single filename")},Wt=(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((i,t)=>Wt(i,r[t]));if(!Kt(e)||!Kt(r))return!1;let n=Object.keys(e).sort(),o=Object.keys(r).sort();return Wt(n,o)&&n.every(i=>Wt(e[i],r[i]))},Vs=(e,r=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>Vs(o,r,n)),r;if(!Kt(e)||n.has(e))return r;n.add(e);for(let[o,i]of Object.entries(e))o==="fileId"&&typeof i=="string"&&r.add(i),Vs(i,r,n);return r},p0=e=>{let r=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[i,t]of Object.entries(o?.sections??{}))for(let[s,a]of(t?.lines??[]).entries()){if(typeof a?.id!="string")continue;let l=r.get(a.id)??[];l.push({sceneId:n,sectionId:i,lineIndex:s,line:a}),r.set(a.id,l)}return r},ld=(e,r,n)=>{let o=e.get(r)??[];return o.length===0&&U(n,`lineId "${r}" does not exist in projectData`),o.length>1&&U(n,`lineId "${r}" is not globally unique in projectData`),o[0]},cd=(e,r)=>e.story.scenes[r.sceneId].sections[r.sectionId].lines[r.lineIndex],nd=e=>({items:(e?.items??[]).map(r=>({id:r?.id,events:r?.events}))}),sd=e=>{let r=cr(e??{});delete r.resourceId,delete r.animations;for(let n of Object.values(r.fields??{}))Kt(n)&&delete n.placeholder;return r},d0=(e,r,n,o)=>{e==="choice"&&!Wt(nd(r),nd(n))&&U(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Wt(sd(r),sd(n))&&U(o,"form behavior must remain identical; only presentation fields and placeholders may change")},f0=({patch:e,path:r,lineIndex:n})=>{Qe(e,r0,r),Ze(e,["type","lineId","actionType","payload"],r),ft(e.lineId,`${r}.lineId`),dt(e.actionType,`${r}.actionType`),He(e.payload,`${r}.payload`),e.mode!==void 0&&e.mode!=="replace"&&U(`${r}.mode`,'line.action supports only "replace"'),Jw.has(e.actionType)||U(`${r}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=ld(n,e.lineId,`${r}.lineId`),i=o.line?.actions?.[e.actionType];return i===void 0&&U(`${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")&&U(`${r}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),Jt(e.payload,"content")&&U(`${r}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&U(`${r}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),d0(e.actionType,i,e.payload,`${r}.payload`),ad({value:e.payload,validator:Qw[e.actionType],path:`${r}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Ms(e.payload,`${r}.payload`),c0(e.actionType,e.payload,`${r}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},m0=(e,r)=>{Yi(e,r),e.forEach((n,o)=>{He(n,`${r}[${o}]`),Qe(n,new Set(["text"]),`${r}[${o}]`),Ze(n,["text"],`${r}[${o}]`),id(n.text,`${r}[${o}].text`)})},y0=({patch:e,path:r,lineIndex:n})=>{Qe(e,t0,r),Ze(e,["type","lineId","payload"],r),ft(e.lineId,`${r}.lineId`),He(e.payload,`${r}.payload`),Qe(e.payload,new Set(["content"]),`${r}.payload`),Ze(e.payload,["content"],`${r}.payload`),m0(e.payload.content,`${r}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&U(`${r}.mode`,'line.dialogue supports only "replace"');let o=ld(n,e.lineId,`${r}.lineId`);return o.line?.actions?.dialogue===void 0&&U(`${r}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},h0=({patch:e,path:r,projectData:n})=>(Qe(e,n0,r),Ze(e,["type","mode","sceneId","payload"],r),ft(e.sceneId,`${r}.sceneId`),He(e.payload,`${r}.payload`),Qe(e.payload,new Set(["name"]),`${r}.payload`),Ze(e.payload,["name"],`${r}.payload`),id(e.payload.name,`${r}.payload.name`),e.mode!=="patch"&&U(`${r}.mode`,'story.scene requires "patch"'),Jt(n?.story?.scenes??{},e.sceneId)||U(`${r}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),g0=(e,r,n)=>{He(r,n),["font","image","sound","spritesheet","video"].includes(e)&&dt(r.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(r.width)||U(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||U(`${n}.height`,"expected an integer")),e==="spritesheet"&&(He(r.jsonData,`${n}.jsonData`),Number.isInteger(r.width)||U(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||U(`${n}.height`,"expected an integer")),e==="color"&&(typeof r.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r.hex))&&U(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),ad({value:r,validator:Zw[e],path:n,contract:`the resource.${e} schema`}),Ms(r,n)},b0=({patch:e,path:r,projectData:n,packageFileIds:o,canonicalFileIds:i})=>{Qe(e,s0,r),Ze(e,["type","resourceId","payload"],r),ft(e.resourceId,`${r}.resourceId`);let t=e.type.slice(9),s=Kw[t];s||U(`${r}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&U(`${r}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&U(`${r}.operation`,'the only resource operation is "add"'),g0(t,e.payload,`${r}.payload`);let a=n?.resources?.[s]??{},l=Jt(a,e.resourceId);e.operation==="add"&&l&&U(`${r}.resourceId`,`cannot add existing ${t} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&U(`${r}.resourceId`,`cannot replace missing ${t} resource "${e.resourceId}"`);for(let u of Vs(e.payload))!o.has(u)&&!i.has(u)&&U(`${r}.payload`,`fileId "${u}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:r,patch:e}},od=({resources:e,collectionName:r,resourceId:n,path:o,label:i})=>{n!==void 0&&(typeof n!="string"||n.length===0||!Jt(e?.[r]??{},n))&&U(o,`${i} resource "${n}" was not found`)},I0=(e,r)=>{let n=cr(e);for(let i of r.patches)i.kind==="resource"&&(n.resources[i.collectionName]??={},n.resources[i.collectionName][i.patch.resourceId]=cr(i.patch.payload));let o=n.resources??{};for(let i of r.patches){if(i.patch.type!=="resource.textStyle")continue;let t=i.patch.payload,s=Array.isArray(t.fontId)?t.fontId:[t.fontId];s.forEach((a,l)=>od({resources:o,collectionName:"fonts",resourceId:a,path:`${i.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[a,l]of[["colorId",t.colorId],["strokeColorId",t.strokeColorId],["shadow.colorId",t.shadow?.colorId]])od({resources:o,collectionName:"colors",resourceId:l,path:`${i.path}.payload.${a}`,label:"color"})}},w0=({patch:e,path:r,projectData:n,lineIndex:o,packageFileIds:i,canonicalFileIds:t})=>{if(He(e,r),dt(e.type,`${r}.type`),e.type==="line.action")return f0({patch:e,path:r,lineIndex:o});if(e.type==="line.dialogue")return y0({patch:e,path:r,lineIndex:o});if(e.type==="story.scene")return h0({patch:e,path:r,projectData:n});if(e.type.startsWith("resource."))return b0({patch:e,path:r,projectData:n,packageFileIds:i,canonicalFileIds:t});U(`${r}.type`,`unsupported patch type "${e.type}"`)},k0=(e,r)=>{Yi(e,r);let n=new Set;return e.forEach((o,i)=>{let t=`${r}[${i}]`;He(o,t),Qe(o,o0,t),Ze(o,["fileId"],t),u0(o.fileId,`${t}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&U(`${t}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&U(`${t}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},v0=({packageId:e,packageData:r,path:n,projectData:o,lineIndex:i,canonicalFileIds:t})=>{He(r,n),Qe(r,e0,n),Ze(r,["language","files","patches"],n),dt(r.language,`${n}.language`);let s=k0(r.files,`${n}.files`);Yi(r.patches,`${n}.patches`);let a=new Set,l=r.patches.map((u,c)=>{let p=w0({patch:u,path:`${n}.patches[${c}]`,projectData:o,lineIndex:i,packageFileIds:s,canonicalFileIds:t});return a.has(p.key)&&U(`${n}.patches[${c}]`,`duplicate patch target "${p.key}"`),a.add(p.key),p});return{id:e,data:r,fileIds:s,patches:l}},ud=({projectData:e,l10nData:r})=>{if(r===void 0)return{packages:new Map};He(r,"l10nData"),Qe(r,new Set(["packages"]),"l10nData"),Ze(r,["packages"],"l10nData"),He(r.packages,"l10nData.packages");let n=p0(e),o=Vs(e?.resources??{}),i=new Map,t=new Map;for(let[s,a]of Object.entries(r.packages)){ft(s,`l10nData.packages.${s}`);let l=v0({packageId:s,packageData:a,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let u of l.fileIds){o.has(u)&&U(`l10nData.packages.${s}.files`,`fileId "${u}" conflicts with a canonical project file`);let c=t.get(u);c!==void 0&&U(`l10nData.packages.${s}.files`,`fileId "${u}" is already declared by package "${c}"`),t.set(u,s)}I0(e,l),i.set(s,l)}return{packages:i}},A0=(e,r)=>{let{collectionName:n,patch:o}=r;e.resources[n]??={},e.resources[n][o.resourceId]=cr(o.payload)},P0=(e,r)=>{let{patch:n}=r,o=e.story.scenes[n.sceneId];o.name=n.payload.name},x0=(e,r)=>{let{location:n,patch:o}=r,i=cd(e,n);if(o.actionType!=="dialogue"){i.actions[o.actionType]=cr(o.payload);return}let t=cr(n.line.actions.dialogue.content);i.actions.dialogue=cr(o.payload),t!==void 0&&(i.actions.dialogue.content=t)},E0=(e,r)=>{let{location:n,patch:o}=r,i=cd(e,n);i.actions.dialogue.content=cr(o.payload.content)},pd=({projectData:e,l10nData:r})=>{let n=ud({projectData:e,l10nData:r});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},qs=({projectData:e,l10nData:r,l10nId:n=null})=>{let o=ud({projectData:e,l10nData:r});if(n!==null&&(ft(n,"l10nId"),o.packages.has(n)||U("l10nId",`package "${n}" was not imported`)),n===null)return e;let i=cr(e),t=o.packages.get(n).patches;return t.filter(s=>s.kind==="resource").forEach(s=>A0(i,s)),t.filter(s=>s.kind==="story.scene").forEach(s=>P0(i,s)),t.filter(s=>s.kind==="line.action").forEach(s=>x0(i,s)),t.filter(s=>s.kind==="line.dialogue").forEach(s=>E0(i,s)),i};var Gi=Object.freeze({auto:1e3,skip:80,authored:1e3}),en=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),dd=new WeakMap,S0=new ArrayBuffer(8),Hi=new DataView(S0),R0=e=>{let r=dd.get(e);if(r)return r;let n={dispatchDepth:0};return dd.set(e,n),n},O0=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null},C0=(e,r)=>Object.keys(e).length===r.length&&r.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Er=(e,r,n)=>{if(!O0(e)||!C0(e,r))throw new TypeError(`${n} has an invalid shape`)},Qt=(e,r)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${r} must be a non-negative safe integer`)},Zt=(e,r)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${r} must be a finite non-negative number`)},fd=e=>{if(Zt(e,"duration"),e===0)return 0n;Hi.setFloat64(0,e,!1);let r=Hi.getUint32(0,!1),n=Hi.getUint32(4,!1),o=r>>>20&2047,i=BigInt(r&1048575)<<32n|BigInt(n);if(o===0)return i;let t=1n<<52n|i,s=o-1;return t<<BigInt(s)},$0=e=>structuredClone(e),Xi=(e,r)=>e===r?!0:!e||!r||e.mode!==r.mode||e.kind!==r.kind?!1:e.mode==="legacy"?e.instanceToken===r.instanceToken:e.delayMs!==r.delayMs?!1:e.kind==="auto"?e.contentKey===r.contentKey&&e.owner.sessionId===r.owner.sessionId&&e.owner.lineEntryId===r.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===r.owner.sessionId:e.trigger===r.trigger&&e.owner.lineEntryId===r.owner.lineEntryId,Wi=(e,r,n)=>{if(r===null)return null;if(e==="auto"){if(Er(r,["owner","delayMs","contentKey"],"auto timer"),Er(r.owner,["sessionId","lineEntryId"],"auto timer owner"),Qt(r.owner.sessionId,"auto owner sessionId"),Qt(r.owner.lineEntryId,"auto owner lineEntryId"),r.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(Zt(r.delayMs,"auto delayMs"),typeof r.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Er(r,["owner","delayMs"],"skip timer"),Er(r.owner,["sessionId"],"skip timer owner"),Qt(r.owner.sessionId,"skip owner sessionId"),Zt(r.delayMs,"skip delayMs");else{if(Er(r,["owner","delayMs","trigger"],"authored timer"),Er(r.owner,["lineEntryId"],"authored timer owner"),Qt(r.owner.lineEntryId,"authored owner lineEntryId"),r.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(Zt(r.delayMs,"authored delayMs"),r.trigger!=="fromStart"&&r.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...$0(r)}},_0=e=>{if(Er(e,["contractVersion","status","lineEntryId","timers"],"playback schedule"),e.contractVersion!==1)throw new TypeError("playback schedule contractVersion must be 1");if(e.status!=="settled"&&e.status!=="unsettled")throw new TypeError('playback schedule status must be "settled" or "unsettled"');if(Qt(e.lineEntryId,"playback schedule lineEntryId"),e.status==="unsettled"){if(e.timers!==null)throw new TypeError("unsettled playback schedule timers must be null");return{contractVersion:1,status:"unsettled",lineEntryId:e.lineEntryId,timers:null}}Er(e.timers,["auto","skip","authored"],"playback schedule timers");let r={auto:Wi("auto",e.timers.auto,e.lineEntryId),skip:Wi("skip",e.timers.skip,e.lineEntryId),authored:Wi("authored",e.timers.authored,e.lineEntryId)};if(r.auto&&r.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:r}},Ki=e=>({descriptor:e,remainingQuanta:fd(e.delayMs)}),Fs=["auto","skip","authored"],md=({ticker:e,dispatchAutomaticAttempt:r,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof r!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let o=R0(e),i=!0,t={},s={},a=null,l=null,u=null,c=null,p=!1,m=!1,d="legacy",f={auto:null,skip:null,authored:null},y={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},h=()=>Fs.some(D=>f[D]),w=()=>{l=null,u=null},b=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let D=u;if(D){if(o.dispatchDepth>0||m){b();return}i&&t===D.lifecycleToken&&s===D.generationToken&&a===D.callback&&h()&&!c&&(l=D.registrationToken),u===D&&(u=null)}}))},E=()=>{if(!c)return;let D=c;e.remove(D),c===D&&(c=null)},k=()=>{let D=a;D&&(w(),a=null,c=D,e.remove(D),c===D&&(c=null))},A=()=>{f={auto:null,skip:null,authored:null}},R=()=>{A(),s={},m||k()},$=D=>{if(o.dispatchDepth>0||m){u=D,b();return}i&&t===D.lifecycleToken&&s===D.generationToken&&a===D.callback&&h()&&(l=D.registrationToken),u===D&&(u=null)},j=()=>{if(!i||!h()||a)return;E();let D=t,ie=s,J={},q=Q=>{if(!i||D!==t||ie!==s||J!==l||q!==a||m)return;if(!Q||typeof Q.deltaMS!="number"||!Number.isFinite(Q.deltaMS)||Q.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let se=fd(Q.deltaMS);m=!0,o.dispatchDepth+=1;let ye=s,Z=null;try{let C=[];for(let _ of Fs){let F=f[_];F&&(F.remainingQuanta<=se?(C.push({kind:_,descriptor:F.descriptor,revision:g[_]}),f[_]=null):F.remainingQuanta-=se)}if(C.length>0){try{r({dueKinds:C.map(({kind:_})=>_)})}catch(_){let F=n(_);if(d==="reconciled"&&F==="preCommit")for(let{kind:oe,descriptor:he}of C)y[oe]=he;else d==="legacy"&&A();throw _}if(d==="legacy")for(let _ of C)_.kind==="skip"&&g.skip===_.revision&&f.skip===null&&(f.skip=Ki(_.descriptor))}}catch(C){Z=C}finally{o.dispatchDepth-=1,m=!1;try{ye===s?h()?j():k():a===q&&!h()&&k()}catch(C){throw Z?new AggregateError([Z,C],"Playback attempt and ticker cleanup both failed"):C}}if(Z)throw Z},K={callback:q,lifecycleToken:D,generationToken:ie,registrationToken:J};a=q,u=K;try{e.add(q)}catch(Q){throw a=null,w(),A(),s={},c=q,Q}$(K)},x=D=>{g[D]+=1,f[D]=null,y[D]=null,!h()&&!m&&k()},M=(D,ie)=>{Zt(ie,`${D} delay`),d="legacy",g[D]+=1,y[D]=null,f[D]=Ki({mode:"legacy",kind:D,instanceToken:{},delayMs:ie}),j()};return{handleLegacyEffect:D=>{switch(D.name){case"startAutoNextTimer":return M("auto",D.payload?.delay??Gi.auto),!0;case"clearAutoNextTimer":return x("auto"),!0;case"startSkipNextTimer":return M("skip",D.payload?.delay??Gi.skip),!0;case"clearSkipNextTimer":return x("skip"),!0;case"nextLineConfigTimer":return M("authored",D.payload?.delay??Gi.authored),!0;case"clearNextLineConfigTimer":return x("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:D=>{let ie;try{ie=_0(D)}catch(q){try{R()}catch(K){throw new AggregateError([q,K],"Playback schedule validation and cleanup both failed")}throw q}if(d="reconciled",ie.status==="unsettled"){A(),m||k();return}let J={};for(let q of Fs){let K=ie.timers[q],Q=y[q];if(Q&&(!K||!Xi(Q,K))&&(y[q]=null),K&&y[q]&&Xi(y[q],K)){J[q]=null;continue}let se=f[q];J[q]=K&&se&&Xi(se.descriptor,K)?se:K?Ki(K):null}f=J,h()?j():m||k()},reset:()=>{let D=[a,c].filter((q,K,Q)=>q&&Q.indexOf(q)===K);t={},s={},w(),a=null,c=null,A(),y={auto:null,skip:null,authored:null};for(let q of Fs)g[q]+=1;d="legacy",i=!0;let ie=null,J=null;for(let q of D)try{e.remove(q)}catch(K){ie??=K,J??=q}if(c=J,ie)throw ie},dispose:()=>{i=!1,t={},s={},w(),A(),y={auto:null,skip:null,authored:null};let D=[a,c].filter((q,K,Q)=>q&&Q.indexOf(q)===K);a=null,c=null;let ie=null,J=null;for(let q of D)try{e.remove(q)}catch(K){ie??=K,J??=q}if(c=J,ie)throw ie}}};var T0=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),N0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ji="conditional",rn="random",Zi=Symbol("conditionalAutoContinue"),j0=new Set(["sectionTransition","resetStoryAtSection"]),D0=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),L0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),M0=new Set(["nextLine","nextLineFromSystem"]),V0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Qi="form",q0=new Set(["submitForm","cancelForm"]),F0="showImageGalleryVariant",U0="playMusicRoomTrack",B0="startSceneReplay",z0=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Le=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Y0=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,tn=e=>e?.type===Zi,Yr=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,G0=(e,r)=>[...new Set([...Object.keys(e??{}),...Object.keys(r??{})])].some(o=>!Object.is(e?.[o],r?.[o]));function ea(e){let r=Y0(),n,o=0,i=!1,t=0,s=null,a=0,l=!1,u=0,c=[],p=null,m=null,d=new Map,f=new Map,y=new Map,g,h,w=null,b=!1,E=!1,k=0,A=new Map,R=al(e.randomSource),{handlePendingEffects:$}=e;if(typeof $!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let j=$.bind($),x=typeof $.reconcilePlaybackScheduleV1=="function"?$.reconcilePlaybackScheduleV1.bind($):null,M=typeof $.reset=="function"?$.reset.bind($):null,B=typeof $.dispose=="function"?$.dispose.bind($):null;if(x&&(!M||!B))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let pe=I=>{if(E)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},G=I=>{if(pe(I),!i||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},ae=(I,v)=>{if(k===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},O=A.get(I);(O===void 0||S[v]>S[O])&&A.set(I,v)},D=I=>{let v=A.get(I)??"preCommit";return A.delete(I),v},ie=I=>{if(x){E=!0;try{let v=x(structuredClone(I));if(v!==null&&(typeof v=="object"||typeof v=="function")&&typeof v.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{E=!1}}},J=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),q=I=>{if(!(!x||!i||!n)){b=!0;try{ie(J())}catch(v){if(I){let S=new AggregateError([I,v],"Playback work and schedule invalidation both failed");throw A.delete(I),ae(S,"reconcileFailed"),S}throw ae(v,"reconcileFailed"),v}}},K=()=>{if(!x||!b||!i||!n||a>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(v){throw ae(v,"reconcileFailed"),q(v),v}try{ie({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(v){throw ae(v,"reconcileFailed"),q(v),v}b=!1},Q=(I=new Map,v=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>v<S.expiresAt).map(([S,O])=>[S,{animation:structuredClone(O.animation),startedAt:O.startedAt,expiresAt:O.expiresAt}])),se=(I=new Map)=>Array.from(I.values()).map(v=>structuredClone(v.animation)),ye=(I=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,v])=>I<v.expiresAt))},Z=()=>{if(i&&!(a>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,v=[...n.selectPendingEffects()],S=v.map(O=>O.name!=="handleLineActions"?O:{...O,payload:{...O.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let O=x?S.filter(T=>!en.has(T.name)):S;O.length>0&&j(O)}catch(O){throw n.clearPendingEffects(),v.forEach(T=>{n.appendPendingEffect(T)}),ae(O,"postCommitUnsettled"),q(O),O}}}finally{l=!1}K()}},C=I=>{a+=1;let v=!1;try{let S=I();return v=!0,S}finally{a-=1,v&&Z()}},_=({initialState:I,namespace:v})=>{pe("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:O,...T}=I,z=O===void 0?void 0:structuredClone(O),Y=structuredClone(I.projectData),te=pd({projectData:Y,l10nData:z}),ue=T.global??{};if(!Le(ue))throw new Error("Malformed global state.");let Oe=ue.runtime??{};if(!Le(Oe))throw new Error("Malformed global.runtime.");let xe=Oe.localizationPackageId;if(xe!=null&&typeof xe!="string")throw new Error("localizationPackageId requires a string or null value");let Rr=new Set(te.map(({l10nId:Hr})=>Hr).filter(Hr=>Hr!==null)),Gr=typeof xe=="string"&&Rr.has(xe)?xe:null,on=qs({projectData:Y,l10nData:z,l10nId:Gr}),Ys=Gu({...T,global:{...ue,localizationPackages:te,runtime:{...Oe,localizationPackageId:Gr}},projectData:on,initialAudioCommandId:S});M?.(),n=Ys,o+=1,i=!0,t=0,s=pt(v),a=0,l=!1,u=0,c=[],p=null,m=null,d=new Map,f=new Map,y=new Map,g=Y,h=z,w=Gr,b=!0,E=!1,k=0,A.clear(),n.appendPendingEffect({name:"handleLineActions"}),Z()},F=()=>{pe("dispose"),i&&(i=!1,o+=1,n?.clearPendingEffects?.(),a=0,l=!1,c=[],p=null,m=null,d=new Map,f=new Map,y=new Map,b=!1,A.clear(),B?.())},oe=()=>s,he=()=>n.selectPresentationState(),Pe=()=>n.selectPresentationChanges(),ge=I=>n.selectSectionLineChanges(I),ce=(I={})=>{G("rendering"),t+=1;let v=Date.now();ye(v);let S=f.size>0,O=Q(d,v),T=S?Q(f,v):new Map,Y={...n.selectRenderState({activePersistentAnimations:se(O),restoredPersistentAnimations:se(T)}),id:`render-${r}-${o}-${t}`};return y.set(Y.id,{builtAt:v,persistentAnimationSessions:new Map([...T.entries(),...O.entries()]),usedRestoredPersistentAnimationSessions:S}),Y},Sr=(I={})=>ce(I),ur=(I={})=>ce(I),nn=I=>{if(!i||!n)return;let v=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=v?y.get(v):null;v&&y.delete(v);let O=new Map;Fl(I?.animations).forEach(T=>{let z=Dn(T);if(!z)return;let Y=S?.persistentAnimationSessions?.get(z)??d.get(z),te=Math.max(0,zl(T)),ue=Y?.startedAt??S?.builtAt??Date.now();O.set(z,{animation:structuredClone(T),startedAt:ue,expiresAt:ue+te})}),d=O,S?.usedRestoredPersistentAnimationSessions&&(f=new Map)},Id=()=>n.selectSystemState(),wd=()=>n.selectAchievements(),kd=I=>n.selectAchievement(I),ta=()=>n.selectSaveSlotMap(),vd=I=>n.selectSaveSlot(I),Ad=I=>n.selectSaveSlotPage(I),Pd=()=>n.selectImageGallery(),xd=()=>n.selectMusicRoom(),Ed=()=>n.selectSceneReplay(),Sd=()=>n.selectIsSceneReplayActive(),ok=()=>n.selectSkipMode(),ik=()=>n.selectAutoMode(),Rd=()=>n.selectRuntime(),Od=()=>n.selectIsChoiceVisible(),Cd=()=>n.selectIsFormVisible(),$d=()=>n.selectActiveInteraction(),_d=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),na=(I,v,S={})=>!Le(v)||I!=="nextLine"?v:S.bypassChoice===!0?{...v,bypassChoice:!0}:S.interactionSource===Qi?{...v,_interactionSource:Qi}:v,sa=(I={})=>({type:Zi,payload:na("nextLine",{_conditionalContinuation:!0},I)}),Us=(I,v)=>tn(I)?{type:Zi,payload:{...I.payload,...v.payload}}:v,Td=I=>{I.savedCheckpointOccurrences.forEach(v=>{n.markSavedRollbackCheckpointTransient(v)}),I.savedCheckpointOccurrences=[]},Nd=(I,v)=>{let S=p;return p=null,!S||!Yr(S.pointer,I)||S.checkpointIndex!==v?.checkpointIndex||S.checkpointIdentity!==v?.checkpoint?[]:S.savedCheckpointOccurrences},jd=I=>{let v=m;return!v||!Yr(v.pointer,I)?null:(m=null,v)},Dd=({actionType:I,pointerBeforeAction:v,pointerAfterAction:S,cursorBeforeAction:O,cursorAfterAction:T,wasSceneReplayActive:z,isSceneReplayActive:Y})=>{!S||!(!Yr(v,S)||O?.checkpoint!==T?.checkpoint||O?.checkpointIndex!==T?.checkpointIndex||I==="jumpToLine")||(m={pointer:S,appendToPrevious:M0.has(I)&&z===Y&&v?.sectionId===S.sectionId&&v?.lineId!==S.lineId,reuseExistingOccurrence:V0.has(I),forceNewOccurrence:I==="jumpToLine"})},oa=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),Td(I))},Ld=(I,v,S)=>D0.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==v?.checkpoint:S?.checkpoint!==v?.checkpoint&&S?.checkpointIndex>v?.checkpointIndex:!1,Md=I=>{let v=c.at(-1);if(!v?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&v.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:v.rollbackCursor?.checkpointIndex,sectionId:v.pointer?.sectionId,lineId:v.pointer?.lineId})},Vd=()=>{c.at(-1)?.savedCheckpointOccurrences.forEach(v=>{let S=n.selectSaveSlot({slotId:v.slotId});S&&(v.saveSlotIdentity=S)})},qd=()=>{let I=c.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},Fd=(I,v,S)=>{let O=c.at(-1);if(!O)return;let T=n.selectCurrentPointer()?.pointer,z=Ld(I,v,S);if(Yr(O.pointer,T)){let Y=S?.checkpoint!==v?.checkpoint||S?.checkpointIndex!==v?.checkpointIndex;z||Y&&L0.has(I)?(oa(O),O.pointer=T,O.rollbackCursor=S,O.markCurrentCheckpointTransient=z,O.savedCheckpointOccurrences=[]):Y&&I==="updateProjectData"&&(O.rollbackCursor=S);return}oa(O),O.pointer=T,O.rollbackCursor=n.selectRollbackCursor?.()??null,O.markCurrentCheckpointTransient=z,O.savedCheckpointOccurrences=[]},mt=(I,v)=>{if(G(`action "${I}"`),!n[I])return;let S=v,O,T;if(I==="updateProjectData")ia(v),O=structuredClone(v.projectData),S={...v,projectData:qs({projectData:O,l10nData:h,l10nId:w})},ia(S);else if(I==="updateLocalizationPackage"){if(T=Ud(v),T===w)return;S={l10nId:T,projectData:qs({projectData:g,l10nData:h,l10nId:T})}}j0.has(I)&&(u+=1);let z=n.selectAutoMode(),Y=z?n.selectRuntime():null,te=n.selectIsSceneReplayActive?.()===!0,ue=N0.has(I)?Q(d):null,Oe=n.selectCurrentPointer()?.pointer??null,xe=n.selectRollbackCursor?.()??null,Rr=!1,Gr;try{Gr=n[I](S),Rr=!0}catch(yt){throw ae(yt,"preCommit"),yt}O!==void 0&&(g=O),T!==void 0&&(w=T),T0.has(I)&&(f=ue??new Map,d=new Map);let on=n.selectIsSceneReplayActive?.()===!0;te!==on&&(d=new Map,f=new Map);let Ys=n.selectCurrentPointer()?.pointer??null,Hr=n.selectRollbackCursor?.()??null;I==="saveSlot"?Md(v):I==="updateProjectData"&&Vd(),Fd(I,xe,Hr),Dd({actionType:I,pointerBeforeAction:Oe,pointerAfterAction:Ys,cursorBeforeAction:xe,cursorAfterAction:Hr,wasSceneReplayActive:te,isSceneReplayActive:on});let tf=n.selectAutoMode()&&(I==="updateVariable"||z&&G0(Y,n.selectRuntime()));(z0.has(I)||tf)&&(b=!0);try{Z()}catch(yt){throw Rr&&ae(yt,"postCommitUnsettled"),yt}return Gr},ia=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");jr(I?.projectData?.resources?.variables??{}),vt(I.projectData),At(I.projectData),Pt(I.projectData)},Ud=I=>{if(!Le(I))throw new Error("updateLocalizationPackage requires an object payload");let v=Object.keys(I);if(v.length!==1||v[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},Bd=(I,v,S)=>{let O=n.selectCurrentPointer()?.pointer;v!==O||S!==u||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),mt("nextLineFromSystem",I.payload))},zd=()=>({renderSequence:t,conditionalRoutingSequence:u,rollbackNavigationContexts:c.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(y),canonicalProjectData:g,localizationPackageId:w,playbackScheduleDirty:b}),Yd=I=>{t=I.renderSequence,u=I.conditionalRoutingSequence,c=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,m=I.pendingDialogueHistoryLineEntry,d=new Map(I.persistentAnimationSessions),f=new Map(I.restoredPersistentAnimationSessions),y=new Map(I.renderPersistentAnimationMetadata),g=I.canonicalProjectData,w=I.localizationPackageId,b=I.playbackScheduleDirty},aa=(I,v={})=>(G("action batch"),C(()=>{let S=zd();try{return n[bo](()=>{let O,T=n.selectCurrentPointer()?.pointer??null,z=n.selectRollbackCursor?.()??null,Y=u,te={pointer:T,rollbackCursor:z,markCurrentCheckpointTransient:v.rollbackSource==="line",savedCheckpointOccurrences:v.savedCheckpointOccurrences?.slice()??[]};c.push(te);try{n.beginRollbackActionBatch({source:v.rollbackSource});try{O=I()}finally{n.endRollbackActionBatch({})}tn(O)&&Bd(O,T,Y);let ue=n.selectCurrentPointer()?.pointer??null;v.rollbackSource==="line"&&Yr(T,ue)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:te.savedCheckpointOccurrences,appendToPrevious:v.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:v.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:v.dialogueHistoryForceNewOccurrence===!0})}finally{c.pop(),(!Yr(T,te.pointer)||z?.checkpoint!==te.rollbackCursor?.checkpoint)&&te.markCurrentCheckpointTransient&&te.savedCheckpointOccurrences.length>0&&(p={pointer:te.pointer,checkpointIndex:te.rollbackCursor?.checkpointIndex,checkpointIdentity:te.rollbackCursor?.checkpoint,savedCheckpointOccurrences:te.savedCheckpointOccurrences})}})}catch(O){throw Yd(S),O}})),Bs=(I,v,S,O={})=>{if(I===Ji||I===rn)return aa(()=>{let T={...O,executionContext:O.executionContext??{depth:0,pendingNavigation:null},actionPath:O.actionPath??[I],randomOutcomeOrdinals:O.randomOutcomeOrdinals??new Map};if(I===rn)return ua(v,S,T);let z=zs(S),Y=Rt({[I]:v},z);return ca(Y[I],S,T)},O);mt(I,v)},Gd=(I,v)=>{if(I!=="nextLineFromSystem")return Bs(I,v);k+=1;try{return Bs(I,v)}finally{k=Math.max(0,k-1)}},la=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},zs=I=>{if(la(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:v,...S}=I,O=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:v,variables:O,runtime:n.selectRuntime?n.selectRuntime():{}}},Hd=I=>{if(!Le(I))return{templatePayload:I,literalTargetIds:null};let v=n.selectImageGalleryConfig();if(!Array.isArray(v?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?v.groups.find(T=>T.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let O=typeof I.variantId=="string"&&S.variants.some(T=>T.id===I.variantId);return{templatePayload:{...I,groupId:null,...O?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...O?{variantId:I.variantId}:{}}}},Xd=I=>!Le(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(O=>O.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Wd=I=>!Le(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(O=>O.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},Kd=I=>{if(!Le(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},Jd=(I,v,S)=>{if(!Le(I))throw new Error(`conditional branch at index ${v} must be an object`);if(!Le(I.actions))throw new Error(`conditional branch at index ${v} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&v!==S-1)throw new Error("conditional else branch must be the last branch")},ca=(I,v,S)=>{Kd(I);let O=sa(S);for(let T=0;T<I.branches.length;T+=1){let z=I.branches[T];Jd(z,T,I.branches.length);let Y=zs(v);if(Object.prototype.hasOwnProperty.call(z,"when")&&!kt(z.when,Y))continue;let ue=sn(z.actions,v,{...S,actionPath:[...S.actionPath??[Ji],"branches",String(T),"actions"]});return tn(ue)?Us(O,ue):O}return O},Qd=I=>{if(!Le(I))throw new Error("random action payload must be an object");let v=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(v!==void 0)throw new Error(`random action.${v} is not supported`);if(!Le(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=g?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||Se(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},ua=(I,v,S)=>{Qd(I),la(v);let O=ll(I.distribution,{randomSource:R});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let Y=(S.actionPath??[rn]).join("."),te=S.randomOutcomeOrdinals??new Map,ue=te.get(Y)??0;te.set(Y,ue+1),n.recordRandomOutcome({path:Y,ordinal:ue,type:O.type,result:O}),qd()}let T;O.type==="integer"?mt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:O.value}]}):T=sn(I.distribution.outcomes[O.outcomeIndex].actions,v,{...S,actionPath:[...S.actionPath??[rn],"distribution","outcomes",String(O.outcomeIndex),"actions"]});let z=sa(S);return tn(T)?Us(z,T):z},Zd=(I,v)=>({...I??{},_form:v}),ef=(I,v,S,O)=>{let T=mt(I,v),z=T?.submitted===!0&&T.valid===!0,Y=T?.cancelled===!0;if(!(!z&&!Y)&&Le(v.actions))return sn(v.actions,Zd(S,T.form),{...O,interactionSource:Qi})},pa=(I,v,S,O)=>{if(I===rn)return ua(v,S,O);let T=zs(S),z={templatePayload:v,literalTargetIds:null};I===F0?z=Hd(v):I===U0?z=Xd(v):I===B0&&(z=Wd(v));let{templatePayload:Y,literalTargetIds:te}=z,Oe=Rt({[I]:Y},T)[I],xe=te?{...Oe,...te}:Oe;if(I===Ji)return ca(xe,S,O);let Rr=na(I,xe,O);if(q0.has(I))return ef(I,Rr,S,O);mt(I,Rr)},sn=(I,v,S)=>{let O,T=S?.executionContext??{depth:0,pendingNavigation:null},z=Cn(I);$n(z),T.depth+=1;try{for(let[Y,te]of z){let ue={...S,executionContext:T,actionPath:[...S?.actionPath??[],Y]};if(Po(Y)){let xe=T.pendingNavigation;if(xe)throw new Error(`action batch cannot execute multiple navigation actions: ${xe.actionType}, ${Y}`);T.pendingNavigation={actionType:Y,payload:te,eventContext:v,options:ue};continue}let Oe=pa(Y,te,v,ue);tn(Oe)&&(O=Us(O,Oe))}}finally{T.depth-=1}if(T.depth===0&&T.pendingNavigation){let Y=T.pendingNavigation;T.pendingNavigation=null,pa(Y.actionType,Y.payload,Y.eventContext,Y.options)}return O},da=(I,v,S={})=>{let O={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return aa(()=>sn(I,v,O),O)},rf=I=>{let v=n.selectCurrentPointer()?.pointer;if(I!==v||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:_,dispose:F,handleAction:Bs,handleInternalAction:Gd,handleActions:da,selectRenderState:Sr,prepareRenderState:ur,commitRenderState:nn,selectPresentationState:he,selectPresentationChanges:Pe,selectSectionLineChanges:ge,selectSystemState:Id,selectAchievements:wd,selectAchievement:kd,selectSaveSlotMap:ta,selectSaveSlot:vd,selectSaveSlotPage:Ad,selectSaveSlots:ta,selectImageGallery:Pd,selectMusicRoom:xd,selectSceneReplay:Ed,selectIsSceneReplayActive:Sd,selectRuntime:Rd,selectIsChoiceVisible:Od,selectIsFormVisible:Cd,selectActiveInteraction:$d,selectHasPendingRenderWork:_d,handleLineActions:I=>{G("line action handling");let v=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!Yr(I.pointer,v))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return C(()=>{let S=n.selectCurrentPointer()?.pointer,O=n.selectRollbackCursor?.()??null,T=p,z=m,Y=Nd(S,O),te=jd(S),ue=n.selectCurrentLine(),Oe=!1;if(ue?.actions){try{da(ue.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:Y,dialogueHistoryAppendToPrevious:te?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:te?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:te?.forceNewOccurrence===!0})}catch(xe){throw p=T,m=z,xe}Oe=!0}return rf(S),Oe})},getNamespace:oe,classifyAutomaticAttemptError:D}}var H0="music-room:player",gd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),yd=(e,r)=>gd.has(e)&&r?._event?.id===H0,bd=({engine:e,routeGraphics:r,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:i},t)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(t)??e.selectRenderState(t);n?.(s),r.render(s),i(o)&&e.commitRenderState?.(s)},X0=({engine:e,routeGraphics:r,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:i,isCurrentLifecycle:t},s)=>{let a=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===a&&bd({engine:e,routeGraphics:r,trackRenderDispatch:n,lifecycleGeneration:i,isCurrentLifecycle:t},s)},W0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveSlots(r?.saveSlots))},K0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalDeviceVariables(r?.globalDeviceVariables))},J0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalAccountVariables(r?.globalAccountVariables))},Q0=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalRuntime(r?.globalRuntime))},Z0=({enqueuePersistenceWrite:e},r)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(r?.updates)})},hd={render:bd,saveSlots:W0,saveGlobalDeviceVariables:K0,saveGlobalAccountVariables:J0,saveGlobalRuntime:Q0,applyScopedDataUpdates:Z0,handleLineActions:X0},ek=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),ra=(e,r,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(r,n)},rk=(e=[])=>{let r=new Set,n=[];for(let o=e.length-1;o>=0;o-=1){let i=e[o];if(typeof i?.name!="string"||i.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!ek.has(i.name)){n.unshift(i);continue}r.has(i.name)||(r.add(i.name),n.unshift(i))}return n},tk=({getEngine:e,routeGraphics:r,ticker:n,handleUnhandledEffect:o,handlePersistenceError:i,indexedDB:t,persistence:s,namespace:a})=>{let l=new Map,u=Promise.resolve(),c=null,p=null,m=!1,d=0,f=0,y=!0,g=md({ticker:n,dispatchAutomaticAttempt:()=>ra(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),h=()=>{c=null,p=null,m=!1,d=0},w=()=>{g.reset(),f+=1,h(),y=!0},b=()=>{f+=1,y=!1,h(),g.dispose()},E=C=>y&&C===f,k=C=>{if(i){i(C);return}console.error("RouteEngine persistence write failed.",C)},A=C=>{if(s)return s;let _=pt(C),F=l.get(_);if(F)return F;let oe=Bi({indexedDB:t,namespace:_});return l.set(_,oe),oe},R=C=>{let _=s?null:pt(a??e()?.getNamespace?.()),F;u=u.catch(()=>{}).then(()=>(F=A(_),C(F))).catch(oe=>{!s&&l.get(_)===F&&l.delete(_),k(oe)})},$=C=>{if(!y)return;let _=typeof C?.id=="string"&&C.id.length>0?C.id:null;d+=1,c=_,m=!1},j=()=>d,x=(C={})=>{if(!y||C?.aborted===!0)return!1;let _=typeof C?.id=="string"&&C.id.length>0?C.id:null;return _?_!==c||_===p?!1:(p=_,!0):c!==null||m?!1:(m=!0,!0)},M=(C,_={})=>{if(!y)return!1;if(yd(C,_)){let oe=gd.get(C),he=e();return ra(he,oe,_?._event),!0}if(C!=="renderComplete"||!x(_))return!1;let F=e();return ra(F,"markLineCompleted",{}),!0},B=new Set(["updateFormField","submitForm","cancelForm"]),pe=new Set(["updateVariable"]),G=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,ae=C=>C?._formKey??C?.formKey,D=(C,_)=>ae(C)===_?.formKey,ie=(C,_)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===_?.source,J=(C,_)=>ie(C,_)?_.source==="form"?D(C,_):!0:!1,q=(C,_)=>!C||typeof C!="object"||Array.isArray(C)||_?.source!=="form"?!1:D(C,_),K=(C={},_)=>Object.keys(C).length>0&&Object.entries(C).every(([F,oe])=>B.has(F)?q(oe,_):pe.has(F)),Q=(C={},_)=>{let F=C?.actions;return _?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:K(F,_):J(C,_)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(oe=>J(oe,_))},se=(C,_={})=>{if(!_?.actions)return!1;let F=G(C);return!F||F.source==="choice"?!1:!Q(_,F)},ye=({preprocessPayload:C,onEvent:_}={})=>async(F,oe={})=>{if(!y)return!1;if(yd(F,oe))return M(F,oe),_?.(F,oe);let he=e(),Pe=f,ge=d;if(se(he,oe))return _?.(F,oe);let ce=await C?.(F,oe)??oe;if(!E(Pe)||e()!==he||d!==ge)return!1;if(se(he,ce))return _?.(F,ce);if(M(F,ce),ce?.actions){let Sr=ce?._event?{_event:ce._event}:ce?.event?{_event:ce.event}:void 0,ur;ce?.bypassChoice===!0?ur={bypassChoice:!0}:ce?._interactionSource&&(ur={interactionSource:ce._interactionSource}),ur?he.handleActions(ce.actions,Sr,ur):he.handleActions(ce.actions,Sr)}return _?.(F,ce)},Z=C=>{if(!y)return;let _=f,F=e(),oe=rk(C),he=oe.some(ge=>ge.name==="handleLineActions");oe.forEach(ge=>{if(!hd[ge.name]&&!en.has(ge.name)&&!o)throw new Error(`Unhandled pending effect "${ge.name}".`)});let Pe={engine:F,routeGraphics:r,ticker:n,trackRenderDispatch:$,getRenderDispatchCount:j,enqueuePersistenceWrite:R,lifecycleGeneration:f,isCurrentLifecycle:E};for(let ge of oe){if(!E(_))break;if(he&&ge.name==="render")continue;if(en.has(ge.name)){g.handleLegacyEffect(ge);continue}let ce=hd[ge.name];if(ce){ce(Pe,ge.payload);continue}o(ge,Pe)}};return Z.handleRouteGraphicsEvent=M,Z.createRouteGraphicsEventHandler=ye,Z.reset=w,Z.dispose=b,Z.reconcilePlaybackScheduleV1=C=>g.reconcilePlaybackScheduleV1(C),Z},nk=tk;var sk=(e,r={})=>{let{resources:n={}}=r;return Jo(e,n)};var Zv=ea;export{Oo as DEFAULT_VISUAL_LAYER,et as RENDER_LAYER,er as VISUAL_LAYER,nk as createEffectsHandler,jw as createIndexedDbPersistence,Zv as default,wo as formatDate,Rm as resolveComputedVariables,sk as resolveLayoutReferences};