route-engine-js 1.46.3 → 1.46.5

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,8 +1,8 @@
1
- var zm=Object.defineProperty;var Xm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Hm=(e,t)=>{for(var n in t)zm(e,n,{get:t[n],enumerable:!0})};var Pf=Xm(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});function Af(e){let t=e.length,n=0,o=0,a;for(;o<t;)n++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<t&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return n}Xa.default=Af;Af.code='require("ajv/dist/runtime/ucs2length").default'});var El=Symbol.for("immer-nothing"),Il=Symbol.for("immer-draftable"),De=Symbol.for("immer-state");function ze(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var mt=Object.getPrototypeOf;function ge(e){return!!e&&!!e[De]}function Hr(e){return e?xl(e)||Array.isArray(e)||!!e[Il]||!!e.constructor?.[Il]||Ln(e)||Mn(e):!1}var Gm=Object.prototype.constructor.toString();function xl(e){if(!e||typeof e!="object")return!1;let t=mt(e);if(t===null)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Gm}function Tn(e){return ge(e)||ze(15,e),e[De].base_}function _n(e,t){Dn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function Dn(e){let t=e[De];return t?t.type_:Array.isArray(e)?1:Ln(e)?2:Mn(e)?3:0}function Fi(e,t){return Dn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Sl(e,t,n){let o=Dn(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function Km(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ln(e){return e instanceof Map}function Mn(e){return e instanceof Set}function Xr(e){return e.copy_||e.base_}function Bi(e,t){if(Ln(e))return new Map(e);if(Mn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=xl(e);if(t===!0||t==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[De];let a=Reflect.ownKeys(o);for(let r=0;r<a.length;r++){let s=a[r],i=o[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(mt(e),o)}else{let o=mt(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Hi(e,t=!1){return Vn(e)||ge(e)||!Hr(e)||(Dn(e)>1&&(e.set=e.add=e.clear=e.delete=Wm),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Hi(o,!0))),e}function Wm(){ze(2)}function Vn(e){return Object.isFrozen(e)}var Jm={};function Gr(e){let t=Jm[e];return t||ze(0,e),t}var Mt;function Ol(){return Mt}function Qm(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function vl(e,t){t&&(Gr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ui(e){Yi(e),e.drafts_.forEach(Zm),e.drafts_=null}function Yi(e){e===Mt&&(Mt=e.parent_)}function kl(e){return Mt=Qm(Mt,e)}function Zm(e){let t=e[De];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Al(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[De].modified_&&(Ui(t),ze(4)),Hr(e)&&(e=Nn(t,e),t.parent_||jn(t,e)),t.patches_&&Gr("Patches").generateReplacementPatches_(n[De].base_,e,t.patches_,t.inversePatches_)):e=Nn(t,n,[]),Ui(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==El?e:void 0}function Nn(e,t,n){if(Vn(t))return t;let o=t[De];if(!o)return _n(t,(a,r)=>Pl(e,o,t,a,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return jn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,r=a,s=!1;o.type_===3&&(r=new Set(a),a.clear(),s=!0),_n(r,(i,l)=>Pl(e,o,a,i,l,n,s)),jn(e,a,!1),n&&e.patches_&&Gr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Pl(e,t,n,o,a,r,s){if(ge(a)){let i=r&&t&&t.type_!==3&&!Fi(t.assigned_,o)?r.concat(o):void 0,l=Nn(e,a,i);if(Sl(n,o,l),ge(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Hr(a)&&!Vn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Nn(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&jn(e,a)}}function jn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Hi(t,n)}function ey(e,t){let n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Ol(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=Gi;n&&(a=[o],r=Vt);let{revoke:s,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=s,i}var Gi={get(e,t){if(t===De)return e;let n=Xr(e);if(!Fi(n,t))return ry(e,n,t);let o=n[t];return e.finalized_||!Hr(o)?o:o===Vi(e.base_,t)?(qi(e),e.copy_[t]=Xi(o,e)):o},has(e,t){return t in Xr(e)},ownKeys(e){return Reflect.ownKeys(Xr(e))},set(e,t,n){let o=Rl(Xr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=Vi(Xr(e),t),r=a?.[De];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Km(n,a)&&(n!==void 0||Fi(e.base_,t)))return!0;qi(e),zi(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Vi(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,qi(e),zi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Xr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){ze(11)},getPrototypeOf(e){return mt(e.base_)},setPrototypeOf(){ze(12)}},Vt={};_n(Gi,(e,t)=>{Vt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Vt.deleteProperty=function(e,t){return Vt.set.call(this,e,t,void 0)};Vt.set=function(e,t,n){return Gi.set.call(this,e[0],t,n,e[0])};function Vi(e,t){let n=e[De];return(n?Xr(n):e)[t]}function ry(e,t,n){let o=Rl(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Rl(e,t){if(!(t in e))return;let n=mt(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=mt(n)}}function zi(e){e.modified_||(e.modified_=!0,e.parent_&&zi(e.parent_))}function qi(e){e.copy_||(e.copy_=Bi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ty=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){let r=n;n=t;let s=this;return function(l=r,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&ze(6),o!==void 0&&typeof o!="function"&&ze(7);let a;if(Hr(t)){let r=kl(this),s=Xi(t,void 0),i=!0;try{a=n(s),i=!1}finally{i?Ui(r):Yi(r)}return vl(r,o),Al(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===El&&(a=void 0),this.autoFreeze_&&Hi(a,!0),o){let r=[],s=[];Gr("Patches").generateReplacementPatches_(t,a,r,s),o(r,s)}return a}else ze(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,l=>t(l,...i));let o,a;return[this.produce(t,n,(s,i)=>{o=s,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Hr(e)||ze(8),ge(e)&&(e=Xe(e));let t=kl(this),n=Xi(e,void 0);return n[De].isManual_=!0,Yi(t),n}finishDraft(e,t){let n=e&&e[De];(!n||!n.isManual_)&&ze(9);let{scope_:o}=n;return vl(o,t),Al(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));let o=Gr("Patches").applyPatches_;return ge(e)?o(e,t):this.produce(e,a=>o(a,t))}};function Xi(e,t){let n=Ln(e)?Gr("MapSet").proxyMap_(e,t):Mn(e)?Gr("MapSet").proxySet_(e,t):ey(e,t);return(t?t.scope_:Ol()).drafts_.push(n),n}function Xe(e){return ge(e)||ze(10,e),Cl(e)}function Cl(e){if(!Hr(e)||Vn(e))return e;let t=e[De],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Bi(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Bi(e,!0);return _n(n,(o,a)=>{Sl(n,o,Cl(a))}),t&&(t.finalized_=!1),n}var Ve=new ty,qn=Ve.produce,yA=Ve.produceWithPatches.bind(Ve),hA=Ve.setAutoFreeze.bind(Ve),gA=Ve.setUseStrictShallowCopy.bind(Ve),bA=Ve.applyPatches.bind(Ve),wA=Ve.createDraft.bind(Ve),IA=Ve.finishDraft.bind(Ve);var x={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},yt={NOT:0};var D=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ne=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Ki=e=>{if(!e||e.trim()==="")throw new D("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new D(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let n of t)if(e.trim().endsWith(n))throw new D(`Incomplete comparison expression - missing right operand (got: '${e}')`)},$l=e=>{if(e.trim().endsWith(" in"))throw new D(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new D(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new D(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of o){if(!a)throw new D(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new D(`Invalid loop syntax (got: '$for ${e}')`)}};var _l=(e,t,n=!1)=>{if(t===null)return new Ne(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ne(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return n?new Ne(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ne(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Nl=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ne(`Unknown function '${e}' (${n})`)};var ny=(e,t,n={})=>{let o={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(o=n.functions||{},a=n.partials||{}):typeof n=="object"&&(o=n));let s=ne(e,{functions:o,partials:a},t,{});return s===void 0?{}:s},ne=(e,t,n,o)=>{let a=t.functions||t;if(e.var&&!e.type)return Ae(e.var,n,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return Ae(e.path,n,o);if(e.type===x.INTERPOLATION)return iy(e.parts,t,n,o);switch(e.type){case x.FUNCTION:return Tl(e,t,n,o);case x.BINARY:return Dl(e,t,n,o);case x.UNARY:return Ll(e,t,n,o);case x.CONDITIONAL:return ay(e,t,n,o);case x.LOOP:return fy(e,t,n,o);case x.OBJECT:return my(e,t,n,o);case x.ARRAY:return yy(e,t,n,o);case x.PARTIAL:return hy(e,t,n,o);case x.PATH_REFERENCE:return gy(e,t,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},jl=new Map,sy=e=>{let t=[],n="",o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")n&&(t.push({type:"property",value:n}),n=""),o=!0;else if(r==="]"){if(o&&n){let s=n.trim();if(/^\d+$/.test(s))t.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let i=s.slice(1,-1);t.push({type:"property",value:i})}else t.push({type:"property",value:s});n=""}o=!1}else n+=r}return n&&t.push({type:"property",value:n}),t},Ae=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let o=jl.get(e);if(!o){let r=[],s="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,s+=c):c==="]"?(i--,s+=c):c==="."&&i===0?s&&(r.push(s),s=""):s+=c}s&&r.push(s),o=[];for(let l of r){let c=sy(l.trim());o.push(...c)}jl.set(e,o)}let a=t;for(let r=0;r<o.length;r++){let s=o[r];if(s.type==="property"&&s.value in n){a=n[s.value];continue}if(a==null)return;(s.type==="property"||s.type==="index")&&(a=a[s.value])}return a},iy=(e,t,n,o)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=ne(r,t,n,o);a.push(s!=null?String(s):"")}return a.join("")},Tl=(e,t,n,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Nl(e.name,a);let s=e.args.map(i=>ne(i,t,n,o));return r(...s)},Or=(e,t,n,o)=>{if(e.var&&!e.type)return Ae(e.var,n,o);switch(e.type){case x.VARIABLE:return Ae(e.path,n,o);case x.LITERAL:return e.value;case x.BINARY:return Dl(e,t,n,o);case x.UNARY:return Ll(e,t,n,o);case x.FUNCTION:return Tl(e,t,n,o);default:return ne(e,t,n,o)}},Dl=(e,t,n,o)=>{if(e.op===ee.AND||e.op===ee.OR){let s=Or(e.left,t,n,o),i=Or(e.right,t,n,o);switch(e.op){case ee.AND:return s&&i;case ee.OR:return s||i}}let a=ne(e.left,t,n,o),r=ne(e.right,t,n,o);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ll=(e,t,n,o)=>{let a=e.op===yt.NOT?Or(e.operand,t,n,o):ne(e.operand,t,n,o);if(e.op===yt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},oy=(e,t,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(Ae(a.path,n,o)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.fast===!0&&!s.whenCondition&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=Ae(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let d=Ae(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=ne(m,t,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=ne(u,t,n,o)}return i}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.fast===!0&&!s.whenCondition&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=Ae(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let d=Ae(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=ne(m,t,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=ne(u,t,n,o)}return i}}}return null},ay=(e,t,n,o)=>{let a=oy(e,t,n,o);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let s=e.conditions[r];if(s===null||Or(s,t,n,o))return ne(e.bodies[r],t,n,o)}return Vl},ly=(e,t)=>{let n=e.body,o=e.itemVar;if(n.type===x.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===x.VARIABLE){let a=n.conditions[0].path,r=n.bodies[0];if(a.startsWith(o+".")){let s=a.substring(o.length+1);if(r.type===x.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let i=[];for(let l=0;l<t.length;l++){let c=t[l];if(c[s]){let u={};for(let p of r.properties){let m=p.key,d=p.value;if(d.type===x.LITERAL)u[m]=d.value;else if(d.type===x.VARIABLE){let f=d.path;if(f===o)u[m]=c;else if(f.startsWith(o+".")){let h=f.substring(o.length+1);u[m]=c[h]}else return null}else if(d.type===x.INTERPOLATION){let f=[],h=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===x.VARIABLE){let y=g.path;if(y===o)f.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),b=c[w];f.push(b!=null?String(b):"")}else{h=!1;break}}else{h=!1;break}if(!h)return null;u[m]=f.join("")}else return null}i.push(u)}}return i}}}return null},cy=(e,t)=>{let n=e.body,o=e.itemVar,a=ly(e,t);if(a!==null)return a;if(n.type===x.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let i of n.properties)if(i.parsedKey)return null;let r=[],s=!0;for(let i of n.properties){let l=i.key,c=i.value;if(c.type===x.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===x.VARIABLE){let u=c.path;if(u===o)r.push({key:l,type:"item"});else if(u.startsWith(o+".")){let p=u.substring(o.length+1);if(!p.includes(".")&&!p.includes("["))r.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(c.type===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===o)r.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let m=p.substring(o.length+1);if(!m.includes(".")&&!m.includes("["))r.push({key:l,type:"prop_string",prop:m});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let i=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}i[l]=u}return i}}return null},uy=(e,t,n,o,a)=>{let r=[],s=e.body;if(s.type===x.OBJECT&&s.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...o,[i]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let f=d.split("."),h=f[0];h in o.__paths__&&(d=o.__paths__[h],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[i]:`${d}[${c}]`,...l&&{[l]:c}};for(let f of s.properties){let h=f.parsedKey?ne(f.parsedKey,t,n,m):f.key,g=f.value;if(g.type===x.LITERAL)p[h]=g.value;else if(g.type===x.VARIABLE){let y=g.path;if(y===i)p[h]=u;else if(y===l)p[h]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[h]=u[w]:p[h]=Ae(y,n,{...o,[i]:u,...l&&{[l]:c}})}else p[h]=Ae(y,n,{...o,[i]:u,...l&&{[l]:c}})}else if(g.type===x.INTERPOLATION){let y=[];for(let w of g.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let b=w.path,A;if(b===i)A=u;else if(b===l)A=c;else if(b.startsWith(i+".")){let k=b.substring(i.length+1);!k.includes(".")&&!k.includes("[")?A=u[k]:A=Ae(b,n,{...o,[i]:u,...l&&{[l]:c}})}else A=Ae(b,n,{...o,[i]:u,...l&&{[l]:c}});y.push(A!=null?String(A):"")}else{let b={...o,[i]:u,...l&&{[l]:c}},A=ne(w,t,n,b);y.push(A!=null?String(A):"")}p[h]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[h]=ne(g,t,n,y)}}r.push(p)}return r}return null},py=(e,t,n)=>{let o=e.body;if(o.type===x.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let r=o.properties[0].value;if(r.type===x.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===x.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===x.OBJECT&&s.properties.length===2){let i=s.properties[0],l=s.properties[1];if(i.key==="id"&&i.value.type===x.VARIABLE&&i.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},fy=(e,t,n,o)=>{let a=ne(e.iterable,t,n,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===x.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===x.VARIABLE?d.path:d.type===x.FUNCTION?`${d.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw _l(p,a,u)}if(!e.indexVar){let c=py(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=cy(e,a);if(c!==null)return c}let r=uy(e,t,n,o,a);if(r!==null)return r;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let c=i.split("."),u=c[0];u in o.__paths__&&(i=o.__paths__[u],c.length>1&&(i+="."+c.slice(1).join(".")))}let l=!1;e.body.type===x.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===x.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...o,[e.itemVar]:a[c],[e.indexVar]:c}:{...o,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=o.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${i}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=ne(e.body,t,n,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];s.push(m===void 0?{}:m)}else s.push(p===void 0?{}:p)}return s},Ml=(e,t,n)=>e.type!==x.OBJECT||e.whenCondition||e.properties.length>t?!1:e.properties.every(({value:o})=>{switch(o.type){case x.LITERAL:case x.VARIABLE:return!0;case x.INTERPOLATION:return o.parts.every(a=>typeof a=="string"||a.type===x.VARIABLE);case x.OBJECT:return n&&Ml(o,5,!1);default:return!1}}),dy=(e,t,n,o)=>{if(e.whenCondition||e.properties.length!==1||!Ml(e.properties[0].value,10,!0))return null;let a=e.properties[0],r=a.parsedKey?ne(a.parsedKey,t,n,o):a.key,s=a.value,i={},l={};for(let c of s.properties){let u=c.parsedKey?ne(c.parsedKey,t,n,o):c.key,p=c.value;if(p.type===x.LITERAL)l[u]=p.value;else if(p.type===x.VARIABLE)l[u]=Ae(p.path,n,o);else if(p.type===x.INTERPOLATION){let m=[];for(let d of p.parts)if(typeof d=="string")m.push(d);else if(d.type===x.VARIABLE){let f=Ae(d.path,n,o);m.push(f!=null?String(f):"")}l[u]=m.join("")}else if(p.type===x.OBJECT){let m={};for(let d of p.properties){let f=d.parsedKey?ne(d.parsedKey,t,n,o):d.key,h=d.value;if(h.type===x.LITERAL)m[f]=h.value;else if(h.type===x.VARIABLE)m[f]=Ae(h.path,n,o);else if(h.type===x.INTERPOLATION){let g=[];for(let y of h.parts)if(typeof y=="string")g.push(y);else if(y.type===x.VARIABLE){let w=Ae(y.path,n,o);g.push(w!=null?String(w):"")}m[f]=g.join("")}}l[u]=m}}return i[r]=l,i},my=(e,t,n,o)=>{let a=t.functions||t;if(e.whenCondition&&!Or(e.whenCondition,a,n,o))return;let r=dy(e,t,n,o);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?ne(u.parsedKey,t,n,o):u.key,m=u.value;if(m.type===x.LITERAL)c[p]=m.value;else if(m.type===x.VARIABLE)c[p]=Ae(m.path,n,o);else if(m.type===x.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===x.VARIABLE){let h=Ae(f.path,n,o);d.push(h!=null?String(h):"")}else{let h=ne(f,t,n,o);d.push(h!=null?String(h):"")}c[p]=d.join("")}else c[p]=ne(m,t,n,o)}return c}let s={},i=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=ne(c.value,t,n,o);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return ne(c.value,t,n,o)}else{let u=c.parsedKey?ne(c.parsedKey,t,n,o):c.key,p=c.value;if(p&&p.type===x.OBJECT&&p.properties){let m=p.properties.find(d=>d.key.startsWith("$for "));if(m){let d=ne(m.value,t,n,o);d!==void 0&&(s[u]=d)}else{let d=ne(c.value,t,n,o);d!==void 0&&(s[u]=d)}}else{let m=ne(c.value,t,n,o);(m!==void 0||p?.type===x.VARIABLE||p?.type===x.FUNCTION)&&(s[u]=m)}}return s},Vl={},yy=(e,t,n,o)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let s=ne(r,t,n,o);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=ne(r,t,n,o);s!==Vl&&s!==void 0&&a.push(s)}return a},hy=(e,t,n,o)=>{let{name:a,data:r,whenCondition:s}=e,i=t.partials||{},l=t.functions||t;if(s&&!Or(s,l,n,o))return;if(!i[a])throw new Ne(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new Ne(`Circular partial reference detected: ${a}`);let u=i[a],p=n,m={...o,_partialStack:[...c,a]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(r){let d=ne(r,t,n,o);p={...p,...d}}return ne(u,t,p,m)},gy=(e,t,n,o)=>{let{path:a}=e,r=a.split("."),s=r[0],i=r.slice(1);if(!o||!(s in o))throw new Ne(`Path reference '#{${a}}' refers to '${s}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(s in o.__paths__))throw new Ne(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[s];if(typeof l=="number"){if(i.length>0)throw new Ne(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Wi=ny;var by=/\$\{([^}]*)\}/g,wy=/#\{([^}]*)\}/g,Fl=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,r=Iy(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},Iy=(e,t={})=>e.trim()?vy(e).map(o=>ky(o.trim(),t)):[],vy=e=>{let t=[],n="",o=0,a=!1,r="";for(let s=0;s<e.length;s++){let i=e[s],l=s>0?e[s-1]:"";!a&&(i==='"'||i==="'")?(a=!0,r=i,n+=i):a&&i===r&&l!=="\\"?(a=!1,r="",n+=i):!a&&i==="("?(o++,n+=i):!a&&i===")"?(o--,n+=i):!a&&i===","&&o===0?(t.push(n),n=""):n+=i}return n&&t.push(n),t},ky=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:x.LITERAL,value:parseFloat(e)};if(e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};let n=Fl(e,t);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,s=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Kr(o.substring(c),i);if(u===-1)break;let p=c+u;p>r&&(r=p,s={op:i,type:l}),c=p+i.length}}if(r!==-1)try{return Ee(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Bl=/^\w+\(.*\)$/,Ay=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Py=e=>{if(!(!e||e.trim()===""||Bl.test(e))&&Ay.test(e))throw e.includes("?")&&e.includes(":")?new D(`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 D(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new D(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},ql=e=>{let t=e.trim();if(Bl.test(t))throw new D(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new D(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new D(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new D(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new D(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},qt=(e,t={})=>{let n=e.trim();Py(n);let o=Fl(n,t);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let r of n)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:n}},Ji=(e,t={})=>{let n=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(n=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),n=n.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),n=n.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(by)],r=[...n.matchAll(wy)],s=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:x.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&o.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?qt(c[1],t):ql(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:n};throw p}}let i=[],l=0;for(let{match:c,type:u}of s){let[p,m]=c,d=c.index;if(d>l){let f=n.substring(l,d);for(let h=0;h<o.length;h++)f=f.replace(`__ESCAPED_${h}__`,o[h]);f&&i.push(f)}try{let f;u==="variable"?f=qt(m.trim(),t):f=ql(m.trim()),i.push(f)}catch(f){if(f.message==="Invalid array index syntax")i.push(p);else throw f}l=d+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);c&&i.push(c)}return{type:x.INTERPOLATION,parts:i}};var eo=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),zl=e=>Object.keys(e),Ce=e=>e.join("."),Rr=(e,t,n)=>{let o=zl(e).filter(a=>!t.has(a));if(o.length>0)throw new D(`Unexpected key '${o[0]}' in condition JSON at '${Ce(n)}'`)},Cr=(e,t)=>typeof e=="string"?Ji(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?xy(e,t):Sy(e,t):{type:x.LITERAL,value:e},Ey=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new D("$each value must be a non-empty string");let o=t.trim();if(o==="")throw new D("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new D("Empty $each body not allowed");if(n.$partial!==void 0)throw new D("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},xy=(e,t)=>{let n=[],o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(r.$each!==void 0)try{let l=Ey(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=Yl(c[0],l[c[0]],t,!0);n.push(u),o=!0;continue}}catch(l){throw l instanceof D?l:new D(l.message)}let i=Object.keys(r);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Yl(i[0],r[i[0]],t);n.push(l),o=!0;continue}}let s=Cr(r,t);n.push(s),(s.type===x.FUNCTION||s.type===x.CONDITIONAL||s.type===x.LOOP||s.type===x.PARTIAL||s.type===x.OBJECT&&!s.fast||s.type===x.ARRAY&&!s.fast)&&(o=!0)}return{type:x.ARRAY,items:n,fast:!o}},Sy=(e,t)=>{let n=[],o=!1,a=null,r=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new D("$partial value must be a string");if(e.$partial.trim()==="")throw new D("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let w of l)if(y===w||y.startsWith(w+" ")||y.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new D(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,d={},f=!1;for(let[y,w]of Object.entries(m)){let b=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(b=y.slice(1)),d[b]=w,f=!0}let h=null;if(f&&(h=Cr(d,t),h.type===x.OBJECT)){let y=!1;for(let w of h.properties)if(w.value.type===x.VARIABLE||w.value.type===x.INTERPOLATION||w.value.type===x.FUNCTION||w.value.type===x.CONDITIONAL||w.value.type===x.OBJECT&&!w.value.fast||w.value.type===x.ARRAY&&!w.value.fast){y=!0;break}y&&(h.fast=!1)}let g={type:x.PARTIAL,name:u,data:h};return p!==void 0&&(g.whenCondition=Ul(p,t)),g}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new D("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new D("Missing condition expression after '$when'");a=Ul(c,t),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new D("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<r.length;){let[l,c]=r[s];if(l==="$when"){s++;continue}if(l==="$each")throw new D("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=Oy(r,s,t);n.push({key:l,value:u.node}),o=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new D(`$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 D(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new D("Missing condition expression after '$if'");{let u=Cr(c,t);(u.type===x.FUNCTION||u.type===x.CONDITIONAL||u.type===x.PARTIAL||u.type===x.OBJECT&&!u.fast||u.type===x.ARRAY&&!u.fast)&&(o=!0);let p=Ji(l,t),m={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let i={type:x.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},Oy=(e,t,n={})=>{let o=[],a=[],r=t,[s,i]=e[r],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new D(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Ki(c);let u=Ee(c,n);for(o.push(u),a.push(Cr(i,n)),r++;r<e.length;){let[p,m]=e[r],d=!1,f;if(l?p.startsWith(`$elif#${l} `)?(f=p.substring(`$elif#${l} `.length),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,f=null):p.startsWith("$elif ")?(f=p.substring(6),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,f=null),d){if(f===null)o.push(null);else{Ki(f);let h=Ee(f,n);o.push(h)}if(a.push(Cr(m,n)),r++,f===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Qi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},Zi={all:ee.AND,any:ee.OR},Ry=new Set(["var","literal","call","not",...Object.keys(Qi),...Object.keys(Zi)]),Cy=(e,t,n)=>{if(!Array.isArray(e))throw new D(`Condition JSON operator '${t}' at '${Ce(n)}' requires an array`);if(e.length!==2)throw new D(`Condition JSON operator '${t}' at '${Ce(n)}' requires exactly 2 operands`);return e},$y=(e,t,n,o,a)=>{if(!Array.isArray(e))throw new D(`Condition JSON operator '${t}' at '${Ce(a)}' requires an array`);if(e.length===0)throw new D(`Condition JSON operator '${t}' at '${Ce(a)}' requires at least 1 condition`);return e.map((s,i)=>Le(s,o,[...a,i])).reduce((s,i)=>({type:x.BINARY,op:n,left:s,right:i}))},_y=(e,t,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],Rr(e,new Set(["call","args"]),n);else if(eo(e.call))o=e.call.name,a=e.call.args??[],Rr(e,new Set(["call"]),n),Rr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new D(`Condition JSON call at '${Ce(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new D(`Condition JSON call at '${Ce(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new D(`Invalid condition JSON function name '${o}' at '${Ce(n)}'`);if(!Array.isArray(a))throw new D(`Condition JSON call '${o}' at '${Ce(n)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,s)=>Le(r,t,[...n,"args",s]))}},Le=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new D(`Condition JSON array at '${Ce(n)}' must be wrapped in an operator or { literal: [...] }`);if(!eo(e))throw new D(`Invalid condition JSON value at '${Ce(n)}'`);let o=zl(e);if(o.length===0)throw new D(`Condition JSON object at '${Ce(n)}' must contain an operator`);let a=o.filter(s=>Ry.has(s));if(a.length===0)throw new D(`Unknown condition JSON operator '${o[0]}' at '${Ce(n)}'`);if(a.length>1)throw new D(`Condition JSON at '${Ce(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(Rr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new D(`Condition JSON var at '${Ce(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return Rr(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return _y(e,t,n);if(r==="not")return Rr(e,new Set(["not"]),n),{type:x.UNARY,op:yt.NOT,operand:Le(e.not,t,[...n,"not"])};if(r in Zi)return Rr(e,new Set([r]),n),$y(e[r],r,Zi[r],t,[...n,r]);if(r in Qi){Rr(e,new Set([r]),n);let s=Cy(e[r],r,[...n,r]);return{type:x.BINARY,op:Qi[r],left:Le(s[0],t,[...n,r,0]),right:Le(s[1],t,[...n,r,1])}}throw new D(`Unknown condition JSON operator '${r}' at '${Ce(n)}'`)},Ul=(e,t={})=>{if(e==null)throw new D("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new D("Empty condition expression after '$when'");return Ee(e,t)}return eo(e)||Array.isArray(e)?Le(e,t):{type:x.LITERAL,value:e}},Ee=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Ee(c,t)}let n=Kr(e,"||");if(n!==-1)return{type:x.BINARY,op:ee.OR,left:Ee(e.substring(0,n).trim(),t),right:Ee(e.substring(n+2).trim(),t)};let o=Kr(e,"&&");if(o!==-1)return{type:x.BINARY,op:ee.AND,left:Ee(e.substring(0,o).trim(),t),right:Ee(e.substring(o+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Kr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Ee(e.substring(0,p).trim(),t),right:Ee(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,i=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let m=Kr(e.substring(p),c);if(m===-1)break;let d=p+m;d>r&&(r=d,s={op:c,type:u}),p=d+c.length}}if(r!==-1&&s)return{type:x.BINARY,op:s.type,left:Ee(e.substring(0,r).trim(),t),right:Ee(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Kr(e,c)!==-1)throw new D(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:yt.NOT,operand:Ee(e.substring(1).trim(),t)}:Xl(e,t)},Kr=(e,t)=>{let n=0,o=0;for(;o<=e.length-t.length;){if(e[o]==="(")n++;else if(e[o]===")")n--;else if(n===0&&e.substring(o,o+t.length)===t)return o;o++}return-1},Ny=e=>{if(e=e.trim(),e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:x.LITERAL,value:""};if(e==="{}")return{type:x.LITERAL,value:{}};if(e==="[]")return{type:x.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:x.LITERAL,value:t}:{type:x.VARIABLE,path:e}},Xl=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return qt(n,t);let a=Ny(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return qt(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},jy=(e,t=!1)=>{let n=t?"$each":"$for";try{$l(e)}catch(o){if(o instanceof D&&t){let a=o.message.replace(/\$for/g,"$each");throw new D(a.replace("Parse Error: ",""))}throw o}},Yl=(e,t,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let g=o?"$each":"$for";throw new D(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=r[1],i=r[2].trim();jy(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new D(`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(y=>y.trim());if(g.length!==2)throw new D(`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 D(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new D(`Reserved variable name: ${m}`);let f=Xl(u,n),h=Cr(t,n);return{type:x.LOOP,itemVar:p,indexVar:m,iterable:f,body:h,flatten:s!=="nested"}};var Ty=(e,t={})=>{let{functions:n={}}=t;return Cr(e,n)},Fn=Ty;var Ft={};Hm(Ft,{now:()=>Dy});var Dy=()=>Date.now();var Ly=(e,t,n={})=>{let{functions:o={},partials:a={}}=n,r={...Ft,...o},s=Fn(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=Fn(c,{functions:r});return Wi(s,t,{functions:r,partials:i})},Wr=Ly;var My=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Vy=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,qy=(e,t)=>{if(My(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new D("Empty condition expression");return Ee(e,t)}return Le(e,t)},Fy=(e,t={},n={})=>{let o=Vy(n),a={...Ft,...o},r=qy(e,a);return!!Or(r,{functions:a,partials:{}},t,{})},ro=Fy;var uo=Symbol("runStoreTransaction"),io="__routeEngineConditionComparison",Bn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",$r=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Bn(e,t)&&e>t,gte:(e,t)=>Bn(e,t)&&e>=t,lt:(e,t)=>Bn(e,t)&&e<t,lte:(e,t)=>Bn(e,t)&&e<=t}),ec=Object.freeze(Object.fromEntries(Object.keys($r).map(e=>[e,`${io}${e}`]))),By=Object.freeze(Object.fromEntries(Object.entries(ec).map(([e,t])=>[t,$r[e]]))),Hl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Uy=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},Un=e=>{if(Array.isArray(e))return e.map(Un);if(e===null||typeof e!="object"||Hl(e,"literal")||Hl(e,"var"))return e;if(Uy(e)?.startsWith(io))throw new Error(`Condition function names beginning with "${io}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,r=ec[o];if(r)return{call:r,args:a.map(Un)}}return Object.fromEntries(n.map(([o,a])=>[o,Un(a)]))},Ut=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Le(e),ro(Un(e),t,{functions:By})},Yy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rc=(e,t,n={})=>{let o={},a={},{transformSelectorFirstArgument:r=h=>h,transformActionFirstArgument:s=h=>h,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},m=0,d=(h,g)=>!u||!c?h:qn(h,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[h,g]of Object.entries(t))h!=="createInitialState"&&(h.startsWith("select")?o[h]=(...y)=>g(r(p.state,p.transactionalMetadata),...y):a[h]=(...y)=>{let w,b=p,A=qn(p,k=>{let E=g(s(k.state,k.transactionalMetadata),...y);w=E!==void 0&&!ge(E)?E:void 0,u&&l&&l({actionName:h,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});return m===0&&(A=d(A,b)),p=A,w});let f=h=>{if(typeof h!="function")throw new Error("Store transaction requires a callback");let g=p,y=m===0;m+=1;let w;try{w=h()}catch(b){throw m-=1,p=g,b}if(m-=1,y)try{p=d(p,g)}catch(b){throw p=g,b}return w};return{...o,...a,[uo]:f}},Hn=(e,t)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return qn(o,r=>{a.forEach(s=>{t.forEach(i=>{i(r,s)})})})};var zy=(e,t)=>{if(e.default!==void 0)return e.default;let n=["number","boolean","string","object"];if(!n.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},Z=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),oo=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},Pe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Xy=new Set(["pageSize","groups"]),Hy=new Set(["id","variants"]),Gy=new Set(["id","imageId"]),Ky=new Set(["pageSize","tracks"]),Wy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),Jy=new Set(["pageSize","replays"]),Qy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Jr=(e,t,n)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},ht=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Yt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!Pe(t))throw new Error("resources.imageGallery must be an object");if(Jr(t,Xy,"resources.imageGallery"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[o,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${o}]`;if(!Pe(a))throw new Error(`${r} must be an object`);if(Jr(a,Hy,r),ht(a.id,`${r}.id`),n.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(n.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let s=new Set;for(let[i,l]of a.variants.entries()){let c=`${r}.variants[${i}]`;if(!Pe(l))throw new Error(`${c} must be an object`);if(Jr(l,Gy,c),ht(l.id,`${c}.id`),ht(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),!Z(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},zt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!Pe(t))throw new Error("resources.musicRoom must be an object");if(Jr(t,Ky,"resources.musicRoom"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[o,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${o}]`;if(!Pe(a))throw new Error(`${r} must be an object`);Jr(a,Wy,r);for(let l of["id","soundId","title"])ht(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&ht(a[l],`${r}.${l}`);if(n.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);n.add(a.id);let s=e?.resources?.sounds?.[a.soundId];if(!Z(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Pe(s))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(s.playbackRate!==void 0&&(typeof s.playbackRate!="number"||!Number.isFinite(s.playbackRate)||s.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let 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&&!Z(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Zy=(e,t,n)=>{let o=Array.isArray(n)?"array":typeof n;switch(t.type){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},Xt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!Pe(t))throw new Error("resources.sceneReplay must be an object");if(Jr(t,Jy,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},o=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!Pe(r))throw new Error(`${s} must be an object`);Jr(r,Qy,s);for(let u of["sceneId","title","thumbnailImageId"])ht(r[u],`${s}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!Z(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let i=n[r.sceneId];if(!i)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=i.initialSectionId,c=i.sections?.[l];if(!c)throw new Error(`Scene replay scene "${r.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${r.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(r.initialVariables!==void 0){if(!Pe(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let m=e?.resources?.variables?.[u];if(!m)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if($e(m))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);Zy(u,m,p)}}}},tc=e=>{let t=ge(e)?Xe(e):e;return structuredClone(t)},eh=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!Z(t,"nameVariableId"))return;let o=t.nameVariableId,a=n?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Gn=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0;if(t?.name!==void 0)return t.name;if(n!==void 0)return n;let s=eh({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},$e=e=>Z(e,"computed"),po=(e,t)=>{switch(e?.type){case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);default:return!1}},Ht=(e={},t={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?o:!$e(s)&&(!n||n.includes(s.scope))&&po(s,r)})),Ge=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),rh=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ge(t,n)}let a="";for(let r=1;r<e.length-1;r+=1){let s=e[r];if(s!=="\\"){if(s.charCodeAt(0)<32)throw Ge(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Ge(t,n);let i=e[r];if(i==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Ge(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
- `,r:"\r",t:" ",b:"\b",f:"\f"};if(!Z(l,i))throw Ge(t,n);a+=l[i]}return a},nc=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ge(e,t);let n=[],o=0,a=()=>{let s=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(s,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw Ge(e,t);n.push(i)},r=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let s=e[o];if(/\d/.test(s??"")){let u=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(u,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw Ge(e,t);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ge(e,t);let i=s,l=o;o+=1;let c=!1;for(;o<e.length;){let u=e[o];if(c)c=!1;else if(u==="\\")c=!0;else if(u===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw Ge(e,t);o+=1,n.push(rh(p,e,t));return}o+=1}if(c||o>=e.length)throw Ge(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Ge(e,t)}return n},to=(e,t)=>{let n=e;for(let o of t){if(n==null||!Z(n,o))return;n=n[o]}return n},sc=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=nc(e),[o,a,...r]=n;if(o==="variables"){if(!a)return t.variables;let s=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return to(s,r)}return o==="runtime"?to(t.runtime,n.slice(1)):to(t,n)},ic=(e,t,n)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&t.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},ao=(e,t)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(t.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},th=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},er=(e,t,n,o)=>(ic(e,t,o),t.map(a=>Xn(a,n))),He=(e,t,n,o)=>{let a=er(e,t,n,o);return a.forEach(r=>th(e,r)),a},nh=(e,t,n)=>{switch(e){case"var":return sc(t,n);case"add":{let[o,a]=He(e,t,n,2);return o+a}case"sub":{let[o,a]=He(e,t,n,2);return o-a}case"mul":{let[o,a]=He(e,t,n,2);return o*a}case"div":{let[o,a]=He(e,t,n,2);return o/a}case"mod":{let[o,a]=He(e,t,n,2);return o%a}case"neg":{let[o]=He(e,t,n,1);return-o}case"round":{let[o]=He(e,t,n,1);return Math.round(o)}case"floor":{let[o]=He(e,t,n,1);return Math.floor(o)}case"ceil":{let[o]=He(e,t,n,1);return Math.ceil(o)}case"min":{let[o,a]=He(e,t,n,2);return Math.min(o,a)}case"max":{let[o,a]=He(e,t,n,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=He(e,t,n,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=er(e,t,n,2);return $r.eq(o,a)}case"neq":{let[o,a]=er(e,t,n,2);return $r.neq(o,a)}case"gt":{let[o,a]=er(e,t,n,2);return $r.gt(o,a)}case"gte":{let[o,a]=er(e,t,n,2);return $r.gte(o,a)}case"lt":{let[o,a]=er(e,t,n,2);return $r.lt(o,a)}case"lte":{let[o,a]=er(e,t,n,2);return $r.lte(o,a)}case"in":{let[o,a]=er(e,t,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return ao(e,t),t.every(o=>!!Xn(o,n));case"or":case"any":return ao(e,t),t.some(o=>!!Xn(o,n));case"not":{let[o]=er(e,t,n,1);return!o}case"length":{let[o]=er(e,t,n,1);return typeof o=="string"||Array.isArray(o)?o.length:Pe(o)?Object.keys(o).length:0}case"includes":{let[o,a]=er(e,t,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return tc(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Xn=(e,t={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let n=Object.entries(e);if(n.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=n;return nh(o,a,t)},lo=(e,t)=>{if(e===null||typeof e!="object"||Z(e,"literal"))return e;if(Z(e,"var"))return{literal:sc(e.var,t)};if(Z(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=>lo(a,t)):lo(o,t)]))},sh=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Le(e),Ut(lo(e,t))},oc=(e,t)=>{if(!Pe(e))throw new Error(`${t} must be an object`);let n=Z(e,"expr"),o=Z(e,"value");if(n===o)throw new Error(`${t} must contain exactly one of expr or value`)},no=(e,t,n)=>(oc(e,t),Z(e,"value")?tc(e.value):Xn(e.expr,n)),ih=(e,t={},n="unknown")=>{if(!Pe(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=Z(e,"expr"),a=Z(e,"value");if(Z(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(!Pe(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(!Pe(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!Z(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(sh(i.when,t))return no(i,`Computed variable "${n}" branch ${s}`,t)}return no(e.default,`Computed variable "${n}" default`,t)}if(o===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return no(e,`Computed variable "${n}"`,t)},ac=(e,t,n)=>{switch(t){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(n)?"array":typeof n}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(n)?"array":typeof n}`);return;case"string":if(typeof n!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(n)?"array":typeof n}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof n}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},oh=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}),ah=new Set(["and","or","all","any"]),lh=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),ch=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),uh=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),ph=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),lc=new WeakMap,Gl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Yn=(e,t,n)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},fh=(e,t,n,o)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${n}`)},cc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,i,...l]=nc(e,r);if(s!=="variables"&&s!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${r} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!Z(n,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=n[i];return $e(c)&&o.add(i),l.length===0?c?.type:void 0},uc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Gl(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let r=Object.entries(e);if(r.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,i]]=r;if(s==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return cc(i,{variableId:t,variableConfigs:n,dependencies:o,path:a})}if(s==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Gl(i)}let l=oh[s];if(l===void 0&&!ah.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?ao(s,i):ic(s,i,l);let c=i.map((u,p)=>uc(u,{variableId:t,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(ch.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),lh.has(s))return"number";if(uh.has(s))return"boolean"},dh=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Le(e)}catch(s){throw new Error(`Computed variable "${t}" ${a} is invalid: ${s.message}`,{cause:s})}let r=(s,i)=>{if(s===null||typeof s!="object"||Z(s,"literal"))return;if(Z(s,"var")){cc(s.var,{variableId:t,variableConfigs:n,dependencies:o,path:i});return}if(Z(s,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(Z(s,"not")){r(s.not,`${i}.not`);return}let l=Object.keys(s).find(c=>ph.has(c));s[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},so=(e,{variableId:t,variableConfig:n,variableConfigs:o,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(oc(e,`Computed variable "${t}" ${r}`),Yn(e,s,r),Z(e,"value")){ac(t,n.type,e.value);return}let i=uc(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});fh(t,n.type,i,`${r}.expr`)},mh=(e,t,n)=>{let o=t.computed;if(!Pe(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=Z(o,"expr"),s=Z(o,"value");if(Z(o,"branches")){if(Yn(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||s)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(o.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(o.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!Pe(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Pe(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Yn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!Z(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);dh(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),so(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),so(o.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Yn(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return so(o,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Qr=(e={})=>{if(!Pe(e))throw new Error("Variable configs must be an object");if(Z(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(Z(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if($e(s)){if(!Pe(s))throw new Error(`Computed variable "${r}" must be an object`);if(!Z(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!Z(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(Z(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Gt(s.scope,r),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${r}`);t.set(r,mh(r,s,e))}});let n=new Set,o=[];t.forEach((r,s)=>{if(n.has(s))return;let i=[{variableId:s,dependencies:[...t.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),n.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...i.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return lc.set(e,a),a},gt=({variables:e={},runtime:t={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=lc.get(n)??Qr(n),r=Ht(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>$e(g)).map(([g])=>g),i=Object.create(null),l=[],c=new Map(a.map((g,y)=>[g,y])),u=-1,p=!1,m=g=>{if(Z(i,g))return i[g];let y=n[g];if(!$e(y))return Z(r,g)?r[g]:void 0;let w=l.indexOf(g);if(w>=0){let b=[...l.slice(w),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=ih(y.computed,h,g);return ac(g,y.type,b),oo(i,g,b),b}finally{l.pop()}},d=g=>{if(Z(i,g))return i[g];let y=n[g];if(!$e(y))return Z(r,g)?r[g]:void 0;let w=c.get(g);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let b=u+1;b<=w;b+=1)m(a[b]),u=b}finally{p=!1}return i[g]}return m(g)},f=new Proxy({},{get:(g,y)=>{if(typeof y=="string")return d(y)},has:(g,y)=>typeof y=="string"&&(Z(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(g,y)=>{if(!(typeof y!="string"||!Z(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),h={variables:f,runtime:t,resolveVariable:d};return o?(s.forEach(g=>{d(g)}),{...r,...i}):f},yh=({variables:e={},runtime:t={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return Qr(a),gt({variables:e,runtime:t,variableConfigs:a,eager:!0})},Kn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if($e(a))return;let r=zy(a,o);a.scope==="context"?oo(t,o,r):oo(n,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},Gt=(e,t)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${n.join(", ")}`)},Kt=(e,t,n)=>{let o={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=o[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(o).flat().includes(t))throw new Error(`Unknown operation: ${t}`);if(!a.includes(t))throw new Error(`Operation "${t}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},hh=2,Kl=12,pc=(e=hh)=>{if(!Number.isInteger(e)||e<0||e>Kl)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Kl}.`);return e},gh=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},zn=e=>typeof e=="number"&&Number.isFinite(e),Wn=(e,t,n,o,a={})=>{if(e==="number"){if(t==="set"&&!zn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!zn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!zn(n))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(t==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);pc(a.roundTo)}}},Jn=(e,t,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!zn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=s=>{let i=a(s,void 0,"value");if(i===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return i};switch(t){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return gh(a(e,0,"current value")/r(n),pc(o.roundTo));case"increment":return a(e,0,"current value")+a(n,1,"value");case"decrement":return a(e,0,"current value")-a(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var fo=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),r={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:Yy[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(n.getHours()),mm:o(n.getMinutes()),ss:o(n.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>r[s])},bh=(e,t)=>{let n=r=>r?.ui,o=n(e),a=n(t);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:t}:a&&o?{changeType:"update",data:t}:null},Bt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,wh=(e,t)=>{let n=e?.character?.sprite,o=t?.character?.sprite,a=Bt(n)?n:void 0,r=Bt(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},Wl=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[n]!==void 0&&(t[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(t[n]=e[n]);return t},Jl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Ql=(e,t)=>t&&!e?{changeType:"add",data:t}:e&&!t?{changeType:"delete",data:e}:e&&t&&JSON.stringify(e)!==JSON.stringify(t)?{changeType:"update",data:t}:null,Ih=(e,t)=>{let n={},o=Ql(Wl(e),Wl(t)),a=Ql(Jl(e),Jl(t));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},mo=(e={},t={})=>{let n={},o=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)n[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(m=>m.applyMode==="persistent");!o.includes(l)&&(l!=="sfx"||p)&&(n[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},r=Ih(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=bh(e.dialogue,t.dialogue);s&&(n.dialogue=s);let i=wh(e.dialogue,t.dialogue);return i&&(n.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},yo=(e={})=>{let t=structuredClone(e);if(t.sfx){let a=Array.isArray(t.sfx.channels)?t.sfx.channels.filter(r=>r.applyMode==="persistent"):[];a.length>0?t.sfx={channels:a}:delete t.sfx}t.background&&(t.background.animations?.playback?.continuity!=="persistent"&&delete t.background.animations,!t.background.resourceId&&!t.background.colorId&&delete t.background);let n=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};n("layout"),n("choice"),n("form"),n("screen"),t.dialogue?.ui&&(delete t.dialogue.ui.animations,Object.keys(t.dialogue.ui).length===0&&delete t.dialogue.ui,Object.keys(t.dialogue).length===0&&delete t.dialogue),t.dialogue?.character?.sprite&&(delete t.dialogue.character.sprite.animations,Object.keys(t.dialogue.character.sprite).length===0&&delete t.dialogue.character.sprite,Object.keys(t.dialogue.character).length===0&&delete t.dialogue.character,Object.keys(t.dialogue).length===0&&delete t.dialogue);let o=(a,r)=>{let s=t[a]?.items;Array.isArray(s)&&(t[a].items=s.map(i=>{let l={...i};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return o("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),o("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),t},vh=(e,t)=>{if(!e||!t)return;let n=e;for(let o of t.split(".")){if(n==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),o))return;n=n[o]}return n},Zl=e=>e!==null&&typeof e=="object"?structuredClone(e):e,kh=(e,t,n)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(t??{},n)?t[n]:void 0;if(e===n){if(o==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return Zl(o)}if(!e.startsWith(`${n}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${n}".`);let a=e.slice(n.length+1),r=vh(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return Zl(r)},Ah={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"])},Ph=(e,t)=>{let n=e[e.length-1];return n?Ah[n]?.has(t)===!0:!1},co=(e,t,n=[])=>Array.isArray(e)?e.map(o=>co(o,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Ph(n,o)?a:co(a,t,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?kh(e,t,"_event"):Wr(e,t):e,Wt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return co(e,t)};var Eh=11102230246251565e-32,fc=128,dc=1e3,mc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Jt=(e,t,n)=>{let o=Object.keys(e).find(a=>!t.has(a));if(o!==void 0)throw new Error(`${n}.${o} is not supported`)},Qn=(e,t)=>{if(!mc(e))throw new Error(`${t} must be an object`)},Zn=(e,t,{min:n,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},xh=(e,t,{min:n,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},ho=e=>{let t=structuredClone(e),n=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(n),Object.freeze(o)),o);return n(t)},Sh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),yc=e=>{let t=e??Sh();if(!mc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=t.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},Oh=(e,t)=>{let n=4294967296-4294967296%t;for(let o=0;o<fc;o+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${fc} rejected samples`)},Rh=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},Ch=(e,t)=>{if(Jt(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=Zn(e.min,"random.distribution.min"),a=Zn(e.max,"random.distribution.max")-n+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return ho({type:"integer",value:a===1?n:n+Oh(t,a)})},$h=(e,t)=>{if(Jt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>dc)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let n=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(Qn(c,p),Jt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Qn(c.actions,`${p}.actions`),{weight:xh(c.weight,`${p}.weight`,{min:0})}}),o=Math.max(...n.map(({weight:c})=>c));if(o<=0)throw new Error("random weighted total weight must be positive");let a=n.map(c=>({...c,weight:c.weight/o})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(n[u].weight>0&&(c.weight===0||c.weight/r<=Eh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Rh(t)*r,i=0,l=a.findLastIndex(({weight:c})=>c>0);for(let c=0;c<a.length;c+=1){let u=a[c];if(i+=u.weight,s<i){l=c;break}}return ho({type:"weighted",outcomeIndex:l})},hc=(e,{randomSource:t})=>{Qn(e,"random.distribution");let o={integer:Ch,weighted:$h}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},es=(e,t)=>{if(Qn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Jt(e,new Set(["type","value"]),"random result"),Zn(e.value,"random result.value");else if(t==="weighted")Jt(e,new Set(["type","outcomeIndex"]),"random result"),Zn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:dc-1});else throw new Error(`unsupported recorded random result type: ${t}`);return ho(e)};var Zr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),wc=Object.freeze([Zr("cleanup",["clearPendingEffects","cleanAll"]),Zr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Zr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Zr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Zr("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),Zr("persistence",["saveSlot"]),Zr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),bt=new Map;wc.forEach(e=>{e.actions.forEach(t=>{if(bt.has(t))throw new Error(`duplicate action execution key: ${t}`);bt.set(t,bt.size)})});var _h=new Set(wc.find(({name:e})=>e==="navigation").actions),gc=bt.get("saveSlot")-.5,bc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",Nh=(e,t)=>e<t?-1:e>t?1:0,rs=e=>Object.entries(e).sort((t,n)=>{let o=bc(...t),a=bc(...n),r=bt.get(o),s=bt.get(a),i=r??gc,l=s??gc;return i!==l?i-l:r!==void 0&&s!==void 0?0:Nh(o,a)}),ts=e=>_h.has(e),ns=e=>{let t=e.map(([n])=>n).filter(ts);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var jh=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),ir=(...e)=>e.map(jh).join(":"),ss=e=>Array.isArray(e?.sounds)?e.sounds:e?.resourceId?[{id:e.resourceId,resourceId:e.resourceId,loop:e.loop??!0,volume:e.volume,startDelayMs:e.startDelayMs??0}]:[],go=e=>!Array.isArray(e?.sounds)&&e?.startDelayMs>0,Qt=(e,t)=>go(e)?ir("bgm","legacy-delay",t.resourceId):ir("bgm",t.id==="default"?t.resourceId:t.id),Ic=({bgm:e,resources:t,previousBgmRender:n})=>{let o=ss(e).filter(c=>t.sounds?.[c.resourceId]),a=ss(n?.bgm).filter(c=>n.resources?.sounds?.[c.resourceId]).map((c,u)=>({sound:c,renderId:n.channel?.children[u]?.id})).filter(({renderId:c})=>c!==void 0),r=new Map,s=new Set,i=(c,u)=>{!u||s.has(u.renderId)||(r.set(c.id,u.renderId),s.add(u.renderId))};return go(e)===go(n?.bgm)&&(o.forEach(c=>i(c,a.find(u=>u.sound.id===c.id))),o.forEach(c=>{r.has(c.id)||i(c,a.find(u=>u.sound.resourceId===c.resourceId&&Qt(n.bgm,u.sound)===Qt(e,c)))})),[...o].sort((c,u)=>+(c.id==="default")-+(u.id==="default")).forEach(c=>{if(r.has(c.id))return;let u=Qt(e,c);s.has(u)&&(u=ir("bgm",c.id)),s.has(u)&&(u=ir("bgm","clip",c.id));let p=0;for(;s.has(u);)u=ir("bgm","clip",c.id,++p);r.set(c.id,u),s.add(u)}),r};var _r=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Zt=Object.freeze({volume:100,pan:0,playbackRate:1}),is=["volume","pan","playbackRate"],Th=["src","startAt","endAt","startDelayMs"],vc=(e,t)=>{if(!e)return null;let n=e.children??[];if(n.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return n[0]},Ec=(e,t)=>e?.id===t?.id&&Th.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),xc=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Dh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),wo=e=>Math.max(-1,Math.min(1,e)),Io=({bgm:e,resources:t,renderedSound:n,property:o})=>{let a=e?.sounds?.length===1?e.sounds[0]:e?.sounds?.find(s=>Qt(e,s)===n?.id),r=t.sounds?.[a?.resourceId];return a?.[o]??r?.[o]??Zt[o]},Lh=({property:e,value:t,relative:n,bgm:o,resources:a,renderedSound:r})=>{if(!o||!r)return t;if(e==="volume"){let s=Io({bgm:o,resources:a,renderedSound:r,property:e});return t*s/100}if(e==="pan"&&!n){let s=Io({bgm:o,resources:a,renderedSound:r,property:e});return wo(t+s)}return t},Mh=({authoredInitialValue:e,authoredKeyframes:t,baselineBgm:n,compiledKeyframes:o,bgm:a,resources:r,renderedSound:s})=>{if(!a||!s)return o;let i=Io({bgm:a,resources:r,renderedSound:s,property:"pan"}),l=e??n?.pan??Zt.pan;return o.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let m=_r(p,"startValue")?l+p.startValue:l,d=m+p.value,{relative:f,...h}=c;return l=d,{...h,..._r(p,"startValue")?{startValue:wo(m+i)}:{},value:wo(d+i)}})},Sc=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},Vh=(e,t)=>({..._r(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Oc=({property:e,authored:t,speed:n,propertyPath:o,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${o}.keyframes] The final keyframe must use an absolute finite numeric value.`);let s={keyframes:t.keyframes.map(i=>{let l=Vh(i,n),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),_r(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return _r(t,"initialValue")&&(s.initialValue=a({property:e,value:t.initialValue,relative:!1})),s},bo=({authored:e,bgm:t,baselineBgm:n=t,property:o,propertyPath:a,renderedSound:r,resources:s,speed:i})=>{let l=Oc({property:o,authored:e,speed:i,propertyPath:a,normalizeValue:({value:c,relative:u})=>Lh({property:o,value:c,relative:u,bgm:t,resources:s,renderedSound:r})});return o==="pan"&&(l.keyframes=Mh({authoredInitialValue:e.initialValue,authoredKeyframes:e.keyframes,baselineBgm:n,compiledKeyframes:l.keyframes,bgm:t,resources:s,renderedSound:r})),l},kc=({actionPath:e,compiled:t,property:n,propertyPath:o,renderedSound:a})=>{let r=a[n]??Zt[n],s=t.keyframes.at(-1);if(!Dh(s.value,r))throw new Error(`[${e}.audioEffects]
3
- [${o}.keyframes] The final keyframe value must match the persistent BGM ${n} value.`);s.value=r},Rc=({selection:e,selectionPath:t,resources:n={}})=>{if(!e)return;let o=e.resourceId,a=`resources.audioEffects.${o}`,r=n.audioEffects?.[o];if(!r)throw new Error(`[${t}.resourceId]
1
+ var Xm=Object.defineProperty;var Hm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Gm=(e,t)=>{for(var n in t)Xm(e,n,{get:t[n],enumerable:!0})};var Ef=Hm(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});function Pf(e){let t=e.length,n=0,o=0,a;for(;o<t;)n++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<t&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return n}Ha.default=Pf;Pf.code='require("ajv/dist/runtime/ucs2length").default'});var xl=Symbol.for("immer-nothing"),vl=Symbol.for("immer-draftable"),De=Symbol.for("immer-state");function ze(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var mt=Object.getPrototypeOf;function ge(e){return!!e&&!!e[De]}function Hr(e){return e?Sl(e)||Array.isArray(e)||!!e[vl]||!!e.constructor?.[vl]||Ln(e)||Mn(e):!1}var Km=Object.prototype.constructor.toString();function Sl(e){if(!e||typeof e!="object")return!1;let t=mt(e);if(t===null)return!0;let n=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Km}function Tn(e){return ge(e)||ze(15,e),e[De].base_}function _n(e,t){Dn(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function Dn(e){let t=e[De];return t?t.type_:Array.isArray(e)?1:Ln(e)?2:Mn(e)?3:0}function Bi(e,t){return Dn(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function Ol(e,t,n){let o=Dn(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function Wm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Ln(e){return e instanceof Map}function Mn(e){return e instanceof Set}function Xr(e){return e.copy_||e.base_}function Ui(e,t){if(Ln(e))return new Map(e);if(Mn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Sl(e);if(t===!0||t==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[De];let a=Reflect.ownKeys(o);for(let r=0;r<a.length;r++){let s=a[r],i=o[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(mt(e),o)}else{let o=mt(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Gi(e,t=!1){return Vn(e)||ge(e)||!Hr(e)||(Dn(e)>1&&(e.set=e.add=e.clear=e.delete=Jm),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Gi(o,!0))),e}function Jm(){ze(2)}function Vn(e){return Object.isFrozen(e)}var Qm={};function Gr(e){let t=Qm[e];return t||ze(0,e),t}var Mt;function Rl(){return Mt}function Zm(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function kl(e,t){t&&(Gr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Yi(e){zi(e),e.drafts_.forEach(ey),e.drafts_=null}function zi(e){e===Mt&&(Mt=e.parent_)}function Al(e){return Mt=Zm(Mt,e)}function ey(e){let t=e[De];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Pl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[De].modified_&&(Yi(t),ze(4)),Hr(e)&&(e=Nn(t,e),t.parent_||jn(t,e)),t.patches_&&Gr("Patches").generateReplacementPatches_(n[De].base_,e,t.patches_,t.inversePatches_)):e=Nn(t,n,[]),Yi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==xl?e:void 0}function Nn(e,t,n){if(Vn(t))return t;let o=t[De];if(!o)return _n(t,(a,r)=>El(e,o,t,a,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return jn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,r=a,s=!1;o.type_===3&&(r=new Set(a),a.clear(),s=!0),_n(r,(i,l)=>El(e,o,a,i,l,n,s)),jn(e,a,!1),n&&e.patches_&&Gr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function El(e,t,n,o,a,r,s){if(ge(a)){let i=r&&t&&t.type_!==3&&!Bi(t.assigned_,o)?r.concat(o):void 0,l=Nn(e,a,i);if(Ol(n,o,l),ge(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Hr(a)&&!Vn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Nn(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&jn(e,a)}}function jn(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Gi(t,n)}function ry(e,t){let n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:Rl(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=Ki;n&&(a=[o],r=Vt);let{revoke:s,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=s,i}var Ki={get(e,t){if(t===De)return e;let n=Xr(e);if(!Bi(n,t))return ty(e,n,t);let o=n[t];return e.finalized_||!Hr(o)?o:o===qi(e.base_,t)?(Fi(e),e.copy_[t]=Hi(o,e)):o},has(e,t){return t in Xr(e)},ownKeys(e){return Reflect.ownKeys(Xr(e))},set(e,t,n){let o=Cl(Xr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=qi(Xr(e),t),r=a?.[De];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(Wm(n,a)&&(n!==void 0||Bi(e.base_,t)))return!0;Fi(e),Xi(e)}return e.copy_[t]===n&&(n!==void 0||t in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=n,e.assigned_[t]=!0),!0},deleteProperty(e,t){return qi(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Fi(e),Xi(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=Xr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){ze(11)},getPrototypeOf(e){return mt(e.base_)},setPrototypeOf(){ze(12)}},Vt={};_n(Ki,(e,t)=>{Vt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Vt.deleteProperty=function(e,t){return Vt.set.call(this,e,t,void 0)};Vt.set=function(e,t,n){return Ki.set.call(this,e[0],t,n,e[0])};function qi(e,t){let n=e[De];return(n?Xr(n):e)[t]}function ty(e,t,n){let o=Cl(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Cl(e,t){if(!(t in e))return;let n=mt(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=mt(n)}}function Xi(e){e.modified_||(e.modified_=!0,e.parent_&&Xi(e.parent_))}function Fi(e){e.copy_||(e.copy_=Ui(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var ny=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,n,o)=>{if(typeof t=="function"&&typeof n!="function"){let r=n;n=t;let s=this;return function(l=r,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&ze(6),o!==void 0&&typeof o!="function"&&ze(7);let a;if(Hr(t)){let r=Al(this),s=Hi(t,void 0),i=!0;try{a=n(s),i=!1}finally{i?Yi(r):zi(r)}return kl(r,o),Pl(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===xl&&(a=void 0),this.autoFreeze_&&Gi(a,!0),o){let r=[],s=[];Gr("Patches").generateReplacementPatches_(t,a,r,s),o(r,s)}return a}else ze(1,t)},this.produceWithPatches=(t,n)=>{if(typeof t=="function")return(s,...i)=>this.produceWithPatches(s,l=>t(l,...i));let o,a;return[this.produce(t,n,(s,i)=>{o=s,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){Hr(e)||ze(8),ge(e)&&(e=Xe(e));let t=Al(this),n=Hi(e,void 0);return n[De].isManual_=!0,zi(t),n}finishDraft(e,t){let n=e&&e[De];(!n||!n.isManual_)&&ze(9);let{scope_:o}=n;return kl(o,t),Pl(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let a=t[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(t=t.slice(n+1));let o=Gr("Patches").applyPatches_;return ge(e)?o(e,t):this.produce(e,a=>o(a,t))}};function Hi(e,t){let n=Ln(e)?Gr("MapSet").proxyMap_(e,t):Mn(e)?Gr("MapSet").proxySet_(e,t):ry(e,t);return(t?t.scope_:Rl()).drafts_.push(n),n}function Xe(e){return ge(e)||ze(10,e),$l(e)}function $l(e){if(!Hr(e)||Vn(e))return e;let t=e[De],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=Ui(e,t.scope_.immer_.useStrictShallowCopy_)}else n=Ui(e,!0);return _n(n,(o,a)=>{Ol(n,o,$l(a))}),t&&(t.finalized_=!1),n}var Ve=new ny,qn=Ve.produce,gA=Ve.produceWithPatches.bind(Ve),bA=Ve.setAutoFreeze.bind(Ve),wA=Ve.setUseStrictShallowCopy.bind(Ve),IA=Ve.applyPatches.bind(Ve),vA=Ve.createDraft.bind(Ve),kA=Ve.finishDraft.bind(Ve);var x={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},yt={NOT:0};var D=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ne=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Wi=e=>{if(!e||e.trim()==="")throw new D("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new D(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let n of t)if(e.trim().endsWith(n))throw new D(`Incomplete comparison expression - missing right operand (got: '${e}')`)},_l=e=>{if(e.trim().endsWith(" in"))throw new D(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new D(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,n]=e.split(" in ");if(!n||n.trim()==="")throw new D(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=t.includes(",")?t.split(",").map(a=>a.trim()):[t.trim()];for(let a of o){if(!a)throw new D(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new D(`Invalid loop syntax (got: '$for ${e}')`)}};var Nl=(e,t,n=!1)=>{if(t===null)return new Ne(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ne(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return n?new Ne(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ne(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},jl=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ne(`Unknown function '${e}' (${n})`)};var sy=(e,t,n={})=>{let o={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(o=n.functions||{},a=n.partials||{}):typeof n=="object"&&(o=n));let s=ne(e,{functions:o,partials:a},t,{});return s===void 0?{}:s},ne=(e,t,n,o)=>{let a=t.functions||t;if(e.var&&!e.type)return Ae(e.var,n,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return Ae(e.path,n,o);if(e.type===x.INTERPOLATION)return oy(e.parts,t,n,o);switch(e.type){case x.FUNCTION:return Dl(e,t,n,o);case x.BINARY:return Ll(e,t,n,o);case x.UNARY:return Ml(e,t,n,o);case x.CONDITIONAL:return ly(e,t,n,o);case x.LOOP:return dy(e,t,n,o);case x.OBJECT:return yy(e,t,n,o);case x.ARRAY:return hy(e,t,n,o);case x.PARTIAL:return gy(e,t,n,o);case x.PATH_REFERENCE:return by(e,t,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Tl=new Map,iy=e=>{let t=[],n="",o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")n&&(t.push({type:"property",value:n}),n=""),o=!0;else if(r==="]"){if(o&&n){let s=n.trim();if(/^\d+$/.test(s))t.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let i=s.slice(1,-1);t.push({type:"property",value:i})}else t.push({type:"property",value:s});n=""}o=!1}else n+=r}return n&&t.push({type:"property",value:n}),t},Ae=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let o=Tl.get(e);if(!o){let r=[],s="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,s+=c):c==="]"?(i--,s+=c):c==="."&&i===0?s&&(r.push(s),s=""):s+=c}s&&r.push(s),o=[];for(let l of r){let c=iy(l.trim());o.push(...c)}Tl.set(e,o)}let a=t;for(let r=0;r<o.length;r++){let s=o[r];if(s.type==="property"&&s.value in n){a=n[s.value];continue}if(a==null)return;(s.type==="property"||s.type==="index")&&(a=a[s.value])}return a},oy=(e,t,n,o)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let s=ne(r,t,n,o);a.push(s!=null?String(s):"")}return a.join("")},Dl=(e,t,n,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw jl(e.name,a);let s=e.args.map(i=>ne(i,t,n,o));return r(...s)},Or=(e,t,n,o)=>{if(e.var&&!e.type)return Ae(e.var,n,o);switch(e.type){case x.VARIABLE:return Ae(e.path,n,o);case x.LITERAL:return e.value;case x.BINARY:return Ll(e,t,n,o);case x.UNARY:return Ml(e,t,n,o);case x.FUNCTION:return Dl(e,t,n,o);default:return ne(e,t,n,o)}},Ll=(e,t,n,o)=>{if(e.op===ee.AND||e.op===ee.OR){let s=Or(e.left,t,n,o),i=Or(e.right,t,n,o);switch(e.op){case ee.AND:return s&&i;case ee.OR:return s||i}}let a=ne(e.left,t,n,o),r=ne(e.right,t,n,o);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Ml=(e,t,n,o)=>{let a=e.op===yt.NOT?Or(e.operand,t,n,o):ne(e.operand,t,n,o);if(e.op===yt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},ay=(e,t,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(Ae(a.path,n,o)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.fast===!0&&!s.whenCondition&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=Ae(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let d=Ae(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=ne(m,t,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=ne(u,t,n,o)}return i}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.fast===!0&&!s.whenCondition&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?ne(l.parsedKey,t,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=Ae(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let d=Ae(m.path,n,o);p.push(d!=null?String(d):"")}else{let d=ne(m,t,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=ne(u,t,n,o)}return i}}}return null},ly=(e,t,n,o)=>{let a=ay(e,t,n,o);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let s=e.conditions[r];if(s===null||Or(s,t,n,o))return ne(e.bodies[r],t,n,o)}return ql},cy=(e,t)=>{let n=e.body,o=e.itemVar;if(n.type===x.CONDITIONAL&&n.conditions.length===1&&n.conditions[0].type===x.VARIABLE){let a=n.conditions[0].path,r=n.bodies[0];if(a.startsWith(o+".")){let s=a.substring(o.length+1);if(r.type===x.OBJECT&&r.properties.length<=5){for(let l of r.properties)if(l.parsedKey)return null;let i=[];for(let l=0;l<t.length;l++){let c=t[l];if(c[s]){let u={};for(let p of r.properties){let m=p.key,d=p.value;if(d.type===x.LITERAL)u[m]=d.value;else if(d.type===x.VARIABLE){let f=d.path;if(f===o)u[m]=c;else if(f.startsWith(o+".")){let h=f.substring(o.length+1);u[m]=c[h]}else return null}else if(d.type===x.INTERPOLATION){let f=[],h=!0;for(let g of d.parts)if(typeof g=="string")f.push(g);else if(g.type===x.VARIABLE){let y=g.path;if(y===o)f.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),b=c[w];f.push(b!=null?String(b):"")}else{h=!1;break}}else{h=!1;break}if(!h)return null;u[m]=f.join("")}else return null}i.push(u)}}return i}}}return null},uy=(e,t)=>{let n=e.body,o=e.itemVar,a=cy(e,t);if(a!==null)return a;if(n.type===x.OBJECT&&n.properties.length<=5&&!n.whenCondition){for(let i of n.properties)if(i.parsedKey)return null;let r=[],s=!0;for(let i of n.properties){let l=i.key,c=i.value;if(c.type===x.LITERAL)r.push({key:l,type:"literal",value:c.value});else if(c.type===x.VARIABLE){let u=c.path;if(u===o)r.push({key:l,type:"item"});else if(u.startsWith(o+".")){let p=u.substring(o.length+1);if(!p.includes(".")&&!p.includes("["))r.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(c.type===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===o)r.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let m=p.substring(o.length+1);if(!m.includes(".")&&!m.includes("["))r.push({key:l,type:"prop_string",prop:m});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let i=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}i[l]=u}return i}}return null},py=(e,t,n,o,a)=>{let r=[],s=e.body;if(s.type===x.OBJECT&&s.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...o,[i]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let f=d.split("."),h=f[0];h in o.__paths__&&(d=o.__paths__[h],f.length>1&&(d+="."+f.slice(1).join(".")))}m.__paths__={...m.__paths__,[i]:`${d}[${c}]`,...l&&{[l]:c}};for(let f of s.properties){let h=f.parsedKey?ne(f.parsedKey,t,n,m):f.key,g=f.value;if(g.type===x.LITERAL)p[h]=g.value;else if(g.type===x.VARIABLE){let y=g.path;if(y===i)p[h]=u;else if(y===l)p[h]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[h]=u[w]:p[h]=Ae(y,n,{...o,[i]:u,...l&&{[l]:c}})}else p[h]=Ae(y,n,{...o,[i]:u,...l&&{[l]:c}})}else if(g.type===x.INTERPOLATION){let y=[];for(let w of g.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let b=w.path,A;if(b===i)A=u;else if(b===l)A=c;else if(b.startsWith(i+".")){let k=b.substring(i.length+1);!k.includes(".")&&!k.includes("[")?A=u[k]:A=Ae(b,n,{...o,[i]:u,...l&&{[l]:c}})}else A=Ae(b,n,{...o,[i]:u,...l&&{[l]:c}});y.push(A!=null?String(A):"")}else{let b={...o,[i]:u,...l&&{[l]:c}},A=ne(w,t,n,b);y.push(A!=null?String(A):"")}p[h]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[h]=ne(g,t,n,y)}}r.push(p)}return r}return null},fy=(e,t,n)=>{let o=e.body;if(o.type===x.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let r=o.properties[0].value;if(r.type===x.CONDITIONAL&&r.conditions.length===1&&r.conditions[0].type===x.VARIABLE&&r.conditions[0].path==="item.visible"){let s=r.bodies[0];if(s.type===x.OBJECT&&s.properties.length===2){let i=s.properties[0],l=s.properties[1];if(i.key==="id"&&i.value.type===x.VARIABLE&&i.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},dy=(e,t,n,o)=>{let a=ne(e.iterable,t,n,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let m=e.iterable.args.map(d=>d.type===x.LITERAL?typeof d.value=="string"?`'${d.value}'`:String(d.value):d.type===x.VARIABLE?d.path:d.type===x.FUNCTION?`${d.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Nl(p,a,u)}if(!e.indexVar){let c=fy(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=uy(e,a);if(c!==null)return c}let r=py(e,t,n,o,a);if(r!==null)return r;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let c=i.split("."),u=c[0];u in o.__paths__&&(i=o.__paths__[u],c.length>1&&(i+="."+c.slice(1).join(".")))}let l=!1;e.body.type===x.ARRAY&&(e.body.items.length<=1?l=!1:l=e.body._shouldPreserveArray??=e.body.items.some(c=>c.type===x.OBJECT&&c.properties.some(u=>u.key.startsWith("$if ")||u.key.startsWith("$when "))));for(let c=0;c<a.length;c++){let u=e.indexVar?{...o,[e.itemVar]:a[c],[e.indexVar]:c}:{...o,[e.itemVar]:a[c]};u.__paths__||(u.__paths__=o.__paths__||{}),u.__paths__={...u.__paths__,[e.itemVar]:`${i}[${c}]`},e.indexVar&&(u.__paths__[e.indexVar]=c);let p=ne(e.body,t,n,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];s.push(m===void 0?{}:m)}else s.push(p===void 0?{}:p)}return s},Vl=(e,t,n)=>e.type!==x.OBJECT||e.whenCondition||e.properties.length>t?!1:e.properties.every(({value:o})=>{switch(o.type){case x.LITERAL:case x.VARIABLE:return!0;case x.INTERPOLATION:return o.parts.every(a=>typeof a=="string"||a.type===x.VARIABLE);case x.OBJECT:return n&&Vl(o,5,!1);default:return!1}}),my=(e,t,n,o)=>{if(e.whenCondition||e.properties.length!==1||!Vl(e.properties[0].value,10,!0))return null;let a=e.properties[0],r=a.parsedKey?ne(a.parsedKey,t,n,o):a.key,s=a.value,i={},l={};for(let c of s.properties){let u=c.parsedKey?ne(c.parsedKey,t,n,o):c.key,p=c.value;if(p.type===x.LITERAL)l[u]=p.value;else if(p.type===x.VARIABLE)l[u]=Ae(p.path,n,o);else if(p.type===x.INTERPOLATION){let m=[];for(let d of p.parts)if(typeof d=="string")m.push(d);else if(d.type===x.VARIABLE){let f=Ae(d.path,n,o);m.push(f!=null?String(f):"")}l[u]=m.join("")}else if(p.type===x.OBJECT){let m={};for(let d of p.properties){let f=d.parsedKey?ne(d.parsedKey,t,n,o):d.key,h=d.value;if(h.type===x.LITERAL)m[f]=h.value;else if(h.type===x.VARIABLE)m[f]=Ae(h.path,n,o);else if(h.type===x.INTERPOLATION){let g=[];for(let y of h.parts)if(typeof y=="string")g.push(y);else if(y.type===x.VARIABLE){let w=Ae(y.path,n,o);g.push(w!=null?String(w):"")}m[f]=g.join("")}}l[u]=m}}return i[r]=l,i},yy=(e,t,n,o)=>{let a=t.functions||t;if(e.whenCondition&&!Or(e.whenCondition,a,n,o))return;let r=my(e,t,n,o);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?ne(u.parsedKey,t,n,o):u.key,m=u.value;if(m.type===x.LITERAL)c[p]=m.value;else if(m.type===x.VARIABLE)c[p]=Ae(m.path,n,o);else if(m.type===x.INTERPOLATION){let d=[];for(let f of m.parts)if(typeof f=="string")d.push(f);else if(f.type===x.VARIABLE){let h=Ae(f.path,n,o);d.push(h!=null?String(h):"")}else{let h=ne(f,t,n,o);d.push(h!=null?String(h):"")}c[p]=d.join("")}else c[p]=ne(m,t,n,o)}return c}let s={},i=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=ne(c.value,t,n,o);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return ne(c.value,t,n,o)}else{let u=c.parsedKey?ne(c.parsedKey,t,n,o):c.key,p=c.value;if(p&&p.type===x.OBJECT&&p.properties){let m=p.properties.find(d=>d.key.startsWith("$for "));if(m){let d=ne(m.value,t,n,o);d!==void 0&&(s[u]=d)}else{let d=ne(c.value,t,n,o);d!==void 0&&(s[u]=d)}}else{let m=ne(c.value,t,n,o);(m!==void 0||p?.type===x.VARIABLE||p?.type===x.FUNCTION)&&(s[u]=m)}}return s},ql={},hy=(e,t,n,o)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let s=ne(r,t,n,o);Array.isArray(s)&&r.flatten!==!1?a.push(...s):a.push(s)}else{let s=ne(r,t,n,o);s!==ql&&s!==void 0&&a.push(s)}return a},gy=(e,t,n,o)=>{let{name:a,data:r,whenCondition:s}=e,i=t.partials||{},l=t.functions||t;if(s&&!Or(s,l,n,o))return;if(!i[a])throw new Ne(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new Ne(`Circular partial reference detected: ${a}`);let u=i[a],p=n,m={...o,_partialStack:[...c,a]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(r){let d=ne(r,t,n,o);p={...p,...d}}return ne(u,t,p,m)},by=(e,t,n,o)=>{let{path:a}=e,r=a.split("."),s=r[0],i=r.slice(1);if(!o||!(s in o))throw new Ne(`Path reference '#{${a}}' refers to '${s}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(s in o.__paths__))throw new Ne(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[s];if(typeof l=="number"){if(i.length>0)throw new Ne(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Ji=sy;var wy=/\$\{([^}]*)\}/g,Iy=/#\{([^}]*)\}/g,Bl=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,r=vy(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},vy=(e,t={})=>e.trim()?ky(e).map(o=>Ay(o.trim(),t)):[],ky=e=>{let t=[],n="",o=0,a=!1,r="";for(let s=0;s<e.length;s++){let i=e[s],l=s>0?e[s-1]:"";!a&&(i==='"'||i==="'")?(a=!0,r=i,n+=i):a&&i===r&&l!=="\\"?(a=!1,r="",n+=i):!a&&i==="("?(o++,n+=i):!a&&i===")"?(o--,n+=i):!a&&i===","&&o===0?(t.push(n),n=""):n+=i}return n&&t.push(n),t},Ay=(e,t={})=>{if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(/^-?\d+(\.\d+)?$/.test(e))return{type:x.LITERAL,value:parseFloat(e)};if(e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};let n=Bl(e,t);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,s=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Kr(o.substring(c),i);if(u===-1)break;let p=c+u;p>r&&(r=p,s={op:i,type:l}),c=p+i.length}}if(r!==-1)try{return Ee(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Ul=/^\w+\(.*\)$/,Py=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Ey=e=>{if(!(!e||e.trim()===""||Ul.test(e))&&Py.test(e))throw e.includes("?")&&e.includes(":")?new D(`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 D(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new D(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Fl=e=>{let t=e.trim();if(Ul.test(t))throw new D(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new D(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new D(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new D(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("?")&&t.includes(":"))throw new D(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},qt=(e,t={})=>{let n=e.trim();Ey(n);let o=Bl(n,t);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let r of n)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:n}},Qi=(e,t={})=>{let n=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(n=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),n=n.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),n=n.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(wy)],r=[...n.matchAll(Iy)],s=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:x.LITERAL,value:c}}if(s.length===1&&s[0].match[0]===n&&o.length===0){let{match:c,type:u}=s[0];try{return u==="variable"?qt(c[1],t):Fl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:n};throw p}}let i=[],l=0;for(let{match:c,type:u}of s){let[p,m]=c,d=c.index;if(d>l){let f=n.substring(l,d);for(let h=0;h<o.length;h++)f=f.replace(`__ESCAPED_${h}__`,o[h]);f&&i.push(f)}try{let f;u==="variable"?f=qt(m.trim(),t):f=Fl(m.trim()),i.push(f)}catch(f){if(f.message==="Invalid array index syntax")i.push(p);else throw f}l=d+p.length}if(l<n.length){let c=n.substring(l);for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);c&&i.push(c)}return{type:x.INTERPOLATION,parts:i}};var ro=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Xl=e=>Object.keys(e),Ce=e=>e.join("."),Rr=(e,t,n)=>{let o=Xl(e).filter(a=>!t.has(a));if(o.length>0)throw new D(`Unexpected key '${o[0]}' in condition JSON at '${Ce(n)}'`)},Cr=(e,t)=>typeof e=="string"?Qi(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?Sy(e,t):Oy(e,t):{type:x.LITERAL,value:e},xy=e=>{let{$each:t,...n}=e;if(typeof t!="string")throw new D("$each value must be a non-empty string");let o=t.trim();if(o==="")throw new D("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new D("Empty $each body not allowed");if(n.$partial!==void 0)throw new D("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},Sy=(e,t)=>{let n=[],o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="object"&&r!==null&&!Array.isArray(r)){if(r.$each!==void 0)try{let l=xy(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=zl(c[0],l[c[0]],t,!0);n.push(u),o=!0;continue}}catch(l){throw l instanceof D?l:new D(l.message)}let i=Object.keys(r);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=zl(i[0],r[i[0]],t);n.push(l),o=!0;continue}}let s=Cr(r,t);n.push(s),(s.type===x.FUNCTION||s.type===x.CONDITIONAL||s.type===x.LOOP||s.type===x.PARTIAL||s.type===x.OBJECT&&!s.fast||s.type===x.ARRAY&&!s.fast)&&(o=!0)}return{type:x.ARRAY,items:n,fast:!o}},Oy=(e,t)=>{let n=[],o=!1,a=null,r=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new D("$partial value must be a string");if(e.$partial.trim()==="")throw new D("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[y]of r)for(let w of l)if(y===w||y.startsWith(w+" ")||y.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new D(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,d={},f=!1;for(let[y,w]of Object.entries(m)){let b=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(b=y.slice(1)),d[b]=w,f=!0}let h=null;if(f&&(h=Cr(d,t),h.type===x.OBJECT)){let y=!1;for(let w of h.properties)if(w.value.type===x.VARIABLE||w.value.type===x.INTERPOLATION||w.value.type===x.FUNCTION||w.value.type===x.CONDITIONAL||w.value.type===x.OBJECT&&!w.value.fast||w.value.type===x.ARRAY&&!w.value.fast){y=!0;break}y&&(h.fast=!1)}let g={type:x.PARTIAL,name:u,data:h};return p!==void 0&&(g.whenCondition=Yl(p,t)),g}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new D("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new D("Missing condition expression after '$when'");a=Yl(c,t),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new D("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<r.length;){let[l,c]=r[s];if(l==="$when"){s++;continue}if(l==="$each")throw new D("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=Ry(r,s,t);n.push({key:l,value:u.node}),o=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new D(`$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 D(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new D("Missing condition expression after '$if'");{let u=Cr(c,t);(u.type===x.FUNCTION||u.type===x.CONDITIONAL||u.type===x.PARTIAL||u.type===x.OBJECT&&!u.fast||u.type===x.ARRAY&&!u.fast)&&(o=!0);let p=Qi(l,t),m={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(m.parsedKey=p),n.push(m),s++}}}let i={type:x.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},Ry=(e,t,n={})=>{let o=[],a=[],r=t,[s,i]=e[r],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new D(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Wi(c);let u=Ee(c,n);for(o.push(u),a.push(Cr(i,n)),r++;r<e.length;){let[p,m]=e[r],d=!1,f;if(l?p.startsWith(`$elif#${l} `)?(f=p.substring(`$elif#${l} `.length),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,f=null):p.startsWith("$elif ")?(f=p.substring(6),f.endsWith(":")&&(f=f.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,f=null),d){if(f===null)o.push(null);else{Wi(f);let h=Ee(f,n);o.push(h)}if(a.push(Cr(m,n)),r++,f===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Zi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},eo={all:ee.AND,any:ee.OR},Cy=new Set(["var","literal","call","not",...Object.keys(Zi),...Object.keys(eo)]),$y=(e,t,n)=>{if(!Array.isArray(e))throw new D(`Condition JSON operator '${t}' at '${Ce(n)}' requires an array`);if(e.length!==2)throw new D(`Condition JSON operator '${t}' at '${Ce(n)}' requires exactly 2 operands`);return e},_y=(e,t,n,o,a)=>{if(!Array.isArray(e))throw new D(`Condition JSON operator '${t}' at '${Ce(a)}' requires an array`);if(e.length===0)throw new D(`Condition JSON operator '${t}' at '${Ce(a)}' requires at least 1 condition`);return e.map((s,i)=>Le(s,o,[...a,i])).reduce((s,i)=>({type:x.BINARY,op:n,left:s,right:i}))},Ny=(e,t,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],Rr(e,new Set(["call","args"]),n);else if(ro(e.call))o=e.call.name,a=e.call.args??[],Rr(e,new Set(["call"]),n),Rr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new D(`Condition JSON call at '${Ce(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new D(`Condition JSON call at '${Ce(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new D(`Invalid condition JSON function name '${o}' at '${Ce(n)}'`);if(!Array.isArray(a))throw new D(`Condition JSON call '${o}' at '${Ce(n)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,s)=>Le(r,t,[...n,"args",s]))}},Le=(e,t={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new D(`Condition JSON array at '${Ce(n)}' must be wrapped in an operator or { literal: [...] }`);if(!ro(e))throw new D(`Invalid condition JSON value at '${Ce(n)}'`);let o=Xl(e);if(o.length===0)throw new D(`Condition JSON object at '${Ce(n)}' must contain an operator`);let a=o.filter(s=>Cy.has(s));if(a.length===0)throw new D(`Unknown condition JSON operator '${o[0]}' at '${Ce(n)}'`);if(a.length>1)throw new D(`Condition JSON at '${Ce(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(Rr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new D(`Condition JSON var at '${Ce(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return Rr(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return Ny(e,t,n);if(r==="not")return Rr(e,new Set(["not"]),n),{type:x.UNARY,op:yt.NOT,operand:Le(e.not,t,[...n,"not"])};if(r in eo)return Rr(e,new Set([r]),n),_y(e[r],r,eo[r],t,[...n,r]);if(r in Zi){Rr(e,new Set([r]),n);let s=$y(e[r],r,[...n,r]);return{type:x.BINARY,op:Zi[r],left:Le(s[0],t,[...n,r,0]),right:Le(s[1],t,[...n,r,1])}}throw new D(`Unknown condition JSON operator '${r}' at '${Ce(n)}'`)},Yl=(e,t={})=>{if(e==null)throw new D("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new D("Empty condition expression after '$when'");return Ee(e,t)}return ro(e)||Array.isArray(e)?Le(e,t):{type:x.LITERAL,value:e}},Ee=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Ee(c,t)}let n=Kr(e,"||");if(n!==-1)return{type:x.BINARY,op:ee.OR,left:Ee(e.substring(0,n).trim(),t),right:Ee(e.substring(n+2).trim(),t)};let o=Kr(e,"&&");if(o!==-1)return{type:x.BINARY,op:ee.AND,left:Ee(e.substring(0,o).trim(),t),right:Ee(e.substring(o+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Kr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Ee(e.substring(0,p).trim(),t),right:Ee(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,i=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let m=Kr(e.substring(p),c);if(m===-1)break;let d=p+m;d>r&&(r=d,s={op:c,type:u}),p=d+c.length}}if(r!==-1&&s)return{type:x.BINARY,op:s.type,left:Ee(e.substring(0,r).trim(),t),right:Ee(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Kr(e,c)!==-1)throw new D(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:yt.NOT,operand:Ee(e.substring(1).trim(),t)}:Hl(e,t)},Kr=(e,t)=>{let n=0,o=0;for(;o<=e.length-t.length;){if(e[o]==="(")n++;else if(e[o]===")")n--;else if(n===0&&e.substring(o,o+t.length)===t)return o;o++}return-1},jy=e=>{if(e=e.trim(),e==="true")return{type:x.LITERAL,value:!0};if(e==="false")return{type:x.LITERAL,value:!1};if(e==="null")return{type:x.LITERAL,value:null};if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))return{type:x.LITERAL,value:e.slice(1,-1)};if(e==='""'||e==="''")return{type:x.LITERAL,value:""};if(e==="{}")return{type:x.LITERAL,value:{}};if(e==="[]")return{type:x.LITERAL,value:[]};let t=Number(e);return!isNaN(t)&&isFinite(t)?{type:x.LITERAL,value:t}:{type:x.VARIABLE,path:e}},Hl=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return qt(n,t);let a=jy(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return qt(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Ty=(e,t=!1)=>{let n=t?"$each":"$for";try{_l(e)}catch(o){if(o instanceof D&&t){let a=o.message.replace(/\$for/g,"$each");throw new D(a.replace("Parse Error: ",""))}throw o}},zl=(e,t,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let g=o?"$each":"$for";throw new D(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=r[1],i=r[2].trim();Ty(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new D(`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(y=>y.trim());if(g.length!==2)throw new D(`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 D(`Reserved variable name: ${p}`);if(m&&d.includes(m))throw new D(`Reserved variable name: ${m}`);let f=Hl(u,n),h=Cr(t,n);return{type:x.LOOP,itemVar:p,indexVar:m,iterable:f,body:h,flatten:s!=="nested"}};var Dy=(e,t={})=>{let{functions:n={}}=t;return Cr(e,n)},Fn=Dy;var Ft={};Gm(Ft,{now:()=>Ly});var Ly=()=>Date.now();var My=(e,t,n={})=>{let{functions:o={},partials:a={}}=n,r={...Ft,...o},s=Fn(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=Fn(c,{functions:r});return Ji(s,t,{functions:r,partials:i})},Wr=My;var Vy=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",qy=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Fy=(e,t)=>{if(Vy(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new D("Empty condition expression");return Ee(e,t)}return Le(e,t)},By=(e,t={},n={})=>{let o=qy(n),a={...Ft,...o},r=Fy(e,a);return!!Or(r,{functions:a,partials:{}},t,{})},to=By;var po=Symbol("runStoreTransaction"),oo="__routeEngineConditionComparison",Bn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",$r=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Bn(e,t)&&e>t,gte:(e,t)=>Bn(e,t)&&e>=t,lt:(e,t)=>Bn(e,t)&&e<t,lte:(e,t)=>Bn(e,t)&&e<=t}),rc=Object.freeze(Object.fromEntries(Object.keys($r).map(e=>[e,`${oo}${e}`]))),Uy=Object.freeze(Object.fromEntries(Object.entries(rc).map(([e,t])=>[t,$r[e]]))),Gl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Yy=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},Un=e=>{if(Array.isArray(e))return e.map(Un);if(e===null||typeof e!="object"||Gl(e,"literal")||Gl(e,"var"))return e;if(Yy(e)?.startsWith(oo))throw new Error(`Condition function names beginning with "${oo}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,r=rc[o];if(r)return{call:r,args:a.map(Un)}}return Object.fromEntries(n.map(([o,a])=>[o,Un(a)]))},Ut=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Le(e),to(Un(e),t,{functions:Uy})},zy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tc=(e,t,n={})=>{let o={},a={},{transformSelectorFirstArgument:r=h=>h,transformActionFirstArgument:s=h=>h,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},m=0,d=(h,g)=>!u||!c?h:qn(h,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[h,g]of Object.entries(t))h!=="createInitialState"&&(h.startsWith("select")?o[h]=(...y)=>g(r(p.state,p.transactionalMetadata),...y):a[h]=(...y)=>{let w,b=p,A=qn(p,k=>{let E=g(s(k.state,k.transactionalMetadata),...y);w=E!==void 0&&!ge(E)?E:void 0,u&&l&&l({actionName:h,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});return m===0&&(A=d(A,b)),p=A,w});let f=h=>{if(typeof h!="function")throw new Error("Store transaction requires a callback");let g=p,y=m===0;m+=1;let w;try{w=h()}catch(b){throw m-=1,p=g,b}if(m-=1,y)try{p=d(p,g)}catch(b){throw p=g,b}return w};return{...o,...a,[po]:f}},Hn=(e,t)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return qn(o,r=>{a.forEach(s=>{t.forEach(i=>{i(r,s)})})})};var Xy=(e,t)=>{if(e.default!==void 0)return e.default;let n=["number","boolean","string","object"];if(!n.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},Z=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),ao=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},Pe=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Hy=new Set(["pageSize","groups"]),Gy=new Set(["id","variants"]),Ky=new Set(["id","imageId"]),Wy=new Set(["pageSize","tracks"]),Jy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),Qy=new Set(["pageSize","replays"]),Zy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Jr=(e,t,n)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},ht=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Yt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!Pe(t))throw new Error("resources.imageGallery must be an object");if(Jr(t,Hy,"resources.imageGallery"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[o,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${o}]`;if(!Pe(a))throw new Error(`${r} must be an object`);if(Jr(a,Gy,r),ht(a.id,`${r}.id`),n.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(n.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let s=new Set;for(let[i,l]of a.variants.entries()){let c=`${r}.variants[${i}]`;if(!Pe(l))throw new Error(`${c} must be an object`);if(Jr(l,Ky,c),ht(l.id,`${c}.id`),ht(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),!Z(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},zt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!Pe(t))throw new Error("resources.musicRoom must be an object");if(Jr(t,Wy,"resources.musicRoom"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[o,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${o}]`;if(!Pe(a))throw new Error(`${r} must be an object`);Jr(a,Jy,r);for(let l of["id","soundId","title"])ht(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&ht(a[l],`${r}.${l}`);if(n.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);n.add(a.id);let s=e?.resources?.sounds?.[a.soundId];if(!Z(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Pe(s))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(s.playbackRate!==void 0&&(typeof s.playbackRate!="number"||!Number.isFinite(s.playbackRate)||s.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let 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&&!Z(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},eh=(e,t,n)=>{let o=Array.isArray(n)?"array":typeof n;switch(t.type){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},Xt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!Pe(t))throw new Error("resources.sceneReplay must be an object");if(Jr(t,Qy,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},o=new Set;for(let[a,r]of t.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!Pe(r))throw new Error(`${s} must be an object`);Jr(r,Zy,s);for(let u of["sceneId","title","thumbnailImageId"])ht(r[u],`${s}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!Z(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let i=n[r.sceneId];if(!i)throw new Error(`Scene replay references unknown scene "${r.sceneId}"`);let l=i.initialSectionId,c=i.sections?.[l];if(!c)throw new Error(`Scene replay scene "${r.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${r.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(r.initialVariables!==void 0){if(!Pe(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let m=e?.resources?.variables?.[u];if(!m)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if($e(m))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);eh(u,m,p)}}}},nc=e=>{let t=ge(e)?Xe(e):e;return structuredClone(t)},rh=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!Z(t,"nameVariableId"))return;let o=t.nameVariableId,a=n?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Gn=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0;if(t?.name!==void 0)return t.name;if(n!==void 0)return n;let s=rh({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},$e=e=>Z(e,"computed"),fo=(e,t)=>{switch(e?.type){case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"string":return typeof t=="string";case"object":return t!==null&&typeof t=="object"&&!Array.isArray(t);default:return!1}},Ht=(e={},t={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?o:!$e(s)&&(!n||n.includes(s.scope))&&fo(s,r)})),Ge=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),th=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ge(t,n)}let a="";for(let r=1;r<e.length-1;r+=1){let s=e[r];if(s!=="\\"){if(s.charCodeAt(0)<32)throw Ge(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Ge(t,n);let i=e[r];if(i==="u"){let c=e.slice(r+1,r+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw Ge(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
2
+ `,r:"\r",t:" ",b:"\b",f:"\f"};if(!Z(l,i))throw Ge(t,n);a+=l[i]}return a},sc=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ge(e,t);let n=[],o=0,a=()=>{let s=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(s,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw Ge(e,t);n.push(i)},r=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let s=e[o];if(/\d/.test(s??"")){let u=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(u,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw Ge(e,t);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ge(e,t);let i=s,l=o;o+=1;let c=!1;for(;o<e.length;){let u=e[o];if(c)c=!1;else if(u==="\\")c=!0;else if(u===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw Ge(e,t);o+=1,n.push(th(p,e,t));return}o+=1}if(c||o>=e.length)throw Ge(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Ge(e,t)}return n},no=(e,t)=>{let n=e;for(let o of t){if(n==null||!Z(n,o))return;n=n[o]}return n},ic=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=sc(e),[o,a,...r]=n;if(o==="variables"){if(!a)return t.variables;let s=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return no(s,r)}return o==="runtime"?no(t.runtime,n.slice(1)):no(t,n)},oc=(e,t,n)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&t.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},lo=(e,t)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(t.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},nh=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},er=(e,t,n,o)=>(oc(e,t,o),t.map(a=>Xn(a,n))),He=(e,t,n,o)=>{let a=er(e,t,n,o);return a.forEach(r=>nh(e,r)),a},sh=(e,t,n)=>{switch(e){case"var":return ic(t,n);case"add":{let[o,a]=He(e,t,n,2);return o+a}case"sub":{let[o,a]=He(e,t,n,2);return o-a}case"mul":{let[o,a]=He(e,t,n,2);return o*a}case"div":{let[o,a]=He(e,t,n,2);return o/a}case"mod":{let[o,a]=He(e,t,n,2);return o%a}case"neg":{let[o]=He(e,t,n,1);return-o}case"round":{let[o]=He(e,t,n,1);return Math.round(o)}case"floor":{let[o]=He(e,t,n,1);return Math.floor(o)}case"ceil":{let[o]=He(e,t,n,1);return Math.ceil(o)}case"min":{let[o,a]=He(e,t,n,2);return Math.min(o,a)}case"max":{let[o,a]=He(e,t,n,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=He(e,t,n,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=er(e,t,n,2);return $r.eq(o,a)}case"neq":{let[o,a]=er(e,t,n,2);return $r.neq(o,a)}case"gt":{let[o,a]=er(e,t,n,2);return $r.gt(o,a)}case"gte":{let[o,a]=er(e,t,n,2);return $r.gte(o,a)}case"lt":{let[o,a]=er(e,t,n,2);return $r.lt(o,a)}case"lte":{let[o,a]=er(e,t,n,2);return $r.lte(o,a)}case"in":{let[o,a]=er(e,t,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return lo(e,t),t.every(o=>!!Xn(o,n));case"or":case"any":return lo(e,t),t.some(o=>!!Xn(o,n));case"not":{let[o]=er(e,t,n,1);return!o}case"length":{let[o]=er(e,t,n,1);return typeof o=="string"||Array.isArray(o)?o.length:Pe(o)?Object.keys(o).length:0}case"includes":{let[o,a]=er(e,t,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return nc(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Xn=(e,t={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let n=Object.entries(e);if(n.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=n;return sh(o,a,t)},co=(e,t)=>{if(e===null||typeof e!="object"||Z(e,"literal"))return e;if(Z(e,"var"))return{literal:ic(e.var,t)};if(Z(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=>co(a,t)):co(o,t)]))},ih=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Le(e),Ut(co(e,t))},ac=(e,t)=>{if(!Pe(e))throw new Error(`${t} must be an object`);let n=Z(e,"expr"),o=Z(e,"value");if(n===o)throw new Error(`${t} must contain exactly one of expr or value`)},so=(e,t,n)=>(ac(e,t),Z(e,"value")?nc(e.value):Xn(e.expr,n)),oh=(e,t={},n="unknown")=>{if(!Pe(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=Z(e,"expr"),a=Z(e,"value");if(Z(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(!Pe(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(!Pe(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!Z(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(ih(i.when,t))return so(i,`Computed variable "${n}" branch ${s}`,t)}return so(e.default,`Computed variable "${n}" default`,t)}if(o===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return so(e,`Computed variable "${n}"`,t)},lc=(e,t,n)=>{switch(t){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(n)?"array":typeof n}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(n)?"array":typeof n}`);return;case"string":if(typeof n!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(n)?"array":typeof n}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof n}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},ah=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}),lh=new Set(["and","or","all","any"]),ch=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),uh=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),ph=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),fh=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),cc=new WeakMap,Kl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,Yn=(e,t,n)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},dh=(e,t,n,o)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${n}`)},uc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,i,...l]=sc(e,r);if(s!=="variables"&&s!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${r} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!Z(n,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=n[i];return $e(c)&&o.add(i),l.length===0?c?.type:void 0},pc=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Kl(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let r=Object.entries(e);if(r.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,i]]=r;if(s==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return uc(i,{variableId:t,variableConfigs:n,dependencies:o,path:a})}if(s==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Kl(i)}let l=ah[s];if(l===void 0&&!lh.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?lo(s,i):oc(s,i,l);let c=i.map((u,p)=>pc(u,{variableId:t,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(uh.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),ch.has(s))return"number";if(ph.has(s))return"boolean"},mh=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Le(e)}catch(s){throw new Error(`Computed variable "${t}" ${a} is invalid: ${s.message}`,{cause:s})}let r=(s,i)=>{if(s===null||typeof s!="object"||Z(s,"literal"))return;if(Z(s,"var")){uc(s.var,{variableId:t,variableConfigs:n,dependencies:o,path:i});return}if(Z(s,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(Z(s,"not")){r(s.not,`${i}.not`);return}let l=Object.keys(s).find(c=>fh.has(c));s[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},io=(e,{variableId:t,variableConfig:n,variableConfigs:o,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(ac(e,`Computed variable "${t}" ${r}`),Yn(e,s,r),Z(e,"value")){lc(t,n.type,e.value);return}let i=pc(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});dh(t,n.type,i,`${r}.expr`)},yh=(e,t,n)=>{let o=t.computed;if(!Pe(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=Z(o,"expr"),s=Z(o,"value");if(Z(o,"branches")){if(Yn(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||s)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(o.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(o.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!Pe(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Pe(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(Yn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!Z(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);mh(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),io(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),io(o.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(Yn(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return io(o,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},Qr=(e={})=>{if(!Pe(e))throw new Error("Variable configs must be an object");if(Z(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(Z(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if($e(s)){if(!Pe(s))throw new Error(`Computed variable "${r}" must be an object`);if(!Z(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!Z(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(Z(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Gt(s.scope,r),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${r}`);t.set(r,yh(r,s,e))}});let n=new Set,o=[];t.forEach((r,s)=>{if(n.has(s))return;let i=[{variableId:s,dependencies:[...t.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),n.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...i.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return cc.set(e,a),a},gt=({variables:e={},runtime:t={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=cc.get(n)??Qr(n),r=Ht(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>$e(g)).map(([g])=>g),i=Object.create(null),l=[],c=new Map(a.map((g,y)=>[g,y])),u=-1,p=!1,m=g=>{if(Z(i,g))return i[g];let y=n[g];if(!$e(y))return Z(r,g)?r[g]:void 0;let w=l.indexOf(g);if(w>=0){let b=[...l.slice(w),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=oh(y.computed,h,g);return lc(g,y.type,b),ao(i,g,b),b}finally{l.pop()}},d=g=>{if(Z(i,g))return i[g];let y=n[g];if(!$e(y))return Z(r,g)?r[g]:void 0;let w=c.get(g);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let b=u+1;b<=w;b+=1)m(a[b]),u=b}finally{p=!1}return i[g]}return m(g)},f=new Proxy({},{get:(g,y)=>{if(typeof y=="string")return d(y)},has:(g,y)=>typeof y=="string"&&(Z(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(g,y)=>{if(!(typeof y!="string"||!Z(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),h={variables:f,runtime:t,resolveVariable:d};return o?(s.forEach(g=>{d(g)}),{...r,...i}):f},hh=({variables:e={},runtime:t={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return Qr(a),gt({variables:e,runtime:t,variableConfigs:a,eager:!0})},Kn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if($e(a))return;let r=Xy(a,o);a.scope==="context"?ao(t,o,r):ao(n,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},Gt=(e,t)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${n.join(", ")}`)},Kt=(e,t,n)=>{let o={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=o[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(o).flat().includes(t))throw new Error(`Unknown operation: ${t}`);if(!a.includes(t))throw new Error(`Operation "${t}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},gh=2,Wl=12,fc=(e=gh)=>{if(!Number.isInteger(e)||e<0||e>Wl)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Wl}.`);return e},bh=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},zn=e=>typeof e=="number"&&Number.isFinite(e),Wn=(e,t,n,o,a={})=>{if(e==="number"){if(t==="set"&&!zn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!zn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!zn(n))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(t==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);fc(a.roundTo)}}},Jn=(e,t,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!zn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=s=>{let i=a(s,void 0,"value");if(i===0)throw new Error(`Operation "${t}" requires value to be a non-zero number.`);return i};switch(t){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return bh(a(e,0,"current value")/r(n),fc(o.roundTo));case"increment":return a(e,0,"current value")+a(n,1,"value");case"decrement":return a(e,0,"current value")-a(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var mo=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),r={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:zy[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(n.getHours()),mm:o(n.getMinutes()),ss:o(n.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>r[s])},wh=(e,t)=>{let n=r=>r?.ui,o=n(e),a=n(t);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:t}:a&&o?{changeType:"update",data:t}:null},Bt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Ih=(e,t)=>{let n=e?.character?.sprite,o=t?.character?.sprite,a=Bt(n)?n:void 0,r=Bt(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},Jl=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[n]!==void 0&&(t[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(t[n]=e[n]);return t},Ql=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Zl=(e,t)=>t&&!e?{changeType:"add",data:t}:e&&!t?{changeType:"delete",data:e}:e&&t&&JSON.stringify(e)!==JSON.stringify(t)?{changeType:"update",data:t}:null,vh=(e,t)=>{let n={},o=Zl(Jl(e),Jl(t)),a=Zl(Ql(e),Ql(t));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},yo=(e={},t={})=>{let n={},o=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)n[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(m=>m.applyMode==="persistent");!o.includes(l)&&(l!=="sfx"||p)&&(n[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(n[l]={changeType:"update",data:u})},r=vh(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=wh(e.dialogue,t.dialogue);s&&(n.dialogue=s);let i=Ih(e.dialogue,t.dialogue);return i&&(n.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},ho=(e={})=>{let t=structuredClone(e);if(t.sfx){let a=Array.isArray(t.sfx.channels)?t.sfx.channels.filter(r=>r.applyMode==="persistent"):[];a.length>0?t.sfx={channels:a}:delete t.sfx}t.background&&(t.background.animations?.playback?.continuity!=="persistent"&&delete t.background.animations,!t.background.resourceId&&!t.background.colorId&&delete t.background);let n=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};n("layout"),n("choice"),n("form"),n("screen"),t.dialogue?.ui&&(delete t.dialogue.ui.animations,Object.keys(t.dialogue.ui).length===0&&delete t.dialogue.ui,Object.keys(t.dialogue).length===0&&delete t.dialogue),t.dialogue?.character?.sprite&&(delete t.dialogue.character.sprite.animations,Object.keys(t.dialogue.character.sprite).length===0&&delete t.dialogue.character.sprite,Object.keys(t.dialogue.character).length===0&&delete t.dialogue.character,Object.keys(t.dialogue).length===0&&delete t.dialogue);let o=(a,r)=>{let s=t[a]?.items;Array.isArray(s)&&(t[a].items=s.map(i=>{let l={...i};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,r(l)?l:null}).filter(Boolean),t[a].items.length===0&&delete t[a])};return o("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),o("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),t},kh=(e,t)=>{if(!e||!t)return;let n=e;for(let o of t.split(".")){if(n==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),o))return;n=n[o]}return n},ec=e=>e!==null&&typeof e=="object"?structuredClone(e):e,Ah=(e,t,n)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(t??{},n)?t[n]:void 0;if(e===n){if(o==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return ec(o)}if(!e.startsWith(`${n}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${n}".`);let a=e.slice(n.length+1),r=kh(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return ec(r)},Ph={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"])},Eh=(e,t)=>{let n=e[e.length-1];return n?Ph[n]?.has(t)===!0:!1},uo=(e,t,n=[])=>Array.isArray(e)?e.map(o=>uo(o,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Eh(n,o)?a:uo(a,t,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Ah(e,t,"_event"):Wr(e,t):e,Wt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return uo(e,t)};var xh=11102230246251565e-32,dc=128,mc=1e3,yc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Jt=(e,t,n)=>{let o=Object.keys(e).find(a=>!t.has(a));if(o!==void 0)throw new Error(`${n}.${o} is not supported`)},Qn=(e,t)=>{if(!yc(e))throw new Error(`${t} must be an object`)},Zn=(e,t,{min:n,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},Sh=(e,t,{min:n,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${t} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},go=e=>{let t=structuredClone(e),n=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(n),Object.freeze(o)),o);return n(t)},Oh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),hc=e=>{let t=e??Oh();if(!yc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=t.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},Rh=(e,t)=>{let n=4294967296-4294967296%t;for(let o=0;o<dc;o+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${dc} rejected samples`)},Ch=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},$h=(e,t)=>{if(Jt(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=Zn(e.min,"random.distribution.min"),a=Zn(e.max,"random.distribution.max")-n+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return go({type:"integer",value:a===1?n:n+Rh(t,a)})},_h=(e,t)=>{if(Jt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>mc)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let n=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(Qn(c,p),Jt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Qn(c.actions,`${p}.actions`),{weight:Sh(c.weight,`${p}.weight`,{min:0})}}),o=Math.max(...n.map(({weight:c})=>c));if(o<=0)throw new Error("random weighted total weight must be positive");let a=n.map(c=>({...c,weight:c.weight/o})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(n[u].weight>0&&(c.weight===0||c.weight/r<=xh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Ch(t)*r,i=0,l=a.findLastIndex(({weight:c})=>c>0);for(let c=0;c<a.length;c+=1){let u=a[c];if(i+=u.weight,s<i){l=c;break}}return go({type:"weighted",outcomeIndex:l})},gc=(e,{randomSource:t})=>{Qn(e,"random.distribution");let o={integer:$h,weighted:_h}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},es=(e,t)=>{if(Qn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Jt(e,new Set(["type","value"]),"random result"),Zn(e.value,"random result.value");else if(t==="weighted")Jt(e,new Set(["type","outcomeIndex"]),"random result"),Zn(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:mc-1});else throw new Error(`unsupported recorded random result type: ${t}`);return go(e)};var Zr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),Ic=Object.freeze([Zr("cleanup",["clearPendingEffects","cleanAll"]),Zr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Zr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Zr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Zr("runtime",["setNextLineConfig","startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","showDialogueUI","hideDialogueUI","toggleDialogueUI","setDialogueTextSpeed","setAutoForwardDelay","setAutoForwardSpeed","setSkipUnseenText","setSkipTransitionsAndAnimations","setSoundVolume","setMusicVolume","setMuteAll","setSaveLoadPagination","incrementSaveLoadPagination","decrementSaveLoadPagination","setMenuPage","setMenuEntryPoint","showConfirmDialog","hideConfirmDialog","pushOverlay","popOverlay","replaceLastOverlay","clearOverlays","completeAchievement","setAchievementProgress","showImageGalleryVariant","moveToPreviousImageGalleryVariant","moveToNextImageGalleryVariant","clearImageGallerySelection","moveToImageGalleryPage","moveToNextImageGalleryPage","moveToPreviousImageGalleryPage","playMusicRoomTrack","playMusicRoom","pauseMusicRoom","stopMusicRoom","seekMusicRoom","playPreviousMusicRoomTrack","playNextMusicRoomTrack","clearMusicRoomSelection","moveToMusicRoomPage","moveToNextMusicRoomPage","moveToPreviousMusicRoomPage","finishSceneReplay","moveToSceneReplayPage","moveToNextSceneReplayPage","moveToPreviousSceneReplayPage","musicRoomSoundReady","musicRoomSoundProgress","musicRoomSoundComplete","musicRoomSoundError","appendPendingEffect","beginRollbackActionBatch","endRollbackActionBatch","ensureRandomReplayOccurrence","recordRandomOutcome","markRollbackCheckpointTransient","markSavedRollbackCheckpointTransient","recordCurrentDialogueHistory"]),Zr("persistence",["saveSlot"]),Zr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),bt=new Map;Ic.forEach(e=>{e.actions.forEach(t=>{if(bt.has(t))throw new Error(`duplicate action execution key: ${t}`);bt.set(t,bt.size)})});var Nh=new Set(Ic.find(({name:e})=>e==="navigation").actions),bc=bt.get("saveSlot")-.5,wc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",jh=(e,t)=>e<t?-1:e>t?1:0,rs=e=>Object.entries(e).sort((t,n)=>{let o=wc(...t),a=wc(...n),r=bt.get(o),s=bt.get(a),i=r??bc,l=s??bc;return i!==l?i-l:r!==void 0&&s!==void 0?0:jh(o,a)}),ts=e=>Nh.has(e),ns=e=>{let t=e.map(([n])=>n).filter(ts);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var Th=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),ir=(...e)=>e.map(Th).join(":"),ss=e=>Array.isArray(e?.sounds)?e.sounds:e?.resourceId?[{id:e.resourceId,resourceId:e.resourceId,loop:e.loop??!0,volume:e.volume,startDelayMs:e.startDelayMs??0}]:[],bo=e=>!Array.isArray(e?.sounds)&&e?.startDelayMs>0,Qt=(e,t)=>bo(e)?ir("bgm","legacy-delay",t.resourceId):ir("bgm",t.id==="default"?t.resourceId:t.id),vc=({bgm:e,resources:t,previousBgmRender:n})=>{let o=ss(e).filter(c=>t.sounds?.[c.resourceId]),a=ss(n?.bgm).filter(c=>n.resources?.sounds?.[c.resourceId]).map((c,u)=>({sound:c,renderId:n.channel?.children[u]?.id})).filter(({renderId:c})=>c!==void 0),r=new Map,s=new Set,i=(c,u)=>{!u||s.has(u.renderId)||(r.set(c.id,u.renderId),s.add(u.renderId))};return bo(e)===bo(n?.bgm)&&(o.forEach(c=>i(c,a.find(u=>u.sound.id===c.id))),o.forEach(c=>{r.has(c.id)||i(c,a.find(u=>u.sound.resourceId===c.resourceId&&Qt(n.bgm,u.sound)===Qt(e,c)))})),[...o].sort((c,u)=>+(c.id==="default")-+(u.id==="default")).forEach(c=>{if(r.has(c.id))return;let u=Qt(e,c);s.has(u)&&(u=ir("bgm",c.id)),s.has(u)&&(u=ir("bgm","clip",c.id));let p=0;for(;s.has(u);)u=ir("bgm","clip",c.id,++p);r.set(c.id,u),s.add(u)}),r};var _r=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Zt=Object.freeze({volume:100,pan:0,playbackRate:1}),is=["volume","pan","playbackRate"],Dh=["src","startAt","endAt","startDelayMs"],kc=(e,t)=>{if(!e)return null;let n=e.children??[];if(n.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return n[0]},xc=(e,t)=>e?.id===t?.id&&Dh.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),Sc=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Lh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),Io=e=>Math.max(-1,Math.min(1,e)),vo=({bgm:e,resources:t,renderedSound:n,property:o})=>{let a=e?.sounds?.length===1?e.sounds[0]:e?.sounds?.find(s=>Qt(e,s)===n?.id),r=t.sounds?.[a?.resourceId];return a?.[o]??r?.[o]??Zt[o]},Mh=({property:e,value:t,relative:n,bgm:o,resources:a,renderedSound:r})=>{if(!o||!r)return t;if(e==="volume"){let s=vo({bgm:o,resources:a,renderedSound:r,property:e});return t*s/100}if(e==="pan"&&!n){let s=vo({bgm:o,resources:a,renderedSound:r,property:e});return Io(t+s)}return t},Vh=({authoredInitialValue:e,authoredKeyframes:t,baselineBgm:n,compiledKeyframes:o,bgm:a,resources:r,renderedSound:s})=>{if(!a||!s)return o;let i=vo({bgm:a,resources:r,renderedSound:s,property:"pan"}),l=e??n?.pan??Zt.pan;return o.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let m=_r(p,"startValue")?l+p.startValue:l,d=m+p.value,{relative:f,...h}=c;return l=d,{...h,..._r(p,"startValue")?{startValue:Io(m+i)}:{},value:Io(d+i)}})},Oc=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},qh=(e,t)=>({..._r(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Rc=({property:e,authored:t,speed:n,propertyPath:o,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${o}.keyframes] The final keyframe must use an absolute finite numeric value.`);let s={keyframes:t.keyframes.map(i=>{let l=qh(i,n),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),_r(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return _r(t,"initialValue")&&(s.initialValue=a({property:e,value:t.initialValue,relative:!1})),s},wo=({authored:e,bgm:t,baselineBgm:n=t,property:o,propertyPath:a,renderedSound:r,resources:s,speed:i})=>{let l=Rc({property:o,authored:e,speed:i,propertyPath:a,normalizeValue:({value:c,relative:u})=>Mh({property:o,value:c,relative:u,bgm:t,resources:s,renderedSound:r})});return o==="pan"&&(l.keyframes=Vh({authoredInitialValue:e.initialValue,authoredKeyframes:e.keyframes,baselineBgm:n,compiledKeyframes:l.keyframes,bgm:t,resources:s,renderedSound:r})),l},Ac=({actionPath:e,compiled:t,property:n,propertyPath:o,renderedSound:a})=>{let r=a[n]??Zt[n],s=t.keyframes.at(-1);if(!Lh(s.value,r))throw new Error(`[${e}.audioEffects]
3
+ [${o}.keyframes] The final keyframe value must match the persistent BGM ${n} value.`);s.value=r},Cc=({selection:e,selectionPath:t,resources:n={}})=>{if(!e)return;let o=e.resourceId,a=`resources.audioEffects.${o}`,r=n.audioEffects?.[o];if(!r)throw new Error(`[${t}.resourceId]
4
4
  [${a}] Unknown audio effect resource "${o}".`);if(r.type!=="update")throw new Error(`[${t}]
5
- [${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let s=Sc(e,t),i={};for(let l of is)_r(r.tween,l)&&(i[l]=Oc({property:l,authored:r.tween[l],speed:s,propertyPath:`${a}.tween.${l}`}));return i},Cc=({bgm:e,resources:t={}})=>{let n=e?.audioEffects?.resourceId,o=t.audioEffects?.[n],a=o?.type==="update"?o.tween:o?.type==="transition"?o.next:void 0;if(!a||(e.sounds??[]).length===0)return e;let s=structuredClone(e);for(let i of is){if(!_r(a,i))continue;let l=a[i].keyframes.at(-1);typeof l?.value!="number"||!Number.isFinite(l.value)||l.relative===!0||(i==="volume"?s.volume=l.value:i==="pan"?s.pan=l.value:s.sounds.forEach(c=>{c.playbackRate=l.value}))}return s},Ac=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),Pc=e=>{if(!e)return e;let t={...e};return delete t.beginEffect,delete t.endEffect,t},qh=({occurrence:e,resources:t={},previousResources:n=t,nextResources:o=t,previousChannel:a,nextChannel:r,previousBgm:s,nextBgm:i})=>{if(!e?.selection)return null;let l=e.selection,c=e.actionPath??"bgm",u=l.resourceId,p=`resources.audioEffects.${u}`,m=t.audioEffects?.[u];if(!m)throw new Error(`[${c}.audioEffects.resourceId]
6
- [${p}] Unknown audio effect resource "${u}".`);let d=Sc(l,`${c}.audioEffects`),f=vc(a,c),h=vc(r,c);if(!f&&!h)return null;if(f&&h&&f.id!==h.id)throw new Error(`[${c}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let g=f?.id??h.id,y=Ec(f,h),w=xc(Pc(f),Pc(h));if(m.type==="transition"){if(y){if(w)return null;throw new Error(`[${c}.audioEffects]
7
- [${p}] Audio effect resource "${u}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let A={};for(let k of is){let E={},v=f?m.prev?.[k]:void 0;v&&(E.exit=bo({authored:v,bgm:s,property:k,propertyPath:`${p}.prev.${k}`,renderedSound:f,resources:n,speed:d}));let O=h?m.next?.[k]:void 0;O&&(E.enter=bo({authored:O,bgm:i,property:k,propertyPath:`${p}.next.${k}`,renderedSound:h,resources:o,speed:d}),kc({actionPath:c,compiled:E.enter,property:k,propertyPath:`${p}.next.${k}`,renderedSound:h})),Object.keys(E).length>0&&(A[k]=E)}return Object.keys(A).length===0?null:{...Ac(e,g),properties:A}}if(m.type!=="update")throw new Error(`[${p}.type] Unsupported audio effect type "${m.type}".`);if(!f||!h||!y)throw new Error(`[${c}.audioEffects]
8
- [${p}] Audio effect resource "${u}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let b={};for(let A of is){if(!_r(m.tween,A))continue;let k=`${p}.tween.${A}`,E=bo({property:A,authored:m.tween[A],speed:d,propertyPath:k,baselineBgm:s,bgm:i,resources:o,renderedSound:h}),v=h[A]??Zt[A];kc({actionPath:c,compiled:E,property:A,propertyPath:k,renderedSound:h}),(f[A]??Zt[A])!==v&&(b[A]={update:E})}return Object.keys(b).length===0?null:{...Ac(e,g),properties:b}},$c=e=>{let t=e.nextResources??e.resources,n=e.occurrence;if(!n?.selection)return[];let o=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=n.selection.resourceId,s=t?.audioEffects?.[r],i=(f,h)=>h?{...f,children:[h]}:null,l=(f,h,g,y)=>{if(!Array.isArray(f?.sounds))return f;let w=g?.children?.indexOf(y)??-1,b=f.sounds.filter(A=>h.sounds?.[A.resourceId])[w];return{...f,sounds:b?[b]:[]}},c=f=>f.map(({previousSound:h,nextSound:g},y)=>qh({...e,occurrence:y===0?n:{...n,occurrenceId:`${n.occurrenceId}:${y}`},resources:t,previousBgm:l(e.previousBgm,e.previousResources??t,e.previousChannel,h),nextBgm:l(e.nextBgm,t,e.nextChannel,g),previousChannel:i(e.previousChannel,h),nextChannel:i(e.nextChannel,g)})).filter(Boolean);if(!s||!["transition","update"].includes(s.type))return c([{previousSound:o[0],nextSound:a[0]}]);let u=new Map(o.map(f=>[f.id,f])),p=new Map(a.map(f=>[f.id,f]));if(s.type==="update"){let f=a.map(y=>({previousSound:u.get(y.id),nextSound:y})),h=f.find(({previousSound:y})=>!y);if(h)return c([h]);let g=o.find(y=>!p.has(y.id));return c(g?[{previousSound:g}]:f)}let m=[];for(let f of o){let h=p.get(f.id);(!h||!Ec(f,h))&&m.push({previousSound:f,nextSound:h})}for(let f of a)u.has(f.id)||m.push({nextSound:f});if(m.length>0)return c(m);let d=o.find(f=>{let h=p.get(f.id);return h&&!xc(f,h)});return c([{previousSound:d??o[0],nextSound:d?p.get(d.id):a[0]}])};var ae=e=>structuredClone(ge(e)?Xe(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),en=e=>e?.animations?.playback?.continuity==="persistent",Y=(e,t)=>ie(e??{},t)&&e[t]!==void 0,os=e=>Y(e,"alpha")||Y(e,"opacity"),Fh=e=>Y(e,"alpha")?e.alpha:e?.opacity,Vc=e=>(Y(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Bh=e=>e?.applyMode==="persistent",Uh="default",Yh=e=>Array.isArray(e?.channels)?e.channels.filter(Bh).map(ae):[],rn=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},zh=e=>os(e)||Y(e,"blur")||Y(e,"filters"),ko=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],qc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],vo=["animationName","animationSpeed","loop"],Xh=e=>Y(e,"transformId")||Y(e,"transform")||ko.some(t=>Y(e,t)),Ao=e=>e?.text&&Y(e.text,"content")&&Y(e.text,"textStyleId"),Po=e=>e?.layout&&Array.isArray(e.layout.elements),Hh=e=>Y(e,"text")||Y(e,"layout"),_c=(e,t)=>e.resourceId?!0:Ao(e)?!t?.text:Po(e)?!t?.layout:!1,Gh=e=>Y(e,"resourceId")||Ao(e)||Po(e),Nc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Kh=e=>Y(e,"resourceId")||Y(e,"sprites")&&Array.isArray(e.sprites)&&e.sprites.length>0,Wh=(e,t)=>{let n={...ae(e),...t};if(t.text&&e.text&&(n.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(n.transform={...ae(e.transform),...ae(t.transform)}),Y(t,"transform")){delete n.transformId;for(let o of ko)Y(t,o)||delete n[o]}else Y(t,"transformId")&&delete n.transform;return n},Jh=(e,t)=>{let n=[e.resourceId,e.text,e.layout].filter(o=>o!==void 0).length;if(n>1)throw n===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(Y(e,"text")&&!Ao(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(Y(e,"layout")&&!Po(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},jc=e=>qc.some(t=>Y(e,t)),Tc=e=>vo.some(t=>Y(e,t)),Qh=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let o of qc)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Fc=(e,t,n)=>{let o=e[n];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},Zh=(e,t)=>{if(!t)return e;let n=Y(e,"transform");for(let o of ko)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},eg=(e,t)=>(t&&(!Y(e,"opacity")&&Y(t,"opacity")&&(e.opacity=t.opacity),!Y(e,"blur")&&Y(t,"blur")&&(e.blur=ae(t.blur)),!Y(e,"filters")&&Y(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Bc=(e,t,n=[],{hasPatchFn:o=()=>!1,hasSubjectFn:a=(s,i)=>t(s,i),mergeItemFn:r}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let s=e.map((i,l)=>{let c=Fc(n,i,l),u=a(i,c),p=zh(i),m=Xh(i),d=o(i),f=ie(i,"animations"),h=Vc(ae(i));if(!u&&(p||m||d)&&c&&(h=r?r(c,h):{...ae(c),...h}),!f){let g=c?t(c):!1,y=t(h);!u&&g&&y&&en(c)?h.animations=ae(c.animations):delete h.animations}return u?h:eg(Zh(h,c),c)}).filter(i=>t(i)||i.animations);return{hasValidItems:s.length>0,processedItems:s}},rg=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},Uc=e=>!!e?.character&&ie(e.character,"sprite"),tg=e=>{let t={},n=!1,o=rg(e);return o!==void 0&&(t.name=o,n=!0),Uc(e)&&(t.sprite=ae(e.character.sprite),n=!0),n?t:void 0},Dc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Lc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:n&&!ie(t,"characterId"),Mc=({previousCharacter:e,characterFields:t,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},c=t??{},u=s&&!n,p=u&&!r;return ie(c,"name")?i.name=c.name:(o&&!n||u)&&ie(l,"name")&&(i.name=ae(l.name)),ie(c,"sprite")?i.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(i.sprite=ae(l.sprite)),Object.keys(i).length>0?i:void 0},ng=({dialogueState:e,content:t,append:n=!1})=>{if(!n||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...o,...t]},sg=()=>({}),ig=(e,t)=>{if(!t.screen)return;let n=os(t.screen),o=Y(t.screen,"blur"),a=ie(t.screen,"animations");if(!n&&!o){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=Fh(t.screen):Y(r,"opacity")&&(s.opacity=r.opacity),o?s.blur=ae(t.screen.blur):Y(r,"blur")&&(s.blur=ae(r.blur)),ie(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ie(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},og=(e,t)=>{if(t.background){let n=Y(t.background,"resourceId"),o=Y(t.background,"colorId"),a=os(t.background),r=Y(t.background,"blur"),s=Y(t.background,"filters"),i=Y(t.background,"transformId"),l=jc(t.background),c=Tc(t.background),{animationsOnly:u,state:p}=rn(t.background,f=>Y(f,"resourceId")||Y(f,"colorId")||os(f)||Y(f,"blur")||Y(f,"filters")||Y(f,"transformId")||jc(f)||Tc(f));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!n&&!o&&!a&&!r&&!s&&!i&&!l&&!c){delete e.background;return}let m=e.background,d=Vc(ae(t.background));if(!n&&m?.resourceId){d.resourceId=m.resourceId,!ie(d,"transformId")&&m.transformId&&(d.transformId=m.transformId);for(let f of vo)!Y(d,f)&&Y(m,f)&&(d[f]=m[f])}n||Qh(d,m,{hasAuthoredTransformId:i}),!n&&!o&&m?.colorId&&(d.colorId=m.colorId),!n&&!a&&Y(m,"opacity")&&(d.opacity=m.opacity),!n&&!r&&Y(m,"blur")&&(d.blur=ae(m.blur)),!n&&!s&&Y(m,"filters")&&(d.filters=ae(m.filters)),ie(d,"resourceId")&&d.resourceId===void 0&&delete d.resourceId,ie(d,"colorId")&&d.colorId===void 0&&delete d.colorId,ie(d,"animations")&&d.animations===void 0&&delete d.animations,ie(d,"transformId")&&d.transformId===void 0&&delete d.transformId,ie(d,"opacity")&&d.opacity===void 0&&delete d.opacity,ie(d,"blur")&&d.blur===void 0&&delete d.blur,ie(d,"filters")&&d.filters===void 0&&delete d.filters;for(let f of vo)ie(d,f)&&d[f]===void 0&&delete d[f];if(!d.resourceId&&!d.colorId){delete e.background;return}!n&&m?.resourceId===d.resourceId&&m?.transformId===d.transformId&&!ie(d,"animations")&&en(m)&&(d.animations=ae(m.animations)),e.background=d}else e.background?.animations&&!en(e.background)&&(e.background.animations={})},ag=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(Dc(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=Lc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=Mc({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=rn(t.dialogue.ui,m=>!!m.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=t.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&ng({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Lc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=ie(t.dialogue,"characterId"),i=tg(t.dialogue),l=Uc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=Mc({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Dc(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},lg=(e,t)=>{let n=Yh(e.sfx);if(!t.sfx){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=n.filter(s=>s.id!==Uh);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(t.sfx.channels.length===0){delete e.sfx;return}let o=new Set(t.sfx.channels.map(r=>r.id)),a=n.filter(r=>!o.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},cg=(e,t,n)=>{if(t.bgm){let o=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!o||o&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Cc({bgm:ae(t.bgm),resources:n}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},ug=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{Jh(r,Fc(n,r,s))});let{hasValidItems:o,processedItems:a}=Bc(t.visual.items,_c,n,{hasPatchFn:Hh,hasSubjectFn:Gh,mergeItemFn:Wh});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!_c(n)||!en(n))?{...n,animations:{}}:n))},pg=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!Nc(a)||!en(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=Bc(t.character.items,Nc,e.character?.items||[],{hasSubjectFn:Kh});n?e.character={items:o}:delete e.character},fg=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},dg=(e,t)=>{if(t.layout){let{animationsOnly:n,state:o}=rn(t.layout,a=>!!a.resourceId);if(n){e.layout=o;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},mg=(e,t)=>{if(t.choice){let{animationsOnly:n,state:o}=rn(t.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...o};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},yg=(e,t)=>{if(t.form){let{animationsOnly:n,state:o}=rn(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},hg=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},gg=(e,t)=>{if(t.voice){let n=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!n||n&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},bg=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},et=(e,{resources:t,initialState:n}={})=>Hn(()=>n??sg(),[bg,ig,og,lg,(r,s)=>cg(r,s,t),ug,ag,pg,fg,dg,mg,yg,hg,gg])(e);var Yc=new WeakMap,qe=(e,t)=>{let n=ge(e)?Xe(e):e;if(!Array.isArray(n))return-1;if(!Object.isFrozen(n))return n.findIndex(a=>a.id===t);let o=Yc.get(n);return o||(o=new Map,n.forEach((a,r)=>{o.has(a.id)||o.set(a.id,r)}),Yc.set(n,o)),o.get(t)??-1};var zc=Object.freeze({}),wg=64,Ig=16,Xc=4,vg=8,Hc=new WeakMap,as=(e,t,n,o)=>{e.delete(t),e.set(t,n),e.size>o&&e.delete(e.keys().next().value)},kg=(e,t)=>{if(!Array.isArray(t.lines)||!Object.isFrozen(e)||!Object.isFrozen(t)||!Object.isFrozen(t.lines)||e.resources&&!Object.isFrozen(e.resources))return null;let n=Hc.get(e);n||(n=new Map,Hc.set(e,n));let o=n.get(t);return o||(o={checkpoints:new Map,recent:new Map}),as(n,t,o,vg),o},Gc=(e,t,n,o=0)=>{let a=t?.lines??[],r=t&&Array.isArray(a)?kg(e,t):null,i=qe(a,n)+o;if(i<0)return o<0?null:zc;if(!r)return et(a.slice(0,i+1).map(u=>u.actions||{}),{resources:e.resources});let l=-1,c=zc;for(let u of[r.checkpoints,r.recent])for(let[p,m]of u)p<=i&&p>l&&(l=p,c=m);for(let u of[i-1,i])u<=l||(c=et(a.slice(l+1,u+1).map(p=>p.actions||{}),{resources:e.resources,initialState:c}),(u+1)%wg===0&&as(r.checkpoints,u,c,Ig),as(r.recent,u,c,Xc),l=u);return as(r.recent,i,c,Xc),c};var wt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Wr(e,t);return n&&typeof n=="object"?e:n};var Ag=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"}}),Nr=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}),tn=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Pg=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Eo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Kc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),xo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Wc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Eg=(e,t)=>{let n=Pg[e];if(n==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(t!==null&&typeof t!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},ls=(e,t)=>{if(Eg(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},So=(e={})=>{let t=e?.config;if(t===void 0)return{...Nr};if(!Wc(t))throw new Error("projectData.config must be an object");let n=Object.keys(t).find(i=>i!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=t.runtimeDefaults;if(o===void 0)return{...Nr};if(!Wc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Kc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...Nr};return Kc.forEach(i=>{o[i]!==void 0&&(s[i]=ls(i,o[i]))}),s},xg=(e,t)=>{if(t.startsWith("global.")){let n=t.slice(7);return e?.global?.[n]}if(t.startsWith("context.runtime.")){let n=t.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[n]}},br=e=>Object.fromEntries(Object.entries(Ag).map(([t,n])=>{let o=xg(e,n.source),a=o!==void 0?o:Nr[t]??tn[t];return[t,a]})),or=(e,t)=>br(e)[t],Jc=(e={})=>Object.fromEntries(Eo.map(t=>[t,e[t]??Nr[t]]));var It=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}),wr=Object.freeze({BEHIND_BACKGROUND:It.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:It.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:It.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:It.VISUAL_BEHIND_CHOICE,FOREGROUND:It.VISUAL_FOREGROUND}),Oo=wr.BEHIND_DIALOGUE,Ro=Object.freeze(Object.values(wr).sort((e,t)=>e-t));var Sg={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:fo},Og=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,nn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return nn(t);let[n]=Object.keys(t),o=Og.exec(n);if(!o)return nn(t);let[,a,r,s]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[i]:nn(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,nn(n)])),Ir=(e,t)=>{let n={functions:Sg};return Wr(nn(e),t,n)},fu=({animationType:e,animationId:t,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},Rg=({id:e,targetId:t,animation:n,playback:o,animationPath:a="animation"})=>{let r=structuredClone(n);if(fu({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let s=Ng(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?gu(r):null;if(s.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&r.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&(!Number.isFinite(i)||i<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=s}}return r},Cg=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return fu({animationType:e.type,animationId:t,animationPath:n}),e.type},$g=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},_g=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Ng=(e,t="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${t}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${t}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${t}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${t}] playback.loop must be a boolean.`);let n={};return e.continuity!==void 0&&(n.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(n.speed=e.speed),e.loop===!0&&(n.loop=!0),Object.keys(n).length>0?n:void 0},jg=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},rr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),du=(e={})=>rr(e,"alpha")&&typeof e.alpha=="number"?e.alpha:rr(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,mu=e=>e?.playback?.continuity==="persistent",Lo=e=>Array.isArray(e)?e.map(Lo):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=Lo(e[n]),t),{}),fs=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(Lo(t))},yu=(e=[])=>e.filter(t=>mu(t)).map(t=>structuredClone(t)),hu=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let o=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+o},0):0,Co=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,hu(n)),0),gu=e=>Math.max(Co(e?.tween),Co(e?.prev?.tween),Co(e?.next?.tween),hu(e?.mask?.progress)),bu=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:gu(e)/jg(e),Tg=e=>e.some(t=>t?.playback?.loop===!0),Qc=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let n=new Set(t.map(fs).filter(Boolean));return e.some(o=>{if(!mu(o))return!1;let a=fs(o);return a?n.has(a):!1})},tr=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:Tg(e)||r&&!t||Qc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:Qc({animationInstances:e,activePersistentAnimations:a}),wu=(e,t,n,o,a)=>{if(e===void 0)return!0;let r=a.slice(0,o).filter(i=>i?.id===n).length,s=e?.[t]?.items?.filter(i=>i?.id===n).at(r);return rr(s??{},"animations")},Dg=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Lg=(e,t)=>{if(Dg(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Mg=({resources:e,animationId:t,playback:n,instanceId:o,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?Rg({id:o,targetId:a,animation:s,playback:n,animationPath:r}):null},Mo=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${t} must be an array of objects`);return e},Vg=({content:e,path:t,variables:n})=>Mo(e,t).reduce((o,a)=>{let r=wt(a.text,{variables:n});return o+`${r??""}`.length},0),Zc=(e=[])=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,(t.get(n.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n))},eu=(e,t=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let o=e?.sprites?.map(({resourceId:a})=>a)||[];return o.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${o.join("-")}`},kt=(e,t)=>{if(t.transformId&&t.transform)throw new Error(`Visual item "${t.id}" cannot define both transformId and transform`);if(t.transform)return t.transform;if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId or transform`);let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},qg=(e,t={})=>{if(!t?.transformId)return;let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},Fg=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Bg=(e={})=>Fg.some(t=>rr(e,t)),Iu=(e={},t)=>{if(t){if(e.images?.[t])return"sprite";if(e.videos?.[t])return"video";if(e.spritesheets?.[t])return"spritesheet-animation";if(e.layouts?.[t])return"container"}},us=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Ug=(e={})=>e.textStyles||{},Yg=(e={})=>e.images||{},zg=.5,Xg=(e={},t,n)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${n}'`);return t}return Object.keys(e.animations??{})[0]},Xo=({id:e,resourceId:t,spritesheet:n,animationName:o,animationSpeed:a,loop:r,width:s,height:i,transform:l={}}={})=>{let c=Xg(n,o,t),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:i??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??zg,loop:r??u.loop??!0}}},vu=({id:e,item:t,resources:n={}}={})=>{let o=n.images?.[t.resourceId];if(o)return{type:"sprite",id:e,src:o.fileId,width:o.width,height:o.height,x:0,y:0};let a=n.spritesheets?.[t.resourceId];if(a)return Xo({id:e,resourceId:t.resourceId,spritesheet:a,animationName:t.animationName,animationSpeed:t.animationSpeed,loop:t.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${t.resourceId}`)},Hg=(e={})=>e.colors||{},Gg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,sn=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,At=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},$o=(e,t,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);return e},_o=(e,t,n,o,{minimum:a}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let r=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${t} for text style "${n}" must be ${r}`)}return e},ys=(e,t)=>{if(typeof e!="string"||!Gg.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},ru=(e,t,n)=>{let o=ys(e,n);if(t===1)return o;let a=Number.parseInt(o.slice(1,3),16),r=Number.parseInt(o.slice(3,5),16),s=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${r}, ${s}, ${t})`},Kg=(e={},t)=>{let n=Ug(e)?.[t];if(!n)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=$o(n.colorAlpha,"colorAlpha",t),i={fontFamily:Array.isArray(n.fontId)?a.join(", "):a[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:ru(r.hex,s,`Color "${n.colorId}" for text style "${t}"`)};if(n.align!==void 0&&(i.align=n.align),n.wordWrap!==void 0&&(i.wordWrap=n.wordWrap),n.breakWords!==void 0&&(i.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(i.wordWrapWidth=n.wordWrapWidth),n.strokeColorId){let l=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=$o(n.strokeAlpha,"strokeAlpha",t);i.strokeColor=ru(l.hex,c,`Stroke color "${n.strokeColorId}" for text style "${t}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth),n.shadow!==void 0){let l=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);i.shadow={color:ys(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:$o(n.shadow.alpha,"shadow.alpha",t),blur:_o(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:_o(n.shadow.offsetX,"offsetX",t,2),offsetY:_o(n.shadow.offsetY,"offsetY",t,2)}}return i},Pt=e=>Array.isArray(e)?e.map(Pt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Pt(n)])),Vo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Vo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=Pt(r);continue}a!=="textStyleId"&&(o[a]=Vo(r,t,sn(n,a)))}return e.textStyleId!==void 0&&(At(e.textStyleId,n,"textStyleId"),o.textStyle=Kg(t,e.textStyleId)),o},Ho=(e={},t)=>{let n=Hg(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return ys(n.hex,`Color "${t}"`)},ku=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",No=(e,t,n)=>{let o=e?.[t];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${n}". Use ${ku(`${t}.fill`)} instead`)},Wg=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>on(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(o[a]=on(r,t,sn(n,a)));return e.colorId!==void 0&&(At(e.colorId,n,"colorId"),o.fill=Ho(t,e.colorId)),o},on=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>on(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${n}". Use ${ku("fill")} instead`);No(e,"hover",n),No(e,"click",n),No(e,"rightClick",n)}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=Pt(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=Wg(r,t,sn(n,a));continue}o[a]=on(r,t,sn(n,a))}}return e.type==="rect"&&e.colorId!==void 0&&(At(e.colorId,n,"colorId"),o.fill=Ho(t,e.colorId)),o},jo=(e={},t)=>{let n=Yg(e)?.[t];return n||null},Au=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",tu=(e,t,n,o)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,o))throw new Error(`Inline ${t}.${o} is not allowed in sprite layout elements at "${n}". Use ${Au(`${t}.${o}`)} instead`)},nu=(e,t,n)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},qo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>qo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${Au(a)} instead`);tu(e,"hover",n,"src"),tu(e,"click",n,"src")}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=Pt(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=qo(r,t,sn(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){At(e.imageId,n,"imageId");let a=jo(t,e.imageId),r=a?.fileId??e.imageId;o.src=r,o.width===void 0&&a?.width!==void 0&&(o.width=a.width),o.height===void 0&&a?.height!==void 0&&(o.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(At(e.hoverImageId,n,"hoverImageId"),nu(o,"hover",jo(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(At(e.clickImageId,n,"clickImageId"),nu(o,"click",jo(t,e.clickImageId)?.fileId??e.clickImageId)),o},Jg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),ps=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>ps(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=Pt(e),o=typeof e.type=="string";(o||t)&&rr(e,"opacity")&&(rr(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])rr(e,a)&&(n[a]=ps(e[a]));for(let[a,r]of Object.entries(e))Jg(a)&&(n[a]=ps(r,{isElementPatch:o||t}));return n},Go=(e,t={},n="root")=>ps(qo(on(Vo(e,t,n),t,n),t,n)),vr=Go,tt=(e=[])=>e.find(t=>t.id==="story"),Qg="#000000",Fo="bg-cg-background-color",Zg=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?ys(n?.backgroundColor??Qg,"screen.backgroundColor"):Ho(e,t.colorId),Pu=(e={})=>du(e),eb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ko=(e={})=>Array.isArray(e.filters)?e.filters:void 0,su=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Pu(e),o=eb(e),a=Ko(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),o&&(r.blur=o),a&&(r.filters=a),r},rb=(e={})=>du(e),tb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Eu=(e={})=>{let t=rb(e),n=tb(e),o={};return t!==void 0&&(o.alpha=t),n&&(o.blur=n),o},rt=(e={})=>{let t=Eu(e),n=Ko(e);return n&&(t.filters=n),t},iu=(e,t,n,o)=>{let a=t[n]??e[n];return t[o]??e[o]??!1?(a??1)*-1:a},ar=(e={},t={})=>{let n={x:t.x??e.x,y:t.y??e.y,anchorX:t.anchorX??e.anchorX,anchorY:t.anchorY??e.anchorY,rotation:t.rotation??e.rotation,scaleX:iu(e,t,"scaleX","flipX"),scaleY:iu(e,t,"scaleY","flipY")},o=t.originX??e.originX,a=t.originY??e.originY;return o!==void 0&&(n.originX=o),a!==void 0&&(n.originY=a),n},nb=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],Wo=(e={})=>e.text&&rr(e.text,"content")&&rr(e.text,"textStyleId"),Jo=(e={})=>e.layout&&Array.isArray(e.layout.elements),ou=(e={})=>{if(e.resourceId)return e.resourceId;if(Wo(e))return"text";if(Jo(e))return"inline-layout"},au=(e,t={})=>typeof e=="string"?t.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?t.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return t.images?.[n]?.fileId??n;if(!n||typeof n!="object"||Array.isArray(n))return n;if(n.imageId){let{imageId:o,...a}=n;return{...a,src:t.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,sb=({item:e,particle:t,resources:n})=>{let o=kt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=au(r,n)),a.texture!==void 0&&(a.texture=au(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...ar(o,e)};return Object.assign(s,rt(e)),s},ib=e=>{let t=[e.resourceId,e.text,e.layout].filter(n=>n!==void 0).length;if(t>1)throw t===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(e.text&&!Wo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Jo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of nb)if(rr(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},ob=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:Fo,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Zg({resources:e,background:t,screen:n})};if(o){let r=Pu(t);r!==void 0&&(a.alpha=r);let s=Ko(t);s&&(a.filters=s)}return a},ab=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,lu=({resources:e={},resourceId:t,colorId:n})=>{let o=Iu(e,t);return t&&(o||n===void 0)?{resourceId:t,targetId:us({resourceId:t,kind:o})}:n!==void 0?{resourceId:Fo,targetId:Fo}:{resourceId:void 0,targetId:void 0}},xu=100,jr=xu,lb="channel:bgm",cb="channel:music-room",ub="music-room:player",pb="channel:voice",fb="default",ds=(e,t,n)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let r=n?` in ${n}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}o.add(a)})},Su=(e,t)=>e*t/xu,Qo=(e={},t)=>e?.[t]??Nr[t],Zo=(e={},t,n=jr)=>Su(n,Qo(e,t)),hs=({id:e,volume:t,muted:n,pan:o,loop:a,playback:r,interruption:s,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),s!==void 0&&(c.interruption=s),c},cs=(e,t,n,o)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:o,db=["muted","pan","playbackRate","startAt","endAt"],gs=({id:e,sound:t,resource:n,projectResources:o,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:s=!1})=>{let i={id:e,type:"sound",src:n.fileId,loop:cs(t,n,"loop",r),volume:cs(t,n,"volume",jr),startDelayMs:cs(t,n,"startDelayMs",0)};db.forEach(c=>{let u=cs(t,n,c,void 0);u!==void 0&&(i[c]=u)}),t.playback!==void 0&&(i.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=Rc({selection:t[c],selectionPath:`${a}.${c}`,resources:o});u&&!s&&(i[c]=u)}let l=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<l)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${l}).`);return i},mb=e=>Math.max(-1,Math.min(1,e)),yb=({node:e,bgm:t,sound:n,resource:o,usesLegacySound:a})=>{a||(e.volume=Su(t.volume??jr,e.volume??jr));let r=t.muted!==void 0,s=n.muted!==void 0||o.muted!==void 0;(r||s)&&(e.muted=t.muted===!0||e.muted===!0);let i=t.pan!==void 0,l=n.pan!==void 0||o.pan!==void 0;return(i||l)&&(e.pan=mb((t.pan??0)+(e.pan??0))),e},Ke=({variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:r=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:b,skipTransitionsAndAnimations:A}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},E=Ib({dialogueState:s,includeInactiveAdvDialogue:i,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g,characters:y};return E&&(v.dialogue=E,v.dialogueLines=E.lines),v},cu=100,ms=(e,t)=>{if(Array.isArray(e))return e.map(o=>ms(o,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=ms(n[o],t)}),n.type==="text-revealing"?t(n):n},hb=e=>ms(e,t=>({...t,revealEffect:"none"})),gb=e=>ms(e,t=>{let n=Number(t.speed??t.displaySpeed),o=Number.isFinite(n)?Math.max(n,cu):cu;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),Tr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?hb(e):n?gb(e):e,Ou=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),Bo=e=>{if(Array.isArray(e))return e.map(Bo);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Bo(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let o=n.actions,a=o&&typeof o=="object"&&!Array.isArray(o)&&Object.prototype.hasOwnProperty.call(o,"nextLine")?{...o.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...n,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},bb=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),uu="submit",To=(e,t,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},r=n.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...o,actions:r}}},Uo=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>Uo(c,t,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===uu,r=o&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Uo(u,t,c==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let c=t?.fields?.[l.field];if(c){let u={updateFormField:{formKey:t.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:To(l.change,u),submit:To(l.submit,t.submitActions)}}}return l.formRole===uu||r?{...l,click:To(l.click,t.submitActions,{replaceActions:!0})}:l},Yo=(e,t)=>{if(Array.isArray(e))return e.map(o=>Yo(o,t));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=Yo(a,t);for(let o of bb){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},zo=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,s=Gn({characterId:e,character:t,characterName:n,characters:o,variables:a});return{...r||{},...t||{},name:s}},Ru=(e=[],t={},n={})=>e.map(o=>{let a=zo({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:t,variables:n}),r=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(s=>s?.text??"").join(""):"";return{...o,text:r,character:a,characterName:a.name}}),wb=e=>!(!e||e.mode==="adv"&&e.content===void 0),Ib=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:o,runtime:a}={})=>{if(!t&&!wb(e))return;let r=e.content===void 0?[{text:""}]:Mo(e.content,"dialogue.content"),s=e.content===void 0?0:Vg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??Nr.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,m)=>{let d=Mo(p.content,`dialogue.lines[${m}].content`),f=zo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:d.map(h=>({...h,text:wt(h.text,{variables:o})})),character:f,characterName:f.name}}),u=zo({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:wt(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},ea=({container:e,resources:t,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=Ir(e,n);return vr(Tr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},Do=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),pu=({renderStateKeyboard:e,keyboard:t,phase:n})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([o,a])=>{let r=e[o]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...r,keydown:{payload:Do(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:Do(a.keyup)});return}e[o]={...r,[n]:{payload:Do(a)}}})},vb=(e={},t={})=>{let n={};return pu({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),pu({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},kr=({animationsDef:e,resources:t,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:r,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:w})=>{let b=Mg({resources:t,animationId:d,playback:f,instanceId:y,targetId:w,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,m=a&&r&&a===r;Lg(e,s);let d=$g(e),f=_g(e),h=t?.animations?.[d],g=Cg(h,{animationId:d,animationPath:s});if(g==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(g==="transition"){let y=`${i}-animation-transition`,w=f?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&m)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},kb=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Ab=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:w,canRollback:b,form:A,saveSlots:k=[]})=>{let{elements:E,animations:v}=e;if(t.background){let O=o===void 0?!0:rr(o?.background??{},"animations"),L=E.find(oe=>oe.id==="story");if(!L)return e;let R=qg(a,t.background),T=R||Bg(t.background),U=n?.background?.resourceId,N=n?.background?.colorId,H=t.background.resourceId??(t.background.animations?U:void 0),fe=t.background.colorId??(t.background.animations?N:void 0),M=ab(a,H),K={...t.background,colorId:fe};if((fe!==void 0||M)&&L.children.push(ob({resources:a,background:K,screen:r,includeAlpha:!M})),H){let{images:oe={},videos:se={},spritesheets:ue={}}=a,Q=Iu(a,H),$;if(Q==="sprite"?$=oe[H]:Q==="video"?$=se[H]:Q==="spritesheet-animation"&&($=ue[H]),$){let j=Q==="video",F=Q==="spritesheet-animation",W={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...R},de={...su(t.background,{includeDefaultAlpha:!0}),...ar(W,t.background)},ve;F?ve=Xo({id:us({resourceId:H,kind:Q}),resourceId:H,spritesheet:$,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:de}):ve={id:us({resourceId:H,kind:Q}),type:j?"video":"sprite",src:$.fileId,width:$.width,height:$.height,...de},j&&(ve.loop=t.background.loop??!1,ve.volume=$.volume??50),ve&&L.children.push(ve)}}if(H){let{layouts:oe={}}=a,se=oe[H];if(se){let ue={id:us({resourceId:H,kind:"container"}),type:"container",children:se.elements,...su(t.background)};T&&Object.assign(ue,ar({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...R},t.background));let Q=Ir(ue,Ke({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:w,canRollback:b,form:A,characters:a.characters||{},skipTransitionsAndAnimations:i}));L.children.push(vr(Tr(Q,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let le=lu({resources:a,resourceId:U,colorId:N}),X=lu({resources:a,resourceId:H,colorId:fe}),te=kr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:X.resourceId,previousTargetId:le.targetId,currentTargetId:X.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});tr({animationInstances:te,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:O})&&v.push(...te)}return e},Pb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(w=>w.id==="story");if(!p)return e;let m=t.character.items||[],d=n?.character?.items||[],f=Zc(m),h=Zc(d),g=new Map,y=new Map;for(let w=0;w<d.length;w++){let b=d[w],A=g.get(b.id)??[];A.push(w),g.set(b.id,A)}for(let w=0;w<m.length;w++){let b=m[w],{transformId:A,sprites:k}=b,E=y.get(b.id)??0;y.set(b.id,E+1);let v=g.get(b.id)?.[E]??-1,O=d[v],L=O?.sprites&&O.sprites.length>0,R=k&&k.length>0,T=v>=0?eu(O,v,h):void 0,U=R?eu(b,w,f):void 0,N=wu(o,"character",b.id,w,m),H=kr({animationsDef:b.animations,resources:a,previousResourceId:T,currentResourceId:U,previousTargetId:T,currentTargetId:U,animationPath:`character.items[${w}].animations`,idPrefix:U??T??`character-${w}`});if(b.animations&&!k&&!A&&L&&tr({animationInstances:H,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:N})){u.push(...H);continue}if(b.animations&&!k&&!A)continue;if(!k||k.length===0||!A){console.warn("Character item missing sprites or transformId:",b);continue}let fe=a.transforms[A];if(!fe){console.warn("Transform not found:",A);continue}let M={type:"container",id:U,...ar(fe,b),...rt(b),children:[]};for(let K of k){let le=vu({id:`${U}-${K.id}`,item:K,resources:a});le&&M.children.push(le)}p.children.push(M),tr({animationInstances:H,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:N})&&u.push(...H)}}return e},Cu=(e,t)=>{if(!Ro.includes(e))throw new Error(`${t} must be one of: ${Ro.join(", ")}.`)},Eb=(e,t)=>{let n=!!e.resourceId||Wo(e)||Jo(e),o=e.layer??(n?void 0:t?.layer)??Oo;return Cu(o,`Visual item "${e.id}" layer`),o},xb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:m,restoredPersistentAnimations:d,autoMode:f,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:w,form:b,saveSlots:A=[],visualLayer:k})=>{let{elements:E,animations:v}=e;if(t.visual&&a){let O=E.find(U=>U.id==="story");if(!O)return e;let L=t.visual.items,R=n?.visual?.items||[],T=Ke({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:A,dialogueState:t.dialogue,isLineCompleted:r,autoMode:f,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:w,form:b,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&Cu(k,"visualLayer");for(let[U,N]of L.entries()){let H=R.find(se=>se.id===N.id),fe=wu(o,"visual",N.id,U,L),M=Eb(N,H);if(k!==void 0&&M!==k)continue;if(ib(N),N.layout){let se=kt(a,N),ue={id:`visual-${N.id}`,type:"container",children:structuredClone(N.layout.elements),...ar(se,N)};Object.assign(ue,rt(N)),O.children.push(ea({container:ue,resources:a,templateData:T,isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}))}if(N.text){let se=kt(a,N),ue={...structuredClone(N.text),id:`visual-${N.id}`,type:"text",...ar(se,N)};Object.assign(ue,rt(N)),O.children.push(vr(Ir(ue,T),a))}if(N.resourceId){let{images:se={},videos:ue={},spritesheets:Q={}}=a,$=Q[N.resourceId];if($){let j=kt(a,N),F=rt(N),W=Xo({id:`visual-${N.id}`,resourceId:N.resourceId,spritesheet:$,animationName:N.animationName,animationSpeed:N.animationSpeed,loop:N.loop,width:N.width,height:N.height,transform:{...ar(j,N),alpha:F.alpha??N.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});W&&O.children.push(structuredClone(W))}else{let j=se[N.resourceId]||ue[N.resourceId];if(j){let F=ue[N.resourceId]!==void 0,W=kt(a,N),de={id:`visual-${N.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...ar(W,N)};Object.assign(de,rt(N)),F&&(de.loop=j.loop??!1,de.volume=j.volume??50),O.children.push(de)}}}let K=!!(a.spritesheets?.[N.resourceId]||a.images?.[N.resourceId]||a.videos?.[N.resourceId]);if(N.resourceId&&!K){let se=a.particles?.[N.resourceId];se&&O.children.push(sb({item:N,particle:se,resources:a}))}let le=!!a.particles?.[N.resourceId];if(N.resourceId&&!K&&!le){let{layouts:se={}}=a,ue=se[N.resourceId];if(ue){let Q=kt(a,N),$={id:`visual-${N.id}`,type:"container",children:structuredClone(ue.elements),...ar(Q,N)};Object.assign($,rt(N));let j=Ir($,T);O.children.push(vr(Tr(j,{isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}),a))}}let X=ou(H),te=ou(N),oe=kr({animationsDef:N.animations,resources:a,previousResourceId:X,currentResourceId:te,previousTargetId:X?`visual-${N.id}`:void 0,currentTargetId:te?`visual-${N.id}`:void 0,animationPath:`visual.items[${N.id}].animations`,idPrefix:N.id});tr({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:m,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:fe})&&v.push(...oe)}}return e},vt="dialogue-character-sprite",Sb=(e,{presentationState:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=tt(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=Bt(c),m=Bt(u),d=kr({animationsDef:c?.animations,resources:o,previousResourceId:m?vt:void 0,currentResourceId:p?vt:void 0,previousTargetId:m?vt:void 0,currentTargetId:p?vt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&tr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e;let f=o.transforms?.[c.transformId];if(!f)return console.warn("Transform not found:",c.transformId),e;let h={type:"container",id:vt,...ar(f),children:[]};for(let g of c.items){let y=vu({id:`${vt}-${g.id}`,item:g,resources:o});y&&h.children.push(y)}return l.children.push(h),tr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e},Ob=(e,{presentationState:t,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:w,activePersistentAnimations:b,saveSlots:A=[]})=>{let{elements:k,animations:E}=e;if(!t.dialogue||a)return e;let v=k.find(L=>L.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:L={}}=o,R=L[t.dialogue.ui.resourceId];if(R){let T={elements:R.elements},U=Ke({variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:w,saveSlots:A,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),N=Ir(T,U),H=vr(Tr(N?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(H))for(let fe of H)v.children.push(fe);else H&&v.children.push(H)}}Sb(e,{presentationState:t,previousPresentationState:n,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let O=kr({animationsDef:t.dialogue.ui?.animations,resources:o,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return tr({animationInstances:O,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&E.push(...O),e},Rb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,form:y,activePersistentAnimations:w,saveSlots:b=[]})=>{let{elements:A,animations:k}=e;if(t.choice&&o){let E=tt(A);if(!E)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let L={elements:v.elements},R=Ir(L,{...Ke({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f??!!t.choice,isFormVisible:h,canRollback:g,form:y,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),T=Bo(vr(Tr(R?.elements,{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(T))for(let U of T)E.children.push(U);else T&&E.children.push(T)}let O=kr({animationsDef:t.choice.animations,resources:o,previousResourceId:n?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});tr({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},Cb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,activePersistentAnimations:y,saveSlots:w=[],form:b})=>{let{elements:A,animations:k}=e;if(!b?.resourceId||!o)return e;let E=tt(A);if(!E)return e;let v=o?.layouts?.[b.resourceId];if(!v)return console.warn(`Form layout not found: ${b.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},L={...Ke({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},R=Ir(O,L),T=Yo(vr(Tr(Uo(R,b),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o),b);T&&E.children.push(T);let U=kr({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 tr({animationInstances:U,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...U),e},$b=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],skipTransitionsAndAnimations:g})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=vb(y.keyboard,y.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(y.elements)||y.elements.length===0)return e;let b=tt(e.elements);if(!b)return e;let A={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return b.children.push(ea({container:A,resources:n,templateData:Ke({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},ra=({presentationState:e,previousBgmRender:t,resources:n={},runtime:o,variables:a,musicRoomPlayer:r,skipTransitionsAndAnimations:s=!1})=>{if(e?.bgm&&n){let i=e.bgm,l=!Array.isArray(i.sounds),c=ss(i),u=!l&&i.loop===!0,p=[];if(l||ds(c,"BGM sound"),u){let f=c.find(h=>h.loop===!0);if(f)throw new Error(`BGM sound "${f.id}" cannot loop inside a looping BGM channel.`)}let m=Ic({bgm:i,resources:n,previousBgmRender:t});if(c.forEach(f=>{let h=n.sounds?.[f.resourceId];if(!h)return;let g=u?{...f,loop:f.loop??!1}:f;p.push(yb({node:gs({id:m.get(f.id),sound:g,resource:h,projectResources:n,soundPath:`bgm.sounds[${JSON.stringify(f.id)}]`,defaultLoop:!u,skipTransitionsAndAnimations:s}),bgm:i,sound:g,resource:h,usesLegacySound:l}))}),p.length===0)return null;let d=Ke({variables:a,runtime:o}).runtime;return hs({id:lb,volume:Qo(d,"musicVolume"),muted:!1,pan:0,loop:l?void 0:i.loop,playback:r?.bgmPlayback,interruption:i.interruption,children:p,runtime:d})}return null},_b=(e,t)=>{if(!tt(e.elements))return e;let o=ra(t);return o&&e.audio.push(o),e},Nb=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:n})=>(t?.length>0&&!n&&(e.audioEffects=structuredClone(t)),e),jb=(e,{resources:t={},runtime:n,variables:o,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let s=r.tracks.find(u=>u.id===a.trackId),i=s?t.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=Ke({variables:o,runtime:n}).runtime,c=gs({id:ub,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(hs({id:cb,volume:Zo(l,"musicVolume",jr),children:[c],runtime:l})),e},Tb=(e,{presentationState:t,resources:n,runtime:o,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&n){let s=t.sfx,i=Array.isArray(s.channels)?s.channels:[],l=i.map(c=>({channel:c,usesLegacyChannel:!1}));ds(i,"SFX channel"),Array.isArray(s.items)&&l.push({channel:{id:fb,sounds:s.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,m=[];if(u||ds(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let d=c.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((d,f)=>{let h=n.sounds?.[d.resourceId];if(!h)return;let g=p?{...d,loop:d.loop??!1}:d;m.push(gs({id:u?ir("sfx","default",f,d.id):ir("sfx",c.id,d.id),sound:g,resource:h,projectResources:n,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(d.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),m.length!==0&&r.push(hs({id:ir("channel","sfx",c.id),volume:Zo(o,"soundVolume",c.volume??jr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:m,runtime:o}))})}return e},Db=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},Lb=(e,{presentationState:t,resources:n,currentSceneId:o,runtime:a,variables:r,skipTransitionsAndAnimations:s})=>{let{audio:i}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:jr,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,m=[];if(c||ds(u,"Voice sound"),p){let f=u.find(h=>h.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(f=>{let h=Db(n,o,f.resourceId);if(!h)return;let g=p?{...f,loop:f.loop??!1}:f;m.push(gs({id:ir("voice",o,c?"default":f.id),sound:g,resource:h,projectResources:n,soundPath:`voice.sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:s}))}),m.length===0)return e;let d=Ke({variables:r,runtime:a}).runtime;return i.push(hs({id:pb,volume:c?l.volume??Qo(d,"soundVolume"):Zo(d,"soundVolume",l.volume??jr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:m,runtime:d})),e},Mb=(e,{presentationState:t,previousPresentationState:n,resources:o={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:b,animations:A}=e;if(t.layout){let O=tt(b);if(!O)return e;let L=o.layouts?.[t.layout.resourceId];if(!L)return e;let R={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:L.elements||[]};O.children.push(ea({container:R,resources:o,templateData:Ke({variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,E=t.layout?.resourceId,v=kr({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:E,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:E?`layout-${E}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return tr({animationInstances:v,isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&A.push(...v),e},Vb=(e,{currentLineActions:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=t?.screen?.animations;if(!l)return e;let c=n!=null,u=kr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return tr({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...u),e},qb=(e,{presentationState:t})=>{let n=tt(e.elements);return!n||!t?.screen||Object.assign(n,Eu(t.screen)),e},Fb=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:h=[],saveSlots:g=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:A}=e;return f&&f.length>0&&f.forEach((k,E)=>{let v=n.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[Ou({id:`overlayStack-${E}-blocker`,screen:y}),...v.elements||[]]},L=Ru(h,n.characters,o),R=Ke({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:L,characters:n.characters||{},skipTransitionsAndAnimations:b}),T=Ir(O,R),[U,...N]=T.children||[],H=vr(Tr({...T,children:N},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);A.push({...H,children:U?[U,...H.children||[]]:H.children})}),e},Bb=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,dialogueHistory:g=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:A}=e;if(!h?.resourceId)return e;let k=n.layouts?.[h.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${h.resourceId}`),e;let E={id:"confirmDialog",type:"container",x:0,y:0,children:[Ou({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=Ru(g,n.characters,o),O=Ir(E,Ke({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,historyDialogue:v,characters:n.characters||{},skipTransitionsAndAnimations:b})),[L,...R]=O.children||[],T=vr(Tr({...O,children:R},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);return A.push({...T,children:L?[L,...T.children||[]]:T.children}),e},an=e=>(t,n)=>xb(t,{...n,visualLayer:e}),Ub=an(wr.BEHIND_BACKGROUND),Yb=an(wr.BEHIND_CHARACTER),zb=an(wr.BEHIND_DIALOGUE),Xb=an(wr.BEHIND_CHOICE),Hb=an(wr.FOREGROUND),$u=e=>Hn(kb,[$b,Ub,Ab,Yb,Pb,zb,Ob,Xb,Rb,Cb,Mb,Hb,qb,Vb,_b,jb,Tb,Lb,Nb,Fb,Bb])(e);function _u(e,t=""){let n=[],o=e.length,a=0,r=0,s=-1,i=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,t?parseInt(t[r++],36):0])}return n}function Nu(e,t,n){let o=0,a=t.length-1;for(;o<=a;){let r=o+a>>>1,s=n[r];if(e<t[r])a=r-1;else if(e>s>>>5)o=r+1;else return s&31}return 0}var ju="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Tu="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Du="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Lu=65535,ta=40960,bs=126976,qu=new Uint8Array(12288),Fu=new Uint8Array(3072),Bu=new Uint8Array(2816),Uu,Yu;{let e=(a,r,s,i,l)=>{let c=r+a.length-1;for(let u=s<r?r:s,p=i>c?c:i;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,r,s]of _u(ju,Tu))e(qu,0,a,r,s),e(Fu,ta,a,r,s),e(Bu,bs,a,r,s),r>=65040&&!(a>=bs&&r<=129791)&&(t[o]=a,n[o++]=r<<5|s);Uu=t.slice(0,o),Yu=n.slice(0,o)}function Mu(e){return e<12288?qu[e]:e<ta?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?Fu[e-ta]: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>=bs&&e<129792?Bu[e-bs]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Nu(e,Uu,Yu)}var zu=Uint8Array.from(Du,Number);function Gb(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 Vu(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Gb(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*Xu(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),o=n>Lu?2:1,a=Mu(n),r=50200>>a&1?Vu(0,a,n):0,s=0,i=n,l=a;for(;o<t;){n=e.codePointAt(o);let c=n>Lu?2:1,u=Mu(n),p=zu[a<<4|u],m;p===0?m=!0:p===1?m=!1:p===2?m=!(r&1):p===3?m=!(r&4):m=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?Vu(r,u,n):0,m&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=o,i=n,l=u),o+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Hu(e){for(let t of Xu(e))yield t.segment}{let e=Xu("_");zu._keep=[e,e.next()]}var Gu=1e3,Qu=50,Kb=0,Ku=100,Wu=50,Wb=60,Jb=3,Qb=.5,Zb=2e4,ew=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,rw=/^\s+$/u,Ju,tw=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Hu(t)):(Ju??=new n(void 0,{granularity:"grapheme"}),Array.from(Ju.segment(t),({segment:o})=>o))},nw=e=>tw(e).reduce((t,n)=>rw.test(n)?t+Qb:ew.test(n)?t+Jb:t+1,0),sw=e=>2**(((Number.isFinite(e)?Math.min(Ku,Math.max(Kb,e)):Qu)-Wu)/(Ku-Wu)),na=({text:e="",baseDelay:t=Gu,speed:n=Qu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):Gu,a=sw(n),r=nw(e)*Wb/a,s=Math.max(o,Zb);return Math.min(o+r,s)};var ws={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},ip=1,Ar=1,xt="choice",Lr="form",pn=()=>({manual:{...ws.manual},auto:{...ws.auto},applyMode:ws.applyMode}),ya=()=>({groupId:null,variantId:null,pageIndex:0}),iw="music-room:player",ow=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),ks=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),ha=new Set,aw=new Set(["groupId","variantId"]),lw=new Set(["pageIndex"]),St=new Set,cw=new Set(["trackId"]),uw=new Set(["positionMs"]),pw=new Set(["pageIndex"]),ga=new Set,fw=new Set(["sceneId"]),dw=new Set(["pageIndex"]),ba=()=>({pageIndex:0}),wa=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...pn()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ia=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let t=ge(e)?Xe(e):e;return structuredClone(t)},q=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),As=e=>{let t=e.global.audioCommandId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal audio command counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=t+1,e.global.audioCommandId},op=e=>{let t=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal scene replay entry counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=t+1,e.global.sceneReplayEntryId},fn=(e,t,n)=>({commandId:As(e),operation:t,...n===void 0?{}:{positionMs:n}}),Ia=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:As(e),operation:"resume"}),e.global.musicRoomPlayer=ks({bgmPlayback:n})},ap=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=e.projectData.resources?.achievements?.[t];if(!n)throw new Error(`Achievement resource "${t}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${n.type}"`);return n},lp=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${t} requires a non-empty string or finite number slotId`)},it=e=>String(e),cp=()=>({sections:[],resources:[]}),up=()=>({sceneIds:[]}),mw=e=>q(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):cp(),yw=e=>q(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):up(),hw=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",gw=({sectionId:e,lineId:t,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:n,text:hw(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),pp=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),bw=e=>q(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,va=e=>{if(!q(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},ww=e=>{if(!q(e?.dialogueHistory))return e.dialogueHistory=pp(e?.rollback?.timeline?.length??0),e.dialogueHistory;let t=e.dialogueHistory;return Array.isArray(t.entries)||(t.entries=[]),Number.isInteger(t.currentLength)||(t.currentLength=t.entries.length),Array.isArray(t.checkpointLengths)||(t.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),t.currentLength=Math.min(Math.max(t.currentLength,0),t.entries.length),t},ka=e=>{let t=va(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},Iw=()=>({resourceId:void 0}),vw=e=>{if(!q(e))return e;let t={...e};return Object.prototype.hasOwnProperty.call(t,"requireComplete")&&!Object.prototype.hasOwnProperty.call(t,"requireLineCompleted")&&(t.requireLineCompleted=t.requireComplete),delete t.requireComplete,t},Je=(e,t)=>{let n=e?.story?.scenes??{};for(let[o,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:o,section:a.sections[t]};return{sceneId:void 0,section:void 0}},fp=e=>{let t=e?.story?.scenes??{},n=new Map;for(let[o,a]of Object.entries(t)){let r=a?.sections??{};for(let s of Object.keys(r)){let i=n.get(s);if(i!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);n.set(s,o);let l=r[s]?.lines,c=new Map;Array.isArray(l)&&l.forEach((u,p)=>{if(typeof u?.id=="string"){if(c.has(u.id))throw new Error(`Duplicate lineId "${u.id}" in scene "${o}", section "${s}": lines[${p}] duplicates lines[${c.get(u.id)}]. Line IDs must be unique within a section.`);c.set(u.id,p)}})}}},dp=e=>e,mp=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==ip)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},kw=(e,t={})=>{let n;try{n=mp(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:n,slotId:dp(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},Aw=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,kw(t,n)])),Pw=(e,t)=>{if(!q(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!q(o))return!1;let{variableId:a,op:r,value:s,roundTo:i}=o,l=t?.resources?.variables?.[a];if(!l||$e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Kt(l.type,r,a),Wn(l.type,r,s,a,{roundTo:i}),r!=="set"||po(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},yp=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!q(o)||!uv(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=Pw(o.payload,t);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},Ew=(e,t,n)=>{let{section:o}=Je(e,t?.sectionId),r=o?.lines?.find(({id:i})=>i===t?.lineId)?.actions,s=n.split(".");for(let i of s){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(i))return;let l=Number(i);if(!Object.prototype.hasOwnProperty.call(r,l))return;r=r[l];continue}if(!q(r)||!Object.prototype.hasOwnProperty.call(r,i))return;r=r[i]}return s.at(-1)==="random"&&q(r?.distribution)?r:void 0},hp=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let t=e.max-e.min+1;return Number.isSafeInteger(t)&&t>=1&&t<=4294967296},gp=(e,t,n)=>e.filter(({path:o,type:a,result:r})=>{let s=Ew(n,t,o);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return q(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let i=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&i?.type==="number"&&i.scope==="context"&&i.readonly!==!0&&!$e(i)&&hp(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),Aa=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==Ar)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let n=new Set,o=e.randomOutcomes.map((a,r)=>{let s=`${a?.path}\0${a?.ordinal}`;if(!q(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||n.has(s))throw new Error(`invalid rollback random outcome at index ${r}`);return n.add(s),{path:a.path,ordinal:a.ordinal,type:a.type,result:es(V(a.result),a.type)}});return t===void 0?o:gp(o,e,t)},xw=(e,t)=>{!q(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!q(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=yp(n.executedActions,t);o?n.executedActions=o:delete n.executedActions;let a=Aa(n,t);a?(n.randomOutcomeVersion=Ar,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},Sw=(e,t)=>{let n=e??{};return Object.values(n).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let s=r?.rollback?.timeline;Array.isArray(s)&&s.forEach(i=>{if(!q(i))return;let l=Aa(i,t);l?(i.randomOutcomeVersion=Ar,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),n},Zu=(e,t,n,o="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!q(e))throw new Error(`Malformed ${o}.${t}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${t}[${n}] entry: missing ${a}.`);if(t==="sections"){let r={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${o}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},Ow=(e,t="viewedRegistry")=>{if(e===void 0)return cp();if(!q(e))throw new Error(`Malformed ${t}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${t}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${t}.resources.`);let n=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,r)=>{let s=Zu(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let s=Zu(a,"resources",r,t);return[s.resourceId,s]})))}},Rw=(e,t="accountReplayRegistry")=>{if(e===void 0)return up();if(!q(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return o}))]}},ln=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:r,section:s}=Je(t,o);if(!s)throw new Error(`Malformed save slot ${n}: section "${o}" does not exist in projectData.`);if(!s.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${n}: line "${a}" does not exist in section "${o}".`);return{sceneId:r,sectionId:o,lineId:a}},bp=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],o=n.initialSectionId,a=n.sections[o];return ln({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},Cw=e=>{try{return bp(e),!0}catch{return!1}},$w=(e,t,n)=>{let o=e?.pointers?.read;if(!q(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return ln(o,t,n);try{return ln(o,t,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],r=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=r;s>=0;s-=1)try{return ln(a[s],t,`${n} compatibility checkpoint`)}catch{}return bp(t)}};var wp=(e,t)=>{let{section:n}=Je(e,t?.sectionId);return n?.lines?.find(o=>o.id===t?.lineId)},_w=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],r=!1;if(e.entries.forEach((i,l)=>{if(!q(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}=Je(t,i.sectionId);if(!c?.lines?.some(p=>p.id===i.lineId)){r=!1,a.push(o.length);return}o.push({sectionId:i.sectionId,lineId:i.lineId,...i.appendToPrevious===!0&&r&&o.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(o.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:s}},Nw=(e,t)=>q(wp(e,t)?.actions?.dialogue),Ip=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:o}=Je(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=>q(s.actions?.dialogue))?.id===t.lineId},jw=(e,t)=>{let n=pp();return e.timeline.forEach(o=>{if(o.returnable!==!1&&Nw(t,o)){let a=wp(t,o),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&Ip(t,r,o);n.entries.push({sectionId:o.sectionId,lineId:o.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},Tw=(e,t,n,o)=>{if(n.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==o)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,s)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=r}),e},Dw=(e,t,n)=>{if(!q(e)||!Array.isArray(e.timeline))return{rollback:un({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!q(c))return[];let p=Aa(c);try{let m=ln(c,n,`rollback.timeline[${u}]`),d=p?gp(p,m,n):void 0,f=vs({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...d?{randomOutcomeVersion:Ar,randomOutcomes:d}:{}}),h=yp(V(c.executedActions),n);return h&&(f.executedActions=h),o.push(u),[f]}catch{return[]}});if(a.length===0)return{rollback:un({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,s=o.indexOf(r);s<0&&(s=a.length-1);let i=a[s];if(i?.sectionId!==t.sectionId||i?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?s=c:(a.push(vs({sectionId:t.sectionId,lineId:t.lineId})),o.push(null),s=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),s):0;return{rollback:{currentIndex:s,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:o,sourceTimelineLength:e.timeline.length}},vp=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=xa(t),a=$w(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!q(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!q(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Ht(V(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=Gw({loadedContextRuntime:q(e.runtime)?V(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Dw(e.rollback,a,t),u=e.dialogueHistory===void 0?jw(i,t):Tw(_w(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:q(e.configuration)?V(e.configuration):{},views:Array.isArray(e.views)?V(e.views):[],bgm:q(e.bgm)?V(e.bgm):{resourceId:void 0},variables:{...o,...r},...u?{dialogueHistory:u}:{},rollback:i};return s&&(p.runtime=s),p},Lw=(e,t)=>{if(!q(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)=>vp(n,t,o))}},Mw=(e,t)=>{if(!q(e))throw new Error("Malformed save slot.");let n=mp(e.formatVersion);return{...e,formatVersion:n,state:Lw(e.state,t)}},ep=(e,t,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${t}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${t} must be an action object`);let o=V(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},Vw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:ep(e.confirmActions,"confirmActions",{required:!0}),cancelActions:ep(e.cancelActions,"cancelActions")}},Ot=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},qw=e=>(q(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Rt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},kp=e=>{if(!(!q(e)||!e.animations))return{animations:V(e.animations)}},Fw=(e,t)=>{let n=kp(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Bw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},Uw=(e,t)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!t))return`${n}:${o}:${t}`},Is=e=>String(e??""),Ap=(e,t)=>{let n=Is(t);return e?.trim===!0?n.trim():n},Yw=e=>q(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>q(t)).map(([t,n])=>[t,{id:t,...V(n)}])):{},zw=(e,t)=>{if(!t||!q(e.global.formDrafts))return;let n=e.global.formDrafts[t];return q(n)?n:void 0},Pp=(e,t)=>{let n=qw(e);q(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let o=n[t];return q(o.values)||(o.values={}),q(o.touched)||(o.touched={}),q(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},Pa=(e,t)=>{let n=Ap(e,t);return e?.required===!0&&n.length===0?"required":null},Ea=({state:e,pointer:t},n=0)=>{if(t?.sectionId==null||t?.lineId==null)return n<0?null:{};let o=ge(e.projectData)?Xe(e.projectData):e.projectData,{section:a}=Je(o,t.sectionId);return Gc(o,a,t.lineId,n)},Xw=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let o=Bw(t),a=Uw(n,o);if(!o||!a)return null;let r=zw(e,a),s=Yw(t),i=Va({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=Is(i?.[d.variableId]),h=Object.prototype.hasOwnProperty.call(r?.values??{},m)?Is(r.values[m]):f,g=r?.touched?.[m]===!0,y=Pa(d,h),w=r?.submitted||g?y:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,A={id:m,variableId:d.variableId,value:h,initialValue:f,valid:!y,error:w,touched: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}:{}};y&&(p=!1),l[m]=A,c.push(A),u[m]=h}),{id:o,key:a,resourceId:t.resourceId,animations:t.animations,valid:p,submitted:r?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:V(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:V(t.cancelActions??{})}}}},Et="line",Dr="interaction",vs=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:o,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{},...a===Ar?{randomOutcomeVersion:Ar,randomOutcomes:V(r??[])}:{}}),xa=e=>{let t=ge(e)?Xe(e):e,{contextVariableDefaultValues:n}=Kn(t??{});return V(n)},Ep=()=>({...V(tn)}),xp=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:V(n),hasLoadedValues:!1};if(!q(e))throw new Error(`Malformed ${o}.`);let a=V(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=ls(s,V(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Hw=({projectData:e,loadedGlobalRuntime:t={}})=>xp({loadedRuntime:t,runtimeIds:Eo,defaults:So(e),path:"global.runtime"}).runtimeState,Gw=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=xp({loadedRuntime:e,runtimeIds:xo,defaults:Ep(),path:"context.runtime"});return n?t:void 0},Vr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ye=e=>{let t=Vr(e);return t?.kind==="sceneReplay"&&q(t.sceneReplay)?t:null},Sp=(e,t)=>{let n=t?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=V(r)})},Kw=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)}}),Ww=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=pn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Jw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=V(t.nextLineConfig),e.global.overlayStack=V(t.overlayStack),e.global.confirmDialog=V(t.confirmDialog),e.global.formDrafts=V(t.formDrafts),e.global.isLineCompleted=t.isLineCompleted,t.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=t.isDialogueHistoryShowing,t.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=V(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=xe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e.global.skipMode&&!n&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!n&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Qw=e=>e.runtime?(xo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=V(tn[t]))}),e.runtime):(e.runtime=Ep(),e.runtime),Zw=e=>Jc(e.global),Op=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Zw(e)}})},Sa=(e,t,n)=>{let o=ls(t,n);if(t in tn){let a=Vr(e);if(!a)return o;let r=Qw(a);return r[t]=o,o}return e.global[t]=o,o},Oa=({pointer:e,projectData:t,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:V(o)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:Iw(),variables:xa(t),rollback:un({pointer:e})}),Ct=e=>e?(e.currentPointerMode="read",q(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,eI=(e,{queueRender:t=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],o=n?.pointers?.read;if(!n||!o?.sectionId||!o?.lineId)return null;let a=Oa({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,rI(e,{queueRender:t}),a},rI=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,Ot(e),Rt(e),e.global.nextLineConfig=pn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Ia(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Rp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},un=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[vs({sectionId:e.sectionId,lineId:e.lineId})]:[]}},qr=(e,t={})=>{if(e?.rollback)return Rp(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=un({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},Ps=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=qr(n);if(o.isRestoring)return;let a=ka(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(vs(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},tI=({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}},nI=({state:e},t={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:a,lineId:r}=t,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[n];return(ge(l)?Tn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},sI=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:s}=t,i=it(n),l=e.global.saveSlots?.[i],c=ge(l)?Tn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||d?.sectionId!==r||d?.lineId!==s||(d.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Cp=(e,t)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:o.currentIndex;if(r<0||r>=o.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<o.timeline.length-1){o.timeline=o.timeline.slice(0,r+1);let s=ka(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},iI=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},o={})=>{let a=o?.source===Et?Et:Dr,r=e.contexts?.[e.contexts.length-1],s=r?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let u=ka(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let i=r?.pointers?.read,l=n?.lineEntryId,c=a===Et&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===i?.sectionId&&s.timeline[s.currentIndex]?.lineId===i?.lineId:n.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:s.currentIndex,source:a,...a===Et?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},oI=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),aI=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let o=t?.at(-1);if(o?.source!==Et||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;Ps(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let s=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=s.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,n?.lineEntryId===o.lineEntryId&&(n.rollbackCheckpointLineEntryId=o.lineEntryId),e},lI=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==Et)return e;if(typeof n?.path!="string"||n.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(n.ordinal)||n.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=es(n.result,n.type),r=Cp(e,t);if(!r)return e;if(r.randomOutcomeVersion!==Ar&&(r.randomOutcomeVersion=Ar,r.randomOutcomes=[]),r.randomOutcomes.some(({path:s,ordinal:i})=>s===n.path&&i===n.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${n.path}#${n.ordinal}`);return r.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:a}),e},lr=(e,t,n,o)=>{let r=o?.at(-1)?.source??Dr;if(!pv(t,r))return;let s=Cp(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:V(n)}))},oa=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=t?.operations??[];for(let{variableId:a,op:r,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if($e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Gt(c,a),Kt(u,r,a),Wn(u,r,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=Jn(n.variables[a],r,s,{roundTo:i}))}},cI=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:o})=>{fv(e,n,o)})},uI=(e,t)=>{let{sectionId:n,lineId:o}=t,s=Me({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Ua(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},$p=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=qr(n),a=o.timeline[t];if(!a)return e;e.global.autoMode&&hn({state:e}),e.global.skipMode&&Mr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{n.variables=xa(e.projectData),n.kind==="sceneReplay"&&(Sp(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(ws),e.global.overlayStack=[],Ot(e),Rt(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&wa(e),uI(e,o.timeline[l]),cI(e,o.timeline[l]);let s=Ct(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=va(n);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=op(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},pI=e=>{let{projectData:t}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:r={},runtime:s={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;fp(t),Yt(t),zt(t),Xt(t),Qr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],m=p.initialSectionId,d=p.sections[m],f={sceneId:u,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:h}=Kn(t),g={...h,...Ht(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Ow(i,"accountViewedRegistry"),accountReplayRegistry:Rw(l),nextLineConfig:pn(),imageGalleryNavigation:ya(),sceneReplayNavigation:ba(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:ks(),saveSlots:Aw(a),localizationPackages:V(c),overlayStack:[],variables:g,...Hw({projectData:t,loadedGlobalRuntime:s})},contexts:[Oa({pointer:f,projectData:t})]}},fI=({state:e})=>e.global.overlayStack||[],dI=({state:e})=>e.global.pendingEffects,_p=({state:e})=>e.global.skipMode,mI=({state:e})=>e.global.autoMode,Np=({state:e})=>e.global.dialogueUIHidden,rp=new WeakMap,yI=8,jp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let o,a=q(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:p,lineId:m}=n.pointers.read,d=Me({state:e},{sectionId:p});if(!d?.lines||!Array.isArray(d.lines))return[];let f=qe(d.lines,m);o=d.lines.slice(0,f+1).map(h=>({sectionId:p,lineId:h.id}))}let r=[],s=gt({variables:{...e.global?.variables??{},...Vr(e)?.variables??{}},runtime:br(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=ge(e.projectData)?Xe(e.projectData):e.projectData,l=Object.isFrozen(i)?rp.get(i):void 0;l||(l=new Map,Object.isFrozen(i)&&rp.set(i,l));let c=new Map(l),u=p=>{let m=c.get(p.sectionId);if(!m){let{section:h}=Je(i,p.sectionId);m={lines:Array.isArray(h?.lines)?h.lines:[],projections:new Map,nextLineIndex:0,presentationState:{}},c.set(p.sectionId,m)}if(l.delete(p.sectionId),l.set(p.sectionId,m),l.size>yI&&l.delete(l.keys().next().value),m.projections.has(p.lineId))return m.projections.get(p.lineId);let d=qe(m.lines,p.lineId);if(d<0)return null;let f=m.lines[d].actions||{};if(!f.dialogue)return m.projections.set(p.lineId,null),null;for(;m.nextLineIndex<=d;){let h=m.lines[m.nextLineIndex],g=m.nextLineIndex===d?f:h.actions||{};m.presentationState=et([m.presentationState,g],{resources:i.resources});let y=m.presentationState.dialogue||{};m.projections.set(h.id,g.dialogue?{line:h,lineActions:g,dialogueState:{characterId:y.characterId,character:y.character,...g.dialogue.append===!0?{content:y.content}:{}}}:null),m.nextLineIndex+=1}return m.projections.get(p.lineId)??null};for(let p of o){if(!bw(p))continue;let m=u(p);if(!m)continue;let{line:d,lineActions:f,dialogueState:h}=m;if(!f.dialogue)continue;let g=Gn({characterId:h.characterId,character:h.character,characters:e.projectData.resources?.characters??{},variables:s}),y=gw({sectionId:p.sectionId,lineId:d.id,content:f.dialogue.append===!0?h.content:f.dialogue.content,dialogueState:h,characterName:g}),w=r[r.length-1];if((a?p.appendToPrevious===!0:f.dialogue.append===!0)&&w?.sectionId===p.sectionId){r[r.length-1]={...r[r.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}r.push(y)}return r},hI=(e,t,n)=>{let o=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:s,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[it(r)],u=ge(c)?Tn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=V(n),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},gI=({state:e},t={})=>{let n=Vr(e),o=n?.pointers?.read,a=mn({state:e});if(!n||!q(a?.actions?.dialogue))return e;let r=qr(n),s=r.timeline?.[r.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=va(n),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||t.forceNewOccurrence!==!0&&i&&l&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let m=ww(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&Ip(e.projectData,p,o);if(m.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,i){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return hI(e,t.savedCheckpointOccurrences,m),e},bI=({state:e})=>e.global.confirmDialog??null,dn=({state:e},{pointer:t}={})=>{let n=t??Fe({state:e})?.pointer,o=Ea({state:e,pointer:n});return Xw({state:e,form:o.form,pointer:n})},wI=({state:e},{pointer:t}={})=>!!dn({state:e},{pointer:t}),xe=({state:e},{pointer:t}={})=>{let n=dn({state:e},{pointer:t});if(n)return{source:Lr,formId:n.id,formKey:n.key};let o=qp({state:e,pointer:t});return o?{source:xt,resourceId:o}:null},II=({state:e,registry:t},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let i=Me({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=qe(i.lines,s.lastLineId),c=qe(i.lines,a);return l===-1||c===-1?s.lastLineId===a:c<=l},Ra=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},Ca=({state:e},t)=>II({state:e,registry:e.global.accountViewedRegistry},t),vI=({state:e},t)=>Ra({registry:e.global.accountViewedRegistry},t),cn=(e,t)=>!Ra({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),$a=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),_a=(e,t)=>{let n=$a(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},aa=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!cn(e,t[a]))return t[a]},kI=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:V(t)},Tp=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??ya(),o=$a(t),a=_a(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:cn(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:cn(e,c)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(d=>d.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(d=>d.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/t.pageSize);p&&m===a&&!cn(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:aa(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:aa(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Na=(e,t)=>!Ra({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),ja=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ta=(e,t)=>{let n=ja(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},la=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!Na(e,t[a]))return t[a]},Dp=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}),AI=(e,t)=>({...Dp(t),locked:Na(e,t)}),tp=e=>{let t=Math.floor(e/1e3),n=t%60,o=Math.floor(t/60);if(o<60)return`${o}:${String(n).padStart(2,"0")}`;let a=Math.floor(o/60),r=o%60;return`${a}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},PI=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:V(t)},Lp=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??ks(),o=ja(t),a=Ta(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>AI(e,u)),i=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[i],c=l?{...Dp(l),canPlayPreviousTrack:la(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:la(e,t.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:tp(n.positionMs),durationText:n.durationMs===null?null:tp(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}}},Da=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),La=(e,t)=>{let n=Da(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},EI=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:V(t)},xI=({state:e})=>ye(e)!==null,SI=({state:e})=>{let t=ye(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Mp=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,Vp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??ba(),o=Da(t),a=La(t,n),r=a*t.pageSize,s=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!Mp(e,l.sceneId)})),i=ye(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},OI=({state:e})=>e.global.nextLineConfig,qp=({state:e,pointer:t}={})=>{let n=t??Fe({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=Me({state:e},{sectionId:o})?.lines||[],i=qe(s,a);if(!(i<0))for(let l=i;l>=0;l-=1){let c=s[l]?.actions;if(!c||!Object.prototype.hasOwnProperty.call(c,"choice"))return;let u=c.choice;if(u?.resourceId)return u.resourceId;if(!u?.animations||c.cleanAll)return}},Fp=({state:e})=>!!qp({state:e}),RI=({state:e})=>structuredClone(e),CI=({state:e})=>V({audioEffects:e.projectData?.resources?.audioEffects??{},sounds:e.projectData?.resources?.sounds??{}}),$I=({state:e})=>{let t=br(e);return{runtime:t,musicRoomPlayer:V(e.global.musicRoomPlayer),skipTransitionsAndAnimations:t.skipTransitionsAndAnimations===!0||Hp(e)}},_I=({state:e},{sectionId:t})=>Je(e.projectData,t).sceneId,NI=({state:e})=>V(e.projectData.resources?.achievements??{}),jI=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:V(n)},Bp=({state:e})=>e.global.saveSlots,TI=({state:e},t)=>{let n=t?.slotId,o=it(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Up=({state:e})=>V(e.global.localizationPackages),Ma=({state:e})=>br(e),DI=({state:e},t)=>or(e,t?.runtimeId),Va=({state:e})=>{let t={...e.global?.variables??{},...Vr(e)?.variables??{}};return gt({variables:t,runtime:br(e),variableConfigs:e.projectData.resources?.variables??{}})},Fe=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},Me=({state:e},t)=>{let{sectionId:n}=t;return Je(e.projectData,n).section},mn=({state:e})=>{let t=Fe({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:o}=t.pointer,a=Me({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines[qe(a.lines,o)]},Yp=({state:e})=>Ea({state:e,pointer:Fe({state:e}).pointer}),zp=e=>{let t=mn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=gt({variables:{...e.global?.variables??{},...Vr(e)?.variables??{}},runtime:br(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${wt(o?.text,{variables:n})??""}`).join("")},Pr=({state:e})=>na({text:zp(e),baseDelay:or(e,"autoForwardDelay"),speed:or(e,"autoForwardSpeed")}),LI=({state:e})=>{let t=Xp({state:e}),o=mn({state:e})?.actions??{},a=et([t??{},o],{resources:e.projectData.resources});return mo(t??{},a??{})},MI=({state:e},{sectionId:t})=>{let n=Me({state:e},{sectionId:t});if(!n?.lines)return[];let o=[],a={};for(let r of n.lines){let s=r.actions||{},i=et([a,s],{resources:e.projectData.resources}),l=mo(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=yo(i)}return o},VI=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let o=MI({state:e},{sectionId:t});return n?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},Xp=({state:e})=>{let t=Ea({state:e,pointer:Fe({state:e}).pointer},-1);return t===null?null:yo(t)},qa=({state:e},{slotsPerPage:t=6}={})=>{let a=((Ma({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let s=0;s<t;s++){let i=a+s,l=e.global.saveSlots&&e.global.saveSlots[it(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},qI=Bp,FI=qa,Hp=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},BI=({state:e},t={})=>{let n=Yp({state:e}),o=Xp({state:e}),a=mn({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:V(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=Fe({state:e}).pointer,{sceneId:c}=Je(e.projectData,l),u={...Ma({state:e}),localizationPackages:Up({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=dn({state:e}),f=Fp({state:e}),h=Tp({state:e}),g=Lp({state:e}),y=Vp({state:e}),w=Va({state:e}),{saveSlots:b}=qa({state:e}),A=Hp(e);return $u({presentationState:n,previousBgmRender:t?.previousBgmRender,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:gf({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||A,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:jp({state:e}),saveSlots:b,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:h,musicRoom:g,sceneReplay:y,musicRoomPlayer:V(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},UI=({state:e},t)=>(e.global.confirmDialog=Vw(t),e.global.pendingEffects.push({name:"render"}),e),YI=({state:e})=>(e.global.confirmDialog&&(Ot(e),e.global.pendingEffects.push({name:"render"})),e),zI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),lr(e,"pushOverlay",n,t),e),XI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),lr(e,"popOverlay",void 0,t),e),HI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),lr(e,"replaceLastOverlay",n,t),e),GI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],Ot(e),Rt(e),e.global.pendingEffects.push({name:"render"}),lr(e,"clearOverlays",void 0,t),e),KI=(e,{activeInteraction:t})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),t&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},yn=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Fw(e,n),Rt(e);let o=xe({state:e},{pointer:t}),a=o?.source===xt,r=o?.source===Lr;KI(e,{activeInteraction:o});let s=ye(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=op(e);s.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:r,activeInteraction:o}},Es=(e,t,n)=>{!(t?.source===xt||t?.source===Lr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Gp=({state:e})=>(xe({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),hn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),WI=({state:e})=>{let t=e.global.autoMode;return xe({state:e})&&!t||(t?hn({state:e}):Gp({state:e})),e},Kp=({state:e})=>(xe({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Mr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),JI=({state:e})=>{let t=_p({state:e});return xe({state:e})&&!t||(t?Mr({state:e}):Kp({state:e})),e},xs=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),lr(e,"showDialogueUI",void 0,t),e),Wp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),lr(e,"hideDialogueUI",void 0,t),e),QI=e=>{let{state:t}=e;return Np({state:t})?xs(e):Wp(e),t},Fr=(e,t,n)=>(Sa(e,t,n),Op(e),e.global.pendingEffects.push({name:"render"}),e),gn=(e,t,n,o,a)=>{let r=Sa(e,t,n);return e.global.pendingEffects.push({name:"render"}),lr(e,o,{value:r},a),e},ZI=({state:e},t)=>Fr(e,"dialogueTextSpeed",t?.value),e0=({state:e},t)=>(Fr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e),r0=({state:e},t)=>(Fr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e),t0=({state:e},t)=>Fr(e,"skipUnseenText",t?.value),n0=({state:e},t)=>Fr(e,"skipTransitionsAndAnimations",t?.value),s0=({state:e},t)=>Fr(e,"soundVolume",t?.value),i0=({state:e},t)=>Fr(e,"musicVolume",t?.value),o0=({state:e},t)=>Fr(e,"muteAll",t?.value),ca=({state:e,rollbackActionBatchStack:t},n)=>gn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),ua=({state:e,rollbackActionBatchStack:t})=>{let n=or(e,"saveLoadPagination")+1;return gn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},pa=({state:e,rollbackActionBatchStack:t})=>{let n=or(e,"saveLoadPagination")-1;return gn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},fa=({state:e,rollbackActionBatchStack:t},n)=>gn(e,"menuPage",n?.value,"setMenuPage",t),da=({state:e,rollbackActionBatchStack:t},n)=>gn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),a0=({state:e})=>(e.global.pendingEffects=[],e),l0=({state:e},t)=>(e.global.pendingEffects.push(t),e),c0=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId;return ap(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},u0=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId,o=ap(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${n}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let r=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:r,target:o.target,completed:r>=o.target}}),e},Jp=e=>e?.lines?.[0],Qp=(e,{sectionId:t,resetStoryState:n=!1,screen:o})=>{let a=!!kp(o),r=Me({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=Jp(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!eI(e,{queueRender:!a}))return e;let i=xe({state:e});n&&e.global.skipMode&&Mr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Ct(l),p=u.read;n||st(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||qr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=un({pointer:u.read}):Ps(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=yn(e,l?.pointers?.read,{screenTransition:o});return Es(e,i,c),e},p0=({state:e},t)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return Qp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Zp=e=>(e.global.accountViewedRegistry=mw(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Ss=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(n=>({scope:n.scope,path:n.path,op:n.op,value:V(n.value)}))}})},ef=(e,t)=>{Ss(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},f0=(e,t,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=q(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(s=>s.sectionId===n);if(r){if(r.lastLineId===void 0)return!1;let s=Me({state:e},{sectionId:n});if(s?.lines){let i=qe(s.lines,r.lastLineId),l=qe(s.lines,o);if(i===-1||l>i)return r.lastLineId===o?!1:(r.lastLineId=o,!0)}else return r.lastLineId===o?!1:(r.lastLineId=o,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:o}),!0},st=(e,t)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;f0(e,Zp(e),t)&&ef(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},d0=({state:e},t)=>(st(e,t),e.global.pendingEffects.push({name:"render"}),e),m0=({state:e},t)=>{if(ye(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let o=Zp(e);o.resources.find(r=>r.resourceId===n)||(o.resources.push({resourceId:n}),ef(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},cr=(e,t,n)=>{if(!q(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},ma=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},Os=(e,t)=>{let n=e.global.imageGalleryNavigation;n.groupId===t.groupId&&n.variantId===t.variantId&&n.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},y0=({state:e},t)=>{let n="showImageGalleryVariant";cr(n,t,aw),ma(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&ma(n,"variantId",t.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let a=o.groups.findIndex(i=>i.id===t.groupId),r=o.groups[a];if(!r)return e;let s=t.variantId===void 0?r.variants[0]:r.variants.find(i=>i.id===t.variantId);return!s||cn(e,s)||Os(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},rf=(e,t,n,o)=>{cr(o,t,ha);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let r=e.global.imageGalleryNavigation;if(typeof r.groupId!="string"||typeof r.variantId!="string")return e;let s=a.groups.find(c=>c.id===r.groupId),i=s?.variants.findIndex(c=>c.id===r.variantId);if(!s||i===void 0||i<0)return e;let l=aa(e,s.variants,i,n);return l&&Os(e,{...r,variantId:l.id}),e},h0=({state:e},t)=>rf(e,t,-1,"moveToPreviousImageGalleryVariant"),g0=({state:e},t)=>rf(e,t,1,"moveToNextImageGalleryVariant"),b0=({state:e},t)=>{if(cr("clearImageGallerySelection",t,ha),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return Os(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},tf=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=$a(n);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=_a(n,a);return t===r||Os(e,{groupId:null,variantId:null,pageIndex:t}),e},w0=({state:e},t)=>{if(cr("moveToImageGalleryPage",t,lw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return tf(e,t.pageIndex)},nf=(e,t,n,o)=>{cr(o,t,ha);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=_a(a,e.global.imageGalleryNavigation)+n;return s<0?e:tf(e,s)},I0=({state:e},t)=>nf(e,t,1,"moveToNextImageGalleryPage"),v0=({state:e},t)=>nf(e,t,-1,"moveToPreviousImageGalleryPage"),Er=(e,t,n)=>{if(!q(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},k0=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},nr=e=>{e.global.pendingEffects.push({name:"render"})},sf=(e,t)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,r=o.trackId===t.id,s=o.bgmPlayback;a||(s={commandId:As(e),operation:"pause"});let i=fn(e,"play",0),l=n.tracks.indexOf(t),c=r?o.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:s},nr(e)},A0=({state:e},t)=>{let n="playMusicRoomTrack";Er(n,t,cw),k0(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Na(e,a)||sf(e,a),e},P0=({state:e},t)=>{Er("playMusicRoom",t,St);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",r=o.readiness==="error",s=o.status==="paused"&&!r?"resume":"play",i=a?0:o.positionMs;return o.playback=fn(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),nr(e),e},E0=({state:e},t)=>{Er("pauseMusicRoom",t,St);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=fn(e,"pause"),o.seekFallback=null,o.status="paused",nr(e)),e},x0=({state:e},t)=>{Er("stopMusicRoom",t,St);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=fn(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,nr(e)),e},S0=({state:e},t)=>{if(Er("seekMusicRoom",t,uw),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let o=e.global.musicRoomPlayer;if(o.trackId===null||o.readiness!=="ready"||o.durationMs===null||t.positionMs>o.durationMs)return e;let a=fn(e,"seek",t.positionMs);return o.seekFallback={commandId:a.commandId,status:o.status,positionMs:o.positionMs},o.playback=a,o.positionMs=t.positionMs,t.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),nr(e),e},of=(e,t,n,o)=>{Er(o,t,St);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===r.trackId);if(s<0)return e;let i=la(e,a.tracks,s,n);return i&&sf(e,i),e},O0=({state:e},t)=>of(e,t,-1,"playPreviousMusicRoomTrack"),R0=({state:e},t)=>of(e,t,1,"playNextMusicRoomTrack"),C0=({state:e},t)=>{Er("clearMusicRoomSelection",t,St);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:As(e),operation:"resume"};return e.global.musicRoomPlayer={...ks({bgmPlayback:r}),pageIndex:a},nr(e),e},af=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=ja(n))return e;let o=e.global.musicRoomPlayer,a=Ta(n,o);return t===a||(o.pageIndex=t,nr(e)),e},$0=({state:e},t)=>{if(Er("moveToMusicRoomPage",t,pw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return af(e,t.pageIndex)},lf=(e,t,n,o)=>{Er(o,t,St);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Ta(a,e.global.musicRoomPlayer)+n;return r<0?e:af(e,r)},_0=({state:e},t)=>lf(e,t,1,"moveToNextMusicRoomPage"),N0=({state:e},t)=>lf(e,t,-1,"moveToPreviousMusicRoomPage"),nt=e=>{let t=ye(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=V(t.sceneReplay.returnState),o=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),Jw(e,n),e.global.pendingEffects.push({name:"render"}),!0},j0=({state:e},t)=>{let n="startSceneReplay";if(cr(n,t,fw),ma(n,"sceneId",t.sceneId),ye(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!Mp(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,i=r?.sections?.[s],l=i?.initialLineId??i?.lines?.[0]?.id;if(!i||!l||!i.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=Kw(e);Ww(e);let u=Oa({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 Sp(e,u),e.contexts.push(u),yn(e,u.pointers.read),e},cf=({state:e},t)=>{cr("finishSceneReplay",t,ga);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Vr(e)?.rollback?.isRestoring===!0)return e;let r=Fe({state:e})?.pointer,{sceneId:s}=Je(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=yw(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Ss(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},T0=({state:e},t)=>(cr("exitSceneReplay",t,ga),nt(e),e),uf=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=Da(n))return e;let o=La(n,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},D0=({state:e},t)=>{if(cr("moveToSceneReplayPage",t,dw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return uf(e,t.pageIndex)},pf=(e,t,n,o)=>{cr(o,t,ga);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=La(a,e.global.sceneReplayNavigation)+n;return r<0?e:uf(e,r)},L0=({state:e},t)=>pf(e,t,1,"moveToNextSceneReplayPage"),M0=({state:e},t)=>pf(e,t,-1,"moveToPreviousSceneReplayPage"),Rs=(e,t)=>{let n=e.global.musicRoomPlayer;return!q(t)||t.id!==iw||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Fa=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,ff=(e,t,n,{readiness:o=t.readiness}={})=>((t.readiness!==o||t.positionMs!==n.positionMs||t.durationMs!==n.durationMs||t.seekFallback!==null)&&(t.readiness=o,t.positionMs=n.positionMs,t.durationMs=n.durationMs,t.seekFallback=null,nr(e)),e),V0=({state:e},t)=>{let n=Rs(e,t);return!n||n.readiness!=="loading"||!Fa(t)?e:ff(e,n,t,{readiness:"ready"})},q0=({state:e},t)=>{let n=Rs(e,t);return!n||n.readiness!=="ready"||!Fa(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:ff(e,n,t)},F0=({state:e},t)=>{let n=Rs(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Fa(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,nr(e)),e},B0=({state:e},t)=>{let n=Rs(e,t);if(!n||typeof t.errorCode!="string"||!ow.has(t.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(t.errorCode==="invalid-position"){let o=n.seekFallback;if(n.playback.operation!=="seek"||o?.commandId!==t.commandId)return e;let a=n.status!==o.status||n.positionMs!==o.positionMs;return n.status=o.status,n.positionMs=o.positionMs,n.seekFallback=null,a&&nr(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,nr(e),e},df=({state:e,rollbackActionBatchStack:t},n)=>{let o=vw(n.manual),{auto:a,applyMode:r}=n,s=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=xe({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"}),lr(e,"setNextLineConfig",n,t),e},U0=({state:e},t)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;lp(n,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=it(n),s=V(e.contexts);s?.forEach(c=>{Ct(c),Rp(c.rollback),xw(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:ip,slotId:dp(n),savedAt:typeof a=="number"?a:Date.now(),image:o,state:i};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},Y0=({state:e},t)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;lp(n,"loadSlot");let o=it(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=Mw(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=pn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Ot(e),Rt(e),Ia(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},z0=({state:e},t)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;fp(n),Yt(n),zt(n),Xt(n),Qr(n?.resources?.variables??{}),So(n);let o=Cw(n),a=o?e.contexts?.map((s,i)=>vp(V(s),n,i)):void 0,r=o?Sw(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=ya(),e.global.sceneReplayNavigation=ba(),Ia(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:i}=Kn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Ht(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return Ot(e),Rt(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},X0=({state:e},t)=>{let{l10nId:n,projectData:o}=t??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!q(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,Sa(e,"localizationPackageId",n),Op(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},H0=({state:e},t)=>{let{sectionId:n,lineId:o}=t;if(!o)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let r=n||a.pointers.read?.sectionId;if(n&&!Me({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Me({state:e},{sectionId:r});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${r} has no lines`),e;if(!s.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${r}`),e;let l=xe({state:e}),c=Ct(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=yn(e,c.read);return Es(e,l,u),e},G0=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return xs({state:e,rollbackActionBatchStack:t}),e;let o=xe({state:e});if(o?.source===xt&&n?.bypassChoice!==!0||o?.source===Lr&&n?._interactionSource!==Lr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return nt(e),e;let d=Fe({state:e})?.pointer,f=d?.sectionId,h=d?.lineId;f&&h&&st(e,{sectionId:f,lineId:h}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}});let g=e.global.nextLineConfig,y=Me({state:e},{sectionId:f});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===h?ia(e):g?.auto?.enabled&&!o&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ye(e)?.sceneReplay.finishOnNextAdvance)return nt(e),e;let r=Fe({state:e})?.pointer,s=r?.sectionId,i=Me({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=qe(c,r?.lineId)+1;if(p<c.length){let m=c[p],d=!or(e,"skipUnseenText");if(e.global.skipMode&&d&&!Ca({state:e},{sectionId:s,lineId:m.id}))return Mr({state:e}),e;if(l&&!l.rollback&&qr(l,{compatibilityAnchor:!0}),l){let h=Ct(l),g=h.read?.lineId;g&&s&&st(e,{sectionId:s,lineId:g}),h.read={sectionId:s,lineId:m.id}}Ps(e,{sectionId:s,lineId:m.id}),wa(e);let{activeInteraction:f}=yn(e,{sectionId:s,lineId:m.id});Es(e,o,f)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),nt(e),e;e.global.autoMode&&hn({state:e}),e.global.skipMode&&Mr({state:e}),ia(e)}return e},K0=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return nt(e),e;let n=xe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}});let o=Fe({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&st(e,{sectionId:a,lineId:r});let s=e.global.nextLineConfig;return s?.auto?.enabled&&!n&&s.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:s.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},W0=({state:e},t)=>Qp(e,{sectionId:t?.sectionId,screen:t?.screen}),J0=({state:e,rollbackActionBatchStack:t},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return xs({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e;let a=xe({state:e});if(a?.source===xt&&n?.bypassChoice!==!0||a?.source===Lr&&n?._interactionSource!==Lr||a&&a.source!==xt&&a.source!==Lr)return e;let r=ye(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(nt(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=Fe({state:e})?.pointer,i=s?.sectionId,l=Me({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=qe(u,s?.lineId)+1;if(m<u.length){let d=u[m],f=!or(e,"skipUnseenText");if(e.global.skipMode&&f&&!Ca({state:e},{sectionId:i,lineId:d.id})&&(Mr({state:e}),!o))return e;if(c&&!c.rollback&&qr(c,{compatibilityAnchor:!0}),c){let g=Ct(c),y=g.read?.lineId;y&&i&&st(e,{sectionId:i,lineId:y}),g.read={sectionId:i,lineId:d.id}}Ps(e,{sectionId:i,lineId:d.id}),wa(e);let{activeInteraction:h}=yn(e,{sectionId:i,lineId:d.id});Es(e,a,h)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),nt(e),e;e.global.autoMode&&hn({state:e}),e.global.skipMode&&Mr({state:e}),ia(e)}return e},Ba=(e,t={})=>{let n=dn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},Q0=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],o=n?.scope,a=n?.type;if($e(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Gt(o,t.variableId),Kt(a,"set",t.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},Z0=(e,t)=>({id:e.id,key:e.key,valid:!0,values:V(t),fields:V(e.fields),fieldList:V(e.fieldList)}),ev=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Fe({state:e})?.pointer,n=t?.sectionId,o=t?.lineId;n&&o&&st(e,{sectionId:n,lineId:o})},rv=({state:e},t={})=>{let n=Ba(e,t),o=t.field;if(!n?.fields?.[o])return e;let a=Pp(e,n.key),r=Is(t.value),s=n.fields[o],i=Pa(s,r);return a.values[o]=r,a.touched[o]=!0,i?a.errors[o]=i:delete a.errors[o],e.global.pendingEffects.push({name:"render"}),e},tv=({state:e,rollbackActionBatchStack:t},n={})=>{let o=Ba(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=Pp(e,o.key);a.submitted=!0;let r={},s={};if(Object.entries(o.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,h=Pa(d,f);a.touched[m]=!0,h&&(s[m]=h),r[m]=Ap(d,f)}),a.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(r)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([m,d])=>{let{scope:f}=Q0(e,d),h=f==="context"?i.variables:e.global.variables,g=r[m];h[d.variableId]=Jn(h[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:V(h[d.variableId])})}),l&&lr(e,"updateVariable",{id:"submitForm",operations:u},t),Ss(e,c);let p=Z0(o,r);return ev(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},nv=({state:e},t={})=>{let n=Ba(e,t);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:V(n.values),fields:V(n.fields),fieldList:V(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},sv=({state:e,rollbackActionBatchStack:t},n)=>{let{id:o,operations:a=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let s=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=e.projectData.resources?.variables?.[c],f=d?.scope,h=d?.type;if($e(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Gt(f,c),Kt(h,u,c),Wn(h,u,p,c,{roundTo:m}),ye(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let g=f==="context"?r.variables:e.global.variables;if(f==="context"){s=!0;let y={variableId:c,op:u,value:p};m!==void 0&&(y.roundTo=m),l.push(y)}g[c]=Jn(g[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&i.push({scope:f,path:`variables.${c}`,op:"set",value:V(g[c])})}),s&&lr(e,"updateVariable",{id:o,operations:l},t),Ss(e,i),e.global.pendingEffects.push({name:"render"}),e},We=e=>(t,n)=>e({state:t},n),mf=e=>({variables:gt({variables:{...e.global?.variables??{},...Vr(e)?.variables??{}},runtime:br(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:br(e)}),iv=e=>{if(!q(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")},ov=(e,t,n)=>{if(!q(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!q(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==n-1)throw new Error("conditional else branch must be the last branch")},av=(e,t,n,o)=>{iv(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(ov(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Ut(r.when,{...mf(e),...n?.bindings??{}}))){Ua(e,r.actions,n,[...o,"branches",String(a),"actions"]);return}}},lv=(e,t,n,o)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==Ar)return;let r=o.join("."),s=n.randomOutcomeOrdinals,i=s.get(r)??0;s.set(r,i+1);let l=a.randomOutcomes?.find(p=>p.path===r&&p.ordinal===i);if(!l)return;if(t?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${r}`);let c=es(V(l.result),l.type);if(c.type==="integer"){if(!hp(t.distribution)||c.value<t.distribution.min||c.value>t.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${r}`);oa(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!q(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Ua(e,u,n,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},cv={conditional:{replayLine:av},random:{replayLine:lv},updateVariable:{recordSources:[Dr],replayLine:oa,replayRecorded:oa,persistInSaveSlot:!0},setNextLineConfig:{replayLine:We(df)},setSaveLoadPagination:{recordSources:[Dr],replayLine:We(ca),replayRecorded:We(ca),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Dr],replayLine:We(ua),replayRecorded:We(ua),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Dr],replayLine:We(pa),replayRecorded:We(pa),persistInSaveSlot:!0},setMenuPage:{recordSources:[Dr],replayLine:We(fa),replayRecorded:We(fa),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Dr],replayLine:We(da),replayRecorded:We(da),persistInSaveSlot:!0},finishSceneReplay:{replayLine:We(cf)}},Cs=e=>cv[e]??null,uv=e=>Cs(e)?.persistInSaveSlot===!0,pv=(e,t)=>{let n=Cs(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},fv=(e,t,n)=>{Cs(t)?.replayRecorded?.(e,n)},dv=(e,t,n,o,a)=>{let r=Cs(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,o,a);return}let s=o?.bindings??{},i=Wt({[t]:n},{...mf(e),...s})[t];r.replayLine(e,i)},Ua=(e,t,n,o)=>{let a=rs(t);ns(a);for(let[r,s]of a)dv(e,r,s,n,[...o,r])},mv=e=>e?.returnable!==!1,yf=(e,t)=>{if(t>=0)return e.currentIndex+t;let n=Math.abs(t);for(let o=e.currentIndex-1;o>=0;o-=1)if(mv(e.timeline[o])&&(n-=1,n===0))return o;return-1},hf=({state:e},t)=>{let{offset:n}=t;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let o=e.contexts[e.contexts.length-1];if(!o)return null;let a=o.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=yf(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},gf=({state:e})=>hf({state:e},{offset:-1})!==null,yv=({state:e},t)=>{let{offset:n=-1}=t;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=qr(o,{compatibilityAnchor:!o.rollback}),r=yf(a,n);return r<0||r>=a.timeline.length?e:$p(e,r)},hv=({state:e},t)=>{let{sectionId:n,lineId:o}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=qr(a,{compatibilityAnchor:!a.rollback}),i=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${n} rollback timeline`);return i===r.currentIndex?e:$p(e,i)},gv=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),sa=(e,t)=>{let n=e[t];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${t} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=n+1,e[t]},np=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,sp=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},bv=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,bf=e=>{let t=e.global?.nextLineConfig?.auto;return t?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:t.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:t.delay??1e3}},Ya=e=>JSON.stringify(bf(e)),wv=({actionName:e,args:t,state:n,previousState:o})=>{let a=np(o),r=np(n);if(!bv(a,r)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&sp(o)!==sp(n))return!0;let s=t[0]??{};if(e==="jumpToLine"){let i=s.sectionId??a?.sectionId;return typeof s.lineId=="string"&&r?.sectionId===i&&r?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=Je(n.projectData,s.sectionId).section,l=Jp(i)?.id;return typeof l=="string"&&r?.sectionId===s.sectionId&&r?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let i=s.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},it(i))}return!1},Iv=({actionName:e,args:t,state:n,transactionalMetadata:o,previousState:a})=>{if(wv({actionName:e,args:t,state:n,previousState:a})){let u=sa(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:Ya(n)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let s=(a.contexts?.length??0)>(n.contexts?.length??0),i=e==="startAutoMode"||e==="startSkipMode"?xe({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&sa(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&sa(o,"skipSessionId")},vv=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==Ya(e))&&(t.rollbackAuthoredSuppression=null)},kv=({state:e,playbackOwnership:t})=>{let n=xe({state:e}),o=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=bf(e),i=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===Ya(e)),c=a?zp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:na({text:c,baseDelay:or(e,"autoForwardDelay"),speed:or(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:s.delayMs,trigger:s.trigger}:null}},Av=({playbackOwnership:e})=>e.lineEntryId,wf=(e,t={})=>{let n=pI(e),o=[],a=t.createPlaybackOwnership??gv;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return rc(n,{selectPendingEffects:dI,selectSkipMode:_p,selectAutoMode:mI,selectIsChoiceVisible:Fp,selectIsFormVisible:wI,selectActiveInteraction:xe,selectActiveForm:dn,selectDialogueUIHidden:Np,selectDialogueHistory:jp,selectConfirmDialog:bI,selectIsLineAccountViewed:Ca,selectIsResourceAccountViewed:vI,selectImageGalleryConfig:kI,selectImageGallery:Tp,selectMusicRoomConfig:PI,selectMusicRoom:Lp,selectSceneReplayConfig:EI,selectSceneReplay:Vp,selectIsSceneReplayActive:xI,selectActiveSceneReplayEntry:SI,selectNextLineConfig:OI,selectSystemState:RI,selectBgmResources:CI,selectBgmPlaybackContext:$I,selectSceneIdForSection:_I,selectAchievements:NI,selectAchievement:jI,selectSaveSlotMap:Bp,selectSaveSlots:qI,selectSaveSlot:TI,selectLocalizationPackages:Up,selectRuntime:Ma,selectRuntimeValue:DI,selectAllVariables:Va,selectCurrentPointer:Fe,selectSection:Me,selectCurrentLine:mn,selectPresentationState:Yp,selectAutoForwardTimerDelay:Pr,selectPresentationChanges:LI,selectSectionLineChanges:VI,selectSaveSlotPage:qa,selectCurrentPageSlots:FI,selectRenderState:BI,selectOverlayStack:fI,selectLineIdByOffset:hf,selectCanRollback:gf,selectRollbackCursor:tI,selectDesiredPlaybackTimers:kv,selectPlaybackLineEntryId:Av,startAutoMode:Gp,stopAutoMode:hn,toggleAutoMode:WI,startSkipMode:Kp,stopSkipMode:Mr,toggleSkipMode:JI,showDialogueUI:xs,hideDialogueUI:Wp,toggleDialogueUI:QI,setDialogueTextSpeed:ZI,setAutoForwardDelay:e0,setAutoForwardSpeed:r0,setSkipUnseenText:t0,setSkipTransitionsAndAnimations:n0,setSoundVolume:s0,setMusicVolume:i0,setMuteAll:o0,setSaveLoadPagination:ca,incrementSaveLoadPagination:ua,decrementSaveLoadPagination:pa,setMenuPage:fa,setMenuEntryPoint:da,showConfirmDialog:UI,hideConfirmDialog:YI,resetStoryAtSection:p0,clearPendingEffects:a0,appendPendingEffect:l0,completeAchievement:c0,setAchievementProgress:u0,beginRollbackActionBatch:iI,endRollbackActionBatch:oI,ensureRandomReplayOccurrence:aI,recordRandomOutcome:lI,markRollbackCheckpointTransient:nI,markSavedRollbackCheckpointTransient:sI,recordCurrentDialogueHistory:gI,addViewedLine:d0,addViewedResource:m0,showImageGalleryVariant:y0,moveToPreviousImageGalleryVariant:h0,moveToNextImageGalleryVariant:g0,clearImageGallerySelection:b0,moveToImageGalleryPage:w0,moveToNextImageGalleryPage:I0,moveToPreviousImageGalleryPage:v0,playMusicRoomTrack:A0,playMusicRoom:P0,pauseMusicRoom:E0,stopMusicRoom:x0,seekMusicRoom:S0,playPreviousMusicRoomTrack:O0,playNextMusicRoomTrack:R0,clearMusicRoomSelection:C0,moveToMusicRoomPage:$0,moveToNextMusicRoomPage:_0,moveToPreviousMusicRoomPage:N0,musicRoomSoundReady:V0,musicRoomSoundProgress:q0,musicRoomSoundComplete:F0,musicRoomSoundError:B0,startSceneReplay:j0,finishSceneReplay:cf,exitSceneReplay:T0,moveToSceneReplayPage:D0,moveToNextSceneReplayPage:L0,moveToPreviousSceneReplayPage:M0,setNextLineConfig:df,saveSlot:U0,loadSlot:Y0,updateProjectData:z0,updateLocalizationPackage:X0,sectionTransition:W0,jumpToLine:H0,nextLine:G0,markLineCompleted:K0,rollbackToLine:hv,rollbackByOffset:yv,pushOverlay:zI,popOverlay:XI,replaceLastOverlay:HI,clearOverlays:GI,updateFormField:rv,submitForm:tv,cancelForm:nv,updateVariable:sv,nextLineFromSystem:J0},{createTransactionalMetadata:a,updateTransactionalMetadata:Iv,finalizeTransactionalMetadata:vv,transformActionFirstArgument:(s,i)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(s,i)=>({state:s,playbackOwnership:i})})};var Pv="route-engine",Ev="projectPersistence";var vf=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),we=e=>Object.prototype.toString.call(e)==="[object Object]",If="variables.",xv=(e={})=>{let t=we(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!we(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lineId=="string"?{lineId:n.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!we(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Sv=(e={})=>{let t=we(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!we(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lastLineId=="string"?{lastLineId:n.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!we(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Ov=(e,t)=>{let n=Sv(e),o=xv(t),a=n.sections.map(s=>({...s})),r=n.resources.map(s=>({...s}));return o.sections.forEach(s=>{let i=a.find(l=>l.sectionId===s.sectionId);if(!i){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(i.lastLineId!==void 0){if(s.lineId===void 0){delete i.lastLineId;return}i.lastLineId=s.lineId}}),o.resources.forEach(s=>{r.find(l=>l.resourceId===s.resourceId)||r.push({...s})}),{sections:a,resources:r}},Rv=(e={})=>{let t=we(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},Cv=(e,t)=>{let n=Rv(e),o=we(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},kf=(e={})=>{let t=we(e)?e:{};return{saveSlots:we(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:we(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:we(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:we(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:we(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:we(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},$v=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!we(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=t.path?.startsWith(If)?t.path.slice(If.length):null;if(o!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${n}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return{scope:t.scope,path:t.path,op:t.op,value:t.value,variableId:o}}if(t.path==="viewedRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);if(!we(t.value)||!Array.isArray(t.value.sceneIds)||t.value.sceneIds.length===0||t.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${n}].`)})},_v=(e,t)=>{let n={};return $v(t).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=Ov(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=Cv(n.accountReplayRegistry??e.accountReplayRegistry,o.value);return}let a=o.scope==="device"?"globalDeviceVariables":"globalAccountVariables";n[a]={...e[a],...n[a],[o.variableId]:o.value}}),n},$t=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},Nv=e=>{let t=$t(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},jv=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},Tv=({indexedDB:e,databaseName:t,objectStoreName:n})=>new Promise((o,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},r.onsuccess=()=>{o(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),Dv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let l=o.transaction(t,"readonly").objectStore(t).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},bn=async({databasePromise:e,objectStoreName:t,namespace:n,patch:o})=>{let a=await e;return new Promise((r,s)=>{let i=a.transaction(t,"readwrite"),l=i.objectStore(t),c=l.get(n),u=!1,p=d=>{u||(u=!0,s(d))},m=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=kf(c.result),f=typeof o=="function"?o(d):o,h={namespace:n,version:1,...vf(),...d,...f},g=l.put(h);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}".`))}})},Lv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let s=o.transaction(t,"readwrite"),l=s.objectStore(t).delete(n),c=!1,u=m=>{c||(c=!0,r(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{u(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{u(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},za=(e={})=>{let{indexedDB:t,databaseName:n=Pv,objectStoreName:o=Ev,namespace:a}=e,r=jv(t),s=Nv(a),i=Tv({indexedDB:r,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await Dv({databasePromise:i,objectStoreName:o,namespace:s});return{...vf(),...kf(l)}},clear:async()=>Lv({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:we(l)?l:{}}}),saveGlobalDeviceVariables:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:we(l)?l:{}}}),saveGlobalAccountVariables:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:we(l)?l:{}}}),saveGlobalRuntime:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:we(l)?l:{}}}),applyScopedDataUpdates:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>_v(c,l)})}},Mv=za;var jf=Tf;var Vv={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Qe=Object.prototype.hasOwnProperty,qv={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 Be(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e!==null){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[d]:r.push(d),s++}if(e.y===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[d]:r.push(d),s++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let f={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[f]:r.push(f),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:qv.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[f]:r.push(f),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Be.errors=r,s===0}var Se=Pf().default;function _s(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return _s.errors=r,s===0}function fr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)_s(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return fr.errors=r,s===0}var Fv={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Ns(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="continuity"||i==="speed"||i==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.continuity!==void 0){let i=e.continuity;if(typeof i!="string"){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="render"||i==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Fv.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ns.errors=r,s===0}function pe(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.playback!==void 0&&(Ns(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pe.errors=r,s===0}function js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Qe.call(Vv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let i={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let i={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let i={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let i={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Be(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),e.filters!==void 0&&(fr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return js.errors=r,s===0}function Tf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return js(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?js.errors:r.concat(js.errors),s=r.length),Tf.errors=r,s===0}var Df=Lf;var Ef={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},xf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function Ts(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="speed"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ts.errors=r,s===0}function _e(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}e.playback!==void 0&&(Ts(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return _e.errors=r,s===0}function Ds(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(xf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:xf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(_e(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)),e.endEffect!==void 0&&(_e(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ds.errors=r,s===0}function Ls(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var c=l===s;if(c){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=i,r!==null&&(i?r.length=i:r=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var m=p===s;if(m){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=u,r!==null&&(u?r.length=u:r=null);let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let w={};r===null?r=[w]:r.push(w),s++}}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[b]:r.push(b),s++}var g=y===s;f=g}if(!f){let y={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Qe.call(Ef.properties,y)){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let b=0;b<w;b++)Ds(y[b],{instancePath:t+"/sounds/"+b,parentData:y,parentDataProperty:b,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Ef.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}e.audioEffects!==void 0&&(_e(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length))}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Ls.errors=r,s===0}function Lf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ls(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),s=r.length),Lf.errors=r,s===0}var Mf=Vf;var Bv={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ms(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=s,d=!0,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let h;if(p.sprites===void 0&&(h="sprites")){let g={};r===null?r=[g]:r.push(g),s++}}var i=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),i){let h=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};r===null?r=[y]:r.push(y),s++}var i=h===s;d=i}if(!d){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[h]:r.push(h),s++}for(let h in p)if(!Qe.call(Bv.properties.items.items.properties,h)){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let h={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let h={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.x!==void 0&&typeof p.x!="number"){let h={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.y!==void 0&&typeof p.y!="number"){let h={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let h={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let h={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let h={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let h={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let h={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let h={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let h={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let h={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let h={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.alpha!==void 0){let h=p.alpha;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.opacity!==void 0){let h=p.opacity;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.blur!==void 0&&(Be(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),p.filters!==void 0&&(fr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),p.sprites!==void 0){let h=p.sprites;if(Array.isArray(h)){let g=h.length;for(let y=0;y<g;y++){let w=h[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let b in w)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let A={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(w.id!==void 0&&typeof w.id!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}}}else{let g={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),s++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let c={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Ms.errors=r,s===0}function Vf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ms(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),s=r.length),Vf.errors=r,s===0}var qf=Ff;function Vs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="items"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:t+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:t+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let d={instancePath:t+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let m={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Vs.errors=r,s===0}function Ff(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Vs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length),Ff.errors=r,s===0}var Bf=Uf;function qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let i={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return qs.errors=r,s===0}function Uf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return qs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),s=r.length),Uf.errors=r,s===0}var Yf=zf;function Fs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Fs.errors=r,s===0}function zf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Fs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),s=r.length),zf.errors=r,s===0}var Xf=Hf;var Sf={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 Bs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Qe.call(Sf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.ui!==void 0){let i=e.ui;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="resourceId"||l==="animations")){let c={instancePath:t+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.resourceId!==void 0&&typeof i.resourceId!="string"){let l={instancePath:t+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}i.animations!==void 0&&(pe(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let l={instancePath:t+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.mode!==void 0){let i=e.mode;if(typeof i!="string"){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="adv"||i==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Sf.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.content!==void 0){let i=e.content;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:t+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}}else{let p={instancePath:t+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let i={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let i={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let i={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let i={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let i={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let i={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.character!==void 0){let i=e.character;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="name"||l==="sprite")){let c={instancePath:t+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.name!==void 0&&typeof i.name!="string"){let l={instancePath:t+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(i.sprite!==void 0){let l=i.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:t+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[d]:r.push(d),s++}if(m.resourceId===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[d]:r.push(d),s++}for(let d in m)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(m.id!==void 0&&typeof m.id!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let d={instancePath:t+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let u={instancePath:t+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[u]:r.push(u),s++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let c={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let i={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let i={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Bs.errors=r,s===0}function Hf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Bs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length),Hf.errors=r,s===0}var Gf=Kf;function Us(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="id"||i==="resourceId"||i==="fields"||i==="submitActions"||i==="cancelActions"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let i={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fields!==void 0){let i=e.fields;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[p]:r.push(p),s++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.submitActions!==void 0){let i=e.submitActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.cancelActions!==void 0){let i=e.cancelActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Us.errors=r,s===0}function Kf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Us(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length),Kf.errors=r,s===0}var Wf=Jf;function Ys(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ys.errors=r,s===0}function Jf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ys(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length),Jf.errors=r,s===0}var Qf=Zf;function zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="alpha"||i==="opacity"||i==="blur"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Be(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return zs.errors=r,s===0}function Zf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return zs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),s=r.length),Zf.errors=r,s===0}var ed=rd;var Of={type:"object",properties:{items:{type:"array",items:{$ref:"#/definitions/audioSound"}},channels:{type:"array",items:{type:"object",properties:{id:{type:"string",minLength:1},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},applyMode:{type:"string",enum:["singleLine","persistent"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1},Rf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function pr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(Rf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Rf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(_e(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)),e.endEffect!==void 0&&(_e(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pr.errors=r,s===0}function Xs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};r===null?r=[p]:r.push(p),s++}}var c=l===s;if(c){let u={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),s++}else s=i,r!==null&&(i?r.length=i:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)pr(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?pr.errors:r.concat(pr.errors),s=r.length)}else{let p={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let d=u[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),s++}if(d.sounds===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="volume"||f==="muted"||f==="pan"||f==="loop"||f==="interruption"||f==="applyMode"||f==="sounds")){let h={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if(Se(f)<1){let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),s++}if(f<0||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let f={instancePath:t+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.pan!==void 0){let f=d.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),s++}if(f<-1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:t+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.interruption!==void 0){let f=d.interruption;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="immediate"||f==="loopEnd")){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:Of.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.applyMode!==void 0){let f=d.applyMode;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="singleLine"||f==="persistent")){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:Of.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let h=f.length;for(let g=0;g<h;g++)pr(f[g],{instancePath:t+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?pr.errors:r.concat(pr.errors),s=r.length)}else{let h={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}}else{let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}}}else{let p={instancePath:t+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}return Xs.errors=r,s===0}function rd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Xs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),s=r.length),rd.errors=r,s===0}var td=nd;var Cf={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function Hs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(typeof e!="string"){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let h=e[f];if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let g={instancePath:t+"/"+f+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let g={instancePath:t+"/"+f+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.furigana!==void 0){let g=h.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let y={instancePath:t+"/"+f+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let y={instancePath:t+"/"+f+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}}}else{let g={instancePath:t+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Hs.errors=r,s===0}function Gs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};r===null?r=[b]:r.push(b),s++}}var m=p===s;if(u=u||m,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.type===void 0&&(A="type")){let k={};r===null?r=[k]:r.push(k),s++}}var m=w===s;if(u=u||m,!u){let A=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.resourceId===void 0&&(E="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var m=A===s;if(u=u||m,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let L={};r===null?r=[L]:r.push(L),s++}}var m=E===s;if(u=u||m,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.transformId===void 0&&(R="transformId")){let T={};r===null?r=[T]:r.push(T),s++}}var m=O===s;if(u=u||m,!u){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.transform===void 0&&(U="transform")){let N={};r===null?r=[N]:r.push(N),s++}}var m=R===s;if(u=u||m,!u){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let H;if(e.x===void 0&&(H="x")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var m=U===s;if(u=u||m,!u){let H=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let K={};r===null?r=[K]:r.push(K),s++}}var m=H===s;if(u=u||m,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let X={};r===null?r=[X]:r.push(X),s++}}var m=M===s;if(u=u||m,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.anchorY===void 0&&(te="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),s++}}var m=le===s;if(u=u||m,!u){let te=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.scaleX===void 0&&(se="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),s++}}var m=te===s;if(u=u||m,!u){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Q;if(e.scaleY===void 0&&(Q="scaleY")){let $={};r===null?r=[$]:r.push($),s++}}var m=se===s;if(u=u||m,!u){let Q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.flipX===void 0&&(j="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var m=Q===s;if(u=u||m,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let W;if(e.flipY===void 0&&(W="flipY")){let de={};r===null?r=[de]:r.push(de),s++}}var m=j===s;if(u=u||m,!u){let W=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ve;if(e.rotation===void 0&&(ve="rotation")){let Ie={};r===null?r=[Ie]:r.push(Ie),s++}}var m=W===s;if(u=u||m,!u){let ve=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let gr={};r===null?r=[gr]:r.push(gr),s++}}var m=ve===s;if(u=u||m,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ze;if(e.originY===void 0&&(Ze="originY")){let ct={};r===null?r=[ct]:r.push(ct),s++}}var m=me===s;if(u=u||m,!u){let Ze=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Sr;if(e.layer===void 0&&(Sr="layer")){let Ur={};r===null?r=[Ur]:r.push(Ur),s++}}var m=Ze===s;if(u=u||m,!u){let Sr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ut;if(e.alpha===void 0&&(ut="alpha")){let jt={};r===null?r=[jt]:r.push(jt),s++}}var m=Sr===s;if(u=u||m,!u){let ut=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Yr;if(e.opacity===void 0&&(Yr="opacity")){let pt={};r===null?r=[pt]:r.push(pt),s++}}var m=ut===s;if(u=u||m,!u){let Yr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let zr;if(e.blur===void 0&&(zr="blur")){let Rn={};r===null?r=[Rn]:r.push(Rn),s++}}var m=Yr===s;if(u=u||m,!u){let zr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Tt;if(e.filters===void 0&&(Tt="filters")){let Dt={};r===null?r=[Dt]:r.push(Dt),s++}}var m=zr===s;if(u=u||m,!u){let Tt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ji;if(e.animations===void 0&&(ji="animations")){let Cn={};r===null?r=[Cn]:r.push(Cn),s++}}var m=Tt===s;u=u||m}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var d=l===s;if(d){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=i,r!==null&&(i?r.length=i:r=null);let f=s,h=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var y=g===s;if(h=h||y,!h){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let A={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[A]:r.push(A),s++}var y=w===s;h=h||y}if(h)s=f,r!==null&&(f?r.length=f:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Hs(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return Gs.errors=r,s===0}function Ks(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="elements"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ks.errors=r,s===0}var Uv={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function Ws(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(Uv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ws.errors=r,s===0}function Js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let m={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=s,g=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.resourceId===void 0&&(v="resourceId")||f.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var i=g===s;if(i){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=h,r!==null&&(h?r.length=h:r=null);let y=s,w=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.resourceId===void 0&&(v="resourceId")||f.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var l=w===s;if(l){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=y,r!==null&&(y?r.length=y:r=null);let b=s,A=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.text===void 0&&(v="text")||f.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=A===s;if(c){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=b,r!==null&&(b?r.length=b:r=null);let k=s,E=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.transformId===void 0&&(v="transformId")||f.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=E===s;if(u){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),s++}for(let v in f)if(!Qe.call(Cf.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),s++}if(f.id!==void 0&&typeof f.id!="string"){let v={instancePath:t+"/items/"+d+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.animationName!==void 0&&typeof f.animationName!="string"){let v={instancePath:t+"/items/"+d+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.animationSpeed!==void 0&&typeof f.animationSpeed!="number"){let v={instancePath:t+"/items/"+d+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.resourceId!==void 0&&typeof f.resourceId!="string"){let v={instancePath:t+"/items/"+d+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.text!==void 0&&(Gs(f.text,{instancePath:t+"/items/"+d+"/text",parentData:f,parentDataProperty:"text",rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length)),f.layout!==void 0&&(Ks(f.layout,{instancePath:t+"/items/"+d+"/layout",parentData:f,parentDataProperty:"layout",rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),s=r.length)),f.transformId!==void 0&&typeof f.transformId!="string"){let v={instancePath:t+"/items/"+d+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.transform!==void 0&&(Ws(f.transform,{instancePath:t+"/items/"+d+"/transform",parentData:f,parentDataProperty:"transform",rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length)),f.x!==void 0&&typeof f.x!="number"){let v={instancePath:t+"/items/"+d+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.y!==void 0&&typeof f.y!="number"){let v={instancePath:t+"/items/"+d+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.anchorX!==void 0&&typeof f.anchorX!="number"){let v={instancePath:t+"/items/"+d+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.anchorY!==void 0&&typeof f.anchorY!="number"){let v={instancePath:t+"/items/"+d+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.scaleX!==void 0&&typeof f.scaleX!="number"){let v={instancePath:t+"/items/"+d+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.scaleY!==void 0&&typeof f.scaleY!="number"){let v={instancePath:t+"/items/"+d+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.flipX!==void 0&&typeof f.flipX!="boolean"){let v={instancePath:t+"/items/"+d+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(f.flipY!==void 0&&typeof f.flipY!="boolean"){let v={instancePath:t+"/items/"+d+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(f.rotation!==void 0&&typeof f.rotation!="number"){let v={instancePath:t+"/items/"+d+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.originX!==void 0&&typeof f.originX!="number"){let v={instancePath:t+"/items/"+d+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.originY!==void 0&&typeof f.originY!="number"){let v={instancePath:t+"/items/"+d+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.layer!==void 0){let v=f.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:Cf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),s++}}if(f.alpha!==void 0){let v=f.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(f.opacity!==void 0){let v=f.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}f.blur!==void 0&&(Be(f.blur,{instancePath:t+"/items/"+d+"/blur",parentData:f,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),f.filters!==void 0&&(fr(f.filters,{instancePath:t+"/items/"+d+"/filters",parentData:f,parentDataProperty:"filters",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),f.animations!==void 0&&(pe(f.animations,{instancePath:t+"/items/"+d+"/animations",parentData:f,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let m={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}return Js.errors=r,s===0}function nd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Js(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),s=r.length),nd.errors=r,s===0}var sd=id;var Yv={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 Qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let y={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[y]:r.push(y),s++}var u=c===s;if(l=l||u,!l){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[b]:r.push(b),s++}var u=y===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let y={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[y]:r.push(y),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var d=m===s;if(d){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=p,r!==null&&(p?r.length=p:r=null);let f=s,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var g=h===s;if(g){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=f,r!==null&&(f?r.length=f:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!(y==="sounds"||y==="resourceId"||y==="volume"||y==="muted"||y==="pan"||y==="loop"||y==="interruption"||y==="startDelayMs")){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let b=0;b<w;b++)pr(y[b],{instancePath:t+"/sounds/"+b,parentData:y,parentDataProperty:b,rootData:a})||(r=r===null?pr.errors:r.concat(pr.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Yv.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Qs.errors=r,s===0}function id(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Qs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),s=r.length),id.errors=r,s===0}var od=ad;var zv={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 Zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};r===null?r=[g]:r.push(g),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let g=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.target===void 0&&(A="target")){let k={};r===null?r=[k]:r.push(k),s++}}var h=w===s;if(h){let A={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[A]:r.push(A),s++}else s=y,r!==null&&(y?r.length=y:r=null);var f=g===s;m=f}if(!m){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),s++}if(e.name===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[g]:r.push(g),s++}if(e.description===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let y={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(!(g==="boolean"||g==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:zv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[y]:r.push(y),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[y]:r.push(y),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return Zs.errors=r,s===0}function ad(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Zs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length),ad.errors=r,s===0}var ld=cd;var Xv={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 Hv={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1};function at(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="value"||i==="duration"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let i={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let i={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.easing!==void 0){let i=e.easing;if(typeof i!="string"){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="linear"||i==="easeInQuad"||i==="easeOutQuad"||i==="easeInOutQuad"||i==="easeInCubic"||i==="easeOutCubic"||i==="easeInOutCubic"||i==="easeInQuart"||i==="easeOutQuart"||i==="easeInOutQuart"||i==="easeInQuint"||i==="easeOutQuint"||i==="easeInOutQuint"||i==="easeInSine"||i==="easeOutSine"||i==="easeInOutSine"||i==="easeInExpo"||i==="easeOutExpo"||i==="easeInOutExpo"||i==="easeInCirc"||i==="easeOutCirc"||i==="easeInOutCirc"||i==="easeInBack"||i==="easeOutBack"||i==="easeInOutBack"||i==="easeInBounce"||i==="easeOutBounce"||i==="easeInOutBounce"||i==="easeInElastic"||i==="easeOutElastic"||i==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:Hv.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return at.errors=r,s===0}function re(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)at(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?at.errors:r.concat(at.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return re.errors=r,s===0}function ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="alpha"||i==="x"||i==="y"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ei.errors=r,s===0}function ri(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="translateX"||i==="translateY"||i==="alpha"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.translateX!==void 0&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ri.errors=r,s===0}function ot(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.tween!==void 0&&(ri(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ot.errors=r,s===0}var $s={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"]}}]},Gv={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function ti(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="texture"||i==="channel"||i==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let i={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.channel!==void 0){let i=e.channel;if(typeof i!="string"){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Gv.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let i={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ti.errors=r,s===0}function ni(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)at(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?at.errors:r.concat(at.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ni.errors=r,s===0}function si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let b={};r===null?r=[b]:r.push(b),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let k={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[k]:r.push(k),s++}var f=b===s;m=f}if(!m){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let h=s,g=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let b={};r===null?r=[b]:r.push(b),s++}var w=y===s;if(s=h,r!==null&&(h?r.length=h:r=null),w){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[k]:r.push(k),s++}var w=b===s;g=w}if(!g){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!Qe.call($s.properties,b)){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:$s.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let b={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.textures!==void 0){let b=e.textures;if(Array.isArray(b)){if(b.length<1){let k={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=b.length;for(let k=0;k<A;k++)if(typeof b[k]!="string"){let E={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}}else{let A={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.items!==void 0){let b=e.items;if(Array.isArray(b)){if(b.length<1){let k={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=b.length;for(let k=0;k<A;k++)ti(b[k],{instancePath:t+"/items/"+k,parentData:b,parentDataProperty:k,rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),s=r.length)}else{let A={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:$s.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:$s.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let b={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let b={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let b={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}e.progress!==void 0&&(ni(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return si.errors=r,s===0}function ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.prev===void 0&&(R="prev")){let T={};r===null?r=[T]:r.push(T),s++}}var p=O===s;if(v=v||p,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let N={};r===null?r=[N]:r.push(N),s++}}var p=R===s;if(v=v||p,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let H;if(e.mask===void 0&&(H="mask")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var p=U===s;v=v||p}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={};r===null?r=[R]:r.push(R),s++}var m=k===s;if(m){let R={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let R={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[R]:r.push(R),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};r===null?r=[b]:r.push(b),s++}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let b=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.tween===void 0&&(R="tween")){let T={};r===null?r=[T]:r.push(T),s++}}var y=k===s;if(y){let R={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[R]:r.push(R),s++}var w=O===s;if(v=v||w,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=R===s;if(v=v||w,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let H={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[H]:r.push(H),s++}var w=U===s;v=v||w}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[R]:r.push(R),s++}var g=b===s;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="complete"||b==="tween"||b==="prev"||b==="next"||b==="mask")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.type!==void 0){let b=e.type;if(typeof b!="string"){let A={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="update"||b==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Xv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let A=b.payload;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let k={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let A={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(ei(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),s=r.length)),e.prev!==void 0&&(ot(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)),e.next!==void 0&&(ot(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)),e.mask!==void 0&&(si(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return ii.errors=r,s===0}function cd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ii(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),s=r.length),cd.errors=r,s===0}var ud=pd;var Kv={type:"object",required:["type"],$defs:{easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},propertyTracks:{type:"object",minProperties:1,properties:{volume:{$ref:"#/$defs/volumeTweenProperty"},pan:{$ref:"#/$defs/panTweenProperty"},playbackRate:{$ref:"#/$defs/playbackRateTweenProperty"}},additionalProperties:!1}},properties:{name:{type:"string"},type:{enum:["update","transition"]},tween:{$ref:"#/$defs/propertyTracks"},prev:{$ref:"#/$defs/propertyTracks"},next:{$ref:"#/$defs/propertyTracks"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{anyOf:[{required:["prev"]},{required:["next"]}],not:{required:["tween"]}}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/audioEffectResource.yaml"};function oi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="number"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}return oi.errors=r,s===0}var Wv={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="string"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let i={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Wv.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),s++}return ai.errors=r,s===0}function dr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="startValue"||i==="value"||i==="duration"||i==="delay"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let i={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.value!==void 0&&(oi(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),s=r.length)),e.duration!==void 0){let i=e.duration;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.delay!==void 0){let i=e.delay;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.easing!==void 0&&(ai(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return dr.errors=r,s===0}function li(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;dr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>100||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(w<0||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>100||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(w<0||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return li.errors=r,s===0}function ci(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)li(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?li.errors:r.concat(li.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ci.errors=r,s===0}function ui(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;dr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>1||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(w<-1||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>1||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(w<-1||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return ui.errors=r,s===0}function pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ui(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pi.errors=r,s===0}function fi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;dr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"&&(w<0||isNaN(w))){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"&&(w<0||isNaN(w))){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return fi.errors=r,s===0}function di(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)fi(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return di.errors=r,s===0}function ur(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="volume"||i==="pan"||i==="playbackRate")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.volume!==void 0&&(ci(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),s=r.length)),e.pan!==void 0&&(pi(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),s=r.length)),e.playbackRate!==void 0&&(di(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?di.errors:r.concat(di.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ur.errors=r,s===0}function mi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.prev===void 0&&(R="prev")){let T={};r===null?r=[T]:r.push(T),s++}}var p=O===s;if(v=v||p,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let N={};r===null?r=[N]:r.push(N),s++}}var p=R===s;v=v||p}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={};r===null?r=[R]:r.push(R),s++}var m=k===s;if(m){let R={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let R={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[R]:r.push(R),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};r===null?r=[b]:r.push(b),s++}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let b=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.tween===void 0&&(R="tween")){let T={};r===null?r=[T]:r.push(T),s++}}var y=k===s;if(y){let R={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[R]:r.push(R),s++}var w=O===s;if(v=v||w,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=R===s;v=v||w}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[R]:r.push(R),s++}var g=b===s;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="tween"||b==="prev"||b==="next")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.type!==void 0){let b=e.type;if(!(b==="update"||b==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Kv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(ur(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length)),e.prev!==void 0&&(ur(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length)),e.next!==void 0&&(ur(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return mi.errors=r,s===0}function pd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return mi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),s=r.length),pd.errors=r,s===0}var fd=dd;function yi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="name"||i==="nameVariableId")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let i={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return yi.errors=r,s===0}function dd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return yi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),s=r.length),dd.errors=r,s===0}var md=yd;var Jv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function hi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!Jv.test(i)){let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return hi.errors=r,s===0}function yd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return hi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),s=r.length),yd.errors=r,s===0}var hd=gd;function gi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let i=e.keyboard;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.keyup!==void 0){let i=e.keyup;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return gi.errors=r,s===0}function gd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return gi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),s=r.length),gd.errors=r,s===0}var bd=wd;function bi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return bi.errors=r,s===0}function wd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return bi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length),wd.errors=r,s===0}var Id=vd;function wi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return wi.errors=r,s===0}function vd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return wi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length),vd.errors=r,s===0}var kd=Ad;function Ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ii.errors=r,s===0}var $f=new RegExp("^\\$(if .+|for .+|else)$","u"),Ha={validate:wn};function vi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!$f.test(i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}for(let i in e)if($f.test(i)){let l=e[i];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)Ha.validate(l[u],{instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?Ha.validate.errors:r.concat(Ha.validate.errors),s=r.length)}else{let c={instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return vi.errors=r,s===0}function wn(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;Ii(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;vi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),s=r.length);var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return wn.errors=r,s===0}function ki(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)wn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?wn.errors:r.concat(wn.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return ki.errors=r,s===0}var Ga={validate:In};function In(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(ki(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),s=r.length)),e.children!==void 0){let i=e.children;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)Ga.validate(i[c],{instancePath:t+"/children/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Ga.validate.errors:r.concat(Ga.validate.errors),s=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return In.errors=r,s===0}function Ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)In(i[c],{instancePath:t+"/elements/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?In.errors:r.concat(In.errors),s=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.transitions!==void 0){let i={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ai.errors=r,s===0}function Ad(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ai(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),s=r.length),Ad.errors=r,s===0}var Pd=Ed;function Pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=null,u=s,p=s,m=s,d=s,f=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let E={};r===null?r=[E]:r.push(E),s++}}var g=h===s;if(f=f||g,!f){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.texture===void 0&&(v="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var g=k===s;if(f=f||g,!f){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.behaviors===void 0&&(L="behaviors")){let R={};r===null?r=[R]:r.push(R),s++}}var g=v===s;if(f=f||g,!f){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.emitter===void 0&&(T="emitter")){let U={};r===null?r=[U]:r.push(U),s++}}var g=L===s;f=f||g}}}if(f)s=d,r!==null&&(d?r.length=d:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=m===s;if(y){let k={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[k]:r.push(k),s++}else s=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let k={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[k]:r.push(k),s++}var b=u===s;b&&(l=!0,c=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}if(e.behaviors===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[k]:r.push(k),s++}if(e.emitter===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[k]:r.push(k),s++}}var b=w===s;if(b&&l?(l=!1,c=[c,1]):b&&(l=!0,c=1),l)s=i,r!==null&&(i?r.length=i:r=null);else{let k={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[k]:r.push(k),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[k]:r.push(k),s++}if(e.height===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[k]:r.push(k),s++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[E]:r.push(E),s++}if(k.appearance===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[E]:r.push(E),s++}for(let E in k)if(!(E==="emission"||E==="movement"||E==="appearance"||E==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let E=k.emission;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.movement!==void 0){let E=k.movement;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.appearance!==void 0){let E=k.appearance;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.bounds!==void 0){let E=k.bounds;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[E]:r.push(E),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0){let k=e.texture,E=s,v=!1,O=null,L=s;if(typeof k=="string"){if(Se(k)<1){let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[T]:r.push(T),s++}}else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[T]:r.push(T),s++}var A=L===s;A&&(v=!0,O=0);let R=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[T]:r.push(T),s++}var A=R===s;if(A&&v?(v=!1,O=[O,1]):A&&(v=!0,O=1),v)s=E,r!==null&&(E?r.length=E:r=null);else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[T]:r.push(T),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let v={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let E=k.length;for(let v=0;v<E;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[L]:r.push(L),s++}for(let L in O)if(!(L==="type"||L==="config")){let R={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"};r===null?r=[R]:r.push(R),s++}if(O.type!==void 0){let L=O.type;if(typeof L=="string"){if(Se(L)<1){let R={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[R]:r.push(R),s++}}else{let R={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[R]:r.push(R),s++}}if(O.config!==void 0){let L=O.config;if(!(L&&typeof L=="object"&&!Array.isArray(L))){let R={instancePath:t+"/behaviors/"+v+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[R]:r.push(R),s++}}}else{let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),s++}}}else{let E={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[E]:r.push(E),s++}if(k.lifetime!==void 0){let E=k.lifetime;if(E&&typeof E=="object"&&!Array.isArray(E)){if(E.min===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),s++}if(E.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),s++}if(E.min!==void 0){let v=E.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(E.max!==void 0){let v=E.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}}else{let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}return Pi.errors=r,s===0}function Ed(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Pi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),s=r.length),Ed.errors=r,s===0}var xd=Sd;var _f={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 Ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(_f.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:_f.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ei.errors=r,s===0}function Sd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ei(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),s=r.length),Sd.errors=r,s===0}var Od=Rd;var Qv=new RegExp("^.+$","u");function xi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.jsonData===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="jsonData"||i==="width"||i==="height"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.jsonData!==void 0){let i=e.jsonData;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(Qv.test(l)){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)if(typeof u[m]!="number"){let d={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+m,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}}else{let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}}else{let l={instancePath:t+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return xi.errors=r,s===0}function Rd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return xi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),s=r.length),Rd.errors=r,s===0}var Cd=$d;var Nf={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 Si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};r===null?r=[l]:r.push(l),s++}if(e.fontSize===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};r===null?r=[l]:r.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};r===null?r=[l]:r.push(l),s++}if(e.colorId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[l]:r.push(l),s++}for(let l in e)if(!Qe.call(Nf.properties,l)){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,m=s;if(typeof l=="string"){if(Se(l)<1){let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}var i=m===s;i&&(u=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let y={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[y]:r.push(y),s++}let f=l.length;for(let y=0;y<f;y++){let w=l[y];if(typeof w=="string"){if(Se(w)<1){let b={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}}let h=l.length,g;if(h>1){let y={};for(;h--;){let w=l[h];if(typeof w=="string"){if(typeof y[w]=="number"){g=y[w];let b={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:h,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+h+" are identical)"};r===null?r=[b]:r.push(b),s++;break}y[w]=h}}}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),s++}var i=d===s;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)s=c,r!==null&&(c?r.length=c:r=null);else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:t+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:t+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight!==void 0&&typeof e.fontWeight!="string"){let l={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:Nf.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Se(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Si.errors=r,s===0}function $d(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Si(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),s=r.length),$d.errors=r,s===0}var _d=Nd;var Zv={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function Oi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Qe.call(Zv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0){let i=e.x;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.y!==void 0){let i=e.y;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Oi.errors=r,s===0}function Nd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Oi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Oi.errors:r.concat(Oi.errors),s=r.length),Nd.errors=r,s===0}var jd=Td;function Ri(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ri.errors=r,s===0}function Td(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ri(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ri.errors:r.concat(Ri.errors),s=r.length),Td.errors=r,s===0}var An=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),kn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),xr=e=>e===void 0?void 0:structuredClone(e),ek=Object.freeze({achievement:"achievements",animation:"animations",audioEffect:"audioEffects",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),rk=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),tk=Object.freeze({background:jf,bgm:Df,character:Mf,choice:qf,cleanAll:Bf,control:Yf,dialogue:Xf,form:Gf,layout:Wf,screen:Qf,sfx:ed,visual:td,voice:sd}),nk=Object.freeze({achievement:od,animation:ld,audioEffect:ud,character:fd,color:md,control:hd,font:bd,image:Id,layout:kd,particle:Pd,sound:xd,spritesheet:Od,textStyle:Cd,transform:_d,video:jd}),sk=new Set(["files","language","patches"]),ik=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),ok=new Set(["lineId","mode","payload","type"]),ak=new Set(["mode","payload","sceneId","type"]),lk=new Set(["mode","operation","payload","resourceId","type"]),ck=new Set(["fileId","mimeType"]),G=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},sr=(e,t)=>{kn(e)||G(t,"expected an object")},Ka=(e,t)=>{Array.isArray(e)||G(t,"expected an array")},_t=(e,t)=>{(typeof e!="string"||e.length===0)&&G(t,"expected a non-empty string")},Vd=(e,t)=>{typeof e!="string"&&G(t,"expected a string")},yr=(e,t,n)=>{for(let o of Object.keys(e))t.has(o)||G(`${n}.${o}`,"unknown field")},hr=(e,t,n)=>{for(let o of t)An(e,o)||G(n,`missing required field "${o}"`)},uk=e=>e.replaceAll("~1","/").replaceAll("~0","~"),pk=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(uk);return t?.keyword==="required"?n.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&n.push(t.params.additionalProperty),n.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},fk=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,n)=>{if(t===void 0)return n;let o=n.instancePath.split("/").length,a=t.instancePath.split("/").length;return o>a?n:t},void 0)??e[0],qd=({value:e,validator:t,path:n,contract:o})=>{if(t(e))return;let a=fk(t.errors);G(pk(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Ci=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||G(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,a)=>Ci(o,`${t}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>Ci(a,`${t}.${o}`,n))}},mr=(e,t)=>{e===""&&G(t,"expected a non-empty resourceId")},dk=(e,t,n)=>{let o=(s,i)=>mr(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>mr(l?.resourceId,`${i}[${c}].resourceId`)),r=(s,i)=>{mr(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":mr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"bgm":o(t.audioEffects,`${n}.audioEffects`),r(t,n);break;case"voice":r(t,n);break;case"sfx":a(t.items,`${n}.items`),(t.channels??[]).forEach((s,i)=>a(s?.sounds,`${n}.channels[${i}].sounds`));break;case"character":(t.items??[]).forEach((s,i)=>{(s.sprites??[]).forEach((l,c)=>mr(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":mr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"control":mr(t.resourceId,`${n}.resourceId`);break;case"dialogue":mr(t.ui?.resourceId,`${n}.ui.resourceId`),o(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,i)=>mr(s?.resourceId,`${n}.character.sprite.items[${i}].resourceId`)),o(t.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(t.animations,`${n}.animations`);break;case"visual":(t.items??[]).forEach((s,i)=>{mr(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},Nt=(e,t)=>{_t(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&G(t,`"${e}" is not a safe ID`)},mk=(e,t)=>{_t(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&G(t,"must be a safe single filename")},vn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((a,r)=>vn(a,t[r]));if(!kn(e)||!kn(t))return!1;let n=Object.keys(e).sort(),o=Object.keys(t).sort();return vn(n,o)&&n.every(a=>vn(e[a],t[a]))},$i=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>$i(o,t,n)),t;if(!kn(e)||n.has(e))return t;n.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&t.add(a),$i(a,t,n);return t},yk=e=>{let t=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(o?.sections??{}))for(let[s,i]of(r?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=t.get(i.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:i}),t.set(i.id,l)}return t},Fd=(e,t,n)=>{let o=e.get(t)??[];return o.length===0&&G(n,`lineId "${t}" does not exist in projectData`),o.length>1&&G(n,`lineId "${t}" is not globally unique in projectData`),o[0]},Bd=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Dd=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Ld=e=>{let t=xr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))kn(n)&&delete n.placeholder;return t},hk=(e,t,n,o)=>{e==="choice"&&!vn(Dd(t),Dd(n))&&G(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!vn(Ld(t),Ld(n))&&G(o,"form behavior must remain identical; only presentation fields and placeholders may change")},gk=({patch:e,path:t,lineIndex:n})=>{yr(e,ik,t),hr(e,["type","lineId","actionType","payload"],t),Nt(e.lineId,`${t}.lineId`),_t(e.actionType,`${t}.actionType`),sr(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'line.action supports only "replace"'),rk.has(e.actionType)||G(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=Fd(n,e.lineId,`${t}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&G(`${t}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&G(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),An(e.payload,"content")&&G(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&G(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),hk(e.actionType,a,e.payload,`${t}.payload`),qd({value:e.payload,validator:tk[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Ci(e.payload,`${t}.payload`),dk(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},bk=(e,t)=>{Ka(e,t),e.forEach((n,o)=>{sr(n,`${t}[${o}]`),yr(n,new Set(["text"]),`${t}[${o}]`),hr(n,["text"],`${t}[${o}]`),Vd(n.text,`${t}[${o}].text`)})},wk=({patch:e,path:t,lineIndex:n})=>{yr(e,ok,t),hr(e,["type","lineId","payload"],t),Nt(e.lineId,`${t}.lineId`),sr(e.payload,`${t}.payload`),yr(e.payload,new Set(["content"]),`${t}.payload`),hr(e.payload,["content"],`${t}.payload`),bk(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'line.dialogue supports only "replace"');let o=Fd(n,e.lineId,`${t}.lineId`);return o.line?.actions?.dialogue===void 0&&G(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},Ik=({patch:e,path:t,projectData:n})=>(yr(e,ak,t),hr(e,["type","mode","sceneId","payload"],t),Nt(e.sceneId,`${t}.sceneId`),sr(e.payload,`${t}.payload`),yr(e.payload,new Set(["name"]),`${t}.payload`),hr(e.payload,["name"],`${t}.payload`),Vd(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&G(`${t}.mode`,'story.scene requires "patch"'),An(n?.story?.scenes??{},e.sceneId)||G(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),vk=(e,t,n)=>{sr(t,n),["font","image","sound","spritesheet","video"].includes(e)&&_t(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||G(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||G(`${n}.height`,"expected an integer")),e==="spritesheet"&&(sr(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||G(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||G(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&G(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),qd({value:t,validator:nk[e],path:n,contract:`the resource.${e} schema`}),Ci(t,n)},kk=({patch:e,path:t,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{yr(e,lk,t),hr(e,["type","resourceId","payload"],t),Nt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=ek[r];s||G(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&G(`${t}.operation`,'the only resource operation is "add"'),vk(r,e.payload,`${t}.payload`);let i=n?.resources?.[s]??{},l=An(i,e.resourceId);e.operation==="add"&&l&&G(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&G(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of $i(e.payload))!o.has(c)&&!a.has(c)&&G(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:t,patch:e}},Md=({resources:e,collectionName:t,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!An(e?.[t]??{},n))&&G(o,`${a} resource "${n}" was not found`)},Ak=(e,t)=>{let n=xr(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=xr(a.patch.payload));let o=n.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,s=Array.isArray(r.fontId)?r.fontId:[r.fontId];s.forEach((i,l)=>Md({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])Md({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},Pk=({patch:e,path:t,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(sr(e,t),_t(e.type,`${t}.type`),e.type==="line.action")return gk({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return wk({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return Ik({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return kk({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});G(`${t}.type`,`unsupported patch type "${e.type}"`)},Ek=(e,t)=>{Ka(e,t);let n=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;sr(o,r),yr(o,ck,r),hr(o,["fileId"],r),mk(o.fileId,`${r}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&G(`${r}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&G(`${r}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},xk=({packageId:e,packageData:t,path:n,projectData:o,lineIndex:a,canonicalFileIds:r})=>{sr(t,n),yr(t,sk,n),hr(t,["language","files","patches"],n),_t(t.language,`${n}.language`);let s=Ek(t.files,`${n}.files`);Ka(t.patches,`${n}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=Pk({patch:c,path:`${n}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return i.has(p.key)&&G(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},Ud=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};sr(t,"l10nData"),yr(t,new Set(["packages"]),"l10nData"),hr(t,["packages"],"l10nData"),sr(t.packages,"l10nData.packages");let n=yk(e),o=$i(e?.resources??{}),a=new Map,r=new Map;for(let[s,i]of Object.entries(t.packages)){Nt(s,`l10nData.packages.${s}`);let l=xk({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&G(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&G(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}Ak(e,l),a.set(s,l)}return{packages:a}},Sk=(e,t)=>{let{collectionName:n,patch:o}=t;e.resources[n]??={},e.resources[n][o.resourceId]=xr(o.payload)},Ok=(e,t)=>{let{patch:n}=t,o=e.story.scenes[n.sceneId];o.name=n.payload.name},Rk=(e,t)=>{let{location:n,patch:o}=t,a=Bd(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=xr(o.payload);return}let r=xr(n.line.actions.dialogue.content);a.actions.dialogue=xr(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},Ck=(e,t)=>{let{location:n,patch:o}=t,a=Bd(e,n);a.actions.dialogue.content=xr(o.payload.content)},Yd=({projectData:e,l10nData:t})=>{let n=Ud({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},_i=({projectData:e,l10nData:t,l10nId:n=null})=>{let o=Ud({projectData:e,l10nData:t});if(n!==null&&(Nt(n,"l10nId"),o.packages.has(n)||G("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=xr(e),r=o.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>Sk(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>Ok(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>Rk(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>Ck(a,s)),a};var Wa=Object.freeze({auto:1e3,skip:80,authored:1e3}),xn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),zd=new WeakMap,$k=new ArrayBuffer(8),Ja=new DataView($k),_k=e=>{let t=zd.get(e);if(t)return t;let n={dispatchDepth:0};return zd.set(e,n),n},Nk=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},jk=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Br=(e,t,n)=>{if(!Nk(e)||!jk(e,t))throw new TypeError(`${n} has an invalid shape`)},Pn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},En=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},Xd=e=>{if(En(e,"duration"),e===0)return 0n;Ja.setFloat64(0,e,!1);let t=Ja.getUint32(0,!1),n=Ja.getUint32(4,!1),o=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(n);if(o===0)return a;let r=1n<<52n|a,s=o-1;return r<<BigInt(s)},Tk=e=>structuredClone(e),Qa=(e,t)=>e===t?!0:!e||!t||e.mode!==t.mode||e.kind!==t.kind?!1:e.mode==="legacy"?e.instanceToken===t.instanceToken:e.delayMs!==t.delayMs?!1:e.kind==="auto"?e.contentKey===t.contentKey&&e.owner.sessionId===t.owner.sessionId&&e.owner.lineEntryId===t.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===t.owner.sessionId:e.trigger===t.trigger&&e.owner.lineEntryId===t.owner.lineEntryId,Za=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(Br(t,["owner","delayMs","contentKey"],"auto timer"),Br(t.owner,["sessionId","lineEntryId"],"auto timer owner"),Pn(t.owner.sessionId,"auto owner sessionId"),Pn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(En(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Br(t,["owner","delayMs"],"skip timer"),Br(t.owner,["sessionId"],"skip timer owner"),Pn(t.owner.sessionId,"skip owner sessionId"),En(t.delayMs,"skip delayMs");else{if(Br(t,["owner","delayMs","trigger"],"authored timer"),Br(t.owner,["lineEntryId"],"authored timer owner"),Pn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(En(t.delayMs,"authored delayMs"),t.trigger!=="fromStart"&&t.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...Tk(t)}},Dk=e=>{if(Br(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(Pn(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}}Br(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:Za("auto",e.timers.auto,e.lineEntryId),skip:Za("skip",e.timers.skip,e.lineEntryId),authored:Za("authored",e.timers.authored,e.lineEntryId)};if(t.auto&&t.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:t}},el=e=>({descriptor:e,remainingQuanta:Xd(e.delayMs)}),Ni=["auto","skip","authored"],Hd=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof t!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let o=_k(e),a=!0,r={},s={},i=null,l=null,c=null,u=null,p=!1,m=!1,d="legacy",f={auto:null,skip:null,authored:null},h={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},y=()=>Ni.some(M=>f[M]),w=()=>{l=null,c=null},b=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||m){b();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},A=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=i;M&&(w(),i=null,u=M,e.remove(M),u===M&&(u=null))},E=()=>{f={auto:null,skip:null,authored:null}},v=()=>{E(),s={},m||k()},O=M=>{if(o.dispatchDepth>0||m){c=M,b();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},L=()=>{if(!a||!y()||i)return;A();let M=r,K=s,le={},X=oe=>{if(!a||M!==r||K!==s||le!==l||X!==i||m)return;if(!oe||typeof oe.deltaMS!="number"||!Number.isFinite(oe.deltaMS)||oe.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let se=Xd(oe.deltaMS);m=!0,o.dispatchDepth+=1;let ue=s,Q=null;try{let $=[];for(let j of Ni){let F=f[j];F&&(F.remainingQuanta<=se?($.push({kind:j,descriptor:F.descriptor,revision:g[j]}),f[j]=null):F.remainingQuanta-=se)}if($.length>0){try{t({dueKinds:$.map(({kind:j})=>j)})}catch(j){let F=n(j);if(d==="reconciled"&&F==="preCommit")for(let{kind:W,descriptor:de}of $)h[W]=de;else d==="legacy"&&E();throw j}if(d==="legacy")for(let j of $)j.kind==="skip"&&g.skip===j.revision&&f.skip===null&&(f.skip=el(j.descriptor))}}catch($){Q=$}finally{o.dispatchDepth-=1,m=!1;try{ue===s?y()?L():k():i===X&&!y()&&k()}catch($){throw Q?new AggregateError([Q,$],"Playback attempt and ticker cleanup both failed"):$}}if(Q)throw Q},te={callback:X,lifecycleToken:M,generationToken:K,registrationToken:le};i=X,c=te;try{e.add(X)}catch(oe){throw i=null,w(),E(),s={},u=X,oe}O(te)},R=M=>{g[M]+=1,f[M]=null,h[M]=null,!y()&&!m&&k()},T=(M,K)=>{En(K,`${M} delay`),d="legacy",g[M]+=1,h[M]=null,f[M]=el({mode:"legacy",kind:M,instanceToken:{},delayMs:K}),L()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return T("auto",M.payload?.delay??Wa.auto),!0;case"clearAutoNextTimer":return R("auto"),!0;case"startSkipNextTimer":return T("skip",M.payload?.delay??Wa.skip),!0;case"clearSkipNextTimer":return R("skip"),!0;case"nextLineConfigTimer":return T("authored",M.payload?.delay??Wa.authored),!0;case"clearNextLineConfigTimer":return R("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let K;try{K=Dk(M)}catch(X){try{v()}catch(te){throw new AggregateError([X,te],"Playback schedule validation and cleanup both failed")}throw X}if(d="reconciled",K.status==="unsettled"){E(),m||k();return}let le={};for(let X of Ni){let te=K.timers[X],oe=h[X];if(oe&&(!te||!Qa(oe,te))&&(h[X]=null),te&&h[X]&&Qa(h[X],te)){le[X]=null;continue}let se=f[X];le[X]=te&&se&&Qa(se.descriptor,te)?se:te?el(te):null}f=le,y()?L():m||k()},reset:()=>{let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);r={},s={},w(),i=null,u=null,E(),h={auto:null,skip:null,authored:null};for(let X of Ni)g[X]+=1;d="legacy",a=!0;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K},dispose:()=>{a=!1,r={},s={},w(),E(),h={auto:null,skip:null,authored:null};let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);i=null,u=null;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K}}};var Lk=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),Mk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),rl="conditional",Sn="random",nl=Symbol("conditionalAutoContinue"),Vk=new Set(["sectionTransition","resetStoryAtSection"]),qk=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),Fk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Bk=new Set(["nextLine","nextLineFromSystem"]),Uk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),tl="form",Yk=new Set(["submitForm","cancelForm"]),zk="showImageGalleryVariant",Xk="playMusicRoomTrack",Hk="startSceneReplay",Gk="channel:bgm",Gd=1e3,Kk=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"]),Ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Wk=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,On=e=>e?.type===nl,lt=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Jk=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function sl(e){let t=Wk(),n,o=0,a=!1,r=0,s=null,i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],w=[],b=!1,A=null,k=null,E=null,v=null,O=new Map,L,R,T=null,U=!1,N=!1,H=0,fe=new Map,M=yc(e.randomSource),{handlePendingEffects:K}=e;if(typeof K!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=K.bind(K),X=typeof K.reconcilePlaybackScheduleV1=="function"?K.reconcilePlaybackScheduleV1.bind(K):null,te=typeof K.reset=="function"?K.reset.bind(K):null,oe=typeof K.dispose=="function"?K.dispose.bind(K):null;if(X&&(!te||!oe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let se=I=>{if(N)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ue=I=>{if(se(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},Q=(I,P)=>{if(H===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},C=fe.get(I);(C===void 0||S[P]>S[C])&&fe.set(I,P)},$=I=>{let P=fe.get(I)??"preCommit";return fe.delete(I),P},j=I=>{if(X){N=!0;try{let P=X(structuredClone(I));if(P!==null&&(typeof P=="object"||typeof P=="function")&&typeof P.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{N=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),W=I=>{if(!(!X||!a||!n)){U=!0;try{j(F())}catch(P){if(I){let S=new AggregateError([I,P],"Playback work and schedule invalidation both failed");throw fe.delete(I),Q(S,"reconcileFailed"),S}throw Q(P,"reconcileFailed"),P}}},de=()=>{if(!X||!U||!a||!n||i>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(P){throw Q(P,"reconcileFailed"),W(P),P}try{j({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(P){throw Q(P,"reconcileFailed"),W(P),P}U=!1},ve=(I=new Map,P=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>P<S.expiresAt).map(([S,C])=>[S,{animation:structuredClone(C.animation),startedAt:C.startedAt,expiresAt:C.expiresAt}])),Ie=(I=new Map)=>Array.from(I.values()).map(P=>structuredClone(P.animation)),me=(I=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,P])=>I<P.expiresAt))},gr=()=>{if(!a||i>0||l)return;l=!0;let I=0;try{for(;n.selectPendingEffects().length>0;){let P=n.selectCurrentPointer()?.pointer??null;if(I>=Gd){let _=new Error(`RouteEngine exceeded ${Gd} synchronous effect batches at section "${P?.sectionId}", line "${P?.lineId}". Check for an immediate routing cycle.`);throw Q(_,"postCommitUnsettled"),W(_),_}I+=1;let S=[...n.selectPendingEffects()],C=S.map(_=>_.name!=="handleLineActions"?_:{..._,payload:{..._.payload,pointer:structuredClone(P)}});n.clearPendingEffects();try{let _=X?C.filter(B=>!xn.has(B.name)):C;_.length>0&&le(_)}catch(_){throw n.clearPendingEffects(),S.forEach(B=>{n.appendPendingEffect(B)}),Q(_,"postCommitUnsettled"),W(_),_}}}finally{l=!1}de()},Ze=I=>{i+=1;let P=!1;try{let S=I();return P=!0,S}finally{i-=1,P&&gr()}},ct=()=>ra({presentationState:n.selectPresentationState(),previousBgmRender:ut(),resources:n.selectBgmResources(),...n.selectBgmPlaybackContext()}),Sr=()=>structuredClone(n.selectPresentationState()?.bgm??null),Ur=()=>n.selectBgmResources(),ut=()=>({channel:A,bgm:k,resources:E}),jt=I=>!!I?.audioEffects,Yr=()=>structuredClone(b?A:ct()),pt=()=>b?structuredClone(k):Sr(),zr=()=>b?structuredClone(E):Ur(),Rn=I=>n.selectSceneIdForSection({sectionId:I}),Tt=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,P=new Set(I?[]:y.map(S=>S.id));w.forEach(S=>{S.status=S.effects?.some(C=>P.has(C.id))?"active":"settled"}),I&&(y=[]),w=[]},Dt=(I,P,S,C,_,B,z)=>{let J=n.selectPlaybackLineEntryId?.()??0,ce=(P.actionPath??["bgm"]).join("."),he=n.selectCurrentPointer()?.pointer,be=he?.sceneId??Rn(he?.sectionId),ke=P.rollbackSource==="line"&&he?`story.scenes[${JSON.stringify(be)}].sections[${JSON.stringify(he.sectionId)}].lines[${JSON.stringify(he.lineId)}].actions.${ce}`:ce,Oe=P.rollbackSource==="line"?`${o}:${J}:${ke}`:null,Ye=Oe?O.get(Oe):null;if(Ye)return Ye;g+=1;let je={occurrenceId:`${t}:g${o}:l${J}:audio${g}`,actionPath:ke,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Te=Ur(),Re=$c({occurrence:je,resources:Te,previousResources:z??Te,nextResources:Te,previousChannel:S,nextChannel:C,previousBgm:_,nextBgm:B});if(je.effects=structuredClone(Re),je.status=Re.length>0?"pending":"settled",y=structuredClone(Re),w.push(je),Oe)for(O.set(Oe,je);O.size>512;){let dt=O.keys().next().value;O.delete(dt)}return je},ji=({initialState:I,namespace:P})=>{se("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:C,..._}=I,B=C===void 0?void 0:structuredClone(C),z=structuredClone(I.projectData),J=Yd({projectData:z,l10nData:B}),ce=_.global??{};if(!Ue(ce))throw new Error("Malformed global state.");let he=ce.runtime??{};if(!Ue(he))throw new Error("Malformed global.runtime.");let be=he.localizationPackageId;if(be!=null&&typeof be!="string")throw new Error("localizationPackageId requires a string or null value");let ke=new Set(J.map(({l10nId:Te})=>Te).filter(Te=>Te!==null)),Oe=typeof be=="string"&&ke.has(be)?be:null,Ye=_i({projectData:z,l10nData:B,l10nId:Oe}),je=wf({..._,global:{...ce,localizationPackages:J,runtime:{...he,localizationPackageId:Oe}},projectData:Ye,initialAudioCommandId:S});te?.(),n=je,o+=1,a=!0,r=0,s=$t(P),i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],w=[],b=!1,A=null,k=null,E=null,v={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Ur()},O=new Map,L=z,R=B,T=Oe,U=!0,N=!1,H=0,fe.clear(),n.appendPendingEffect({name:"handleLineActions"}),gr()},Cn=()=>{se("dispose"),a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,y=[],w=[],b=!1,A=null,k=null,E=null,v=null,O=new Map,U=!1,fe.clear(),oe?.())},Zd=()=>s,em=()=>n.selectPresentationState(),rm=()=>n.selectPresentationChanges(),tm=I=>n.selectSectionLineChanges(I),ol=(I={})=>{ue("rendering"),r+=1;let P=Date.now();me(P);let S=f.size>0,C=ve(d,P),_=S?ve(f,P):new Map,B=n.selectRenderState({previousBgmRender:ut(),activePersistentAnimations:Ie(C),restoredPersistentAnimations:Ie(_),activeAudioEffects:structuredClone(y)}),z={...B,id:`render-${t}-${o}-${r}`};return h.set(z.id,{builtAt:P,persistentAnimationSessions:new Map([..._.entries(),...C.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectIds:y.map(J=>J.id),bgmPresentation:Sr(),bgmResources:Ur(),retainsActiveAudioEffects:y.length>0&&y.every(J=>(B.audioEffects??[]).some(ce=>ce.id===J.id))}),z},nm=(I={})=>ol(I),sm=(I={})=>ol(I),im=I=>{if(!a||!n)return;let P=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=P?h.get(P):null;P&&h.delete(P);let C=I?.audio?.find(B=>B?.id===Gk);b=!0,A=C?structuredClone(C):null,k=structuredClone(S?.bgmPresentation??null),E=structuredClone(S?.bgmResources??null);let _=new Map;yu(I?.animations).forEach(B=>{let z=fs(B);if(!z)return;let J=S?.persistentAnimationSessions?.get(z)??d.get(z),ce=Math.max(0,bu(B)),he=J?.startedAt??S?.builtAt??Date.now();_.set(z,{animation:structuredClone(B),startedAt:he,expiresAt:he+ce})}),d=_,S?.usedRestoredPersistentAnimationSessions&&(f=new Map),S?.activeAudioEffectIds?.length>0&&!S.retainsActiveAudioEffects&&y.length===S.activeAudioEffectIds.length&&S.activeAudioEffectIds.every(B=>y.some(z=>z.id===B))&&(y=[])},om=()=>n.selectSystemState(),am=()=>n.selectAchievements(),lm=I=>n.selectAchievement(I),al=()=>n.selectSaveSlotMap(),cm=I=>n.selectSaveSlot(I),um=I=>n.selectSaveSlotPage(I),pm=()=>n.selectImageGallery(),fm=()=>n.selectMusicRoom(),dm=()=>n.selectSceneReplay(),mm=()=>n.selectIsSceneReplayActive(),uA=()=>n.selectSkipMode(),pA=()=>n.selectAutoMode(),ym=()=>n.selectRuntime(),hm=()=>n.selectIsChoiceVisible(),gm=()=>n.selectIsFormVisible(),bm=()=>n.selectActiveInteraction(),wm=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),ll=(I,P,S={})=>!Ue(P)||I!=="nextLine"?P:S.bypassChoice===!0?{...P,bypassChoice:!0}:S.interactionSource===tl?{...P,_interactionSource:tl}:P,cl=(I={})=>({type:nl,payload:ll("nextLine",{_conditionalContinuation:!0},I)}),Ti=(I,P)=>On(I)?{type:nl,payload:{...I.payload,...P.payload}}:P,Im=I=>{I.savedCheckpointOccurrences.forEach(P=>{n.markSavedRollbackCheckpointTransient(P)}),I.savedCheckpointOccurrences=[]},vm=(I,P)=>{let S=p;return p=null,!S||!lt(S.pointer,I)||S.checkpointIndex!==P?.checkpointIndex||S.checkpointIdentity!==P?.checkpoint?[]:S.savedCheckpointOccurrences},km=I=>{let P=m;return!P||!lt(P.pointer,I)?null:(m=null,P)},Am=({actionType:I,pointerBeforeAction:P,pointerAfterAction:S,cursorBeforeAction:C,cursorAfterAction:_,wasSceneReplayActive:B,isSceneReplayActive:z})=>{!S||!(!lt(P,S)||C?.checkpoint!==_?.checkpoint||C?.checkpointIndex!==_?.checkpointIndex||I==="jumpToLine")||(m={pointer:S,appendToPrevious:Bk.has(I)&&B===z&&P?.sectionId===S.sectionId&&P?.lineId!==S.lineId,reuseExistingOccurrence:Uk.has(I),forceNewOccurrence:I==="jumpToLine"})},ul=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),Im(I))},Pm=(I,P,S)=>qk.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==P?.checkpoint:S?.checkpoint!==P?.checkpoint&&S?.checkpointIndex>P?.checkpointIndex:!1,Em=I=>{let P=u.at(-1);if(!P?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&P.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:P.rollbackCursor?.checkpointIndex,sectionId:P.pointer?.sectionId,lineId:P.pointer?.lineId})},xm=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(P=>{let S=n.selectSaveSlot({slotId:P.slotId});S&&(P.saveSlotIdentity=S)})},Sm=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},Om=(I,P,S)=>{let C=u.at(-1);if(!C)return;let _=n.selectCurrentPointer()?.pointer,B=Pm(I,P,S);if(lt(C.pointer,_)){let z=S?.checkpoint!==P?.checkpoint||S?.checkpointIndex!==P?.checkpointIndex;B||z&&Fk.has(I)?(ul(C),C.pointer=_,C.rollbackCursor=S,C.markCurrentCheckpointTransient=B,C.savedCheckpointOccurrences=[]):z&&I==="updateProjectData"&&(C.rollbackCursor=S);return}ul(C),C.pointer=_,C.rollbackCursor=n.selectRollbackCursor?.()??null,C.markCurrentCheckpointTransient=B,C.savedCheckpointOccurrences=[]},ft=(I,P)=>{if(ue(`action "${I}"`),!n[I])return;let S=P,C,_;if(I==="updateProjectData")pl(P),C=structuredClone(P.projectData),S={...P,projectData:_i({projectData:C,l10nData:R,l10nId:T})},pl(S);else if(I==="updateLocalizationPackage"){if(_=Rm(P),_===T)return;S={l10nId:_,projectData:_i({projectData:L,l10nData:R,l10nId:_})}}Vk.has(I)&&(c+=1);let B=n.selectAutoMode(),z=B?n.selectRuntime():null,J=n.selectIsSceneReplayActive?.()===!0,ce=Mk.has(I)?ve(d):null,he=n.selectCurrentPointer()?.pointer??null,be=n.selectRollbackCursor?.()??null,ke=ts(I),Oe=ke?n.selectPlaybackLineEntryId?.()??0:null,Ye=ke?Yr():null,je=ke?pt():null,Te=ke?zr():null,Re=!1,dt;try{dt=n[I](S),Re=!0}catch(Lt){throw Q(Lt,"preCommit"),Lt}C!==void 0&&(L=C),_!==void 0&&(T=_),Lk.has(I)&&(f=ce??new Map,d=new Map,y=[]),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=[]);let gl=n.selectIsSceneReplayActive?.()===!0;J!==gl&&(d=new Map,f=new Map);let Um=n.selectCurrentPointer()?.pointer??null,bl=n.selectRollbackCursor?.()??null,wl=ke?n.selectPlaybackLineEntryId?.()??0:null;ke&&wl!==Oe&&(v={lineEntryId:wl,channel:Ye,presentation:je,resources:Te}),I==="saveSlot"?Em(P):I==="updateProjectData"&&xm(),Om(I,be,bl),Am({actionType:I,pointerBeforeAction:he,pointerAfterAction:Um,cursorBeforeAction:be,cursorAfterAction:bl,wasSceneReplayActive:J,isSceneReplayActive:gl});let Ym=n.selectAutoMode()&&(I==="updateVariable"||B&&Jk(z,n.selectRuntime()));(Kk.has(I)||Ym)&&(U=!0);try{gr()}catch(Lt){throw Re&&Q(Lt,"postCommitUnsettled"),Lt}return dt},pl=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Qr(I?.projectData?.resources?.variables??{}),Yt(I.projectData),zt(I.projectData),Xt(I.projectData)},Rm=I=>{if(!Ue(I))throw new Error("updateLocalizationPackage requires an object payload");let P=Object.keys(I);if(P.length!==1||P[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},Cm=(I,P,S)=>{let C=n.selectCurrentPointer()?.pointer;P!==C||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),ft("nextLineFromSystem",I.payload))},$m=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(h),audioEffectOccurrenceSequence:g,activeAudioEffects:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:v?structuredClone(v):null,acceptedLineBgmActionOccurrences:new Map(O),canonicalProjectData:L,localizationPackageId:T,playbackScheduleDirty:U}),_m=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,m=I.pendingDialogueHistoryLineEntry,d=new Map(I.persistentAnimationSessions),f=new Map(I.restoredPersistentAnimationSessions),h=new Map(I.renderPersistentAnimationMetadata),g=I.audioEffectOccurrenceSequence,y=I.activeAudioEffects,w=I.pendingAudioEffectOccurrences.slice(),v=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,O=new Map(I.acceptedLineBgmActionOccurrences),L=I.canonicalProjectData,T=I.localizationPackageId,U=I.playbackScheduleDirty},Di=(I,P={})=>(ue("action batch"),Ze(()=>{let S=$m();try{return n[uo](()=>{let C,_=n.selectCurrentPointer()?.pointer??null,B=n.selectRollbackCursor?.()??null,z=c,J={pointer:_,rollbackCursor:B,markCurrentCheckpointTransient:P.rollbackSource==="line",savedCheckpointOccurrences:P.savedCheckpointOccurrences?.slice()??[]};u.push(J);try{n.beginRollbackActionBatch({source:P.rollbackSource});try{C=I()}finally{n.endRollbackActionBatch({})}On(C)&&Cm(C,_,z),Tt();let ce=n.selectCurrentPointer()?.pointer??null;P.rollbackSource==="line"&&lt(_,ce)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:J.savedCheckpointOccurrences,appendToPrevious:P.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:P.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:P.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!lt(_,J.pointer)||B?.checkpoint!==J.rollbackCursor?.checkpoint)&&J.markCurrentCheckpointTransient&&J.savedCheckpointOccurrences.length>0&&(p={pointer:J.pointer,checkpointIndex:J.rollbackCursor?.checkpointIndex,checkpointIdentity:J.rollbackCursor?.checkpoint,savedCheckpointOccurrences:J.savedCheckpointOccurrences})}})}catch(C){throw _m(S),C}})),Li=(I,P,S,C={})=>{if(I===rl||I===Sn)return Di(()=>{let _={...C,executionContext:C.executionContext??{depth:0,pendingNavigation:null},actionPath:C.actionPath??[I],randomOutcomeOrdinals:C.randomOutcomeOrdinals??new Map};if(I===Sn)return ml(P,S,_);let B=Mi(S),z=Wt({[I]:P},B);return dl(z[I],S,_)},C);if(I==="bgm")return Di(()=>{let _=pt(),B=jt(P),z=B?Yr():null,J=B?zr():null;ft(I,P);let ce=Sr();Dt(P,{...C,actionPath:C.actionPath??[I]},z,B?ct():null,_,ce,J)},C);ft(I,P)},Nm=(I,P)=>{if(I!=="nextLineFromSystem")return Li(I,P);H+=1;try{return Li(I,P)}finally{H=Math.max(0,H-1)}},fl=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Mi=I=>{if(fl(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:P,...S}=I,C=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:P,variables:C,runtime:n.selectRuntime?n.selectRuntime():{}}},jm=I=>{if(!Ue(I))return{templatePayload:I,literalTargetIds:null};let P=n.selectImageGalleryConfig();if(!Array.isArray(P?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?P.groups.find(_=>_.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let C=typeof I.variantId=="string"&&S.variants.some(_=>_.id===I.variantId);return{templatePayload:{...I,groupId:null,...C?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...C?{variantId:I.variantId}:{}}}},Tm=I=>!Ue(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(C=>C.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Dm=I=>!Ue(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(C=>C.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},Lm=I=>{if(!Ue(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},Mm=(I,P,S)=>{if(!Ue(I))throw new Error(`conditional branch at index ${P} must be an object`);if(!Ue(I.actions))throw new Error(`conditional branch at index ${P} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&P!==S-1)throw new Error("conditional else branch must be the last branch")},dl=(I,P,S)=>{Lm(I);let C=cl(S);for(let _=0;_<I.branches.length;_+=1){let B=I.branches[_];Mm(B,_,I.branches.length);let z=Mi(P);if(Object.prototype.hasOwnProperty.call(B,"when")&&!Ut(B.when,z))continue;let ce=$n(B.actions,P,{...S,actionPath:[...S.actionPath??[rl],"branches",String(_),"actions"]});return On(ce)?Ti(C,ce):C}return C},Vm=I=>{if(!Ue(I))throw new Error("random action payload must be an object");let P=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(P!==void 0)throw new Error(`random action.${P} is not supported`);if(!Ue(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=L?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||$e(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},ml=(I,P,S)=>{Vm(I),fl(P);let C=hc(I.distribution,{randomSource:M});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let z=(S.actionPath??[Sn]).join("."),J=S.randomOutcomeOrdinals??new Map,ce=J.get(z)??0;J.set(z,ce+1),n.recordRandomOutcome({path:z,ordinal:ce,type:C.type,result:C}),Sm()}let _;C.type==="integer"?ft("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:C.value}]}):_=$n(I.distribution.outcomes[C.outcomeIndex].actions,P,{...S,actionPath:[...S.actionPath??[Sn],"distribution","outcomes",String(C.outcomeIndex),"actions"]});let B=cl(S);return On(_)?Ti(B,_):B},qm=(I,P)=>({...I??{},_form:P}),Fm=(I,P,S,C)=>{let _=ft(I,P),B=_?.submitted===!0&&_.valid===!0,z=_?.cancelled===!0;if(!(!B&&!z)&&Ue(P.actions))return $n(P.actions,qm(S,_.form),{...C,interactionSource:tl})},yl=(I,P,S,C)=>{if(I===Sn)return ml(P,S,C);let _=Mi(S),B={templatePayload:P,literalTargetIds:null};I===zk?B=jm(P):I===Xk?B=Tm(P):I===Hk&&(B=Dm(P));let{templatePayload:z,literalTargetIds:J}=B,he=Wt({[I]:z},_)[I],be=J?{...he,...J}:he;if(I===rl)return dl(be,S,C);let ke=ll(I,be,C);if(Yk.has(I))return Fm(I,ke,S,C);let Oe=null,Ye=null,je=null,Te=!1;if(I==="bgm"){let Re=C.audioEffectHandoff,dt=Re?.available?Re.presentation:pt();Te=jt(ke),Te&&Re?.available?(Re.available=!1,Oe=structuredClone(Re.channel),Ye=structuredClone(Re.presentation),je=structuredClone(Re.resources)):Te&&(Oe=Yr(),Ye=dt,je=zr())}if(ft(I,ke),I==="bgm"){let Re=Sr();Dt(ke,C,Oe,Te?ct():null,Ye,Re,je)}},$n=(I,P,S)=>{let C,_=S?.executionContext??{depth:0,pendingNavigation:null},B=rs(I);ns(B),_.depth+=1;try{for(let[z,J]of B){let ce={...S,executionContext:_,actionPath:[...S?.actionPath??[],z]};if(ts(z)){let be=_.pendingNavigation;if(be)throw new Error(`action batch cannot execute multiple navigation actions: ${be.actionType}, ${z}`);_.pendingNavigation={actionType:z,payload:J,eventContext:P,options:ce};continue}let he=yl(z,J,P,ce);On(he)&&(C=Ti(C,he))}}finally{_.depth-=1}if(_.depth===0&&_.pendingNavigation){let z=_.pendingNavigation;_.pendingNavigation=null,yl(z.actionType,z.payload,z.eventContext,z.options)}return C},hl=(I,P,S={})=>{let C={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Di(()=>$n(I,P,C),C)},Bm=I=>{let P=n.selectCurrentPointer()?.pointer;if(I!==P||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:ji,dispose:Cn,handleAction:Li,handleInternalAction:Nm,handleActions:hl,selectRenderState:nm,prepareRenderState:sm,commitRenderState:im,selectPresentationState:em,selectPresentationChanges:rm,selectSectionLineChanges:tm,selectSystemState:om,selectAchievements:am,selectAchievement:lm,selectSaveSlotMap:al,selectSaveSlot:cm,selectSaveSlotPage:um,selectSaveSlots:al,selectImageGallery:pm,selectMusicRoom:fm,selectSceneReplay:dm,selectIsSceneReplayActive:mm,selectRuntime:ym,selectIsChoiceVisible:hm,selectIsFormVisible:gm,selectActiveInteraction:bm,selectHasPendingRenderWork:wm,handleLineActions:I=>{ue("line action handling");let P=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!lt(I.pointer,P))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return Ze(()=>{let S=n.selectCurrentPointer()?.pointer,C=n.selectPlaybackLineEntryId?.()??0,_=v?.lineEntryId===C?v:null,B=_?{available:!0,channel:structuredClone(_.channel),presentation:structuredClone(_.presentation),resources:structuredClone(_.resources)}:null,z=n.selectRollbackCursor?.()??null,J=p,ce=m,he=vm(S,z),be=km(S),ke=n.selectCurrentLine(),Oe=!1;if(ke?.actions){try{hl(ke.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:he,dialogueHistoryAppendToPrevious:be?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:be?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:be?.forceNewOccurrence===!0,audioEffectHandoff:B})}catch(Ye){throw p=J,m=ce,Ye}Oe=!0}return v?.lineEntryId===C&&(v=null),Bm(S),Oe})},getNamespace:Zd,classifyAutomaticAttemptError:$}}var Qk="music-room:player",Jd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Kd=(e,t)=>Jd.has(e)&&t?._event?.id===Qk,Qd=({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(r)??e.selectRenderState(r);n?.(s),t.render(s),a(o)&&e.commitRenderState?.(s)},Zk=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&Qd({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},eA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},rA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},tA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},nA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},sA=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Wd={render:Qd,saveSlots:eA,saveGlobalDeviceVariables:rA,saveGlobalAccountVariables:tA,saveGlobalRuntime:nA,applyScopedDataUpdates:sA,handleLineActions:Zk},iA=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),il=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},oA=(e=[])=>{let t=new Set,n=[];for(let o=e.length-1;o>=0;o-=1){let a=e[o];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!iA.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},aA=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,m=!1,d=0,f=0,h=!0,g=Hd({ticker:n,dispatchAutomaticAttempt:()=>il(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:$=>e()?.classifyAutomaticAttemptError?.($)??"preCommit"}),y=()=>{u=null,p=null,m=!1,d=0},w=()=>{g.reset(),f+=1,y(),h=!0},b=()=>{f+=1,h=!1,y(),g.dispose()},A=$=>h&&$===f,k=$=>{if(a){a($);return}console.error("RouteEngine persistence write failed.",$)},E=$=>{if(s)return s;let j=$t($),F=l.get(j);if(F)return F;let W=za({indexedDB:r,namespace:j});return l.set(j,W),W},v=$=>{let j=s?null:$t(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=E(j),$(F))).catch(W=>{!s&&l.get(j)===F&&l.delete(j),k(W)})},O=$=>{if(!h)return;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;d+=1,u=j,m=!1},L=()=>d,R=($={})=>{if(!h||$?.aborted===!0)return!1;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||m?!1:(m=!0,!0)},T=($,j={})=>{if(!h)return!1;if(Kd($,j)){let W=Jd.get($),de=e();return il(de,W,j?._event),!0}if($!=="renderComplete"||!R(j))return!1;let F=e();return il(F,"markLineCompleted",{}),!0},U=new Set(["updateFormField","submitForm","cancelForm"]),N=new Set(["updateVariable"]),H=$=>typeof $?.selectActiveInteraction=="function"?$.selectActiveInteraction():typeof $?.selectIsChoiceVisible=="function"&&$.selectIsChoiceVisible()?{source:"choice"}:null,fe=$=>$?._formKey??$?.formKey,M=($,j)=>fe($)===j?.formKey,K=($,j)=>!$||typeof $!="object"||Array.isArray($)?!1:$._interactionSource===j?.source,le=($,j)=>K($,j)?j.source==="form"?M($,j):!0:!1,X=($,j)=>!$||typeof $!="object"||Array.isArray($)||j?.source!=="form"?!1:M($,j),te=($={},j)=>Object.keys($).length>0&&Object.entries($).every(([F,W])=>U.has(F)?X(W,j):N.has(F)),oe=($={},j)=>{let F=$?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:te(F,j):le($,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(W=>le(W,j))},se=($,j={})=>{if(!j?.actions)return!1;let F=H($);return!F||F.source==="choice"?!1:!oe(j,F)},ue=({preprocessPayload:$,onEvent:j}={})=>async(F,W={})=>{if(!h)return!1;if(Kd(F,W))return T(F,W),j?.(F,W);let de=e(),ve=f,Ie=d;if(se(de,W))return j?.(F,W);let me=await $?.(F,W)??W;if(!A(ve)||e()!==de||d!==Ie)return!1;if(se(de,me))return j?.(F,me);if(T(F,me),me?.actions){let gr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,Ze;me?.bypassChoice===!0?Ze={bypassChoice:!0}:me?._interactionSource&&(Ze={interactionSource:me._interactionSource}),Ze?de.handleActions(me.actions,gr,Ze):de.handleActions(me.actions,gr)}return j?.(F,me)},Q=$=>{if(!h)return;let j=f,F=e(),W=oA($),de=W.some(Ie=>Ie.name==="handleLineActions");W.forEach(Ie=>{if(!Wd[Ie.name]&&!xn.has(Ie.name)&&!o)throw new Error(`Unhandled pending effect "${Ie.name}".`)});let ve={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:L,enqueuePersistenceWrite:v,lifecycleGeneration:f,isCurrentLifecycle:A};for(let Ie of W){if(!A(j))break;if(de&&Ie.name==="render")continue;if(xn.has(Ie.name)){g.handleLegacyEffect(Ie);continue}let me=Wd[Ie.name];if(me){me(ve,Ie.payload);continue}o(Ie,ve)}};return Q.handleRouteGraphicsEvent=T,Q.createRouteGraphicsEventHandler=ue,Q.reset=w,Q.dispose=b,Q.reconcilePlaybackScheduleV1=$=>g.reconcilePlaybackScheduleV1($),Q},lA=aA;var cA=(e,t={})=>{let{resources:n={}}=t;return Go(e,n)};var b1=sl;export{Oo as DEFAULT_VISUAL_LAYER,It as RENDER_LAYER,wr as VISUAL_LAYER,lA as createEffectsHandler,Mv as createIndexedDbPersistence,b1 as default,fo as formatDate,yh as resolveComputedVariables,cA as resolveLayoutReferences};
5
+ [${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let s=Oc(e,t),i={};for(let l of is)_r(r.tween,l)&&(i[l]=Rc({property:l,authored:r.tween[l],speed:s,propertyPath:`${a}.tween.${l}`}));return i},$c=({bgm:e,resources:t={}})=>{let n=e?.audioEffects?.resourceId,o=t.audioEffects?.[n],a=o?.type==="update"?o.tween:o?.type==="transition"?o.next:void 0;if(!a||(e.sounds??[]).length===0)return e;let s=structuredClone(e);for(let i of is){if(!_r(a,i))continue;let l=a[i].keyframes.at(-1);typeof l?.value!="number"||!Number.isFinite(l.value)||l.relative===!0||(i==="volume"?s.volume=l.value:i==="pan"?s.pan=l.value:s.sounds.forEach(c=>{c.playbackRate=l.value}))}return s},Pc=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),Ec=e=>{if(!e)return e;let t={...e};return delete t.beginEffect,delete t.endEffect,t},Fh=({occurrence:e,resources:t={},previousResources:n=t,nextResources:o=t,previousChannel:a,nextChannel:r,previousBgm:s,nextBgm:i})=>{if(!e?.selection)return null;let l=e.selection,c=e.actionPath??"bgm",u=l.resourceId,p=`resources.audioEffects.${u}`,m=t.audioEffects?.[u];if(!m)throw new Error(`[${c}.audioEffects.resourceId]
6
+ [${p}] Unknown audio effect resource "${u}".`);let d=Oc(l,`${c}.audioEffects`),f=kc(a,c),h=kc(r,c);if(!f&&!h)return null;if(f&&h&&f.id!==h.id)throw new Error(`[${c}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let g=f?.id??h.id,y=xc(f,h),w=Sc(Ec(f),Ec(h));if(m.type==="transition"){if(y){if(w)return null;throw new Error(`[${c}.audioEffects]
7
+ [${p}] Audio effect resource "${u}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let A={};for(let k of is){let E={},v=f?m.prev?.[k]:void 0;v&&(E.exit=wo({authored:v,bgm:s,property:k,propertyPath:`${p}.prev.${k}`,renderedSound:f,resources:n,speed:d}));let O=h?m.next?.[k]:void 0;O&&(E.enter=wo({authored:O,bgm:i,property:k,propertyPath:`${p}.next.${k}`,renderedSound:h,resources:o,speed:d}),Ac({actionPath:c,compiled:E.enter,property:k,propertyPath:`${p}.next.${k}`,renderedSound:h})),Object.keys(E).length>0&&(A[k]=E)}return Object.keys(A).length===0?null:{...Pc(e,g),properties:A}}if(m.type!=="update")throw new Error(`[${p}.type] Unsupported audio effect type "${m.type}".`);if(!f||!h||!y)throw new Error(`[${c}.audioEffects]
8
+ [${p}] Audio effect resource "${u}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let b={};for(let A of is){if(!_r(m.tween,A))continue;let k=`${p}.tween.${A}`,E=wo({property:A,authored:m.tween[A],speed:d,propertyPath:k,baselineBgm:s,bgm:i,resources:o,renderedSound:h}),v=h[A]??Zt[A];Ac({actionPath:c,compiled:E,property:A,propertyPath:k,renderedSound:h}),(f[A]??Zt[A])!==v&&(b[A]={update:E})}return Object.keys(b).length===0?null:{...Pc(e,g),properties:b}},_c=e=>{let t=e.nextResources??e.resources,n=e.occurrence;if(!n?.selection)return[];let o=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=n.selection.resourceId,s=t?.audioEffects?.[r],i=(f,h)=>h?{...f,children:[h]}:null,l=(f,h,g,y)=>{if(!Array.isArray(f?.sounds))return f;let w=g?.children?.indexOf(y)??-1,b=f.sounds.filter(A=>h.sounds?.[A.resourceId])[w];return{...f,sounds:b?[b]:[]}},c=f=>f.map(({previousSound:h,nextSound:g},y)=>Fh({...e,occurrence:y===0?n:{...n,occurrenceId:`${n.occurrenceId}:${y}`},resources:t,previousBgm:l(e.previousBgm,e.previousResources??t,e.previousChannel,h),nextBgm:l(e.nextBgm,t,e.nextChannel,g),previousChannel:i(e.previousChannel,h),nextChannel:i(e.nextChannel,g)})).filter(Boolean);if(!s||!["transition","update"].includes(s.type))return c([{previousSound:o[0],nextSound:a[0]}]);let u=new Map(o.map(f=>[f.id,f])),p=new Map(a.map(f=>[f.id,f]));if(s.type==="update"){let f=a.map(y=>({previousSound:u.get(y.id),nextSound:y})),h=f.find(({previousSound:y})=>!y);if(h)return c([h]);let g=o.find(y=>!p.has(y.id));return c(g?[{previousSound:g}]:f)}let m=[];for(let f of o){let h=p.get(f.id);(!h||!xc(f,h))&&m.push({previousSound:f,nextSound:h})}for(let f of a)u.has(f.id)||m.push({nextSound:f});if(m.length>0)return c(m);let d=o.find(f=>{let h=p.get(f.id);return h&&!Sc(f,h)});return c([{previousSound:d??o[0],nextSound:d?p.get(d.id):a[0]}])};var ae=e=>structuredClone(ge(e)?Xe(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),en=e=>e?.animations?.playback?.continuity==="persistent",Y=(e,t)=>ie(e??{},t)&&e[t]!==void 0,os=e=>Y(e,"alpha")||Y(e,"opacity"),Bh=e=>Y(e,"alpha")?e.alpha:e?.opacity,qc=e=>(Y(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Uh=e=>e?.applyMode==="persistent",Yh="default",zh=e=>Array.isArray(e?.channels)?e.channels.filter(Uh).map(ae):[],rn=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Xh=e=>os(e)||Y(e,"blur")||Y(e,"filters"),Ao=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Fc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],ko=["animationName","animationSpeed","loop"],Hh=e=>Y(e,"transformId")||Y(e,"transform")||Ao.some(t=>Y(e,t)),Po=e=>e?.text&&Y(e.text,"content")&&Y(e.text,"textStyleId"),Eo=e=>e?.layout&&Array.isArray(e.layout.elements),Gh=e=>Y(e,"text")||Y(e,"layout"),Nc=(e,t)=>e.resourceId?!0:Po(e)?!t?.text:Eo(e)?!t?.layout:!1,Kh=e=>Y(e,"resourceId")||Po(e)||Eo(e),jc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Wh=e=>Y(e,"resourceId")||Y(e,"sprites")&&Array.isArray(e.sprites)&&e.sprites.length>0,Jh=(e,t)=>{let n={...ae(e),...t};if(t.text&&e.text&&(n.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(n.transform={...ae(e.transform),...ae(t.transform)}),Y(t,"transform")){delete n.transformId;for(let o of Ao)Y(t,o)||delete n[o]}else Y(t,"transformId")&&delete n.transform;return n},Qh=(e,t)=>{let n=[e.resourceId,e.text,e.layout].filter(o=>o!==void 0).length;if(n>1)throw n===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(Y(e,"text")&&!Po(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(Y(e,"layout")&&!Eo(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Tc=e=>Fc.some(t=>Y(e,t)),Dc=e=>ko.some(t=>Y(e,t)),Zh=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let o of Fc)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Bc=(e,t,n)=>{let o=e[n];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},eg=(e,t)=>{if(!t)return e;let n=Y(e,"transform");for(let o of Ao)!n&&!Y(e,o)&&Y(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},rg=(e,t)=>(t&&(!Y(e,"opacity")&&Y(t,"opacity")&&(e.opacity=t.opacity),!Y(e,"blur")&&Y(t,"blur")&&(e.blur=ae(t.blur)),!Y(e,"filters")&&Y(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Uc=(e,t,n=[],{hasPatchFn:o=()=>!1,hasSubjectFn:a=(s,i)=>t(s,i),mergeItemFn:r}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let s=e.map((i,l)=>{let c=Bc(n,i,l),u=a(i,c),p=Xh(i),m=Hh(i),d=o(i),f=ie(i,"animations"),h=qc(ae(i));if(!u&&(p||m||d)&&c&&(h=r?r(c,h):{...ae(c),...h}),!f){let g=c?t(c):!1,y=t(h);!u&&g&&y&&en(c)?h.animations=ae(c.animations):delete h.animations}return u?h:rg(eg(h,c),c)}).filter(i=>t(i)||i.animations);return{hasValidItems:s.length>0,processedItems:s}},tg=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},Yc=e=>!!e?.character&&ie(e.character,"sprite"),ng=e=>{let t={},n=!1,o=tg(e);return o!==void 0&&(t.name=o,n=!0),Yc(e)&&(t.sprite=ae(e.character.sprite),n=!0),n?t:void 0},Lc=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Mc=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:n&&!ie(t,"characterId"),Vc=({previousCharacter:e,characterFields:t,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},c=t??{},u=s&&!n,p=u&&!r;return ie(c,"name")?i.name=c.name:(o&&!n||u)&&ie(l,"name")&&(i.name=ae(l.name)),ie(c,"sprite")?i.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(i.sprite=ae(l.sprite)),Object.keys(i).length>0?i:void 0},sg=({dialogueState:e,content:t,append:n=!1})=>{if(!n||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...o,...t]},ig=()=>({}),og=(e,t)=>{if(!t.screen)return;let n=os(t.screen),o=Y(t.screen,"blur"),a=ie(t.screen,"animations");if(!n&&!o){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=Bh(t.screen):Y(r,"opacity")&&(s.opacity=r.opacity),o?s.blur=ae(t.screen.blur):Y(r,"blur")&&(s.blur=ae(r.blur)),ie(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ie(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},ag=(e,t)=>{if(t.background){let n=Y(t.background,"resourceId"),o=Y(t.background,"colorId"),a=os(t.background),r=Y(t.background,"blur"),s=Y(t.background,"filters"),i=Y(t.background,"transformId"),l=Tc(t.background),c=Dc(t.background),{animationsOnly:u,state:p}=rn(t.background,f=>Y(f,"resourceId")||Y(f,"colorId")||os(f)||Y(f,"blur")||Y(f,"filters")||Y(f,"transformId")||Tc(f)||Dc(f));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!n&&!o&&!a&&!r&&!s&&!i&&!l&&!c){delete e.background;return}let m=e.background,d=qc(ae(t.background));if(!n&&m?.resourceId){d.resourceId=m.resourceId,!ie(d,"transformId")&&m.transformId&&(d.transformId=m.transformId);for(let f of ko)!Y(d,f)&&Y(m,f)&&(d[f]=m[f])}n||Zh(d,m,{hasAuthoredTransformId:i}),!n&&!o&&m?.colorId&&(d.colorId=m.colorId),!n&&!a&&Y(m,"opacity")&&(d.opacity=m.opacity),!n&&!r&&Y(m,"blur")&&(d.blur=ae(m.blur)),!n&&!s&&Y(m,"filters")&&(d.filters=ae(m.filters)),ie(d,"resourceId")&&d.resourceId===void 0&&delete d.resourceId,ie(d,"colorId")&&d.colorId===void 0&&delete d.colorId,ie(d,"animations")&&d.animations===void 0&&delete d.animations,ie(d,"transformId")&&d.transformId===void 0&&delete d.transformId,ie(d,"opacity")&&d.opacity===void 0&&delete d.opacity,ie(d,"blur")&&d.blur===void 0&&delete d.blur,ie(d,"filters")&&d.filters===void 0&&delete d.filters;for(let f of ko)ie(d,f)&&d[f]===void 0&&delete d[f];if(!d.resourceId&&!d.colorId){delete e.background;return}!n&&m?.resourceId===d.resourceId&&m?.transformId===d.transformId&&!ie(d,"animations")&&en(m)&&(d.animations=ae(m.animations)),e.background=d}else e.background?.animations&&!en(e.background)&&(e.background.animations={})},lg=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(Lc(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=Mc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=Vc({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=rn(t.dialogue.ui,m=>!!m.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=t.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&sg({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Mc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=ie(t.dialogue,"characterId"),i=ng(t.dialogue),l=Yc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=Vc({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Lc(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},cg=(e,t)=>{let n=zh(e.sfx);if(!t.sfx){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=n.filter(s=>s.id!==Yh);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(t.sfx.channels.length===0){delete e.sfx;return}let o=new Set(t.sfx.channels.map(r=>r.id)),a=n.filter(r=>!o.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},ug=(e,t,n)=>{if(t.bgm){let o=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!o||o&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=$c({bgm:ae(t.bgm),resources:n}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},pg=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{Qh(r,Bc(n,r,s))});let{hasValidItems:o,processedItems:a}=Uc(t.visual.items,Nc,n,{hasPatchFn:Gh,hasSubjectFn:Kh,mergeItemFn:Jh});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!Nc(n)||!en(n))?{...n,animations:{}}:n))},fg=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!jc(a)||!en(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=Uc(t.character.items,jc,e.character?.items||[],{hasSubjectFn:Wh});n?e.character={items:o}:delete e.character},dg=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},mg=(e,t)=>{if(t.layout){let{animationsOnly:n,state:o}=rn(t.layout,a=>!!a.resourceId);if(n){e.layout=o;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},yg=(e,t)=>{if(t.choice){let{animationsOnly:n,state:o}=rn(t.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...o};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},hg=(e,t)=>{if(t.form){let{animationsOnly:n,state:o}=rn(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},gg=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},bg=(e,t)=>{if(t.voice){let n=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!n||n&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},wg=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},et=(e,{resources:t,initialState:n}={})=>Hn(()=>n??ig(),[wg,og,ag,cg,(r,s)=>ug(r,s,t),pg,lg,fg,dg,mg,yg,hg,gg,bg])(e);var zc=new WeakMap,qe=(e,t)=>{let n=ge(e)?Xe(e):e;if(!Array.isArray(n))return-1;if(!Object.isFrozen(n))return n.findIndex(a=>a.id===t);let o=zc.get(n);return o||(o=new Map,n.forEach((a,r)=>{o.has(a.id)||o.set(a.id,r)}),zc.set(n,o)),o.get(t)??-1};var Xc=Object.freeze({}),Ig=64,vg=16,Hc=4,kg=8,Gc=new WeakMap,as=(e,t,n,o)=>{e.delete(t),e.set(t,n),e.size>o&&e.delete(e.keys().next().value)},Ag=(e,t)=>{if(!Array.isArray(t.lines)||!Object.isFrozen(e)||!Object.isFrozen(t)||!Object.isFrozen(t.lines)||e.resources&&!Object.isFrozen(e.resources))return null;let n=Gc.get(e);n||(n=new Map,Gc.set(e,n));let o=n.get(t);return o||(o={checkpoints:new Map,recent:new Map}),as(n,t,o,kg),o},Kc=(e,t,n,o=0)=>{let a=t?.lines??[],r=t&&Array.isArray(a)?Ag(e,t):null,i=qe(a,n)+o;if(i<0)return o<0?null:Xc;if(!r)return et(a.slice(0,i+1).map(u=>u.actions||{}),{resources:e.resources});let l=-1,c=Xc;for(let u of[r.checkpoints,r.recent])for(let[p,m]of u)p<=i&&p>l&&(l=p,c=m);for(let u of[i-1,i])u<=l||(c=et(a.slice(l+1,u+1).map(p=>p.actions||{}),{resources:e.resources,initialState:c}),(u+1)%Ig===0&&as(r.checkpoints,u,c,vg),as(r.recent,u,c,Hc),l=u);return as(r.recent,i,c,Hc),c};var wt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Wr(e,t);return n&&typeof n=="object"?e:n};var Pg=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"}}),Nr=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}),tn=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Eg=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"}),xo=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Wc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),So=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Jc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),xg=(e,t)=>{let n=Eg[e];if(n==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(t!==null&&typeof t!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},ls=(e,t)=>{if(xg(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},Oo=(e={})=>{let t=e?.config;if(t===void 0)return{...Nr};if(!Jc(t))throw new Error("projectData.config must be an object");let n=Object.keys(t).find(i=>i!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=t.runtimeDefaults;if(o===void 0)return{...Nr};if(!Jc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Wc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...Nr};return Wc.forEach(i=>{o[i]!==void 0&&(s[i]=ls(i,o[i]))}),s},Sg=(e,t)=>{if(t.startsWith("global.")){let n=t.slice(7);return e?.global?.[n]}if(t.startsWith("context.runtime.")){let n=t.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[n]}},br=e=>Object.fromEntries(Object.entries(Pg).map(([t,n])=>{let o=Sg(e,n.source),a=o!==void 0?o:Nr[t]??tn[t];return[t,a]})),or=(e,t)=>br(e)[t],Qc=(e={})=>Object.fromEntries(xo.map(t=>[t,e[t]??Nr[t]]));var It=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}),wr=Object.freeze({BEHIND_BACKGROUND:It.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:It.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:It.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:It.VISUAL_BEHIND_CHOICE,FOREGROUND:It.VISUAL_FOREGROUND}),Ro=wr.BEHIND_DIALOGUE,Co=Object.freeze(Object.values(wr).sort((e,t)=>e-t));var Og={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:mo},Rg=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,nn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return nn(t);let[n]=Object.keys(t),o=Rg.exec(n);if(!o)return nn(t);let[,a,r,s]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[i]:nn(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,nn(n)])),Ir=(e,t)=>{let n={functions:Og};return Wr(nn(e),t,n)},du=({animationType:e,animationId:t,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},Cg=({id:e,targetId:t,animation:n,playback:o,animationPath:a="animation"})=>{let r=structuredClone(n);if(du({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let s=jg(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?bu(r):null;if(s.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&r.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&(!Number.isFinite(i)||i<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);r.playback=s}}return r},$g=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return du({animationType:e.type,animationId:t,animationPath:n}),e.type},_g=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},Ng=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},jg=(e,t="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${t}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${t}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${t}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${t}] playback.loop must be a boolean.`);let n={};return e.continuity!==void 0&&(n.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(n.speed=e.speed),e.loop===!0&&(n.loop=!0),Object.keys(n).length>0?n:void 0},Tg=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},rr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),mu=(e={})=>rr(e,"alpha")&&typeof e.alpha=="number"?e.alpha:rr(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,yu=e=>e?.playback?.continuity==="persistent",Mo=e=>Array.isArray(e)?e.map(Mo):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=Mo(e[n]),t),{}),fs=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(Mo(t))},hu=(e=[])=>e.filter(t=>yu(t)).map(t=>structuredClone(t)),gu=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,n)=>{let o=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return t+o},0):0,$o=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,gu(n)),0),bu=e=>Math.max($o(e?.tween),$o(e?.prev?.tween),$o(e?.next?.tween),gu(e?.mask?.progress)),wu=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:bu(e)/Tg(e),Dg=e=>e.some(t=>t?.playback?.loop===!0),Zc=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let n=new Set(t.map(fs).filter(Boolean));return e.some(o=>{if(!yu(o))return!1;let a=fs(o);return a?n.has(a):!1})},tr=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:Dg(e)||r&&!t||Zc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:Zc({animationInstances:e,activePersistentAnimations:a}),Iu=(e,t,n,o,a)=>{if(e===void 0)return!0;let r=a.slice(0,o).filter(i=>i?.id===n).length,s=e?.[t]?.items?.filter(i=>i?.id===n).at(r);return rr(s??{},"animations")},Lg=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Mg=(e,t)=>{if(Lg(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Vg=({resources:e,animationId:t,playback:n,instanceId:o,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let s=e?.animations?.[t];return s?Cg({id:o,targetId:a,animation:s,playback:n,animationPath:r}):null},Vo=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${t} must be an array of objects`);return e},qg=({content:e,path:t,variables:n})=>Vo(e,t).reduce((o,a)=>{let r=wt(a.text,{variables:n});return o+`${r??""}`.length},0),eu=(e=[])=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,(t.get(n.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,n])=>n>1).map(([n])=>n))},ru=(e,t=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let o=e?.sprites?.map(({resourceId:a})=>a)||[];return o.length===0?`character-container-${e.id}`:`character-container-${e.id}-${t}-${o.join("-")}`},kt=(e,t)=>{if(t.transformId&&t.transform)throw new Error(`Visual item "${t.id}" cannot define both transformId and transform`);if(t.transform)return t.transform;if(!t.transformId)throw new Error(`Visual item "${t.id}" requires transformId or transform`);let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return n},Fg=(e,t={})=>{if(!t?.transformId)return;let n=e.transforms?.[t.transformId];if(!n)throw new Error(`Transform "${t.transformId}" not found for background`);return n},Bg=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Ug=(e={})=>Bg.some(t=>rr(e,t)),vu=(e={},t)=>{if(t){if(e.images?.[t])return"sprite";if(e.videos?.[t])return"video";if(e.spritesheets?.[t])return"spritesheet-animation";if(e.layouts?.[t])return"container"}},us=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Yg=(e={})=>e.textStyles||{},zg=(e={})=>e.images||{},Xg=.5,Hg=(e={},t,n)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${n}'`);return t}return Object.keys(e.animations??{})[0]},Ho=({id:e,resourceId:t,spritesheet:n,animationName:o,animationSpeed:a,loop:r,width:s,height:i,transform:l={}}={})=>{let c=Hg(n,o,t),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:i??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Xg,loop:r??u.loop??!0}}},ku=({id:e,item:t,resources:n={}}={})=>{let o=n.images?.[t.resourceId];if(o)return{type:"sprite",id:e,src:o.fileId,width:o.width,height:o.height,x:0,y:0};let a=n.spritesheets?.[t.resourceId];if(a)return Ho({id:e,resourceId:t.resourceId,spritesheet:a,animationName:t.animationName,animationSpeed:t.animationSpeed,loop:t.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${t.resourceId}`)},Gg=(e={})=>e.colors||{},Kg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,sn=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,At=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},_o=(e,t,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);return e},No=(e,t,n,o,{minimum:a}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let r=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${t} for text style "${n}" must be ${r}`)}return e},ys=(e,t)=>{if(typeof e!="string"||!Kg.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},tu=(e,t,n)=>{let o=ys(e,n);if(t===1)return o;let a=Number.parseInt(o.slice(1,3),16),r=Number.parseInt(o.slice(3,5),16),s=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${r}, ${s}, ${t})`},Wg=(e={},t)=>{let n=Yg(e)?.[t];if(!n)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=_o(n.colorAlpha,"colorAlpha",t),i={fontFamily:Array.isArray(n.fontId)?a.join(", "):a[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:tu(r.hex,s,`Color "${n.colorId}" for text style "${t}"`)};if(n.align!==void 0&&(i.align=n.align),n.wordWrap!==void 0&&(i.wordWrap=n.wordWrap),n.breakWords!==void 0&&(i.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(i.wordWrapWidth=n.wordWrapWidth),n.strokeColorId){let l=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${t}"`);let c=_o(n.strokeAlpha,"strokeAlpha",t);i.strokeColor=tu(l.hex,c,`Stroke color "${n.strokeColorId}" for text style "${t}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth),n.shadow!==void 0){let l=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${t}"`);i.shadow={color:ys(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:_o(n.shadow.alpha,"shadow.alpha",t),blur:No(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:No(n.shadow.offsetX,"offsetX",t,2),offsetY:No(n.shadow.offsetY,"offsetY",t,2)}}return i},Pt=e=>Array.isArray(e)?e.map(Pt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Pt(n)])),hs=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},qo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>qo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=Pt(r);continue}a!=="textStyleId"&&hs(o,a,qo(r,t,sn(n,a)))}return e.textStyleId!==void 0&&(At(e.textStyleId,n,"textStyleId"),o.textStyle=Wg(t,e.textStyleId)),o},Go=(e={},t)=>{let n=Gg(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return ys(n.hex,`Color "${t}"`)},Au=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",jo=(e,t,n)=>{let o=e?.[t];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${t}.fill is not allowed in rect layout elements at "${n}". Use ${Au(`${t}.fill`)} instead`)},Jg=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>on(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,r]of Object.entries(e))a!=="colorId"&&hs(o,a,on(r,t,sn(n,a)));return e.colorId!==void 0&&(At(e.colorId,n,"colorId"),o.fill=Go(t,e.colorId)),o},on=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>on(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${n}". Use ${Au("fill")} instead`);jo(e,"hover",n),jo(e,"click",n),jo(e,"rightClick",n)}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=Pt(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=Jg(r,t,sn(n,a));continue}hs(o,a,on(r,t,sn(n,a)))}}return e.type==="rect"&&e.colorId!==void 0&&(At(e.colorId,n,"colorId"),o.fill=Go(t,e.colorId)),o},To=(e={},t)=>{let n=zg(e)?.[t];return n||null},Pu=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",nu=(e,t,n,o)=>{let a=e?.[t];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,o))throw new Error(`Inline ${t}.${o} is not allowed in sprite layout elements at "${n}". Use ${Pu(`${t}.${o}`)} instead`)},su=(e,t,n)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},Fo=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Fo(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${Pu(a)} instead`);nu(e,"hover",n,"src"),nu(e,"click",n,"src")}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=Pt(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||hs(o,a,Fo(r,t,sn(n,a)))}if(e.type==="sprite"&&e.imageId!==void 0){At(e.imageId,n,"imageId");let a=To(t,e.imageId),r=a?.fileId??e.imageId;o.src=r,o.width===void 0&&a?.width!==void 0&&(o.width=a.width),o.height===void 0&&a?.height!==void 0&&(o.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(At(e.hoverImageId,n,"hoverImageId"),su(o,"hover",To(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(At(e.clickImageId,n,"clickImageId"),su(o,"click",To(t,e.clickImageId)?.fileId??e.clickImageId)),o},Qg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),ps=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>ps(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=Pt(e),o=typeof e.type=="string";(o||t)&&rr(e,"opacity")&&(rr(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])rr(e,a)&&(n[a]=ps(e[a]));for(let[a,r]of Object.entries(e))Qg(a)&&(n[a]=ps(r,{isElementPatch:o||t}));return n},Ko=(e,t={},n="root")=>ps(Fo(on(qo(e,t,n),t,n),t,n)),vr=Ko,tt=(e=[])=>e.find(t=>t.id==="story"),Zg="#000000",Bo="bg-cg-background-color",eb=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?ys(n?.backgroundColor??Zg,"screen.backgroundColor"):Go(e,t.colorId),Eu=(e={})=>mu(e),rb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Wo=(e={})=>Array.isArray(e.filters)?e.filters:void 0,iu=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Eu(e),o=rb(e),a=Wo(e),r={};return(t||n!==void 0)&&(r.alpha=n??1),o&&(r.blur=o),a&&(r.filters=a),r},tb=(e={})=>mu(e),nb=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},xu=(e={})=>{let t=tb(e),n=nb(e),o={};return t!==void 0&&(o.alpha=t),n&&(o.blur=n),o},rt=(e={})=>{let t=xu(e),n=Wo(e);return n&&(t.filters=n),t},ou=(e,t,n,o)=>{let a=t[n]??e[n];return t[o]??e[o]??!1?(a??1)*-1:a},ar=(e={},t={})=>{let n={x:t.x??e.x,y:t.y??e.y,anchorX:t.anchorX??e.anchorX,anchorY:t.anchorY??e.anchorY,rotation:t.rotation??e.rotation,scaleX:ou(e,t,"scaleX","flipX"),scaleY:ou(e,t,"scaleY","flipY")},o=t.originX??e.originX,a=t.originY??e.originY;return o!==void 0&&(n.originX=o),a!==void 0&&(n.originY=a),n},sb=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],Jo=(e={})=>e.text&&rr(e.text,"content")&&rr(e.text,"textStyleId"),Qo=(e={})=>e.layout&&Array.isArray(e.layout.elements),au=(e={})=>{if(e.resourceId)return e.resourceId;if(Jo(e))return"text";if(Qo(e))return"inline-layout"},lu=(e,t={})=>typeof e=="string"?t.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?t.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return t.images?.[n]?.fileId??n;if(!n||typeof n!="object"||Array.isArray(n))return n;if(n.imageId){let{imageId:o,...a}=n;return{...a,src:t.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:t.images?.[n.src]?.fileId??n.src}:n})}:e,ib=({item:e,particle:t,resources:n})=>{let o=kt(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=lu(r,n)),a.texture!==void 0&&(a.texture=lu(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...ar(o,e)};return Object.assign(s,rt(e)),s},ob=e=>{let t=[e.resourceId,e.text,e.layout].filter(n=>n!==void 0).length;if(t>1)throw t===2&&e.resourceId!==void 0&&e.text!==void 0?new Error(`Visual item "${e.id}" cannot define both resourceId and text`):new Error(`Visual item "${e.id}" must define only one of resourceId, text, or layout`);if(e.transformId&&e.transform)throw new Error(`Visual item "${e.id}" cannot define both transformId and transform`);if(e.text&&!Jo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Qo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of sb)if(rr(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},ab=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:Bo,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:eb({resources:e,background:t,screen:n})};if(o){let r=Eu(t);r!==void 0&&(a.alpha=r);let s=Wo(t);s&&(a.filters=s)}return a},lb=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,cu=({resources:e={},resourceId:t,colorId:n})=>{let o=vu(e,t);return t&&(o||n===void 0)?{resourceId:t,targetId:us({resourceId:t,kind:o})}:n!==void 0?{resourceId:Bo,targetId:Bo}:{resourceId:void 0,targetId:void 0}},Su=100,jr=Su,cb="channel:bgm",ub="channel:music-room",pb="music-room:player",fb="channel:voice",db="default",ds=(e,t,n)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let r=n?` in ${n}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}o.add(a)})},Ou=(e,t)=>e*t/Su,Zo=(e={},t)=>e?.[t]??Nr[t],ea=(e={},t,n=jr)=>Ou(n,Zo(e,t)),gs=({id:e,volume:t,muted:n,pan:o,loop:a,playback:r,interruption:s,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),s!==void 0&&(c.interruption=s),c},cs=(e,t,n,o)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:o,mb=["muted","pan","playbackRate","startAt","endAt"],bs=({id:e,sound:t,resource:n,projectResources:o,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:s=!1})=>{let i={id:e,type:"sound",src:n.fileId,loop:cs(t,n,"loop",r),volume:cs(t,n,"volume",jr),startDelayMs:cs(t,n,"startDelayMs",0)};mb.forEach(c=>{let u=cs(t,n,c,void 0);u!==void 0&&(i[c]=u)}),t.playback!==void 0&&(i.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=Cc({selection:t[c],selectionPath:`${a}.${c}`,resources:o});u&&!s&&(i[c]=u)}let l=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<l)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${l}).`);return i},yb=e=>Math.max(-1,Math.min(1,e)),hb=({node:e,bgm:t,sound:n,resource:o,usesLegacySound:a})=>{a||(e.volume=Ou(t.volume??jr,e.volume??jr));let r=t.muted!==void 0,s=n.muted!==void 0||o.muted!==void 0;(r||s)&&(e.muted=t.muted===!0||e.muted===!0);let i=t.pan!==void 0,l=n.pan!==void 0||o.pan!==void 0;return(i||l)&&(e.pan=yb((t.pan??0)+(e.pan??0))),e},Ke=({variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:r=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:b,skipTransitionsAndAnimations:A}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},E=vb({dialogueState:s,includeInactiveAdvDialogue:i,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:d,confirmDialog:f,form:h,historyDialogue:g,characters:y};return E&&(v.dialogue=E,v.dialogueLines=E.lines),v},uu=100,ms=(e,t)=>{if(Array.isArray(e))return e.map(o=>ms(o,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=ms(n[o],t)}),n.type==="text-revealing"?t(n):n},gb=e=>ms(e,t=>({...t,revealEffect:"none"})),bb=e=>ms(e,t=>{let n=Number(t.speed??t.displaySpeed),o=Number.isFinite(n)?Math.max(n,uu):uu;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),Tr=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?gb(e):n?bb(e):e,Ru=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),Uo=e=>{if(Array.isArray(e))return e.map(Uo);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Uo(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let o=n.actions,a=o&&typeof o=="object"&&!Array.isArray(o)&&Object.prototype.hasOwnProperty.call(o,"nextLine")?{...o.nextLine,bypassChoice:!0}:void 0;return{...t,click:{...t.click,payload:{...n,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},wb=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),pu="submit",Do=(e,t,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},r=n.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...o,actions:r}}},Yo=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>Yo(c,t,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===pu,r=o&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Yo(u,t,c==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let c=t?.fields?.[l.field];if(c){let u={updateFormField:{formKey:t.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:Do(l.change,u),submit:Do(l.submit,t.submitActions)}}}return l.formRole===pu||r?{...l,click:Do(l.click,t.submitActions,{replaceActions:!0})}:l},zo=(e,t)=>{if(Array.isArray(e))return e.map(o=>zo(o,t));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=zo(a,t);for(let o of wb){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},Xo=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,s=Gn({characterId:e,character:t,characterName:n,characters:o,variables:a});return{...r||{},...t||{},name:s}},Cu=(e=[],t={},n={})=>e.map(o=>{let a=Xo({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:t,variables:n}),r=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(s=>s?.text??"").join(""):"";return{...o,text:r,character:a,characterName:a.name}}),Ib=e=>!(!e||e.mode==="adv"&&e.content===void 0),vb=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:o,runtime:a}={})=>{if(!t&&!Ib(e))return;let r=e.content===void 0?[{text:""}]:Vo(e.content,"dialogue.content"),s=e.content===void 0?0:qg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??Nr.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,m)=>{let d=Vo(p.content,`dialogue.lines[${m}].content`),f=Xo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:d.map(h=>({...h,text:wt(h.text,{variables:o})})),character:f,characterName:f.name}}),u=Xo({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:wt(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},ra=({container:e,resources:t,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=Ir(e,n);return vr(Tr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},Lo=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),fu=({renderStateKeyboard:e,keyboard:t,phase:n})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([o,a])=>{let r=e[o]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...r,keydown:{payload:Lo(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:Lo(a.keyup)});return}e[o]={...r,[n]:{payload:Lo(a)}}})},kb=(e={},t={})=>{let n={};return fu({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),fu({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},kr=({animationsDef:e,resources:t,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:r,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:w})=>{let b=Vg({resources:t,animationId:d,playback:f,instanceId:y,targetId:w,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,m=a&&r&&a===r;Mg(e,s);let d=_g(e),f=Ng(e),h=t?.animations?.[d],g=$g(h,{animationId:d,animationPath:s});if(g==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(g==="transition"){let y=`${i}-animation-transition`,w=f?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&m)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},Ab=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Pb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:w,canRollback:b,form:A,saveSlots:k=[]})=>{let{elements:E,animations:v}=e;if(t.background){let O=o===void 0?!0:rr(o?.background??{},"animations"),L=E.find(oe=>oe.id==="story");if(!L)return e;let R=Fg(a,t.background),T=R||Ug(t.background),U=n?.background?.resourceId,N=n?.background?.colorId,H=t.background.resourceId??(t.background.animations?U:void 0),fe=t.background.colorId??(t.background.animations?N:void 0),M=lb(a,H),K={...t.background,colorId:fe};if((fe!==void 0||M)&&L.children.push(ab({resources:a,background:K,screen:r,includeAlpha:!M})),H){let{images:oe={},videos:se={},spritesheets:ue={}}=a,Q=vu(a,H),$;if(Q==="sprite"?$=oe[H]:Q==="video"?$=se[H]:Q==="spritesheet-animation"&&($=ue[H]),$){let j=Q==="video",F=Q==="spritesheet-animation",W={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...R},de={...iu(t.background,{includeDefaultAlpha:!0}),...ar(W,t.background)},ve;F?ve=Ho({id:us({resourceId:H,kind:Q}),resourceId:H,spritesheet:$,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:de}):ve={id:us({resourceId:H,kind:Q}),type:j?"video":"sprite",src:$.fileId,width:$.width,height:$.height,...de},j&&(ve.loop=t.background.loop??!1,ve.volume=$.volume??50),ve&&L.children.push(ve)}}if(H){let{layouts:oe={}}=a,se=oe[H];if(se){let ue={id:us({resourceId:H,kind:"container"}),type:"container",children:se.elements,...iu(t.background)};T&&Object.assign(ue,ar({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...R},t.background));let Q=Ir(ue,Ke({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:h,skipMode:g,isChoiceVisible:y,isFormVisible:w,canRollback:b,form:A,characters:a.characters||{},skipTransitionsAndAnimations:i}));L.children.push(vr(Tr(Q,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let le=cu({resources:a,resourceId:U,colorId:N}),X=cu({resources:a,resourceId:H,colorId:fe}),te=kr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:X.resourceId,previousTargetId:le.targetId,currentTargetId:X.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});tr({animationInstances:te,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:O})&&v.push(...te)}return e},Eb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(w=>w.id==="story");if(!p)return e;let m=t.character.items||[],d=n?.character?.items||[],f=eu(m),h=eu(d),g=new Map,y=new Map;for(let w=0;w<d.length;w++){let b=d[w],A=g.get(b.id)??[];A.push(w),g.set(b.id,A)}for(let w=0;w<m.length;w++){let b=m[w],{transformId:A,sprites:k}=b,E=y.get(b.id)??0;y.set(b.id,E+1);let v=g.get(b.id)?.[E]??-1,O=d[v],L=O?.sprites&&O.sprites.length>0,R=k&&k.length>0,T=v>=0?ru(O,v,h):void 0,U=R?ru(b,w,f):void 0,N=Iu(o,"character",b.id,w,m),H=kr({animationsDef:b.animations,resources:a,previousResourceId:T,currentResourceId:U,previousTargetId:T,currentTargetId:U,animationPath:`character.items[${w}].animations`,idPrefix:U??T??`character-${w}`});if(b.animations&&!k&&!A&&L&&tr({animationInstances:H,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:N})){u.push(...H);continue}if(b.animations&&!k&&!A)continue;if(!k||k.length===0||!A){console.warn("Character item missing sprites or transformId:",b);continue}let fe=a.transforms[A];if(!fe){console.warn("Transform not found:",A);continue}let M={type:"container",id:U,...ar(fe,b),...rt(b),children:[]};for(let K of k){let le=ku({id:`${U}-${K.id}`,item:K,resources:a});le&&M.children.push(le)}p.children.push(M),tr({animationInstances:H,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:N})&&u.push(...H)}}return e},$u=(e,t)=>{if(!Co.includes(e))throw new Error(`${t} must be one of: ${Co.join(", ")}.`)},xb=(e,t)=>{let n=!!e.resourceId||Jo(e)||Qo(e),o=e.layer??(n?void 0:t?.layer)??Ro;return $u(o,`Visual item "${e.id}" layer`),o},Sb=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:m,restoredPersistentAnimations:d,autoMode:f,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:w,form:b,saveSlots:A=[],visualLayer:k})=>{let{elements:E,animations:v}=e;if(t.visual&&a){let O=E.find(U=>U.id==="story");if(!O)return e;let L=t.visual.items,R=n?.visual?.items||[],T=Ke({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:A,dialogueState:t.dialogue,isLineCompleted:r,autoMode:f,skipMode:h,isChoiceVisible:g,isFormVisible:y,canRollback:w,form:b,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&$u(k,"visualLayer");for(let[U,N]of L.entries()){let H=R.find(se=>se.id===N.id),fe=Iu(o,"visual",N.id,U,L),M=xb(N,H);if(k!==void 0&&M!==k)continue;if(ob(N),N.layout){let se=kt(a,N),ue={id:`visual-${N.id}`,type:"container",children:structuredClone(N.layout.elements),...ar(se,N)};Object.assign(ue,rt(N)),O.children.push(ra({container:ue,resources:a,templateData:T,isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}))}if(N.text){let se=kt(a,N),ue={...structuredClone(N.text),id:`visual-${N.id}`,type:"text",...ar(se,N)};Object.assign(ue,rt(N)),O.children.push(vr(Ir(ue,T),a))}if(N.resourceId){let{images:se={},videos:ue={},spritesheets:Q={}}=a,$=Q[N.resourceId];if($){let j=kt(a,N),F=rt(N),W=Ho({id:`visual-${N.id}`,resourceId:N.resourceId,spritesheet:$,animationName:N.animationName,animationSpeed:N.animationSpeed,loop:N.loop,width:N.width,height:N.height,transform:{...ar(j,N),alpha:F.alpha??N.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});W&&O.children.push(structuredClone(W))}else{let j=se[N.resourceId]||ue[N.resourceId];if(j){let F=ue[N.resourceId]!==void 0,W=kt(a,N),de={id:`visual-${N.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...ar(W,N)};Object.assign(de,rt(N)),F&&(de.loop=j.loop??!1,de.volume=j.volume??50),O.children.push(de)}}}let K=!!(a.spritesheets?.[N.resourceId]||a.images?.[N.resourceId]||a.videos?.[N.resourceId]);if(N.resourceId&&!K){let se=a.particles?.[N.resourceId];se&&O.children.push(ib({item:N,particle:se,resources:a}))}let le=!!a.particles?.[N.resourceId];if(N.resourceId&&!K&&!le){let{layouts:se={}}=a,ue=se[N.resourceId];if(ue){let Q=kt(a,N),$={id:`visual-${N.id}`,type:"container",children:structuredClone(ue.elements),...ar(Q,N)};Object.assign($,rt(N));let j=Ir($,T);O.children.push(vr(Tr(j,{isLineCompleted:r,skipMode:h,skipTransitionsAndAnimations:s}),a))}}let X=au(H),te=au(N),oe=kr({animationsDef:N.animations,resources:a,previousResourceId:X,currentResourceId:te,previousTargetId:X?`visual-${N.id}`:void 0,currentTargetId:te?`visual-${N.id}`:void 0,animationPath:`visual.items[${N.id}].animations`,idPrefix:N.id});tr({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:m,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:fe})&&v.push(...oe)}}return e},vt="dialogue-character-sprite",Ob=(e,{presentationState:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=tt(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=Bt(c),m=Bt(u),d=kr({animationsDef:c?.animations,resources:o,previousResourceId:m?vt:void 0,currentResourceId:p?vt:void 0,previousTargetId:m?vt:void 0,currentTargetId:p?vt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&tr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e;let f=o.transforms?.[c.transformId];if(!f)return console.warn("Transform not found:",c.transformId),e;let h={type:"container",id:vt,...ar(f),children:[]};for(let g of c.items){let y=ku({id:`${vt}-${g.id}`,item:g,resources:o});y&&h.children.push(y)}return l.children.push(h),tr({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e},Rb=(e,{presentationState:t,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:d,variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:w,activePersistentAnimations:b,saveSlots:A=[]})=>{let{elements:k,animations:E}=e;if(!t.dialogue||a)return e;let v=k.find(L=>L.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:L={}}=o,R=L[t.dialogue.ui.resourceId];if(R){let T={elements:R.elements},U=Ke({variables:f,imageGallery:h,musicRoom:g,sceneReplay:y,runtime:w,saveSlots:A,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),N=Ir(T,U),H=vr(Tr(N?.elements,{isLineCompleted:m,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(H))for(let fe of H)v.children.push(fe);else H&&v.children.push(H)}}Ob(e,{presentationState:t,previousPresentationState:n,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let O=kr({animationsDef:t.dialogue.ui?.animations,resources:o,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return tr({animationInstances:O,isLineCompleted:m,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&E.push(...O),e},Cb=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,form:y,activePersistentAnimations:w,saveSlots:b=[]})=>{let{elements:A,animations:k}=e;if(t.choice&&o){let E=tt(A);if(!E)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let L={elements:v.elements},R=Ir(L,{...Ke({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f??!!t.choice,isFormVisible:h,canRollback:g,form:y,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),T=Uo(vr(Tr(R?.elements,{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(T))for(let U of T)E.children.push(U);else T&&E.children.push(T)}let O=kr({animationsDef:t.choice.animations,resources:o,previousResourceId:n?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});tr({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},$b=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,activePersistentAnimations:y,saveSlots:w=[],form:b})=>{let{elements:A,animations:k}=e;if(!b?.resourceId||!o)return e;let E=tt(A);if(!E)return e;let v=o?.layouts?.[b.resourceId];if(!v)return console.warn(`Form layout not found: ${b.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},L={...Ke({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:d,isChoiceVisible:f,isFormVisible:h,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},R=Ir(O,L),T=zo(vr(Tr(Yo(R,b),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o),b);T&&E.children.push(T);let U=kr({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 tr({animationInstances:U,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...U),e},_b=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],skipTransitionsAndAnimations:g})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=kb(y.keyboard,y.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(y.elements)||y.elements.length===0)return e;let b=tt(e.elements);if(!b)return e;let A={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return b.children.push(ra({container:A,resources:n,templateData:Ke({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},ta=({presentationState:e,previousBgmRender:t,resources:n={},runtime:o,variables:a,musicRoomPlayer:r,skipTransitionsAndAnimations:s=!1})=>{if(e?.bgm&&n){let i=e.bgm,l=!Array.isArray(i.sounds),c=ss(i),u=!l&&i.loop===!0,p=[];if(l||ds(c,"BGM sound"),u){let f=c.find(h=>h.loop===!0);if(f)throw new Error(`BGM sound "${f.id}" cannot loop inside a looping BGM channel.`)}let m=vc({bgm:i,resources:n,previousBgmRender:t});if(c.forEach(f=>{let h=n.sounds?.[f.resourceId];if(!h)return;let g=u?{...f,loop:f.loop??!1}:f;p.push(hb({node:bs({id:m.get(f.id),sound:g,resource:h,projectResources:n,soundPath:`bgm.sounds[${JSON.stringify(f.id)}]`,defaultLoop:!u,skipTransitionsAndAnimations:s}),bgm:i,sound:g,resource:h,usesLegacySound:l}))}),p.length===0)return null;let d=Ke({variables:a,runtime:o}).runtime;return gs({id:cb,volume:Zo(d,"musicVolume"),muted:!1,pan:0,loop:l?void 0:i.loop,playback:r?.bgmPlayback,interruption:i.interruption,children:p,runtime:d})}return null},Nb=(e,t)=>{if(!tt(e.elements))return e;let o=ta(t);return o&&e.audio.push(o),e},jb=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:n})=>(t?.length>0&&!n&&(e.audioEffects=structuredClone(t)),e),Tb=(e,{resources:t={},runtime:n,variables:o,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let s=r.tracks.find(u=>u.id===a.trackId),i=s?t.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=Ke({variables:o,runtime:n}).runtime,c=bs({id:pb,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(gs({id:ub,volume:ea(l,"musicVolume",jr),children:[c],runtime:l})),e},Db=(e,{presentationState:t,resources:n,runtime:o,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&n){let s=t.sfx,i=Array.isArray(s.channels)?s.channels:[],l=i.map(c=>({channel:c,usesLegacyChannel:!1}));ds(i,"SFX channel"),Array.isArray(s.items)&&l.push({channel:{id:db,sounds:s.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,m=[];if(u||ds(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let d=c.sounds.find(f=>f.loop===!0);if(d)throw new Error(`SFX sound "${d.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((d,f)=>{let h=n.sounds?.[d.resourceId];if(!h)return;let g=p?{...d,loop:d.loop??!1}:d;m.push(bs({id:u?ir("sfx","default",f,d.id):ir("sfx",c.id,d.id),sound:g,resource:h,projectResources:n,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(d.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),m.length!==0&&r.push(gs({id:ir("channel","sfx",c.id),volume:ea(o,"soundVolume",c.volume??jr),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:m,runtime:o}))})}return e},Lb=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},Mb=(e,{presentationState:t,resources:n,currentSceneId:o,runtime:a,variables:r,skipTransitionsAndAnimations:s})=>{let{audio:i}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:jr,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,m=[];if(c||ds(u,"Voice sound"),p){let f=u.find(h=>h.loop===!0);if(f)throw new Error(`Voice sound "${f.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(f=>{let h=Lb(n,o,f.resourceId);if(!h)return;let g=p?{...f,loop:f.loop??!1}:f;m.push(bs({id:ir("voice",o,c?"default":f.id),sound:g,resource:h,projectResources:n,soundPath:`voice.sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:s}))}),m.length===0)return e;let d=Ke({variables:r,runtime:a}).runtime;return i.push(gs({id:fb,volume:c?l.volume??Zo(d,"soundVolume"):ea(d,"soundVolume",l.volume??jr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:m,runtime:d})),e},Vb=(e,{presentationState:t,previousPresentationState:n,resources:o={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,saveSlots:h=[],isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:b,animations:A}=e;if(t.layout){let O=tt(b);if(!O)return e;let L=o.layouts?.[t.layout.resourceId];if(!L)return e;let R={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:L.elements||[]};O.children.push(ra({container:R,resources:o,templateData:Ke({variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,E=t.layout?.resourceId,v=kr({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:E,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:E?`layout-${E}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return tr({animationInstances:v,isLineCompleted:g,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&A.push(...v),e},qb=(e,{currentLineActions:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=t?.screen?.animations;if(!l)return e;let c=n!=null,u=kr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return tr({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...u),e},Fb=(e,{presentationState:t})=>{let n=tt(e.elements);return!n||!t?.screen||Object.assign(n,xu(t.screen)),e},Bb=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,overlayStack:f=[],dialogueHistory:h=[],saveSlots:g=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:A}=e;return f&&f.length>0&&f.forEach((k,E)=>{let v=n.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[Ru({id:`overlayStack-${E}-blocker`,screen:y}),...v.elements||[]]},L=Cu(h,n.characters,o),R=Ke({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:d,historyDialogue:L,characters:n.characters||{},skipTransitionsAndAnimations:b}),T=Ir(O,R),[U,...N]=T.children||[],H=vr(Tr({...T,children:N},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);A.push({...H,children:U?[U,...H.children||[]]:H.children})}),e},Ub=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,dialogueHistory:g=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:A}=e;if(!h?.resourceId)return e;let k=n.layouts?.[h.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${h.resourceId}`),e;let E={id:"confirmDialog",type:"container",x:0,y:0,children:[Ru({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=Cu(g,n.characters,o),O=Ir(E,Ke({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:d,form:f,confirmDialog:h,historyDialogue:v,characters:n.characters||{},skipTransitionsAndAnimations:b})),[L,...R]=O.children||[],T=vr(Tr({...O,children:R},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);return A.push({...T,children:L?[L,...T.children||[]]:T.children}),e},an=e=>(t,n)=>Sb(t,{...n,visualLayer:e}),Yb=an(wr.BEHIND_BACKGROUND),zb=an(wr.BEHIND_CHARACTER),Xb=an(wr.BEHIND_DIALOGUE),Hb=an(wr.BEHIND_CHOICE),Gb=an(wr.FOREGROUND),_u=e=>Hn(Ab,[_b,Yb,Pb,zb,Eb,Xb,Rb,Hb,Cb,$b,Vb,Gb,Fb,qb,Nb,Tb,Db,Mb,jb,Bb,Ub])(e);function Nu(e,t=""){let n=[],o=e.length,a=0,r=0,s=-1,i=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,t?parseInt(t[r++],36):0])}return n}function ju(e,t,n){let o=0,a=t.length-1;for(;o<=a;){let r=o+a>>>1,s=n[r];if(e<t[r])a=r-1;else if(e>s>>>5)o=r+1;else return s&31}return 0}var Tu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Du="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Lu="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Mu=65535,na=40960,ws=126976,Fu=new Uint8Array(12288),Bu=new Uint8Array(3072),Uu=new Uint8Array(2816),Yu,zu;{let e=(a,r,s,i,l)=>{let c=r+a.length-1;for(let u=s<r?r:s,p=i>c?c:i;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,r,s]of Nu(Tu,Du))e(Fu,0,a,r,s),e(Bu,na,a,r,s),e(Uu,ws,a,r,s),r>=65040&&!(a>=ws&&r<=129791)&&(t[o]=a,n[o++]=r<<5|s);Yu=t.slice(0,o),zu=n.slice(0,o)}function Vu(e){return e<12288?Fu[e]:e<na?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?Bu[e-na]: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>=ws&&e<129792?Uu[e-ws]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:ju(e,Yu,zu)}var Xu=Uint8Array.from(Lu,Number);function Kb(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 qu(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Kb(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*Hu(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),o=n>Mu?2:1,a=Vu(n),r=50200>>a&1?qu(0,a,n):0,s=0,i=n,l=a;for(;o<t;){n=e.codePointAt(o);let c=n>Mu?2:1,u=Vu(n),p=Xu[a<<4|u],m;p===0?m=!0:p===1?m=!1:p===2?m=!(r&1):p===3?m=!(r&4):m=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?qu(r,u,n):0,m&&(yield{segment:e.slice(s,o),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},s=o,i=n,l=u),o+=c,a=u}yield{segment:e.slice(s),index:s,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Gu(e){for(let t of Hu(e))yield t.segment}{let e=Hu("_");Xu._keep=[e,e.next()]}var Ku=1e3,Zu=50,Wb=0,Wu=100,Ju=50,Jb=60,Qb=3,Zb=.5,ew=2e4,rw=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,tw=/^\s+$/u,Qu,nw=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Gu(t)):(Qu??=new n(void 0,{granularity:"grapheme"}),Array.from(Qu.segment(t),({segment:o})=>o))},sw=e=>nw(e).reduce((t,n)=>tw.test(n)?t+Zb:rw.test(n)?t+Qb:t+1,0),iw=e=>2**(((Number.isFinite(e)?Math.min(Wu,Math.max(Wb,e)):Zu)-Ju)/(Wu-Ju)),sa=({text:e="",baseDelay:t=Ku,speed:n=Zu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):Ku,a=iw(n),r=sw(e)*Jb/a,s=Math.max(o,ew);return Math.min(o+r,s)};var Is={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},op=1,Ar=1,xt="choice",Lr="form",pn=()=>({manual:{...Is.manual},auto:{...Is.auto},applyMode:Is.applyMode}),ha=()=>({groupId:null,variantId:null,pageIndex:0}),ow="music-room:player",aw=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),As=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),ga=new Set,lw=new Set(["groupId","variantId"]),cw=new Set(["pageIndex"]),St=new Set,uw=new Set(["trackId"]),pw=new Set(["positionMs"]),fw=new Set(["pageIndex"]),ba=new Set,dw=new Set(["sceneId"]),mw=new Set(["pageIndex"]),wa=()=>({pageIndex:0}),Ia=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...pn()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},oa=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let t=ge(e)?Xe(e):e;return structuredClone(t)},q=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ps=e=>{let t=e.global.audioCommandId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal audio command counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=t+1,e.global.audioCommandId},ap=e=>{let t=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(t)||t<0)throw new Error("Internal scene replay entry counter is invalid");if(t===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=t+1,e.global.sceneReplayEntryId},fn=(e,t,n)=>({commandId:Ps(e),operation:t,...n===void 0?{}:{positionMs:n}}),va=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:Ps(e),operation:"resume"}),e.global.musicRoomPlayer=As({bgmPlayback:n})},lp=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=e.projectData.resources?.achievements?.[t];if(!n)throw new Error(`Achievement resource "${t}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${n.type}"`);return n},cp=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${t} requires a non-empty string or finite number slotId`)},it=e=>String(e),up=()=>({sections:[],resources:[]}),pp=()=>({sceneIds:[]}),yw=e=>q(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):up(),hw=e=>q(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):pp(),gw=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",bw=({sectionId:e,lineId:t,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:n,text:gw(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),fp=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),ww=e=>q(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,ka=e=>{if(!q(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},Iw=e=>{if(!q(e?.dialogueHistory))return e.dialogueHistory=fp(e?.rollback?.timeline?.length??0),e.dialogueHistory;let t=e.dialogueHistory;return Array.isArray(t.entries)||(t.entries=[]),Number.isInteger(t.currentLength)||(t.currentLength=t.entries.length),Array.isArray(t.checkpointLengths)||(t.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),t.currentLength=Math.min(Math.max(t.currentLength,0),t.entries.length),t},Aa=e=>{let t=ka(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},vw=()=>({resourceId:void 0}),kw=e=>{if(!q(e))return e;let t={...e};return Object.prototype.hasOwnProperty.call(t,"requireComplete")&&!Object.prototype.hasOwnProperty.call(t,"requireLineCompleted")&&(t.requireLineCompleted=t.requireComplete),delete t.requireComplete,t},Je=(e,t)=>{let n=e?.story?.scenes??{};for(let[o,a]of Object.entries(n))if(a?.sections?.[t])return{sceneId:o,section:a.sections[t]};return{sceneId:void 0,section:void 0}},dp=e=>{let t=e?.story?.scenes??{},n=new Map;for(let[o,a]of Object.entries(t)){let r=a?.sections??{};for(let s of Object.keys(r)){let i=n.get(s);if(i!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);n.set(s,o);let l=r[s]?.lines,c=new Map;Array.isArray(l)&&l.forEach((u,p)=>{if(typeof u?.id=="string"){if(c.has(u.id))throw new Error(`Duplicate lineId "${u.id}" in scene "${o}", section "${s}": lines[${p}] duplicates lines[${c.get(u.id)}]. Line IDs must be unique within a section.`);c.set(u.id,p)}})}}},mp=e=>e,yp=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==op)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},Aw=(e,t={})=>{let n;try{n=yp(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:n,slotId:mp(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},Pw=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Aw(t,n)])),Ew=(e,t)=>{if(!q(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!q(o))return!1;let{variableId:a,op:r,value:s,roundTo:i}=o,l=t?.resources?.variables?.[a];if(!l||$e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Kt(l.type,r,a),Wn(l.type,r,s,a,{roundTo:i}),r!=="set"||fo(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},hp=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!q(o)||!pv(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=Ew(o.payload,t);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},xw=(e,t,n)=>{let{section:o}=Je(e,t?.sectionId),r=o?.lines?.find(({id:i})=>i===t?.lineId)?.actions,s=n.split(".");for(let i of s){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(i))return;let l=Number(i);if(!Object.prototype.hasOwnProperty.call(r,l))return;r=r[l];continue}if(!q(r)||!Object.prototype.hasOwnProperty.call(r,i))return;r=r[i]}return s.at(-1)==="random"&&q(r?.distribution)?r:void 0},gp=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let t=e.max-e.min+1;return Number.isSafeInteger(t)&&t>=1&&t<=4294967296},bp=(e,t,n)=>e.filter(({path:o,type:a,result:r})=>{let s=xw(n,t,o);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return q(s.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let i=n?.resources?.variables?.[s.variableId];return typeof s.variableId=="string"&&i?.type==="number"&&i.scope==="context"&&i.readonly!==!0&&!$e(i)&&gp(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),Pa=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==Ar)throw new Error(`unsupported rollback random outcome version: ${e.randomOutcomeVersion}`);if(!Array.isArray(e.randomOutcomes))throw new Error("versioned rollback random outcomes must be an array");let n=new Set,o=e.randomOutcomes.map((a,r)=>{let s=`${a?.path}\0${a?.ordinal}`;if(!q(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||n.has(s))throw new Error(`invalid rollback random outcome at index ${r}`);return n.add(s),{path:a.path,ordinal:a.ordinal,type:a.type,result:es(V(a.result),a.type)}});return t===void 0?o:bp(o,e,t)},Sw=(e,t)=>{!q(e)||!Array.isArray(e.timeline)||e.timeline.forEach(n=>{if(!q(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=hp(n.executedActions,t);o?n.executedActions=o:delete n.executedActions;let a=Pa(n,t);a?(n.randomOutcomeVersion=Ar,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},Ow=(e,t)=>{let n=e??{};return Object.values(n).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let s=r?.rollback?.timeline;Array.isArray(s)&&s.forEach(i=>{if(!q(i))return;let l=Pa(i,t);l?(i.randomOutcomeVersion=Ar,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),n},ep=(e,t,n,o="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!q(e))throw new Error(`Malformed ${o}.${t}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${t}[${n}] entry: missing ${a}.`);if(t==="sections"){let r={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${o}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},Rw=(e,t="viewedRegistry")=>{if(e===void 0)return up();if(!q(e))throw new Error(`Malformed ${t}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${t}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${t}.resources.`);let n=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,r)=>{let s=ep(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let s=ep(a,"resources",r,t);return[s.resourceId,s]})))}},Cw=(e,t="accountReplayRegistry")=>{if(e===void 0)return pp();if(!q(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return o}))]}},ln=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:r,section:s}=Je(t,o);if(!s)throw new Error(`Malformed save slot ${n}: section "${o}" does not exist in projectData.`);if(!s.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${n}: line "${a}" does not exist in section "${o}".`);return{sceneId:r,sectionId:o,lineId:a}},wp=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],o=n.initialSectionId,a=n.sections[o];return ln({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},$w=e=>{try{return wp(e),!0}catch{return!1}},_w=(e,t,n)=>{let o=e?.pointers?.read;if(!q(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return ln(o,t,n);try{return ln(o,t,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],r=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=r;s>=0;s-=1)try{return ln(a[s],t,`${n} compatibility checkpoint`)}catch{}return wp(t)}};var Ip=(e,t)=>{let{section:n}=Je(e,t?.sectionId);return n?.lines?.find(o=>o.id===t?.lineId)},Nw=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],r=!1;if(e.entries.forEach((i,l)=>{if(!q(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}=Je(t,i.sectionId);if(!c?.lines?.some(p=>p.id===i.lineId)){r=!1,a.push(o.length);return}o.push({sectionId:i.sectionId,lineId:i.lineId,...i.appendToPrevious===!0&&r&&o.length>0?{appendToPrevious:!0}:{}}),r=!0,a.push(o.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:s}},jw=(e,t)=>q(Ip(e,t)?.actions?.dialogue),vp=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:o}=Je(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=>q(s.actions?.dialogue))?.id===t.lineId},Tw=(e,t)=>{let n=fp();return e.timeline.forEach(o=>{if(o.returnable!==!1&&jw(t,o)){let a=Ip(t,o),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&vp(t,r,o);n.entries.push({sectionId:o.sectionId,lineId:o.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},Dw=(e,t,n,o)=>{if(n.length!==t.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==o)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,s)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=r}),e},Lw=(e,t,n)=>{if(!q(e)||!Array.isArray(e.timeline))return{rollback:un({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!q(c))return[];let p=Pa(c);try{let m=ln(c,n,`rollback.timeline[${u}]`),d=p?bp(p,m,n):void 0,f=ks({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...d?{randomOutcomeVersion:Ar,randomOutcomes:d}:{}}),h=hp(V(c.executedActions),n);return h&&(f.executedActions=h),o.push(u),[f]}catch{return[]}});if(a.length===0)return{rollback:un({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,s=o.indexOf(r);s<0&&(s=a.length-1);let i=a[s];if(i?.sectionId!==t.sectionId||i?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?s=c:(a.push(ks({sectionId:t.sectionId,lineId:t.lineId})),o.push(null),s=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),s):0;return{rollback:{currentIndex:s,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:o,sourceTimelineLength:e.timeline.length}},kp=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Sa(t),a=_w(e,t,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!q(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!q(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let r=e.variables?Ht(V(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=Kw({loadedContextRuntime:q(e.runtime)?V(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=Lw(e.rollback,a,t),u=e.dialogueHistory===void 0?Tw(i,t):Dw(Nw(e.dialogueHistory,t,`contexts[${n}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:q(e.configuration)?V(e.configuration):{},views:Array.isArray(e.views)?V(e.views):[],bgm:q(e.bgm)?V(e.bgm):{resourceId:void 0},variables:{...o,...r},...u?{dialogueHistory:u}:{},rollback:i};return s&&(p.runtime=s),p},Mw=(e,t)=>{if(!q(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)=>kp(n,t,o))}},Vw=(e,t)=>{if(!q(e))throw new Error("Malformed save slot.");let n=yp(e.formatVersion);return{...e,formatVersion:n,state:Mw(e.state,t)}},rp=(e,t,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${t}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${t} must be an action object`);let o=V(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},qw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:rp(e.confirmActions,"confirmActions",{required:!0}),cancelActions:rp(e.cancelActions,"cancelActions")}},Ot=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Fw=e=>(q(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Rt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},Ap=e=>{if(!(!q(e)||!e.animations))return{animations:V(e.animations)}},Bw=(e,t)=>{let n=Ap(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Uw=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},Yw=(e,t)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!t))return`${n}:${o}:${t}`},vs=e=>String(e??""),Pp=(e,t)=>{let n=vs(t);return e?.trim===!0?n.trim():n},zw=e=>q(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>q(t)).map(([t,n])=>[t,{id:t,...V(n)}])):{},Xw=(e,t)=>{if(!t||!q(e.global.formDrafts))return;let n=e.global.formDrafts[t];return q(n)?n:void 0},Ep=(e,t)=>{let n=Fw(e);q(n[t])||(n[t]={values:{},touched:{},errors:{},submitted:!1});let o=n[t];return q(o.values)||(o.values={}),q(o.touched)||(o.touched={}),q(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},Ea=(e,t)=>{let n=Pp(e,t);return e?.required===!0&&n.length===0?"required":null},xa=({state:e,pointer:t},n=0)=>{if(t?.sectionId==null||t?.lineId==null)return n<0?null:{};let o=ge(e.projectData)?Xe(e.projectData):e.projectData,{section:a}=Je(o,t.sectionId);return Kc(o,a,t.lineId,n)},Hw=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let o=Uw(t),a=Yw(n,o);if(!o||!a)return null;let r=Xw(e,a),s=zw(t),i=qa({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([m,d])=>{let f=vs(i?.[d.variableId]),h=Object.prototype.hasOwnProperty.call(r?.values??{},m)?vs(r.values[m]):f,g=r?.touched?.[m]===!0,y=Ea(d,h),w=r?.submitted||g?y:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,A={id:m,variableId:d.variableId,value:h,initialValue:f,valid:!y,error:w,touched: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}:{}};y&&(p=!1),l[m]=A,c.push(A),u[m]=h}),{id:o,key:a,resourceId:t.resourceId,animations:t.animations,valid:p,submitted:r?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:V(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:V(t.cancelActions??{})}}}},Et="line",Dr="interaction",ks=({sectionId:e,lineId:t,rollbackPolicy:n,returnable:o,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{},...a===Ar?{randomOutcomeVersion:Ar,randomOutcomes:V(r??[])}:{}}),Sa=e=>{let t=ge(e)?Xe(e):e,{contextVariableDefaultValues:n}=Kn(t??{});return V(n)},xp=()=>({...V(tn)}),Sp=({loadedRuntime:e,runtimeIds:t,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:V(n),hasLoadedValues:!1};if(!q(e))throw new Error(`Malformed ${o}.`);let a=V(n),r=!1;return t.forEach(s=>{e[s]!==void 0&&(a[s]=ls(s,V(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Gw=({projectData:e,loadedGlobalRuntime:t={}})=>Sp({loadedRuntime:t,runtimeIds:xo,defaults:Oo(e),path:"global.runtime"}).runtimeState,Kw=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=Sp({loadedRuntime:e,runtimeIds:So,defaults:xp(),path:"context.runtime"});return n?t:void 0},Vr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ye=e=>{let t=Vr(e);return t?.kind==="sceneReplay"&&q(t.sceneReplay)?t:null},Op=(e,t)=>{let n=t?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=V(r)})},Ww=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)}}),Jw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=pn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Qw=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=V(t.nextLineConfig),e.global.overlayStack=V(t.overlayStack),e.global.confirmDialog=V(t.confirmDialog),e.global.formDrafts=V(t.formDrafts),e.global.isLineCompleted=t.isLineCompleted,t.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=t.isDialogueHistoryShowing,t.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=V(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=xe({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({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}})},Zw=e=>e.runtime?(So.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=V(tn[t]))}),e.runtime):(e.runtime=xp(),e.runtime),eI=e=>Qc(e.global),Rp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:eI(e)}})},Oa=(e,t,n)=>{let o=ls(t,n);if(t in tn){let a=Vr(e);if(!a)return o;let r=Zw(a);return r[t]=o,o}return e.global[t]=o,o},Ra=({pointer:e,projectData:t,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:V(o)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:vw(),variables:Sa(t),rollback:un({pointer:e})}),Ct=e=>e?(e.currentPointerMode="read",q(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,rI=(e,{queueRender:t=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],o=n?.pointers?.read;if(!n||!o?.sectionId||!o?.lineId)return null;let a=Ra({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,tI(e,{queueRender:t}),a},tI=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,Ot(e),Rt(e),e.global.nextLineConfig=pn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,va(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Cp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},un=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[ks({sectionId:e.sectionId,lineId:e.lineId})]:[]}},qr=(e,t={})=>{if(e?.rollback)return Cp(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=un({pointer:n,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},Es=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=qr(n);if(o.isRestoring)return;let a=Aa(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(ks(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},nI=({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}},sI=({state:e},t={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:a,lineId:r}=t,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[n];return(ge(l)?Tn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},iI=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:s}=t,i=it(n),l=e.global.saveSlots?.[i],c=ge(l)?Tn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,d=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==s||d?.sectionId!==r||d?.lineId!==s||(d.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},$p=(e,t)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let a=t?.at(-1),r=typeof a?.checkpointIndex=="number"?a.checkpointIndex:o.currentIndex;if(r<0||r>=o.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&r<o.timeline.length-1){o.timeline=o.timeline.slice(0,r+1);let s=Aa(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},oI=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},o={})=>{let a=o?.source===Et?Et:Dr,r=e.contexts?.[e.contexts.length-1],s=r?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let u=Aa(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let i=r?.pointers?.read,l=n?.lineEntryId,c=a===Et&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===i?.sectionId&&s.timeline[s.currentIndex]?.lineId===i?.lineId:n.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:s.currentIndex,source:a,...a===Et?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},aI=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),lI=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let o=t?.at(-1);if(o?.source!==Et||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;Es(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let s=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=s.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,n?.lineEntryId===o.lineEntryId&&(n.rollbackCheckpointLineEntryId=o.lineEntryId),e},cI=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==Et)return e;if(typeof n?.path!="string"||n.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(n.ordinal)||n.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=es(n.result,n.type),r=$p(e,t);if(!r)return e;if(r.randomOutcomeVersion!==Ar&&(r.randomOutcomeVersion=Ar,r.randomOutcomes=[]),r.randomOutcomes.some(({path:s,ordinal:i})=>s===n.path&&i===n.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${n.path}#${n.ordinal}`);return r.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:a}),e},lr=(e,t,n,o)=>{let r=o?.at(-1)?.source??Dr;if(!fv(t,r))return;let s=$p(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:V(n)}))},aa=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=t?.operations??[];for(let{variableId:a,op:r,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if($e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Gt(c,a),Kt(u,r,a),Wn(u,r,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=Jn(n.variables[a],r,s,{roundTo:i}))}},uI=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:o})=>{dv(e,n,o)})},pI=(e,t)=>{let{sectionId:n,lineId:o}=t,s=Me({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Ya(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},_p=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=qr(n),a=o.timeline[t];if(!a)return e;e.global.autoMode&&hn({state:e}),e.global.skipMode&&Mr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{n.variables=Sa(e.projectData),n.kind==="sceneReplay"&&(Op(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(Is),e.global.overlayStack=[],Ot(e),Rt(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&Ia(e),pI(e,o.timeline[l]),uI(e,o.timeline[l]);let s=Ct(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=ka(n);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=ap(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},fI=e=>{let{projectData:t}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:r={},runtime:s={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;dp(t),Yt(t),zt(t),Xt(t),Qr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],m=p.initialSectionId,d=p.sections[m],f={sceneId:u,sectionId:m,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:h}=Kn(t),g={...h,...Ht(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Rw(i,"accountViewedRegistry"),accountReplayRegistry:Cw(l),nextLineConfig:pn(),imageGalleryNavigation:ha(),sceneReplayNavigation:wa(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:As(),saveSlots:Pw(a),localizationPackages:V(c),overlayStack:[],variables:g,...Gw({projectData:t,loadedGlobalRuntime:s})},contexts:[Ra({pointer:f,projectData:t})]}},dI=({state:e})=>e.global.overlayStack||[],mI=({state:e})=>e.global.pendingEffects,Np=({state:e})=>e.global.skipMode,yI=({state:e})=>e.global.autoMode,jp=({state:e})=>e.global.dialogueUIHidden,tp=new WeakMap,hI=8,Tp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(!n)return[];let o,a=q(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:p,lineId:m}=n.pointers.read,d=Me({state:e},{sectionId:p});if(!d?.lines||!Array.isArray(d.lines))return[];let f=qe(d.lines,m);o=d.lines.slice(0,f+1).map(h=>({sectionId:p,lineId:h.id}))}let r=[],s=gt({variables:{...e.global?.variables??{},...Vr(e)?.variables??{}},runtime:br(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=ge(e.projectData)?Xe(e.projectData):e.projectData,l=Object.isFrozen(i)?tp.get(i):void 0;l||(l=new Map,Object.isFrozen(i)&&tp.set(i,l));let c=new Map(l),u=p=>{let m=c.get(p.sectionId);if(!m){let{section:h}=Je(i,p.sectionId);m={lines:Array.isArray(h?.lines)?h.lines:[],projections:new Map,nextLineIndex:0,presentationState:{}},c.set(p.sectionId,m)}if(l.delete(p.sectionId),l.set(p.sectionId,m),l.size>hI&&l.delete(l.keys().next().value),m.projections.has(p.lineId))return m.projections.get(p.lineId);let d=qe(m.lines,p.lineId);if(d<0)return null;let f=m.lines[d].actions||{};if(!f.dialogue)return m.projections.set(p.lineId,null),null;for(;m.nextLineIndex<=d;){let h=m.lines[m.nextLineIndex],g=m.nextLineIndex===d?f:h.actions||{};m.presentationState=et([m.presentationState,g],{resources:i.resources});let y=m.presentationState.dialogue||{};m.projections.set(h.id,g.dialogue?{line:h,lineActions:g,dialogueState:{characterId:y.characterId,character:y.character,...g.dialogue.append===!0?{content:y.content}:{}}}:null),m.nextLineIndex+=1}return m.projections.get(p.lineId)??null};for(let p of o){if(!ww(p))continue;let m=u(p);if(!m)continue;let{line:d,lineActions:f,dialogueState:h}=m;if(!f.dialogue)continue;let g=Gn({characterId:h.characterId,character:h.character,characters:e.projectData.resources?.characters??{},variables:s}),y=bw({sectionId:p.sectionId,lineId:d.id,content:f.dialogue.append===!0?h.content:f.dialogue.content,dialogueState:h,characterName:g}),w=r[r.length-1];if((a?p.appendToPrevious===!0:f.dialogue.append===!0)&&w?.sectionId===p.sectionId){r[r.length-1]={...r[r.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}r.push(y)}return r},gI=(e,t,n)=>{let o=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:s,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[it(r)],u=ge(c)?Tn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==s||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=V(n),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},bI=({state:e},t={})=>{let n=Vr(e),o=n?.pointers?.read,a=mn({state:e});if(!n||!q(a?.actions?.dialogue))return e;let r=qr(n),s=r.timeline?.[r.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=ka(n),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||t.forceNewOccurrence!==!0&&i&&l&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let m=Iw(n);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&vp(e.projectData,p,o);if(m.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,i){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return gI(e,t.savedCheckpointOccurrences,m),e},wI=({state:e})=>e.global.confirmDialog??null,dn=({state:e},{pointer:t}={})=>{let n=t??Fe({state:e})?.pointer,o=xa({state:e,pointer:n});return Hw({state:e,form:o.form,pointer:n})},II=({state:e},{pointer:t}={})=>!!dn({state:e},{pointer:t}),xe=({state:e},{pointer:t}={})=>{let n=dn({state:e},{pointer:t});if(n)return{source:Lr,formId:n.id,formKey:n.key};let o=Fp({state:e,pointer:t});return o?{source:xt,resourceId:o}:null},vI=({state:e,registry:t},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let i=Me({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=qe(i.lines,s.lastLineId),c=qe(i.lines,a);return l===-1||c===-1?s.lastLineId===a:c<=l},Ca=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},$a=({state:e},t)=>vI({state:e,registry:e.global.accountViewedRegistry},t),kI=({state:e},t)=>Ca({registry:e.global.accountViewedRegistry},t),cn=(e,t)=>!Ca({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),_a=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),Na=(e,t)=>{let n=_a(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},la=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!cn(e,t[a]))return t[a]},AI=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:V(t)},Dp=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??ha(),o=_a(t),a=Na(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:cn(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:cn(e,c)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=t.groups.findIndex(d=>d.id===n.groupId),c=t.groups[l],u=c?.variants.findIndex(d=>d.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/t.pageSize);p&&m===a&&!cn(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:la(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:la(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},ja=(e,t)=>!Ca({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Ta=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Da=(e,t)=>{let n=Ta(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},ca=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!ja(e,t[a]))return t[a]},Lp=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}),PI=(e,t)=>({...Lp(t),locked:ja(e,t)}),np=e=>{let t=Math.floor(e/1e3),n=t%60,o=Math.floor(t/60);if(o<60)return`${o}:${String(n).padStart(2,"0")}`;let a=Math.floor(o/60),r=o%60;return`${a}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`},EI=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:V(t)},Mp=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??As(),o=Ta(t),a=Da(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>PI(e,u)),i=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[i],c=l?{...Lp(l),canPlayPreviousTrack:ca(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:ca(e,t.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:np(n.positionMs),durationText:n.durationMs===null?null:np(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}}},La=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Ma=(e,t)=>{let n=La(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},xI=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:V(t)},SI=({state:e})=>ye(e)!==null,OI=({state:e})=>{let t=ye(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Vp=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,qp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??wa(),o=La(t),a=Ma(t,n),r=a*t.pageSize,s=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!Vp(e,l.sceneId)})),i=ye(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},RI=({state:e})=>e.global.nextLineConfig,Fp=({state:e,pointer:t}={})=>{let n=t??Fe({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=Me({state:e},{sectionId:o})?.lines||[],i=qe(s,a);if(!(i<0))for(let l=i;l>=0;l-=1){let c=s[l]?.actions;if(!c||!Object.prototype.hasOwnProperty.call(c,"choice"))return;let u=c.choice;if(u?.resourceId)return u.resourceId;if(!u?.animations||c.cleanAll)return}},Bp=({state:e})=>!!Fp({state:e}),CI=({state:e})=>structuredClone(e),$I=({state:e})=>V({audioEffects:e.projectData?.resources?.audioEffects??{},sounds:e.projectData?.resources?.sounds??{}}),_I=({state:e})=>{let t=br(e);return{runtime:t,musicRoomPlayer:V(e.global.musicRoomPlayer),skipTransitionsAndAnimations:t.skipTransitionsAndAnimations===!0||Gp(e)}},NI=({state:e},{sectionId:t})=>Je(e.projectData,t).sceneId,jI=({state:e})=>V(e.projectData.resources?.achievements??{}),TI=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:V(n)},Up=({state:e})=>e.global.saveSlots,DI=({state:e},t)=>{let n=t?.slotId,o=it(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Yp=({state:e})=>V(e.global.localizationPackages),Va=({state:e})=>br(e),LI=({state:e},t)=>or(e,t?.runtimeId),qa=({state:e})=>{let t={...e.global?.variables??{},...Vr(e)?.variables??{}};return gt({variables:t,runtime:br(e),variableConfigs:e.projectData.resources?.variables??{}})},Fe=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},Me=({state:e},t)=>{let{sectionId:n}=t;return Je(e.projectData,n).section},mn=({state:e})=>{let t=Fe({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:o}=t.pointer,a=Me({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines[qe(a.lines,o)]},zp=({state:e})=>xa({state:e,pointer:Fe({state:e}).pointer}),Xp=e=>{let t=mn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=gt({variables:{...e.global?.variables??{},...Vr(e)?.variables??{}},runtime:br(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${wt(o?.text,{variables:n})??""}`).join("")},Pr=({state:e})=>sa({text:Xp(e),baseDelay:or(e,"autoForwardDelay"),speed:or(e,"autoForwardSpeed")}),MI=({state:e})=>{let t=Hp({state:e}),o=mn({state:e})?.actions??{},a=et([t??{},o],{resources:e.projectData.resources});return yo(t??{},a??{})},VI=({state:e},{sectionId:t})=>{let n=Me({state:e},{sectionId:t});if(!n?.lines)return[];let o=[],a={};for(let r of n.lines){let s=r.actions||{},i=et([a,s],{resources:e.projectData.resources}),l=yo(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=ho(i)}return o},qI=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let o=VI({state:e},{sectionId:t});return n?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},Hp=({state:e})=>{let t=xa({state:e,pointer:Fe({state:e}).pointer},-1);return t===null?null:ho(t)},Fa=({state:e},{slotsPerPage:t=6}={})=>{let a=((Va({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let s=0;s<t;s++){let i=a+s,l=e.global.saveSlots&&e.global.saveSlots[it(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},FI=Up,BI=Fa,Gp=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},UI=({state:e},t={})=>{let n=zp({state:e}),o=Hp({state:e}),a=mn({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:V(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=Fe({state:e}).pointer,{sceneId:c}=Je(e.projectData,l),u={...Va({state:e}),localizationPackages:Yp({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],d=dn({state:e}),f=Bp({state:e}),h=Dp({state:e}),g=Mp({state:e}),y=qp({state:e}),w=qa({state:e}),{saveSlots:b}=Fa({state:e}),A=Gp(e);return _u({presentationState:n,previousBgmRender:t?.previousBgmRender,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:f,isFormVisible:!!d,canRollback:bf({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||A,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:Tp({state:e}),saveSlots:b,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:h,musicRoom:g,sceneReplay:y,musicRoomPlayer:V(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},YI=({state:e},t)=>(e.global.confirmDialog=qw(t),e.global.pendingEffects.push({name:"render"}),e),zI=({state:e})=>(e.global.confirmDialog&&(Ot(e),e.global.pendingEffects.push({name:"render"})),e),XI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),lr(e,"pushOverlay",n,t),e),HI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),lr(e,"popOverlay",void 0,t),e),GI=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),lr(e,"replaceLastOverlay",n,t),e),KI=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],Ot(e),Rt(e),e.global.pendingEffects.push({name:"render"}),lr(e,"clearOverlays",void 0,t),e),WI=(e,{activeInteraction:t})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),t&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},yn=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Bw(e,n),Rt(e);let o=xe({state:e},{pointer:t}),a=o?.source===xt,r=o?.source===Lr;WI(e,{activeInteraction:o});let s=ye(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=ap(e);s.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:r,activeInteraction:o}},xs=(e,t,n)=>{!(t?.source===xt||t?.source===Lr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Kp=({state:e})=>(xe({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),hn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),JI=({state:e})=>{let t=e.global.autoMode;return xe({state:e})&&!t||(t?hn({state:e}):Kp({state:e})),e},Wp=({state:e})=>(xe({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Mr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),QI=({state:e})=>{let t=Np({state:e});return xe({state:e})&&!t||(t?Mr({state:e}):Wp({state:e})),e},Ss=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),lr(e,"showDialogueUI",void 0,t),e),Jp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),lr(e,"hideDialogueUI",void 0,t),e),ZI=e=>{let{state:t}=e;return jp({state:t})?Ss(e):Jp(e),t},Fr=(e,t,n)=>(Oa(e,t,n),Rp(e),e.global.pendingEffects.push({name:"render"}),e),gn=(e,t,n,o,a)=>{let r=Oa(e,t,n);return e.global.pendingEffects.push({name:"render"}),lr(e,o,{value:r},a),e},e0=({state:e},t)=>Fr(e,"dialogueTextSpeed",t?.value),r0=({state:e},t)=>(Fr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e),t0=({state:e},t)=>(Fr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e),n0=({state:e},t)=>Fr(e,"skipUnseenText",t?.value),s0=({state:e},t)=>Fr(e,"skipTransitionsAndAnimations",t?.value),i0=({state:e},t)=>Fr(e,"soundVolume",t?.value),o0=({state:e},t)=>Fr(e,"musicVolume",t?.value),a0=({state:e},t)=>Fr(e,"muteAll",t?.value),ua=({state:e,rollbackActionBatchStack:t},n)=>gn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),pa=({state:e,rollbackActionBatchStack:t})=>{let n=or(e,"saveLoadPagination")+1;return gn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},fa=({state:e,rollbackActionBatchStack:t})=>{let n=or(e,"saveLoadPagination")-1;return gn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},da=({state:e,rollbackActionBatchStack:t},n)=>gn(e,"menuPage",n?.value,"setMenuPage",t),ma=({state:e,rollbackActionBatchStack:t},n)=>gn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),l0=({state:e})=>(e.global.pendingEffects=[],e),c0=({state:e},t)=>(e.global.pendingEffects.push(t),e),u0=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId;return lp(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},p0=({state:e},t)=>{if(ye(e))return e;let n=t?.resourceId,o=lp(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${n}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let r=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:r,target:o.target,completed:r>=o.target}}),e},Qp=e=>e?.lines?.[0],Zp=(e,{sectionId:t,resetStoryState:n=!1,screen:o})=>{let a=!!Ap(o),r=Me({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=Qp(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!rI(e,{queueRender:!a}))return e;let i=xe({state:e});n&&e.global.skipMode&&Mr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=Ct(l),p=u.read;n||st(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||qr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=un({pointer:u.read}):Es(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=yn(e,l?.pointers?.read,{screenTransition:o});return xs(e,i,c),e},f0=({state:e},t)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return Zp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},ef=e=>(e.global.accountViewedRegistry=yw(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Os=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(n=>({scope:n.scope,path:n.path,op:n.op,value:V(n.value)}))}})},rf=(e,t)=>{Os(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},d0=(e,t,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=q(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(s=>s.sectionId===n);if(r){if(r.lastLineId===void 0)return!1;let s=Me({state:e},{sectionId:n});if(s?.lines){let i=qe(s.lines,r.lastLineId),l=qe(s.lines,o);if(i===-1||l>i)return r.lastLineId===o?!1:(r.lastLineId=o,!0)}else return r.lastLineId===o?!1:(r.lastLineId=o,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:o}),!0},st=(e,t)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;d0(e,ef(e),t)&&rf(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},m0=({state:e},t)=>(st(e,t),e.global.pendingEffects.push({name:"render"}),e),y0=({state:e},t)=>{if(ye(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let o=ef(e);o.resources.find(r=>r.resourceId===n)||(o.resources.push({resourceId:n}),rf(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},cr=(e,t,n)=>{if(!q(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},ya=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},Rs=(e,t)=>{let n=e.global.imageGalleryNavigation;n.groupId===t.groupId&&n.variantId===t.variantId&&n.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},h0=({state:e},t)=>{let n="showImageGalleryVariant";cr(n,t,lw),ya(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&ya(n,"variantId",t.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let a=o.groups.findIndex(i=>i.id===t.groupId),r=o.groups[a];if(!r)return e;let s=t.variantId===void 0?r.variants[0]:r.variants.find(i=>i.id===t.variantId);return!s||cn(e,s)||Rs(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},tf=(e,t,n,o)=>{cr(o,t,ga);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let r=e.global.imageGalleryNavigation;if(typeof r.groupId!="string"||typeof r.variantId!="string")return e;let s=a.groups.find(c=>c.id===r.groupId),i=s?.variants.findIndex(c=>c.id===r.variantId);if(!s||i===void 0||i<0)return e;let l=la(e,s.variants,i,n);return l&&Rs(e,{...r,variantId:l.id}),e},g0=({state:e},t)=>tf(e,t,-1,"moveToPreviousImageGalleryVariant"),b0=({state:e},t)=>tf(e,t,1,"moveToNextImageGalleryVariant"),w0=({state:e},t)=>{if(cr("clearImageGallerySelection",t,ga),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return Rs(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},nf=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=_a(n);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=Na(n,a);return t===r||Rs(e,{groupId:null,variantId:null,pageIndex:t}),e},I0=({state:e},t)=>{if(cr("moveToImageGalleryPage",t,cw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return nf(e,t.pageIndex)},sf=(e,t,n,o)=>{cr(o,t,ga);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=Na(a,e.global.imageGalleryNavigation)+n;return s<0?e:nf(e,s)},v0=({state:e},t)=>sf(e,t,1,"moveToNextImageGalleryPage"),k0=({state:e},t)=>sf(e,t,-1,"moveToPreviousImageGalleryPage"),Er=(e,t,n)=>{if(!q(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},A0=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},nr=e=>{e.global.pendingEffects.push({name:"render"})},of=(e,t)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,r=o.trackId===t.id,s=o.bgmPlayback;a||(s={commandId:Ps(e),operation:"pause"});let i=fn(e,"play",0),l=n.tracks.indexOf(t),c=r?o.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:s},nr(e)},P0=({state:e},t)=>{let n="playMusicRoomTrack";Er(n,t,uw),A0(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||ja(e,a)||of(e,a),e},E0=({state:e},t)=>{Er("playMusicRoom",t,St);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",r=o.readiness==="error",s=o.status==="paused"&&!r?"resume":"play",i=a?0:o.positionMs;return o.playback=fn(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),nr(e),e},x0=({state:e},t)=>{Er("pauseMusicRoom",t,St);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=fn(e,"pause"),o.seekFallback=null,o.status="paused",nr(e)),e},S0=({state:e},t)=>{Er("stopMusicRoom",t,St);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=fn(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,nr(e)),e},O0=({state:e},t)=>{if(Er("seekMusicRoom",t,pw),typeof t.positionMs!="number"||!Number.isFinite(t.positionMs)||t.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let o=e.global.musicRoomPlayer;if(o.trackId===null||o.readiness!=="ready"||o.durationMs===null||t.positionMs>o.durationMs)return e;let a=fn(e,"seek",t.positionMs);return o.seekFallback={commandId:a.commandId,status:o.status,positionMs:o.positionMs},o.playback=a,o.positionMs=t.positionMs,t.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),nr(e),e},af=(e,t,n,o)=>{Er(o,t,St);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===r.trackId);if(s<0)return e;let i=ca(e,a.tracks,s,n);return i&&of(e,i),e},R0=({state:e},t)=>af(e,t,-1,"playPreviousMusicRoomTrack"),C0=({state:e},t)=>af(e,t,1,"playNextMusicRoomTrack"),$0=({state:e},t)=>{Er("clearMusicRoomSelection",t,St);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:Ps(e),operation:"resume"};return e.global.musicRoomPlayer={...As({bgmPlayback:r}),pageIndex:a},nr(e),e},lf=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=Ta(n))return e;let o=e.global.musicRoomPlayer,a=Da(n,o);return t===a||(o.pageIndex=t,nr(e)),e},_0=({state:e},t)=>{if(Er("moveToMusicRoomPage",t,fw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return lf(e,t.pageIndex)},cf=(e,t,n,o)=>{Er(o,t,St);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Da(a,e.global.musicRoomPlayer)+n;return r<0?e:lf(e,r)},N0=({state:e},t)=>cf(e,t,1,"moveToNextMusicRoomPage"),j0=({state:e},t)=>cf(e,t,-1,"moveToPreviousMusicRoomPage"),nt=e=>{let t=ye(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=V(t.sceneReplay.returnState),o=t.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),Qw(e,n),e.global.pendingEffects.push({name:"render"}),!0},T0=({state:e},t)=>{let n="startSceneReplay";if(cr(n,t,dw),ya(n,"sceneId",t.sceneId),ye(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!Vp(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],s=r?.initialSectionId,i=r?.sections?.[s],l=i?.initialLineId??i?.lines?.[0]?.id;if(!i||!l||!i.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=Ww(e);Jw(e);let u=Ra({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 Op(e,u),e.contexts.push(u),yn(e,u.pointers.read),e},uf=({state:e},t)=>{cr("finishSceneReplay",t,ba);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Vr(e)?.rollback?.isRestoring===!0)return e;let r=Fe({state:e})?.pointer,{sceneId:s}=Je(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=hw(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),Os(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},D0=({state:e},t)=>(cr("exitSceneReplay",t,ba),nt(e),e),pf=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=La(n))return e;let o=Ma(n,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},L0=({state:e},t)=>{if(cr("moveToSceneReplayPage",t,mw),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return pf(e,t.pageIndex)},ff=(e,t,n,o)=>{cr(o,t,ba);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Ma(a,e.global.sceneReplayNavigation)+n;return r<0?e:pf(e,r)},M0=({state:e},t)=>ff(e,t,1,"moveToNextSceneReplayPage"),V0=({state:e},t)=>ff(e,t,-1,"moveToPreviousSceneReplayPage"),Cs=(e,t)=>{let n=e.global.musicRoomPlayer;return!q(t)||t.id!==ow||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},Ba=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,df=(e,t,n,{readiness:o=t.readiness}={})=>((t.readiness!==o||t.positionMs!==n.positionMs||t.durationMs!==n.durationMs||t.seekFallback!==null)&&(t.readiness=o,t.positionMs=n.positionMs,t.durationMs=n.durationMs,t.seekFallback=null,nr(e)),e),q0=({state:e},t)=>{let n=Cs(e,t);return!n||n.readiness!=="loading"||!Ba(t)?e:df(e,n,t,{readiness:"ready"})},F0=({state:e},t)=>{let n=Cs(e,t);return!n||n.readiness!=="ready"||!Ba(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:df(e,n,t)},B0=({state:e},t)=>{let n=Cs(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!Ba(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,nr(e)),e},U0=({state:e},t)=>{let n=Cs(e,t);if(!n||typeof t.errorCode!="string"||!aw.has(t.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(t.errorCode==="invalid-position"){let o=n.seekFallback;if(n.playback.operation!=="seek"||o?.commandId!==t.commandId)return e;let a=n.status!==o.status||n.positionMs!==o.positionMs;return n.status=o.status,n.positionMs=o.positionMs,n.seekFallback=null,a&&nr(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,nr(e),e},mf=({state:e,rollbackActionBatchStack:t},n)=>{let o=kw(n.manual),{auto:a,applyMode:r}=n,s=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,f=xe({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"}),lr(e,"setNextLineConfig",n,t),e},Y0=({state:e},t)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;cp(n,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=it(n),s=V(e.contexts);s?.forEach(c=>{Ct(c),Cp(c.rollback),Sw(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:op,slotId:mp(n),savedAt:typeof a=="number"?a:Date.now(),image:o,state:i};return e.global.saveSlots[r]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},z0=({state:e},t)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;cp(n,"loadSlot");let o=it(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=Vw(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=pn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Ot(e),Rt(e),va(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},X0=({state:e},t)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;dp(n),Yt(n),zt(n),Xt(n),Qr(n?.resources?.variables??{}),Oo(n);let o=$w(n),a=o?e.contexts?.map((s,i)=>kp(V(s),n,i)):void 0,r=o?Ow(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=ha(),e.global.sceneReplayNavigation=wa(),va(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:i}=Kn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Ht(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return Ot(e),Rt(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},H0=({state:e},t)=>{let{l10nId:n,projectData:o}=t??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!q(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,Oa(e,"localizationPackageId",n),Rp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},G0=({state:e},t)=>{let{sectionId:n,lineId:o}=t;if(!o)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let r=n||a.pointers.read?.sectionId;if(n&&!Me({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Me({state:e},{sectionId:r});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${r} has no lines`),e;if(!s.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${r}`),e;let l=xe({state:e}),c=Ct(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=yn(e,c.read);return xs(e,l,u),e},K0=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Ss({state:e,rollbackActionBatchStack:t}),e;let o=xe({state:e});if(o?.source===xt&&n?.bypassChoice!==!0||o?.source===Lr&&n?._interactionSource!==Lr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return nt(e),e;let d=Fe({state:e})?.pointer,f=d?.sectionId,h=d?.lineId;f&&h&&st(e,{sectionId:f,lineId:h}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}});let g=e.global.nextLineConfig,y=Me({state:e},{sectionId:f});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===h?oa(e):g?.auto?.enabled&&!o&&g.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:g.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ye(e)?.sceneReplay.finishOnNextAdvance)return nt(e),e;let r=Fe({state:e})?.pointer,s=r?.sectionId,i=Me({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=qe(c,r?.lineId)+1;if(p<c.length){let m=c[p],d=!or(e,"skipUnseenText");if(e.global.skipMode&&d&&!$a({state:e},{sectionId:s,lineId:m.id}))return Mr({state:e}),e;if(l&&!l.rollback&&qr(l,{compatibilityAnchor:!0}),l){let h=Ct(l),g=h.read?.lineId;g&&s&&st(e,{sectionId:s,lineId:g}),h.read={sectionId:s,lineId:m.id}}Es(e,{sectionId:s,lineId:m.id}),Ia(e);let{activeInteraction:f}=yn(e,{sectionId:s,lineId:m.id});xs(e,o,f)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),nt(e),e;e.global.autoMode&&hn({state:e}),e.global.skipMode&&Mr({state:e}),oa(e)}return e},W0=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return nt(e),e;let n=xe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}});let o=Fe({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&st(e,{sectionId:a,lineId:r});let s=e.global.nextLineConfig;return s?.auto?.enabled&&!n&&s.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:s.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},J0=({state:e},t)=>Zp(e,{sectionId:t?.sectionId,screen:t?.screen}),Q0=({state:e,rollbackActionBatchStack:t},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return Ss({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Pr({state:e})}}),e;let a=xe({state:e});if(a?.source===xt&&n?.bypassChoice!==!0||a?.source===Lr&&n?._interactionSource!==Lr||a&&a.source!==xt&&a.source!==Lr)return e;let r=ye(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(nt(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=Fe({state:e})?.pointer,i=s?.sectionId,l=Me({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=qe(u,s?.lineId)+1;if(m<u.length){let d=u[m],f=!or(e,"skipUnseenText");if(e.global.skipMode&&f&&!$a({state:e},{sectionId:i,lineId:d.id})&&(Mr({state:e}),!o))return e;if(c&&!c.rollback&&qr(c,{compatibilityAnchor:!0}),c){let g=Ct(c),y=g.read?.lineId;y&&i&&st(e,{sectionId:i,lineId:y}),g.read={sectionId:i,lineId:d.id}}Es(e,{sectionId:i,lineId:d.id}),Ia(e);let{activeInteraction:h}=yn(e,{sectionId:i,lineId:d.id});xs(e,a,h)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),nt(e),e;e.global.autoMode&&hn({state:e}),e.global.skipMode&&Mr({state:e}),oa(e)}return e},Ua=(e,t={})=>{let n=dn({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},Z0=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let n=e.projectData.resources?.variables?.[t.variableId],o=n?.scope,a=n?.type;if($e(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Gt(o,t.variableId),Kt(a,"set",t.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},ev=(e,t)=>({id:e.id,key:e.key,valid:!0,values:V(t),fields:V(e.fields),fieldList:V(e.fieldList)}),rv=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Fe({state:e})?.pointer,n=t?.sectionId,o=t?.lineId;n&&o&&st(e,{sectionId:n,lineId:o})},tv=({state:e},t={})=>{let n=Ua(e,t),o=t.field;if(!n?.fields?.[o])return e;let a=Ep(e,n.key),r=vs(t.value),s=n.fields[o],i=Ea(s,r);return a.values[o]=r,a.touched[o]=!0,i?a.errors[o]=i:delete a.errors[o],e.global.pendingEffects.push({name:"render"}),e},nv=({state:e,rollbackActionBatchStack:t},n={})=>{let o=Ua(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=Ep(e,o.key);a.submitted=!0;let r={},s={};if(Object.entries(o.fields).forEach(([m,d])=>{let f=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:d.value,h=Ea(d,f);a.touched[m]=!0,h&&(s[m]=h),r[m]=Pp(d,f)}),a.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(r)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([m,d])=>{let{scope:f}=Z0(e,d),h=f==="context"?i.variables:e.global.variables,g=r[m];h[d.variableId]=Jn(h[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:V(h[d.variableId])})}),l&&lr(e,"updateVariable",{id:"submitForm",operations:u},t),Os(e,c);let p=ev(o,r);return rv(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},sv=({state:e},t={})=>{let n=Ua(e,t);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:V(n.values),fields:V(n.fields),fieldList:V(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},iv=({state:e,rollbackActionBatchStack:t},n)=>{let{id:o,operations:a=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let r=e.contexts[e.contexts.length-1];if(r?.rollback?.isRestoring)return e;let s=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let d=e.projectData.resources?.variables?.[c],f=d?.scope,h=d?.type;if($e(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Gt(f,c),Kt(h,u,c),Wn(h,u,p,c,{roundTo:m}),ye(e)&&f!=="context")throw new Error(`Cannot update ${f}-scoped variable "${c}" while a scene replay is active`);let g=f==="context"?r.variables:e.global.variables;if(f==="context"){s=!0;let y={variableId:c,op:u,value:p};m!==void 0&&(y.roundTo=m),l.push(y)}g[c]=Jn(g[c],u,p,{roundTo:m}),(f==="device"||f==="account")&&i.push({scope:f,path:`variables.${c}`,op:"set",value:V(g[c])})}),s&&lr(e,"updateVariable",{id:o,operations:l},t),Os(e,i),e.global.pendingEffects.push({name:"render"}),e},We=e=>(t,n)=>e({state:t},n),yf=e=>({variables:gt({variables:{...e.global?.variables??{},...Vr(e)?.variables??{}},runtime:br(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:br(e)}),ov=e=>{if(!q(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")},av=(e,t,n)=>{if(!q(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!q(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==n-1)throw new Error("conditional else branch must be the last branch")},lv=(e,t,n,o)=>{ov(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(av(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Ut(r.when,{...yf(e),...n?.bindings??{}}))){Ya(e,r.actions,n,[...o,"branches",String(a),"actions"]);return}}},cv=(e,t,n,o)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==Ar)return;let r=o.join("."),s=n.randomOutcomeOrdinals,i=s.get(r)??0;s.set(r,i+1);let l=a.randomOutcomes?.find(p=>p.path===r&&p.ordinal===i);if(!l)return;if(t?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${r}`);let c=es(V(l.result),l.type);if(c.type==="integer"){if(!gp(t.distribution)||c.value<t.distribution.min||c.value>t.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${r}`);aa(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!q(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Ya(e,u,n,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},uv={conditional:{replayLine:lv},random:{replayLine:cv},updateVariable:{recordSources:[Dr],replayLine:aa,replayRecorded:aa,persistInSaveSlot:!0},setNextLineConfig:{replayLine:We(mf)},setSaveLoadPagination:{recordSources:[Dr],replayLine:We(ua),replayRecorded:We(ua),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Dr],replayLine:We(pa),replayRecorded:We(pa),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Dr],replayLine:We(fa),replayRecorded:We(fa),persistInSaveSlot:!0},setMenuPage:{recordSources:[Dr],replayLine:We(da),replayRecorded:We(da),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Dr],replayLine:We(ma),replayRecorded:We(ma),persistInSaveSlot:!0},finishSceneReplay:{replayLine:We(uf)}},$s=e=>uv[e]??null,pv=e=>$s(e)?.persistInSaveSlot===!0,fv=(e,t)=>{let n=$s(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},dv=(e,t,n)=>{$s(t)?.replayRecorded?.(e,n)},mv=(e,t,n,o,a)=>{let r=$s(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,o,a);return}let s=o?.bindings??{},i=Wt({[t]:n},{...yf(e),...s})[t];r.replayLine(e,i)},Ya=(e,t,n,o)=>{let a=rs(t);ns(a);for(let[r,s]of a)mv(e,r,s,n,[...o,r])},yv=e=>e?.returnable!==!1,hf=(e,t)=>{if(t>=0)return e.currentIndex+t;let n=Math.abs(t);for(let o=e.currentIndex-1;o>=0;o-=1)if(yv(e.timeline[o])&&(n-=1,n===0))return o;return-1},gf=({state:e},t)=>{let{offset:n}=t;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let o=e.contexts[e.contexts.length-1];if(!o)return null;let a=o.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let r=hf(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},bf=({state:e})=>gf({state:e},{offset:-1})!==null,hv=({state:e},t)=>{let{offset:n=-1}=t;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=qr(o,{compatibilityAnchor:!o.rollback}),r=hf(a,n);return r<0||r>=a.timeline.length?e:_p(e,r)},gv=({state:e},t)=>{let{sectionId:n,lineId:o}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=qr(a,{compatibilityAnchor:!a.rollback}),i=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${n} rollback timeline`);return i===r.currentIndex?e:_p(e,i)},bv=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),ia=(e,t)=>{let n=e[t];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${t} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=n+1,e[t]},sp=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,ip=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},wv=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,wf=e=>{let t=e.global?.nextLineConfig?.auto;return t?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:t.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:t.delay??1e3}},za=e=>JSON.stringify(wf(e)),Iv=({actionName:e,args:t,state:n,previousState:o})=>{let a=sp(o),r=sp(n);if(!wv(a,r)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&ip(o)!==ip(n))return!0;let s=t[0]??{};if(e==="jumpToLine"){let i=s.sectionId??a?.sectionId;return typeof s.lineId=="string"&&r?.sectionId===i&&r?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=Je(n.projectData,s.sectionId).section,l=Qp(i)?.id;return typeof l=="string"&&r?.sectionId===s.sectionId&&r?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let i=s.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},it(i))}return!1},vv=({actionName:e,args:t,state:n,transactionalMetadata:o,previousState:a})=>{if(Iv({actionName:e,args:t,state:n,previousState:a})){let u=ia(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:za(n)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let s=(a.contexts?.length??0)>(n.contexts?.length??0),i=e==="startAutoMode"||e==="startSkipMode"?xe({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&ia(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&ia(o,"skipSessionId")},kv=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==za(e))&&(t.rollbackAuthoredSuppression=null)},Av=({state:e,playbackOwnership:t})=>{let n=xe({state:e}),o=t.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!n&&e.global.skipMode===!0,s=wf(e),i=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===za(e)),c=a?Xp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:sa({text:c,baseDelay:or(e,"autoForwardDelay"),speed:or(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:s.delayMs,trigger:s.trigger}:null}},Pv=({playbackOwnership:e})=>e.lineEntryId,If=(e,t={})=>{let n=fI(e),o=[],a=t.createPlaybackOwnership??bv;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return tc(n,{selectPendingEffects:mI,selectSkipMode:Np,selectAutoMode:yI,selectIsChoiceVisible:Bp,selectIsFormVisible:II,selectActiveInteraction:xe,selectActiveForm:dn,selectDialogueUIHidden:jp,selectDialogueHistory:Tp,selectConfirmDialog:wI,selectIsLineAccountViewed:$a,selectIsResourceAccountViewed:kI,selectImageGalleryConfig:AI,selectImageGallery:Dp,selectMusicRoomConfig:EI,selectMusicRoom:Mp,selectSceneReplayConfig:xI,selectSceneReplay:qp,selectIsSceneReplayActive:SI,selectActiveSceneReplayEntry:OI,selectNextLineConfig:RI,selectSystemState:CI,selectBgmResources:$I,selectBgmPlaybackContext:_I,selectSceneIdForSection:NI,selectAchievements:jI,selectAchievement:TI,selectSaveSlotMap:Up,selectSaveSlots:FI,selectSaveSlot:DI,selectLocalizationPackages:Yp,selectRuntime:Va,selectRuntimeValue:LI,selectAllVariables:qa,selectCurrentPointer:Fe,selectSection:Me,selectCurrentLine:mn,selectPresentationState:zp,selectAutoForwardTimerDelay:Pr,selectPresentationChanges:MI,selectSectionLineChanges:qI,selectSaveSlotPage:Fa,selectCurrentPageSlots:BI,selectRenderState:UI,selectOverlayStack:dI,selectLineIdByOffset:gf,selectCanRollback:bf,selectRollbackCursor:nI,selectDesiredPlaybackTimers:Av,selectPlaybackLineEntryId:Pv,startAutoMode:Kp,stopAutoMode:hn,toggleAutoMode:JI,startSkipMode:Wp,stopSkipMode:Mr,toggleSkipMode:QI,showDialogueUI:Ss,hideDialogueUI:Jp,toggleDialogueUI:ZI,setDialogueTextSpeed:e0,setAutoForwardDelay:r0,setAutoForwardSpeed:t0,setSkipUnseenText:n0,setSkipTransitionsAndAnimations:s0,setSoundVolume:i0,setMusicVolume:o0,setMuteAll:a0,setSaveLoadPagination:ua,incrementSaveLoadPagination:pa,decrementSaveLoadPagination:fa,setMenuPage:da,setMenuEntryPoint:ma,showConfirmDialog:YI,hideConfirmDialog:zI,resetStoryAtSection:f0,clearPendingEffects:l0,appendPendingEffect:c0,completeAchievement:u0,setAchievementProgress:p0,beginRollbackActionBatch:oI,endRollbackActionBatch:aI,ensureRandomReplayOccurrence:lI,recordRandomOutcome:cI,markRollbackCheckpointTransient:sI,markSavedRollbackCheckpointTransient:iI,recordCurrentDialogueHistory:bI,addViewedLine:m0,addViewedResource:y0,showImageGalleryVariant:h0,moveToPreviousImageGalleryVariant:g0,moveToNextImageGalleryVariant:b0,clearImageGallerySelection:w0,moveToImageGalleryPage:I0,moveToNextImageGalleryPage:v0,moveToPreviousImageGalleryPage:k0,playMusicRoomTrack:P0,playMusicRoom:E0,pauseMusicRoom:x0,stopMusicRoom:S0,seekMusicRoom:O0,playPreviousMusicRoomTrack:R0,playNextMusicRoomTrack:C0,clearMusicRoomSelection:$0,moveToMusicRoomPage:_0,moveToNextMusicRoomPage:N0,moveToPreviousMusicRoomPage:j0,musicRoomSoundReady:q0,musicRoomSoundProgress:F0,musicRoomSoundComplete:B0,musicRoomSoundError:U0,startSceneReplay:T0,finishSceneReplay:uf,exitSceneReplay:D0,moveToSceneReplayPage:L0,moveToNextSceneReplayPage:M0,moveToPreviousSceneReplayPage:V0,setNextLineConfig:mf,saveSlot:Y0,loadSlot:z0,updateProjectData:X0,updateLocalizationPackage:H0,sectionTransition:J0,jumpToLine:G0,nextLine:K0,markLineCompleted:W0,rollbackToLine:gv,rollbackByOffset:hv,pushOverlay:XI,popOverlay:HI,replaceLastOverlay:GI,clearOverlays:KI,updateFormField:tv,submitForm:nv,cancelForm:sv,updateVariable:iv,nextLineFromSystem:Q0},{createTransactionalMetadata:a,updateTransactionalMetadata:vv,finalizeTransactionalMetadata:kv,transformActionFirstArgument:(s,i)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(s,i)=>({state:s,playbackOwnership:i})})};var Ev="route-engine",xv="projectPersistence";var kf=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),we=e=>Object.prototype.toString.call(e)==="[object Object]",vf="variables.",Sv=(e={})=>{let t=we(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!we(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lineId=="string"?{lineId:n.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!we(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Ov=(e={})=>{let t=we(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!we(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lastLineId=="string"?{lastLineId:n.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!we(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Rv=(e,t)=>{let n=Ov(e),o=Sv(t),a=n.sections.map(s=>({...s})),r=n.resources.map(s=>({...s}));return o.sections.forEach(s=>{let i=a.find(l=>l.sectionId===s.sectionId);if(!i){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(i.lastLineId!==void 0){if(s.lineId===void 0){delete i.lastLineId;return}i.lastLineId=s.lineId}}),o.resources.forEach(s=>{r.find(l=>l.resourceId===s.resourceId)||r.push({...s})}),{sections:a,resources:r}},Cv=(e={})=>{let t=we(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},$v=(e,t)=>{let n=Cv(e),o=we(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},Af=(e={})=>{let t=we(e)?e:{};return{saveSlots:we(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:we(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:we(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:we(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:we(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:we(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},_v=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!we(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=t.path?.startsWith(vf)?t.path.slice(vf.length):null;if(o!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${n}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return{scope:t.scope,path:t.path,op:t.op,value:t.value,variableId:o}}if(t.path==="viewedRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${n}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${n}].`);if(!we(t.value)||!Array.isArray(t.value.sceneIds)||t.value.sceneIds.length===0||t.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${n}].`)})},Nv=(e,t)=>{let n={};return _v(t).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=Rv(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=$v(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},$t=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},jv=e=>{let t=$t(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},Tv=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},Dv=({indexedDB:e,databaseName:t,objectStoreName:n})=>new Promise((o,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let s=r.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},r.onsuccess=()=>{o(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),Lv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let l=o.transaction(t,"readonly").objectStore(t).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},bn=async({databasePromise:e,objectStoreName:t,namespace:n,patch:o})=>{let a=await e;return new Promise((r,s)=>{let i=a.transaction(t,"readwrite"),l=i.objectStore(t),c=l.get(n),u=!1,p=d=>{u||(u=!0,s(d))},m=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=Af(c.result),f=typeof o=="function"?o(d):o,h={namespace:n,version:1,...kf(),...d,...f},g=l.put(h);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}".`))}})},Mv=async({databasePromise:e,objectStoreName:t,namespace:n})=>{let o=await e;return new Promise((a,r)=>{let s=o.transaction(t,"readwrite"),l=s.objectStore(t).delete(n),c=!1,u=m=>{c||(c=!0,r(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${n}" from IndexedDB.`))},s.oncomplete=()=>{p()},s.onerror=()=>{u(s.error??new Error(`IndexedDB transaction failed while clearing namespace "${n}".`))},s.onabort=()=>{u(s.error??new Error(`IndexedDB transaction aborted while clearing namespace "${n}".`))}})},Xa=(e={})=>{let{indexedDB:t,databaseName:n=Ev,objectStoreName:o=xv,namespace:a}=e,r=Tv(t),s=jv(a),i=Dv({indexedDB:r,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await Lv({databasePromise:i,objectStoreName:o,namespace:s});return{...kf(),...Af(l)}},clear:async()=>Mv({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:we(l)?l:{}}}),saveGlobalDeviceVariables:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:we(l)?l:{}}}),saveGlobalAccountVariables:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:we(l)?l:{}}}),saveGlobalRuntime:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:we(l)?l:{}}}),applyScopedDataUpdates:async l=>bn({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>Nv(c,l)})}},Vv=Xa;var Tf=Df;var qv={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Qe=Object.prototype.hasOwnProperty,Fv={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 Be(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e!==null){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[d]:r.push(d),s++}if(e.y===void 0){let d={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[d]:r.push(d),s++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let f={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[f]:r.push(f),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let f={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Fv.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[f]:r.push(f),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Be.errors=r,s===0}var Se=Ef().default;function Ns(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ns.errors=r,s===0}function fr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)Ns(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return fr.errors=r,s===0}var Bv={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="continuity"||i==="speed"||i==="loop")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.continuity!==void 0){let i=e.continuity;if(typeof i!="string"){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="render"||i==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Bv.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return js.errors=r,s===0}function pe(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.playback!==void 0&&(js(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?js.errors:r.concat(js.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pe.errors=r,s===0}function Ts(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Qe.call(qv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let i={instancePath:t+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let i={instancePath:t+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let i={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let i={instancePath:t+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Be(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),e.filters!==void 0&&(fr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ts.errors=r,s===0}function Df(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ts(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length),Df.errors=r,s===0}var Lf=Mf;var xf={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},Sf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function Ds(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="speed"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ds.errors=r,s===0}function _e(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}e.playback!==void 0&&(Ds(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return _e.errors=r,s===0}function Ls(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(Sf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Sf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(_e(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)),e.endEffect!==void 0&&(_e(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ls.errors=r,s===0}function Ms(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var c=l===s;if(c){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=i,r!==null&&(i?r.length=i:r=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var m=p===s;if(m){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=u,r!==null&&(u?r.length=u:r=null);let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.audioEffects===void 0&&(y="audioEffects")){let w={};r===null?r=[w]:r.push(w),s++}}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[b]:r.push(b),s++}var g=y===s;f=g}if(!f){let y={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[y]:r.push(y),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Qe.call(xf.properties,y)){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let b=0;b<w;b++)Ls(y[b],{instancePath:t+"/sounds/"+b,parentData:y,parentDataProperty:b,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:xf.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}e.audioEffects!==void 0&&(_e(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length))}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Ms.errors=r,s===0}function Mf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ms(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),s=r.length),Mf.errors=r,s===0}var Vf=qf;var Uv={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Vs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=s,d=!0,f=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let h;if(p.sprites===void 0&&(h="sprites")){let g={};r===null?r=[g]:r.push(g),s++}}var i=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),i){let h=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let y={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};r===null?r=[y]:r.push(y),s++}var i=h===s;d=i}if(!d){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[h]:r.push(h),s++}for(let h in p)if(!Qe.call(Uv.properties.items.items.properties,h)){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let h={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let h={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(p.x!==void 0&&typeof p.x!="number"){let h={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.y!==void 0&&typeof p.y!="number"){let h={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let h={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let h={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let h={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let h={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let h={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let h={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let h={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let h={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let h={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}if(p.alpha!==void 0){let h=p.alpha;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.opacity!==void 0){let h=p.opacity;if(typeof h=="number"){if(h>1||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(h<0||isNaN(h)){let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}}if(p.blur!==void 0&&(Be(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),p.filters!==void 0&&(fr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),p.sprites!==void 0){let h=p.sprites;if(Array.isArray(h)){let g=h.length;for(let y=0;y<g;y++){let w=h[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let b in w)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let A={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(w.id!==void 0&&typeof w.id!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let b={instancePath:t+"/items/"+u+"/sprites/"+y+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}}}else{let g={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),s++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}}}else{let c={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Vs.errors=r,s===0}function qf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Vs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length),qf.errors=r,s===0}var Ff=Bf;function qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="items"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:t+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:t+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let d={instancePath:t+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let m={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return qs.errors=r,s===0}function Bf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return qs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),s=r.length),Bf.errors=r,s===0}var Uf=Yf;function Fs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="mode"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let i={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Fs.errors=r,s===0}function Yf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Fs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),s=r.length),Yf.errors=r,s===0}var zf=Xf;function Bs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="resourceId"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Bs.errors=r,s===0}function Xf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Bs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length),Xf.errors=r,s===0}var Hf=Gf;var Of={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:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Qe.call(Of.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.ui!==void 0){let i=e.ui;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="resourceId"||l==="animations")){let c={instancePath:t+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.resourceId!==void 0&&typeof i.resourceId!="string"){let l={instancePath:t+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}i.animations!==void 0&&(pe(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let l={instancePath:t+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.mode!==void 0){let i=e.mode;if(typeof i!="string"){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="adv"||i==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:Of.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.content!==void 0){let i=e.content;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:t+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}}else{let p={instancePath:t+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let i={instancePath:t+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let i={instancePath:t+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let i={instancePath:t+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let i={instancePath:t+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let i={instancePath:t+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let i={instancePath:t+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.character!==void 0){let i=e.character;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="name"||l==="sprite")){let c={instancePath:t+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(i.name!==void 0&&typeof i.name!="string"){let l={instancePath:t+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(i.sprite!==void 0){let l=i.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:t+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[d]:r.push(d),s++}if(m.resourceId===void 0){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[d]:r.push(d),s++}for(let d in m)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let f={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(m.id!==void 0&&typeof m.id!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let d={instancePath:t+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let d={instancePath:t+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),s++}}else{let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),s++}}}else{let u={instancePath:t+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[u]:r.push(u),s++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let c={instancePath:t+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let i={instancePath:t+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let i={instancePath:t+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Us.errors=r,s===0}function Gf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Us(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length),Gf.errors=r,s===0}var Kf=Wf;function Ys(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="id"||i==="resourceId"||i==="fields"||i==="submitActions"||i==="cancelActions"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let i={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fields!==void 0){let i=e.fields;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[p]:r.push(p),s++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.submitActions!==void 0){let i=e.submitActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.cancelActions!==void 0){let i=e.cancelActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ys.errors=r,s===0}function Wf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ys(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length),Wf.errors=r,s===0}var Jf=Qf;function zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return zs.errors=r,s===0}function Qf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return zs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),s=r.length),Qf.errors=r,s===0}var Zf=ed;function Xs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="alpha"||i==="opacity"||i==="blur"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.alpha!==void 0){let i=e.alpha;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/alpha",schemaPath:"#/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}e.blur!==void 0&&(Be(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Xs.errors=r,s===0}function ed(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Xs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),s=r.length),ed.errors=r,s===0}var rd=td;var Rf={type:"object",properties:{items:{type:"array",items:{$ref:"#/definitions/audioSound"}},channels:{type:"array",items:{type:"object",properties:{id:{type:"string",minLength:1},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},applyMode:{type:"string",enum:["singleLine","persistent"]},sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}}},required:["id","sounds"],additionalProperties:!1}}},allOf:[{not:{required:["items","channels"]}}],additionalProperties:!1},Cf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function pr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.resourceId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(Cf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Cf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}e.beginEffect!==void 0&&(_e(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length)),e.endEffect!==void 0&&(_e(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?_e.errors:r.concat(_e.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return pr.errors=r,s===0}function Hs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};r===null?r=[p]:r.push(p),s++}}var c=l===s;if(c){let u={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),s++}else s=i,r!==null&&(i?r.length=i:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)pr(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?pr.errors:r.concat(pr.errors),s=r.length)}else{let p={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let d=u[m];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[f]:r.push(f),s++}if(d.sounds===void 0){let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[f]:r.push(f),s++}for(let f in d)if(!(f==="id"||f==="volume"||f==="muted"||f==="pan"||f==="loop"||f==="interruption"||f==="applyMode"||f==="sounds")){let h={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(d.id!==void 0){let f=d.id;if(typeof f=="string"){if(Se(f)<1){let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}}if(d.volume!==void 0){let f=d.volume;if(typeof f=="number"){if(f>100||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),s++}if(f<0||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let f={instancePath:t+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.pan!==void 0){let f=d.pan;if(typeof f=="number"){if(f>1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),s++}if(f<-1||isNaN(f)){let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={instancePath:t+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),s++}if(d.interruption!==void 0){let f=d.interruption;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="immediate"||f==="loopEnd")){let h={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:Rf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.applyMode!==void 0){let f=d.applyMode;if(typeof f!="string"){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(!(f==="singleLine"||f==="persistent")){let h={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:Rf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[h]:r.push(h),s++}}if(d.sounds!==void 0){let f=d.sounds;if(Array.isArray(f)){let h=f.length;for(let g=0;g<h;g++)pr(f[g],{instancePath:t+"/channels/"+m+"/sounds/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?pr.errors:r.concat(pr.errors),s=r.length)}else{let h={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}}else{let f={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),s++}}}else{let p={instancePath:t+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}return Hs.errors=r,s===0}function td(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Hs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length),td.errors=r,s===0}var nd=sd;var $f={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function Gs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(typeof e!="string"){let p={instancePath:t,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[p]:r.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let f=0;f<d;f++){let h=e[f];if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let g={instancePath:t+"/"+f+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let g={instancePath:t+"/"+f+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(h.furigana!==void 0){let g=h.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let y={instancePath:t+"/"+f+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let y={instancePath:t+"/"+f+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/"+f+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}}}else{let g={instancePath:t+"/"+f,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}}}else{let d={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),s++}var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return Gs.errors=r,s===0}function Ks(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};r===null?r=[b]:r.push(b),s++}}var m=p===s;if(u=u||m,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.type===void 0&&(A="type")){let k={};r===null?r=[k]:r.push(k),s++}}var m=w===s;if(u=u||m,!u){let A=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.resourceId===void 0&&(E="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var m=A===s;if(u=u||m,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let L={};r===null?r=[L]:r.push(L),s++}}var m=E===s;if(u=u||m,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.transformId===void 0&&(R="transformId")){let T={};r===null?r=[T]:r.push(T),s++}}var m=O===s;if(u=u||m,!u){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.transform===void 0&&(U="transform")){let N={};r===null?r=[N]:r.push(N),s++}}var m=R===s;if(u=u||m,!u){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let H;if(e.x===void 0&&(H="x")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var m=U===s;if(u=u||m,!u){let H=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let K={};r===null?r=[K]:r.push(K),s++}}var m=H===s;if(u=u||m,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let X={};r===null?r=[X]:r.push(X),s++}}var m=M===s;if(u=u||m,!u){let le=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.anchorY===void 0&&(te="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),s++}}var m=le===s;if(u=u||m,!u){let te=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let se;if(e.scaleX===void 0&&(se="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),s++}}var m=te===s;if(u=u||m,!u){let se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Q;if(e.scaleY===void 0&&(Q="scaleY")){let $={};r===null?r=[$]:r.push($),s++}}var m=se===s;if(u=u||m,!u){let Q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let j;if(e.flipX===void 0&&(j="flipX")){let F={};r===null?r=[F]:r.push(F),s++}}var m=Q===s;if(u=u||m,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let W;if(e.flipY===void 0&&(W="flipY")){let de={};r===null?r=[de]:r.push(de),s++}}var m=j===s;if(u=u||m,!u){let W=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ve;if(e.rotation===void 0&&(ve="rotation")){let Ie={};r===null?r=[Ie]:r.push(Ie),s++}}var m=W===s;if(u=u||m,!u){let ve=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let gr={};r===null?r=[gr]:r.push(gr),s++}}var m=ve===s;if(u=u||m,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ze;if(e.originY===void 0&&(Ze="originY")){let ct={};r===null?r=[ct]:r.push(ct),s++}}var m=me===s;if(u=u||m,!u){let Ze=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Sr;if(e.layer===void 0&&(Sr="layer")){let Ur={};r===null?r=[Ur]:r.push(Ur),s++}}var m=Ze===s;if(u=u||m,!u){let Sr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ut;if(e.alpha===void 0&&(ut="alpha")){let jt={};r===null?r=[jt]:r.push(jt),s++}}var m=Sr===s;if(u=u||m,!u){let ut=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Yr;if(e.opacity===void 0&&(Yr="opacity")){let pt={};r===null?r=[pt]:r.push(pt),s++}}var m=ut===s;if(u=u||m,!u){let Yr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let zr;if(e.blur===void 0&&(zr="blur")){let Rn={};r===null?r=[Rn]:r.push(Rn),s++}}var m=Yr===s;if(u=u||m,!u){let zr=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Tt;if(e.filters===void 0&&(Tt="filters")){let Dt={};r===null?r=[Dt]:r.push(Dt),s++}}var m=zr===s;if(u=u||m,!u){let Tt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ti;if(e.animations===void 0&&(Ti="animations")){let Cn={};r===null?r=[Cn]:r.push(Cn),s++}}var m=Tt===s;u=u||m}}}}}}}}}}}}}}}}}}}}}}if(u)s=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),s++}var d=l===s;if(d){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),s++}else s=i,r!==null&&(i?r.length=i:r=null);let f=s,h=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};r===null?r=[w]:r.push(w),s++}var y=g===s;if(h=h||y,!h){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let A={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[A]:r.push(A),s++}var y=w===s;h=h||y}if(h)s=f,r!==null&&(f?r.length=f:r=null);else{let w={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[w]:r.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Gs(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),s=r.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:t+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),s++}return Ks.errors=r,s===0}function Ws(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="elements"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ws.errors=r,s===0}var Yv={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function Js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(Yv.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Js.errors=r,s===0}function Qs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let m={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let m=p.length;for(let d=0;d<m;d++){let f=p[d],h=s,g=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.resourceId===void 0&&(v="resourceId")||f.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var i=g===s;if(i){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=h,r!==null&&(h?r.length=h:r=null);let y=s,w=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.resourceId===void 0&&(v="resourceId")||f.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var l=w===s;if(l){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=y,r!==null&&(y?r.length=y:r=null);let b=s,A=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.text===void 0&&(v="text")||f.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=A===s;if(c){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=b,r!==null&&(b?r.length=b:r=null);let k=s,E=s;if(f&&typeof f=="object"&&!Array.isArray(f)){let v;if(f.transformId===void 0&&(v="transformId")||f.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=E===s;if(u){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),s++}else s=k,r!==null&&(k?r.length=k:r=null);if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),s++}for(let v in f)if(!Qe.call($f.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),s++}if(f.id!==void 0&&typeof f.id!="string"){let v={instancePath:t+"/items/"+d+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.animationName!==void 0&&typeof f.animationName!="string"){let v={instancePath:t+"/items/"+d+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.animationSpeed!==void 0&&typeof f.animationSpeed!="number"){let v={instancePath:t+"/items/"+d+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.resourceId!==void 0&&typeof f.resourceId!="string"){let v={instancePath:t+"/items/"+d+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.text!==void 0&&(Ks(f.text,{instancePath:t+"/items/"+d+"/text",parentData:f,parentDataProperty:"text",rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),s=r.length)),f.layout!==void 0&&(Ws(f.layout,{instancePath:t+"/items/"+d+"/layout",parentData:f,parentDataProperty:"layout",rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length)),f.transformId!==void 0&&typeof f.transformId!="string"){let v={instancePath:t+"/items/"+d+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),s++}if(f.transform!==void 0&&(Js(f.transform,{instancePath:t+"/items/"+d+"/transform",parentData:f,parentDataProperty:"transform",rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),s=r.length)),f.x!==void 0&&typeof f.x!="number"){let v={instancePath:t+"/items/"+d+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.y!==void 0&&typeof f.y!="number"){let v={instancePath:t+"/items/"+d+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.anchorX!==void 0&&typeof f.anchorX!="number"){let v={instancePath:t+"/items/"+d+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.anchorY!==void 0&&typeof f.anchorY!="number"){let v={instancePath:t+"/items/"+d+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.scaleX!==void 0&&typeof f.scaleX!="number"){let v={instancePath:t+"/items/"+d+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.scaleY!==void 0&&typeof f.scaleY!="number"){let v={instancePath:t+"/items/"+d+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.flipX!==void 0&&typeof f.flipX!="boolean"){let v={instancePath:t+"/items/"+d+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(f.flipY!==void 0&&typeof f.flipY!="boolean"){let v={instancePath:t+"/items/"+d+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),s++}if(f.rotation!==void 0&&typeof f.rotation!="number"){let v={instancePath:t+"/items/"+d+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.originX!==void 0&&typeof f.originX!="number"){let v={instancePath:t+"/items/"+d+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.originY!==void 0&&typeof f.originY!="number"){let v={instancePath:t+"/items/"+d+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),s++}if(f.layer!==void 0){let v=f.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:$f.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),s++}}if(f.alpha!==void 0){let v=f.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+d+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(f.opacity!==void 0){let v=f.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[O]:r.push(O),s++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}f.blur!==void 0&&(Be(f.blur,{instancePath:t+"/items/"+d+"/blur",parentData:f,parentDataProperty:"blur",rootData:a})||(r=r===null?Be.errors:r.concat(Be.errors),s=r.length)),f.filters!==void 0&&(fr(f.filters,{instancePath:t+"/items/"+d+"/filters",parentData:f,parentDataProperty:"filters",rootData:a})||(r=r===null?fr.errors:r.concat(fr.errors),s=r.length)),f.animations!==void 0&&(pe(f.animations,{instancePath:t+"/items/"+d+"/animations",parentData:f,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),s=r.length))}else{let v={instancePath:t+"/items/"+d,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let m={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}return Qs.errors=r,s===0}function sd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Qs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),s=r.length),sd.errors=r,s===0}var id=od;var zv={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 Zs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let y={instancePath:t,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};r===null?r=[y]:r.push(y),s++}var u=c===s;if(l=l||u,!l){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[b]:r.push(b),s++}var u=y===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let y={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[y]:r.push(y),s++}let p=s,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.resourceId===void 0&&(y="resourceId")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var d=m===s;if(d){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=p,r!==null&&(p?r.length=p:r=null);let f=s,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let y;if(e.startDelayMs===void 0&&(y="startDelayMs")||e.sounds===void 0&&(y="sounds")){let w={};r===null?r=[w]:r.push(w),s++}}var g=h===s;if(g){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),s++}else s=f,r!==null&&(f?r.length=f:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!(y==="sounds"||y==="resourceId"||y==="volume"||y==="muted"||y==="pan"||y==="loop"||y==="interruption"||y==="startDelayMs")){let w={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};r===null?r=[w]:r.push(w),s++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let b=0;b<w;b++)pr(y[b],{instancePath:t+"/sounds/"+b,parentData:y,parentDataProperty:b,rootData:a})||(r=r===null?pr.errors:r.concat(pr.errors),s=r.length)}else{let w={instancePath:t+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[w]:r.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let y={instancePath:t+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(e.volume!==void 0){let y=e.volume;if(typeof y=="number"){if(y>100||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[w]:r.push(w),s++}if(y<0||isNaN(y)){let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let y={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.pan!==void 0){let y=e.pan;if(typeof y=="number"){if(y>1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[w]:r.push(w),s++}if(y<-1||isNaN(y)){let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let y={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[y]:r.push(y),s++}if(e.interruption!==void 0){let y=e.interruption;if(typeof y!="string"){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[w]:r.push(w),s++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:zv.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),s++}}if(e.startDelayMs!==void 0){let y=e.startDelayMs;if(typeof y=="number"){if(y<0||isNaN(y)){let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[w]:r.push(w),s++}}else{let w={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[w]:r.push(w),s++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),s++}return Zs.errors=r,s===0}function od(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Zs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length),od.errors=r,s===0}var ad=ld;var Xv={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 ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};r===null?r=[g]:r.push(g),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};r===null?r=[w]:r.push(w),s++}var u=g===s;l=u}if(!l){let g={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};r===null?r=[g]:r.push(g),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let g=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let A;if(e.target===void 0&&(A="target")){let k={};r===null?r=[k]:r.push(k),s++}}var h=w===s;if(h){let A={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[A]:r.push(A),s++}else s=y,r!==null&&(y?r.length=y:r=null);var f=g===s;m=f}if(!m){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[g]:r.push(g),s++}if(e.name===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[g]:r.push(g),s++}if(e.description===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let y={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}if(!(g==="boolean"||g==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Xv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[y]:r.push(y),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let y={instancePath:t+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[y]:r.push(y),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if(Se(g)<1){let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[y]:r.push(y),s++}}else{let y={instancePath:t+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[y]:r.push(y),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}}else{let g={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),s++}return ei.errors=r,s===0}function ld(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ei(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),s=r.length),ld.errors=r,s===0}var cd=ud;var Hv={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 Gv={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1};function at(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="value"||i==="duration"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let i={instancePath:t+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let i={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.easing!==void 0){let i=e.easing;if(typeof i!="string"){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="linear"||i==="easeInQuad"||i==="easeOutQuad"||i==="easeInOutQuad"||i==="easeInCubic"||i==="easeOutCubic"||i==="easeInOutCubic"||i==="easeInQuart"||i==="easeOutQuart"||i==="easeInOutQuart"||i==="easeInQuint"||i==="easeOutQuint"||i==="easeInOutQuint"||i==="easeInSine"||i==="easeOutSine"||i==="easeInOutSine"||i==="easeInExpo"||i==="easeOutExpo"||i==="easeInOutExpo"||i==="easeInCirc"||i==="easeOutCirc"||i==="easeInOutCirc"||i==="easeInBack"||i==="easeOutBack"||i==="easeInOutBack"||i==="easeInBounce"||i==="easeOutBounce"||i==="easeInOutBounce"||i==="easeInElastic"||i==="easeOutElastic"||i==="easeInOutElastic")){let l={instancePath:t+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:Gv.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return at.errors=r,s===0}function re(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)at(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?at.errors:r.concat(at.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return re.errors=r,s===0}function ri(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="alpha"||i==="x"||i==="y"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ri.errors=r,s===0}function ti(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="translateX"||i==="translateY"||i==="alpha"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.translateX!==void 0&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ti.errors=r,s===0}function ot(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="tween"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.tween!==void 0&&(ti(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ot.errors=r,s===0}var _s={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"]}}]},Kv={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function ni(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="texture"||i==="channel"||i==="invert")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let i={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.channel!==void 0){let i=e.channel;if(typeof i!="string"){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Kv.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let i={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ni.errors=r,s===0}function si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)at(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?at.errors:r.concat(at.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return si.errors=r,s===0}function ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let k={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let p=s,m=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let b={};r===null?r=[b]:r.push(b),s++}var f=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),f){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let k={instancePath:t,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};r===null?r=[k]:r.push(k),s++}var f=b===s;m=f}if(!m){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let h=s,g=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let b={};r===null?r=[b]:r.push(b),s++}var w=y===s;if(s=h,r!==null&&(h?r.length=h:r=null),w){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let k={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};r===null?r=[k]:r.push(k),s++}var w=b===s;g=w}if(!g){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!Qe.call(_s.properties,b)){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let A={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:_s.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let b={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.textures!==void 0){let b=e.textures;if(Array.isArray(b)){if(b.length<1){let k={instancePath:t+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=b.length;for(let k=0;k<A;k++)if(typeof b[k]!="string"){let E={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}}else{let A={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.items!==void 0){let b=e.items;if(Array.isArray(b)){if(b.length<1){let k={instancePath:t+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[k]:r.push(k),s++}let A=b.length;for(let k=0;k<A;k++)ni(b[k],{instancePath:t+"/items/"+k,parentData:b,parentDataProperty:k,rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),s=r.length)}else{let A={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[A]:r.push(A),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let A={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:_s.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let A={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:_s.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let b={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let b={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let b={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}e.progress!==void 0&&(si(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return ii.errors=r,s===0}function oi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.prev===void 0&&(R="prev")){let T={};r===null?r=[T]:r.push(T),s++}}var p=O===s;if(v=v||p,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let N={};r===null?r=[N]:r.push(N),s++}}var p=R===s;if(v=v||p,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let H;if(e.mask===void 0&&(H="mask")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var p=U===s;v=v||p}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={};r===null?r=[R]:r.push(R),s++}var m=k===s;if(m){let R={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let R={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[R]:r.push(R),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};r===null?r=[b]:r.push(b),s++}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let b=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.tween===void 0&&(R="tween")){let T={};r===null?r=[T]:r.push(T),s++}}var y=k===s;if(y){let R={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[R]:r.push(R),s++}var w=O===s;if(v=v||w,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=R===s;if(v=v||w,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let H={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[H]:r.push(H),s++}var w=U===s;v=v||w}}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[R]:r.push(R),s++}var g=b===s;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="complete"||b==="tween"||b==="prev"||b==="next"||b==="mask")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.type!==void 0){let b=e.type;if(typeof b!="string"){let A={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[A]:r.push(A),s++}if(!(b==="update"||b==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Hv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let A=b.payload;if(!(A&&typeof A=="object"&&!Array.isArray(A))){let k={instancePath:t+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}}}else{let A={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(ri(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),s=r.length)),e.prev!==void 0&&(ot(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)),e.next!==void 0&&(ot(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),s=r.length)),e.mask!==void 0&&(ii(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return oi.errors=r,s===0}function ud(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return oi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),s=r.length),ud.errors=r,s===0}var pd=fd;var Wv={type:"object",required:["type"],$defs:{easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},propertyTracks:{type:"object",minProperties:1,properties:{volume:{$ref:"#/$defs/volumeTweenProperty"},pan:{$ref:"#/$defs/panTweenProperty"},playbackRate:{$ref:"#/$defs/playbackRateTweenProperty"}},additionalProperties:!1}},properties:{name:{type:"string"},type:{enum:["update","transition"]},tween:{$ref:"#/$defs/propertyTracks"},prev:{$ref:"#/$defs/propertyTracks"},next:{$ref:"#/$defs/propertyTracks"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{anyOf:[{required:["prev"]},{required:["next"]}],not:{required:["tween"]}}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/audioEffectResource.yaml"};function ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="number"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}return ai.errors=r,s===0}var Jv={type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]};function li(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(typeof e!="string"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(!(e==="linear"||e==="easeInQuad"||e==="easeOutQuad"||e==="easeInOutQuad"||e==="easeInCubic"||e==="easeOutCubic"||e==="easeInOutCubic"||e==="easeInQuart"||e==="easeOutQuart"||e==="easeInOutQuart"||e==="easeInQuint"||e==="easeOutQuint"||e==="easeInOutQuint"||e==="easeInSine"||e==="easeOutSine"||e==="easeInOutSine"||e==="easeInExpo"||e==="easeOutExpo"||e==="easeInOutExpo"||e==="easeInCirc"||e==="easeOutCirc"||e==="easeInOutCirc"||e==="easeInBack"||e==="easeOutBack"||e==="easeInOutBack"||e==="easeInBounce"||e==="easeOutBounce"||e==="easeInOutBounce"||e==="easeInElastic"||e==="easeOutElastic"||e==="easeInOutElastic")){let i={instancePath:t,schemaPath:"#/enum",keyword:"enum",params:{allowedValues:Jv.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),s++}return li.errors=r,s===0}function dr(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};r===null?r=[i]:r.push(i),s++}if(e.duration===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="startValue"||i==="value"||i==="duration"||i==="delay"||i==="easing"||i==="relative")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.startValue!==void 0&&typeof e.startValue!="number"){let i={instancePath:t+"/startValue",schemaPath:"#/properties/startValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.value!==void 0&&(ai(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),s=r.length)),e.duration!==void 0){let i=e.duration;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.delay!==void 0){let i=e.delay;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/delay",schemaPath:"#/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.easing!==void 0&&(li(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?li.errors:r.concat(li.errors),s=r.length)),e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:t+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return dr.errors=r,s===0}function ci(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;dr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>100||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(w<0||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>100||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(w<0||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return ci.errors=r,s===0}function ui(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)ci(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ui.errors=r,s===0}function pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;dr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"){if(w>1||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(w<-1||isNaN(w)){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"){if(w>1||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(w<-1||isNaN(w)){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return pi.errors=r,s===0}function fi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)pi(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return fi.errors=r,s===0}function di(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;dr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?dr.errors:r.concat(dr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let g;if(e.value===void 0&&(g="value")){let y={};r===null?r=[y]:r.push(y),s++}else{if(e.value!==void 0){let y=s;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),s++}var u=y===s}else var u=!0;if(u)if(e.relative!==void 0){let y=s;if(e.relative!==!1){let b={};r===null?r=[b]:r.push(b),s++}var u=y===s}else var u=!0}}var p=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),p){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.value!==void 0){let w=e.value;if(typeof w=="number"&&(w<0||isNaN(w))){let b={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}var p=g===s;l=p}if(!l){let g={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}let m=s,d=!0,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let g={};r===null?r=[g]:r.push(g),s++}var h=f===s;if(s=m,r!==null&&(m?r.length=m:r=null),h){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.startValue!==void 0){let w=e.startValue;if(typeof w=="number"&&(w<0||isNaN(w))){let b={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}var h=g===s;d=h}if(!d){let g={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),s++}return di.errors=r,s===0}function mi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[c]:r.push(c),s++}let l=i.length;for(let c=0;c<l;c++)di(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),s=r.length)}else{let l={instancePath:t+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return mi.errors=r,s===0}function ur(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="volume"||i==="pan"||i==="playbackRate")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}e.volume!==void 0&&(ui(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),s=r.length)),e.pan!==void 0&&(fi(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),s=r.length)),e.playbackRate!==void 0&&(mi(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),s=r.length))}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ur.errors=r,s===0}function yi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};r===null?r=[b]:r.push(b),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let b=s,A=s,k=s,E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.prev===void 0&&(R="prev")){let T={};r===null?r=[T]:r.push(T),s++}}var p=O===s;if(v=v||p,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.next===void 0&&(U="next")){let N={};r===null?r=[N]:r.push(N),s++}}var p=R===s;v=v||p}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={};r===null?r=[R]:r.push(R),s++}var m=k===s;if(m){let R={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let R={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[R]:r.push(R),s++}var u=b===s;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}let d=s,f=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};r===null?r=[b]:r.push(b),s++}var g=h===s;if(s=d,r!==null&&(d?r.length=d:r=null),g){let b=s,A=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.tween===void 0&&(R="tween")){let T={};r===null?r=[T]:r.push(T),s++}}var y=k===s;if(y){let R={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[R]:r.push(R),s++}else s=A,r!==null&&(A?r.length=A:r=null);let E=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[R]:r.push(R),s++}var w=O===s;if(v=v||w,!v){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let U={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[U]:r.push(U),s++}var w=R===s;v=v||w}if(v)s=E,r!==null&&(E?r.length=E:r=null);else{let R={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[R]:r.push(R),s++}var g=b===s;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="tween"||b==="prev"||b==="next")){let A={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[A]:r.push(A),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(e.type!==void 0){let b=e.type;if(!(b==="update"||b==="transition")){let A={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Wv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[A]:r.push(A),s++}}e.tween!==void 0&&(ur(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length)),e.prev!==void 0&&(ur(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length)),e.next!==void 0&&(ur(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?ur.errors:r.concat(ur.errors),s=r.length))}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),s++}return yi.errors=r,s===0}function fd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return yi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),s=r.length),fd.errors=r,s===0}var dd=md;function hi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="name"||i==="nameVariableId")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let i={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return hi.errors=r,s===0}function md(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return hi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),s=r.length),md.errors=r,s===0}var yd=hd;var Qv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function gi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(i!=="hex"){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!Qv.test(i)){let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return gi.errors=r,s===0}function hd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return gi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),s=r.length),hd.errors=r,s===0}var gd=bd;function bi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let i=e.keyboard;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),s++}}}else{let p={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.keyup!==void 0){let i=e.keyup;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let u={instancePath:t+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}else{let l={instancePath:t+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:t+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),s++}}}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return bi.errors=r,s===0}function bd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return bi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),s=r.length),bd.errors=r,s===0}var wd=Id;function wi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return wi.errors=r,s===0}function Id(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return wi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),s=r.length),Id.errors=r,s===0}var vd=kd;function Ii(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ii.errors=r,s===0}function kd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ii(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),s=r.length),kd.errors=r,s===0}var Ad=Pd;function vi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[i]:r.push(i),s++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Se(i)<1){let l={instancePath:t+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return vi.errors=r,s===0}var _f=new RegExp("^\\$(if .+|for .+|else)$","u"),Ga={validate:wn};function ki(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:t,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!_f.test(i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}for(let i in e)if(_f.test(i)){let l=e[i];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)Ga.validate(l[u],{instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?Ga.validate.errors:r.concat(Ga.validate.errors),s=r.length)}else{let c={instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return ki.errors=r,s===0}function wn(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=s;vi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),s=r.length);var u=c===s;if(l=l||u,!l){let p=s;ki(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),s=r.length);var u=p===s;l=l||u}if(l)s=i,r!==null&&(i?r.length=i:r=null);else{let p={instancePath:t,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[p]:r.push(p),s++}return wn.errors=r,s===0}function Ai(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)wn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?wn.errors:r.concat(wn.errors),s=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),s++}return Ai.errors=r,s===0}var Ka={validate:In};function In(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(Ai(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),s=r.length)),e.children!==void 0){let i=e.children;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)Ka.validate(i[c],{instancePath:t+"/children/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Ka.validate.errors:r.concat(Ka.validate.errors),s=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return In.errors=r,s===0}function Pi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)In(i[c],{instancePath:t+"/elements/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?In.errors:r.concat(In.errors),s=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),s++}}if(e.transitions!==void 0){let i={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Pi.errors=r,s===0}function Pd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Pi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),s=r.length),Pd.errors=r,s===0}var Ed=xd;function Ei(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=null,u=s,p=s,m=s,d=s,f=!1,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let E={};r===null?r=[E]:r.push(E),s++}}var g=h===s;if(f=f||g,!f){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.texture===void 0&&(v="texture")){let O={};r===null?r=[O]:r.push(O),s++}}var g=k===s;if(f=f||g,!f){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.behaviors===void 0&&(L="behaviors")){let R={};r===null?r=[R]:r.push(R),s++}}var g=v===s;if(f=f||g,!f){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.emitter===void 0&&(T="emitter")){let U={};r===null?r=[U]:r.push(U),s++}}var g=L===s;f=f||g}}}if(f)s=d,r!==null&&(d?r.length=d:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=m===s;if(y){let k={instancePath:t,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[k]:r.push(k),s++}else s=p,r!==null&&(p?r.length=p:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let k={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};r===null?r=[k]:r.push(k),s++}var b=u===s;b&&(l=!0,c=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};r===null?r=[k]:r.push(k),s++}if(e.behaviors===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};r===null?r=[k]:r.push(k),s++}if(e.emitter===void 0){let k={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};r===null?r=[k]:r.push(k),s++}}var b=w===s;if(b&&l?(l=!1,c=[c,1]):b&&(l=!0,c=1),l)s=i,r!==null&&(i?r.length=i:r=null);else{let k={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[k]:r.push(k),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[k]:r.push(k),s++}if(e.height===void 0){let k={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[k]:r.push(k),s++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),s++}}else{let E={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let k={instancePath:t+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[k]:r.push(k),s++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[E]:r.push(E),s++}if(k.appearance===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[E]:r.push(E),s++}for(let E in k)if(!(E==="emission"||E==="movement"||E==="appearance"||E==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let E=k.emission;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.movement!==void 0){let E=k.movement;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.appearance!==void 0){let E=k.appearance;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}if(k.bounds!==void 0){let E=k.bounds;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[E]:r.push(E),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0){let k=e.texture,E=s,v=!1,O=null,L=s;if(typeof k=="string"){if(Se(k)<1){let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[T]:r.push(T),s++}}else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[T]:r.push(T),s++}var A=L===s;A&&(v=!0,O=0);let R=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[T]:r.push(T),s++}var A=R===s;if(A&&v?(v=!1,O=[O,1]):A&&(v=!0,O=1),v)s=E,r!==null&&(E?r.length=E:r=null);else{let T={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[T]:r.push(T),s++}}if(e.behaviors!==void 0){let k=e.behaviors;if(Array.isArray(k)){if(k.length<1){let v={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[v]:r.push(v),s++}let E=k.length;for(let v=0;v<E;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[L]:r.push(L),s++}for(let L in O)if(!(L==="type"||L==="config")){let R={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:L},message:"must NOT have additional properties"};r===null?r=[R]:r.push(R),s++}if(O.type!==void 0){let L=O.type;if(typeof L=="string"){if(Se(L)<1){let R={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[R]:r.push(R),s++}}else{let R={instancePath:t+"/behaviors/"+v+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[R]:r.push(R),s++}}if(O.config!==void 0){let L=O.config;if(!(L&&typeof L=="object"&&!Array.isArray(L))){let R={instancePath:t+"/behaviors/"+v+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[R]:r.push(R),s++}}}else{let L={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),s++}}}else{let E={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[E]:r.push(E),s++}if(k.lifetime!==void 0){let E=k.lifetime;if(E&&typeof E=="object"&&!Array.isArray(E)){if(E.min===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),s++}if(E.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),s++}if(E.min!==void 0){let v=E.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}if(E.max!==void 0){let v=E.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),s++}}else{let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),s++}}}else{let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),s++}}}else{let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),s++}return Ei.errors=r,s===0}function xd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ei(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),s=r.length),xd.errors=r,s===0}var Sd=Od;var Nf={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 xi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!Qe.call(Nf.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:t+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:t+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}else{let l={instancePath:t+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:Nf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:t+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return xi.errors=r,s===0}function Od(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return xi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),s=r.length),Od.errors=r,s===0}var Rd=Cd;var Zv=new RegExp("^.+$","u");function Si(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.jsonData===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="jsonData"||i==="width"||i==="height"||i==="animations")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.jsonData!==void 0){let i=e.jsonData;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:t+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(Zv.test(l)){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};r===null?r=[u]:r.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};r===null?r=[p]:r.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)if(typeof u[m]!="number"){let d={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+m,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}}else{let p={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[p]:r.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),s++}}}else{let l={instancePath:t+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Si.errors=r,s===0}function Cd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Si(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),s=r.length),Cd.errors=r,s===0}var $d=_d;var jf={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 Oi(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};r===null?r=[l]:r.push(l),s++}if(e.fontSize===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};r===null?r=[l]:r.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};r===null?r=[l]:r.push(l),s++}if(e.colorId===void 0){let l={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[l]:r.push(l),s++}for(let l in e)if(!Qe.call(jf.properties,l)){let c={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};r===null?r=[c]:r.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,m=s;if(typeof l=="string"){if(Se(l)<1){let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[f]:r.push(f),s++}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[f]:r.push(f),s++}var i=m===s;i&&(u=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let y={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[y]:r.push(y),s++}let f=l.length;for(let y=0;y<f;y++){let w=l[y];if(typeof w=="string"){if(Se(w)<1){let b={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}}let h=l.length,g;if(h>1){let y={};for(;h--;){let w=l[h];if(typeof w=="string"){if(typeof y[w]=="number"){g=y[w];let b={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:h,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+h+" are identical)"};r===null?r=[b]:r.push(b),s++;break}y[w]=h}}}}else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),s++}var i=d===s;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)s=c,r!==null&&(c?r.length=c:r=null);else{let f={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:t+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:t+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:t+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.fontWeight!==void 0&&typeof e.fontWeight!="string"){let l={instancePath:t+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[c]:r.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:jf.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Se(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return Oi.errors=r,s===0}function _d(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Oi(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Oi.errors:r.concat(Oi.errors),s=r.length),_d.errors=r,s===0}var Nd=jd;var ek={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function Ri(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Qe.call(ek.properties,i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.x!==void 0){let i=e.x;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.y!==void 0){let i=e.y;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:t+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:t+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:t+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:t+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.flipX!==void 0&&typeof e.flipX!="boolean"){let i={instancePath:t+"/flipX",schemaPath:"#/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.flipY!==void 0&&typeof e.flipY!="boolean"){let i={instancePath:t+"/flipY",schemaPath:"#/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[i]:r.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:t+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:t+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:t+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),s++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ri.errors=r,s===0}function jd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ri(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ri.errors:r.concat(Ri.errors),s=r.length),jd.errors=r,s===0}var Td=Dd;function Ci(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};r===null?r=[i]:r.push(i),s++}if(e.width===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};r===null?r=[i]:r.push(i),s++}if(e.height===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};r===null?r=[i]:r.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:t+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:t+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[i]:r.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[l]:r.push(l),s++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),s++}return Ci.errors=r,s===0}function Dd(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ci(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ci.errors:r.concat(Ci.errors),s=r.length),Dd.errors=r,s===0}var An=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),kn=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),xr=e=>e===void 0?void 0:structuredClone(e),rk=Object.freeze({achievement:"achievements",animation:"animations",audioEffect:"audioEffects",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),tk=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),nk=Object.freeze({background:Tf,bgm:Lf,character:Vf,choice:Ff,cleanAll:Uf,control:zf,dialogue:Hf,form:Kf,layout:Jf,screen:Zf,sfx:rd,visual:nd,voice:id}),sk=Object.freeze({achievement:ad,animation:cd,audioEffect:pd,character:dd,color:yd,control:gd,font:wd,image:vd,layout:Ad,particle:Ed,sound:Sd,spritesheet:Rd,textStyle:$d,transform:Nd,video:Td}),ik=new Set(["files","language","patches"]),ok=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),ak=new Set(["lineId","mode","payload","type"]),lk=new Set(["mode","payload","sceneId","type"]),ck=new Set(["mode","operation","payload","resourceId","type"]),uk=new Set(["fileId","mimeType"]),G=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},sr=(e,t)=>{kn(e)||G(t,"expected an object")},Wa=(e,t)=>{Array.isArray(e)||G(t,"expected an array")},_t=(e,t)=>{(typeof e!="string"||e.length===0)&&G(t,"expected a non-empty string")},qd=(e,t)=>{typeof e!="string"&&G(t,"expected a string")},yr=(e,t,n)=>{for(let o of Object.keys(e))t.has(o)||G(`${n}.${o}`,"unknown field")},hr=(e,t,n)=>{for(let o of t)An(e,o)||G(n,`missing required field "${o}"`)},pk=e=>e.replaceAll("~1","/").replaceAll("~0","~"),fk=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(pk);return t?.keyword==="required"?n.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&n.push(t.params.additionalProperty),n.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},dk=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,n)=>{if(t===void 0)return n;let o=n.instancePath.split("/").length,a=t.instancePath.split("/").length;return o>a?n:t},void 0)??e[0],Fd=({value:e,validator:t,path:n,contract:o})=>{if(t(e))return;let a=dk(t.errors);G(fk(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},$i=(e,t,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||G(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,a)=>$i(o,`${t}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>$i(a,`${t}.${o}`,n))}},mr=(e,t)=>{e===""&&G(t,"expected a non-empty resourceId")},mk=(e,t,n)=>{let o=(s,i)=>mr(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>mr(l?.resourceId,`${i}[${c}].resourceId`)),r=(s,i)=>{mr(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":mr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"bgm":o(t.audioEffects,`${n}.audioEffects`),r(t,n);break;case"voice":r(t,n);break;case"sfx":a(t.items,`${n}.items`),(t.channels??[]).forEach((s,i)=>a(s?.sounds,`${n}.channels[${i}].sounds`));break;case"character":(t.items??[]).forEach((s,i)=>{(s.sprites??[]).forEach((l,c)=>mr(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":mr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"control":mr(t.resourceId,`${n}.resourceId`);break;case"dialogue":mr(t.ui?.resourceId,`${n}.ui.resourceId`),o(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,i)=>mr(s?.resourceId,`${n}.character.sprite.items[${i}].resourceId`)),o(t.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(t.animations,`${n}.animations`);break;case"visual":(t.items??[]).forEach((s,i)=>{mr(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},Nt=(e,t)=>{_t(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&G(t,`"${e}" is not a safe ID`)},yk=(e,t)=>{_t(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&G(t,"must be a safe single filename")},vn=(e,t)=>{if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return!Array.isArray(e)||!Array.isArray(t)?!1:e.length===t.length&&e.every((a,r)=>vn(a,t[r]));if(!kn(e)||!kn(t))return!1;let n=Object.keys(e).sort(),o=Object.keys(t).sort();return vn(n,o)&&n.every(a=>vn(e[a],t[a]))},_i=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>_i(o,t,n)),t;if(!kn(e)||n.has(e))return t;n.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&t.add(a),_i(a,t,n);return t},hk=e=>{let t=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(o?.sections??{}))for(let[s,i]of(r?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=t.get(i.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:i}),t.set(i.id,l)}return t},Bd=(e,t,n)=>{let o=e.get(t)??[];return o.length===0&&G(n,`lineId "${t}" does not exist in projectData`),o.length>1&&G(n,`lineId "${t}" is not globally unique in projectData`),o[0]},Ud=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Ld=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Md=e=>{let t=xr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))kn(n)&&delete n.placeholder;return t},gk=(e,t,n,o)=>{e==="choice"&&!vn(Ld(t),Ld(n))&&G(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!vn(Md(t),Md(n))&&G(o,"form behavior must remain identical; only presentation fields and placeholders may change")},bk=({patch:e,path:t,lineIndex:n})=>{yr(e,ok,t),hr(e,["type","lineId","actionType","payload"],t),Nt(e.lineId,`${t}.lineId`),_t(e.actionType,`${t}.actionType`),sr(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'line.action supports only "replace"'),tk.has(e.actionType)||G(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=Bd(n,e.lineId,`${t}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&G(`${t}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&G(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),An(e.payload,"content")&&G(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&G(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),gk(e.actionType,a,e.payload,`${t}.payload`),Fd({value:e.payload,validator:nk[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),$i(e.payload,`${t}.payload`),mk(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},wk=(e,t)=>{Wa(e,t),e.forEach((n,o)=>{sr(n,`${t}[${o}]`),yr(n,new Set(["text"]),`${t}[${o}]`),hr(n,["text"],`${t}[${o}]`),qd(n.text,`${t}[${o}].text`)})},Ik=({patch:e,path:t,lineIndex:n})=>{yr(e,ak,t),hr(e,["type","lineId","payload"],t),Nt(e.lineId,`${t}.lineId`),sr(e.payload,`${t}.payload`),yr(e.payload,new Set(["content"]),`${t}.payload`),hr(e.payload,["content"],`${t}.payload`),wk(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'line.dialogue supports only "replace"');let o=Bd(n,e.lineId,`${t}.lineId`);return o.line?.actions?.dialogue===void 0&&G(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},vk=({patch:e,path:t,projectData:n})=>(yr(e,lk,t),hr(e,["type","mode","sceneId","payload"],t),Nt(e.sceneId,`${t}.sceneId`),sr(e.payload,`${t}.payload`),yr(e.payload,new Set(["name"]),`${t}.payload`),hr(e.payload,["name"],`${t}.payload`),qd(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&G(`${t}.mode`,'story.scene requires "patch"'),An(n?.story?.scenes??{},e.sceneId)||G(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),kk=(e,t,n)=>{sr(t,n),["font","image","sound","spritesheet","video"].includes(e)&&_t(t.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||G(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||G(`${n}.height`,"expected an integer")),e==="spritesheet"&&(sr(t.jsonData,`${n}.jsonData`),Number.isInteger(t.width)||G(`${n}.width`,"expected an integer"),Number.isInteger(t.height)||G(`${n}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&G(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),Fd({value:t,validator:sk[e],path:n,contract:`the resource.${e} schema`}),$i(t,n)},Ak=({patch:e,path:t,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{yr(e,ck,t),hr(e,["type","resourceId","payload"],t),Nt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=rk[r];s||G(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&G(`${t}.operation`,'the only resource operation is "add"'),kk(r,e.payload,`${t}.payload`);let i=n?.resources?.[s]??{},l=An(i,e.resourceId);e.operation==="add"&&l&&G(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&G(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of _i(e.payload))!o.has(c)&&!a.has(c)&&G(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:t,patch:e}},Vd=({resources:e,collectionName:t,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!An(e?.[t]??{},n))&&G(o,`${a} resource "${n}" was not found`)},Pk=(e,t)=>{let n=xr(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=xr(a.patch.payload));let o=n.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,s=Array.isArray(r.fontId)?r.fontId:[r.fontId];s.forEach((i,l)=>Vd({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])Vd({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},Ek=({patch:e,path:t,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(sr(e,t),_t(e.type,`${t}.type`),e.type==="line.action")return bk({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return Ik({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return vk({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return Ak({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});G(`${t}.type`,`unsupported patch type "${e.type}"`)},xk=(e,t)=>{Wa(e,t);let n=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;sr(o,r),yr(o,uk,r),hr(o,["fileId"],r),yk(o.fileId,`${r}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&G(`${r}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&G(`${r}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},Sk=({packageId:e,packageData:t,path:n,projectData:o,lineIndex:a,canonicalFileIds:r})=>{sr(t,n),yr(t,ik,n),hr(t,["language","files","patches"],n),_t(t.language,`${n}.language`);let s=xk(t.files,`${n}.files`);Wa(t.patches,`${n}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=Ek({patch:c,path:`${n}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:r});return i.has(p.key)&&G(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:t,fileIds:s,patches:l}},Yd=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};sr(t,"l10nData"),yr(t,new Set(["packages"]),"l10nData"),hr(t,["packages"],"l10nData"),sr(t.packages,"l10nData.packages");let n=hk(e),o=_i(e?.resources??{}),a=new Map,r=new Map;for(let[s,i]of Object.entries(t.packages)){Nt(s,`l10nData.packages.${s}`);let l=Sk({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&G(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&G(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,s)}Pk(e,l),a.set(s,l)}return{packages:a}},Ok=(e,t)=>{let{collectionName:n,patch:o}=t;e.resources[n]??={},e.resources[n][o.resourceId]=xr(o.payload)},Rk=(e,t)=>{let{patch:n}=t,o=e.story.scenes[n.sceneId];o.name=n.payload.name},Ck=(e,t)=>{let{location:n,patch:o}=t,a=Ud(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=xr(o.payload);return}let r=xr(n.line.actions.dialogue.content);a.actions.dialogue=xr(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},$k=(e,t)=>{let{location:n,patch:o}=t,a=Ud(e,n);a.actions.dialogue.content=xr(o.payload.content)},zd=({projectData:e,l10nData:t})=>{let n=Yd({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},Ni=({projectData:e,l10nData:t,l10nId:n=null})=>{let o=Yd({projectData:e,l10nData:t});if(n!==null&&(Nt(n,"l10nId"),o.packages.has(n)||G("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=xr(e),r=o.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>Ok(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>Rk(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>Ck(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>$k(a,s)),a};var Ja=Object.freeze({auto:1e3,skip:80,authored:1e3}),xn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Xd=new WeakMap,_k=new ArrayBuffer(8),Qa=new DataView(_k),Nk=e=>{let t=Xd.get(e);if(t)return t;let n={dispatchDepth:0};return Xd.set(e,n),n},jk=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Tk=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Br=(e,t,n)=>{if(!jk(e)||!Tk(e,t))throw new TypeError(`${n} has an invalid shape`)},Pn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},En=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},Hd=e=>{if(En(e,"duration"),e===0)return 0n;Qa.setFloat64(0,e,!1);let t=Qa.getUint32(0,!1),n=Qa.getUint32(4,!1),o=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(n);if(o===0)return a;let r=1n<<52n|a,s=o-1;return r<<BigInt(s)},Dk=e=>structuredClone(e),Za=(e,t)=>e===t?!0:!e||!t||e.mode!==t.mode||e.kind!==t.kind?!1:e.mode==="legacy"?e.instanceToken===t.instanceToken:e.delayMs!==t.delayMs?!1:e.kind==="auto"?e.contentKey===t.contentKey&&e.owner.sessionId===t.owner.sessionId&&e.owner.lineEntryId===t.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===t.owner.sessionId:e.trigger===t.trigger&&e.owner.lineEntryId===t.owner.lineEntryId,el=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(Br(t,["owner","delayMs","contentKey"],"auto timer"),Br(t.owner,["sessionId","lineEntryId"],"auto timer owner"),Pn(t.owner.sessionId,"auto owner sessionId"),Pn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(En(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Br(t,["owner","delayMs"],"skip timer"),Br(t.owner,["sessionId"],"skip timer owner"),Pn(t.owner.sessionId,"skip owner sessionId"),En(t.delayMs,"skip delayMs");else{if(Br(t,["owner","delayMs","trigger"],"authored timer"),Br(t.owner,["lineEntryId"],"authored timer owner"),Pn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(En(t.delayMs,"authored delayMs"),t.trigger!=="fromStart"&&t.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...Dk(t)}},Lk=e=>{if(Br(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(Pn(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}}Br(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:el("auto",e.timers.auto,e.lineEntryId),skip:el("skip",e.timers.skip,e.lineEntryId),authored:el("authored",e.timers.authored,e.lineEntryId)};if(t.auto&&t.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:t}},rl=e=>({descriptor:e,remainingQuanta:Hd(e.delayMs)}),ji=["auto","skip","authored"],Gd=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof t!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let o=Nk(e),a=!0,r={},s={},i=null,l=null,c=null,u=null,p=!1,m=!1,d="legacy",f={auto:null,skip:null,authored:null},h={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},y=()=>ji.some(M=>f[M]),w=()=>{l=null,c=null},b=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||m){b();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},A=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=i;M&&(w(),i=null,u=M,e.remove(M),u===M&&(u=null))},E=()=>{f={auto:null,skip:null,authored:null}},v=()=>{E(),s={},m||k()},O=M=>{if(o.dispatchDepth>0||m){c=M,b();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},L=()=>{if(!a||!y()||i)return;A();let M=r,K=s,le={},X=oe=>{if(!a||M!==r||K!==s||le!==l||X!==i||m)return;if(!oe||typeof oe.deltaMS!="number"||!Number.isFinite(oe.deltaMS)||oe.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let se=Hd(oe.deltaMS);m=!0,o.dispatchDepth+=1;let ue=s,Q=null;try{let $=[];for(let j of ji){let F=f[j];F&&(F.remainingQuanta<=se?($.push({kind:j,descriptor:F.descriptor,revision:g[j]}),f[j]=null):F.remainingQuanta-=se)}if($.length>0){try{t({dueKinds:$.map(({kind:j})=>j)})}catch(j){let F=n(j);if(d==="reconciled"&&F==="preCommit")for(let{kind:W,descriptor:de}of $)h[W]=de;else d==="legacy"&&E();throw j}if(d==="legacy")for(let j of $)j.kind==="skip"&&g.skip===j.revision&&f.skip===null&&(f.skip=rl(j.descriptor))}}catch($){Q=$}finally{o.dispatchDepth-=1,m=!1;try{ue===s?y()?L():k():i===X&&!y()&&k()}catch($){throw Q?new AggregateError([Q,$],"Playback attempt and ticker cleanup both failed"):$}}if(Q)throw Q},te={callback:X,lifecycleToken:M,generationToken:K,registrationToken:le};i=X,c=te;try{e.add(X)}catch(oe){throw i=null,w(),E(),s={},u=X,oe}O(te)},R=M=>{g[M]+=1,f[M]=null,h[M]=null,!y()&&!m&&k()},T=(M,K)=>{En(K,`${M} delay`),d="legacy",g[M]+=1,h[M]=null,f[M]=rl({mode:"legacy",kind:M,instanceToken:{},delayMs:K}),L()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return T("auto",M.payload?.delay??Ja.auto),!0;case"clearAutoNextTimer":return R("auto"),!0;case"startSkipNextTimer":return T("skip",M.payload?.delay??Ja.skip),!0;case"clearSkipNextTimer":return R("skip"),!0;case"nextLineConfigTimer":return T("authored",M.payload?.delay??Ja.authored),!0;case"clearNextLineConfigTimer":return R("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let K;try{K=Lk(M)}catch(X){try{v()}catch(te){throw new AggregateError([X,te],"Playback schedule validation and cleanup both failed")}throw X}if(d="reconciled",K.status==="unsettled"){E(),m||k();return}let le={};for(let X of ji){let te=K.timers[X],oe=h[X];if(oe&&(!te||!Za(oe,te))&&(h[X]=null),te&&h[X]&&Za(h[X],te)){le[X]=null;continue}let se=f[X];le[X]=te&&se&&Za(se.descriptor,te)?se:te?rl(te):null}f=le,y()?L():m||k()},reset:()=>{let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);r={},s={},w(),i=null,u=null,E(),h={auto:null,skip:null,authored:null};for(let X of ji)g[X]+=1;d="legacy",a=!0;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K},dispose:()=>{a=!1,r={},s={},w(),E(),h={auto:null,skip:null,authored:null};let M=[i,u].filter((X,te,oe)=>X&&oe.indexOf(X)===te);i=null,u=null;let K=null,le=null;for(let X of M)try{e.remove(X)}catch(te){K??=te,le??=X}if(u=le,K)throw K}}};var Mk=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),Vk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),tl="conditional",Sn="random",sl=Symbol("conditionalAutoContinue"),qk=new Set(["sectionTransition","resetStoryAtSection"]),Fk=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),Bk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Uk=new Set(["nextLine","nextLineFromSystem"]),Yk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),nl="form",zk=new Set(["submitForm","cancelForm"]),Xk="showImageGalleryVariant",Hk="playMusicRoomTrack",Gk="startSceneReplay",Kk="channel:bgm",Kd=1e3,Wk="routing_cycle",Jk=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Ue=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Qk=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,On=e=>e?.type===sl,lt=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Zk=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function il(e){let t=Qk(),n,o=0,a=!1,r=0,s=null,i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],w=[],b=!1,A=null,k=null,E=null,v=null,O=new Map,L,R,T=null,U=!1,N=!1,H=0,fe=new Map,M=hc(e.randomSource),{handlePendingEffects:K}=e;if(typeof K!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=K.bind(K),X=typeof K.reconcilePlaybackScheduleV1=="function"?K.reconcilePlaybackScheduleV1.bind(K):null,te=typeof K.reset=="function"?K.reset.bind(K):null,oe=typeof K.dispose=="function"?K.dispose.bind(K):null;if(X&&(!te||!oe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let se=I=>{if(N)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ue=I=>{if(se(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},Q=(I,P)=>{if(H===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},C=fe.get(I);(C===void 0||S[P]>S[C])&&fe.set(I,P)},$=I=>{let P=fe.get(I)??"preCommit";return fe.delete(I),P},j=I=>{if(X){N=!0;try{let P=X(structuredClone(I));if(P!==null&&(typeof P=="object"||typeof P=="function")&&typeof P.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{N=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),W=I=>{if(!(!X||!a||!n)){U=!0;try{j(F())}catch(P){if(I){let S=new AggregateError([I,P],"Playback work and schedule invalidation both failed");throw fe.delete(I),Q(S,"reconcileFailed"),S}throw Q(P,"reconcileFailed"),P}}},de=()=>{if(!X||!U||!a||!n||i>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(P){throw Q(P,"reconcileFailed"),W(P),P}try{j({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(P){throw Q(P,"reconcileFailed"),W(P),P}U=!1},ve=(I=new Map,P=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>P<S.expiresAt).map(([S,C])=>[S,{animation:structuredClone(C.animation),startedAt:C.startedAt,expiresAt:C.expiresAt}])),Ie=(I=new Map)=>Array.from(I.values()).map(P=>structuredClone(P.animation)),me=(I=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,P])=>I<P.expiresAt))},gr=()=>{if(!a||i>0||l)return;l=!0;let I=0;try{for(;n.selectPendingEffects().length>0;){let P=n.selectCurrentPointer()?.pointer??null;if(I>=Kd){let _=new Error(`RouteEngine exceeded ${Kd} synchronous effect batches at section "${P?.sectionId}", line "${P?.lineId}". Check for an immediate routing cycle.`);throw _.code=Wk,_.pointer={sectionId:P?.sectionId,lineId:P?.lineId},Q(_,"postCommitUnsettled"),W(_),_}I+=1;let S=[...n.selectPendingEffects()],C=S.map(_=>_.name!=="handleLineActions"?_:{..._,payload:{..._.payload,pointer:structuredClone(P)}});n.clearPendingEffects();try{let _=X?C.filter(B=>!xn.has(B.name)):C;_.length>0&&le(_)}catch(_){throw n.clearPendingEffects(),S.forEach(B=>{n.appendPendingEffect(B)}),Q(_,"postCommitUnsettled"),W(_),_}}}finally{l=!1}de()},Ze=I=>{i+=1;let P=!1;try{let S=I();return P=!0,S}finally{i-=1,P&&gr()}},ct=()=>ta({presentationState:n.selectPresentationState(),previousBgmRender:ut(),resources:n.selectBgmResources(),...n.selectBgmPlaybackContext()}),Sr=()=>structuredClone(n.selectPresentationState()?.bgm??null),Ur=()=>n.selectBgmResources(),ut=()=>({channel:A,bgm:k,resources:E}),jt=I=>!!I?.audioEffects,Yr=()=>structuredClone(b?A:ct()),pt=()=>b?structuredClone(k):Sr(),zr=()=>b?structuredClone(E):Ur(),Rn=I=>n.selectSceneIdForSection({sectionId:I}),Tt=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,P=new Set(I?[]:y.map(S=>S.id));w.forEach(S=>{S.status=S.effects?.some(C=>P.has(C.id))?"active":"settled"}),I&&(y=[]),w=[]},Dt=(I,P,S,C,_,B,z)=>{let J=n.selectPlaybackLineEntryId?.()??0,ce=(P.actionPath??["bgm"]).join("."),he=n.selectCurrentPointer()?.pointer,be=he?.sceneId??Rn(he?.sectionId),ke=P.rollbackSource==="line"&&he?`story.scenes[${JSON.stringify(be)}].sections[${JSON.stringify(he.sectionId)}].lines[${JSON.stringify(he.lineId)}].actions.${ce}`:ce,Oe=P.rollbackSource==="line"?`${o}:${J}:${ke}`:null,Ye=Oe?O.get(Oe):null;if(Ye)return Ye;g+=1;let je={occurrenceId:`${t}:g${o}:l${J}:audio${g}`,actionPath:ke,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Te=Ur(),Re=_c({occurrence:je,resources:Te,previousResources:z??Te,nextResources:Te,previousChannel:S,nextChannel:C,previousBgm:_,nextBgm:B});if(je.effects=structuredClone(Re),je.status=Re.length>0?"pending":"settled",y=structuredClone(Re),w.push(je),Oe)for(O.set(Oe,je);O.size>512;){let dt=O.keys().next().value;O.delete(dt)}return je},Ti=({initialState:I,namespace:P})=>{se("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:C,..._}=I,B=C===void 0?void 0:structuredClone(C),z=structuredClone(I.projectData),J=zd({projectData:z,l10nData:B}),ce=_.global??{};if(!Ue(ce))throw new Error("Malformed global state.");let he=ce.runtime??{};if(!Ue(he))throw new Error("Malformed global.runtime.");let be=he.localizationPackageId;if(be!=null&&typeof be!="string")throw new Error("localizationPackageId requires a string or null value");let ke=new Set(J.map(({l10nId:Te})=>Te).filter(Te=>Te!==null)),Oe=typeof be=="string"&&ke.has(be)?be:null,Ye=Ni({projectData:z,l10nData:B,l10nId:Oe}),je=If({..._,global:{...ce,localizationPackages:J,runtime:{...he,localizationPackageId:Oe}},projectData:Ye,initialAudioCommandId:S});te?.(),n=je,o+=1,a=!0,r=0,s=$t(P),i=0,l=!1,c=0,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,g=0,y=[],w=[],b=!1,A=null,k=null,E=null,v={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Ur()},O=new Map,L=z,R=B,T=Oe,U=!0,N=!1,H=0,fe.clear(),n.appendPendingEffect({name:"handleLineActions"}),gr()},Cn=()=>{se("dispose"),a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,m=null,d=new Map,f=new Map,h=new Map,y=[],w=[],b=!1,A=null,k=null,E=null,v=null,O=new Map,U=!1,fe.clear(),oe?.())},em=()=>s,rm=()=>n.selectPresentationState(),tm=()=>n.selectPresentationChanges(),nm=I=>n.selectSectionLineChanges(I),al=(I={})=>{ue("rendering"),r+=1;let P=Date.now();me(P);let S=f.size>0,C=ve(d,P),_=S?ve(f,P):new Map,B=n.selectRenderState({previousBgmRender:ut(),activePersistentAnimations:Ie(C),restoredPersistentAnimations:Ie(_),activeAudioEffects:structuredClone(y)}),z={...B,id:`render-${t}-${o}-${r}`};return h.set(z.id,{builtAt:P,persistentAnimationSessions:new Map([..._.entries(),...C.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectIds:y.map(J=>J.id),bgmPresentation:Sr(),bgmResources:Ur(),retainsActiveAudioEffects:y.length>0&&y.every(J=>(B.audioEffects??[]).some(ce=>ce.id===J.id))}),z},sm=(I={})=>al(I),im=(I={})=>al(I),om=I=>{if(!a||!n)return;let P=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=P?h.get(P):null;P&&h.delete(P);let C=I?.audio?.find(B=>B?.id===Kk);b=!0,A=C?structuredClone(C):null,k=structuredClone(S?.bgmPresentation??null),E=structuredClone(S?.bgmResources??null);let _=new Map;hu(I?.animations).forEach(B=>{let z=fs(B);if(!z)return;let J=S?.persistentAnimationSessions?.get(z)??d.get(z),ce=Math.max(0,wu(B)),he=J?.startedAt??S?.builtAt??Date.now();_.set(z,{animation:structuredClone(B),startedAt:he,expiresAt:he+ce})}),d=_,S?.usedRestoredPersistentAnimationSessions&&(f=new Map),S?.activeAudioEffectIds?.length>0&&!S.retainsActiveAudioEffects&&y.length===S.activeAudioEffectIds.length&&S.activeAudioEffectIds.every(B=>y.some(z=>z.id===B))&&(y=[])},am=()=>n.selectSystemState(),lm=()=>n.selectAchievements(),cm=I=>n.selectAchievement(I),ll=()=>n.selectSaveSlotMap(),um=I=>n.selectSaveSlot(I),pm=I=>n.selectSaveSlotPage(I),fm=()=>n.selectImageGallery(),dm=()=>n.selectMusicRoom(),mm=()=>n.selectSceneReplay(),ym=()=>n.selectIsSceneReplayActive(),fA=()=>n.selectSkipMode(),dA=()=>n.selectAutoMode(),hm=()=>n.selectRuntime(),gm=()=>n.selectIsChoiceVisible(),bm=()=>n.selectIsFormVisible(),wm=()=>n.selectActiveInteraction(),Im=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),cl=(I,P,S={})=>!Ue(P)||I!=="nextLine"?P:S.bypassChoice===!0?{...P,bypassChoice:!0}:S.interactionSource===nl?{...P,_interactionSource:nl}:P,ul=(I={})=>({type:sl,payload:cl("nextLine",{_conditionalContinuation:!0},I)}),Di=(I,P)=>On(I)?{type:sl,payload:{...I.payload,...P.payload}}:P,vm=I=>{I.savedCheckpointOccurrences.forEach(P=>{n.markSavedRollbackCheckpointTransient(P)}),I.savedCheckpointOccurrences=[]},km=(I,P)=>{let S=p;return p=null,!S||!lt(S.pointer,I)||S.checkpointIndex!==P?.checkpointIndex||S.checkpointIdentity!==P?.checkpoint?[]:S.savedCheckpointOccurrences},Am=I=>{let P=m;return!P||!lt(P.pointer,I)?null:(m=null,P)},Pm=({actionType:I,pointerBeforeAction:P,pointerAfterAction:S,cursorBeforeAction:C,cursorAfterAction:_,wasSceneReplayActive:B,isSceneReplayActive:z})=>{!S||!(!lt(P,S)||C?.checkpoint!==_?.checkpoint||C?.checkpointIndex!==_?.checkpointIndex||I==="jumpToLine")||(m={pointer:S,appendToPrevious:Uk.has(I)&&B===z&&P?.sectionId===S.sectionId&&P?.lineId!==S.lineId,reuseExistingOccurrence:Yk.has(I),forceNewOccurrence:I==="jumpToLine"})},pl=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),vm(I))},Em=(I,P,S)=>Fk.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==P?.checkpoint:S?.checkpoint!==P?.checkpoint&&S?.checkpointIndex>P?.checkpointIndex:!1,xm=I=>{let P=u.at(-1);if(!P?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&P.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:P.rollbackCursor?.checkpointIndex,sectionId:P.pointer?.sectionId,lineId:P.pointer?.lineId})},Sm=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(P=>{let S=n.selectSaveSlot({slotId:P.slotId});S&&(P.saveSlotIdentity=S)})},Om=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},Rm=(I,P,S)=>{let C=u.at(-1);if(!C)return;let _=n.selectCurrentPointer()?.pointer,B=Em(I,P,S);if(lt(C.pointer,_)){let z=S?.checkpoint!==P?.checkpoint||S?.checkpointIndex!==P?.checkpointIndex;B||z&&Bk.has(I)?(pl(C),C.pointer=_,C.rollbackCursor=S,C.markCurrentCheckpointTransient=B,C.savedCheckpointOccurrences=[]):z&&I==="updateProjectData"&&(C.rollbackCursor=S);return}pl(C),C.pointer=_,C.rollbackCursor=n.selectRollbackCursor?.()??null,C.markCurrentCheckpointTransient=B,C.savedCheckpointOccurrences=[]},ft=(I,P)=>{if(ue(`action "${I}"`),!n[I])return;let S=P,C,_;if(I==="updateProjectData")fl(P),C=structuredClone(P.projectData),S={...P,projectData:Ni({projectData:C,l10nData:R,l10nId:T})},fl(S);else if(I==="updateLocalizationPackage"){if(_=Cm(P),_===T)return;S={l10nId:_,projectData:Ni({projectData:L,l10nData:R,l10nId:_})}}qk.has(I)&&(c+=1);let B=n.selectAutoMode(),z=B?n.selectRuntime():null,J=n.selectIsSceneReplayActive?.()===!0,ce=Vk.has(I)?ve(d):null,he=n.selectCurrentPointer()?.pointer??null,be=n.selectRollbackCursor?.()??null,ke=ts(I),Oe=ke?n.selectPlaybackLineEntryId?.()??0:null,Ye=ke?Yr():null,je=ke?pt():null,Te=ke?zr():null,Re=!1,dt;try{dt=n[I](S),Re=!0}catch(Lt){throw Q(Lt,"preCommit"),Lt}C!==void 0&&(L=C),_!==void 0&&(T=_),Mk.has(I)&&(f=ce??new Map,d=new Map,y=[]),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=[]);let bl=n.selectIsSceneReplayActive?.()===!0;J!==bl&&(d=new Map,f=new Map);let Ym=n.selectCurrentPointer()?.pointer??null,wl=n.selectRollbackCursor?.()??null,Il=ke?n.selectPlaybackLineEntryId?.()??0:null;ke&&Il!==Oe&&(v={lineEntryId:Il,channel:Ye,presentation:je,resources:Te}),I==="saveSlot"?xm(P):I==="updateProjectData"&&Sm(),Rm(I,be,wl),Pm({actionType:I,pointerBeforeAction:he,pointerAfterAction:Ym,cursorBeforeAction:be,cursorAfterAction:wl,wasSceneReplayActive:J,isSceneReplayActive:bl});let zm=n.selectAutoMode()&&(I==="updateVariable"||B&&Zk(z,n.selectRuntime()));(Jk.has(I)||zm)&&(U=!0);try{gr()}catch(Lt){throw Re&&Q(Lt,"postCommitUnsettled"),Lt}return dt},fl=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Qr(I?.projectData?.resources?.variables??{}),Yt(I.projectData),zt(I.projectData),Xt(I.projectData)},Cm=I=>{if(!Ue(I))throw new Error("updateLocalizationPackage requires an object payload");let P=Object.keys(I);if(P.length!==1||P[0]!=="l10nId")throw new Error("updateLocalizationPackage only accepts l10nId");if(I.l10nId!==null&&(typeof I.l10nId!="string"||I.l10nId.length===0))throw new Error("updateLocalizationPackage requires a non-empty l10nId or null");return I.l10nId},$m=(I,P,S)=>{let C=n.selectCurrentPointer()?.pointer;P!==C||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),ft("nextLineFromSystem",I.payload))},_m=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(f),renderPersistentAnimationMetadata:new Map(h),audioEffectOccurrenceSequence:g,activeAudioEffects:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:v?structuredClone(v):null,acceptedLineBgmActionOccurrences:new Map(O),canonicalProjectData:L,localizationPackageId:T,playbackScheduleDirty:U}),Nm=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,m=I.pendingDialogueHistoryLineEntry,d=new Map(I.persistentAnimationSessions),f=new Map(I.restoredPersistentAnimationSessions),h=new Map(I.renderPersistentAnimationMetadata),g=I.audioEffectOccurrenceSequence,y=I.activeAudioEffects,w=I.pendingAudioEffectOccurrences.slice(),v=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,O=new Map(I.acceptedLineBgmActionOccurrences),L=I.canonicalProjectData,T=I.localizationPackageId,U=I.playbackScheduleDirty},Li=(I,P={})=>(ue("action batch"),Ze(()=>{let S=_m();try{return n[po](()=>{let C,_=n.selectCurrentPointer()?.pointer??null,B=n.selectRollbackCursor?.()??null,z=c,J={pointer:_,rollbackCursor:B,markCurrentCheckpointTransient:P.rollbackSource==="line",savedCheckpointOccurrences:P.savedCheckpointOccurrences?.slice()??[]};u.push(J);try{n.beginRollbackActionBatch({source:P.rollbackSource});try{C=I()}finally{n.endRollbackActionBatch({})}On(C)&&$m(C,_,z),Tt();let ce=n.selectCurrentPointer()?.pointer??null;P.rollbackSource==="line"&&lt(_,ce)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:J.savedCheckpointOccurrences,appendToPrevious:P.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:P.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:P.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!lt(_,J.pointer)||B?.checkpoint!==J.rollbackCursor?.checkpoint)&&J.markCurrentCheckpointTransient&&J.savedCheckpointOccurrences.length>0&&(p={pointer:J.pointer,checkpointIndex:J.rollbackCursor?.checkpointIndex,checkpointIdentity:J.rollbackCursor?.checkpoint,savedCheckpointOccurrences:J.savedCheckpointOccurrences})}})}catch(C){throw Nm(S),C}})),Mi=(I,P,S,C={})=>{if(I===tl||I===Sn)return Li(()=>{let _={...C,executionContext:C.executionContext??{depth:0,pendingNavigation:null},actionPath:C.actionPath??[I],randomOutcomeOrdinals:C.randomOutcomeOrdinals??new Map};if(I===Sn)return yl(P,S,_);let B=Vi(S),z=Wt({[I]:P},B);return ml(z[I],S,_)},C);if(I==="bgm")return Li(()=>{let _=pt(),B=jt(P),z=B?Yr():null,J=B?zr():null;ft(I,P);let ce=Sr();Dt(P,{...C,actionPath:C.actionPath??[I]},z,B?ct():null,_,ce,J)},C);ft(I,P)},jm=(I,P)=>{if(I!=="nextLineFromSystem")return Mi(I,P);H+=1;try{return Mi(I,P)}finally{H=Math.max(0,H-1)}},dl=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Vi=I=>{if(dl(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:P,...S}=I,C=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:P,variables:C,runtime:n.selectRuntime?n.selectRuntime():{}}},Tm=I=>{if(!Ue(I))return{templatePayload:I,literalTargetIds:null};let P=n.selectImageGalleryConfig();if(!Array.isArray(P?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?P.groups.find(_=>_.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let C=typeof I.variantId=="string"&&S.variants.some(_=>_.id===I.variantId);return{templatePayload:{...I,groupId:null,...C?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...C?{variantId:I.variantId}:{}}}},Dm=I=>!Ue(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(C=>C.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Lm=I=>!Ue(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(C=>C.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},Mm=I=>{if(!Ue(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},Vm=(I,P,S)=>{if(!Ue(I))throw new Error(`conditional branch at index ${P} must be an object`);if(!Ue(I.actions))throw new Error(`conditional branch at index ${P} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&P!==S-1)throw new Error("conditional else branch must be the last branch")},ml=(I,P,S)=>{Mm(I);let C=ul(S);for(let _=0;_<I.branches.length;_+=1){let B=I.branches[_];Vm(B,_,I.branches.length);let z=Vi(P);if(Object.prototype.hasOwnProperty.call(B,"when")&&!Ut(B.when,z))continue;let ce=$n(B.actions,P,{...S,actionPath:[...S.actionPath??[tl],"branches",String(_),"actions"]});return On(ce)?Di(C,ce):C}return C},qm=I=>{if(!Ue(I))throw new Error("random action payload must be an object");let P=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(P!==void 0)throw new Error(`random action.${P} is not supported`);if(!Ue(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=L?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||$e(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},yl=(I,P,S)=>{qm(I),dl(P);let C=gc(I.distribution,{randomSource:M});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let z=(S.actionPath??[Sn]).join("."),J=S.randomOutcomeOrdinals??new Map,ce=J.get(z)??0;J.set(z,ce+1),n.recordRandomOutcome({path:z,ordinal:ce,type:C.type,result:C}),Om()}let _;C.type==="integer"?ft("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:C.value}]}):_=$n(I.distribution.outcomes[C.outcomeIndex].actions,P,{...S,actionPath:[...S.actionPath??[Sn],"distribution","outcomes",String(C.outcomeIndex),"actions"]});let B=ul(S);return On(_)?Di(B,_):B},Fm=(I,P)=>({...I??{},_form:P}),Bm=(I,P,S,C)=>{let _=ft(I,P),B=_?.submitted===!0&&_.valid===!0,z=_?.cancelled===!0;if(!(!B&&!z)&&Ue(P.actions))return $n(P.actions,Fm(S,_.form),{...C,interactionSource:nl})},hl=(I,P,S,C)=>{if(I===Sn)return yl(P,S,C);let _=Vi(S),B={templatePayload:P,literalTargetIds:null};I===Xk?B=Tm(P):I===Hk?B=Dm(P):I===Gk&&(B=Lm(P));let{templatePayload:z,literalTargetIds:J}=B,he=Wt({[I]:z},_)[I],be=J?{...he,...J}:he;if(I===tl)return ml(be,S,C);let ke=cl(I,be,C);if(zk.has(I))return Bm(I,ke,S,C);let Oe=null,Ye=null,je=null,Te=!1;if(I==="bgm"){let Re=C.audioEffectHandoff,dt=Re?.available?Re.presentation:pt();Te=jt(ke),Te&&Re?.available?(Re.available=!1,Oe=structuredClone(Re.channel),Ye=structuredClone(Re.presentation),je=structuredClone(Re.resources)):Te&&(Oe=Yr(),Ye=dt,je=zr())}if(ft(I,ke),I==="bgm"){let Re=Sr();Dt(ke,C,Oe,Te?ct():null,Ye,Re,je)}},$n=(I,P,S)=>{let C,_=S?.executionContext??{depth:0,pendingNavigation:null},B=rs(I);ns(B),_.depth+=1;try{for(let[z,J]of B){let ce={...S,executionContext:_,actionPath:[...S?.actionPath??[],z]};if(ts(z)){let be=_.pendingNavigation;if(be)throw new Error(`action batch cannot execute multiple navigation actions: ${be.actionType}, ${z}`);_.pendingNavigation={actionType:z,payload:J,eventContext:P,options:ce};continue}let he=hl(z,J,P,ce);On(he)&&(C=Di(C,he))}}finally{_.depth-=1}if(_.depth===0&&_.pendingNavigation){let z=_.pendingNavigation;_.pendingNavigation=null,hl(z.actionType,z.payload,z.eventContext,z.options)}return C},gl=(I,P,S={})=>{let C={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Li(()=>$n(I,P,C),C)},Um=I=>{let P=n.selectCurrentPointer()?.pointer;if(I!==P||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:Ti,dispose:Cn,handleAction:Mi,handleInternalAction:jm,handleActions:gl,selectRenderState:sm,prepareRenderState:im,commitRenderState:om,selectPresentationState:rm,selectPresentationChanges:tm,selectSectionLineChanges:nm,selectSystemState:am,selectAchievements:lm,selectAchievement:cm,selectSaveSlotMap:ll,selectSaveSlot:um,selectSaveSlotPage:pm,selectSaveSlots:ll,selectImageGallery:fm,selectMusicRoom:dm,selectSceneReplay:mm,selectIsSceneReplayActive:ym,selectRuntime:hm,selectIsChoiceVisible:gm,selectIsFormVisible:bm,selectActiveInteraction:wm,selectHasPendingRenderWork:Im,handleLineActions:I=>{ue("line action handling");let P=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!lt(I.pointer,P))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return Ze(()=>{let S=n.selectCurrentPointer()?.pointer,C=n.selectPlaybackLineEntryId?.()??0,_=v?.lineEntryId===C?v:null,B=_?{available:!0,channel:structuredClone(_.channel),presentation:structuredClone(_.presentation),resources:structuredClone(_.resources)}:null,z=n.selectRollbackCursor?.()??null,J=p,ce=m,he=km(S,z),be=Am(S),ke=n.selectCurrentLine(),Oe=!1;if(ke?.actions){try{gl(ke.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:he,dialogueHistoryAppendToPrevious:be?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:be?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:be?.forceNewOccurrence===!0,audioEffectHandoff:B})}catch(Ye){throw p=J,m=ce,Ye}Oe=!0}return v?.lineEntryId===C&&(v=null),Um(S),Oe})},getNamespace:em,classifyAutomaticAttemptError:$}}var eA="music-room:player",Qd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Wd=(e,t)=>Qd.has(e)&&t?._event?.id===eA,Zd=({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(r)??e.selectRenderState(r);n?.(s),t.render(s),a(o)&&e.commitRenderState?.(s)},rA=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&Zd({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},tA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},nA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},sA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},iA=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},oA=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},Jd={render:Zd,saveSlots:tA,saveGlobalDeviceVariables:nA,saveGlobalAccountVariables:sA,saveGlobalRuntime:iA,applyScopedDataUpdates:oA,handleLineActions:rA},aA=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),ol=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},lA=(e=[])=>{let t=new Set,n=[];for(let o=e.length-1;o>=0;o-=1){let a=e[o];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!aA.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},cA=({getEngine:e,routeGraphics:t,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:r,persistence:s,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,m=!1,d=0,f=0,h=!0,g=Gd({ticker:n,dispatchAutomaticAttempt:()=>ol(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:$=>e()?.classifyAutomaticAttemptError?.($)??"preCommit"}),y=()=>{u=null,p=null,m=!1,d=0},w=()=>{g.reset(),f+=1,y(),h=!0},b=()=>{f+=1,h=!1,y(),g.dispose()},A=$=>h&&$===f,k=$=>{if(a){a($);return}console.error("RouteEngine persistence write failed.",$)},E=$=>{if(s)return s;let j=$t($),F=l.get(j);if(F)return F;let W=Xa({indexedDB:r,namespace:j});return l.set(j,W),W},v=$=>{let j=s?null:$t(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=E(j),$(F))).catch(W=>{!s&&l.get(j)===F&&l.delete(j),k(W)})},O=$=>{if(!h)return;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;d+=1,u=j,m=!1},L=()=>d,R=($={})=>{if(!h||$?.aborted===!0)return!1;let j=typeof $?.id=="string"&&$.id.length>0?$.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||m?!1:(m=!0,!0)},T=($,j={})=>{if(!h)return!1;if(Wd($,j)){let W=Qd.get($),de=e();return ol(de,W,j?._event),!0}if($!=="renderComplete"||!R(j))return!1;let F=e();return ol(F,"markLineCompleted",{}),!0},U=new Set(["updateFormField","submitForm","cancelForm"]),N=new Set(["updateVariable"]),H=$=>typeof $?.selectActiveInteraction=="function"?$.selectActiveInteraction():typeof $?.selectIsChoiceVisible=="function"&&$.selectIsChoiceVisible()?{source:"choice"}:null,fe=$=>$?._formKey??$?.formKey,M=($,j)=>fe($)===j?.formKey,K=($,j)=>!$||typeof $!="object"||Array.isArray($)?!1:$._interactionSource===j?.source,le=($,j)=>K($,j)?j.source==="form"?M($,j):!0:!1,X=($,j)=>!$||typeof $!="object"||Array.isArray($)||j?.source!=="form"?!1:M($,j),te=($={},j)=>Object.keys($).length>0&&Object.entries($).every(([F,W])=>U.has(F)?X(W,j):N.has(F)),oe=($={},j)=>{let F=$?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:te(F,j):le($,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(W=>le(W,j))},se=($,j={})=>{if(!j?.actions)return!1;let F=H($);return!F||F.source==="choice"?!1:!oe(j,F)},ue=({preprocessPayload:$,onEvent:j}={})=>async(F,W={})=>{if(!h)return!1;if(Wd(F,W))return T(F,W),j?.(F,W);let de=e(),ve=f,Ie=d;if(se(de,W))return j?.(F,W);let me=await $?.(F,W)??W;if(!A(ve)||e()!==de||d!==Ie)return!1;if(se(de,me))return j?.(F,me);if(T(F,me),me?.actions){let gr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,Ze;me?.bypassChoice===!0?Ze={bypassChoice:!0}:me?._interactionSource&&(Ze={interactionSource:me._interactionSource}),Ze?de.handleActions(me.actions,gr,Ze):de.handleActions(me.actions,gr)}return j?.(F,me)},Q=$=>{if(!h)return;let j=f,F=e(),W=lA($),de=W.some(Ie=>Ie.name==="handleLineActions");W.forEach(Ie=>{if(!Jd[Ie.name]&&!xn.has(Ie.name)&&!o)throw new Error(`Unhandled pending effect "${Ie.name}".`)});let ve={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:L,enqueuePersistenceWrite:v,lifecycleGeneration:f,isCurrentLifecycle:A};for(let Ie of W){if(!A(j))break;if(de&&Ie.name==="render")continue;if(xn.has(Ie.name)){g.handleLegacyEffect(Ie);continue}let me=Jd[Ie.name];if(me){me(ve,Ie.payload);continue}o(Ie,ve)}};return Q.handleRouteGraphicsEvent=T,Q.createRouteGraphicsEventHandler=ue,Q.reset=w,Q.dispose=b,Q.reconcilePlaybackScheduleV1=$=>g.reconcilePlaybackScheduleV1($),Q},uA=cA;var pA=(e,t={})=>{let{resources:n={}}=t;return Ko(e,n)};var I1=il;export{Ro as DEFAULT_VISUAL_LAYER,It as RENDER_LAYER,wr as VISUAL_LAYER,uA as createEffectsHandler,Vv as createIndexedDbPersistence,I1 as default,mo as formatDate,hh as resolveComputedVariables,pA as resolveLayoutReferences};