route-engine-js 1.40.0 → 1.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteEngine.js +6 -2
- package/package.json +2 -2
package/dist/RouteEngine.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
var pf=Object.defineProperty;var df=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),ff=(e,r)=>{for(var n in r)pf(e,n,{get:r[n],enumerable:!0})};var ip=df(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});function op(e){let r=e.length,n=0,o=0,a;for(;o<r;)n++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<r&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return n}ea.default=op;op.code='require("ajv/dist/runtime/ucs2length").default'});var Sa=Symbol.for("immer-nothing"),va=Symbol.for("immer-draftable"),Ce=Symbol.for("immer-state");function Me(e,...r){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var Wr=Object.getPrototypeOf;function we(e){return!!e&&!!e[Ce]}function $r(e){return e?Oa(e)||Array.isArray(e)||!!e[va]||!!e.constructor?.[va]||hn(e)||gn(e):!1}var mf=Object.prototype.constructor.toString();function Oa(e){if(!e||typeof e!="object")return!1;let r=Wr(e);if(r===null)return!0;let n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===mf}function mn(e){return we(e)||Me(15,e),e[Ce].base_}function pn(e,r){yn(e)===0?Reflect.ownKeys(e).forEach(n=>{r(n,e[n],e)}):e.forEach((n,o)=>r(o,n,e))}function yn(e){let r=e[Ce];return r?r.type_:Array.isArray(e)?1:hn(e)?2:gn(e)?3:0}function ro(e,r){return yn(e)===2?e.has(r):Object.prototype.hasOwnProperty.call(e,r)}function Ra(e,r,n){let o=yn(e);o===2?e.set(r,n):o===3?e.add(n):e[r]=n}function yf(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r}function hn(e){return e instanceof Map}function gn(e){return e instanceof Set}function Cr(e){return e.copy_||e.base_}function to(e,r){if(hn(e))return new Map(e);if(gn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=Oa(e);if(r===!0||r==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Ce];let a=Reflect.ownKeys(o);for(let t=0;t<a.length;t++){let s=a[t],i=o[s];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[s]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[s]})}return Object.create(Wr(e),o)}else{let o=Wr(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function ao(e,r=!1){return bn(e)||we(e)||!$r(e)||(yn(e)>1&&(e.set=e.add=e.clear=e.delete=hf),Object.freeze(e),r&&Object.entries(e).forEach(([n,o])=>ao(o,!0))),e}function hf(){Me(2)}function bn(e){return Object.isFrozen(e)}var gf={};function _r(e){let r=gf[e];return r||Me(0,e),r}var It;function Ca(){return It}function bf(e,r){return{drafts_:[],parent_:e,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Aa(e,r){r&&(_r("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=r)}function no(e){so(e),e.drafts_.forEach(If),e.drafts_=null}function so(e){e===It&&(It=e.parent_)}function Pa(e){return It=bf(It,e)}function If(e){let r=e[Ce];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function xa(e,r){r.unfinalizedDrafts_=r.drafts_.length;let n=r.drafts_[0];return e!==void 0&&e!==n?(n[Ce].modified_&&(no(r),Me(4)),$r(e)&&(e=dn(r,e),r.parent_||fn(r,e)),r.patches_&&_r("Patches").generateReplacementPatches_(n[Ce].base_,e,r.patches_,r.inversePatches_)):e=dn(r,n,[]),no(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),e!==Sa?e:void 0}function dn(e,r,n){if(bn(r))return r;let o=r[Ce];if(!o)return pn(r,(a,t)=>Ea(e,o,r,a,t,n)),r;if(o.scope_!==e)return r;if(!o.modified_)return fn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,t=a,s=!1;o.type_===3&&(t=new Set(a),a.clear(),s=!0),pn(t,(i,l)=>Ea(e,o,a,i,l,n,s)),fn(e,a,!1),n&&e.patches_&&_r("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function Ea(e,r,n,o,a,t,s){if(we(a)){let i=t&&r&&r.type_!==3&&!ro(r.assigned_,o)?t.concat(o):void 0,l=dn(e,a,i);if(Ra(n,o,l),we(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if($r(a)&&!bn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;dn(e,a),(!r||!r.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&fn(e,a)}}function fn(e,r,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&ao(r,n)}function wf(e,r){let n=Array.isArray(e),o={type_:n?1:0,scope_:r?r.scope_:Ca(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,t=lo;n&&(a=[o],t=wt);let{revoke:s,proxy:i}=Proxy.revocable(a,t);return o.draft_=i,o.revoke_=s,i}var lo={get(e,r){if(r===Ce)return e;let n=Cr(e);if(!ro(n,r))return kf(e,n,r);let o=n[r];return e.finalized_||!$r(o)?o:o===Zs(e.base_,r)?(eo(e),e.copy_[r]=io(o,e)):o},has(e,r){return r in Cr(e)},ownKeys(e){return Reflect.ownKeys(Cr(e))},set(e,r,n){let o=$a(Cr(e),r);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=Zs(Cr(e),r),t=a?.[Ce];if(t&&t.base_===n)return e.copy_[r]=n,e.assigned_[r]=!1,!0;if(yf(n,a)&&(n!==void 0||ro(e.base_,r)))return!0;eo(e),oo(e)}return e.copy_[r]===n&&(n!==void 0||r in e.copy_)||Number.isNaN(n)&&Number.isNaN(e.copy_[r])||(e.copy_[r]=n,e.assigned_[r]=!0),!0},deleteProperty(e,r){return Zs(e.base_,r)!==void 0||r in e.base_?(e.assigned_[r]=!1,eo(e),oo(e)):delete e.assigned_[r],e.copy_&&delete e.copy_[r],!0},getOwnPropertyDescriptor(e,r){let n=Cr(e),o=Reflect.getOwnPropertyDescriptor(n,r);return o&&{writable:!0,configurable:e.type_!==1||r!=="length",enumerable:o.enumerable,value:n[r]}},defineProperty(){Me(11)},getPrototypeOf(e){return Wr(e.base_)},setPrototypeOf(){Me(12)}},wt={};pn(lo,(e,r)=>{wt[e]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}});wt.deleteProperty=function(e,r){return wt.set.call(this,e,r,void 0)};wt.set=function(e,r,n){return lo.set.call(this,e[0],r,n,e[0])};function Zs(e,r){let n=e[Ce];return(n?Cr(n):e)[r]}function kf(e,r,n){let o=$a(r,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function $a(e,r){if(!(r in e))return;let n=Wr(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,r);if(o)return o;n=Wr(n)}}function oo(e){e.modified_||(e.modified_=!0,e.parent_&&oo(e.parent_))}function eo(e){e.copy_||(e.copy_=to(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var vf=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,o)=>{if(typeof r=="function"&&typeof n!="function"){let t=n;n=r;let s=this;return function(l=t,...c){return s.produce(l,u=>n.call(this,u,...c))}}typeof n!="function"&&Me(6),o!==void 0&&typeof o!="function"&&Me(7);let a;if($r(r)){let t=Pa(this),s=io(r,void 0),i=!0;try{a=n(s),i=!1}finally{i?no(t):so(t)}return Aa(t,o),xa(a,t)}else if(!r||typeof r!="object"){if(a=n(r),a===void 0&&(a=r),a===Sa&&(a=void 0),this.autoFreeze_&&ao(a,!0),o){let t=[],s=[];_r("Patches").generateReplacementPatches_(r,a,t,s),o(t,s)}return a}else Me(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(s,...i)=>this.produceWithPatches(s,l=>r(l,...i));let o,a;return[this.produce(r,n,(s,i)=>{o=s,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){$r(e)||Me(8),we(e)&&(e=pr(e));let r=Pa(this),n=io(e,void 0);return n[Ce].isManual_=!0,so(r),n}finishDraft(e,r){let n=e&&e[Ce];(!n||!n.isManual_)&&Me(9);let{scope_:o}=n;return Aa(o,r),xa(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,r){let n;for(n=r.length-1;n>=0;n--){let a=r[n];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}n>-1&&(r=r.slice(n+1));let o=_r("Patches").applyPatches_;return we(e)?o(e,r):this.produce(e,a=>o(a,r))}};function io(e,r){let n=hn(e)?_r("MapSet").proxyMap_(e,r):gn(e)?_r("MapSet").proxySet_(e,r):wf(e,r);return(r?r.scope_:Ca()).drafts_.push(n),n}function pr(e){return we(e)||Me(10,e),_a(e)}function _a(e){if(!$r(e)||bn(e))return e;let r=e[Ce],n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=to(e,r.scope_.immer_.useStrictShallowCopy_)}else n=to(e,!0);return pn(n,(o,a)=>{Ra(n,o,_a(a))}),r&&(r.finalized_=!1),n}var _e=new vf,In=_e.produce,wk=_e.produceWithPatches.bind(_e),kk=_e.setAutoFreeze.bind(_e),vk=_e.setUseStrictShallowCopy.bind(_e),Ak=_e.applyPatches.bind(_e),Pk=_e.createDraft.bind(_e),xk=_e.finishDraft.bind(_e);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},J={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},Kr={NOT:0};var j=class extends Error{constructor(r){super(`Parse Error: ${r}`),this.name="JemplParseError"}},Oe=class extends Error{constructor(r){super(`Render Error: ${r}`),this.name="JemplRenderError"}};var co=e=>{if(!e||e.trim()==="")throw new j("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let n=e.includes("===")?"==":"!=";throw new j(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${n}'? (got: '${e}')`)}let r=["<",">","<=",">=","==","!="];for(let n of r)if(e.trim().endsWith(n))throw new j(`Incomplete comparison expression - missing right operand (got: '${e}')`)},Ta=e=>{if(e.trim().endsWith(" in"))throw new j(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new j(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[r,n]=e.split(" in ");if(!n||n.trim()==="")throw new j(`Missing iterable expression after 'in' (got: '$for ${e}')`);let o=r.includes(",")?r.split(",").map(a=>a.trim()):[r.trim()];for(let a of o){if(!a)throw new j(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new j(`Invalid loop syntax (got: '$for ${e}')`)}};var Na=(e,r,n=!1)=>{if(r===null)return new Oe(`Cannot iterate over null value at '$for ${e}'`);if(r===void 0)return new Oe(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof r;return n?new Oe(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Oe(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},ja=(e,r)=>{let n=r&&Object.keys(r).length>0?Object.keys(r).join(", "):"no custom functions provided";return new Oe(`Unknown function '${e}' (${n})`)};var Af=(e,r,n={})=>{let o={},a={};n&&typeof n=="object"&&(n.functions!==void 0||n.partials!==void 0?(o=n.functions||{},a=n.partials||{}):typeof n=="object"&&(o=n));let s=ee(e,{functions:o,partials:a},r,{});return s===void 0?{}:s},ee=(e,r,n,o)=>{let a=r.functions||r;if(e.var&&!e.type)return be(e.var,n,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return be(e.path,n,o);if(e.type===x.INTERPOLATION)return xf(e.parts,r,n,o);switch(e.type){case x.FUNCTION:return La(e,r,n,o);case x.BINARY:return Ma(e,r,n,o);case x.UNARY:return Va(e,r,n,o);case x.CONDITIONAL:return Sf(e,r,n,o);case x.LOOP:return _f(e,r,n,o);case x.OBJECT:return Nf(e,r,n,o);case x.ARRAY:return jf(e,r,n,o);case x.PARTIAL:return Df(e,r,n,o);case x.PATH_REFERENCE:return Lf(e,r,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Da=new Map,Pf=e=>{let r=[],n="",o=!1;for(let a=0;a<e.length;a++){let t=e[a];if(t==="[")n&&(r.push({type:"property",value:n}),n=""),o=!0;else if(t==="]"){if(o&&n){let s=n.trim();if(/^\d+$/.test(s))r.push({type:"index",value:parseInt(s,10)});else if(s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")){let i=s.slice(1,-1);r.push({type:"property",value:i})}else r.push({type:"property",value:s});n=""}o=!1}else n+=t}return n&&r.push({type:"property",value:n}),r},be=(e,r,n)=>{if(!e)return;if(e in n)return n[e];let o=Da.get(e);if(!o){let t=[],s="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,s+=c):c==="]"?(i--,s+=c):c==="."&&i===0?s&&(t.push(s),s=""):s+=c}s&&t.push(s),o=[];for(let l of t){let c=Pf(l.trim());o.push(...c)}Da.set(e,o)}let a=r;for(let t=0;t<o.length;t++){let s=o[t];if(s.type==="property"&&s.value in n){a=n[s.value];continue}if(a==null)return;(s.type==="property"||s.type==="index")&&(a=a[s.value])}return a},xf=(e,r,n,o)=>{let a=[];for(let t of e)if(typeof t=="string")a.push(t);else{let s=ee(t,r,n,o);a.push(s!=null?String(s):"")}return a.join("")},La=(e,r,n,o)=>{let a=r.functions||r,t=a[e.name];if(!t)throw ja(e.name,a);let s=e.args.map(i=>ee(i,r,n,o));return t(...s)},dr=(e,r,n,o)=>{if(e.var&&!e.type)return be(e.var,n,o);switch(e.type){case x.VARIABLE:return be(e.path,n,o);case x.LITERAL:return e.value;case x.BINARY:return Ma(e,r,n,o);case x.UNARY:return Va(e,r,n,o);case x.FUNCTION:return La(e,r,n,o);default:return ee(e,r,n,o)}},Ma=(e,r,n,o)=>{if(e.op===J.AND||e.op===J.OR){let s=dr(e.left,r,n,o),i=dr(e.right,r,n,o);switch(e.op){case J.AND:return s&&i;case J.OR:return s||i}}let a=ee(e.left,r,n,o),t=ee(e.right,r,n,o);switch(e.op){case J.EQ:return a==t;case J.NEQ:return a!=t;case J.GT:return a>t;case J.LT:return a<t;case J.GTE:return a>=t;case J.LTE:return a<=t;case J.IN:return Array.isArray(t)?t.includes(a):!1;case J.ADD:if(typeof a!="number"||typeof t!="number")throw new Oe(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof t}`);return a+t;case J.SUBTRACT:if(typeof a!="number"||typeof t!="number")throw new Oe(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof t}`);return a-t;default:throw new Error(`Unknown binary operator: ${e.op}`)}},Va=(e,r,n,o)=>{let a=e.op===Kr.NOT?dr(e.operand,r,n,o):ee(e.operand,r,n,o);if(e.op===Kr.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Ef=(e,r,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(be(a.path,n,o)){let s=e.bodies[0];if(s.type===x.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?ee(l.parsedKey,r,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=be(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let f of u.parts)if(typeof f=="string")p.push(f);else if(f.type===x.VARIABLE){let d=be(f.path,n,o);p.push(d!=null?String(d):"")}else{let d=ee(f,r,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=ee(u,r,n,o)}return i}}else{let s=e.bodies[1];if(s.type===x.OBJECT&&s.properties.length<=5){let i={};for(let l of s.properties){let c=l.parsedKey?ee(l.parsedKey,r,n,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=be(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let f of u.parts)if(typeof f=="string")p.push(f);else if(f.type===x.VARIABLE){let d=be(f.path,n,o);p.push(d!=null?String(d):"")}else{let d=ee(f,r,n,o);p.push(d!=null?String(d):"")}i[c]=p.join("")}else i[c]=ee(u,r,n,o)}return i}}}return null},Sf=(e,r,n,o)=>{let a=Ef(e,r,n,o);if(a!==null)return a;for(let t=0;t<e.conditions.length;t++){let s=e.conditions[t];if(s===null||dr(s,r,n,o))return ee(e.bodies[t],r,n,o)}return qa},Of=(e,r)=>{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,t=n.bodies[0];if(a.startsWith(o+".")){let s=a.substring(o.length+1);if(t.type===x.OBJECT&&t.properties.length<=5){for(let l of t.properties)if(l.parsedKey)return null;let i=[];for(let l=0;l<r.length;l++){let c=r[l];if(c[s]){let u={};for(let p of t.properties){let f=p.key,d=p.value;if(d.type===x.LITERAL)u[f]=d.value;else if(d.type===x.VARIABLE){let m=d.path;if(m===o)u[f]=c;else if(m.startsWith(o+".")){let y=m.substring(o.length+1);u[f]=c[y]}else return null}else if(d.type===x.INTERPOLATION){let m=[],y=!0;for(let g of d.parts)if(typeof g=="string")m.push(g);else if(g.type===x.VARIABLE){let h=g.path;if(h===o)m.push(c!=null?String(c):"");else if(h.startsWith(o+".")){let w=h.substring(o.length+1),b=c[w];m.push(b!=null?String(b):"")}else{y=!1;break}}else{y=!1;break}if(!y)return null;u[f]=m.join("")}else return null}i.push(u)}}return i}}}return null},Rf=(e,r)=>{let n=e.body,o=e.itemVar,a=Of(e,r);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 t=[],s=!0;for(let i of n.properties){let l=i.key,c=i.value;if(c.type===x.LITERAL)t.push({key:l,type:"literal",value:c.value});else if(c.type===x.VARIABLE){let u=c.path;if(u===o)t.push({key:l,type:"item"});else if(u.startsWith(o+".")){let p=u.substring(o.length+1);if(!p.includes(".")&&!p.includes("["))t.push({key:l,type:"prop",prop:p});else{s=!1;break}}else{s=!1;break}}else if(c.type===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===o)t.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let f=p.substring(o.length+1);if(!f.includes(".")&&!f.includes("["))t.push({key:l,type:"prop_string",prop:f});else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}else{s=!1;break}}if(s){let i=new Array(r.length);if(t.length===3&&t[0].type==="prop"&&t[0].key==="id"&&t[1].type==="prop_string"&&t[1].key==="title"&&t[2].type==="prop"&&t[2].key==="completed")for(let l=0;l<r.length;l++){let c=r[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<r.length;l++){let c=r[l],u={};for(let p of t)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let f=c[p.prop];u[p.key]=f!=null?String(f):""}i[l]=u}return i}}return null},Cf=(e,r,n,o,a)=>{let t=[],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={},f={...o,[i]:u,...l&&{[l]:c}};f.__paths__||(f.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let m=d.split("."),y=m[0];y in o.__paths__&&(d=o.__paths__[y],m.length>1&&(d+="."+m.slice(1).join(".")))}f.__paths__={...f.__paths__,[i]:`${d}[${c}]`,...l&&{[l]:c}};for(let m of s.properties){let y=m.parsedKey?ee(m.parsedKey,r,n,f):m.key,g=m.value;if(g.type===x.LITERAL)p[y]=g.value;else if(g.type===x.VARIABLE){let h=g.path;if(h===i)p[y]=u;else if(h===l)p[y]=c;else if(h.startsWith(i+".")){let w=h.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[y]=u[w]:p[y]=be(h,n,{...o,[i]:u,...l&&{[l]:c}})}else p[y]=be(h,n,{...o,[i]:u,...l&&{[l]:c}})}else if(g.type===x.INTERPOLATION){let h=[];for(let w of g.parts)if(typeof w=="string")h.push(w);else if(w.type===x.VARIABLE){let b=w.path,E;if(b===i)E=u;else if(b===l)E=c;else if(b.startsWith(i+".")){let v=b.substring(i.length+1);!v.includes(".")&&!v.includes("[")?E=u[v]:E=be(b,n,{...o,[i]:u,...l&&{[l]:c}})}else E=be(b,n,{...o,[i]:u,...l&&{[l]:c}});h.push(E!=null?String(E):"")}else{let b={...o,[i]:u,...l&&{[l]:c}},E=ee(w,r,n,b);h.push(E!=null?String(E):"")}p[y]=h.join("")}else{let h={...o,[i]:u,...l&&{[l]:c}};p[y]=ee(g,r,n,h)}}t.push(p)}return t}return null},$f=(e,r,n)=>{let o=e.body;if(o.type===x.OBJECT&&o.properties.length===1&&o.properties[0].key==="$if item.visible"){let t=o.properties[0].value;if(t.type===x.CONDITIONAL&&t.conditions.length===1&&t.conditions[0].type===x.VARIABLE&&t.conditions[0].path==="item.visible"){let s=t.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<r.length;u++){let p=r[u];if(p.visible){let f={id:p.id};p.highlighted?(f.highlight=!0,f.message=`This item is highlighted: ${p.name}`):(f.highlight=!1,f.message=p.name),c.push(f)}}return c}}}}return null},_f=(e,r,n,o)=>{let a=ee(e.iterable,r,n,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let f=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}(${f})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Na(p,a,u)}if(!e.indexVar){let c=$f(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=Rf(e,a);if(c!==null)return c}let t=Cf(e,r,n,o,a);if(t!==null)return t;let s=[],i=e.iterable.path||"";if(o&&o.__paths__&&i){let c=i.split("."),u=c[0];u in o.__paths__&&(i=o.__paths__[u],c.length>1&&(i+="."+c.slice(1).join(".")))}let l=!1;e.body.type===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=ee(e.body,r,n,u);if(Array.isArray(p)&&p.length===1&&!l){let f=p[0];s.push(f===void 0?{}:f)}else s.push(p===void 0?{}:p)}return s},Tf=(e,r,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],t=a.parsedKey?ee(a.parsedKey,r,n,o):a.key,s=a.value;if(s.type===x.OBJECT&&s.properties.length<=10&&!s.whenCondition){let i={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?ee(u.parsedKey,r,n,o):u.key,f=u.value;if(f.type===x.LITERAL)l[p]=f.value;else if(f.type===x.VARIABLE)l[p]=be(f.path,n,o);else if(f.type===x.INTERPOLATION){let d=[];for(let m of f.parts)if(typeof m=="string")d.push(m);else if(m.type===x.VARIABLE){let y=be(m.path,n,o);d.push(y!=null?String(y):"")}else{c=!1;break}if(!c)break;l[p]=d.join("")}else if(f.type===x.OBJECT&&f.properties.length<=5){let d={};for(let m of f.properties){let y=m.key,g=m.value;if(g.type===x.LITERAL)d[y]=g.value;else if(g.type===x.VARIABLE)d[y]=be(g.path,n,o);else if(g.type===x.INTERPOLATION){let h=[];for(let w of g.parts)if(typeof w=="string")h.push(w);else if(w.type===x.VARIABLE){let b=be(w.path,n,o);h.push(b!=null?String(b):"")}else{c=!1;break}if(!c)break;d[y]=h.join("")}else{c=!1;break}}if(!c)break;l[p]=d}else{c=!1;break}}if(c)return i[t]=l,i}}return null},Nf=(e,r,n,o)=>{let a=r.functions||r;if(e.whenCondition&&!dr(e.whenCondition,a,n,o))return;let t=Tf(e,r,n,o);if(t!==null)return t;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?ee(u.parsedKey,r,n,o):u.key,f=u.value;if(f.type===x.LITERAL)c[p]=f.value;else if(f.type===x.VARIABLE)c[p]=be(f.path,n,o);else if(f.type===x.INTERPOLATION){let d=[];for(let m of f.parts)if(typeof m=="string")d.push(m);else if(m.type===x.VARIABLE){let y=be(m.path,n,o);d.push(y!=null?String(y):"")}else{let y=ee(m,r,n,o);d.push(y!=null?String(y):"")}c[p]=d.join("")}else c[p]=ee(f,r,n,o)}return c}let s={},i=null,l=!1;for(let c of e.properties)if(!c.key.startsWith("$if ")&&!c.key.match(/^\$if\s+\w+.*:?$/)&&!c.key.startsWith("$elif")&&!c.key.startsWith("$else")&&!c.key.startsWith("$for ")){l=!0;break}for(let c of e.properties)if(c.key.startsWith("$if ")||c.key.match(/^\$if\s+\w+.*:?$/)){let u=ee(c.value,r,n,o);if(!l&&u!==null&&u!==void 0)return Array.isArray(u)&&u.length===1?u[0]:u;typeof u=="object"&&u!==null&&!Array.isArray(u)&&Object.assign(s,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return ee(c.value,r,n,o)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(f=>f.key.startsWith("$for "));if(p){let f=ee(p.value,r,n,o);f!==void 0&&(s[c.key]=f)}else{let f=ee(c.value,r,n,o);f!==void 0&&(s[c.key]=f)}}else{let p=c.parsedKey?ee(c.parsedKey,r,n,o):c.key,f=ee(c.value,r,n,o);f!==void 0&&(s[p]=f)}}return s},qa={},jf=(e,r,n,o)=>{let a=[];for(let t of e.items)if(t.type===x.LOOP){let s=ee(t,r,n,o);Array.isArray(s)&&t.flatten!==!1?a.push(...s):a.push(s)}else{let s=ee(t,r,n,o);s!==qa&&s!==void 0&&a.push(s)}return a},Df=(e,r,n,o)=>{let{name:a,data:t,whenCondition:s}=e,i=r.partials||{},l=r.functions||r;if(s&&!dr(s,l,n,o))return;if(!i[a])throw new Oe(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new Oe(`Circular partial reference detected: ${a}`);let u=i[a],p=n,f={...o,_partialStack:[...c,a]};if(o){p={...n};for(let d of Object.keys(o))d.startsWith("_")||(p[d]=o[d])}if(t){let d=ee(t,r,n,o);p={...p,...d}}return ee(u,r,p,f)},Lf=(e,r,n,o)=>{let{path:a}=e,t=a.split("."),s=t[0],i=t.slice(1);if(!o||!(s in o))throw new Oe(`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 Oe(`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 Oe(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var uo=Af;var Mf=/\$\{([^}]*)\}/g,Vf=/#\{([^}]*)\}/g,Ua=(e,r={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,t=qf(a,r);return{isFunction:!0,type:x.FUNCTION,name:o,args:t}},qf=(e,r={})=>e.trim()?Ff(e).map(o=>Uf(o.trim(),r)):[],Ff=e=>{let r=[],n="",o=0,a=!1,t="";for(let s=0;s<e.length;s++){let i=e[s],l=s>0?e[s-1]:"";!a&&(i==='"'||i==="'")?(a=!0,t=i,n+=i):a&&i===t&&l!=="\\"?(a=!1,t="",n+=i):!a&&i==="("?(o++,n+=i):!a&&i===")"?(o--,n+=i):!a&&i===","&&o===0?(r.push(n),n=""):n+=i}return n&&r.push(n),r},Uf=(e,r={})=>{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=Ua(e,r);if(n.isFunction)return{type:n.type,name:n.name,args:n.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],t=-1,s=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Tr(o.substring(c),i);if(u===-1)break;let p=c+u;p>t&&(t=p,s={op:i,type:l}),c=p+i.length}}if(t!==-1)try{return ke(o,r)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Ba=/^\w+\(.*\)$/,Bf=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Yf=e=>{if(!(!e||e.trim()===""||Ba.test(e))&&Bf.test(e))throw e.includes("?")&&e.includes(":")?new j(`Complex expressions not supported in variable replacements - consider calculating the value in your data instead. Offending expression: "${e}"`):e.includes("||")||e.includes("&&")||e.includes("??")?new j(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new j(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Fa=e=>{let r=e.trim();if(Ba.test(r))throw new j(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(r.includes("["))throw new j(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(r))throw new j(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(r))throw new j(`Logical operators not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(r.includes("?")&&r.includes(":"))throw new j(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:r}},kt=(e,r={})=>{let n=e.trim();Yf(n);let o=Ua(n,r);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(n.includes("[")&&!/[\s+\-*/%|&?:]/.test(n)){let a=0;for(let t of n)t==="["?a++:t==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:n}},po=(e,r={})=>{let n=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(n=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),n=n.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),n=n.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),n=n.replace(/\\DOUBLE_ESC_VAR/g,"\\"),n=n.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...n.matchAll(Mf)],t=[...n.matchAll(Vf)],s=[...a.map(c=>({match:c,type:"variable"})),...t.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(s.length===0){let c=n;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type: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"?kt(c[1],r):Fa(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,f]=c,d=c.index;if(d>l){let m=n.substring(l,d);for(let y=0;y<o.length;y++)m=m.replace(`__ESCAPED_${y}__`,o[y]);m&&i.push(m)}try{let m;u==="variable"?m=kt(f.trim(),r):m=Fa(f.trim()),i.push(m)}catch(m){if(m.message==="Invalid array index syntax")i.push(p);else throw m}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 yo=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Ga=e=>Object.keys(e),Ee=e=>e.join("."),fr=(e,r,n)=>{let o=Ga(e).filter(a=>!r.has(a));if(o.length>0)throw new j(`Unexpected key '${o[0]}' in condition JSON at '${Ee(n)}'`)},mr=(e,r)=>typeof e=="string"?po(e,r):typeof e=="object"&&e!==null?Array.isArray(e)?Gf(e,r):Hf(e,r):{type:x.LITERAL,value:e},zf=e=>{let{$each:r,...n}=e;if(typeof r!="string")throw new j("$each value must be a non-empty string");let o=r.trim();if(o==="")throw new j("$each value must be a non-empty string");if(Object.keys(n).length===0)throw new j("Empty $each body not allowed");if(n.$partial!==void 0)throw new j("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:n}},Gf=(e,r)=>{let n=[],o=!1;for(let a=0;a<e.length;a++){let t=e[a];if(typeof t=="object"&&t!==null&&!Array.isArray(t)){if(t.$each!==void 0)try{let l=zf(t),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=za(c[0],l[c[0]],r,!0);n.push(u),o=!0;continue}}catch(l){throw l instanceof j?l:new j(l.message)}let i=Object.keys(t);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=za(i[0],t[i[0]],r);n.push(l),o=!0;continue}}let s=mr(t,r);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}},Hf=(e,r)=>{let n=[],o=!1,a=null,t=Object.entries(e),s=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new j("$partial value must be a string");if(e.$partial.trim()==="")throw new j("$partial value cannot be an empty string");let l=["$if","$elif","$else","$for"],c=[];for(let[h]of t)for(let w of l)if(h===w||h.startsWith(w+" ")||h.startsWith(w+"#")){c.push(w);break}if(c.length>0)throw new j(`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,...f}=e,d={},m=!1;for(let[h,w]of Object.entries(f)){let b=h;(h.startsWith("\\$")||h.startsWith("$$"))&&(b=h.slice(1)),d[b]=w,m=!0}let y=null;if(m&&(y=mr(d,r),y.type===x.OBJECT)){let h=!1;for(let w of y.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){h=!0;break}h&&(y.fast=!1)}let g={type:x.PARTIAL,name:u,data:y};return p!==void 0&&(g.whenCondition=Ya(p,r)),g}for(let[l,c]of t)if(l==="$when"){if(a!==null)throw new j("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new j("Missing condition expression after '$when'");a=Ya(c,r),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new j("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;s<t.length;){let[l,c]=t[s];if(l==="$when"){s++;continue}if(l==="$each")throw new j("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=Xf(t,s,r);n.push({key:l,value:u.node}),o=!0,s=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new j(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new j(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new j("Missing condition expression after '$if'");{let u=mr(c,r);(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=po(l,r),f={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(f.parsedKey=p),n.push(f),s++}}}let i={type:x.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},Xf=(e,r,n={})=>{let o=[],a=[],t=r,[s,i]=e[t],l=null,c;if(s.startsWith("$if#")){let p=s.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new j(`Invalid conditional syntax: ${s}`)}else c=s.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());co(c);let u=ke(c,n);for(o.push(u),a.push(mr(i,n)),t++;t<e.length;){let[p,f]=e[t],d=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,m=null),d){if(m===null)o.push(null);else{co(m);let y=ke(m,n);o.push(y)}if(a.push(mr(f,n)),t++,m===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:t}},fo={eq:J.EQ,neq:J.NEQ,gt:J.GT,gte:J.GTE,lt:J.LT,lte:J.LTE,in:J.IN,add:J.ADD,sub:J.SUBTRACT},mo={all:J.AND,any:J.OR},Wf=new Set(["var","literal","call","not",...Object.keys(fo),...Object.keys(mo)]),Kf=(e,r,n)=>{if(!Array.isArray(e))throw new j(`Condition JSON operator '${r}' at '${Ee(n)}' requires an array`);if(e.length!==2)throw new j(`Condition JSON operator '${r}' at '${Ee(n)}' requires exactly 2 operands`);return e},Jf=(e,r,n,o,a)=>{if(!Array.isArray(e))throw new j(`Condition JSON operator '${r}' at '${Ee(a)}' requires an array`);if(e.length===0)throw new j(`Condition JSON operator '${r}' at '${Ee(a)}' requires at least 1 condition`);return e.map((s,i)=>$e(s,o,[...a,i])).reduce((s,i)=>({type:x.BINARY,op:n,left:s,right:i}))},Qf=(e,r,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],fr(e,new Set(["call","args"]),n);else if(yo(e.call))o=e.call.name,a=e.call.args??[],fr(e,new Set(["call"]),n),fr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new j(`Condition JSON call at '${Ee(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new j(`Condition JSON call at '${Ee(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new j(`Invalid condition JSON function name '${o}' at '${Ee(n)}'`);if(!Array.isArray(a))throw new j(`Condition JSON call '${o}' at '${Ee(n)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((t,s)=>$e(t,r,[...n,"args",s]))}},$e=(e,r={},n=["$when"])=>{if(typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null)return{type:x.LITERAL,value:e};if(Array.isArray(e))throw new j(`Condition JSON array at '${Ee(n)}' must be wrapped in an operator or { literal: [...] }`);if(!yo(e))throw new j(`Invalid condition JSON value at '${Ee(n)}'`);let o=Ga(e);if(o.length===0)throw new j(`Condition JSON object at '${Ee(n)}' must contain an operator`);let a=o.filter(s=>Wf.has(s));if(a.length===0)throw new j(`Unknown condition JSON operator '${o[0]}' at '${Ee(n)}'`);if(a.length>1)throw new j(`Condition JSON at '${Ee(n)}' must contain exactly one operator`);let t=a.includes("call")?"call":a[0];if(t==="var"){if(fr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new j(`Condition JSON var at '${Ee(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(t==="literal")return fr(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(t==="call")return Qf(e,r,n);if(t==="not")return fr(e,new Set(["not"]),n),{type:x.UNARY,op:Kr.NOT,operand:$e(e.not,r,[...n,"not"])};if(t in mo)return fr(e,new Set([t]),n),Jf(e[t],t,mo[t],r,[...n,t]);if(t in fo){fr(e,new Set([t]),n);let s=Kf(e[t],t,[...n,t]);return{type:x.BINARY,op:fo[t],left:$e(s[0],r,[...n,t,0]),right:$e(s[1],r,[...n,t,1])}}throw new j(`Unknown condition JSON operator '${t}' at '${Ee(n)}'`)},Ya=(e,r={})=>{if(e==null)throw new j("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new j("Empty condition expression after '$when'");return ke(e,r)}return yo(e)||Array.isArray(e)?$e(e,r):{type:x.LITERAL,value:e}},ke=(e,r={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let f=0;f<c.length;f++)if(c[f]==="("?u++:c[f]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return ke(c,r)}let n=Tr(e,"||");if(n!==-1)return{type:x.BINARY,op:J.OR,left:ke(e.substring(0,n).trim(),r),right:ke(e.substring(n+2).trim(),r)};let o=Tr(e,"&&");if(o!==-1)return{type:x.BINARY,op:J.AND,left:ke(e.substring(0,o).trim(),r),right:ke(e.substring(o+2).trim(),r)};let a=[{op:">=",type:J.GTE},{op:"<=",type:J.LTE},{op:"==",type:J.EQ},{op:"!=",type:J.NEQ},{op:">",type:J.GT},{op:"<",type:J.LT},{op:" in ",type:J.IN}];for(let{op:c,type:u}of a){let p=Tr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:ke(e.substring(0,p).trim(),r),right:ke(e.substring(p+c.length).trim(),r)}}let t=-1,s=null,i=[{op:" + ",type:J.ADD},{op:" - ",type:J.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let f=Tr(e.substring(p),c);if(f===-1)break;let d=p+f;d>t&&(t=d,s={op:c,type:u}),p=d+c.length}}if(t!==-1&&s)return{type:x.BINARY,op:s.type,left:ke(e.substring(0,t).trim(),r),right:ke(e.substring(t+s.op.length).trim(),r)};let l=[" * "," / "," % "];for(let c of l)if(Tr(e,c)!==-1)throw new j(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:Kr.NOT,operand:ke(e.substring(1).trim(),r)}:Ha(e,r)},Tr=(e,r)=>{let n=0,o=0;for(;o<=e.length-r.length;){if(e[o]==="(")n++;else if(e[o]===")")n--;else if(n===0&&e.substring(o,o+r.length)===r)return o;o++}return-1},Zf=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 r=Number(e);return!isNaN(r)&&isFinite(r)?{type:x.LITERAL,value:r}:{type:x.VARIABLE,path:e}},Ha=(e,r)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return kt(n,r);let a=Zf(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return kt(n,r)}catch(t){if(t.message&&t.message.includes("not supported"))return a;throw t}},em=(e,r=!1)=>{let n=r?"$each":"$for";try{Ta(e)}catch(o){if(o instanceof j&&r){let a=o.message.replace(/\$for/g,"$each");throw new j(a.replace("Parse Error: ",""))}throw o}},za=(e,r,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,t=e.match(a);if(!t){let g=o?"$each":"$for";throw new j(`Invalid loop syntax (got: '${e.replace("$for",g)}')`)}let s=t[1],i=t[2].trim();em(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let g=o?"$each":"$for";throw new j(`Invalid loop syntax - missing 'in' keyword (got: '${g} ${i}')`)}let c=l[1].trim(),u=l[2].trim(),p,f=null;if(c.includes(",")){let g=c.split(",").map(h=>h.trim());if(g.length!==2)throw new j(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=g[0],f=g[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new j(`Reserved variable name: ${p}`);if(f&&d.includes(f))throw new j(`Reserved variable name: ${f}`);let m=Ha(u,n),y=mr(r,n);return{type:x.LOOP,itemVar:p,indexVar:f,iterable:m,body:y,flatten:s!=="nested"}};var rm=(e,r={})=>{let{functions:n={}}=r;return mr(e,n)},wn=rm;var vt={};ff(vt,{now:()=>tm});var tm=()=>Date.now();var nm=(e,r,n={})=>{let{functions:o={},partials:a={}}=n,t={...vt,...o},s=wn(e,{functions:t}),i={};for(let[l,c]of Object.entries(a))i[l]=wn(c,{functions:t});return uo(s,r,{functions:t,partials:i})},Nr=nm;var sm=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",om=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,im=(e,r)=>{if(sm(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new j("Empty condition expression");return ke(e,r)}return $e(e,r)},am=(e,r={},n={})=>{let o=om(n),a={...vt,...o},t=im(e,a);return!!dr(t,{functions:a,partials:{}},r,{})},ho=am;var xo=Symbol("runStoreTransaction"),wo="__routeEngineConditionComparison",kn=(e,r)=>typeof e=="number"&&typeof r=="number"&&Number.isFinite(e)&&Number.isFinite(r)||typeof e=="string"&&typeof r=="string",yr=Object.freeze({eq:(e,r)=>e===r,neq:(e,r)=>e!==r,gt:(e,r)=>kn(e,r)&&e>r,gte:(e,r)=>kn(e,r)&&e>=r,lt:(e,r)=>kn(e,r)&&e<r,lte:(e,r)=>kn(e,r)&&e<=r}),rl=Object.freeze(Object.fromEntries(Object.keys(yr).map(e=>[e,`${wo}${e}`]))),lm=Object.freeze(Object.fromEntries(Object.entries(rl).map(([e,r])=>[r,yr[e]]))),Xa=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),cm=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},vn=e=>{if(Array.isArray(e))return e.map(vn);if(e===null||typeof e!="object"||Xa(e,"literal")||Xa(e,"var"))return e;if(cm(e)?.startsWith(wo))throw new Error(`Condition function names beginning with "${wo}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,t=rl[o];if(t)return{call:t,args:a.map(vn)}}return Object.fromEntries(n.map(([o,a])=>[o,vn(a)]))},Pt=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return $e(e),ho(vn(e),r,{functions:lm})},um=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],tl=(e,r,n={})=>{let o={},a={},{transformSelectorFirstArgument:t=y=>y,transformActionFirstArgument:s=y=>y,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},f=0,d=(y,g)=>!u||!c?y:In(y,h=>{c({state:h.state,transactionalMetadata:h.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});for(let[y,g]of Object.entries(r))y!=="createInitialState"&&(y.startsWith("select")?o[y]=(...h)=>g(t(p.state,p.transactionalMetadata),...h):a[y]=(...h)=>{let w,b=p,E=In(p,v=>{let P=g(s(v.state,v.transactionalMetadata),...h);w=P!==void 0&&!we(P)?P:void 0,u&&l&&l({actionName:y,args:h,state:v.state,transactionalMetadata:v.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});return f===0&&(E=d(E,b)),p=E,w});let m=y=>{if(typeof y!="function")throw new Error("Store transaction requires a callback");let g=p,h=f===0;f+=1;let w;try{w=y()}catch(b){throw f-=1,p=g,b}if(f-=1,h)try{p=d(p,g)}catch(b){throw p=g,b}return w};return{...o,...a,[xo]:m}},En=(e,r)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return In(o,t=>{a.forEach(s=>{r.forEach(i=>{i(t,s)})})})};var pm=(e,r)=>{if(e.default!==void 0)return e.default;let n=["number","boolean","string","object"];if(!n.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${r}. Expected one of: ${n.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},W=(e,r)=>Object.prototype.hasOwnProperty.call(e??{},r),ko=(e,r,n)=>{Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0})},Ie=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),dm=new Set(["pageSize","groups"]),fm=new Set(["id","variants"]),mm=new Set(["id","imageId"]),ym=new Set(["pageSize","tracks"]),hm=new Set(["id","soundId","title","artist","album","description","coverImageId"]),gm=new Set(["pageSize","replays"]),bm=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),jr=(e,r,n)=>{Object.keys(e).forEach(o=>{if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},Jr=(e,r)=>{if(typeof e!="string"||e.length===0)throw new Error(`${r} must be a non-empty string`)},xt=(e={})=>{let r=e?.resources?.imageGallery;if(r===void 0)return;if(!Ie(r))throw new Error("resources.imageGallery must be an object");if(jr(r,dm,"resources.imageGallery"),!Number.isInteger(r.pageSize)||r.pageSize<1)throw new Error("resources.imageGallery.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(r.groups))throw new Error("resources.imageGallery.groups must be an array");let n=new Set;for(let[o,a]of r.groups.entries()){let t=`resources.imageGallery.groups[${o}]`;if(!Ie(a))throw new Error(`${t} must be an object`);if(jr(a,fm,t),Jr(a.id,`${t}.id`),n.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(n.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${t}.variants must be a non-empty array`);let s=new Set;for(let[i,l]of a.variants.entries()){let c=`${t}.variants[${i}]`;if(!Ie(l))throw new Error(`${c} must be an object`);if(jr(l,mm,c),Jr(l.id,`${c}.id`),Jr(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),!W(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},Et=(e={})=>{let r=e?.resources?.musicRoom;if(r===void 0)return;if(!Ie(r))throw new Error("resources.musicRoom must be an object");if(jr(r,ym,"resources.musicRoom"),!Number.isInteger(r.pageSize)||r.pageSize<1)throw new Error("resources.musicRoom.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(r.tracks))throw new Error("resources.musicRoom.tracks must be an array");let n=new Set;for(let[o,a]of r.tracks.entries()){let t=`resources.musicRoom.tracks[${o}]`;if(!Ie(a))throw new Error(`${t} must be an object`);jr(a,hm,t);for(let l of["id","soundId","title"])Jr(a[l],`${t}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&Jr(a[l],`${t}.${l}`);if(n.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);n.add(a.id);let s=e?.resources?.sounds?.[a.soundId];if(!W(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Ie(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&&!W(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},Im=(e,r,n)=>{let o=Array.isArray(n)?"array":typeof n;switch(r.type){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof n!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${r.type}"`)}},St=(e={})=>{let r=e?.resources?.sceneReplay;if(r===void 0)return;if(!Ie(r))throw new Error("resources.sceneReplay must be an object");if(jr(r,gm,"resources.sceneReplay"),!Number.isInteger(r.pageSize)||r.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(r.replays))throw new Error("resources.sceneReplay.replays must be an array");let n=e?.story?.scenes??{},o=new Set;for(let[a,t]of r.replays.entries()){let s=`resources.sceneReplay.replays[${a}]`;if(!Ie(t))throw new Error(`${s} must be an object`);jr(t,bm,s);for(let u of["sceneId","title","thumbnailImageId"])Jr(t[u],`${s}.${u}`);if(o.has(t.sceneId))throw new Error(`Duplicate scene replay sceneId "${t.sceneId}"`);if(o.add(t.sceneId),!W(e?.resources?.images,t.thumbnailImageId))throw new Error(`Scene replay scene "${t.sceneId}" references unknown thumbnail image "${t.thumbnailImageId}"`);let i=n[t.sceneId];if(!i)throw new Error(`Scene replay references unknown scene "${t.sceneId}"`);let l=i.initialSectionId,c=i.sections?.[l];if(!c)throw new Error(`Scene replay scene "${t.sceneId}" references unknown initial section "${l}"`);if(c.initialLineId!==void 0&&!c.lines?.some(u=>u.id===c.initialLineId))throw new Error(`Scene replay scene "${t.sceneId}" initial section "${l}" references unknown initial line "${c.initialLineId}"`);if(t.initialVariables!==void 0){if(!Ie(t.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(t.initialVariables)){let f=e?.resources?.variables?.[u];if(!f)throw new Error(`Scene replay scene "${t.sceneId}" initialVariables references unknown variable "${u}"`);if(Se(f))throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize computed variable "${u}"`);if(f.readonly===!0)throw new Error(`Scene replay scene "${t.sceneId}" cannot initialize readonly variable "${u}"`);if(f.scope!=="context")throw new Error(`Scene replay scene "${t.sceneId}" can only initialize context variable "${u}"`);Im(u,f,p)}}}},nl=e=>{let r=we(e)?pr(e):e;return structuredClone(r)},wm=({characterId:e,resourceCharacter:r,variables:n={}}={})=>{if(!W(r,"nameVariableId"))return;let o=r.nameVariableId,a=n?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Sn=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0;if(r?.name!==void 0)return r.name;if(n!==void 0)return n;let s=wm({characterId:e,resourceCharacter:t,variables:a});return s!==void 0?s:t?.name||""},Se=e=>W(e,"computed"),Eo=(e,r)=>{switch(e?.type){case"number":return typeof r=="number"&&Number.isFinite(r);case"boolean":return typeof r=="boolean";case"string":return typeof r=="string";case"object":return r!==null&&typeof r=="object"&&!Array.isArray(r);default:return!1}},Ot=(e={},r={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,t])=>{let s=r[a];return s===void 0?o:!Se(s)&&(!n||n.includes(s.scope))&&Eo(s,t)})),qe=(e,r)=>new Error(`${r} has invalid path: ${JSON.stringify(e)}`),km=(e,r,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw qe(r,n)}let a="";for(let t=1;t<e.length-1;t+=1){let s=e[t];if(s!=="\\"){if(s.charCodeAt(0)<32)throw qe(r,n);a+=s;continue}if(t+=1,t>=e.length-1)throw qe(r,n);let i=e[t];if(i==="u"){let c=e.slice(t+1,t+5);if(c.length!==4||!/^[0-9a-fA-F]{4}$/.test(c))throw qe(r,n);a+=String.fromCharCode(Number.parseInt(c,16)),t+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!W(l,i))throw qe(r,n);a+=l[i]}return a},sl=(e,r="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw qe(e,r);let n=[],o=0,a=()=>{let s=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(s,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw qe(e,r);n.push(i)},t=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let s=e[o];if(/\d/.test(s??"")){let u=o;for(;o<e.length&&/\d/.test(e[o]);)o+=1;let p=e.slice(u,o);for(;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]"||p.length>1&&p.startsWith("0"))throw qe(e,r);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw qe(e,r);let i=s,l=o;o+=1;let c=!1;for(;o<e.length;){let u=e[o];if(c)c=!1;else if(u==="\\")c=!0;else if(u===i){let p=e.slice(l,o+1);for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;if(e[o]!=="]")throw qe(e,r);o+=1,n.push(km(p,e,r));return}o+=1}if(c||o>=e.length)throw qe(e,r)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){t();continue}throw qe(e,r)}return n},go=(e,r)=>{let n=e;for(let o of r){if(n==null||!W(n,o))return;n=n[o]}return n},ol=(e,r={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=sl(e),[o,a,...t]=n;if(o==="variables"){if(!a)return r.variables;let s=typeof r.resolveVariable=="function"?r.resolveVariable(a):r.variables?.[a];return go(s,t)}return o==="runtime"?go(r.runtime,n.slice(1)):go(r,n)},il=(e,r,n)=>{if(!Array.isArray(r))throw new Error(`Computed expression operator "${e}" requires an array`);if(n!==void 0&&r.length!==n)throw new Error(`Computed expression operator "${e}" requires ${n} operand(s)`)},vo=(e,r)=>{if(!Array.isArray(r))throw new Error(`Computed expression operator "${e}" requires an array`);if(r.length===0)throw new Error(`Computed expression operator "${e}" requires at least one operand`)},vm=(e,r)=>{if(typeof r!="number"||!Number.isFinite(r))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Be=(e,r,n,o)=>(il(e,r,o),r.map(a=>xn(a,n))),Ve=(e,r,n,o)=>{let a=Be(e,r,n,o);return a.forEach(t=>vm(e,t)),a},Am=(e,r,n)=>{switch(e){case"var":return ol(r,n);case"add":{let[o,a]=Ve(e,r,n,2);return o+a}case"sub":{let[o,a]=Ve(e,r,n,2);return o-a}case"mul":{let[o,a]=Ve(e,r,n,2);return o*a}case"div":{let[o,a]=Ve(e,r,n,2);return o/a}case"mod":{let[o,a]=Ve(e,r,n,2);return o%a}case"neg":{let[o]=Ve(e,r,n,1);return-o}case"round":{let[o]=Ve(e,r,n,1);return Math.round(o)}case"floor":{let[o]=Ve(e,r,n,1);return Math.floor(o)}case"ceil":{let[o]=Ve(e,r,n,1);return Math.ceil(o)}case"min":{let[o,a]=Ve(e,r,n,2);return Math.min(o,a)}case"max":{let[o,a]=Ve(e,r,n,2);return Math.max(o,a)}case"clamp":{let[o,a,t]=Ve(e,r,n,3);return Math.min(t,Math.max(a,o))}case"eq":{let[o,a]=Be(e,r,n,2);return yr.eq(o,a)}case"neq":{let[o,a]=Be(e,r,n,2);return yr.neq(o,a)}case"gt":{let[o,a]=Be(e,r,n,2);return yr.gt(o,a)}case"gte":{let[o,a]=Be(e,r,n,2);return yr.gte(o,a)}case"lt":{let[o,a]=Be(e,r,n,2);return yr.lt(o,a)}case"lte":{let[o,a]=Be(e,r,n,2);return yr.lte(o,a)}case"in":{let[o,a]=Be(e,r,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return vo(e,r),r.every(o=>!!xn(o,n));case"or":case"any":return vo(e,r),r.some(o=>!!xn(o,n));case"not":{let[o]=Be(e,r,n,1);return!o}case"length":{let[o]=Be(e,r,n,1);return typeof o=="string"||Array.isArray(o)?o.length:Ie(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Be(e,r,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return nl(r);default:throw new Error(`Unknown computed expression operator: ${e}`)}},xn=(e,r={})=>{if(e===null||typeof e!="object")return e;if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let n=Object.entries(e);if(n.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=n;return Am(o,a,r)},Ao=(e,r)=>{if(e===null||typeof e!="object"||W(e,"literal"))return e;if(W(e,"var"))return{literal:ol(e.var,r)};if(W(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=>Ao(a,r)):Ao(o,r)]))},Pm=(e,r={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return $e(e),Pt(Ao(e,r))},al=(e,r)=>{if(!Ie(e))throw new Error(`${r} must be an object`);let n=W(e,"expr"),o=W(e,"value");if(n===o)throw new Error(`${r} must contain exactly one of expr or value`)},bo=(e,r,n)=>(al(e,r),W(e,"value")?nl(e.value):xn(e.expr,n)),xm=(e,r={},n="unknown")=>{if(!Ie(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=W(e,"expr"),a=W(e,"value");if(W(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(!Ie(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(!Ie(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!W(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(Pm(i.when,r))return bo(i,`Computed variable "${n}" branch ${s}`,r)}return bo(e.default,`Computed variable "${n}" default`,r)}if(o===a)throw new Error(`Computed variable "${n}" must contain exactly one of expr, value, or branches`);return bo(e,`Computed variable "${n}"`,r)},ll=(e,r,n)=>{switch(r){case"number":if(typeof n!="number"||!Number.isFinite(n))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(n)?"array":typeof n}`);return;case"boolean":if(typeof n!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(n)?"array":typeof n}`);return;case"string":if(typeof n!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(n)?"array":typeof n}`);return;case"object":if(n===null||typeof n!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof n}`);return;default:throw new Error(`Invalid variable type: ${r} for computed variable ${e}`)}},Em=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}),Sm=new Set(["and","or","all","any"]),Om=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Rm=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Cm=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),$m=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),cl=new WeakMap,Wa=e=>e===null?"null":Array.isArray(e)?"object":typeof e,An=(e,r,n)=>{for(let o of Object.keys(e))if(!r.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},_m=(e,r,n,o)=>{if(n!==void 0&&n!==r)throw new Error(`Computed variable "${e}" ${o} expected type ${r}, got ${n}`)},ul=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{let t=`Computed variable "${r}" ${a} var`,[s,i,...l]=sl(e,t);if(s!=="variables"&&s!=="runtime")throw new Error(`${t} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${t} must reference a concrete ${s} member, got ${JSON.stringify(e)}`);if(s==="runtime")return;if(!W(n,i))throw new Error(`Computed variable "${r}" ${a} references unknown variable "${i}"`);let c=n[i];return Se(c)&&o.add(i),l.length===0?c?.type:void 0},pl=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{if(e===null||typeof e!="object"){if(typeof e=="number"&&!Number.isFinite(e))throw new Error(`Computed variable "${r}" ${a} must use finite numeric literals`);return Wa(e)}if(Array.isArray(e))throw new Error("Computed expression arrays are not valid; use value for literal arrays");let t=Object.entries(e);if(t.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[s,i]]=t;if(s==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return ul(i,{variableId:r,variableConfigs:n,dependencies:o,path:a})}if(s==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${r}" ${a} must use finite numeric literals`);return Wa(i)}let l=Em[s];if(l===void 0&&!Sm.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?vo(s,i):il(s,i,l);let c=i.map((u,p)=>pl(u,{variableId:r,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(Rm.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),Om.has(s))return"number";if(Cm.has(s))return"boolean"},Tm=(e,{variableId:r,variableConfigs:n,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{$e(e)}catch(s){throw new Error(`Computed variable "${r}" ${a} is invalid: ${s.message}`,{cause:s})}let t=(s,i)=>{if(s===null||typeof s!="object"||W(s,"literal"))return;if(W(s,"var")){ul(s.var,{variableId:r,variableConfigs:n,dependencies:o,path:i});return}if(W(s,"call"))throw new Error(`Computed variable "${r}" ${i} function calls are not supported`);if(W(s,"not")){t(s.not,`${i}.not`);return}let l=Object.keys(s).find(c=>$m.has(c));s[l].forEach((c,u)=>{t(c,`${i}.${l}[${u}]`)})};t(e,a)},Io=(e,{variableId:r,variableConfig:n,variableConfigs:o,dependencies:a,path:t,allowedKeys:s=new Set(["expr","value"])})=>{if(al(e,`Computed variable "${r}" ${t}`),An(e,s,t),W(e,"value")){ll(r,n.type,e.value);return}let i=pl(e.expr,{variableId:r,variableConfigs:o,dependencies:a,path:`${t}.expr`});_m(r,n.type,i,`${t}.expr`)},Nm=(e,r,n)=>{let o=r.computed;if(!Ie(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,t=W(o,"expr"),s=W(o,"value");if(W(o,"branches")){if(An(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),t||s)throw new Error(`Computed variable "${e}" cannot combine branches with expr or value`);if(!Array.isArray(o.branches))throw new Error(`Computed variable "${e}" branches must be an array`);if(o.branches.length===0)throw new Error(`Computed variable "${e}" branches must not be empty`);if(!Ie(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Ie(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(An(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!W(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Tm(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Io(l,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Io(o.default,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(An(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),t===s)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return Io(o,{variableId:e,variableConfig:r,variableConfigs:n,dependencies:a,path:"computed"}),a},Dr=(e={})=>{if(!Ie(e))throw new Error("Variable configs must be an object");if(W(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(W(e,""))throw new Error("Variable ids must not be empty");let r=new Map;Object.entries(e).forEach(([t,s])=>{if(Se(s)){if(!Ie(s))throw new Error(`Computed variable "${t}" must be an object`);if(!W(s,"type"))throw new Error(`Computed variable "${t}" requires type`);if(!W(s,"scope"))throw new Error(`Computed variable "${t}" requires scope`);if(W(s,"default"))throw new Error(`Computed variable "${t}" must not declare a top-level default`);if(Rt(s.scope,t),!["number","boolean","string","object"].includes(s.type))throw new Error(`Invalid variable type: ${s.type} for computed variable ${t}`);r.set(t,Nm(t,s,e))}});let n=new Set,o=[];r.forEach((t,s)=>{if(n.has(s))return;let i=[{variableId:s,dependencies:[...r.get(s)??[]],nextDependencyIndex:0}],l=new Map([[s,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),n.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,n.has(u))continue;let p=l.get(u);if(p!==void 0){let f=[...i.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${f}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...r.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return cl.set(e,a),a},Qr=({variables:e={},runtime:r={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=cl.get(n)??Dr(n),t=Ot(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,g])=>Se(g)).map(([g])=>g),i=Object.create(null),l=[],c=new Map(a.map((g,h)=>[g,h])),u=-1,p=!1,f=g=>{if(W(i,g))return i[g];let h=n[g];if(!Se(h))return W(t,g)?t[g]:void 0;let w=l.indexOf(g);if(w>=0){let b=[...l.slice(w),g].join(" -> ");throw new Error(`Computed variable cycle detected: ${b}`)}l.push(g);try{let b=xm(h.computed,y,g);return ll(g,h.type,b),ko(i,g,b),b}finally{l.pop()}},d=g=>{if(W(i,g))return i[g];let h=n[g];if(!Se(h))return W(t,g)?t[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)f(a[b]),u=b}finally{p=!1}return i[g]}return f(g)},m=new Proxy({},{get:(g,h)=>{if(typeof h=="string")return d(h)},has:(g,h)=>typeof h=="string"&&(W(t,h)||s.includes(h)),ownKeys:()=>[...new Set([...Object.keys(t),...s])],getOwnPropertyDescriptor:(g,h)=>{if(!(typeof h!="string"||!W(t,h)&&!s.includes(h)))return{enumerable:!0,configurable:!0}}}),y={variables:m,runtime:r,resolveVariable:d};return o?(s.forEach(g=>{d(g)}),{...t,...i}):m},jm=({variables:e={},runtime:r={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return Dr(a),Qr({variables:e,runtime:r,variableConfigs:a,eager:!0})},On=e=>{let r={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(Se(a))return;let t=pm(a,o);a.scope==="context"?ko(r,o,t):ko(n,o,t)}),{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:r,globalVariablesDefaultValues:n}},Rt=(e,r)=>{let n=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${r}`);if(!n.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${r}. Expected one of: ${n.join(", ")}`)},Ct=(e,r,n)=>{let o={number:["set","increment","decrement","multiply","divide"],boolean:["set","toggle"],string:["set"],object:["set"]},a=o[e];if(!a)throw new Error(`Unknown variable type: ${e} for variable ${n}`);if(!Object.values(o).flat().includes(r))throw new Error(`Unknown operation: ${r}`);if(!a.includes(r))throw new Error(`Operation "${r}" is not valid for variable "${n}" of type "${e}". Valid operations: ${a.join(", ")}`)},Dm=2,Ka=12,dl=(e=Dm)=>{if(!Number.isInteger(e)||e<0||e>Ka)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Ka}.`);return e},Lm=(e,r)=>{let n=10**r;return Math.round((e+Number.EPSILON)*n)/n},Pn=e=>typeof e=="number"&&Number.isFinite(e),Rn=(e,r,n,o,a={})=>{if(e==="number"){if(r==="set"&&!Pn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(r==="multiply"&&!Pn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(r==="divide"&&!Pn(n))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(r==="divide"){if(n===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);dl(a.roundTo)}}},Cn=(e,r,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!Pn(c))throw new Error(`Operation "${r}" requires ${l} to be a number.`);return c},t=s=>{let i=a(s,void 0,"value");if(i===0)throw new Error(`Operation "${r}" requires value to be a non-zero number.`);return i};switch(r){case"set":return n;case"multiply":return a(e,1,"current value")*a(n,void 0,"value");case"divide":return Lm(a(e,0,"current value")/t(n),dl(o.roundTo));case"increment":return a(e,0,"current value")+a(n,1,"value");case"decrement":return a(e,0,"current value")-a(n,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${r}`)}};var So=(e,r="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let n=new Date(e),o=s=>String(s).padStart(2,"0"),a=String(n.getFullYear()),t={DD:o(n.getDate()),MM:o(n.getMonth()+1),MMM:um[n.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(n.getHours()),mm:o(n.getMinutes()),ss:o(n.getSeconds())};return r.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,s=>t[s])},Mm=(e,r)=>{let n=t=>t?.ui,o=n(e),a=n(r);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:r}:a&&o?{changeType:"update",data:r}:null},At=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,Vm=(e,r)=>{let n=e?.character?.sprite,o=r?.character?.sprite,a=At(n)?n:void 0,t=At(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(t)?null:a&&!t?{changeType:"delete",data:a}:t&&!a?{changeType:"add",data:t}:t&&a?{changeType:"update",data:t}:null},Ja=e=>{if(e?.resourceId===void 0)return;let r={resourceId:e.resourceId};e.transformId!==void 0&&(r.transformId=e.transformId);for(let n of["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"])e[n]!==void 0&&(r[n]=e[n]);for(let n of["animationName","animationSpeed","loop"])e[n]!==void 0&&(r[n]=e[n]);return r},Qa=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Za=(e,r)=>r&&!e?{changeType:"add",data:r}:e&&!r?{changeType:"delete",data:e}:e&&r&&JSON.stringify(e)!==JSON.stringify(r)?{changeType:"update",data:r}:null,qm=(e,r)=>{let n={},o=Za(Ja(e),Ja(r)),a=Za(Qa(e),Qa(r));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},Oo=(e={},r={})=>{let n={},o=["voice"],a=l=>{let c=e[l],u=r[l];if(u&&!c)n[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(f=>f.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})},t=qm(e.background,r.background);t&&(n.background=t),a("screen"),a("bgm"),a("voice");let s=Mm(e.dialogue,r.dialogue);s&&(n.dialogue=s);let i=Vm(e.dialogue,r.dialogue);return i&&(n.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),n},Ro=(e={})=>{let r=structuredClone(e);if(r.sfx){let a=Array.isArray(r.sfx.channels)?r.sfx.channels.filter(t=>t.applyMode==="persistent"):[];a.length>0?r.sfx={channels:a}:delete r.sfx}r.background&&(r.background.animations?.playback?.continuity!=="persistent"&&delete r.background.animations,!r.background.resourceId&&!r.background.colorId&&delete r.background);let n=a=>{r[a]&&(delete r[a].animations,Object.keys(r[a]).length===0&&delete r[a])};n("layout"),n("choice"),n("form"),n("screen"),r.dialogue?.ui&&(delete r.dialogue.ui.animations,Object.keys(r.dialogue.ui).length===0&&delete r.dialogue.ui,Object.keys(r.dialogue).length===0&&delete r.dialogue),r.dialogue?.character?.sprite&&(delete r.dialogue.character.sprite.animations,Object.keys(r.dialogue.character.sprite).length===0&&delete r.dialogue.character.sprite,Object.keys(r.dialogue.character).length===0&&delete r.dialogue.character,Object.keys(r.dialogue).length===0&&delete r.dialogue);let o=(a,t)=>{let s=r[a]?.items;Array.isArray(s)&&(r[a].items=s.map(i=>{let l={...i};return l.animations?.playback?.continuity!=="persistent"&&delete l.animations,t(l)?l:null}).filter(Boolean),r[a].items.length===0&&delete r[a])};return o("character",a=>a.sprites&&a.sprites.length>0||a.transformId||a.resourceId),o("visual",a=>a.resourceId||a.text||a.layout||a.transformId||a.transform),r},Fm=(e,r)=>{if(!e||!r)return;let n=e;for(let o of r.split(".")){if(n==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(n),o))return;n=n[o]}return n},el=e=>e!==null&&typeof e=="object"?structuredClone(e):e,Um=(e,r,n)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(r??{},n)?r[n]:void 0;if(e===n){if(o==null)throw new Error(`Action template binding "${n}" requires event context "${n}".`);return el(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),t=Fm(o,a);if(t===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return el(t)},Bm={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"])},Ym=(e,r)=>{let n=e[e.length-1];return n?Bm[n]?.has(r)===!0:!1},Po=(e,r,n=[])=>Array.isArray(e)?e.map(o=>Po(o,r,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Ym(n,o)?a:Po(a,r,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Um(e,r,"_event"):Nr(e,r):e,$t=(e,r)=>{if(!r)return e;if(Object.prototype.hasOwnProperty.call(r,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return Po(e,r)};var zm=11102230246251565e-32,fl=128,ml=1e3,yl=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),_t=(e,r,n)=>{let o=Object.keys(e).find(a=>!r.has(a));if(o!==void 0)throw new Error(`${n}.${o} is not supported`)},$n=(e,r)=>{if(!yl(e))throw new Error(`${r} must be an object`)},_n=(e,r,{min:n,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${r} must be a safe integer`);if(n!==void 0&&e<n)throw new Error(`${r} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${r} must be at most ${o}`);return e},Gm=(e,r,{min:n,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} must be a finite number`);if(n!==void 0&&e<n)throw new Error(`${r} must be at least ${n}`);if(o!==void 0&&e>o)throw new Error(`${r} must be at most ${o}`);return e},Co=e=>{let r=structuredClone(e),n=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(n),Object.freeze(o)),o);return n(r)},Hm=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),hl=e=>{let r=e??Hm();if(!yl(r)||typeof r.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let n=r.nextUint32();if(!Number.isInteger(n)||n<0||n>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return n}}},Xm=(e,r)=>{let n=4294967296-4294967296%r;for(let o=0;o<fl;o+=1){let a=e.nextUint32();if(a<n)return a%r}throw new Error(`random source exhausted after ${fl} rejected samples`)},Wm=e=>{let r=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(r*67108864+n)/9007199254740992},Km=(e,r)=>{if(_t(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=_n(e.min,"random.distribution.min"),a=_n(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 Co({type:"integer",value:a===1?n:n+Xm(r,a)})},Jm=(e,r)=>{if(_t(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>ml)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($n(c,p),_t(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return $n(c.actions,`${p}.actions`),{weight:Gm(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})),t=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(n[u].weight>0&&(c.weight===0||c.weight/t<=zm))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Wm(r)*t,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 Co({type:"weighted",outcomeIndex:l})},gl=(e,{randomSource:r})=>{$n(e,"random.distribution");let o={integer:Km,weighted:Jm}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,r)},Tn=(e,r)=>{if($n(e,"random result"),e.type!==r)throw new Error("random result type does not match its recorded type");if(r==="integer")_t(e,new Set(["type","value"]),"random result"),_n(e.value,"random result.value");else if(r==="weighted")_t(e,new Set(["type","outcomeIndex"]),"random result"),_n(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:ml-1});else throw new Error(`unsupported recorded random result type: ${r}`);return Co(e)};var Lr=(e,r)=>Object.freeze({name:e,actions:Object.freeze(r)}),wl=Object.freeze([Lr("cleanup",["clearPendingEffects","cleanAll"]),Lr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Lr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Lr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Lr("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"]),Lr("persistence",["saveSlot"]),Lr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),Zr=new Map;wl.forEach(e=>{e.actions.forEach(r=>{if(Zr.has(r))throw new Error(`duplicate action execution key: ${r}`);Zr.set(r,Zr.size)})});var Qm=new Set(wl.find(({name:e})=>e==="navigation").actions),bl=Zr.get("saveSlot")-.5,Il=(e,r)=>e!=="random"?e:r?.distribution?.type==="weighted"?"random:weighted":"random:integer",Zm=(e,r)=>e<r?-1:e>r?1:0,Nn=e=>Object.entries(e).sort((r,n)=>{let o=Il(...r),a=Il(...n),t=Zr.get(o),s=Zr.get(a),i=t??bl,l=s??bl;return i!==l?i-l:t!==void 0&&s!==void 0?0:Zm(o,a)}),$o=e=>Qm.has(e),jn=e=>{let r=e.map(([n])=>n).filter($o);if(!(r.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${r.join(", ")}`)};var le=e=>structuredClone(we(e)?pr(e):e),se=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Tt=e=>e?.animations?.playback?.continuity==="persistent",X=(e,r)=>se(e??{},r)&&e[r]!==void 0,ey=e=>e?.applyMode==="persistent",ry="default",ty=e=>Array.isArray(e?.channels)?e.channels.filter(ey).map(le):[],Nt=(e,r)=>e?!r(e)&&e.animations?{animationsOnly:!0,state:{animations:le(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},ny=e=>X(e,"opacity")||X(e,"blur"),To=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Ol=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],_o=["animationName","animationSpeed","loop"],sy=e=>X(e,"transformId")||X(e,"transform")||To.some(r=>X(e,r)),Rl=e=>e?.text&&X(e.text,"content")&&X(e.text,"textStyleId"),Cl=e=>e?.layout&&Array.isArray(e.layout.elements),oy=e=>X(e,"text")||X(e,"layout"),kl=(e,r)=>e.resourceId?!0:Rl(e)?!r?.text:Cl(e)?!r?.layout:!1,vl=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,iy=(e,r)=>{let n={...le(e),...r};if(r.text&&e.text&&(n.text={...le(e.text),...le(r.text)}),r.transform&&e.transform&&(n.transform={...le(e.transform),...le(r.transform)}),X(r,"transform")){delete n.transformId;for(let o of To)X(r,o)||delete n[o]}else X(r,"transformId")&&delete n.transform;return n},ay=(e,r)=>{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(X(e,"text")&&!Rl(e)&&!r?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(X(e,"layout")&&!Cl(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Al=e=>Ol.some(r=>X(e,r)),Pl=e=>_o.some(r=>X(e,r)),ly=(e,r,{hasAuthoredTransformId:n=!1}={})=>{if(!r)return e;for(let o of Ol)!n&&!X(e,o)&&X(r,o)&&(e[o]=r[o]),se(e,o)&&e[o]===void 0&&delete e[o];return e},$l=(e,r,n)=>{let o=e[n];return o?.id===r?.id?o:e.find(a=>a.id===r?.id)},cy=(e,r)=>{if(!r)return e;for(let n of To)!X(e,n)&&X(r,n)&&(e[n]=r[n]),se(e,n)&&e[n]===void 0&&delete e[n];return e},uy=(e,r)=>(r&&(!X(e,"opacity")&&X(r,"opacity")&&(e.opacity=r.opacity),!X(e,"blur")&&X(r,"blur")&&(e.blur=le(r.blur)),se(e,"opacity")&&e.opacity===void 0&&delete e.opacity,se(e,"blur")&&e.blur===void 0&&delete e.blur),e),_l=(e,r,n=[],{hasPatchFn:o=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let t=e.map((s,i)=>{let l=$l(n,s,i),c=r(s,l),u=ny(s),p=sy(s),f=o(s),d=se(s,"animations"),m=le(s);if(!c&&(u||p||f)&&l&&(m=a?a(l,m):{...le(l),...m}),!d){let y=l?r(l):!1,g=r(m);y&&g&&Tt(l)?m.animations=le(l.animations):delete m.animations}return uy(cy(m,l),l)}).filter(s=>r(s)||s.animations);return{hasValidItems:t.length>0,processedItems:t}},py=e=>{if(e){if(e.character&&se(e.character,"name"))return e.character.name;if(se(e,"characterName"))return e.characterName}},Tl=e=>!!e?.character&&se(e.character,"sprite"),dy=e=>{let r={},n=!1,o=py(e);return o!==void 0&&(r.name=o,n=!0),Tl(e)&&(r.sprite=le(e.character.sprite),n=!0),n?r:void 0},xl=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},El=({dialogueState:e,dialogueAction:r,persistCharacter:n})=>se(r,"persistSprite")?r.persistSprite===!0:se(e,"persistSprite")?e.persistSprite===!0:n&&!se(r,"characterId"),Sl=({previousCharacter:e,characterFields:r,hasCharacterId:n,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:t,isAppendingAdvDialogueContent:s})=>{let i={},l=e??{},c=r??{},u=s&&!n,p=u&&!t;return se(c,"name")?i.name=c.name:(o&&!n||u)&&se(l,"name")&&(i.name=le(l.name)),se(c,"sprite")?i.sprite=le(c.sprite):(a||p)&&se(l,"sprite")&&(i.sprite=le(l.sprite)),Object.keys(i).length>0?i:void 0},fy=({dialogueState:e,content:r,append:n=!1})=>{if(!n||!Array.isArray(r)){e.content=r,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>le(a)):delete e.initialRevealedContent,e.content=[...o,...r]},my=()=>({}),yy=(e,r)=>{if(!r.screen)return;let n=X(r.screen,"opacity"),o=X(r.screen,"blur"),a=se(r.screen,"animations");if(!n&&!o){a||delete e.screen;return}let t=e.screen,s={};if(n?s.opacity=r.screen.opacity:X(t,"opacity")&&(s.opacity=t.opacity),o?s.blur=le(r.screen.blur):X(t,"blur")&&(s.blur=le(t.blur)),se(s,"opacity")&&s.opacity===void 0&&delete s.opacity,se(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},hy=(e,r)=>{if(r.background){let n=X(r.background,"resourceId"),o=X(r.background,"colorId"),a=X(r.background,"opacity"),t=X(r.background,"blur"),s=X(r.background,"transformId"),i=Al(r.background),l=Pl(r.background),{animationsOnly:c,state:u}=Nt(r.background,d=>X(d,"resourceId")||X(d,"colorId")||X(d,"opacity")||X(d,"blur")||X(d,"transformId")||Al(d)||Pl(d));if(c){e.background=e.background?{...le(e.background),...u}:u;return}if(!n&&!o&&!a&&!t&&!s&&!i&&!l){delete e.background;return}let p=e.background,f=le(r.background);if(!n&&p?.resourceId){f.resourceId=p.resourceId,!se(f,"transformId")&&p.transformId&&(f.transformId=p.transformId);for(let d of _o)!X(f,d)&&X(p,d)&&(f[d]=p[d])}ly(f,p,{hasAuthoredTransformId:s}),!o&&p?.colorId&&(f.colorId=p.colorId),!a&&X(p,"opacity")&&(f.opacity=p.opacity),!t&&X(p,"blur")&&(f.blur=le(p.blur)),se(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,se(f,"colorId")&&f.colorId===void 0&&delete f.colorId,se(f,"animations")&&f.animations===void 0&&delete f.animations,se(f,"transformId")&&f.transformId===void 0&&delete f.transformId,se(f,"opacity")&&f.opacity===void 0&&delete f.opacity,se(f,"blur")&&f.blur===void 0&&delete f.blur;for(let d of _o)se(f,d)&&f[d]===void 0&&delete f[d];if(!f.resourceId&&!f.colorId){delete e.background;return}p?.resourceId===f.resourceId&&p?.transformId===f.transformId&&!se(f,"animations")&&Tt(p)&&(f.animations=le(p.animations)),e.background=f}else e.background?.animations&&!Tt(e.background)&&(e.background.animations={})},gy=(e,r)=>{if(!r.dialogue){if(e.dialogue&&(xl(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=El({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=Sl({previousCharacter:e.dialogue.character,characterFields:{},hasCharacterId:!1,persistCharacter:u,persistSprite:p,hasExplicitPersistSprite:!1,isAppendingAdvDialogueContent:!1}),e.dialogue.character||delete e.dialogue.character}return}e.dialogue||(e.dialogue={});let n=e.dialogue.mode;if(r.dialogue.ui){let{animationsOnly:u,state:p}=Nt(r.dialogue.ui,f=>!!f.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...r.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});r.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),r.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=r.dialogue.append===!0&&n!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(r.dialogue.content);r.dialogue.content!==void 0&&fy({dialogueState:e.dialogue,content:r.dialogue.content,append:o}),se(r.dialogue,"textSpeed")?e.dialogue.textSpeed=r.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=se(r.dialogue,"persistCharacter")?r.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let t=El({dialogueState:e.dialogue,dialogueAction:r.dialogue,persistCharacter:a});se(r.dialogue,"persistSprite")&&(e.dialogue.persistSprite=t);let s=se(r.dialogue,"characterId"),i=dy(r.dialogue),l=Tl(r.dialogue);s?r.dialogue.characterId?e.dialogue.characterId=r.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=Sl({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:t,hasExplicitPersistSprite:se(r.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||xl(e.dialogue),r.dialogue.clear){delete e.dialogue;return}if(r.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&r.dialogue.content!==void 0){let u={content:r.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=le(e.dialogue.character)),e.dialogue.lines.push(u)}},by=(e,r)=>{let n=ty(e.sfx);if(!r.sfx){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(Array.isArray(r.sfx.items)){let t=n.filter(s=>s.id!==ry);if(r.sfx.items.length===0){if(t.length>0){e.sfx={channels:t};return}delete e.sfx;return}e.sfx=le(r.sfx),t.length>0&&(e.sfx.channels=t);return}if(!Array.isArray(r.sfx.channels)){if(n.length>0){e.sfx={channels:n};return}delete e.sfx;return}if(r.sfx.channels.length===0){delete e.sfx;return}let o=new Set(r.sfx.channels.map(t=>t.id)),a=n.filter(t=>!o.has(t.id));for(let t of r.sfx.channels)Array.isArray(t.sounds)&&t.sounds.length>0&&a.push(le(t));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Iy=(e,r)=>{if(r.bgm){let n=Array.isArray(r.bgm.sounds);if(!r.bgm.resourceId&&!n||n&&r.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=le(r.bgm),r.bgm.resourceId&&(e.bgm.loop=r.bgm.loop??!0)}},wy=(e,r)=>{if(r.visual){let n=e.visual?.items||[];r.visual.items?.forEach((t,s)=>{ay(t,$l(n,t,s))});let{hasValidItems:o,processedItems:a}=_l(r.visual.items,kl,n,{hasPatchFn:oy,mergeItemFn:iy});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!kl(n)||!Tt(n))?{...n,animations:{}}:n))},ky=(e,r)=>{if(!r.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!vl(a)||!Tt(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=_l(r.character.items,vl,e.character?.items||[]);n?e.character={items:o}:delete e.character},vy=(e,r)=>{r.animation?e.animation=r.animation:e.animation&&delete e.animation},Ay=(e,r)=>{if(r.layout){let{animationsOnly:n,state:o}=Nt(r.layout,a=>!!a.resourceId);if(n){e.layout=o;return}if(!r.layout.resourceId){delete e.layout;return}e.layout=r.layout}else e.layout&&delete e.layout},Py=(e,r)=>{if(r.choice){let{animationsOnly:n,state:o}=Nt(r.choice,a=>!!a.resourceId);if(n){e.choice={...e.choice,...o};return}if(!r.choice.resourceId){delete e.choice;return}e.choice=r.choice}else e.choice&&delete e.choice},xy=(e,r)=>{if(r.form){let{animationsOnly:n,state:o}=Nt(r.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!r.form.resourceId){delete e.form;return}e.form=le(r.form)}else e.form&&delete e.form},Ey=(e,r)=>{if(r.control){if(!r.control.resourceId){delete e.control;return}e.control=r.control}},Sy=(e,r)=>{if(r.voice){let n=Array.isArray(r.voice.sounds);if(!r.voice.resourceId&&!n||n&&r.voice.sounds.length===0){delete e.voice;return}e.voice=le(r.voice)}else e.voice&&delete e.voice},Oy=(e,r)=>{r.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Mr=e=>En(my,[Oy,yy,hy,by,Iy,wy,gy,ky,vy,Ay,Py,xy,Ey,Sy])(e);var et=(e,r)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Nr(e,r);return n&&typeof n=="object"?e:n};var Ry=Object.freeze({dialogueTextSpeed:{source:"global.dialogueTextSpeed"},autoForwardDelay:{source:"global.autoForwardDelay"},autoForwardSpeed:{source:"global.autoForwardSpeed"},skipUnseenText:{source:"global.skipUnseenText"},skipTransitionsAndAnimations:{source:"global.skipTransitionsAndAnimations"},soundVolume:{source:"global.soundVolume"},musicVolume:{source:"global.musicVolume"},muteAll:{source:"global.muteAll"},localizationPackageId:{source:"global.localizationPackageId"},saveLoadPagination:{source:"context.runtime.saveLoadPagination"},menuPage:{source:"context.runtime.menuPage"},menuEntryPoint:{source:"context.runtime.menuEntryPoint"},autoMode:{source:"global.autoMode"},skipMode:{source:"global.skipMode"},dialogueUIHidden:{source:"global.dialogueUIHidden"},isLineCompleted:{source:"global.isLineCompleted"}}),hr=Object.freeze({dialogueTextSpeed:50,autoForwardDelay:1e3,autoForwardSpeed:50,skipUnseenText:!1,skipTransitionsAndAnimations:!1,soundVolume:50,musicVolume:50,muteAll:!1,localizationPackageId:null,autoMode:!1,skipMode:!1,dialogueUIHidden:!1,isLineCompleted:!1}),jt=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),Cy=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"}),No=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Nl=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),jo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),jl=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$y=(e,r)=>{let n=Cy[e];if(n==="number"){if(typeof r!="number"||!Number.isFinite(r))throw new Error(`${e} requires a finite numeric value`);return}if(n==="boolean"){if(typeof r!="boolean")throw new Error(`${e} requires a boolean value`);return}if(n==="string"){if(typeof r!="string")throw new Error(`${e} requires a string value`);return}if(n==="nullableString"){if(r!==null&&typeof r!="string")throw new Error(`${e} requires a string or null value`);return}throw new Error(`Unsupported runtime field "${e}"`)},Dn=(e,r)=>{if($y(e,r),e==="autoForwardDelay"&&r<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(r<0||r>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(r)):r},Do=(e={})=>{let r=e?.config;if(r===void 0)return{...hr};if(!jl(r))throw new Error("projectData.config must be an object");let n=Object.keys(r).find(i=>i!=="runtimeDefaults");if(n)throw new Error(`projectData.config contains unsupported field "${n}"`);let o=r.runtimeDefaults;if(o===void 0)return{...hr};if(!jl(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Nl),t=Object.keys(o).find(i=>!a.has(i));if(t)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${t}"`);let s={...hr};return Nl.forEach(i=>{o[i]!==void 0&&(s[i]=Dn(i,o[i]))}),s},_y=(e,r)=>{if(r.startsWith("global.")){let n=r.slice(7);return e?.global?.[n]}if(r.startsWith("context.runtime.")){let n=r.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[n]}},gr=e=>Object.fromEntries(Object.entries(Ry).map(([r,n])=>{let o=_y(e,n.source),a=o!==void 0?o:hr[r]??jt[r];return[r,a]})),We=(e,r)=>gr(e)[r],Dl=(e={})=>Object.fromEntries(No.map(r=>[r,e[r]??hr[r]]));var rt=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}),nr=Object.freeze({BEHIND_BACKGROUND:rt.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:rt.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:rt.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:rt.VISUAL_BEHIND_CHOICE,FOREGROUND:rt.VISUAL_FOREGROUND}),Lo=nr.BEHIND_DIALOGUE,Mo=Object.freeze(Object.values(nr).sort((e,r)=>e-r));var Ty={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([r,n])=>({id:r,...n})),formatDate:So},Ny=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Dt=e=>Array.isArray(e)?e.map(r=>{if(!r||typeof r!="object"||Array.isArray(r)||Object.keys(r).length!==1)return Dt(r);let[n]=Object.keys(r),o=Ny.exec(n);if(!o)return Dt(r);let[,a,t,s]=o,i=`$for ${a}${t?`, ${t}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(r[n])?r[n]:[];return{[i]:Dt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Dt(n)])),sr=(e,r)=>{let n={functions:Ty};return Nr(Dt(e),r,n)},ri=({animationType:e,animationId:r,animationPath:n})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${n}] Animation "${r}" has unsupported type "${e}". Use "update" or "transition".`)},jy=({id:e,targetId:r,animation:n,playback:o,animationPath:a="animation"})=>{let t=structuredClone(n);if(ri({animationType:t.type,animationId:e,animationPath:a}),delete t.name,delete t.playback,t.id=e,t.targetId=r,o!==void 0){let s=Vy(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?Ql(t):null;if(s.loop===!0&&t.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(s.loop===!0&&t.complete!==void 0)throw new Error(`[${a}.playback] animation.complete is not allowed when playback.loop is true because a loop never completes.`);if(s.loop===!0&&(!Number.isFinite(i)||i<=0))throw new Error(`[${a}.playback] playback.loop requires an animation with a finite duration greater than 0.`);t.playback=s}}return t},Dy=(e,{animationId:r="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return ri({animationType:e.type,animationId:r,animationPath:n}),e.type},Ly=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},My=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Vy=(e,r="animation.playback")=>{if(e===void 0)return;if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`[${r}] playback must be an object.`);if(e.continuity!==void 0&&e.continuity!=="render"&&e.continuity!=="persistent")throw new Error(`[${r}] playback.continuity must be "render" or "persistent".`);if(e.speed!==void 0&&(typeof e.speed!="number"||!Number.isFinite(e.speed)||e.speed<=0))throw new Error(`[${r}] playback.speed must be a finite number greater than 0.`);if(e.loop!==void 0&&typeof e.loop!="boolean")throw new Error(`[${r}] playback.loop must be a boolean.`);let n={};return e.continuity!==void 0&&(n.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(n.speed=e.speed),e.loop===!0&&(n.loop=!0),Object.keys(n).length>0?n:void 0},qy=e=>{let r=e?.playback?.speed;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:1},br=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Wl=e=>e?.playback?.continuity==="persistent",Go=e=>Array.isArray(e)?e.map(Go):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((r,n)=>(r[n]=Go(e[n]),r),{}),qn=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let r=structuredClone(e);return r.playback&&(delete r.playback.continuity,r.playback.speed===1&&delete r.playback.speed,Object.keys(r.playback).length===0&&delete r.playback),JSON.stringify(Go(r))},Kl=(e=[])=>e.filter(r=>Wl(r)).map(r=>structuredClone(r)),Jl=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((r,n)=>{let o=typeof n?.duration=="number"&&Number.isFinite(n.duration)?n.duration:0;return r+o},0):0,Vo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((r,n)=>Math.max(r,Jl(n)),0),Ql=e=>Math.max(Vo(e?.tween),Vo(e?.prev?.tween),Vo(e?.next?.tween),Jl(e?.mask?.progress)),Zl=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Ql(e)/qy(e),Fy=e=>e.some(r=>r?.playback?.loop===!0),Ll=({animationInstances:e,activePersistentAnimations:r})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(r)||r.length===0)return!1;let n=new Set(r.map(qn).filter(Boolean));return e.some(o=>{if(!Wl(o))return!1;let a=qn(o);return a?n.has(a):!1})},Ye=({animationInstances:e,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:t=!0})=>!Array.isArray(e)||e.length===0||n?!1:Fy(e)||t&&!r||Ll({animationInstances:e,activePersistentAnimations:o})?!0:t?!1:Ll({animationInstances:e,activePersistentAnimations:a}),ec=(e,r,n,o,a)=>{if(e===void 0)return!0;let t=a.slice(0,o).filter(i=>i?.id===n).length,s=e?.[r]?.items?.filter(i=>i?.id===n).at(t);return br(s??{},"animations")},Uy=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(r=>e[r]!==void 0),By=(e,r)=>{if(Uy(e))throw new Error(`[${r}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},Yy=({resources:e,animationId:r,playback:n,instanceId:o,targetId:a,animationPath:t="animation"})=>{if(!r||!a)return!1;let s=e?.animations?.[r];return s?jy({id:o,targetId:a,animation:s,playback:n,animationPath:t}):null},zy=(e,{defaultTargetId:r,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return ri({animationType:a.type,animationId:a.id??n,animationPath:o}),a.id??=n,a.targetId??=r,a},ti=({animations:e,transitions:r,defaultTargetId:n,idPrefix:o,animationPathPrefix:a=o})=>{r.forEach((t,s)=>{e.push(zy(t,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},Ho=(e,r)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${r} must be an array of objects`);return e},Gy=({content:e,path:r,variables:n})=>Ho(e,r).reduce((o,a)=>{let t=et(a.text,{variables:n});return o+`${t??""}`.length},0),Ml=(e=[])=>{let r=new Map;for(let n of e)n?.id&&r.set(n.id,(r.get(n.id)??0)+1);return new Set(Array.from(r.entries()).filter(([,n])=>n>1).map(([n])=>n))},Ln=(e,r=0,n=new Set)=>{if(!n.has(e?.id))return`character-container-${e.id}`;let o=e?.sprites?.map(({resourceId:a})=>a)||[];return o.length===0?`character-container-${e.id}`:`character-container-${e.id}-${r}-${o.join("-")}`},nt=(e,r)=>{if(r.transformId&&r.transform)throw new Error(`Visual item "${r.id}" cannot define both transformId and transform`);if(r.transform)return r.transform;if(!r.transformId)throw new Error(`Visual item "${r.id}" requires transformId or transform`);let n=e.transforms?.[r.transformId];if(!n)throw new Error(`Transform "${r.transformId}" not found for visual item "${r.id}"`);return n},Hy=(e,r={})=>{if(!r?.transformId)return;let n=e.transforms?.[r.transformId];if(!n)throw new Error(`Transform "${r.transformId}" not found for background`);return n},Xy=["x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY"],Wy=(e={})=>Xy.some(r=>br(e,r)),rc=(e={},r)=>{if(r){if(e.images?.[r])return"sprite";if(e.videos?.[r])return"video";if(e.spritesheets?.[r])return"spritesheet-animation";if(e.layouts?.[r])return"container"}},Vn=({resourceId:e,kind:r})=>{if(e)return r?`bg-cg-background-${r}`:`bg-cg-${e}`},Ky=(e={})=>e.textStyles||{},Jy=(e={})=>e.images||{},Qy=.5,Zy=(e={},r,n)=>{if(r){if(!e.animations?.[r])throw new Error(`Animation '${r}' not found in spritesheet resource '${n}'`);return r}return Object.keys(e.animations??{})[0]},ni=({id:e,resourceId:r,spritesheet:n,animationName:o,animationSpeed:a,loop:t,width:s,height:i,transform:l={}}={})=>{let c=Zy(n,o,r),u=c?n.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${r}`);return}return{id:e,type:"spritesheet-animation",...l,width:s??n.width,height:i??n.height,src:n.fileId,atlas:n.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Qy,loop:t??u.loop??!0}}},tc=({id:e,item:r,resources:n={}}={})=>{let o=n.images?.[r.resourceId];if(o)return{type:"sprite",id:e,src:o.fileId,width:o.width,height:o.height,x:0,y:0};let a=n.spritesheets?.[r.resourceId];if(a)return ni({id:e,resourceId:r.resourceId,spritesheet:a,animationName:r.animationName,animationSpeed:r.animationSpeed,loop:r.loop,transform:{x:0,y:0}});console.warn(`Character sprite resource not found: ${r.resourceId}`)},eh=(e={})=>e.colors||{},rh=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,Mt=(e,r)=>e==="root"?`${r}`:`${e}.${r}`,st=(e,r,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${r}" must resolve to a non-empty string`)},qo=(e,r,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${r} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${r} for text style "${n}" must be a number between 0 and 1`);return e},Fo=(e,r,n,o,{minimum:a}={})=>{if(e===void 0)return o;if(typeof e!="number"||!Number.isFinite(e)||a!==void 0&&e<a){let t=a===void 0?"a finite number":`a finite number >= ${a}`;throw new Error(`shadow.${r} for text style "${n}" must be ${t}`)}return e},Bn=(e,r)=>{if(typeof e!="string"||!rh.test(e))throw new Error(`${r} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(n=>n.repeat(2)).join("")}`:e},Vl=(e,r,n)=>{let o=Bn(e,n);if(r===1)return o;let a=Number.parseInt(o.slice(1,3),16),t=Number.parseInt(o.slice(3,5),16),s=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${t}, ${s}, ${r})`},th=(e={},r)=>{let n=Ky(e)?.[r];if(!n)throw new Error(`Text style "${r}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${r}"`);return c.fileId}),t=e.colors?.[n.colorId];if(!t)throw new Error(`Color "${n.colorId}" not found for text style "${r}"`);let s=qo(n.colorAlpha,"colorAlpha",r),i={fontFamily:Array.isArray(n.fontId)?a.join(", "):a[0],fontSize:n.fontSize??16,fontWeight:n.fontWeight??"400",fontStyle:n.fontStyle??"normal",lineHeight:n.lineHeight??1.2,fill:Vl(t.hex,s,`Color "${n.colorId}" for text style "${r}"`)};if(n.align!==void 0&&(i.align=n.align),n.wordWrap!==void 0&&(i.wordWrap=n.wordWrap),n.breakWords!==void 0&&(i.breakWords=n.breakWords),n.wordWrapWidth!==void 0&&(i.wordWrapWidth=n.wordWrapWidth),n.strokeColorId){let l=e.colors?.[n.strokeColorId];if(!l)throw new Error(`Stroke color "${n.strokeColorId}" not found for text style "${r}"`);let c=qo(n.strokeAlpha,"strokeAlpha",r);i.strokeColor=Vl(l.hex,c,`Stroke color "${n.strokeColorId}" for text style "${r}"`)}else if(n.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${r}" requires strokeColorId`);if(n.strokeWidth!==void 0&&(i.strokeWidth=n.strokeWidth),n.shadow!==void 0){let l=e.colors?.[n.shadow.colorId];if(!l)throw new Error(`Shadow color "${n.shadow.colorId}" not found for text style "${r}"`);i.shadow={color:Bn(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${r}"`),alpha:qo(n.shadow.alpha,"shadow.alpha",r),blur:Fo(n.shadow.blur,"blur",r,0,{minimum:0}),offsetX:Fo(n.shadow.offsetX,"offsetX",r,2),offsetY:Fo(n.shadow.offsetY,"offsetY",r,2)}}return i},Xo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>Xo(a,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let o={};for(let[a,t]of Object.entries(e))a!=="textStyleId"&&(o[a]=Xo(t,r,Mt(n,a)));return e.textStyleId!==void 0&&(st(e.textStyleId,n,"textStyleId"),o.textStyle=th(r,e.textStyleId)),o},si=(e={},r)=>{let n=eh(e)?.[r];if(!n)throw new Error(`Color "${r}" not found`);return Bn(n.hex,`Color "${r}"`)},nc=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",Uo=(e,r,n)=>{let o=e?.[r];if(!(!o||typeof o!="object"||Array.isArray(o))&&Object.prototype.hasOwnProperty.call(o,"fill"))throw new Error(`Inline ${r}.fill is not allowed in rect layout elements at "${n}". Use ${nc(`${r}.fill`)} instead`)},nh=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>Vt(a,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,t]of Object.entries(e))a!=="colorId"&&(o[a]=Vt(t,r,Mt(n,a)));return e.colorId!==void 0&&(st(e.colorId,n,"colorId"),o.fill=si(r,e.colorId)),o},Vt=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>Vt(a,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;if(e.type==="rect"){if(Object.prototype.hasOwnProperty.call(e,"fill"))throw new Error(`Inline fill is not allowed in rect layout elements at "${n}". Use ${nc("fill")} instead`);Uo(e,"hover",n),Uo(e,"click",n),Uo(e,"rightClick",n)}let o={};for(let[a,t]of Object.entries(e))if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=nh(t,r,Mt(n,a));continue}o[a]=Vt(t,r,Mt(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(st(e.colorId,n,"colorId"),o.fill=si(r,e.colorId)),o},Bo=(e={},r)=>{let n=Jy(e)?.[r];return n||null},sc=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",ql=(e,r,n,o)=>{let a=e?.[r];if(!(!a||typeof a!="object"||Array.isArray(a))&&Object.prototype.hasOwnProperty.call(a,o))throw new Error(`Inline ${r}.${o} is not allowed in sprite layout elements at "${n}". Use ${sc(`${r}.${o}`)} instead`)},Fl=(e,r,n)=>{let o=e[r];e[r]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},Wo=(e,r={},n="root")=>{if(Array.isArray(e))return e.map((a,t)=>Wo(a,r,`${n}[${t}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${sc(a)} instead`);ql(e,"hover",n,"src"),ql(e,"click",n,"src")}let o={};for(let[a,t]of Object.entries(e))e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=Wo(t,r,Mt(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){st(e.imageId,n,"imageId");let a=Bo(r,e.imageId),t=a?.fileId??e.imageId;o.src=t,o.width===void 0&&a?.width!==void 0&&(o.width=a.width),o.height===void 0&&a?.height!==void 0&&(o.height=a.height)}return e.type==="sprite"&&e.hoverImageId!==void 0&&(st(e.hoverImageId,n,"hoverImageId"),Fl(o,"hover",Bo(r,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(st(e.clickImageId,n,"clickImageId"),Fl(o,"click",Bo(r,e.clickImageId)?.fileId??e.clickImageId)),o},oi=(e,r={},n="root")=>Wo(Vt(Xo(e,r,n),r,n),r,n),or=oi,qr=(e=[])=>e.find(r=>r.id==="story"),sh="#000000",Ko="bg-cg-background-color",oh=({resources:e={},background:r={},screen:n})=>r?.colorId===void 0?Bn(n?.backgroundColor??sh,"screen.backgroundColor"):si(e,r.colorId),oc=(e={})=>{if(br(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},ih=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Ul=(e={},{includeDefaultAlpha:r=!1}={})=>{let n=oc(e),o=ih(e),a={};return(r||n!==void 0)&&(a.alpha=n??1),o&&(a.blur=o),a},ah=(e={})=>{if(br(e,"opacity"))return typeof e.opacity=="number"?e.opacity:void 0},lh=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},ic=(e={})=>{let r=ah(e),n=lh(e),o={};return r!==void 0&&(o.alpha=r),n&&(o.blur=n),o},Vr=(e={})=>ic(e),Ke=(e={},r={})=>{let n={x:r.x??e.x,y:r.y??e.y,anchorX:r.anchorX??e.anchorX,anchorY:r.anchorY??e.anchorY,rotation:r.rotation??e.rotation,scaleX:r.scaleX??e.scaleX,scaleY:r.scaleY??e.scaleY},o=r.originX??e.originX,a=r.originY??e.originY;return o!==void 0&&(n.originX=o),a!==void 0&&(n.originY=a),n},ch=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","rotation","originX","originY","layer","opacity","blur","animations"],ii=(e={})=>e.text&&br(e.text,"content")&&br(e.text,"textStyleId"),ai=(e={})=>e.layout&&Array.isArray(e.layout.elements),Bl=(e={})=>{if(e.resourceId)return e.resourceId;if(ii(e))return"text";if(ai(e))return"inline-layout"},Yl=(e,r={})=>typeof e=="string"?r.images?.[e]?.fileId??e:!e||typeof e!="object"||Array.isArray(e)?e:e.imageId?r.images?.[e.imageId]?.fileId??e.imageId:Array.isArray(e.items)?{...e,items:e.items.map(n=>{if(typeof n=="string")return r.images?.[n]?.fileId??n;if(!n||typeof n!="object"||Array.isArray(n))return n;if(n.imageId){let{imageId:o,...a}=n;return{...a,src:r.images?.[o]?.fileId??o}}return typeof n.src=="string"?{...n,src:r.images?.[n.src]?.fileId??n.src}:n})}:e,uh=({item:e,particle:r,resources:n})=>{let o=nt(n,e),a=structuredClone(r),t=a.modules?.appearance?.texture;t!==void 0&&(a.modules.appearance.texture=Yl(t,n)),a.texture!==void 0&&(a.texture=Yl(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...Ke(o,e)};return Object.assign(s,Vr(e)),s},ph=e=>{let r=[e.resourceId,e.text,e.layout].filter(n=>n!==void 0).length;if(r>1)throw r===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&&!ii(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!ai(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of ch)if(br(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},dh=({resources:e,background:r,screen:n={width:1920,height:1080},includeOpacity:o=!1})=>{let a={id:Ko,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:oh({resources:e,background:r,screen:n})};if(o){let t=oc(r);t!==void 0&&(a.alpha=t)}return a},fh=(e={},r)=>r?!!(e.images?.[r]||e.videos?.[r]||e.spritesheets?.[r]||e.layouts?.[r]):!1,zl=({resources:e={},resourceId:r,colorId:n})=>{let o=rc(e,r);return r&&(o||n===void 0)?{resourceId:r,targetId:Vn({resourceId:r,kind:o})}:n!==void 0?{resourceId:Ko,targetId:Ko}:{resourceId:void 0,targetId:void 0}},ac=100,Ir=ac,mh="channel:bgm",yh="channel:music-room",hh="music-room:player",gh="channel:voice",bh="default",Ih=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Lt=(...e)=>e.map(Ih).join(":"),Fn=(e,r,n)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let t=n?` in ${n}`:"";throw new Error(`Duplicate ${r} id "${a}"${t}.`)}o.add(a)})},wh=(e,r)=>e*r/ac,lc=(e={},r)=>e?.[r]??hr[r],Yn=(e={},r,n=Ir)=>wh(n,lc(e,r)),zn=({id:e,volume:r,muted:n,pan:o,loop:a,playback:t,interruption:s,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:r,muted:!!l?.muteAll||(n??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),t!==void 0&&(c.playback=structuredClone(t)),s!==void 0&&(c.interruption=s),c},Mn=(e,r,n,o)=>e[n]!==void 0?e[n]:r[n]!==void 0?r[n]:o,kh=["muted","pan","playbackRate","startAt","endAt"],Gn=({id:e,sound:r,resource:n,defaultLoop:o=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:Mn(r,n,"loop",o),volume:Mn(r,n,"volume",Ir),startDelayMs:Mn(r,n,"startDelayMs",0)};kh.forEach(s=>{let i=Mn(r,n,s,void 0);i!==void 0&&(a[s]=i)}),r.playback!==void 0&&(a.playback=structuredClone(r.playback));let t=a.startAt??0;if(a.endAt!==void 0&&a.endAt!==null&&a.endAt<t)throw new Error(`Sound "${e}" endAt (${a.endAt}) must be greater than or equal to startAt (${t}).`);return a},Fe=({variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,runtime:a,saveSlots:t=[],dialogueState:s,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,confirmDialog:m,form:y,historyDialogue:g=[],characters:h={},dialogueUIHidden:w,skipOnlyViewedLines:b,skipTransitionsAndAnimations:E}={})=>{let v={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},P=Eh({dialogueState:s,includeInactiveAdvDialogue:i,characters:h,variables:e,runtime:v}),k={variables:e,imageGallery:r,musicRoom:n,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:v.localizationPackageId,runtime:v,saveSlots:t,isChoiceVisible:p,isFormVisible:f,canRollback:d,confirmDialog:m,form:y,historyDialogue:g,characters:h};return P&&(k.dialogue=P,k.dialogueLines=P.lines),k},Gl=100,Un=(e,r)=>{if(Array.isArray(e))return e.map(o=>Un(o,r));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=Un(n[o],r)}),n.type==="text-revealing"?r(n):n},vh=e=>Un(e,r=>({...r,revealEffect:"none"})),Ah=e=>Un(e,r=>{let n=Number(r.speed??r.displaySpeed),o=Number.isFinite(n)?Math.max(n,Gl):Gl;return{...r,speed:o,...Object.prototype.hasOwnProperty.call(r,"displaySpeed")?{displaySpeed:o}:{}}}),wr=(e,{isLineCompleted:r=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>r||o?vh(e):n?Ah(e):e,cc=({id:e,screen:r={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:r.width,height:r.height,x:0,y:0,click:{payload:{actions:{}}}}),Jo=e=>{if(Array.isArray(e))return e.map(Jo);if(!e||typeof e!="object")return e;let r={};for(let[t,s]of Object.entries(e))r[t]=Jo(s);let n=r.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return r;let o=n.actions,a=o&&typeof o=="object"&&!Array.isArray(o)&&Object.prototype.hasOwnProperty.call(o,"nextLine")?{...o.nextLine,bypassChoice:!0}:void 0;return{...r,click:{...r.click,payload:{...n,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},Ph=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Hl="submit",Yo=(e,r,n={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},t=n.replaceActions===!0?r:{...a,...r};return{...e||{},payload:{...o,actions:t}}},Qo=(e,r,n={})=>{if(Array.isArray(e))return e.map(c=>Qo(c,r,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===Hl,t=o&&n.submitRoleAncestor,s=a||t?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Qo(u,r,c==="children"?s:{});let l=i;if(l.type==="input"&&typeof l.field=="string"){let c=r?.fields?.[l.field];if(c){let u={updateFormField:{formKey:r.key,field:c.id,value:"_event.value"}};l={...l,value:c.value,placeholder:l.placeholder===void 0?c.placeholder:l.placeholder,multiline:l.multiline===void 0?c.multiline:l.multiline,...l.maxLength===void 0&&c.maxLength!==void 0?{maxLength:c.maxLength}:{},change:Yo(l.change,u),submit:Yo(l.submit,r.submitActions)}}}return l.formRole===Hl||t?{...l,click:Yo(l.click,r.submitActions,{replaceActions:!0})}:l},Zo=(e,r)=>{if(Array.isArray(e))return e.map(o=>Zo(o,r));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=Zo(a,r);for(let o of Ph){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},ei=({characterId:e,character:r,characterName:n,characters:o={},variables:a={}}={})=>{let t=e?o?.[e]:void 0,s=Sn({characterId:e,character:r,characterName:n,characters:o,variables:a});return{...t||{},...r||{},name:s}},uc=(e=[],r={},n={})=>e.map(o=>{let a=ei({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:r,variables:n}),t=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(s=>s?.text??"").join(""):"";return{...o,text:t,character:a,characterName:a.name}}),xh=e=>!(!e||e.mode==="adv"&&e.content===void 0),Eh=({dialogueState:e,includeInactiveAdvDialogue:r=!1,characters:n={},variables:o,runtime:a}={})=>{if(!r&&!xh(e))return;let t=e.content===void 0?[{text:""}]:Ho(e.content,"dialogue.content"),s=e.content===void 0?0:Gy({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??hr.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,f)=>{let d=Ho(p.content,`dialogue.lines[${f}].content`),m=ei({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:d.map(y=>({...y,text:et(y.text,{variables:o})})),character:m,characterName:m.name}}),u=ei({characterId:e.characterId,character:e.character,characters:n,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:t.map(p=>({...p,text:et(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},li=({container:e,resources:r,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:t=!1})=>{let s=sr(e,n);return or(wr(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:t}),r)},zo=(e,r={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(r),Xl=({renderStateKeyboard:e,keyboard:r,phase:n})=>{!r||typeof r!="object"||Array.isArray(r)||Object.entries(r).forEach(([o,a])=>{let t=e[o]??{},s=n==="keydown"?a?.keydown:a?.keyup;if(n==="keydown"&&s&&typeof s=="object"){e[o]={...t,keydown:{payload:zo(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:zo(a.keyup)});return}e[o]={...t,[n]:{payload:zo(a)}}})},Sh=(e={},r={})=>{let n={};return Xl({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Xl({renderStateKeyboard:n,keyboard:r,phase:"keyup"}),Object.keys(n).length>0?n:void 0},ir=({animationsDef:e,resources:r,previousResourceId:n,currentResourceId:o,previousTargetId:a,currentTargetId:t,animationPath:s,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:h,targetId:w})=>{let b=Yy({resources:r,animationId:d,playback:m,instanceId:h,targetId:w,animationPath:s});b&&l.push(b)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,f=a&&t&&a===t;By(e,s);let d=Ly(e),m=My(e),y=r?.animations?.[d],g=Dy(y,{animationId:d,animationPath:s});if(g==="update")return p&&t?c({instanceId:`${i}-animation-update`,targetId:t}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(g==="transition"){let h=`${i}-animation-transition`,w=m?.continuity==="persistent"?h:`${i}-animation-in`;if(u&&p&&f)return c({instanceId:h,targetId:t}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:t})}return l},Oh=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),Rh=(e,{presentationState:r,previousPresentationState:n,currentLineActions:o,resources:a={},screen:t={width:1920,height:1080},isLineCompleted:s,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:f,activePersistentAnimations:d,restoredPersistentAnimations:m,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,saveSlots:v=[]})=>{let{elements:P,animations:k}=e;if(r.background){let O=o===void 0?!0:br(o?.background??{},"animations"),D=P.find(oe=>oe.id==="story");if(!D)return e;let $=Hy(a,r.background),q=$||Wy(r.background),Y=n?.background?.resourceId,T=n?.background?.colorId,U=r.background.resourceId??(r.background.animations?Y:void 0),ie=r.background.colorId??(r.background.animations?T:void 0),L=fh(a,U),ae={...r.background,colorId:ie};if((ie!==void 0||L)&&D.children.push(dh({resources:a,background:ae,screen:t,includeOpacity:!L})),U){let{images:oe={},videos:re={},spritesheets:pe={}}=a,te=rc(a,U),C;if(te==="sprite"?C=oe[U]:te==="video"?C=re[U]:te==="spritesheet-animation"&&(C=pe[U]),C){let _=te==="video",F=te==="spritesheet-animation",K={x:(t?.width??1920)/2,y:(t?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...$},de={...Ul(r.background,{includeDefaultAlpha:!0}),...Ke(K,r.background)},Pe;F?Pe=ni({id:Vn({resourceId:U,kind:te}),resourceId:U,spritesheet:C,animationName:r.background.animationName,animationSpeed:r.background.animationSpeed,loop:r.background.loop,transform:de}):Pe={id:Vn({resourceId:U,kind:te}),type:_?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...de},_&&(Pe.loop=r.background.loop??!1,Pe.volume=C.volume??50),Pe&&D.children.push(Pe)}}if(U){let{layouts:oe={}}=a,re=oe[U];if(re){let pe={id:Vn({resourceId:U,kind:"container"}),type:"container",children:re.elements,...Ul(r.background)};q&&Object.assign(pe,Ke({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...$},r.background));let te=sr(pe,Fe({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:f,saveSlots:v,dialogueState:r.dialogue,isLineCompleted:s,autoMode:y,skipMode:g,isChoiceVisible:h,isFormVisible:w,canRollback:b,form:E,characters:a.characters||{},skipTransitionsAndAnimations:i}));D.children.push(or(wr(te,{isLineCompleted:s,skipMode:g,skipTransitionsAndAnimations:i}),a))}}let ue=zl({resources:a,resourceId:Y,colorId:T}),B=zl({resources:a,resourceId:U,colorId:ie}),Z=ir({animationsDef:r.background.animations,resources:a,previousResourceId:ue.resourceId,currentResourceId:B.resourceId,previousTargetId:ue.targetId,currentTargetId:B.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ye({animationInstances:Z,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:O})&&k.push(...Z)}return e},Ch=(e,{presentationState:r,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(r.character&&a){let p=c.find(g=>g.id==="story");if(!p)return e;let f=r.character.items||[],d=n?.character?.items||[],m=Ml(f),y=Ml(d);for(let g=0;g<f.length;g++){let h=f[g],{transformId:w,sprites:b}=h,E=d.find(U=>U.id===h.id),v=d.findIndex(U=>U.id===h.id),P=E?.sprites&&E.sprites.length>0,k=b&&b.length>0,O=v>=0?Ln(E,v,y):void 0,D=ec(o,"character",h.id,g,f),$=ir({animationsDef:h.animations,resources:a,previousResourceId:O,currentResourceId:k?Ln(h,g,m):void 0,previousTargetId:O,currentTargetId:k?Ln(h,g,m):void 0,animationPath:`character.items[${g}].animations`,idPrefix:"character"});if(h.animations&&!b&&!w&&P&&Ye({animationInstances:$,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:D})){u.push(...$);continue}if(h.animations&&!b&&!w)continue;if(!b||b.length===0||!w){console.warn("Character item missing sprites or transformId:",h);continue}let q=Ln(h,g,m),Y=a.transforms[w];if(!Y){console.warn("Transform not found:",w);continue}let T={type:"container",id:q,...Ke(Y,h),...Vr(h),children:[]};for(let U of b){let ie=tc({id:`${q}-${U.id}`,item:U,resources:a});ie&&T.children.push(ie)}p.children.push(T),Ye({animationInstances:$,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:D})&&u.push(...$)}}return e},pc=(e,r)=>{if(!Mo.includes(e))throw new Error(`${r} must be one of: ${Mo.join(", ")}.`)},$h=(e,r)=>{let n=!!e.resourceId||ii(e)||ai(e),o=e.layer??(n?void 0:r?.layer)??Lo;return pc(o,`Visual item "${e.id}" layer`),o},_h=(e,{presentationState:r,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:f,restoredPersistentAnimations:d,autoMode:m,skipMode:y,isChoiceVisible:g,isFormVisible:h,canRollback:w,form:b,saveSlots:E=[],visualLayer:v})=>{let{elements:P,animations:k}=e;if(r.visual&&a){let O=P.find(Y=>Y.id==="story");if(!O)return e;let D=r.visual.items,$=n?.visual?.items||[],q=Fe({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:E,dialogueState:r.dialogue,isLineCompleted:t,autoMode:m,skipMode:y,isChoiceVisible:g,isFormVisible:h,canRollback:w,form:b,characters:a.characters||{},skipTransitionsAndAnimations:s});v!==void 0&&pc(v,"visualLayer");for(let[Y,T]of D.entries()){let U=$.find(re=>re.id===T.id),ie=ec(o,"visual",T.id,Y,D),L=$h(T,U);if(v!==void 0&&L!==v)continue;if(ph(T),T.layout){let re=nt(a,T),pe={id:`visual-${T.id}`,type:"container",children:structuredClone(T.layout.elements),...Ke(re,T)};Object.assign(pe,Vr(T)),O.children.push(li({container:pe,resources:a,templateData:q,isLineCompleted:t,skipMode:y,skipTransitionsAndAnimations:s}))}if(T.text){let re=nt(a,T),pe={...structuredClone(T.text),id:`visual-${T.id}`,type:"text",...Ke(re,T)};Object.assign(pe,Vr(T)),O.children.push(or(sr(pe,q),a))}if(T.resourceId){let{images:re={},videos:pe={},spritesheets:te={}}=a,C=te[T.resourceId];if(C){let _=nt(a,T),F=Vr(T),K=ni({id:`visual-${T.id}`,resourceId:T.resourceId,spritesheet:C,animationName:T.animationName,animationSpeed:T.animationSpeed,loop:T.loop,width:T.width,height:T.height,transform:{...Ke(_,T),alpha:F.alpha??T.alpha??1,...F.blur?{blur:F.blur}:{}}});K&&O.children.push(structuredClone(K))}else{let _=re[T.resourceId]||pe[T.resourceId];if(_){let F=pe[T.resourceId]!==void 0,K=nt(a,T),de={id:`visual-${T.id}`,type:F?"video":"sprite",src:_.fileId,width:_.width,height:_.height,...Ke(K,T)};Object.assign(de,Vr(T)),F&&(de.loop=_.loop??!1,de.volume=_.volume??50),O.children.push(de)}}}let ae=!!(a.spritesheets?.[T.resourceId]||a.images?.[T.resourceId]||a.videos?.[T.resourceId]);if(T.resourceId&&!ae){let re=a.particles?.[T.resourceId];re&&O.children.push(uh({item:T,particle:re,resources:a}))}let ue=!!a.particles?.[T.resourceId];if(T.resourceId&&!ae&&!ue){let{layouts:re={}}=a,pe=re[T.resourceId];if(pe){let te=nt(a,T),C={id:`visual-${T.id}`,type:"container",children:structuredClone(pe.elements),...Ke(te,T)};Object.assign(C,Vr(T));let _=sr(C,q);O.children.push(or(wr(_,{isLineCompleted:t,skipMode:y,skipTransitionsAndAnimations:s}),a))}}let B=Bl(U),Z=Bl(T),oe=ir({animationsDef:T.animations,resources:a,previousResourceId:B,currentResourceId:Z,previousTargetId:B?`visual-${T.id}`:void 0,currentTargetId:Z?`visual-${T.id}`:void 0,animationPath:`visual.items[${T.id}].animations`,idPrefix:T.id});Ye({animationInstances:oe,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:f,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:ie})&&k.push(...oe)}}return e},tt="dialogue-character-sprite",Th=(e,{presentationState:r,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:i}=e,l=qr(e.elements);if(!l)return e;let c=r.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=At(c),f=At(u),d=ir({animationsDef:c?.animations,resources:o,previousResourceId:f?tt:void 0,currentResourceId:p?tt:void 0,previousTargetId:f?tt:void 0,currentTargetId:p?tt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&f&&Ye({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...d),e;let m=o.transforms?.[c.transformId];if(!m)return console.warn("Transform not found:",c.transformId),e;let y={type:"container",id:tt,...Ke(m),children:[]};for(let g of c.items){let h=tc({id:`${tt}-${g.id}`,item:g,resources:o});h&&y.children.push(h)}return l.children.push(y),Ye({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...d),e},Nh=(e,{presentationState:r,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:f,skipTransitionsAndAnimations:d,variables:m,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,activePersistentAnimations:b,saveSlots:E=[]})=>{let{elements:v,animations:P}=e;if(!r.dialogue||a)return e;let k=v.find(D=>D.id==="story");if(!k)return e;if(r.dialogue.ui&&r.dialogue.ui.resourceId){let{layouts:D={}}=o,$=D[r.dialogue.ui.resourceId];if($){let q={elements:$.elements},Y=Fe({variables:m,imageGallery:y,musicRoom:g,sceneReplay:h,runtime:w,saveSlots:E,dialogueState:r.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:f,autoMode:t,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),T=sr(q,Y),U=or(wr(T?.elements,{isLineCompleted:f,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(U))for(let ie of U)k.children.push(ie);else U&&k.children.push(U)}}Th(e,{presentationState:r,previousPresentationState:n,resources:o,isLineCompleted:f,skipTransitionsAndAnimations:d,activePersistentAnimations:b});let O=ir({animationsDef:r.dialogue.ui?.animations,resources:o,previousResourceId:n?.dialogue?.ui?.resourceId,currentResourceId:r.dialogue.ui?.resourceId,previousTargetId:n?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:r.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return Ye({animationInstances:O,isLineCompleted:f,skipTransitionsAndAnimations:d,activePersistentAnimations:b})&&P.push(...O),e},jh=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:f,skipMode:d,isChoiceVisible:m,isFormVisible:y,canRollback:g,form:h,activePersistentAnimations:w,saveSlots:b=[]})=>{let{elements:E,animations:v}=e;if(r.choice&&o){let P=qr(E);if(!P)return e;let k=o?.layouts?.[r.choice.resourceId];if(k&&k.elements){let D={elements:k.elements},$=sr(D,{...Fe({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:b,dialogueState:r.dialogue,isLineCompleted:t,autoMode:f,skipMode:d,isChoiceVisible:m??!!r.choice,isFormVisible:y,canRollback:g,form:h,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:r.choice?.items??[]}}),q=Jo(or(wr($?.elements,{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(q))for(let Y of q)P.children.push(Y);else q&&P.children.push(q)}let O=ir({animationsDef:r.choice.animations,resources:o,previousResourceId:n?.choice?.resourceId,currentResourceId:r.choice.resourceId,previousTargetId:n?.choice?.resourceId?"choice-container":void 0,currentTargetId:r.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});Ye({animationInstances:O,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&v.push(...O)}return e},Dh=(e,{presentationState:r,previousPresentationState:n,resources:o,screen:a,isLineCompleted:t,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:f,skipMode:d,isChoiceVisible:m,isFormVisible:y,canRollback:g,activePersistentAnimations:h,saveSlots:w=[],form:b})=>{let{elements:E,animations:v}=e;if(!b?.resourceId||!o)return e;let P=qr(E);if(!P)return e;let k=o?.layouts?.[b.resourceId];if(!k)return console.warn(`Form layout not found: ${b.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:k.elements||[]},D={...Fe({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:r.dialogue,isLineCompleted:t,autoMode:f,skipMode:d,isChoiceVisible:m,isFormVisible:y,canRollback:g,characters:o.characters||{},skipTransitionsAndAnimations:s,form:b}),form:b},$=sr(O,D),q=Zo(or(wr(Qo($,b),{isLineCompleted:t,skipMode:d,skipTransitionsAndAnimations:s}),o),b);q&&P.children.push(q);let Y=ir({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 Ye({animationInstances:Y,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:h})&&v.push(...Y),e},Lh=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,saveSlots:y=[],skipTransitionsAndAnimations:g})=>{if(!r.control?.resourceId)return e;let h=n.controls?.[r.control.resourceId];if(!h)return e;let w=Sh(h.keyboard,h.keyup);if(w&&Object.keys(w).length>0&&(e.global.keyboard=w),!Array.isArray(h.elements)||h.elements.length===0)return e;let b=qr(e.elements);if(!b)return e;let E={id:`control-${r.control.resourceId}`,type:"container",x:0,y:0,children:h.elements};return b.children.push(li({container:E,resources:n,templateData:Fe({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,characters:n.characters||{},skipTransitionsAndAnimations:g}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:g})),e},Mh=(e,{presentationState:r,resources:n,runtime:o,variables:a,musicRoomPlayer:t})=>{let{elements:s,audio:i}=e;if(r.bgm&&n){if(!qr(s))return e;let c=r.bgm,u=!Array.isArray(c.sounds),p=u?c.resourceId?[{id:"default",resourceId:c.resourceId,loop:c.loop??!0,volume:c.volume,startDelayMs:c.startDelayMs??0}]:[]:c.sounds,f=!u&&c.loop===!0,d=[];if(u||Fn(p,"BGM sound"),f){let y=p.find(g=>g.loop===!0);if(y)throw new Error(`BGM sound "${y.id}" cannot loop inside a looping BGM channel.`)}if(p.forEach(y=>{let g=n.sounds?.[y.resourceId];if(!g)return;let h=f?{...y,loop:y.loop??!1}:y;d.push(Gn({id:Lt("bgm",u?"default":y.id),sound:h,resource:g,defaultLoop:!f}))}),d.length===0)return e;let m=Fe({variables:a,runtime:o}).runtime;i.push(zn({id:mh,volume:Yn(m,"musicVolume",u?Ir:c.volume??Ir),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,playback:t?.bgmPlayback,interruption:c.interruption,children:d,runtime:m}))}return e},Vh=(e,{resources:r={},runtime:n,variables:o,musicRoomPlayer:a})=>{let t=r.musicRoom;if(!t||!a?.trackId||!a.playback)return e;let s=t.tracks.find(u=>u.id===a.trackId),i=s?r.sounds?.[s.soundId]:void 0;if(!s||!i)return e;let l=Fe({variables:o,runtime:n}).runtime,c=Gn({id:hh,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i});return e.audio.push(zn({id:yh,volume:Yn(l,"musicVolume",Ir),children:[c],runtime:l})),e},qh=(e,{presentationState:r,resources:n,runtime:o})=>{let{audio:a}=e;if(r.sfx&&n){let t=r.sfx,s=Array.isArray(t.channels)?t.channels:[],i=s.map(l=>({channel:l,usesLegacyChannel:!1}));Fn(s,"SFX channel"),Array.isArray(t.items)&&i.push({channel:{id:bh,sounds:t.items},usesLegacyChannel:!0}),i.forEach(({channel:l,usesLegacyChannel:c})=>{let u=!c&&l.loop===!0,p=[];if(c||Fn(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let f=l.sounds.find(d=>d.loop===!0);if(f)throw new Error(`SFX sound "${f.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((f,d)=>{let m=n.sounds?.[f.resourceId];if(!m)return;let y=u?{...f,loop:f.loop??!1}:f;p.push(Gn({id:c?Lt("sfx","default",d,f.id):Lt("sfx",l.id,f.id),sound:y,resource:m,defaultLoop:u?!1:void 0}))}),p.length!==0&&a.push(zn({id:Lt("channel","sfx",l.id),volume:Yn(o,"soundVolume",l.volume??Ir),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:c?void 0:l.interruption,children:p,runtime:o}))})}return e},Fh=(e,r,n)=>{if(!(!r||!n))return e?.voices?.[r]?.[n]},Uh=(e,{presentationState:r,resources:n,currentSceneId:o,runtime:a,variables:t})=>{let{audio:s}=e;if(!r?.voice)return e;let i=r.voice,l=!Array.isArray(i.sounds),c=l?i.resourceId?[{id:"default",resourceId:i.resourceId,loop:i.loop??!1,volume:Ir,startDelayMs:i.startDelayMs??0}]:[]:i.sounds,u=!l&&i.loop===!0,p=[];if(l||Fn(c,"Voice sound"),u){let d=c.find(m=>m.loop===!0);if(d)throw new Error(`Voice sound "${d.id}" cannot loop inside a looping Voice channel.`)}if(c.forEach(d=>{let m=Fh(n,o,d.resourceId);if(!m)return;let y=u?{...d,loop:d.loop??!1}:d;p.push(Gn({id:Lt("voice",o,l?"default":d.id),sound:y,resource:m,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let f=Fe({variables:t,runtime:a}).runtime;return s.push(zn({id:gh,volume:l?i.volume??lc(f,"soundVolume"):Yn(f,"soundVolume",i.volume??Ir),muted:i.muted,pan:i.pan,loop:l?void 0:i.loop,interruption:i.interruption,children:p,runtime:f})),e},Bh=(e,{presentationState:r,previousPresentationState:n,resources:o={},variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,saveSlots:y=[],isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})=>{let{elements:b,animations:E}=e;if(r.layout){let O=qr(b);if(!O)return e;let D=o.layouts?.[r.layout.resourceId];if(!D)return e;Array.isArray(D.transitions)&&!g&&!h&&ti({animations:E,transitions:D.transitions,defaultTargetId:`layout-${r.layout.resourceId}`,idPrefix:`layout-${r.layout.resourceId}`,animationPathPrefix:"layout"});let $={id:`layout-${r.layout.resourceId}`,type:"container",x:0,y:0,children:D.elements||[]};O.children.push(li({container:$,resources:o,templateData:Fe({variables:a,imageGallery:t,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:y,dialogueState:r.dialogue,isLineCompleted:g,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,characters:o.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:g,skipMode:u,skipTransitionsAndAnimations:h}))}let v=n?.layout?.resourceId,P=r.layout?.resourceId,k=ir({animationsDef:r.layout?.animations,resources:o,previousResourceId:v,currentResourceId:P,previousTargetId:v?`layout-${v}`:void 0,currentTargetId:P?`layout-${P}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ye({animationInstances:k,isLineCompleted:g,skipTransitionsAndAnimations:h,activePersistentAnimations:w})&&E.push(...k),e},Yh=(e,{currentLineActions:r,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})=>{let{animations:i}=e,l=r?.screen?.animations;if(!l)return e;let c=n!=null,u=ir({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ye({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:t,activePersistentAnimations:s})&&i.push(...u),e},zh=(e,{presentationState:r})=>{let n=qr(e.elements);return!n||!r?.screen||Object.assign(n,ic(r.screen)),e},Gh=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:f,form:d,overlayStack:m=[],dialogueHistory:y=[],saveSlots:g=[],screen:h,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:E,animations:v}=e;return m&&m.length>0&&m.forEach((P,k)=>{let O=n.layouts?.[P.resourceId];if(!O){console.warn(`Overlay layout not found: ${P.resourceId}`);return}Array.isArray(O.transitions)&&(b||ti({animations:v,transitions:O.transitions,defaultTargetId:`overlayStack-${k}`,idPrefix:`overlayStack-${k}`,animationPathPrefix:`overlayStack[${k}]`}));let D={id:`overlayStack-${k}`,type:"container",x:0,y:0,children:[cc({id:`overlayStack-${k}-blocker`,screen:h}),...O.elements||[]]},$=uc(y,n.characters,o),q=Fe({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:g,dialogueState:r?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:f,form:d,historyDialogue:$,characters:n.characters||{},skipTransitionsAndAnimations:b}),Y=sr(D,q),[T,...U]=Y.children||[],ie=or(wr({...Y,children:U},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:b}),n);E.push({...ie,children:T?[T,...ie.children||[]]:ie.children})}),e},Hh=(e,{presentationState:r,resources:n={},variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,confirmDialog:y,dialogueHistory:g=[],screen:h,isLineCompleted:w,skipTransitionsAndAnimations:b})=>{let{elements:E,animations:v}=e;if(!y?.resourceId)return e;let P=n.layouts?.[y.resourceId];if(!P)return console.warn(`ConfirmDialog layout not found: ${y.resourceId}`),e;Array.isArray(P.transitions)&&!b&&ti({animations:v,transitions:P.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let k={id:"confirmDialog",type:"container",x:0,y:0,children:[cc({id:"confirmDialog-blocker",screen:h}),...P.elements||[]]},O=uc(g,n.characters,o),D=sr(k,Fe({variables:o,imageGallery:a,musicRoom:t,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:r?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,confirmDialog:y,historyDialogue:O,characters:n.characters||{},skipTransitionsAndAnimations:b})),[$,...q]=D.children||[],Y=or(wr({...D,children:q},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:b}),n);return E.push({...Y,children:$?[$,...Y.children||[]]:Y.children}),e},qt=e=>(r,n)=>_h(r,{...n,visualLayer:e}),Xh=qt(nr.BEHIND_BACKGROUND),Wh=qt(nr.BEHIND_CHARACTER),Kh=qt(nr.BEHIND_DIALOGUE),Jh=qt(nr.BEHIND_CHOICE),Qh=qt(nr.FOREGROUND),dc=e=>En(Oh,[Lh,Xh,Rh,Wh,Ch,Kh,Nh,Jh,jh,Dh,Bh,Qh,zh,Yh,Mh,Vh,qh,Uh,Gh,Hh])(e);function fc(e,r=""){let n=[],o=e.length,a=0,t=0,s=-1,i=()=>{let l=0,c=0,u;do u=parseInt(e[a++],36),l+=(u&15)<<c,c+=4;while(u&16);return l};for(;a<o;){let l=s+1+i();s=l+i(),n.push([l,s,r?parseInt(r[t++],36):0])}return n}function mc(e,r,n){let o=0,a=r.length-1;for(;o<=a;){let t=o+a>>>1,s=n[t];if(e<r[t])a=t-1;else if(e>s>>>5)o=t+1;else return s&31}return 0}var yc="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",hc="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",gc="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var bc=65535,ci=40960,Hn=126976,kc=new Uint8Array(12288),vc=new Uint8Array(3072),Ac=new Uint8Array(2816),Pc,xc;{let e=(a,t,s,i,l)=>{let c=t+a.length-1;for(let u=s<t?t:s,p=i>c?c:i;u<=p;u++)a[u-t]=l},r=new Uint32Array(320),n=new Uint32Array(320),o=0;for(let[a,t,s]of fc(yc,hc))e(kc,0,a,t,s),e(vc,ci,a,t,s),e(Ac,Hn,a,t,s),t>=65040&&!(a>=Hn&&t<=129791)&&(r[o]=a,n[o++]=t<<5|s);Pc=r.slice(0,o),xc=n.slice(0,o)}function Ic(e){return e<12288?kc[e]:e<ci?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?vc[e-ci]:e<55204?(e-44032)%28?8:7:e<57344?e<=55238?e>=55216?13:0:e>=55243&&e<=55291?12:0:e<65024?e===64286?3:0:e<65040?3:e>=Hn&&e<129792?Ac[e-Hn]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:mc(e,Pc,xc)}var Ec=Uint8Array.from(gc,Number);function Zh(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 wc(e,r,n){switch(r){case 3:return e&24?n===8204?e&6:(e&24)===16||Zh(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*Sc(e){let r=e.length;if(r===0)return;let n=e.codePointAt(0),o=n>bc?2:1,a=Ic(n),t=50200>>a&1?wc(0,a,n):0,s=0,i=n,l=a;for(;o<r;){n=e.codePointAt(o);let c=n>bc?2:1,u=Ic(n),p=Ec[a<<4|u],f;p===0?f=!0:p===1?f=!1:p===2?f=!(t&1):p===3?f=!(t&4):f=(t&24)!==16,t=50200>>u&1&&(t!==0||u!==3)?wc(t,u,n):0,f&&(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*Oc(e){for(let r of Sc(e))yield r.segment}{let e=Sc("_");Ec._keep=[e,e.next()]}var Rc=1e3,Tc=50,eg=0,Cc=100,$c=50,rg=60,tg=3,ng=.5,sg=2e4,og=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,ig=/^\s+$/u,_c,ag=e=>{let r=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(Oc(r)):(_c??=new n(void 0,{granularity:"grapheme"}),Array.from(_c.segment(r),({segment:o})=>o))},lg=e=>ag(e).reduce((r,n)=>ig.test(n)?r+ng:og.test(n)?r+tg:r+1,0),cg=e=>2**(((Number.isFinite(e)?Math.min(Cc,Math.max(eg,e)):Tc)-$c)/(Cc-$c)),ui=({text:e="",baseDelay:r=Rc,speed:n=Tc}={})=>{let o=Number.isFinite(r)?Math.max(0,r):Rc,a=cg(n),t=lg(e)*rg/a,s=Math.max(o,sg);return Math.min(o+t,s)};var Xn={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Vc=1,vi=1,ar=1,at="choice",vr="form",Yt=()=>({manual:{...Xn.manual},auto:{...Xn.auto},applyMode:Xn.applyMode}),Ai=()=>({groupId:null,variantId:null,pageIndex:0}),ug="music-room:player",pg=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Jn=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Pi=new Set,dg=new Set(["groupId","variantId"]),fg=new Set(["pageIndex"]),lt=new Set,mg=new Set(["trackId"]),yg=new Set(["positionMs"]),hg=new Set(["pageIndex"]),xi=new Set,gg=new Set(["sceneId"]),bg=new Set(["pageIndex"]),Ei=()=>({pageIndex:0}),Si=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...Yt()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},di=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let r=we(e)?pr(e):e;return structuredClone(r)},M=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Qn=e=>{let r=e.global.audioCommandId;if(!Number.isSafeInteger(r)||r<0)throw new Error("Internal audio command counter is invalid");if(r===Number.MAX_SAFE_INTEGER)throw new Error("Audio command counter is exhausted");return e.global.audioCommandId=r+1,e.global.audioCommandId},qc=e=>{let r=e.global.sceneReplayEntryId;if(!Number.isSafeInteger(r)||r<0)throw new Error("Internal scene replay entry counter is invalid");if(r===Number.MAX_SAFE_INTEGER)throw new Error("Scene replay entry counter is exhausted");return e.global.sceneReplayEntryId=r+1,e.global.sceneReplayEntryId},zt=(e,r,n)=>({commandId:Qn(e),operation:r,...n===void 0?{}:{positionMs:n}}),Oi=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let r=e.global.musicRoomPlayer,n=r.bgmPlayback;r.trackId!==null&&(n={commandId:Qn(e),operation:"resume"}),e.global.musicRoomPlayer=Jn({bgmPlayback:n})},Fc=(e,r)=>{if(typeof r!="string"||r.length===0)throw new Error("Achievement action requires a non-empty resourceId");let n=e.projectData.resources?.achievements?.[r];if(!n)throw new Error(`Achievement resource "${r}" not found`);if(n.type!=="boolean"&&n.type!=="number")throw new Error(`Achievement resource "${r}" has invalid type "${n.type}"`);return n},Uc=(e,r)=>{if(e==null||e==="")throw new Error(`${r} requires slotId`);let n=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!n&&!o)throw new Error(`${r} requires a non-empty string or finite number slotId`)},Br=e=>String(e),Bc=()=>({sections:[],resources:[]}),Yc=()=>({sceneIds:[]}),Ig=e=>M(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Bc(),wg=e=>M(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):Yc(),kg=e=>Array.isArray(e)?e.map(r=>r?.text??"").join(""):"",vg=({sectionId:e,lineId:r,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:r,content:n,text:kg(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),zc=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),Ag=e=>M(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,Ri=e=>{if(!M(e?.dialogueHistory))return null;let r=e.dialogueHistory;return!Array.isArray(r.entries)||!Number.isInteger(r.currentLength)||!Array.isArray(r.checkpointLengths)?null:r},Pg=e=>{if(!M(e?.dialogueHistory))return e.dialogueHistory=zc(e?.rollback?.timeline?.length??0),e.dialogueHistory;let r=e.dialogueHistory;return Array.isArray(r.entries)||(r.entries=[]),Number.isInteger(r.currentLength)||(r.currentLength=r.entries.length),Array.isArray(r.checkpointLengths)||(r.checkpointLengths=Array(e?.rollback?.timeline?.length??0).fill(0)),r.currentLength=Math.min(Math.max(r.currentLength,0),r.entries.length),r},Ci=e=>{let r=Ri(e);return r?(r.currentLength<r.entries.length&&(r.entries=r.entries.slice(0,r.currentLength)),r):null},xg=()=>({resourceId:void 0}),Eg=e=>{if(!M(e))return e;let r={...e};return Object.prototype.hasOwnProperty.call(r,"requireComplete")&&!Object.prototype.hasOwnProperty.call(r,"requireLineCompleted")&&(r.requireLineCompleted=r.requireComplete),delete r.requireComplete,r},Ge=(e,r)=>{let n=e?.story?.scenes??{};for(let[o,a]of Object.entries(n))if(a?.sections?.[r])return{sceneId:o,section:a.sections[r]};return{sceneId:void 0,section:void 0}},Gc=e=>{let r=e?.story?.scenes??{},n=new Map;for(let[o,a]of Object.entries(r)){let t=a?.sections??{};for(let s of Object.keys(t)){let i=n.get(s);if(i!==void 0)throw new Error(`Duplicate sectionId "${s}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);n.set(s,o)}}},Hc=e=>e,Xc=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Vc)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},Sg=(e,r={})=>{let n;try{n=Xc(r.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...r,formatVersion:n,slotId:Hc(r.slotId??r.slotKey??e),savedAt:typeof r.savedAt=="number"?r.savedAt:r.date};return delete o.slotKey,delete o.date,o},Og=(e={})=>Object.fromEntries(Object.entries(e).map(([r,n])=>[r,Sg(r,n)])),Rg=(e,r)=>{if(!M(e)||!Array.isArray(e.operations))return null;let n=e.operations.filter(o=>{if(!M(o))return!1;let{variableId:a,op:t,value:s,roundTo:i}=o,l=r?.resources?.variables?.[a];if(!l||Se(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Ct(l.type,t,a),Rn(l.type,t,s,a,{roundTo:i}),t!=="set"||Eo(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},Wc=(e,r)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!M(o)||!gw(o.type))return[];if(o.type!=="updateVariable"||r===void 0)return[o];let a=Rg(o.payload,r);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},Cg=(e,r,n)=>{let{section:o}=Ge(e,r?.sectionId),t=o?.lines?.find(({id:i})=>i===r?.lineId)?.actions,s=n.split(".");for(let i of s){if(Array.isArray(t)){if(!/^(0|[1-9]\d*)$/.test(i))return;let l=Number(i);if(!Object.prototype.hasOwnProperty.call(t,l))return;t=t[l];continue}if(!M(t)||!Object.prototype.hasOwnProperty.call(t,i))return;t=t[i]}return s.at(-1)==="random"&&M(t?.distribution)?t:void 0},Kc=e=>{if(e?.type!=="integer"||!Number.isSafeInteger(e.min)||!Number.isSafeInteger(e.max))return!1;let r=e.max-e.min+1;return Number.isSafeInteger(r)&&r>=1&&r<=4294967296},Jc=(e,r,n)=>e.filter(({path:o,type:a,result:t})=>{let s=Cg(n,r,o);if(s?.distribution?.type!==a)return!1;if(a==="weighted")return M(s.distribution.outcomes?.[t.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&&!Se(i)&&Kc(s.distribution)&&t.value>=s.distribution.min&&t.value<=s.distribution.max}return!1}),$i=(e,r)=>{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,t)=>{let s=`${a?.path}\0${a?.ordinal}`;if(!M(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 ${t}`);return n.add(s),{path:a.path,ordinal:a.ordinal,type:a.type,result:Tn(V(a.result),a.type)}});return r===void 0?o:Jc(o,e,r)},$g=(e,r)=>{!M(e)||!Array.isArray(e.timeline)||(e.returnabilityVersion=vi,e.timeline.forEach(n=>{if(!M(n))return;typeof n.returnable!="boolean"&&delete n.returnable;let o=Wc(n.executedActions,r);o?n.executedActions=o:delete n.executedActions;let a=$i(n,r);a?(n.randomOutcomeVersion=ar,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)}))},_g=(e,r)=>{let n=e??{};return Object.values(n).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(t=>{let s=t?.rollback?.timeline;Array.isArray(s)&&s.forEach(i=>{if(!M(i))return;let l=$i(i,r);l?(i.randomOutcomeVersion=ar,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),n},Nc=(e,r,n,o="viewedRegistry")=>{let a=r==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!M(e))throw new Error(`Malformed ${o}.${r}[${n}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${r}[${n}] entry: missing ${a}.`);if(r==="sections"){let t={sectionId:e.sectionId};if(e.lastLineId!==void 0&&e.lastLineId!==null&&typeof e.lastLineId!="string")throw new Error(`Malformed ${o}.sections[${n}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(t.lastLineId=e.lastLineId),t}return{resourceId:e.resourceId}},Tg=(e,r="viewedRegistry")=>{if(e===void 0)return Bc();if(!M(e))throw new Error(`Malformed ${r}.`);if(e.sections!==void 0&&!Array.isArray(e.sections))throw new Error(`Malformed ${r}.sections.`);if(e.resources!==void 0&&!Array.isArray(e.resources))throw new Error(`Malformed ${r}.resources.`);let n=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(n.map((a,t)=>{let s=Nc(a,"sections",t,r);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,t)=>{let s=Nc(a,"resources",t,r);return[s.resourceId,s]})))}},Ng=(e,r="accountReplayRegistry")=>{if(e===void 0)return Yc();if(!M(e))throw new Error(`Malformed ${r}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${r}.sceneIds.`);let n=e.sceneIds??[];return{sceneIds:[...new Set(n.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${r}.sceneIds[${a}] entry.`);return o}))]}},Ft=(e,r,n)=>{if(!M(e))throw new Error(`Malformed save slot ${n}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${n}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${n}: missing lineId.`);let{sceneId:t,section:s}=Ge(r,o);if(!s)throw new Error(`Malformed save slot ${n}: section "${o}" does not exist in projectData.`);if(!s.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${n}: line "${a}" does not exist in section "${o}".`);return{sceneId:t,sectionId:o,lineId:a}},Qc=e=>{let r=e.story.initialSceneId,n=e.story.scenes[r],o=n.initialSectionId,a=n.sections[o];return Ft({sceneId:r,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},jg=e=>{try{return Qc(e),!0}catch{return!1}},Dg=(e,r,n)=>{let o=e?.pointers?.read;if(!M(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return Ft(o,r,n);try{return Ft(o,r,n)}catch{let a=Array.isArray(e?.rollback?.timeline)?e.rollback.timeline:[],t=Number.isInteger(e?.rollback?.currentIndex)?Math.min(e.rollback.currentIndex,a.length-1):a.length-1;for(let s=t;s>=0;s-=1)try{return Ft(a[s],r,`${n} compatibility checkpoint`)}catch{}return Qc(r)}},Zc=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,_i=(e,r)=>{let{section:n}=Ge(e,r?.sectionId);return n?.lines?.find(o=>o.id===r?.lineId)},Lg=(e,r,n)=>{if(!M(e))throw new Error(`Malformed save slot ${n}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${n}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${n}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${n}.checkpointLengths.`);let o=[],a=[0],t=!1;if(e.entries.forEach((i,l)=>{if(!M(i))throw new Error(`Malformed save slot ${n}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${n}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${n}.entries[${l}].appendToPrevious.`);let{section:c}=Ge(r,i.sectionId);if(!c?.lines?.some(p=>p.id===i.lineId)){t=!1,a.push(o.length);return}o.push({sectionId:i.sectionId,lineId:i.lineId,...i.appendToPrevious===!0&&t&&o.length>0?{appendToPrevious:!0}:{}}),t=!0,a.push(o.length)}),e.currentLength<0||e.currentLength>e.entries.length)throw new Error(`Malformed save slot ${n}.currentLength: must reference the retained entries.`);let s=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${n}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:s}},Mg=(e,r)=>M(_i(e,r)?.actions?.dialogue),eu=(e,r,n)=>{if(!r||r.sectionId!==n.sectionId)return!1;let{section:o}=Ge(e,n.sectionId),a=o?.lines?.findIndex(s=>s.id===n.lineId);return typeof a!="number"||a<=0?!1:o.lines.slice(0,a).findLast(s=>M(s.actions?.dialogue))?.id===r.lineId},Vg=(e,r)=>{let n=zc();return e.timeline.forEach(o=>{if(o.returnable!==!1&&Mg(r,o)){let a=_i(r,o),t=n.entries.at(-1),s=a.actions.dialogue.append===!0&&eu(r,t,o);n.entries.push({sectionId:o.sectionId,lineId:o.lineId,...s?{appendToPrevious:!0}:{}})}n.checkpointLengths.push(n.entries.length)}),n.currentLength=n.checkpointLengths[e.currentIndex]??0,n.entries.length>0?n:null},qg=(e,r,n,o)=>{if(n.length!==r.timeline.length)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: rollback checkpoint mapping is incomplete.");if(e.checkpointLengths.length!==o)throw new Error("Malformed save slot dialogueHistory.checkpointLengths: expected one length per rollback checkpoint.");e.checkpointLengths=n.map(t=>t===null?e.currentLength:e.checkpointLengths[t]);let a=0;return e.checkpointLengths.forEach((t,s)=>{if(t<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${s}]: lengths must be chronological.`);a=t}),e},Fg=(e,r)=>{let{section:n}=Ge(e,r?.sectionId),o=n?.lines?.findIndex(t=>t.id===r?.lineId);if(typeof o!="number"||o<0)return null;let a=n.lines[o+1];return a?{sectionId:r.sectionId,lineId:a.id}:null},ru=(e,r,n)=>{if(typeof r?.sectionId!="string")return!1;let{section:o}=Ge(e,r.sectionId);return Zc({sectionId:r.sectionId,lineId:o?.lines?.[0]?.id},n)},Ug=new Set(["jumpToLine","rollbackByOffset","rollbackToLine","sectionTransition","resetStoryAtSection"]),ot={always:"always",maybe:"maybe",never:"never"},Bg=e=>{if(!Object.prototype.hasOwnProperty.call(e??{},"when"))return ot.always;let r=e.when,n;if(r===null||typeof r=="boolean"||typeof r=="number")n=r;else if(M(r)&&Object.keys(r).length===1&&Object.prototype.hasOwnProperty.call(r,"literal"))n=r.literal;else return ot.maybe;return n?ot.always:ot.never},tu=(e,r)=>{if(!Array.isArray(e?.branches))return!1;for(let n of e.branches){let o=Bg(n);if(o!==ot.never){if(r(n))return!0;if(o===ot.always)return!1}}return!1},nu=e=>tu(e,r=>Object.entries(r?.actions??{}).some(([n,o])=>n==="conditional"?nu(o):Ug.has(n))),su=(e,r,n)=>tu(r,o=>Object.entries(o?.actions??{}).some(([a,t])=>a==="sectionTransition"?ru(e,t,n):a==="conditional"?su(e,t,n):!1)),Yg=(e,r,n)=>{if(!r)return!0;let o=_i(n,e)?.actions;if(!M(o))return!0;if(ru(n,o.sectionTransition,r))return!1;let a=o.conditional;return a?!(su(n,a,r)||!(o.choice?.resourceId||o.form?.resourceId)&&!nu(a)&&Zc(Fg(n,e),r)):!0},zg=(e,r,n)=>{if(!M(e)||!Array.isArray(e.timeline))return{rollback:Bt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=new WeakSet,a=[],t=e.timeline.flatMap((p,f)=>{if(!M(p))return[];let d=$i(p);try{let m=Ft(p,n,`rollback.timeline[${f}]`),y=d?Jc(d,m,n):void 0,g=Kn({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:p.rollbackPolicy,returnable:p.returnable,...y?{randomOutcomeVersion:ar,randomOutcomes:y}:{}});typeof p.returnable=="boolean"&&o.add(g);let h=Wc(V(p.executedActions),n);return h&&(g.executedActions=h),a.push(f),[g]}catch{return[]}});if(t.length===0)return{rollback:Bt({pointer:r,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};e.returnabilityVersion!==vi&&t.forEach((p,f)=>{!o.has(p)&&!Yg(p,t[f+1],n)&&(p.returnable=!1)});let i=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,l=a.indexOf(i);l<0&&(l=t.length-1);let c=t[l];if(c?.sectionId!==r.sectionId||c?.lineId!==r.lineId){let p=t.findLastIndex(f=>f.sectionId===r.sectionId&&f.lineId===r.lineId);p>=0?l=p:(t.push(Kn({sectionId:r.sectionId,lineId:r.lineId})),a.push(null),l=t.length-1)}let u=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),l):0;return{rollback:{currentIndex:l,isRestoring:!1,replayStartIndex:u,timeline:t},sourceCheckpointIndexes:a,sourceTimelineLength:e.timeline.length}},ou=(e,r,n)=>{if(!M(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=Ni(r),a=Dg(e,r,`contexts[${n}].pointers.read`);if(e.variables!==void 0&&!M(e.variables))throw new Error(`Malformed save slot contexts[${n}].variables entry.`);if(e.runtime!==void 0&&!M(e.runtime))throw new Error(`Malformed save slot contexts[${n}].runtime entry.`);let t=e.variables?Ot(V(e.variables),r.resources?.variables??{},{allowedScopes:["context"]}):{},s=sb({loadedContextRuntime:M(e.runtime)?V(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=zg(e.rollback,a,r),u=e.dialogueHistory===void 0?Vg(i,r):qg(Lg(e.dialogueHistory,r,`contexts[${n}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:M(e.configuration)?V(e.configuration):{},views:Array.isArray(e.views)?V(e.views):[],bgm:M(e.bgm)?V(e.bgm):{resourceId:void 0},variables:{...o,...t},...u?{dialogueHistory:u}:{},rollback:i};return s&&(p.runtime=s),p},Gg=(e,r)=>{if(!M(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((n,o)=>ou(n,r,o))}},Hg=(e,r)=>{if(!M(e))throw new Error("Malformed save slot.");let n=Xc(e.formatVersion);return{...e,formatVersion:n,state:Gg(e.state,r)}},jc=(e,r,{required:n=!1}={})=>{if(e===void 0){if(n)throw new Error(`showConfirmDialog requires ${r}`);return{hideConfirmDialog:{}}}if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`showConfirmDialog ${r} must be an action object`);let o=V(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},Xg=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:jc(e.confirmActions,"confirmActions",{required:!0}),cancelActions:jc(e.cancelActions,"cancelActions")}},ct=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Wg=e=>(M(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),ut=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},iu=e=>{if(!(!M(e)||!e.animations))return{animations:V(e.animations)}},Kg=(e,r)=>{let n=iu(r);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Jg=e=>{let r=e?.id??e?.resourceId;return typeof r=="string"&&r.length>0?r:void 0},Qg=(e,r)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!r))return`${n}:${o}:${r}`},Wn=e=>String(e??""),au=(e,r)=>{let n=Wn(r);return e?.trim===!0?n.trim():n},Zg=e=>M(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,r])=>M(r)).map(([r,n])=>[r,{id:r,...V(n)}])):{},eb=(e,r)=>{if(!r||!M(e.global.formDrafts))return;let n=e.global.formDrafts[r];return M(n)?n:void 0},lu=(e,r)=>{let n=Wg(e);M(n[r])||(n[r]={values:{},touched:{},errors:{},submitted:!1});let o=n[r];return M(o.values)||(o.values={}),M(o.touched)||(o.touched={}),M(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},Ti=(e,r)=>{let n=au(e,r);return e?.required===!0&&n.length===0?"required":null},rb=({state:e,pointer:r})=>{if(!r?.sectionId||!r?.lineId)return{};let o=ve({state:e},{sectionId:r.sectionId})?.lines||[],a=o.findIndex(t=>t.id===r.lineId);return a<0?{}:Mr(o.slice(0,a+1).map(t=>t.actions||{}))},tb=({state:e,form:r,pointer:n})=>{if(!r?.resourceId)return null;let o=Jg(r),a=Qg(n,o);if(!o||!a)return null;let t=eb(e,a),s=Zg(r),i=Hi({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([f,d])=>{let m=Wn(i?.[d.variableId]),y=Object.prototype.hasOwnProperty.call(t?.values??{},f)?Wn(t.values[f]):m,g=t?.touched?.[f]===!0,h=Ti(d,y),w=t?.submitted||g?h:null,b=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,E={id:f,variableId:d.variableId,value:y,initialValue:m,valid:!h,error:w,touched:g,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...b!==void 0?{maxLength:b}:{}};h&&(p=!1),l[f]=E,c.push(E),u[f]=y}),{id:o,key:a,resourceId:r.resourceId,animations:r.animations,valid:p,submitted:t?.submitted===!0,fields:l,fieldList:c,values:u,submitActions:{submitForm:{formKey:a,actions:V(r.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:V(r.cancelActions??{})}}}},it="line",kr="interaction",Kn=({sectionId:e,lineId:r,rollbackPolicy:n,returnable:o,randomOutcomeVersion:a,randomOutcomes:t})=>({sectionId:e,lineId:r,rollbackPolicy:n??"free",...typeof o=="boolean"?{returnable:o}:{},...a===ar?{randomOutcomeVersion:ar,randomOutcomes:V(t??[])}:{}}),Ni=e=>{let r=we(e)?pr(e):e,{contextVariableDefaultValues:n}=On(r??{});return V(n)},cu=()=>({...V(jt)}),uu=({loadedRuntime:e,runtimeIds:r,defaults:n={},path:o})=>{if(e===void 0)return{runtimeState:V(n),hasLoadedValues:!1};if(!M(e))throw new Error(`Malformed ${o}.`);let a=V(n),t=!1;return r.forEach(s=>{e[s]!==void 0&&(a[s]=Dn(s,V(e[s])),t=!0)}),{runtimeState:a,hasLoadedValues:t}},nb=({projectData:e,loadedGlobalRuntime:r={}})=>uu({loadedRuntime:r,runtimeIds:No,defaults:Do(e),path:"global.runtime"}).runtimeState,sb=({loadedContextRuntime:e={}})=>{let{runtimeState:r,hasLoadedValues:n}=uu({loadedRuntime:e,runtimeIds:jo,defaults:cu(),path:"context.runtime"});return n?r:void 0},Pr=e=>{let r=Array.isArray(e?.contexts)?e.contexts:[];return r[r.length-1]},ye=e=>{let r=Pr(e);return r?.kind==="sceneReplay"&&M(r.sceneReplay)?r:null},pu=(e,r)=>{let n=r?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===n);Object.entries(o?.initialVariables??{}).forEach(([a,t])=>{r.variables[a]=V(t)})},ob=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)}}),ib=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=Yt(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},ab=(e,r)=>{e.global.autoMode=r.autoMode,e.global.skipMode=r.skipMode,e.global.dialogueUIHidden=r.dialogueUIHidden,e.global.nextLineConfig=V(r.nextLineConfig),e.global.overlayStack=V(r.overlayStack),e.global.confirmDialog=V(r.confirmDialog),e.global.formDrafts=V(r.formDrafts),e.global.isLineCompleted=r.isLineCompleted,r.isDialogueHistoryShowing===void 0?delete e.global.isDialogueHistoryShowing:e.global.isDialogueHistoryShowing=r.isDialogueHistoryShowing,r.pendingScreenTransition===void 0?delete e.global.pendingScreenTransition:e.global.pendingScreenTransition=V(r.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let n=Ae({state:e});e.global.autoMode&&e.global.isLineCompleted&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({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}})},lb=e=>e.runtime?(jo.forEach(r=>{e.runtime[r]===void 0&&(e.runtime[r]=V(jt[r]))}),e.runtime):(e.runtime=cu(),e.runtime),cb=e=>Dl(e.global),du=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:cb(e)}})},ji=(e,r,n)=>{let o=Dn(r,n);if(r in jt){let a=Pr(e);if(!a)return o;let t=lb(a);return t[r]=o,o}return e.global[r]=o,o},Di=({pointer:e,projectData:r,kind:n,sceneReplay:o})=>({...n===void 0?{}:{kind:n},...o===void 0?{}:{sceneReplay:V(o)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:xg(),variables:Ni(r),rollback:Bt({pointer:e})}),pt=e=>e?(e.currentPointerMode="read",M(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,ub=(e,{queueRender:r=!0}={})=>{let n=e.contexts?.[e.contexts.length-1],o=n?.pointers?.read;if(!n||!o?.sectionId||!o?.lineId)return null;let a=Di({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,pb(e,{queueRender:r}),a},pb=(e,{queueRender:r=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,ct(e),ut(e),e.global.nextLineConfig=Yt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Oi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),r&&e.global.pendingEffects.push({name:"render"})},fu=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},Bt=({pointer:e,replayStartIndex:r=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:r,timeline:n?[Kn({sectionId:e.sectionId,lineId:e.lineId})]:[]}},xr=(e,r={})=>{if(e?.rollback)return fu(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=Bt({pointer:n,replayStartIndex:r.compatibilityAnchor?1:0}),e.rollback},Zn=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=xr(n);if(o.isRestoring)return;let a=Ci(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(Kn(r)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},db=({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}},fb=({state:e},r={})=>{let{checkpointIndex:n,checkpointIdentity:o,sectionId:a,lineId:t}=r,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(n)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[n];return(we(l)?mn(l):l)!==o||l?.sectionId!==a||l?.lineId!==t||(l.returnable=!1),e},mb=({state:e},r={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:t,lineId:s}=r,i=Br(n),l=e.global.saveSlots?.[i],c=we(l)?mn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,f=p?.rollback,d=f?.timeline?.[a];return!Number.isInteger(a)||f?.currentIndex!==a||p?.pointers?.read?.sectionId!==t||p?.pointers?.read?.lineId!==s||d?.sectionId!==t||d?.lineId!==s||(d.returnable=!1,f.returnabilityVersion=vi,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},mu=(e,r)=>{let n=e.contexts?.[e.contexts.length-1],o=n?.rollback;if(!o||o.isRestoring||!Array.isArray(o.timeline)||typeof o.currentIndex!="number")return null;let a=r?.at(-1),t=typeof a?.checkpointIndex=="number"?a.checkpointIndex:o.currentIndex;if(t<0||t>=o.timeline.length)return null;if(typeof a?.checkpointIndex!="number"&&t<o.timeline.length-1){o.timeline=o.timeline.slice(0,t+1);let s=Ci(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,t+1))}return o.timeline[t]??null},yb=({state:e,rollbackActionBatchStack:r,playbackOwnership:n},o={})=>{let a=o?.source===it?it:kr,t=e.contexts?.[e.contexts.length-1],s=t?.rollback;if(!s||s.isRestoring||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"||s.currentIndex<0||s.currentIndex>=s.timeline.length)return r.push({checkpointIndex:null,source:a}),e;if(s.currentIndex<s.timeline.length-1){s.timeline=s.timeline.slice(0,s.currentIndex+1);let u=Ci(t);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let i=t?.pointers?.read,l=n?.lineEntryId,c=a===it&&(n?.rollbackCheckpointLineEntryId===void 0?s.timeline[s.currentIndex]?.sectionId===i?.sectionId&&s.timeline[s.currentIndex]?.lineId===i?.lineId:n.rollbackCheckpointLineEntryId===l);return r.push({checkpointIndex:s.currentIndex,source:a,...a===it?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},hb=({state:e,rollbackActionBatchStack:r})=>(r.pop(),e),gb=({state:e,rollbackActionBatchStack:r,playbackOwnership:n})=>{let o=r?.at(-1);if(o?.source!==it||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;Zn(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},bb=({state:e,rollbackActionBatchStack:r},n)=>{if(r?.at(-1)?.source!==it)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=Tn(n.result,n.type),t=mu(e,r);if(!t)return e;if(t.randomOutcomeVersion!==ar&&(t.randomOutcomeVersion=ar,t.randomOutcomes=[]),t.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 t.randomOutcomes.push({path:n.path,ordinal:n.ordinal,type:n.type,result:a}),e},Je=(e,r,n,o)=>{let t=o?.at(-1)?.source??kr;if(!bw(r,t))return;let s=mu(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:r,payload:V(n)}))},fi=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return;let o=r?.operations??[];for(let{variableId:a,op:t,value:s,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(Se(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Rt(c,a),Ct(u,t,a),Rn(u,t,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=Cn(n.variables[a],t,s,{roundTo:i}))}},Ib=(e,r)=>{Array.isArray(r?.executedActions)&&r.executedActions.forEach(({type:n,payload:o})=>{Iw(e,n,o)})},wb=(e,r)=>{let{sectionId:n,lineId:o}=r,s=ve({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&Ji(e,s,{checkpoint:r,bindings:{},randomOutcomeOrdinals:new Map},[])},yu=(e,r)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=xr(n),a=o.timeline[r];if(!a)return e;e.global.autoMode&&Wt({state:e}),e.global.skipMode&&Ar({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=r;try{n.variables=Ni(e.projectData),n.kind==="sceneReplay"&&(pu(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(Xn),e.global.overlayStack=[],ct(e),ut(e),e.global.isLineCompleted=!0;let t=o.replayStartIndex??0;for(let l=t;l<=r;l++)l>t&&Si(e),wb(e,o.timeline[l]),Ib(e,o.timeline[l]);let s=pt(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=Ri(n);i&&(i.currentLength=Math.min(i.checkpointLengths[r]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=qc(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},kb=e=>{let{projectData:r}=e,n=e.initialAudioCommandId??0;if(!Number.isSafeInteger(n)||n<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:t={},runtime:s={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;Gc(r),xt(r),Et(r),St(r),Dr(r?.resources?.variables??{});let u=r.story.initialSceneId,p=r.story.scenes[u],f=p.initialSectionId,d=p.sections[f],m={sceneId:u,sectionId:f,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:y}=On(r),g={...y,...Ot(t,r.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:r,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Tg(i,"accountViewedRegistry"),accountReplayRegistry:Ng(l),nextLineConfig:Yt(),imageGalleryNavigation:Ai(),sceneReplayNavigation:Ei(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:Jn(),saveSlots:Og(a),localizationPackages:V(c),overlayStack:[],variables:g,...nb({projectData:r,loadedGlobalRuntime:s})},contexts:[Di({pointer:m,projectData:r})]}},vb=({state:e})=>e.global.overlayStack||[],Ab=({state:e})=>e.global.pendingEffects,hu=({state:e})=>e.global.skipMode,Pb=({state:e})=>e.global.autoMode,gu=({state:e})=>e.global.dialogueUIHidden,bu=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(!n)return[];let o,a=M(n.dialogueHistory)&&Array.isArray(n.dialogueHistory.entries)&&Number.isInteger(n.dialogueHistory.currentLength);if(a)o=n.dialogueHistory.entries.slice(0,n.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=n.pointers.read,p=ve({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let f=p.lines.findIndex(d=>d.id===u);o=p.lines.slice(0,f+1).map(d=>({sectionId:c,lineId:d.id}))}let t=[],s=Qr({variables:{...e.global?.variables??{},...Pr(e)?.variables??{}},runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let f=ve({state:e},{sectionId:c.sectionId}),d=Array.isArray(f?.lines)?f.lines:[];u={lines:d,lineIndexes:new Map(d.map((m,y)=>[m.id,y])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let f=u.lines[u.nextLineIndex],d=f.actions||{};u.presentationState=Mr([u.presentationState,d]),u.projections.set(f.id,{line:f,lineActions:d,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!Ag(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:f,dialogueState:d}=u;if(!f.dialogue)continue;let m=Sn({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:s}),y=vg({sectionId:c.sectionId,lineId:p.id,content:f.dialogue.append===!0?d.content:f.dialogue.content,dialogueState:d,characterName:m}),g=t[t.length-1];if((a?c.appendToPrevious===!0:f.dialogue.append===!0)&&g?.sectionId===c.sectionId){t[t.length-1]={...t[t.length-1],content:y.content,text:y.text,characterId:y.characterId,character:y.character,characterName:y.characterName};continue}t.push(y)}return t},xb=(e,r,n)=>{let o=!1;for(let a of r??[]){let{slotId:t,saveSlotIdentity:s,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[Br(t)],u=we(c)?mn(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}}})},Eb=({state:e},r={})=>{let n=Pr(e),o=n?.pointers?.read,a=Ht({state:e});if(!n||!M(a?.actions?.dialogue))return e;let t=xr(n),s=t.timeline?.[t.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=Ri(n),c=l?.checkpointLengths?.[t.currentIndex],u=t.currentIndex>0?l?.checkpointLengths?.[t.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(r.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||r.forceNewOccurrence!==!0&&i&&l&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let f=Pg(n);f.currentLength<f.entries.length&&(f.entries=f.entries.slice(0,f.currentLength));let d=a.actions.dialogue.append===!0&&r.appendToPrevious===!0&&eu(e.projectData,p,o);if(f.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),f.currentLength=f.entries.length,i){for(;f.checkpointLengths.length<t.timeline.length;)f.checkpointLengths.push(f.checkpointLengths.at(-1)??0);f.checkpointLengths[t.currentIndex]=f.currentLength}return xb(e,r.savedCheckpointOccurrences,f),e},Sb=({state:e})=>e.global.confirmDialog??null,Gt=({state:e},{pointer:r}={})=>{let n=r??Te({state:e})?.pointer,o=rb({state:e,pointer:n});return tb({state:e,form:o.form,pointer:n})},Ob=({state:e},{pointer:r}={})=>!!Gt({state:e},{pointer:r}),Ae=({state:e},{pointer:r}={})=>{let n=Gt({state:e},{pointer:r});if(n)return{source:vr,formId:n.id,formKey:n.key};let o=Pu({state:e,pointer:r});return o?{source:at,resourceId:o}:null},Rb=({state:e,registry:r},n)=>{let{sectionId:o,lineId:a}=n,s=(Array.isArray(r?.sections)?r.sections:[]).find(u=>u.sectionId===o);if(!s)return!1;if(s.lastLineId===void 0||a===void 0)return!0;let i=ve({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=i.lines.findIndex(u=>u.id===s.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},Li=({registry:e},r)=>{let{resourceId:n}=r;return!!(Array.isArray(e?.resources)?e.resources:[]).find(t=>t.resourceId===n)},Mi=({state:e},r)=>Rb({state:e,registry:e.global.accountViewedRegistry},r),Cb=({state:e},r)=>Li({registry:e.global.accountViewedRegistry},r),Ut=(e,r)=>!Li({registry:e.global.accountViewedRegistry},{resourceId:r.imageId}),Vi=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),qi=(e,r)=>{let n=Vi(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},mi=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!Ut(e,r[a]))return r[a]},$b=({state:e})=>{let r=e.projectData?.resources?.imageGallery;return r===void 0?void 0:V(r)},Iu=({state:e})=>{let r=e.projectData?.resources?.imageGallery;if(r===void 0)return null;let n=e.global.imageGalleryNavigation??Ai(),o=Vi(r),a=qi(r,n),t=a*r.pageSize,s=r.groups.slice(t,t+r.pageSize).map(l=>({groupId:l.id,locked:Ut(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:Ut(e,c)}))})),i=null;if(typeof n.groupId=="string"&&typeof n.variantId=="string"){let l=r.groups.findIndex(d=>d.id===n.groupId),c=r.groups[l],u=c?.variants.findIndex(d=>d.id===n.variantId),p=u===void 0||u<0?void 0:c.variants[u],f=l<0?-1:Math.floor(l/r.pageSize);p&&f===a&&!Ut(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:mi(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:mi(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Fi=(e,r)=>!Li({registry:e.global.accountViewedRegistry},{resourceId:r.soundId}),Ui=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Bi=(e,r)=>{let n=Ui(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},yi=(e,r,n,o)=>{for(let a=n+o;a>=0&&a<r.length;a+=o)if(!Fi(e,r[a]))return r[a]},wu=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}),_b=(e,r)=>({...wu(r),locked:Fi(e,r)}),Dc=e=>{let r=Math.floor(e/1e3),n=r%60,o=Math.floor(r/60);if(o<60)return`${o}:${String(n).padStart(2,"0")}`;let a=Math.floor(o/60),t=o%60;return`${a}:${String(t).padStart(2,"0")}:${String(n).padStart(2,"0")}`},Tb=({state:e})=>{let r=e.projectData?.resources?.musicRoom;return r===void 0?void 0:V(r)},ku=({state:e})=>{let r=e.projectData?.resources?.musicRoom;if(r===void 0)return null;let n=e.global.musicRoomPlayer??Jn(),o=Ui(r),a=Bi(r,n),t=a*r.pageSize,s=r.tracks.slice(t,t+r.pageSize).map(u=>_b(e,u)),i=r.tracks.findIndex(u=>u.id===n.trackId),l=r.tracks[i],c=l?{...wu(l),canPlayPreviousTrack:yi(e,r.tracks,i,-1)!==void 0,canPlayNextTrack:yi(e,r.tracks,i,1)!==void 0}:null;return{pageTracks:s,selection:c,playback:c?{status:n.status,readiness:n.readiness,positionMs:n.positionMs,durationMs:n.durationMs,positionText:Dc(n.positionMs),durationText:n.durationMs===null?null:Dc(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}}},Yi=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),zi=(e,r)=>{let n=Yi(e);if(n===0)return 0;let o=Number.isInteger(r?.pageIndex)?r.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Nb=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;return r===void 0?void 0:V(r)},jb=({state:e})=>ye(e)!==null,Db=({state:e})=>{let r=ye(e);return r?{sceneId:r.sceneReplay.sceneId,entryId:r.sceneReplay.entryId}:null},vu=(e,r)=>e.global.accountReplayRegistry?.sceneIds?.includes(r)===!0,Au=({state:e})=>{let r=e.projectData?.resources?.sceneReplay;if(r===void 0)return null;let n=e.global.sceneReplayNavigation??Ei(),o=Yi(r),a=zi(r,n),t=a*r.pageSize,s=r.replays.slice(t,t+r.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!vu(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}}},Lb=({state:e})=>e.global.nextLineConfig,Pu=({state:e,pointer:r}={})=>{let n=r??Te({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=ve({state:e},{sectionId:o})?.lines||[],i=s.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of s.slice(0,i+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},xu=({state:e})=>!!Pu({state:e}),Mb=({state:e})=>structuredClone(e),Vb=({state:e})=>V(e.projectData.resources?.achievements??{}),qb=({state:e},r)=>{let n=e.projectData.resources?.achievements?.[r?.resourceId];return n===void 0?void 0:V(n)},Eu=({state:e})=>e.global.saveSlots,Fb=({state:e},r)=>{let n=r?.slotId,o=Br(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Su=({state:e})=>V(e.global.localizationPackages),Gi=({state:e})=>gr(e),Ub=({state:e},r)=>We(e,r?.runtimeId),Hi=({state:e})=>{let r={...e.global?.variables??{},...Pr(e)?.variables??{}};return Qr({variables:r,runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{}})},Te=({state:e})=>{let r=Array.isArray(e.contexts)?e.contexts:[],n=r[r.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},ve=({state:e},r)=>{let{sectionId:n}=r;return Ge(e.projectData,n).section},Ht=({state:e})=>{let r=Te({state:e});if(!r?.pointer)return;let{sectionId:n,lineId:o}=r.pointer,a=ve({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(t=>t.id===o)},Ou=({state:e})=>{let{sectionId:r,lineId:n}=Te({state:e}).pointer,a=ve({state:e},{sectionId:r})?.lines||[],t=a.findIndex(c=>c.id===n),i=a.slice(0,t+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(f=>{p[f]=u[f]}),p});return Mr(i)},Ru=e=>{let r=Ht({state:e})?.actions?.dialogue;if(r?.clear===!0||!Array.isArray(r?.content))return"";let n=Qr({variables:{...e.global?.variables??{},...Pr(e)?.variables??{}},runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return r.content.map(o=>`${et(o?.text,{variables:n})??""}`).join("")},lr=({state:e})=>ui({text:Ru(e),baseDelay:We(e,"autoForwardDelay"),speed:We(e,"autoForwardSpeed")}),Bb=({state:e})=>{let r=Cu({state:e}),o=Ht({state:e})?.actions??{},a=Mr([r??{},o]);return Oo(r??{},a??{})},Yb=({state:e},{sectionId:r})=>{let n=ve({state:e},{sectionId:r});if(!n?.lines)return[];let o=[],a={};for(let t of n.lines){let s=t.actions||{},i=Mr([a,s]),l=Oo(a,i);o.push({id:t.id,changes:l,presentationState:i}),a=Ro(i)}return o},zb=({state:e},{sectionId:r,includePresentationState:n=!1})=>{let o=Yb({state:e},{sectionId:r});return n?{lines:o}:{lines:o.map(({presentationState:a,...t})=>t)}},Cu=({state:e})=>{let{sectionId:r,lineId:n}=Te({state:e}).pointer,a=ve({state:e},{sectionId:r})?.lines||[],t=a.findIndex(l=>l.id===n);if(t<=0)return null;let i=a.slice(0,t).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return Ro(Mr(i))},Xi=({state:e},{slotsPerPage:r=6}={})=>{let a=((Gi({state:e}).saveLoadPagination??1)-1)*r+1,t=[];for(let s=0;s<r;s++){let i=a+s,l=e.global.saveSlots&&e.global.saveSlots[Br(i)]||{};t.push({...l,slotId:i})}return{saveSlots:t}},Gb=Eu,Hb=Xi,Xb=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},Wb=({state:e},r={})=>{let n=Ou({state:e}),o=Cu({state:e}),a=Ht({state:e})?.actions??{},t=e.global.pendingScreenTransition,s=t?.animations?{...a,screen:V(t)}:a,i=t?.animations&&o===null?{}:o,{sectionId:l}=Te({state:e}).pointer,{sceneId:c}=Ge(e.projectData,l),u={...Gi({state:e}),localizationPackages:Su({state:e})},p=r?.activePersistentAnimations??[],f=r?.restoredPersistentAnimations??[],d=Gt({state:e}),m=xu({state:e}),y=Iu({state:e}),g=ku({state:e}),h=Au({state:e}),w=Hi({state:e}),{saveSlots:b}=Xi({state:e}),E=Xb(e);return dc({presentationState:n,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:m,isFormVisible:!!d,canRollback:Zu({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:bu({state:e}),saveSlots:b,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:f,imageGallery:y,musicRoom:g,sceneReplay:h,musicRoomPlayer:V(e.global.musicRoomPlayer)})},Kb=({state:e},r)=>(e.global.confirmDialog=Xg(r),e.global.pendingEffects.push({name:"render"}),e),Jb=({state:e})=>(e.global.confirmDialog&&(ct(e),e.global.pendingEffects.push({name:"render"})),e),Qb=({state:e,rollbackActionBatchStack:r},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),Je(e,"pushOverlay",n,r),e),Zb=({state:e,rollbackActionBatchStack:r})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),Je(e,"popOverlay",void 0,r),e),eI=({state:e,rollbackActionBatchStack:r},n)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=n),e.global.pendingEffects.push({name:"render"}),Je(e,"replaceLastOverlay",n,r),e),rI=({state:e,rollbackActionBatchStack:r})=>(e.global.overlayStack=[],ct(e),ut(e),e.global.pendingEffects.push({name:"render"}),Je(e,"clearOverlays",void 0,r),e),tI=(e,{activeInteraction:r})=>{e.global.autoMode&&e.global.pendingEffects.push({name:"clearAutoNextTimer"}),r&&e.global.skipMode&&e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.nextLineConfig?.auto?.enabled&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},Xt=(e,r,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Kg(e,n),ut(e);let o=Ae({state:e},{pointer:r}),a=o?.source===at,t=o?.source===vr;tI(e,{activeInteraction:o});let s=ye(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=qc(e);s.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:s.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:t,activeInteraction:o}},es=(e,r,n)=>{!(r?.source===at||r?.source===vr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},$u=({state:e})=>(Ae({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),Wt=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),nI=({state:e})=>{let r=e.global.autoMode;return Ae({state:e})&&!r||(r?Wt({state:e}):$u({state:e})),e},_u=({state:e})=>(Ae({state:e})||(e.global.autoMode&&(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"})),e.global.skipMode=!0,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.pendingEffects.push({name:"render"})),e),Ar=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),sI=({state:e})=>{let r=hu({state:e});return Ae({state:e})&&!r||(r?Ar({state:e}):_u({state:e})),e},rs=({state:e,rollbackActionBatchStack:r})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),Je(e,"showDialogueUI",void 0,r),e),Tu=({state:e,rollbackActionBatchStack:r})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),Je(e,"hideDialogueUI",void 0,r),e),oI=e=>{let{state:r}=e;return gu({state:r})?rs(e):Tu(e),r},Er=(e,r,n)=>(ji(e,r,n),du(e),e.global.pendingEffects.push({name:"render"}),e),Kt=(e,r,n,o,a)=>{let t=ji(e,r,n);return e.global.pendingEffects.push({name:"render"}),Je(e,o,{value:t},a),e},iI=({state:e},r)=>Er(e,"dialogueTextSpeed",r?.value),aI=({state:e},r)=>(Er(e,"autoForwardDelay",r?.value),e.global.autoMode&&e.global.isLineCompleted&&!Ae({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}}),e),lI=({state:e},r)=>(Er(e,"autoForwardSpeed",r?.value),e.global.autoMode&&e.global.isLineCompleted&&!Ae({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}}),e),cI=({state:e},r)=>Er(e,"skipUnseenText",r?.value),uI=({state:e},r)=>Er(e,"skipTransitionsAndAnimations",r?.value),pI=({state:e},r)=>Er(e,"soundVolume",r?.value),dI=({state:e},r)=>Er(e,"musicVolume",r?.value),fI=({state:e},r)=>Er(e,"muteAll",r?.value),hi=({state:e,rollbackActionBatchStack:r},n)=>Kt(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",r),gi=({state:e,rollbackActionBatchStack:r})=>{let n=We(e,"saveLoadPagination")+1;return Kt(e,"saveLoadPagination",n,"incrementSaveLoadPagination",r),e},bi=({state:e,rollbackActionBatchStack:r})=>{let n=We(e,"saveLoadPagination")-1;return Kt(e,"saveLoadPagination",n,"decrementSaveLoadPagination",r),e},Ii=({state:e,rollbackActionBatchStack:r},n)=>Kt(e,"menuPage",n?.value,"setMenuPage",r),wi=({state:e,rollbackActionBatchStack:r},n)=>Kt(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",r),mI=({state:e})=>(e.global.pendingEffects=[],e),yI=({state:e},r)=>(e.global.pendingEffects.push(r),e),hI=({state:e},r)=>{if(ye(e))return e;let n=r?.resourceId;return Fc(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},gI=({state:e},r)=>{if(ye(e))return e;let n=r?.resourceId,o=Fc(e,n);if(o.type!=="number")throw new Error(`Achievement resource "${n}" does not support numeric progress`);let a=r?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${n}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${n}" must have a positive integer target`);let t=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:n,current:t,target:o.target,completed:t>=o.target}}),e},Nu=e=>e?.lines?.[0],ju=(e,{sectionId:r,resetStoryState:n=!1,screen:o})=>{let a=!!iu(o),t=ve({state:e},{sectionId:r});if(!t)return console.warn(`Section not found: ${r}`),e;let s=Nu(t);if(!s)return console.warn(`Section ${r} has no lines`),e;if(n&&!ub(e,{queueRender:!a}))return e;let i=Ae({state:e});n&&e.global.skipMode&&Ar({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=pt(l),p=u.read;n||Ur(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||xr(l,{compatibilityAnchor:!0}),u.read={sectionId:r,lineId:s.id},n?l.rollback=Bt({pointer:u.read}):Zn(e,{sectionId:r,lineId:s.id})}let{activeInteraction:c}=Xt(e,l?.pointers?.read,{screenTransition:o});return es(e,i,c),e},bI=({state:e},r)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return ju(e,{sectionId:r?.sectionId,resetStoryState:!0,screen:r?.screen})},Du=e=>(e.global.accountViewedRegistry=Ig(e.global.accountViewedRegistry),e.global.accountViewedRegistry),ts=(e,r)=>{!Array.isArray(r)||r.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:r.map(n=>({scope:n.scope,path:n.path,op:n.op,value:V(n.value)}))}})},Lu=(e,r)=>{ts(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(r?.sections)?r.sections:[]).map(n=>({sectionId:n.sectionId,...n.lastLineId===void 0?{}:{lineId:n.lastLineId}})),resources:Array.isArray(r?.resources)?r.resources:[]}}])},II=(e,r,{sectionId:n,lineId:o})=>{if(!n||!o)return!1;let a=M(r)?r:{};Array.isArray(a.sections)||(a.sections=[]);let t=a.sections.find(s=>s.sectionId===n);if(t){if(t.lastLineId===void 0)return!1;let s=ve({state:e},{sectionId:n});if(s?.lines){let i=s.lines.findIndex(c=>c.id===t.lastLineId),l=s.lines.findIndex(c=>c.id===o);if(i===-1||l>i)return t.lastLineId===o?!1:(t.lastLineId=o,!0)}else return t.lastLineId===o?!1:(t.lastLineId=o,!0);return!1}else return a.sections.push({sectionId:n,lastLineId:o}),!0},Ur=(e,r)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;II(e,Du(e),r)&&Lu(e,{sections:[{sectionId:r.sectionId,lastLineId:r.lineId}],resources:[]})},wI=({state:e},r)=>(Ur(e,r),e.global.pendingEffects.push({name:"render"}),e),kI=({state:e},r)=>{if(ye(e))return e;let{resourceId:n}=r;if(e.global.accountViewedRegistry!==void 0){let o=Du(e);o.resources.find(t=>t.resourceId===n)||(o.resources.push({resourceId:n}),Lu(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},Qe=(e,r,n)=>{if(!M(r))throw new Error(`${e} payload must be an object`);Object.keys(r).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},ki=(e,r,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${r}`)},ns=(e,r)=>{let n=e.global.imageGalleryNavigation;n.groupId===r.groupId&&n.variantId===r.variantId&&n.pageIndex===r.pageIndex||(e.global.imageGalleryNavigation=r,e.global.pendingEffects.push({name:"render"}))},vI=({state:e},r)=>{let n="showImageGalleryVariant";Qe(n,r,dg),ki(n,"groupId",r.groupId),Object.prototype.hasOwnProperty.call(r,"variantId")&&ki(n,"variantId",r.variantId);let o=e.projectData?.resources?.imageGallery;if(o===void 0)return e;let a=o.groups.findIndex(i=>i.id===r.groupId),t=o.groups[a];if(!t)return e;let s=r.variantId===void 0?t.variants[0]:t.variants.find(i=>i.id===r.variantId);return!s||Ut(e,s)||ns(e,{groupId:t.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},Mu=(e,r,n,o)=>{Qe(o,r,Pi);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let t=e.global.imageGalleryNavigation;if(typeof t.groupId!="string"||typeof t.variantId!="string")return e;let s=a.groups.find(c=>c.id===t.groupId),i=s?.variants.findIndex(c=>c.id===t.variantId);if(!s||i===void 0||i<0)return e;let l=mi(e,s.variants,i,n);return l&&ns(e,{...t,variantId:l.id}),e},AI=({state:e},r)=>Mu(e,r,-1,"moveToPreviousImageGalleryVariant"),PI=({state:e},r)=>Mu(e,r,1,"moveToNextImageGalleryVariant"),xI=({state:e},r)=>{if(Qe("clearImageGallerySelection",r,Pi),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return ns(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},Vu=(e,r)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=Vi(n);if(r>=o)return e;let a=e.global.imageGalleryNavigation,t=qi(n,a);return r===t||ns(e,{groupId:null,variantId:null,pageIndex:r}),e},EI=({state:e},r)=>{if(Qe("moveToImageGalleryPage",r,fg),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return Vu(e,r.pageIndex)},qu=(e,r,n,o)=>{Qe(o,r,Pi);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=qi(a,e.global.imageGalleryNavigation)+n;return s<0?e:Vu(e,s)},SI=({state:e},r)=>qu(e,r,1,"moveToNextImageGalleryPage"),OI=({state:e},r)=>qu(e,r,-1,"moveToPreviousImageGalleryPage"),cr=(e,r,n)=>{if(!M(r))throw new Error(`${e} payload must be an object`);Object.keys(r).forEach(o=>{if(!n.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},RI=(e,r)=>{if(typeof r!="string"||r.length===0)throw new Error(`${e} requires a non-empty trackId`)},ze=e=>{e.global.pendingEffects.push({name:"render"})},Fu=(e,r)=>{let n=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,t=o.trackId===r.id,s=o.bgmPlayback;a||(s={commandId:Qn(e),operation:"pause"});let i=zt(e,"play",0),l=n.tracks.indexOf(r),c=t?o.durationMs:null;e.global.musicRoomPlayer={trackId:r.id,pageIndex:Math.floor(l/n.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:s},ze(e)},CI=({state:e},r)=>{let n="playMusicRoomTrack";cr(n,r,mg),RI(n,r.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(t=>t.id===r.trackId);return!a||Fi(e,a)||Fu(e,a),e},$I=({state:e},r)=>{cr("playMusicRoom",r,lt);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",t=o.readiness==="error",s=o.status==="paused"&&!t?"resume":"play",i=a?0:o.positionMs;return o.playback=zt(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,t&&(o.readiness=o.durationMs===null?"loading":"ready"),ze(e),e},_I=({state:e},r)=>{cr("pauseMusicRoom",r,lt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=zt(e,"pause"),o.seekFallback=null,o.status="paused",ze(e)),e},TI=({state:e},r)=>{cr("stopMusicRoom",r,lt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=zt(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,ze(e)),e},NI=({state:e},r)=>{if(cr("seekMusicRoom",r,yg),typeof r.positionMs!="number"||!Number.isFinite(r.positionMs)||r.positionMs<0)throw new Error("seekMusicRoom requires a finite non-negative positionMs");let o=e.global.musicRoomPlayer;if(o.trackId===null||o.readiness!=="ready"||o.durationMs===null||r.positionMs>o.durationMs)return e;let a=zt(e,"seek",r.positionMs);return o.seekFallback={commandId:a.commandId,status:o.status,positionMs:o.positionMs},o.playback=a,o.positionMs=r.positionMs,r.positionMs===o.durationMs?o.status="ended":o.status==="ended"&&(o.status="stopped"),ze(e),e},Uu=(e,r,n,o)=>{cr(o,r,lt);let a=e.projectData?.resources?.musicRoom,t=e.global.musicRoomPlayer;if(!a||t.trackId===null)return e;let s=a.tracks.findIndex(l=>l.id===t.trackId);if(s<0)return e;let i=yi(e,a.tracks,s,n);return i&&Fu(e,i),e},jI=({state:e},r)=>Uu(e,r,-1,"playPreviousMusicRoomTrack"),DI=({state:e},r)=>Uu(e,r,1,"playNextMusicRoomTrack"),LI=({state:e},r)=>{cr("clearMusicRoomSelection",r,lt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,t={commandId:Qn(e),operation:"resume"};return e.global.musicRoomPlayer={...Jn({bgmPlayback:t}),pageIndex:a},ze(e),e},Bu=(e,r)=>{let n=e.projectData?.resources?.musicRoom;if(!n||r>=Ui(n))return e;let o=e.global.musicRoomPlayer,a=Bi(n,o);return r===a||(o.pageIndex=r,ze(e)),e},MI=({state:e},r)=>{if(cr("moveToMusicRoomPage",r,hg),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Bu(e,r.pageIndex)},Yu=(e,r,n,o)=>{cr(o,r,lt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let t=Bi(a,e.global.musicRoomPlayer)+n;return t<0?e:Bu(e,t)},VI=({state:e},r)=>Yu(e,r,1,"moveToNextMusicRoomPage"),qI=({state:e},r)=>Yu(e,r,-1,"moveToPreviousMusicRoomPage"),Fr=e=>{let r=ye(e);if(!r)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let n=V(r.sceneReplay.returnState),o=r.sceneReplay.sceneId;return e.global.pendingEffects=e.global.pendingEffects.filter(a=>a?.name!=="handleLineActions"||a?.payload?.sceneReplaySceneId!==o),e.contexts.pop(),ab(e,n),e.global.pendingEffects.push({name:"render"}),!0},FI=({state:e},r)=>{let n="startSceneReplay";if(Qe(n,r,gg),ki(n,"sceneId",r.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===r.sceneId);if(!a||!vu(e,a.sceneId))return e;let t=e.projectData.story.scenes[a.sceneId],s=t?.initialSectionId,i=t?.sections?.[s],l=i?.initialLineId??i?.lines?.[0]?.id;if(!i||!l||!i.lines.some(p=>p.id===l))throw new Error(`Scene replay scene "${a.sceneId}" has an invalid initial section`);let c=ob(e);ib(e);let u=Di({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 pu(e,u),e.contexts.push(u),Xt(e,u.pointers.read),e},zu=({state:e},r)=>{Qe("finishSceneReplay",r,xi);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Pr(e)?.rollback?.isRestoring===!0)return e;let t=Te({state:e})?.pointer,{sceneId:s}=Ge(e.projectData,t?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=wg(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),ts(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},UI=({state:e},r)=>(Qe("exitSceneReplay",r,xi),Fr(e),e),Gu=(e,r)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||r>=Yi(n))return e;let o=zi(n,e.global.sceneReplayNavigation);return r===o||(e.global.sceneReplayNavigation.pageIndex=r,e.global.pendingEffects.push({name:"render"})),e},BI=({state:e},r)=>{if(Qe("moveToSceneReplayPage",r,bg),!Number.isInteger(r.pageIndex)||r.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Gu(e,r.pageIndex)},Hu=(e,r,n,o)=>{Qe(o,r,xi);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let t=zi(a,e.global.sceneReplayNavigation)+n;return t<0?e:Gu(e,t)},YI=({state:e},r)=>Hu(e,r,1,"moveToNextSceneReplayPage"),zI=({state:e},r)=>Hu(e,r,-1,"moveToPreviousSceneReplayPage"),ss=(e,r)=>{let n=e.global.musicRoomPlayer;return!M(r)||r.id!==ug||n.trackId===null||!n.playback||r.commandId!==n.playback.commandId?null:n},Wi=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,Xu=(e,r,n,{readiness:o=r.readiness}={})=>((r.readiness!==o||r.positionMs!==n.positionMs||r.durationMs!==n.durationMs||r.seekFallback!==null)&&(r.readiness=o,r.positionMs=n.positionMs,r.durationMs=n.durationMs,r.seekFallback=null,ze(e)),e),GI=({state:e},r)=>{let n=ss(e,r);return!n||n.readiness!=="loading"||!Wi(r)?e:Xu(e,n,r,{readiness:"ready"})},HI=({state:e},r)=>{let n=ss(e,r);return!n||n.readiness!=="ready"||!Wi(r)||n.status==="stopped"&&r.positionMs!==0||n.status==="ended"&&r.positionMs!==r.durationMs?e:Xu(e,n,r)},XI=({state:e},r)=>{let n=ss(e,r);return!n||n.readiness!=="ready"||n.status!=="playing"||!Wi(r)||r.positionMs!==r.durationMs||(n.status="ended",n.positionMs=r.positionMs,n.durationMs=r.durationMs,n.seekFallback=null,ze(e)),e},WI=({state:e},r)=>{let n=ss(e,r);if(!n||typeof r.errorCode!="string"||!pg.has(r.errorCode)||n.readiness==="error"&&n.status==="stopped")return e;if(r.errorCode==="invalid-position"){let o=n.seekFallback;if(n.playback.operation!=="seek"||o?.commandId!==r.commandId)return e;let a=n.status!==o.status||n.positionMs!==o.positionMs;return n.status=o.status,n.positionMs=o.positionMs,n.seekFallback=null,a&&ze(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,ze(e),e},Wu=({state:e,rollbackActionBatchStack:r},n)=>{let o=Eg(n.manual),{auto:a,applyMode:t}=n,s=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},t!==void 0?e.global.nextLineConfig.applyMode=t:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),t!==void 0&&(e.global.nextLineConfig.applyMode=t));let p=e.global.nextLineConfig.auto?.enabled,f=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,m=Ae({state:e});return!u&&(a!==void 0&&(p!==s||f!==i||d!==l))&&(!m&&p===!0&&(f==="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"}),Je(e,"setNextLineConfig",n,r),e},KI=({state:e},r)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let n=r?.slotId;Uc(n,"saveSlot");let{thumbnailImage:o}=r,a=r?.savedAt,t=Br(n),s=V(e.contexts);s?.forEach(c=>{pt(c),fu(c.rollback),$g(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:Vc,slotId:Hc(n),savedAt:typeof a=="number"?a:Date.now(),image:o,state:i};return e.global.saveSlots[t]=l,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}},{name:"render"}),e},JI=({state:e},r)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let n=r?.slotId;Uc(n,"loadSlot");let o=Br(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let t=Hg(a,e.projectData);e.contexts=t.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=Yt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,ct(e),ut(e),Oi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},QI=({state:e},r)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=r;Gc(n),xt(n),Et(n),St(n),Dr(n?.resources?.variables??{}),Do(n);let o=jg(n),a=o?e.contexts?.map((s,i)=>ou(V(s),n,i)):void 0,t=o?_g(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=Ai(),e.global.sceneReplayNavigation=Ei(),Oi(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:i}=On(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Ot(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=t}return ct(e),ut(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},ZI=({state:e},r)=>{let{l10nId:n,projectData:o}=r??{};if(n!==null&&(typeof n!="string"||n.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!M(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,ji(e,"localizationPackageId",n),du(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Ae({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},ew=({state:e},r)=>{let{sectionId:n,lineId:o}=r;if(!o)return console.warn("jumpToLine requires lineId parameter"),e;let a=e.contexts[e.contexts.length-1];if(!a)return console.warn("No context available for jumpToLine"),e;let t=n||a.pointers.read?.sectionId;if(n&&!ve({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=ve({state:e},{sectionId:t});if(!s?.lines||!Array.isArray(s.lines))return console.warn(`Section ${t} has no lines`),e;if(!s.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${t}`),e;let l=Ae({state:e}),c=pt(a);c.read={sectionId:t,lineId:o};let{activeInteraction:u}=Xt(e,c.read);return es(e,l,u),e},rw=({state:e,rollbackActionBatchStack:r},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return rs({state:e,rollbackActionBatchStack:r}),e;let o=Ae({state:e});if(o?.source===at&&n?.bypassChoice!==!0||o?.source===vr&&n?._interactionSource!==vr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return Fr(e),e;let d=Te({state:e})?.pointer,m=d?.sectionId,y=d?.lineId;m&&y&&Ur(e,{sectionId:m,lineId:y}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}});let g=e.global.nextLineConfig,h=ve({state:e},{sectionId:m});return Array.isArray(h?.lines)&&h.lines.at(-1)?.id===y?di(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 Fr(e),e;let t=Te({state:e})?.pointer,s=t?.sectionId,i=ve({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(f=>f.id===t?.lineId)+1;if(p<c.length){let f=c[p],d=!We(e,"skipUnseenText");if(e.global.skipMode&&d&&!Mi({state:e},{sectionId:s,lineId:f.id}))return Ar({state:e}),e;if(l&&!l.rollback&&xr(l,{compatibilityAnchor:!0}),l){let y=pt(l),g=y.read?.lineId;g&&s&&Ur(e,{sectionId:s,lineId:g}),y.read={sectionId:s,lineId:f.id}}Zn(e,{sectionId:s,lineId:f.id}),Si(e);let{activeInteraction:m}=Xt(e,{sectionId:s,lineId:f.id});es(e,o,m)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Fr(e),e;e.global.autoMode&&Wt({state:e}),e.global.skipMode&&Ar({state:e}),di(e)}return e},tw=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return Fr(e),e;let n=Ae({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}});let o=Te({state:e})?.pointer,a=o?.sectionId,t=o?.lineId;a&&t&&Ur(e,{sectionId:a,lineId:t});let s=e.global.nextLineConfig;return s?.auto?.enabled&&!n&&s.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:s.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},nw=({state:e},r)=>ju(e,{sectionId:r?.sectionId,screen:r?.screen}),sw=({state:e,rollbackActionBatchStack:r},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return rs({state:e,rollbackActionBatchStack:r}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:lr({state:e})}}),e;let a=Ae({state:e});if(a?.source===at&&n?.bypassChoice!==!0||a?.source===vr&&n?._interactionSource!==vr||a&&a.source!==at&&a.source!==vr)return e;let t=ye(e);if(t?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(Fr(e),e):(t.sceneReplay.exitOnLineCompleted=!0,e);let s=Te({state:e})?.pointer,i=s?.sectionId,l=ve({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],f=u.findIndex(d=>d.id===s?.lineId)+1;if(f<u.length){let d=u[f],m=!We(e,"skipUnseenText");if(e.global.skipMode&&m&&!Mi({state:e},{sectionId:i,lineId:d.id})&&(Ar({state:e}),!o))return e;if(c&&!c.rollback&&xr(c,{compatibilityAnchor:!0}),c){let g=pt(c),h=g.read?.lineId;h&&i&&Ur(e,{sectionId:i,lineId:h}),g.read={sectionId:i,lineId:d.id}}Zn(e,{sectionId:i,lineId:d.id}),Si(e);let{activeInteraction:y}=Xt(e,{sectionId:i,lineId:d.id});es(e,a,y)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Fr(e),e;e.global.autoMode&&Wt({state:e}),e.global.skipMode&&Ar({state:e}),di(e)}return e},Ki=(e,r={})=>{let n=Gt({state:e});return!n||r.formKey&&r.formKey!==n.key||r.formId&&r.formId!==n.id?null:n},ow=(e,r)=>{if(!r.variableId)throw new Error(`form field "${r.id}" requires variableId`);let n=e.projectData.resources?.variables?.[r.variableId],o=n?.scope,a=n?.type;if(Se(n))throw new Error(`Cannot update computed variable: ${r.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${r.variableId}`);if(Rt(o,r.variableId),Ct(a,"set",r.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${r.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},iw=(e,r)=>({id:e.id,key:e.key,valid:!0,values:V(r),fields:V(e.fields),fieldList:V(e.fieldList)}),aw=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let r=Te({state:e})?.pointer,n=r?.sectionId,o=r?.lineId;n&&o&&Ur(e,{sectionId:n,lineId:o})},lw=({state:e},r={})=>{let n=Ki(e,r),o=r.field;if(!n?.fields?.[o])return e;let a=lu(e,n.key),t=Wn(r.value),s=n.fields[o],i=Ti(s,t);return a.values[o]=t,a.touched[o]=!0,i?a.errors[o]=i:delete a.errors[o],e.global.pendingEffects.push({name:"render"}),e},cw=({state:e,rollbackActionBatchStack:r},n={})=>{let o=Ki(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=lu(e,o.key);a.submitted=!0;let t={},s={};if(Object.entries(o.fields).forEach(([f,d])=>{let m=Object.prototype.hasOwnProperty.call(a.values,f)?a.values[f]:d.value,y=Ti(d,m);a.touched[f]=!0,y&&(s[f]=y),t[f]=au(d,m)}),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(t)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([f,d])=>{let{scope:m}=ow(e,d),y=m==="context"?i.variables:e.global.variables,g=t[f];y[d.variableId]=Cn(y[d.variableId],"set",g),m==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:g})),(m==="device"||m==="account")&&c.push({scope:m,path:`variables.${d.variableId}`,op:"set",value:V(y[d.variableId])})}),l&&Je(e,"updateVariable",{id:"submitForm",operations:u},r),ts(e,c);let p=iw(o,t);return aw(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},uw=({state:e},r={})=>{let n=Ki(e,r);return n?(delete e.global.formDrafts?.[n.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:n.id,key:n.key,values:V(n.values),fields:V(n.fields),fieldList:V(n.fieldList)}}):{cancelled:!1,reason:"inactive"}},pw=({state:e,rollbackActionBatchStack:r},n)=>{let{id:o,operations:a=[]}=n;if(!o)throw new Error("updateVariable requires an id field");if(typeof o!="string"||!/^[a-zA-Z0-9]+$/.test(o))throw new Error(`updateVariable id must be alphanumeric, got: "${o}"`);let t=e.contexts[e.contexts.length-1];if(t?.rollback?.isRestoring)return e;let s=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:f})=>{let d=e.projectData.resources?.variables?.[c],m=d?.scope,y=d?.type;if(Se(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Rt(m,c),Ct(y,u,c),Rn(y,u,p,c,{roundTo:f}),ye(e)&&m!=="context")throw new Error(`Cannot update ${m}-scoped variable "${c}" while a scene replay is active`);let g=m==="context"?t.variables:e.global.variables;if(m==="context"){s=!0;let h={variableId:c,op:u,value:p};f!==void 0&&(h.roundTo=f),l.push(h)}g[c]=Cn(g[c],u,p,{roundTo:f}),(m==="device"||m==="account")&&i.push({scope:m,path:`variables.${c}`,op:"set",value:V(g[c])})}),s&&Je(e,"updateVariable",{id:o,operations:l},r),ts(e,i),e.global.pendingEffects.push({name:"render"}),e},Ue=e=>(r,n)=>e({state:r},n),Ku=e=>({variables:Qr({variables:{...e.global?.variables??{},...Pr(e)?.variables??{}},runtime:gr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:gr(e)}),dw=e=>{if(!M(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},fw=(e,r,n)=>{if(!M(e))throw new Error(`conditional branch at index ${r} must be an object`);if(!M(e.actions))throw new Error(`conditional branch at index ${r} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&r!==n-1)throw new Error("conditional else branch must be the last branch")},mw=(e,r,n,o)=>{dw(r);for(let a=0;a<r.branches.length;a+=1){let t=r.branches[a];if(fw(t,a,r.branches.length),!(Object.prototype.hasOwnProperty.call(t,"when")&&!Pt(t.when,{...Ku(e),...n?.bindings??{}}))){Ji(e,t.actions,n,[...o,"branches",String(a),"actions"]);return}}},yw=(e,r,n,o)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==ar)return;let t=o.join("."),s=n.randomOutcomeOrdinals,i=s.get(t)??0;s.set(t,i+1);let l=a.randomOutcomes?.find(p=>p.path===t&&p.ordinal===i);if(!l)return;if(r?.distribution?.type!==l.type)throw new Error(`recorded random outcome type does not match canonical action at ${t}`);let c=Tn(V(l.result),l.type);if(c.type==="integer"){if(!Kc(r.distribution)||c.value<r.distribution.min||c.value>r.distribution.max)throw new Error(`recorded random outcome does not match canonical action at ${t}`);fi(e,{id:"randomResult",operations:[{variableId:r.variableId,op:"set",value:c.value}]});return}let u=r.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!M(u))throw new Error(`recorded random outcome does not match canonical action at ${t}`);Ji(e,u,n,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},hw={conditional:{replayLine:mw},random:{replayLine:yw},updateVariable:{recordSources:[kr],replayLine:fi,replayRecorded:fi,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Ue(Wu)},setSaveLoadPagination:{recordSources:[kr],replayLine:Ue(hi),replayRecorded:Ue(hi),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[kr],replayLine:Ue(gi),replayRecorded:Ue(gi),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[kr],replayLine:Ue(bi),replayRecorded:Ue(bi),persistInSaveSlot:!0},setMenuPage:{recordSources:[kr],replayLine:Ue(Ii),replayRecorded:Ue(Ii),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[kr],replayLine:Ue(wi),replayRecorded:Ue(wi),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Ue(zu)}},os=e=>hw[e]??null,gw=e=>os(e)?.persistInSaveSlot===!0,bw=(e,r)=>{let n=os(e)?.recordSources;return Array.isArray(n)&&n.includes(r)},Iw=(e,r,n)=>{os(r)?.replayRecorded?.(e,n)},ww=(e,r,n,o,a)=>{let t=os(r);if(!t?.replayLine)return;if(r==="conditional"||r==="random"){t.replayLine(e,n,o,a);return}let s=o?.bindings??{},i=$t({[r]:n},{...Ku(e),...s})[r];t.replayLine(e,i)},Ji=(e,r,n,o)=>{let a=Nn(r);jn(a);for(let[t,s]of a)ww(e,t,s,n,[...o,t])},kw=e=>e?.returnable!==!1,Ju=(e,r)=>{if(r>=0)return e.currentIndex+r;let n=Math.abs(r);for(let o=e.currentIndex-1;o>=0;o-=1)if(kw(e.timeline[o])&&(n-=1,n===0))return o;return-1},Qu=({state:e},r)=>{let{offset:n}=r;if(n===void 0||typeof n!="number")return console.warn("selectLineIdByOffset requires a numeric offset"),null;let o=e.contexts[e.contexts.length-1];if(!o)return null;let a=o.rollback;if(!Array.isArray(a?.timeline)||typeof a?.currentIndex!="number")return null;let t=Ju(a,n);if(t<0||t>=a.timeline.length)return null;let s=a.timeline[t];return{sectionId:s.sectionId,lineId:s.lineId}},Zu=({state:e})=>Qu({state:e},{offset:-1})!==null,vw=({state:e},r)=>{let{offset:n=-1}=r;if(n>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=xr(o,{compatibilityAnchor:!o.rollback}),t=Ju(a,n);return t<0||t>=a.timeline.length?e:yu(e,t)},Aw=({state:e},r)=>{let{sectionId:n,lineId:o}=r,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let t=xr(a,{compatibilityAnchor:!a.rollback}),i=t.timeline.slice(0,t.currentIndex+1).findLastIndex(l=>l.sectionId===n&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${n} rollback timeline`);return i===t.currentIndex?e:yu(e,i)},Pw=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),pi=(e,r)=>{let n=e[r];if(!Number.isSafeInteger(n)||n<0)throw new RangeError(`Internal playback ${r} is invalid`);if(n===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${r} is exhausted`);return e[r]=n+1,e[r]},Lc=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Mc=e=>{let r=e.contexts?.[e.contexts.length-1];return Number.isInteger(r?.rollback?.currentIndex)?r.rollback.currentIndex:null},xw=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,ep=e=>{let r=e.global?.nextLineConfig?.auto;return r?.enabled!==!0?{enabled:!1}:{enabled:!0,trigger:r.trigger==="fromStart"?"fromStart":"fromComplete",delayMs:r.delay??1e3}},Qi=e=>JSON.stringify(ep(e)),Ew=({actionName:e,args:r,state:n,previousState:o})=>{let a=Lc(o),t=Lc(n);if(!xw(a,t)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Mc(o)!==Mc(n))return!0;let s=r[0]??{};if(e==="jumpToLine"){let i=s.sectionId??a?.sectionId;return typeof s.lineId=="string"&&t?.sectionId===i&&t?.lineId===s.lineId&&n.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=Ge(n.projectData,s.sectionId).section,l=Nu(i)?.id;return typeof l=="string"&&t?.sectionId===s.sectionId&&t?.lineId===l&&n.global.isLineCompleted===!1}if(e==="loadSlot"){let i=s.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},Br(i))}return!1},Sw=({actionName:e,args:r,state:n,transactionalMetadata:o,previousState:a})=>{if(Ew({actionName:e,args:r,state:n,previousState:a})){let u=pi(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:Qi(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"?Ae({state:a}):null;n.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||s&&a.global.autoMode!==!0)&&pi(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&pi(o,"skipSessionId")},Ow=({state:e,transactionalMetadata:r})=>{let n=r.rollbackAuthoredSuppression;n&&(n.lineEntryId!==r.lineEntryId||n.configKey!==Qi(e))&&(r.rollbackAuthoredSuppression=null)},Rw=({state:e,playbackOwnership:r})=>{let n=Ae({state:e}),o=r.lineEntryId,a=!n&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,t=!n&&e.global.skipMode===!0,s=ep(e),i=r.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===Qi(e)),c=a?Ru(e):null;return{auto:a?{owner:{sessionId:r.autoSessionId,lineEntryId:o},delayMs:ui({text:c,baseDelay:We(e,"autoForwardDelay"),speed:We(e,"autoForwardSpeed")}),contentKey:c}:null,skip:t?{owner:{sessionId:r.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:s.delayMs,trigger:s.trigger}:null}},Cw=({playbackOwnership:e})=>e.lineEntryId,rp=(e,r={})=>{let n=kb(e),o=[],a=r.createPlaybackOwnership??Pw;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return tl(n,{selectPendingEffects:Ab,selectSkipMode:hu,selectAutoMode:Pb,selectIsChoiceVisible:xu,selectIsFormVisible:Ob,selectActiveInteraction:Ae,selectActiveForm:Gt,selectDialogueUIHidden:gu,selectDialogueHistory:bu,selectConfirmDialog:Sb,selectIsLineAccountViewed:Mi,selectIsResourceAccountViewed:Cb,selectImageGalleryConfig:$b,selectImageGallery:Iu,selectMusicRoomConfig:Tb,selectMusicRoom:ku,selectSceneReplayConfig:Nb,selectSceneReplay:Au,selectIsSceneReplayActive:jb,selectActiveSceneReplayEntry:Db,selectNextLineConfig:Lb,selectSystemState:Mb,selectAchievements:Vb,selectAchievement:qb,selectSaveSlotMap:Eu,selectSaveSlots:Gb,selectSaveSlot:Fb,selectLocalizationPackages:Su,selectRuntime:Gi,selectRuntimeValue:Ub,selectAllVariables:Hi,selectCurrentPointer:Te,selectSection:ve,selectCurrentLine:Ht,selectPresentationState:Ou,selectAutoForwardTimerDelay:lr,selectPresentationChanges:Bb,selectSectionLineChanges:zb,selectSaveSlotPage:Xi,selectCurrentPageSlots:Hb,selectRenderState:Wb,selectOverlayStack:vb,selectLineIdByOffset:Qu,selectCanRollback:Zu,selectRollbackCursor:db,selectDesiredPlaybackTimers:Rw,selectPlaybackLineEntryId:Cw,startAutoMode:$u,stopAutoMode:Wt,toggleAutoMode:nI,startSkipMode:_u,stopSkipMode:Ar,toggleSkipMode:sI,showDialogueUI:rs,hideDialogueUI:Tu,toggleDialogueUI:oI,setDialogueTextSpeed:iI,setAutoForwardDelay:aI,setAutoForwardSpeed:lI,setSkipUnseenText:cI,setSkipTransitionsAndAnimations:uI,setSoundVolume:pI,setMusicVolume:dI,setMuteAll:fI,setSaveLoadPagination:hi,incrementSaveLoadPagination:gi,decrementSaveLoadPagination:bi,setMenuPage:Ii,setMenuEntryPoint:wi,showConfirmDialog:Kb,hideConfirmDialog:Jb,resetStoryAtSection:bI,clearPendingEffects:mI,appendPendingEffect:yI,completeAchievement:hI,setAchievementProgress:gI,beginRollbackActionBatch:yb,endRollbackActionBatch:hb,ensureRandomReplayOccurrence:gb,recordRandomOutcome:bb,markRollbackCheckpointTransient:fb,markSavedRollbackCheckpointTransient:mb,recordCurrentDialogueHistory:Eb,addViewedLine:wI,addViewedResource:kI,showImageGalleryVariant:vI,moveToPreviousImageGalleryVariant:AI,moveToNextImageGalleryVariant:PI,clearImageGallerySelection:xI,moveToImageGalleryPage:EI,moveToNextImageGalleryPage:SI,moveToPreviousImageGalleryPage:OI,playMusicRoomTrack:CI,playMusicRoom:$I,pauseMusicRoom:_I,stopMusicRoom:TI,seekMusicRoom:NI,playPreviousMusicRoomTrack:jI,playNextMusicRoomTrack:DI,clearMusicRoomSelection:LI,moveToMusicRoomPage:MI,moveToNextMusicRoomPage:VI,moveToPreviousMusicRoomPage:qI,musicRoomSoundReady:GI,musicRoomSoundProgress:HI,musicRoomSoundComplete:XI,musicRoomSoundError:WI,startSceneReplay:FI,finishSceneReplay:zu,exitSceneReplay:UI,moveToSceneReplayPage:BI,moveToNextSceneReplayPage:YI,moveToPreviousSceneReplayPage:zI,setNextLineConfig:Wu,saveSlot:KI,loadSlot:JI,updateProjectData:QI,updateLocalizationPackage:ZI,sectionTransition:nw,jumpToLine:ew,nextLine:rw,markLineCompleted:tw,rollbackToLine:Aw,rollbackByOffset:vw,pushOverlay:Qb,popOverlay:Zb,replaceLastOverlay:eI,clearOverlays:rI,updateFormField:lw,submitForm:cw,cancelForm:uw,updateVariable:pw,nextLineFromSystem:sw},{createTransactionalMetadata:a,updateTransactionalMetadata:Sw,finalizeTransactionalMetadata:Ow,transformActionFirstArgument:(s,i)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(s,i)=>({state:s,playbackOwnership:i})})};var $w="route-engine",_w="projectPersistence";var np=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),he=e=>Object.prototype.toString.call(e)==="[object Object]",tp="variables.",Tw=(e={})=>{let r=he(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!he(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lineId=="string"?{lineId:n.lineId}:{}}).filter(Boolean),resources:(Array.isArray(r.resources)?r.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!he(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},Nw=(e={})=>{let r=he(e)?e:{};return{sections:(Array.isArray(r.sections)?r.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!he(n)||typeof n.sectionId!="string"||n.sectionId.length===0?null:{sectionId:n.sectionId,...typeof n.lastLineId=="string"?{lastLineId:n.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(r.resources)?r.resources:[]).map(n=>typeof n=="string"||typeof n=="number"?{resourceId:String(n)}:!he(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},jw=(e,r)=>{let n=Nw(e),o=Tw(r),a=n.sections.map(s=>({...s})),t=n.resources.map(s=>({...s}));return o.sections.forEach(s=>{let i=a.find(l=>l.sectionId===s.sectionId);if(!i){a.push({sectionId:s.sectionId,...s.lineId===void 0?{}:{lastLineId:s.lineId}});return}if(i.lastLineId!==void 0){if(s.lineId===void 0){delete i.lastLineId;return}i.lastLineId=s.lineId}}),o.resources.forEach(s=>{t.find(l=>l.resourceId===s.resourceId)||t.push({...s})}),{sections:a,resources:t}},Dw=(e={})=>{let r=he(e)?e:{},n=Array.isArray(r.sceneIds)?r.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},Lw=(e,r)=>{let n=Dw(e),o=he(r)&&Array.isArray(r.sceneIds)?r.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},sp=(e={})=>{let r=he(e)?e:{};return{saveSlots:he(r.saveSlots)?r.saveSlots:{},globalDeviceVariables:he(r.globalDeviceVariables)?r.globalDeviceVariables:{},globalAccountVariables:he(r.globalAccountVariables)?r.globalAccountVariables:{},globalRuntime:he(r.globalRuntime)?r.globalRuntime:{},accountViewedRegistry:he(r.accountViewedRegistry)?r.accountViewedRegistry:{},accountReplayRegistry:he(r.accountReplayRegistry)?r.accountReplayRegistry:{}}},Mw=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((r,n)=>{if(!he(r))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=r.path?.startsWith(tp)?r.path.slice(tp.length):null;if(o!==null){if(!["device","account"].includes(r.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${r.scope}" at updates[${n}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${r.path}" at updates[${n}].`);if(r.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${r.op}" at updates[${n}].`);return{scope:r.scope,path:r.path,op:r.op,value:r.value,variableId:o}}if(r.path==="viewedRegistry"){if(r.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${r.scope}" at updates[${n}].`);if(r.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${r.op}" at updates[${n}].`);return r}if(r.path==="replayRegistry"){if(r.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${r.scope}" at updates[${n}].`);if(r.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${r.op}" at updates[${n}].`);if(!he(r.value)||!Array.isArray(r.value.sceneIds)||r.value.sceneIds.length===0||r.value.sceneIds.some(a=>typeof a!="string"||a.length===0))throw new Error(`Malformed applyScopedDataUpdates replayRegistry value at updates[${n}].`);return{...r,value:{sceneIds:[...new Set(r.value.sceneIds)]}}}throw typeof r.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${n}].`):new Error(`Unsupported applyScopedDataUpdates path "${r.path}" at updates[${n}].`)})},Vw=(e,r)=>{let n={};return Mw(r).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=jw(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=Lw(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},dt=e=>{if(typeof e!="string")return null;let r=e.trim();return r.length>0?r:null},qw=e=>{let r=dt(e);if(!r)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return r},Fw=e=>{let r=e??globalThis.indexedDB;if(!r)throw new Error("IndexedDB is not available in this environment.");return r},Uw=({indexedDB:e,databaseName:r,objectStoreName:n})=>new Promise((o,a)=>{let t=e.open(r,1);t.onupgradeneeded=()=>{let s=t.result;s.objectStoreNames.contains(n)||s.createObjectStore(n,{keyPath:"namespace"})},t.onsuccess=()=>{o(t.result)},t.onerror=()=>{a(t.error??new Error(`Failed to open IndexedDB database "${r}".`))}}),Bw=async({databasePromise:e,objectStoreName:r,namespace:n})=>{let o=await e;return new Promise((a,t)=>{let l=o.transaction(r,"readonly").objectStore(r).get(n);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{t(l.error??new Error(`Failed to read persisted namespace "${n}" from IndexedDB.`))}})},Jt=async({databasePromise:e,objectStoreName:r,namespace:n,patch:o})=>{let a=await e;return new Promise((t,s)=>{let i=a.transaction(r,"readwrite"),l=i.objectStore(r),c=l.get(n),u=!1,p=d=>{u||(u=!0,s(d))},f=()=>{u||(u=!0,t())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=sp(c.result),m=typeof o=="function"?o(d):o,y={namespace:n,version:1,...np(),...d,...m},g=l.put(y);g.onerror=()=>{p(g.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},i.oncomplete=()=>{f()},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}".`))}})},Yw=async({databasePromise:e,objectStoreName:r,namespace:n})=>{let o=await e;return new Promise((a,t)=>{let s=o.transaction(r,"readwrite"),l=s.objectStore(r).delete(n),c=!1,u=f=>{c||(c=!0,t(f))},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}".`))}})},Zi=(e={})=>{let{indexedDB:r,databaseName:n=$w,objectStoreName:o=_w,namespace:a}=e,t=Fw(r),s=qw(a),i=Uw({indexedDB:t,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await Bw({databasePromise:i,objectStoreName:o,namespace:s});return{...np(),...sp(l)}},clear:async()=>Yw({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>Jt({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:he(l)?l:{}}}),saveGlobalDeviceVariables:async l=>Jt({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:he(l)?l:{}}}),saveGlobalAccountVariables:async l=>Jt({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:he(l)?l:{}}}),saveGlobalRuntime:async l=>Jt({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:he(l)?l:{}}}),applyScopedDataUpdates:async l=>Jt({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>Vw(c,l)})}},zw=Zi;var fp=mp;var Gw={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ze=Object.prototype.hasOwnProperty,Hw={anyOf:[{type:"null"},{type:"object",properties:{x:{type:"number",minimum:0},y:{type:"number",minimum:0},quality:{type:"number",minimum:1},kernelSize:{type:"integer",enum:[5,7,9,11,13,15]},repeatEdgePixels:{type:"boolean"}},required:["x","y"],additionalProperties:!1}]};function De(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=s;if(e!==null){let p={instancePath:r,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"null"},message:"must be null"};t===null?t=[p]:t.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let d={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};t===null?t=[d]:t.push(d),s++}if(e.y===void 0){let d={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};t===null?t=[d]:t.push(d),s++}for(let d in e)if(!(d==="x"||d==="y"||d==="quality"||d==="kernelSize"||d==="repeatEdgePixels")){let m={instancePath:r,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let m={instancePath:r+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let m={instancePath:r+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let m={instancePath:r+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let m={instancePath:r+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[m]:t.push(m),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let m={instancePath:r+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Hw.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};t===null?t=[m]:t.push(m),s++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let d={instancePath:r+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}}else{let d={instancePath:r,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}var u=p===s;l=l||u}if(l)s=i,t!==null&&(i?t.length=i:t=null);else{let p={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[p]:t.push(p),s++}return De.errors=t,s===0}var Xw={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function as(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="continuity"||i==="speed"||i==="loop")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.continuity!==void 0){let i=e.continuity;if(typeof i!="string"){let l={instancePath:r+"/continuity",schemaPath:"#/properties/continuity/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="render"||i==="persistent")){let l={instancePath:r+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:Xw.properties.continuity.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.speed!==void 0){let i=e.speed;if(typeof i=="number"){if(i<=0||isNaN(i)){let l={instancePath:r+"/speed",schemaPath:"#/properties/speed/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/speed",schemaPath:"#/properties/speed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return as.errors=t,s===0}function ce(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="resourceId"||i==="playback")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}e.playback!==void 0&&(as(e.playback,{instancePath:r+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(t=t===null?as.errors:t.concat(as.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ce.errors=t,s===0}function ls(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ze.call(Gw.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.animationName!==void 0&&typeof e.animationName!="string"){let i={instancePath:r+"/animationName",schemaPath:"#/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.animationSpeed!==void 0&&typeof e.animationSpeed!="number"){let i={instancePath:r+"/animationSpeed",schemaPath:"#/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.colorId!==void 0&&typeof e.colorId!="string"){let i={instancePath:r+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.transformId!==void 0&&typeof e.transformId!="string"){let i={instancePath:r+"/transformId",schemaPath:"#/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:r+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:r+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}e.blur!==void 0&&(De(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),e.animations!==void 0&&(ce(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ls.errors=t,s===0}function mp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ls(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ls.errors:t.concat(ls.errors),s=t.length),mp.errors=t,s===0}var yp=hp;var Ww={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}}],additionalProperties:!1},ap={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["id","resourceId"],additionalProperties:!1},je=ip().default;function Ne(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.id===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[i]:t.push(i),s++}if(e.resourceId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!Ze.call(ap.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(je(i)<1){let l={instancePath:r+"/id",schemaPath:"#/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(je(i)<1){let l={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:ap.properties.endAt.type},message:"must be number,null"};t===null?t=[l]:t.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Ne.errors=t,s===0}function cs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.resourceId===void 0&&(d="resourceId")||e.sounds===void 0&&(d="sounds")){let m={};t===null?t=[m]:t.push(m),s++}}var c=l===s;if(c){let d={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[d]:t.push(d),s++}else s=i,t!==null&&(i?t.length=i:t=null);let u=s,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let d;if(e.startDelayMs===void 0&&(d="startDelayMs")||e.sounds===void 0&&(d="sounds")){let m={};t===null?t=[m]:t.push(m),s++}}var f=p===s;if(f){let d={instancePath:r,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[d]:t.push(d),s++}else s=u,t!==null&&(u?t.length=u:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let d in e)if(!(d==="sounds"||d==="resourceId"||d==="loop"||d==="interruption"||d==="volume"||d==="muted"||d==="pan"||d==="startDelayMs")){let m={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(e.sounds!==void 0){let d=e.sounds;if(Array.isArray(d)){let m=d.length;for(let y=0;y<m;y++)Ne(d[y],{instancePath:r+"/sounds/"+y,parentData:d,parentDataProperty:y,rootData:a})||(t=t===null?Ne.errors:t.concat(Ne.errors),s=t.length)}else{let m={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[m]:t.push(m),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let d={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[d]:t.push(d),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let d={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}if(e.interruption!==void 0){let d=e.interruption;if(typeof d!="string"){let m={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}if(!(d==="immediate"||d==="loopEnd")){let m={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Ww.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[m]:t.push(m),s++}}if(e.volume!==void 0){let d=e.volume;if(typeof d=="number"){if(d>100||isNaN(d)){let m={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[m]:t.push(m),s++}if(d<0||isNaN(d)){let m={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let d={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}if(e.pan!==void 0){let d=e.pan;if(typeof d=="number"){if(d>1||isNaN(d)){let m={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[m]:t.push(m),s++}if(d<-1||isNaN(d)){let m={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}if(e.startDelayMs!==void 0){let d=e.startDelayMs;if(typeof d=="number"){if(d<0||isNaN(d)){let m={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[m]:t.push(m),s++}}}else{let d={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}return cs.errors=t,s===0}function hp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return cs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?cs.errors:t.concat(cs.errors),s=t.length),hp.errors=t,s===0}var gp=bp;var Kw={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function us(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let l in e)if(l!=="items"){let c={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],f=s,d=!0,m=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let y;if(p.sprites===void 0&&(y="sprites")){let g={};t===null?t=[g]:t.push(g),s++}}var i=m===s;if(s=f,t!==null&&(f?t.length=f:t=null),i){let y=s;if(p&&typeof p=="object"&&!Array.isArray(p)&&p.transformId===void 0){let h={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/then/required",keyword:"required",params:{missingProperty:"transformId"},message:"must have required property 'transformId'"};t===null?t=[h]:t.push(h),s++}var i=y===s;d=i}if(!d){let y={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[y]:t.push(y),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let y={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[y]:t.push(y),s++}for(let y in p)if(!Ze.call(Kw.properties.items.items.properties,y)){let g={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:y},message:"must NOT have additional properties"};t===null?t=[g]:t.push(g),s++}if(p.id!==void 0&&typeof p.id!="string"){let y={instancePath:r+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let y={instancePath:r+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(p.x!==void 0&&typeof p.x!="number"){let y={instancePath:r+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.y!==void 0&&typeof p.y!="number"){let y={instancePath:r+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let y={instancePath:r+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let y={instancePath:r+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let y={instancePath:r+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let y={instancePath:r+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let y={instancePath:r+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let y={instancePath:r+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let y={instancePath:r+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}if(p.opacity!==void 0){let y=p.opacity;if(typeof y=="number"){if(y>1||isNaN(y)){let g={instancePath:r+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[g]:t.push(g),s++}if(y<0||isNaN(y)){let g={instancePath:r+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[g]:t.push(g),s++}}else{let g={instancePath:r+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[g]:t.push(g),s++}}if(p.blur!==void 0&&(De(p.blur,{instancePath:r+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),p.sprites!==void 0){let y=p.sprites;if(Array.isArray(y)){let g=y.length;for(let h=0;h<g;h++){let w=y[h];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let b in w)if(!(b==="id"||b==="resourceId"||b==="animationName"||b==="animationSpeed"||b==="loop")){let E={instancePath:r+"/items/"+u+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(w.id!==void 0&&typeof w.id!="string"){let b={instancePath:r+"/items/"+u+"/sprites/"+h+"/id",schemaPath:"#/properties/items/items/properties/sprites/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let b={instancePath:r+"/items/"+u+"/sprites/"+h+"/resourceId",schemaPath:"#/properties/items/items/properties/sprites/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let b={instancePath:r+"/items/"+u+"/sprites/"+h+"/animationName",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let b={instancePath:r+"/items/"+u+"/sprites/"+h+"/animationSpeed",schemaPath:"#/properties/items/items/properties/sprites/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[b]:t.push(b),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let b={instancePath:r+"/items/"+u+"/sprites/"+h+"/loop",schemaPath:"#/properties/items/items/properties/sprites/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[b]:t.push(b),s++}}else{let b={instancePath:r+"/items/"+u+"/sprites/"+h,schemaPath:"#/properties/items/items/properties/sprites/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}}}else{let g={instancePath:r+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[g]:t.push(g),s++}}p.animations!==void 0&&(ce(p.animations,{instancePath:r+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let y={instancePath:r+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[y]:t.push(y),s++}}}else{let c={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[c]:t.push(c),s++}}}else{let l={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}return us.errors=t,s===0}function bp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return us(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?us.errors:t.concat(us.errors),s=t.length),bp.errors=t,s===0}var Ip=wp;function ps(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="items"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let f={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};t===null?t=[f]:t.push(f),s++}if(u.id!==void 0&&typeof u.id!="string"){let p={instancePath:r+"/items/"+c+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}if(u.content!==void 0&&typeof u.content!="string"){let p={instancePath:r+"/items/"+c+"/content",schemaPath:"#/properties/items/items/properties/content/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let f=p.click;if(!(f&&typeof f=="object"&&!Array.isArray(f))){let d={instancePath:r+"/items/"+c+"/events/click",schemaPath:"#/properties/items/items/properties/events/properties/click/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}}}else{let f={instancePath:r+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),s++}}}else{let p={instancePath:r+"/items/"+c,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}e.animations!==void 0&&(ce(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ps.errors=t,s===0}function wp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ps(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ps.errors:t.concat(ps.errors),s=t.length),wp.errors=t,s===0}var kp=vp;function ds(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(i!=="mode"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.mode!==void 0&&typeof e.mode!="string"){let i={instancePath:r+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ds.errors=t,s===0}function vp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ds(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ds.errors:t.concat(ds.errors),s=t.length),vp.errors=t,s===0}var Ap=Pp;function fs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.resourceId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="resourceId"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return fs.errors=t,s===0}function Pp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return fs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?fs.errors:t.concat(fs.errors),s=t.length),Pp.errors=t,s===0}var xp=Ep;var lp={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 ms(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ze.call(lp.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.ui!==void 0){let i=e.ui;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="resourceId"||l==="animations")){let c={instancePath:r+"/ui",schemaPath:"#/properties/ui/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(i.resourceId!==void 0&&typeof i.resourceId!="string"){let l={instancePath:r+"/ui/resourceId",schemaPath:"#/properties/ui/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}i.animations!==void 0&&(ce(i.animations,{instancePath:r+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let l={instancePath:r+"/ui",schemaPath:"#/properties/ui/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.mode!==void 0){let i=e.mode;if(typeof i!="string"){let l={instancePath:r+"/mode",schemaPath:"#/properties/mode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="adv"||i==="nvl")){let l={instancePath:r+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:lp.properties.mode.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.content!==void 0){let i=e.content;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.text!==void 0&&typeof u.text!="string"){let p={instancePath:r+"/content/"+c+"/text",schemaPath:"#/properties/content/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}}else{let p={instancePath:r+"/content/"+c,schemaPath:"#/properties/content/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/content",schemaPath:"#/properties/content/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}if(e.textSpeed!==void 0&&typeof e.textSpeed!="number"){let i={instancePath:r+"/textSpeed",schemaPath:"#/properties/textSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.append!==void 0&&typeof e.append!="boolean"){let i={instancePath:r+"/append",schemaPath:"#/properties/append/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.characterId!==void 0&&typeof e.characterId!="string"){let i={instancePath:r+"/characterId",schemaPath:"#/properties/characterId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.characterName!==void 0&&typeof e.characterName!="string"){let i={instancePath:r+"/characterName",schemaPath:"#/properties/characterName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.persistCharacter!==void 0&&typeof e.persistCharacter!="boolean"){let i={instancePath:r+"/persistCharacter",schemaPath:"#/properties/persistCharacter/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.persistSprite!==void 0&&typeof e.persistSprite!="boolean"){let i={instancePath:r+"/persistSprite",schemaPath:"#/properties/persistSprite/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.character!==void 0){let i=e.character;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(!(l==="name"||l==="sprite")){let c={instancePath:r+"/character",schemaPath:"#/properties/character/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(i.name!==void 0&&typeof i.name!="string"){let l={instancePath:r+"/character/name",schemaPath:"#/properties/character/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(i.sprite!==void 0){let l=i.sprite;if(l&&typeof l=="object"&&!Array.isArray(l)){for(let c in l)if(!(c==="transformId"||c==="items"||c==="animations")){let u={instancePath:r+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(l.transformId!==void 0&&typeof l.transformId!="string"){let c={instancePath:r+"/character/sprite/transformId",schemaPath:"#/properties/character/properties/sprite/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[c]:t.push(c),s++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let f=c[p];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let d={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[d]:t.push(d),s++}if(f.resourceId===void 0){let d={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[d]:t.push(d),s++}for(let d in f)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let m={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};t===null?t=[m]:t.push(m),s++}if(f.id!==void 0&&typeof f.id!="string"){let d={instancePath:r+"/character/sprite/items/"+p+"/id",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[d]:t.push(d),s++}if(f.resourceId!==void 0&&typeof f.resourceId!="string"){let d={instancePath:r+"/character/sprite/items/"+p+"/resourceId",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[d]:t.push(d),s++}if(f.animationName!==void 0&&typeof f.animationName!="string"){let d={instancePath:r+"/character/sprite/items/"+p+"/animationName",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[d]:t.push(d),s++}if(f.animationSpeed!==void 0&&typeof f.animationSpeed!="number"){let d={instancePath:r+"/character/sprite/items/"+p+"/animationSpeed",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[d]:t.push(d),s++}if(f.loop!==void 0&&typeof f.loop!="boolean"){let d={instancePath:r+"/character/sprite/items/"+p+"/loop",schemaPath:"#/properties/character/properties/sprite/properties/items/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[d]:t.push(d),s++}}else{let d={instancePath:r+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[d]:t.push(d),s++}}}else{let u={instancePath:r+"/character/sprite/items",schemaPath:"#/properties/character/properties/sprite/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[u]:t.push(u),s++}}l.animations!==void 0&&(ce(l.animations,{instancePath:r+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let c={instancePath:r+"/character/sprite",schemaPath:"#/properties/character/properties/sprite/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),s++}}}else{let l={instancePath:r+"/character",schemaPath:"#/properties/character/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.clear!==void 0&&typeof e.clear!="boolean"){let i={instancePath:r+"/clear",schemaPath:"#/properties/clear/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.clearPage!==void 0&&typeof e.clearPage!="boolean"){let i={instancePath:r+"/clearPage",schemaPath:"#/properties/clearPage/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ms.errors=t,s===0}function Ep(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ms(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ms.errors:t.concat(ms.errors),s=t.length),Ep.errors=t,s===0}var Sp=Op;function ys(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="id"||i==="resourceId"||i==="fields"||i==="submitActions"||i==="cancelActions"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.id!==void 0&&typeof e.id!="string"){let i={instancePath:r+"/id",schemaPath:"#/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fields!==void 0){let i=e.fields;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.variableId===void 0){let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/required",keyword:"required",params:{missingProperty:"variableId"},message:"must have required property 'variableId'"};t===null?t=[u]:t.push(u),s++}for(let u in c)if(!(u==="variableId"||u==="required"||u==="trim"||u==="placeholder"||u==="multiline"||u==="maxLength")){let p={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(c.variableId!==void 0&&typeof c.variableId!="string"){let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/variableId",schemaPath:"#/properties/fields/additionalProperties/properties/variableId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[u]:t.push(u),s++}if(c.required!==void 0&&typeof c.required!="boolean"){let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/required",schemaPath:"#/properties/fields/additionalProperties/properties/required/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[u]:t.push(u),s++}if(c.trim!==void 0&&typeof c.trim!="boolean"){let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/trim",schemaPath:"#/properties/fields/additionalProperties/properties/trim/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[u]:t.push(u),s++}if(c.placeholder!==void 0&&typeof c.placeholder!="string"){let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/placeholder",schemaPath:"#/properties/fields/additionalProperties/properties/placeholder/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[u]:t.push(u),s++}if(c.multiline!==void 0&&typeof c.multiline!="boolean"){let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/multiline",schemaPath:"#/properties/fields/additionalProperties/properties/multiline/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[u]:t.push(u),s++}if(c.maxLength!==void 0){let u=c.maxLength;if(!(typeof u=="number"&&!(u%1)&&!isNaN(u))){let p={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[p]:t.push(p),s++}if(typeof u=="number"&&(u<0||isNaN(u))){let p={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/maxLength",schemaPath:"#/properties/fields/additionalProperties/properties/maxLength/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[p]:t.push(p),s++}}}else{let u={instancePath:r+"/fields/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/fields/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}}else{let l={instancePath:r+"/fields",schemaPath:"#/properties/fields/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.submitActions!==void 0){let i=e.submitActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:r+"/submitActions",schemaPath:"#/properties/submitActions/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.cancelActions!==void 0){let i=e.cancelActions;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:r+"/cancelActions",schemaPath:"#/properties/cancelActions/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}e.animations!==void 0&&(ce(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ys.errors=t,s===0}function Op(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return ys(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?ys.errors:t.concat(ys.errors),s=t.length),Op.errors=t,s===0}var Rp=Cp;function hs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="resourceId"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let i={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}e.animations!==void 0&&(ce(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return hs.errors=t,s===0}function Cp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return hs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?hs.errors:t.concat(hs.errors),s=t.length),Cp.errors=t,s===0}var $p=_p;function gs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="opacity"||i==="blur"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.opacity!==void 0){let i=e.opacity;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/opacity",schemaPath:"#/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}e.blur!==void 0&&(De(e.blur,{instancePath:r+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),e.animations!==void 0&&(ce(e.animations,{instancePath:r+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return gs.errors=t,s===0}function _p(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return gs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?gs.errors:t.concat(gs.errors),s=t.length),_p.errors=t,s===0}var Tp=Np;var cp={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};function bs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.items===void 0&&(u="items")||e.channels===void 0&&(u="channels")){let p={};t===null?t=[p]:t.push(p),s++}}var c=l===s;if(c){let u={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[u]:t.push(u),s++}else s=i,t!==null&&(i?t.length=i:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let u in e)if(!(u==="items"||u==="channels")){let p={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let f=0;f<p;f++)Ne(u[f],{instancePath:r+"/items/"+f,parentData:u,parentDataProperty:f,rootData:a})||(t=t===null?Ne.errors:t.concat(Ne.errors),s=t.length)}else{let p={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[p]:t.push(p),s++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let f=0;f<p;f++){let d=u[f];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let m={instancePath:r+"/channels/"+f,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[m]:t.push(m),s++}if(d.sounds===void 0){let m={instancePath:r+"/channels/"+f,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};t===null?t=[m]:t.push(m),s++}for(let m in d)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="applyMode"||m==="sounds")){let y={instancePath:r+"/channels/"+f,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};t===null?t=[y]:t.push(y),s++}if(d.id!==void 0){let m=d.id;if(typeof m=="string"){if(je(m)<1){let y={instancePath:r+"/channels/"+f+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/channels/"+f+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}}if(d.volume!==void 0){let m=d.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let y={instancePath:r+"/channels/"+f+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[y]:t.push(y),s++}if(m<0||isNaN(m)){let y={instancePath:r+"/channels/"+f+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/channels/"+f+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let m={instancePath:r+"/channels/"+f+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[m]:t.push(m),s++}if(d.pan!==void 0){let m=d.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let y={instancePath:r+"/channels/"+f+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[y]:t.push(y),s++}if(m<-1||isNaN(m)){let y={instancePath:r+"/channels/"+f+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[y]:t.push(y),s++}}else{let y={instancePath:r+"/channels/"+f+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[y]:t.push(y),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let m={instancePath:r+"/channels/"+f+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[m]:t.push(m),s++}if(d.interruption!==void 0){let m=d.interruption;if(typeof m!="string"){let y={instancePath:r+"/channels/"+f+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(!(m==="immediate"||m==="loopEnd")){let y={instancePath:r+"/channels/"+f+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:cp.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[y]:t.push(y),s++}}if(d.applyMode!==void 0){let m=d.applyMode;if(typeof m!="string"){let y={instancePath:r+"/channels/"+f+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[y]:t.push(y),s++}if(!(m==="singleLine"||m==="persistent")){let y={instancePath:r+"/channels/"+f+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:cp.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};t===null?t=[y]:t.push(y),s++}}if(d.sounds!==void 0){let m=d.sounds;if(Array.isArray(m)){let y=m.length;for(let g=0;g<y;g++)Ne(m[g],{instancePath:r+"/channels/"+f+"/sounds/"+g,parentData:m,parentDataProperty:g,rootData:a})||(t=t===null?Ne.errors:t.concat(Ne.errors),s=t.length)}else{let y={instancePath:r+"/channels/"+f+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[y]:t.push(y),s++}}}else{let m={instancePath:r+"/channels/"+f,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[m]:t.push(m),s++}}}else{let p={instancePath:r+"/channels",schemaPath:"#/properties/channels/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[p]:t.push(p),s++}}}else{let u={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}return bs.errors=t,s===0}function Np(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return bs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?bs.errors:t.concat(bs.errors),s=t.length),Np.errors=t,s===0}var jp=Dp;var up={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"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function Is(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=s;if(typeof e!="string"){let p={instancePath:r,schemaPath:"#/anyOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[p]:t.push(p),s++}var u=c===s;if(l=l||u,!l){let p=s;if(Array.isArray(e)){let d=e.length;for(let m=0;m<d;m++){let y=e[m];if(y&&typeof y=="object"&&!Array.isArray(y)){if(y.text!==void 0&&typeof y.text!="string"){let g={instancePath:r+"/"+m+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[g]:t.push(g),s++}if(y.textStyleId!==void 0&&typeof y.textStyleId!="string"){let g={instancePath:r+"/"+m+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[g]:t.push(g),s++}if(y.furigana!==void 0){let g=y.furigana;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let h={instancePath:r+"/"+m+"/furigana/text",schemaPath:"#/anyOf/1/items/properties/furigana/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let h={instancePath:r+"/"+m+"/furigana/textStyleId",schemaPath:"#/anyOf/1/items/properties/furigana/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/"+m+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[h]:t.push(h),s++}}}else{let g={instancePath:r+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[g]:t.push(g),s++}}}else{let d={instancePath:r,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[d]:t.push(d),s++}var u=p===s;l=l||u}if(l)s=i,t!==null&&(i?t.length=i:t=null);else{let p={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[p]:t.push(p),s++}return Is.errors=t,s===0}function ws(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=s,c=s,u=!1,p=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let b={};t===null?t=[b]:t.push(b),s++}}var f=p===s;if(u=u||f,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let v={};t===null?t=[v]:t.push(v),s++}}var f=w===s;if(u=u||f,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.resourceId===void 0&&(P="resourceId")){let k={};t===null?t=[k]:t.push(k),s++}}var f=E===s;if(u=u||f,!u){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let D={};t===null?t=[D]:t.push(D),s++}}var f=P===s;if(u=u||f,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let q={};t===null?t=[q]:t.push(q),s++}}var f=O===s;if(u=u||f,!u){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Y;if(e.transform===void 0&&(Y="transform")){let T={};t===null?t=[T]:t.push(T),s++}}var f=$===s;if(u=u||f,!u){let Y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.x===void 0&&(U="x")){let ie={};t===null?t=[ie]:t.push(ie),s++}}var f=Y===s;if(u=u||f,!u){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.y===void 0&&(L="y")){let ae={};t===null?t=[ae]:t.push(ae),s++}}var f=U===s;if(u=u||f,!u){let L=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ue;if(e.anchorX===void 0&&(ue="anchorX")){let B={};t===null?t=[B]:t.push(B),s++}}var f=L===s;if(u=u||f,!u){let ue=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.anchorY===void 0&&(Z="anchorY")){let oe={};t===null?t=[oe]:t.push(oe),s++}}var f=ue===s;if(u=u||f,!u){let Z=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let re;if(e.scaleX===void 0&&(re="scaleX")){let pe={};t===null?t=[pe]:t.push(pe),s++}}var f=Z===s;if(u=u||f,!u){let re=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.scaleY===void 0&&(te="scaleY")){let C={};t===null?t=[C]:t.push(C),s++}}var f=re===s;if(u=u||f,!u){let te=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let _;if(e.rotation===void 0&&(_="rotation")){let F={};t===null?t=[F]:t.push(F),s++}}var f=te===s;if(u=u||f,!u){let _=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.originX===void 0&&(K="originX")){let de={};t===null?t=[de]:t.push(de),s++}}var f=_===s;if(u=u||f,!u){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Pe;if(e.originY===void 0&&(Pe="originY")){let ge={};t===null?t=[ge]:t.push(ge),s++}}var f=K===s;if(u=u||f,!u){let Pe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let fe;if(e.layer===void 0&&(fe="layer")){let Or={};t===null?t=[Or]:t.push(Or),s++}}var f=Pe===s;if(u=u||f,!u){let fe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Xe;if(e.opacity===void 0&&(Xe="opacity")){let an={};t===null?t=[an]:t.push(an),s++}}var f=fe===s;if(u=u||f,!u){let Xe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let yt;if(e.blur===void 0&&(yt="blur")){let ln={};t===null?t=[ln]:t.push(ln),s++}}var f=Xe===s;if(u=u||f,!u){let yt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Xs;if(e.animations===void 0&&(Xs="animations")){let ht={};t===null?t=[ht]:t.push(ht),s++}}var f=yt===s;u=u||f}}}}}}}}}}}}}}}}}}if(u)s=c,t!==null&&(c?t.length=c:t=null);else{let w={};t===null?t=[w]:t.push(w),s++}var d=l===s;if(d){let w={instancePath:r,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[w]:t.push(w),s++}else s=i,t!==null&&(i?t.length=i:t=null);let m=s,y=!1,g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.content===void 0){let w={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"content"},message:"must have required property 'content'"};t===null?t=[w]:t.push(w),s++}var h=g===s;if(y=y||h,!y){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let E={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};t===null?t=[E]:t.push(E),s++}var h=w===s;y=y||h}if(y)s=m,t!==null&&(m?t.length=m:t=null);else{let w={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[w]:t.push(w),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(Is(e.content,{instancePath:r+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(t=t===null?Is.errors:t.concat(Is.errors),s=t.length)),e.textStyleId!==void 0&&typeof e.textStyleId!="string"){let w={instancePath:r+"/textStyleId",schemaPath:"#/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[w]:t.push(w),s++}if(e.width!==void 0&&typeof e.width!="number"){let w={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}if(e.height!==void 0&&typeof e.height!="number"){let w={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[w]:t.push(w),s++}return ws.errors=t,s===0}function ks(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"elements"},message:"must have required property 'elements'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="elements"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return ks.errors=t,s===0}var Jw={type:"object",properties:{x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},minProperties:1,additionalProperties:!1};function vs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!Ze.call(Jw.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.x!==void 0&&typeof e.x!="number"){let i={instancePath:r+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.y!==void 0&&typeof e.y!="number"){let i={instancePath:r+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return vs.errors=t,s===0}function As(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let f={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};t===null?t=[f]:t.push(f),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let f=p.length;for(let d=0;d<f;d++){let m=p[d],y=s,g=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let k;if(m.resourceId===void 0&&(k="resourceId")||m.text===void 0&&(k="text")){let O={};t===null?t=[O]:t.push(O),s++}}var i=g===s;if(i){let k={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[k]:t.push(k),s++}else s=y,t!==null&&(y?t.length=y:t=null);let h=s,w=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let k;if(m.resourceId===void 0&&(k="resourceId")||m.layout===void 0&&(k="layout")){let O={};t===null?t=[O]:t.push(O),s++}}var l=w===s;if(l){let k={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[k]:t.push(k),s++}else s=h,t!==null&&(h?t.length=h:t=null);let b=s,E=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let k;if(m.text===void 0&&(k="text")||m.layout===void 0&&(k="layout")){let O={};t===null?t=[O]:t.push(O),s++}}var c=E===s;if(c){let k={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[k]:t.push(k),s++}else s=b,t!==null&&(b?t.length=b:t=null);let v=s,P=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let k;if(m.transformId===void 0&&(k="transformId")||m.transform===void 0&&(k="transform")){let O={};t===null?t=[O]:t.push(O),s++}}var u=P===s;if(u){let k={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[k]:t.push(k),s++}else s=v,t!==null&&(v?t.length=v:t=null);if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let k={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};t===null?t=[k]:t.push(k),s++}for(let k in m)if(!Ze.call(up.properties.items.items.properties,k)){let O={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};t===null?t=[O]:t.push(O),s++}if(m.id!==void 0&&typeof m.id!="string"){let k={instancePath:r+"/items/"+d+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[k]:t.push(k),s++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let k={instancePath:r+"/items/"+d+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[k]:t.push(k),s++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let k={instancePath:r+"/items/"+d+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let k={instancePath:r+"/items/"+d+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[k]:t.push(k),s++}if(m.text!==void 0&&(ws(m.text,{instancePath:r+"/items/"+d+"/text",parentData:m,parentDataProperty:"text",rootData:a})||(t=t===null?ws.errors:t.concat(ws.errors),s=t.length)),m.layout!==void 0&&(ks(m.layout,{instancePath:r+"/items/"+d+"/layout",parentData:m,parentDataProperty:"layout",rootData:a})||(t=t===null?ks.errors:t.concat(ks.errors),s=t.length)),m.transformId!==void 0&&typeof m.transformId!="string"){let k={instancePath:r+"/items/"+d+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[k]:t.push(k),s++}if(m.transform!==void 0&&(vs(m.transform,{instancePath:r+"/items/"+d+"/transform",parentData:m,parentDataProperty:"transform",rootData:a})||(t=t===null?vs.errors:t.concat(vs.errors),s=t.length)),m.x!==void 0&&typeof m.x!="number"){let k={instancePath:r+"/items/"+d+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.y!==void 0&&typeof m.y!="number"){let k={instancePath:r+"/items/"+d+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.anchorX!==void 0&&typeof m.anchorX!="number"){let k={instancePath:r+"/items/"+d+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.anchorY!==void 0&&typeof m.anchorY!="number"){let k={instancePath:r+"/items/"+d+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.scaleX!==void 0&&typeof m.scaleX!="number"){let k={instancePath:r+"/items/"+d+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.scaleY!==void 0&&typeof m.scaleY!="number"){let k={instancePath:r+"/items/"+d+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.rotation!==void 0&&typeof m.rotation!="number"){let k={instancePath:r+"/items/"+d+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.originX!==void 0&&typeof m.originX!="number"){let k={instancePath:r+"/items/"+d+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.originY!==void 0&&typeof m.originY!="number"){let k={instancePath:r+"/items/"+d+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[k]:t.push(k),s++}if(m.layer!==void 0){let k=m.layer;if(typeof k!="number"){let O={instancePath:r+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[O]:t.push(O),s++}if(!(k===10||k===30||k===50||k===70||k===90)){let O={instancePath:r+"/items/"+d+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:up.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};t===null?t=[O]:t.push(O),s++}}if(m.opacity!==void 0){let k=m.opacity;if(typeof k=="number"){if(k>1||isNaN(k)){let O={instancePath:r+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[O]:t.push(O),s++}if(k<0||isNaN(k)){let O={instancePath:r+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[O]:t.push(O),s++}}else{let O={instancePath:r+"/items/"+d+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[O]:t.push(O),s++}}m.blur!==void 0&&(De(m.blur,{instancePath:r+"/items/"+d+"/blur",parentData:m,parentDataProperty:"blur",rootData:a})||(t=t===null?De.errors:t.concat(De.errors),s=t.length)),m.animations!==void 0&&(ce(m.animations,{instancePath:r+"/items/"+d+"/animations",parentData:m,parentDataProperty:"animations",rootData:a})||(t=t===null?ce.errors:t.concat(ce.errors),s=t.length))}else{let k={instancePath:r+"/items/"+d,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}}else{let f={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[f]:t.push(f),s++}}}else{let p={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}return As.errors=t,s===0}function Dp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return As(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?As.errors:t.concat(As.errors),s=t.length),Dp.errors=t,s===0}var Lp=Mp;var Qw={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 Ps(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.resourceId===void 0){let h={instancePath:r,schemaPath:"#/anyOf/0/required",keyword:"required",params:{missingProperty:"resourceId"},message:"must have required property 'resourceId'"};t===null?t=[h]:t.push(h),s++}var u=c===s;if(l=l||u,!l){let h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let b={instancePath:r,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};t===null?t=[b]:t.push(b),s++}var u=h===s;l=l||u}if(l)s=i,t!==null&&(i?t.length=i:t=null);else{let h={instancePath:r,schemaPath:"#/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[h]:t.push(h),s++}let p=s,f=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.resourceId===void 0&&(h="resourceId")||e.sounds===void 0&&(h="sounds")){let w={};t===null?t=[w]:t.push(w),s++}}var d=f===s;if(d){let h={instancePath:r,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[h]:t.push(h),s++}else s=p,t!==null&&(p?t.length=p:t=null);let m=s,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.startDelayMs===void 0&&(h="startDelayMs")||e.sounds===void 0&&(h="sounds")){let w={};t===null?t=[w]:t.push(w),s++}}var g=y===s;if(g){let h={instancePath:r,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[h]:t.push(h),s++}else s=m,t!==null&&(m?t.length=m:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)){for(let h in e)if(!(h==="sounds"||h==="resourceId"||h==="volume"||h==="muted"||h==="pan"||h==="loop"||h==="interruption"||h==="startDelayMs")){let w={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};t===null?t=[w]:t.push(w),s++}if(e.sounds!==void 0){let h=e.sounds;if(Array.isArray(h)){let w=h.length;for(let b=0;b<w;b++)Ne(h[b],{instancePath:r+"/sounds/"+b,parentData:h,parentDataProperty:b,rootData:a})||(t=t===null?Ne.errors:t.concat(Ne.errors),s=t.length)}else{let w={instancePath:r+"/sounds",schemaPath:"#/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[w]:t.push(w),s++}}if(e.resourceId!==void 0&&typeof e.resourceId!="string"){let h={instancePath:r+"/resourceId",schemaPath:"#/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(e.volume!==void 0){let h=e.volume;if(typeof h=="number"){if(h>100||isNaN(h)){let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[w]:t.push(w),s++}if(h<0||isNaN(h)){let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let h={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[h]:t.push(h),s++}if(e.pan!==void 0){let h=e.pan;if(typeof h=="number"){if(h>1||isNaN(h)){let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[w]:t.push(w),s++}if(h<-1||isNaN(h)){let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}if(e.loop!==void 0&&typeof e.loop!="boolean"){let h={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[h]:t.push(h),s++}if(e.interruption!==void 0){let h=e.interruption;if(typeof h!="string"){let w={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[w]:t.push(w),s++}if(!(h==="immediate"||h==="loopEnd")){let w={instancePath:r+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Qw.properties.interruption.enum},message:"must be equal to one of the allowed values"};t===null?t=[w]:t.push(w),s++}}if(e.startDelayMs!==void 0){let h=e.startDelayMs;if(typeof h=="number"){if(h<0||isNaN(h)){let w={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[w]:t.push(w),s++}}else{let w={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[w]:t.push(w),s++}}}else{let h={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[h]:t.push(h),s++}return Ps.errors=t,s===0}function Mp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ps(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ps.errors:t.concat(Ps.errors),s=t.length),Mp.errors=t,s===0}var Vp=qp;var Zw={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 xs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let g={};t===null?t=[g]:t.push(g),s++}var u=c===s;if(s=i,t!==null&&(i?t.length=i:t=null),u){let g=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.target===void 0){let w={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"target"},message:"must have required property 'target'"};t===null?t=[w]:t.push(w),s++}var u=g===s;l=u}if(!l){let g={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[g]:t.push(g),s++}let p=s,f=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let g={};t===null?t=[g]:t.push(g),s++}var m=d===s;if(s=p,t!==null&&(p?t.length=p:t=null),m){let g=s,h=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let v={};t===null?t=[v]:t.push(v),s++}}var y=w===s;if(y){let E={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[E]:t.push(E),s++}else s=h,t!==null&&(h?t.length=h:t=null);var m=g===s;f=m}if(!f){let g={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[g]:t.push(g),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[g]:t.push(g),s++}if(e.name===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};t===null?t=[g]:t.push(g),s++}if(e.description===void 0){let g={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};t===null?t=[g]:t.push(g),s++}for(let g in e)if(!(g==="type"||g==="target"||g==="name"||g==="description"||g==="lockedName"||g==="lockedDescription"||g==="hidden")){let h={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};t===null?t=[h]:t.push(h),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let h={instancePath:r+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}if(!(g==="boolean"||g==="number")){let h={instancePath:r+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Zw.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[h]:t.push(h),s++}}if(e.target!==void 0){let g=e.target;if(!(typeof g=="number"&&!(g%1)&&!isNaN(g))){let h={instancePath:r+"/target",schemaPath:"#/properties/target/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[h]:t.push(h),s++}if(typeof g=="number"&&(g<1||isNaN(g))){let h={instancePath:r+"/target",schemaPath:"#/properties/target/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[h]:t.push(h),s++}}if(e.name!==void 0){let g=e.name;if(typeof g=="string"){if(je(g)<1){let h={instancePath:r+"/name",schemaPath:"#/properties/name/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.description!==void 0){let g=e.description;if(typeof g=="string"){if(je(g)<1){let h={instancePath:r+"/description",schemaPath:"#/properties/description/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/description",schemaPath:"#/properties/description/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.lockedName!==void 0){let g=e.lockedName;if(typeof g=="string"){if(je(g)<1){let h={instancePath:r+"/lockedName",schemaPath:"#/properties/lockedName/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/lockedName",schemaPath:"#/properties/lockedName/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.lockedDescription!==void 0){let g=e.lockedDescription;if(typeof g=="string"){if(je(g)<1){let h={instancePath:r+"/lockedDescription",schemaPath:"#/properties/lockedDescription/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[h]:t.push(h),s++}}else{let h={instancePath:r+"/lockedDescription",schemaPath:"#/properties/lockedDescription/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[h]:t.push(h),s++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let g={instancePath:r+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[g]:t.push(g),s++}}else{let g={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[g]:t.push(g),s++}return xs.errors=t,s===0}function qp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return xs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?xs.errors:t.concat(xs.errors),s=t.length),qp.errors=t,s===0}var Fp=Up;var e0={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 r0={type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1};function zr(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.value===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"value"},message:"must have required property 'value'"};t===null?t=[i]:t.push(i),s++}if(e.duration===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="value"||i==="duration"||i==="easing"||i==="relative")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.value!==void 0&&typeof e.value!="number"){let i={instancePath:r+"/value",schemaPath:"#/properties/value/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.duration!==void 0&&typeof e.duration!="number"){let i={instancePath:r+"/duration",schemaPath:"#/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.easing!==void 0){let i=e.easing;if(typeof i!="string"){let l={instancePath:r+"/easing",schemaPath:"#/properties/easing/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="linear"||i==="easeInQuad"||i==="easeOutQuad"||i==="easeInOutQuad"||i==="easeInCubic"||i==="easeOutCubic"||i==="easeInOutCubic"||i==="easeInQuart"||i==="easeOutQuart"||i==="easeInOutQuart"||i==="easeInQuint"||i==="easeOutQuint"||i==="easeInOutQuint"||i==="easeInSine"||i==="easeOutSine"||i==="easeInOutSine"||i==="easeInExpo"||i==="easeOutExpo"||i==="easeInOutExpo"||i==="easeInCirc"||i==="easeOutCirc"||i==="easeInOutCirc"||i==="easeInBack"||i==="easeOutBack"||i==="easeInOutBack"||i==="easeInBounce"||i==="easeOutBounce"||i==="easeInOutBounce"||i==="easeInElastic"||i==="easeOutElastic"||i==="easeInOutElastic")){let l={instancePath:r+"/easing",schemaPath:"#/properties/easing/enum",keyword:"enum",params:{allowedValues:r0.properties.easing.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.relative!==void 0&&typeof e.relative!="boolean"){let i={instancePath:r+"/relative",schemaPath:"#/properties/relative/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return zr.errors=t,s===0}function Q(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:r+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[c]:t.push(c),s++}let l=i.length;for(let c=0;c<l;c++)zr(i[c],{instancePath:r+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(t=t===null?zr.errors:t.concat(zr.errors),s=t.length)}else{let l={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Q.errors=t,s===0}function Es(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="alpha"||i==="x"||i==="y"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.alpha!==void 0&&(Q(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.x!==void 0&&(Q(e.x,{instancePath:r+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.y!==void 0&&(Q(e.y,{instancePath:r+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.scaleX!==void 0&&(Q(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.scaleY!==void 0&&(Q(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.rotation!==void 0&&(Q(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Es.errors=t,s===0}function Ss(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(Object.keys(e).length<1){let i={instancePath:r,schemaPath:"#/minProperties",keyword:"minProperties",params:{limit:1},message:"must NOT have fewer than 1 properties"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="translateX"||i==="translateY"||i==="alpha"||i==="scaleX"||i==="scaleY"||i==="rotation")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.translateX!==void 0&&(Q(e.translateX,{instancePath:r+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.translateY!==void 0&&(Q(e.translateY,{instancePath:r+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.alpha!==void 0&&(Q(e.alpha,{instancePath:r+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.scaleX!==void 0&&(Q(e.scaleX,{instancePath:r+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.scaleY!==void 0&&(Q(e.scaleY,{instancePath:r+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length)),e.rotation!==void 0&&(Q(e.rotation,{instancePath:r+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(t=t===null?Q.errors:t.concat(Q.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Ss.errors=t,s===0}function Yr(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.tween===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="tween"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}e.tween!==void 0&&(Ss(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Ss.errors:t.concat(Ss.errors),s=t.length))}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Yr.errors=t,s===0}var is={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"]}}]},t0={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function Os(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="texture"||i==="channel"||i==="invert")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.texture!==void 0&&typeof e.texture!="string"){let i={instancePath:r+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.channel!==void 0){let i=e.channel;if(typeof i!="string"){let l={instancePath:r+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:r+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:t0.properties.channel.enum},message:"must be equal to one of the allowed values"};t===null?t=[l]:t.push(l),s++}}if(e.invert!==void 0&&typeof e.invert!="boolean"){let i={instancePath:r+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Os.errors=t,s===0}function Rs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="initialValue"||i==="keyframes")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.initialValue!==void 0&&typeof e.initialValue!="number"){let i={instancePath:r+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.keyframes!==void 0){let i=e.keyframes;if(Array.isArray(i)){if(i.length<1){let c={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[c]:t.push(c),s++}let l=i.length;for(let c=0;c<l;c++)zr(i[c],{instancePath:r+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(t=t===null?zr.errors:t.concat(zr.errors),s=t.length)}else{let l={instancePath:r+"/keyframes",schemaPath:"#/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Rs.errors=t,s===0}function Cs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let b={};t===null?t=[b]:t.push(b),s++}var u=c===s;if(s=i,t!==null&&(i?t.length=i:t=null),u){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.texture===void 0){let v={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[v]:t.push(v),s++}var u=b===s;l=u}if(!l){let b={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let p=s,f=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let b={};t===null?t=[b]:t.push(b),s++}var m=d===s;if(s=p,t!==null&&(p?t.length=p:t=null),m){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textures===void 0){let v={instancePath:r,schemaPath:"#/allOf/1/then/required",keyword:"required",params:{missingProperty:"textures"},message:"must have required property 'textures'"};t===null?t=[v]:t.push(v),s++}var m=b===s;f=m}if(!f){let b={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let y=s,g=!0,h=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let b={};t===null?t=[b]:t.push(b),s++}var w=h===s;if(s=y,t!==null&&(y?t.length=y:t=null),w){let b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.items===void 0){let v={instancePath:r,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"items"},message:"must have required property 'items'"};t===null?t=[v]:t.push(v),s++}var w=b===s;g=w}if(!g){let b={instancePath:r,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let b={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};t===null?t=[b]:t.push(b),s++}for(let b in e)if(!Ze.call(is.properties,b)){let E={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(e.kind!==void 0){let b=e.kind;if(typeof b!="string"){let E={instancePath:r+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="single"||b==="sequence"||b==="composite")){let E={instancePath:r+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:is.properties.kind.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let b={instancePath:r+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(e.textures!==void 0){let b=e.textures;if(Array.isArray(b)){if(b.length<1){let v={instancePath:r+"/textures",schemaPath:"#/properties/textures/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[v]:t.push(v),s++}let E=b.length;for(let v=0;v<E;v++)if(typeof b[v]!="string"){let P={instancePath:r+"/textures/"+v,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[P]:t.push(P),s++}}else{let E={instancePath:r+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[E]:t.push(E),s++}}if(e.items!==void 0){let b=e.items;if(Array.isArray(b)){if(b.length<1){let v={instancePath:r+"/items",schemaPath:"#/properties/items/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[v]:t.push(v),s++}let E=b.length;for(let v=0;v<E;v++)Os(b[v],{instancePath:r+"/items/"+v,parentData:b,parentDataProperty:v,rootData:a})||(t=t===null?Os.errors:t.concat(Os.errors),s=t.length)}else{let E={instancePath:r+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[E]:t.push(E),s++}}if(e.combine!==void 0){let b=e.combine;if(typeof b!="string"){let E={instancePath:r+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="max"||b==="min"||b==="multiply"||b==="add")){let E={instancePath:r+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:is.properties.combine.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.channel!==void 0){let b=e.channel;if(typeof b!="string"){let E={instancePath:r+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="red"||b==="green"||b==="blue"||b==="alpha")){let E={instancePath:r+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:is.properties.channel.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let b={instancePath:r+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[b]:t.push(b),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let b={instancePath:r+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[b]:t.push(b),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let b={instancePath:r+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}e.progress!==void 0&&(Rs(e.progress,{instancePath:r+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(t=t===null?Rs.errors:t.concat(Rs.errors),s=t.length))}else{let b={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}return Cs.errors=t,s===0}function $s(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let b={};t===null?t=[b]:t.push(b),s++}var u=c===s;if(s=i,t!==null&&(i?t.length=i:t=null),u){let b=s,E=s,v=s,P=s,k=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let q={};t===null?t=[q]:t.push(q),s++}}var p=O===s;if(k=k||p,!k){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Y;if(e.next===void 0&&(Y="next")){let T={};t===null?t=[T]:t.push(T),s++}}var p=$===s;if(k=k||p,!k){let Y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.mask===void 0&&(U="mask")){let ie={};t===null?t=[ie]:t.push(ie),s++}}var p=Y===s;k=k||p}}if(k)s=P,t!==null&&(P?t.length=P:t=null);else{let $={};t===null?t=[$]:t.push($),s++}var f=v===s;if(f){let $={instancePath:r,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[$]:t.push($),s++}else s=E,t!==null&&(E?t.length=E:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let $={instancePath:r,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};t===null?t=[$]:t.push($),s++}var u=b===s;l=u}if(!l){let b={instancePath:r,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}let d=s,m=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let b={};t===null?t=[b]:t.push(b),s++}var g=y===s;if(s=d,t!==null&&(d?t.length=d:t=null),g){let b=s,E=s,v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let q={};t===null?t=[q]:t.push(q),s++}}var h=v===s;if(h){let $={instancePath:r,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[$]:t.push($),s++}else s=E,t!==null&&(E?t.length=E:t=null);let P=s,k=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let $={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};t===null?t=[$]:t.push($),s++}var w=O===s;if(k=k||w,!k){let $=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let Y={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};t===null?t=[Y]:t.push(Y),s++}var w=$===s;if(k=k||w,!k){let Y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let U={instancePath:r,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};t===null?t=[U]:t.push(U),s++}var w=Y===s;k=k||w}}if(k)s=P,t!==null&&(P?t.length=P:t=null);else{let $={instancePath:r,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};t===null?t=[$]:t.push($),s++}var g=b===s;m=g}if(!m){let b={instancePath:r,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};t===null?t=[b]:t.push(b),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[b]:t.push(b),s++}for(let b in e)if(!(b==="name"||b==="type"||b==="complete"||b==="tween"||b==="prev"||b==="next"||b==="mask")){let E={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};t===null?t=[E]:t.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let b={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}if(e.type!==void 0){let b=e.type;if(typeof b!="string"){let E={instancePath:r+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[E]:t.push(E),s++}if(!(b==="update"||b==="transition")){let E={instancePath:r+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:e0.properties.type.enum},message:"must be equal to one of the allowed values"};t===null?t=[E]:t.push(E),s++}}if(e.complete!==void 0){let b=e.complete;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.payload!==void 0){let E=b.payload;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:r+"/complete/payload",schemaPath:"#/properties/complete/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[v]:t.push(v),s++}}}else{let E={instancePath:r+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[E]:t.push(E),s++}}e.tween!==void 0&&(Es(e.tween,{instancePath:r+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(t=t===null?Es.errors:t.concat(Es.errors),s=t.length)),e.prev!==void 0&&(Yr(e.prev,{instancePath:r+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(t=t===null?Yr.errors:t.concat(Yr.errors),s=t.length)),e.next!==void 0&&(Yr(e.next,{instancePath:r+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(t=t===null?Yr.errors:t.concat(Yr.errors),s=t.length)),e.mask!==void 0&&(Cs(e.mask,{instancePath:r+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(t=t===null?Cs.errors:t.concat(Cs.errors),s=t.length))}else{let b={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[b]:t.push(b),s++}return $s.errors=t,s===0}function Up(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return $s(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?$s.errors:t.concat($s.errors),s=t.length),Up.errors=t,s===0}var Bp=Yp;function _s(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!(i==="name"||i==="nameVariableId")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.name!==void 0&&typeof e.name!="string"){let i={instancePath:r+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(je(i)<1){let l={instancePath:r+"/nameVariableId",schemaPath:"#/properties/nameVariableId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/nameVariableId",schemaPath:"#/properties/nameVariableId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return _s.errors=t,s===0}function Yp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return _s(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?_s.errors:t.concat(_s.errors),s=t.length),Yp.errors=t,s===0}var zp=Gp;var n0=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function Ts(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.hex===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"hex"},message:"must have required property 'hex'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(i!=="hex"){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!n0.test(i)){let l={instancePath:r+"/hex",schemaPath:"#/properties/hex/pattern",keyword:"pattern",params:{pattern:"^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"},message:'must match pattern "^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$"'};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/hex",schemaPath:"#/properties/hex/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Ts.errors=t,s===0}function Gp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ts(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ts.errors:t.concat(Ts.errors),s=t.length),Gp.errors=t,s===0}var Hp=Xp;function Ns(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyboard!==void 0){let i=e.keyboard;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyboard/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let f={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),s++}}}else{let p={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let f={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[f]:t.push(f),s++}}}else{let p={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let u={instancePath:r+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyboard/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}}else{let l={instancePath:r+"/keyboard",schemaPath:"#/properties/keyboard/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.keyup!==void 0){let i=e.keyup;if(i&&typeof i=="object"&&!Array.isArray(i))for(let l in i){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.actions!==void 0){let u=c.actions;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/actions",schemaPath:"#/properties/keyup/additionalProperties/properties/actions/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}if(c.payload!==void 0){let u=c.payload;if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/payload",schemaPath:"#/properties/keyup/additionalProperties/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let u={instancePath:r+"/keyup/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/keyup/additionalProperties/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}}else{let l={instancePath:r+"/keyup",schemaPath:"#/properties/keyup/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Ns.errors=t,s===0}function Xp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ns(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ns.errors:t.concat(Ns.errors),s=t.length),Xp.errors=t,s===0}var Wp=Kp;function js(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return js.errors=t,s===0}function Kp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return js(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?js.errors:t.concat(js.errors),s=t.length),Kp.errors=t,s===0}var Jp=Qp;function Ds(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Ds.errors=t,s===0}function Qp(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ds(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ds.errors:t.concat(Ds.errors),s=t.length),Qp.errors=t,s===0}var Zp=ed;function Ls(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.elements!==void 0){let i=e.elements;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(!(u&&typeof u=="object"&&!Array.isArray(u))){let p={instancePath:r+"/elements/"+c,schemaPath:"#/properties/elements/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[p]:t.push(p),s++}}}else{let l={instancePath:r+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Ls.errors=t,s===0}function ed(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ls(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ls.errors:t.concat(Ls.errors),s=t.length),ed.errors=t,s===0}var rd=td;function Ms(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0,i=s,l=!1,c=null,u=s,p=s,f=s,d=s,m=!1,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let v;if(e.count===void 0&&(v="count")){let P={};t===null?t=[P]:t.push(P),s++}}var g=y===s;if(m=m||g,!m){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.texture===void 0&&(k="texture")){let O={};t===null?t=[O]:t.push(O),s++}}var g=v===s;if(m=m||g,!m){let k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.behaviors===void 0&&(D="behaviors")){let $={};t===null?t=[$]:t.push($),s++}}var g=k===s;if(m=m||g,!m){let D=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let q;if(e.emitter===void 0&&(q="emitter")){let Y={};t===null?t=[Y]:t.push(Y),s++}}var g=D===s;m=m||g}}}if(m)s=d,t!==null&&(d?t.length=d:t=null);else{let v={};t===null?t=[v]:t.push(v),s++}var h=f===s;if(h){let v={instancePath:r,schemaPath:"#/oneOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};t===null?t=[v]:t.push(v),s++}else s=p,t!==null&&(p?t.length=p:t=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.modules===void 0){let v={instancePath:r,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"modules"},message:"must have required property 'modules'"};t===null?t=[v]:t.push(v),s++}var b=u===s;b&&(l=!0,c=0);let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.texture===void 0){let v={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"texture"},message:"must have required property 'texture'"};t===null?t=[v]:t.push(v),s++}if(e.behaviors===void 0){let v={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"behaviors"},message:"must have required property 'behaviors'"};t===null?t=[v]:t.push(v),s++}if(e.emitter===void 0){let v={instancePath:r,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"emitter"},message:"must have required property 'emitter'"};t===null?t=[v]:t.push(v),s++}}var b=w===s;if(b&&l?(l=!1,c=[c,1]):b&&(l=!0,c=1),l)s=i,t!==null&&(i?t.length=i:t=null);else{let v={instancePath:r,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};t===null?t=[v]:t.push(v),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.width===void 0){let v={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[v]:t.push(v),s++}if(e.height===void 0){let v={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[v]:t.push(v),s++}for(let v in e)if(!(v==="width"||v==="height"||v==="seed"||v==="modules"||v==="count"||v==="texture"||v==="behaviors"||v==="emitter")){let P={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};t===null?t=[P]:t.push(P),s++}if(e.width!==void 0){let v=e.width;if(typeof v=="number"){if(v<=0||isNaN(v)){let P={instancePath:r+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[P]:t.push(P),s++}}else{let P={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[P]:t.push(P),s++}}if(e.height!==void 0){let v=e.height;if(typeof v=="number"){if(v<=0||isNaN(v)){let P={instancePath:r+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};t===null?t=[P]:t.push(P),s++}}else{let P={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[P]:t.push(P),s++}}if(e.seed!==void 0&&typeof e.seed!="number"){let v={instancePath:r+"/seed",schemaPath:"#/properties/seed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[v]:t.push(v),s++}if(e.modules!==void 0){let v=e.modules;if(v&&typeof v=="object"&&!Array.isArray(v)){if(v.emission===void 0){let P={instancePath:r+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};t===null?t=[P]:t.push(P),s++}if(v.appearance===void 0){let P={instancePath:r+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};t===null?t=[P]:t.push(P),s++}for(let P in v)if(!(P==="emission"||P==="movement"||P==="appearance"||P==="bounds")){let k={instancePath:r+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};t===null?t=[k]:t.push(k),s++}if(v.emission!==void 0){let P=v.emission;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let k={instancePath:r+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}if(v.movement!==void 0){let P=v.movement;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let k={instancePath:r+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}if(v.appearance!==void 0){let P=v.appearance;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let k={instancePath:r+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}if(v.bounds!==void 0){let P=v.bounds;if(!(P&&typeof P=="object"&&!Array.isArray(P))){let k={instancePath:r+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}}else{let P={instancePath:r+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[P]:t.push(P),s++}}if(e.count!==void 0){let v=e.count;if(!(typeof v=="number"&&!(v%1)&&!isNaN(v))){let P={instancePath:r+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[P]:t.push(P),s++}if(typeof v=="number"&&(v<1||isNaN(v))){let P={instancePath:r+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};t===null?t=[P]:t.push(P),s++}}if(e.texture!==void 0){let v=e.texture,P=s,k=!1,O=null,D=s;if(typeof v=="string"){if(je(v)<1){let q={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[q]:t.push(q),s++}}else{let q={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[q]:t.push(q),s++}var E=D===s;E&&(k=!0,O=0);let $=s;if(!(v&&typeof v=="object"&&!Array.isArray(v))){let q={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[q]:t.push(q),s++}var E=$===s;if(E&&k?(k=!1,O=[O,1]):E&&(k=!0,O=1),k)s=P,t!==null&&(P?t.length=P:t=null);else{let q={instancePath:r+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};t===null?t=[q]:t.push(q),s++}}if(e.behaviors!==void 0){let v=e.behaviors;if(Array.isArray(v)){if(v.length<1){let k={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[k]:t.push(k),s++}let P=v.length;for(let k=0;k<P;k++){let O=v[k];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let D={instancePath:r+"/behaviors/"+k,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};t===null?t=[D]:t.push(D),s++}for(let D in O)if(!(D==="type"||D==="config")){let $={instancePath:r+"/behaviors/"+k,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:D},message:"must NOT have additional properties"};t===null?t=[$]:t.push($),s++}if(O.type!==void 0){let D=O.type;if(typeof D=="string"){if(je(D)<1){let $={instancePath:r+"/behaviors/"+k+"/type",schemaPath:"#/properties/behaviors/items/properties/type/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[$]:t.push($),s++}}else{let $={instancePath:r+"/behaviors/"+k+"/type",schemaPath:"#/properties/behaviors/items/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[$]:t.push($),s++}}if(O.config!==void 0){let D=O.config;if(!(D&&typeof D=="object"&&!Array.isArray(D))){let $={instancePath:r+"/behaviors/"+k+"/config",schemaPath:"#/properties/behaviors/items/properties/config/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[$]:t.push($),s++}}}else{let D={instancePath:r+"/behaviors/"+k,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[D]:t.push(D),s++}}}else{let P={instancePath:r+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[P]:t.push(P),s++}}if(e.emitter!==void 0){let v=e.emitter;if(v&&typeof v=="object"&&!Array.isArray(v)){if(v.lifetime===void 0){let P={instancePath:r+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};t===null?t=[P]:t.push(P),s++}if(v.lifetime!==void 0){let P=v.lifetime;if(P&&typeof P=="object"&&!Array.isArray(P)){if(P.min===void 0){let k={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};t===null?t=[k]:t.push(k),s++}if(P.max===void 0){let k={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};t===null?t=[k]:t.push(k),s++}if(P.min!==void 0){let k=P.min;if(typeof k=="number"){if(k<0||isNaN(k)){let O={instancePath:r+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[O]:t.push(O),s++}}else{let O={instancePath:r+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[O]:t.push(O),s++}}if(P.max!==void 0){let k=P.max;if(typeof k=="number"){if(k<0||isNaN(k)){let O={instancePath:r+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[O]:t.push(O),s++}}else{let O={instancePath:r+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[O]:t.push(O),s++}}}else{let k={instancePath:r+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[k]:t.push(k),s++}}}else{let P={instancePath:r+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[P]:t.push(P),s++}}}else{let v={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[v]:t.push(v),s++}return Ms.errors=t,s===0}function td(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Ms(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Ms.errors:t.concat(Ms.errors),s=t.length),td.errors=t,s===0}var nd=sd;var pp={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 Vs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!Ze.call(pp.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.loop!==void 0&&typeof e.loop!="boolean"){let i={instancePath:r+"/loop",schemaPath:"#/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.volume!==void 0){let i=e.volume;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};t===null?t=[l]:t.push(l),s++}if(i<0||isNaN(i)){let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/volume",schemaPath:"#/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.muted!==void 0&&typeof e.muted!="boolean"){let i={instancePath:r+"/muted",schemaPath:"#/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[i]:t.push(i),s++}if(e.pan!==void 0){let i=e.pan;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[l]:t.push(l),s++}if(i<-1||isNaN(i)){let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/pan",schemaPath:"#/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startDelayMs!==void 0){let i=e.startDelayMs;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startDelayMs",schemaPath:"#/properties/startDelayMs/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.playbackRate!==void 0){let i=e.playbackRate;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/playbackRate",schemaPath:"#/properties/playbackRate/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.startAt!==void 0){let i=e.startAt;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}else{let l={instancePath:r+"/startAt",schemaPath:"#/properties/startAt/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}}if(e.endAt!==void 0){let i=e.endAt;if(typeof i!="number"&&i!==null){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/type",keyword:"type",params:{type:pp.properties.endAt.type},message:"must be number,null"};t===null?t=[l]:t.push(l),s++}if(typeof i=="number"&&(i<0||isNaN(i))){let l={instancePath:r+"/endAt",schemaPath:"#/properties/endAt/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Vs.errors=t,s===0}function sd(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Vs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Vs.errors:t.concat(Vs.errors),s=t.length),sd.errors=t,s===0}var od=id;var s0=new RegExp("^.+$","u");function qs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.jsonData===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"jsonData"},message:"must have required property 'jsonData'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="jsonData"||i==="width"||i==="height"||i==="animations")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.jsonData!==void 0){let i=e.jsonData;if(!(i&&typeof i=="object"&&!Array.isArray(i))){let l={instancePath:r+"/jsonData",schemaPath:"#/properties/jsonData/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(s0.test(l)){let c=i[l];if(c&&typeof c=="object"&&!Array.isArray(c)){if(c.frames===void 0){let u={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/required",keyword:"required",params:{missingProperty:"frames"},message:"must have required property 'frames'"};t===null?t=[u]:t.push(u),s++}for(let u in c)if(!(u==="frames"||u==="animationSpeed"||u==="loop")){let p={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:u},message:"must NOT have additional properties"};t===null?t=[p]:t.push(p),s++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let f=0;f<p;f++)if(typeof u[f]!="number"){let d={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+f,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[d]:t.push(d),s++}}else{let p={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[p]:t.push(p),s++}}if(c.animationSpeed!==void 0&&typeof c.animationSpeed!="number"){let u={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/animationSpeed",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}if(c.loop!==void 0&&typeof c.loop!="boolean"){let u={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/loop",schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[u]:t.push(u),s++}}}else{let l={instancePath:r+"/animations",schemaPath:"#/properties/animations/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return qs.errors=t,s===0}function id(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return qs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?qs.errors:t.concat(qs.errors),s=t.length),id.errors=t,s===0}var ad=ld;var dp={type:"object",properties:{fontId:{oneOf:[{type:"string",minLength:1},{type:"array",minItems:1,uniqueItems:!0,items:{type:"string",minLength:1}}]},colorId:{type:"string"},colorAlpha:{type:"number"},fontSize:{type:"number"},fontWeight:{type:"string"},fontStyle:{type:"string",enum:["normal","italic","oblique"]},lineHeight:{type:"number"},align:{type:"string"},wordWrap:{type:"boolean"},breakWords:{type:"boolean"},wordWrapWidth:{type:"number"},strokeColorId:{type:"string"},strokeAlpha:{type:"number"},strokeWidth:{type:"number"},shadow:{type:"object",properties:{colorId:{type:"string",minLength:1},alpha:{type:"number",minimum:0,maximum:1},blur:{type:"number",minimum:0},offsetX:{type:"number"},offsetY:{type:"number"}},required:["colorId"],additionalProperties:!1}},required:["fontId","fontSize","fontWeight","fontStyle","lineHeight","colorId"],additionalProperties:!1};function Fs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fontId===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontId"},message:"must have required property 'fontId'"};t===null?t=[l]:t.push(l),s++}if(e.fontSize===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontSize"},message:"must have required property 'fontSize'"};t===null?t=[l]:t.push(l),s++}if(e.fontWeight===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontWeight"},message:"must have required property 'fontWeight'"};t===null?t=[l]:t.push(l),s++}if(e.fontStyle===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fontStyle"},message:"must have required property 'fontStyle'"};t===null?t=[l]:t.push(l),s++}if(e.lineHeight===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"lineHeight"},message:"must have required property 'lineHeight'"};t===null?t=[l]:t.push(l),s++}if(e.colorId===void 0){let l={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};t===null?t=[l]:t.push(l),s++}for(let l in e)if(!Ze.call(dp.properties,l)){let c={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:l},message:"must NOT have additional properties"};t===null?t=[c]:t.push(c),s++}if(e.fontId!==void 0){let l=e.fontId,c=s,u=!1,p=null,f=s;if(typeof l=="string"){if(je(l)<1){let m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[m]:t.push(m),s++}}else{let m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[m]:t.push(m),s++}var i=f===s;i&&(u=!0,p=0);let d=s;if(Array.isArray(l)){if(l.length<1){let h={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};t===null?t=[h]:t.push(h),s++}let m=l.length;for(let h=0;h<m;h++){let w=l[h];if(typeof w=="string"){if(je(w)<1){let b={instancePath:r+"/fontId/"+h,schemaPath:"#/properties/fontId/oneOf/1/items/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[b]:t.push(b),s++}}else{let b={instancePath:r+"/fontId/"+h,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[b]:t.push(b),s++}}let y=l.length,g;if(y>1){let h={};for(;y--;){let w=l[y];if(typeof w=="string"){if(typeof h[w]=="number"){g=h[w];let b={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:y,j:g},message:"must NOT have duplicate items (items ## "+g+" and "+y+" are identical)"};t===null?t=[b]:t.push(b),s++;break}h[w]=y}}}}else{let m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};t===null?t=[m]:t.push(m),s++}var i=d===s;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)s=c,t!==null&&(c?t.length=c:t=null);else{let m={instancePath:r+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};t===null?t=[m]:t.push(m),s++}}if(e.colorId!==void 0&&typeof e.colorId!="string"){let l={instancePath:r+"/colorId",schemaPath:"#/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.colorAlpha!==void 0&&typeof e.colorAlpha!="number"){let l={instancePath:r+"/colorAlpha",schemaPath:"#/properties/colorAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.fontSize!==void 0&&typeof e.fontSize!="number"){let l={instancePath:r+"/fontSize",schemaPath:"#/properties/fontSize/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.fontWeight!==void 0&&typeof e.fontWeight!="string"){let l={instancePath:r+"/fontWeight",schemaPath:"#/properties/fontWeight/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.fontStyle!==void 0){let l=e.fontStyle;if(typeof l!="string"){let c={instancePath:r+"/fontStyle",schemaPath:"#/properties/fontStyle/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[c]:t.push(c),s++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:r+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:dp.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};t===null?t=[c]:t.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:r+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:r+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:r+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[l]:t.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:r+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};t===null?t=[l]:t.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:r+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:r+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[l]:t.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:r+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:r+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[l]:t.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};t===null?t=[c]:t.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};t===null?t=[u]:t.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(je(c)<1){let u={instancePath:r+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[u]:t.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};t===null?t=[u]:t.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:r+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};t===null?t=[u]:t.push(u),s++}}else{let u={instancePath:r+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[u]:t.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:r+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[c]:t.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:r+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[c]:t.push(c),s++}}else{let c={instancePath:r+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[c]:t.push(c),s++}}}else{let l={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[l]:t.push(l),s++}return Fs.errors=t,s===0}function ld(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Fs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Fs.errors:t.concat(Fs.errors),s=t.length),ld.errors=t,s===0}var cd=ud;var o0={type:"object",properties:{x:{type:"integer"},y:{type:"integer"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"}},additionalProperties:!1};function Us(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ze.call(o0.properties,i)){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.x!==void 0){let i=e.x;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/x",schemaPath:"#/properties/x/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.y!==void 0){let i=e.y;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/y",schemaPath:"#/properties/y/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.anchorX!==void 0&&typeof e.anchorX!="number"){let i={instancePath:r+"/anchorX",schemaPath:"#/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.anchorY!==void 0&&typeof e.anchorY!="number"){let i={instancePath:r+"/anchorY",schemaPath:"#/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleX!==void 0&&typeof e.scaleX!="number"){let i={instancePath:r+"/scaleX",schemaPath:"#/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.scaleY!==void 0&&typeof e.scaleY!="number"){let i={instancePath:r+"/scaleY",schemaPath:"#/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.rotation!==void 0&&typeof e.rotation!="number"){let i={instancePath:r+"/rotation",schemaPath:"#/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originX!==void 0&&typeof e.originX!="number"){let i={instancePath:r+"/originX",schemaPath:"#/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}if(e.originY!==void 0&&typeof e.originY!="number"){let i={instancePath:r+"/originY",schemaPath:"#/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};t===null?t=[i]:t.push(i),s++}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Us.errors=t,s===0}function ud(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Us(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Us.errors:t.concat(Us.errors),s=t.length),ud.errors=t,s===0}var pd=dd;function Bs(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.fileId===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"fileId"},message:"must have required property 'fileId'"};t===null?t=[i]:t.push(i),s++}if(e.width===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"width"},message:"must have required property 'width'"};t===null?t=[i]:t.push(i),s++}if(e.height===void 0){let i={instancePath:r,schemaPath:"#/required",keyword:"required",params:{missingProperty:"height"},message:"must have required property 'height'"};t===null?t=[i]:t.push(i),s++}for(let i in e)if(!(i==="fileId"||i==="fileType"||i==="width"||i==="height")){let l={instancePath:r,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};t===null?t=[l]:t.push(l),s++}if(e.fileId!==void 0&&typeof e.fileId!="string"){let i={instancePath:r+"/fileId",schemaPath:"#/properties/fileId/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.fileType!==void 0&&typeof e.fileType!="string"){let i={instancePath:r+"/fileType",schemaPath:"#/properties/fileType/type",keyword:"type",params:{type:"string"},message:"must be string"};t===null?t=[i]:t.push(i),s++}if(e.width!==void 0){let i=e.width;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}if(e.height!==void 0){let i=e.height;if(!(typeof i=="number"&&!(i%1)&&!isNaN(i))){let l={instancePath:r+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"integer"},message:"must be integer"};t===null?t=[l]:t.push(l),s++}}}else{let i={instancePath:r,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};t===null?t=[i]:t.push(i),s++}return Bs.errors=t,s===0}function dd(e,{instancePath:r="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let t=null,s=0;return Bs(e,{instancePath:r,parentData:n,parentDataProperty:o,rootData:a})||(t=t===null?Bs.errors:t.concat(Bs.errors),s=t.length),dd.errors=t,s===0}var en=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),Zt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ur=e=>e===void 0?void 0:structuredClone(e),i0=Object.freeze({achievement:"achievements",animation:"animations",character:"characters",color:"colors",control:"controls",font:"fonts",image:"images",layout:"layouts",particle:"particles",sound:"sounds",spritesheet:"spritesheets",textStyle:"textStyles",transform:"transforms",video:"videos"}),a0=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),l0=Object.freeze({background:fp,bgm:yp,character:gp,choice:Ip,cleanAll:kp,control:Ap,dialogue:xp,form:Sp,layout:Rp,screen:$p,sfx:Tp,visual:jp,voice:Lp}),c0=Object.freeze({achievement:Vp,animation:Fp,character:Bp,color:zp,control:Hp,font:Wp,image:Jp,layout:Zp,particle:rd,sound:nd,spritesheet:od,textStyle:ad,transform:cd,video:pd}),u0=new Set(["files","language","patches"]),p0=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),d0=new Set(["lineId","mode","payload","type"]),f0=new Set(["mode","payload","sceneId","type"]),m0=new Set(["mode","operation","payload","resourceId","type"]),y0=new Set(["fileId","mimeType"]),z=(e,r)=>{throw new Error(`Invalid l10nData at ${e}: ${r}`)},He=(e,r)=>{Zt(e)||z(r,"expected an object")},ra=(e,r)=>{Array.isArray(e)||z(r,"expected an array")},ft=(e,r)=>{(typeof e!="string"||e.length===0)&&z(r,"expected a non-empty string")},hd=(e,r)=>{typeof e!="string"&&z(r,"expected a string")},rr=(e,r,n)=>{for(let o of Object.keys(e))r.has(o)||z(`${n}.${o}`,"unknown field")},tr=(e,r,n)=>{for(let o of r)en(e,o)||z(n,`missing required field "${o}"`)},h0=e=>e.replaceAll("~1","/").replaceAll("~0","~"),g0=(e,r)=>{let n=(r?.instancePath??"").split("/").slice(1).map(h0);return r?.keyword==="required"?n.push(r.params.missingProperty):r?.keyword==="additionalProperties"&&n.push(r.params.additionalProperty),n.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},b0=(e=[])=>e.filter(r=>!["anyOf","if","not","oneOf"].includes(r.keyword)).reduce((r,n)=>{if(r===void 0)return n;let o=n.instancePath.split("/").length,a=r.instancePath.split("/").length;return o>a?n:r},void 0)??e[0],gd=({value:e,validator:r,path:n,contract:o})=>{if(r(e))return;let a=b0(r.errors);z(g0(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Ys=(e,r,n=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||z(r,"expected a finite number");return}if(!(e===null||typeof e!="object"||n.has(e))){if(n.add(e),Array.isArray(e)){e.forEach((o,a)=>Ys(o,`${r}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>Ys(a,`${r}.${o}`,n))}},er=(e,r)=>{e===""&&z(r,"expected a non-empty resourceId")},I0=(e,r,n)=>{let o=(s,i)=>er(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>er(l?.resourceId,`${i}[${c}].resourceId`)),t=(s,i)=>{er(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":er(r.resourceId,`${n}.resourceId`),o(r.animations,`${n}.animations`);break;case"bgm":case"voice":t(r,n);break;case"sfx":a(r.items,`${n}.items`),(r.channels??[]).forEach((s,i)=>a(s?.sounds,`${n}.channels[${i}].sounds`));break;case"character":(r.items??[]).forEach((s,i)=>{(s.sprites??[]).forEach((l,c)=>er(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":er(r.resourceId,`${n}.resourceId`),o(r.animations,`${n}.animations`);break;case"control":er(r.resourceId,`${n}.resourceId`);break;case"dialogue":er(r.ui?.resourceId,`${n}.ui.resourceId`),o(r.ui?.animations,`${n}.ui.animations`),(r.character?.sprite?.items??[]).forEach((s,i)=>er(s?.resourceId,`${n}.character.sprite.items[${i}].resourceId`)),o(r.character?.sprite?.animations,`${n}.character.sprite.animations`);break;case"screen":o(r.animations,`${n}.animations`);break;case"visual":(r.items??[]).forEach((s,i)=>{er(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},mt=(e,r)=>{ft(e,r),(e==="__proto__"||e==="constructor"||e==="prototype")&&z(r,`"${e}" is not a safe ID`)},w0=(e,r)=>{ft(e,r),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&z(r,"must be a safe single filename")},Qt=(e,r)=>{if(Object.is(e,r))return!0;if(Array.isArray(e)||Array.isArray(r))return!Array.isArray(e)||!Array.isArray(r)?!1:e.length===r.length&&e.every((a,t)=>Qt(a,r[t]));if(!Zt(e)||!Zt(r))return!1;let n=Object.keys(e).sort(),o=Object.keys(r).sort();return Qt(n,o)&&n.every(a=>Qt(e[a],r[a]))},zs=(e,r=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>zs(o,r,n)),r;if(!Zt(e)||n.has(e))return r;n.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&r.add(a),zs(a,r,n);return r},k0=e=>{let r=new Map;for(let[n,o]of Object.entries(e?.story?.scenes??{}))for(let[a,t]of Object.entries(o?.sections??{}))for(let[s,i]of(t?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=r.get(i.id)??[];l.push({sceneId:n,sectionId:a,lineIndex:s,line:i}),r.set(i.id,l)}return r},bd=(e,r,n)=>{let o=e.get(r)??[];return o.length===0&&z(n,`lineId "${r}" does not exist in projectData`),o.length>1&&z(n,`lineId "${r}" is not globally unique in projectData`),o[0]},Id=(e,r)=>e.story.scenes[r.sceneId].sections[r.sectionId].lines[r.lineIndex],fd=e=>({items:(e?.items??[]).map(r=>({id:r?.id,events:r?.events}))}),md=e=>{let r=ur(e??{});delete r.resourceId,delete r.animations;for(let n of Object.values(r.fields??{}))Zt(n)&&delete n.placeholder;return r},v0=(e,r,n,o)=>{e==="choice"&&!Qt(fd(r),fd(n))&&z(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!Qt(md(r),md(n))&&z(o,"form behavior must remain identical; only presentation fields and placeholders may change")},A0=({patch:e,path:r,lineIndex:n})=>{rr(e,p0,r),tr(e,["type","lineId","actionType","payload"],r),mt(e.lineId,`${r}.lineId`),ft(e.actionType,`${r}.actionType`),He(e.payload,`${r}.payload`),e.mode!==void 0&&e.mode!=="replace"&&z(`${r}.mode`,'line.action supports only "replace"'),a0.has(e.actionType)||z(`${r}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=bd(n,e.lineId,`${r}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&z(`${r}.actionType`,`source line "${e.lineId}" does not contain action "${e.actionType}"`),e.actionType==="dialogue"?((!Array.isArray(e.ignoreFields)||e.ignoreFields.length!==1||e.ignoreFields[0]!=="content")&&z(`${r}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),en(e.payload,"content")&&z(`${r}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&z(`${r}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),v0(e.actionType,a,e.payload,`${r}.payload`),gd({value:e.payload,validator:l0[e.actionType],path:`${r}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Ys(e.payload,`${r}.payload`),I0(e.actionType,e.payload,`${r}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},P0=(e,r)=>{ra(e,r),e.forEach((n,o)=>{He(n,`${r}[${o}]`),rr(n,new Set(["text"]),`${r}[${o}]`),tr(n,["text"],`${r}[${o}]`),hd(n.text,`${r}[${o}].text`)})},x0=({patch:e,path:r,lineIndex:n})=>{rr(e,d0,r),tr(e,["type","lineId","payload"],r),mt(e.lineId,`${r}.lineId`),He(e.payload,`${r}.payload`),rr(e.payload,new Set(["content"]),`${r}.payload`),tr(e.payload,["content"],`${r}.payload`),P0(e.payload.content,`${r}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&z(`${r}.mode`,'line.dialogue supports only "replace"');let o=bd(n,e.lineId,`${r}.lineId`);return o.line?.actions?.dialogue===void 0&&z(`${r}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},E0=({patch:e,path:r,projectData:n})=>(rr(e,f0,r),tr(e,["type","mode","sceneId","payload"],r),mt(e.sceneId,`${r}.sceneId`),He(e.payload,`${r}.payload`),rr(e.payload,new Set(["name"]),`${r}.payload`),tr(e.payload,["name"],`${r}.payload`),hd(e.payload.name,`${r}.payload.name`),e.mode!=="patch"&&z(`${r}.mode`,'story.scene requires "patch"'),en(n?.story?.scenes??{},e.sceneId)||z(`${r}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),S0=(e,r,n)=>{He(r,n),["font","image","sound","spritesheet","video"].includes(e)&&ft(r.fileId,`${n}.fileId`),["image","video"].includes(e)&&(Number.isInteger(r.width)||z(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||z(`${n}.height`,"expected an integer")),e==="spritesheet"&&(He(r.jsonData,`${n}.jsonData`),Number.isInteger(r.width)||z(`${n}.width`,"expected an integer"),Number.isInteger(r.height)||z(`${n}.height`,"expected an integer")),e==="color"&&(typeof r.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(r.hex))&&z(`${n}.hex`,"expected an opaque #RGB or #RRGGBB color"),gd({value:r,validator:c0[e],path:n,contract:`the resource.${e} schema`}),Ys(r,n)},O0=({patch:e,path:r,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{rr(e,m0,r),tr(e,["type","resourceId","payload"],r),mt(e.resourceId,`${r}.resourceId`);let t=e.type.slice(9),s=i0[t];s||z(`${r}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&z(`${r}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&z(`${r}.operation`,'the only resource operation is "add"'),S0(t,e.payload,`${r}.payload`);let i=n?.resources?.[s]??{},l=en(i,e.resourceId);e.operation==="add"&&l&&z(`${r}.resourceId`,`cannot add existing ${t} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&z(`${r}.resourceId`,`cannot replace missing ${t} resource "${e.resourceId}"`);for(let c of zs(e.payload))!o.has(c)&&!a.has(c)&&z(`${r}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:s,path:r,patch:e}},yd=({resources:e,collectionName:r,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!en(e?.[r]??{},n))&&z(o,`${a} resource "${n}" was not found`)},R0=(e,r)=>{let n=ur(e);for(let a of r.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=ur(a.patch.payload));let o=n.resources??{};for(let a of r.patches){if(a.patch.type!=="resource.textStyle")continue;let t=a.patch.payload,s=Array.isArray(t.fontId)?t.fontId:[t.fontId];s.forEach((i,l)=>yd({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${s.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",t.colorId],["strokeColorId",t.strokeColorId],["shadow.colorId",t.shadow?.colorId]])yd({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},C0=({patch:e,path:r,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:t})=>{if(He(e,r),ft(e.type,`${r}.type`),e.type==="line.action")return A0({patch:e,path:r,lineIndex:o});if(e.type==="line.dialogue")return x0({patch:e,path:r,lineIndex:o});if(e.type==="story.scene")return E0({patch:e,path:r,projectData:n});if(e.type.startsWith("resource."))return O0({patch:e,path:r,projectData:n,packageFileIds:a,canonicalFileIds:t});z(`${r}.type`,`unsupported patch type "${e.type}"`)},$0=(e,r)=>{ra(e,r);let n=new Set;return e.forEach((o,a)=>{let t=`${r}[${a}]`;He(o,t),rr(o,y0,t),tr(o,["fileId"],t),w0(o.fileId,`${t}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&z(`${t}.mimeType`,"expected a non-empty string"),n.has(o.fileId)&&z(`${t}.fileId`,`duplicate fileId "${o.fileId}"`),n.add(o.fileId)}),n},_0=({packageId:e,packageData:r,path:n,projectData:o,lineIndex:a,canonicalFileIds:t})=>{He(r,n),rr(r,u0,n),tr(r,["language","files","patches"],n),ft(r.language,`${n}.language`);let s=$0(r.files,`${n}.files`);ra(r.patches,`${n}.patches`);let i=new Set,l=r.patches.map((c,u)=>{let p=C0({patch:c,path:`${n}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:s,canonicalFileIds:t});return i.has(p.key)&&z(`${n}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:r,fileIds:s,patches:l}},wd=({projectData:e,l10nData:r})=>{if(r===void 0)return{packages:new Map};He(r,"l10nData"),rr(r,new Set(["packages"]),"l10nData"),tr(r,["packages"],"l10nData"),He(r.packages,"l10nData.packages");let n=k0(e),o=zs(e?.resources??{}),a=new Map,t=new Map;for(let[s,i]of Object.entries(r.packages)){mt(s,`l10nData.packages.${s}`);let l=_0({packageId:s,packageData:i,path:`l10nData.packages.${s}`,projectData:e,lineIndex:n,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&z(`l10nData.packages.${s}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=t.get(c);u!==void 0&&z(`l10nData.packages.${s}.files`,`fileId "${c}" is already declared by package "${u}"`),t.set(c,s)}R0(e,l),a.set(s,l)}return{packages:a}},T0=(e,r)=>{let{collectionName:n,patch:o}=r;e.resources[n]??={},e.resources[n][o.resourceId]=ur(o.payload)},N0=(e,r)=>{let{patch:n}=r,o=e.story.scenes[n.sceneId];o.name=n.payload.name},j0=(e,r)=>{let{location:n,patch:o}=r,a=Id(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=ur(o.payload);return}let t=ur(n.line.actions.dialogue.content);a.actions.dialogue=ur(o.payload),t!==void 0&&(a.actions.dialogue.content=t)},D0=(e,r)=>{let{location:n,patch:o}=r,a=Id(e,n);a.actions.dialogue.content=ur(o.payload.content)},kd=({projectData:e,l10nData:r})=>{let n=wd({projectData:e,l10nData:r});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},Gs=({projectData:e,l10nData:r,l10nId:n=null})=>{let o=wd({projectData:e,l10nData:r});if(n!==null&&(mt(n,"l10nId"),o.packages.has(n)||z("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=ur(e),t=o.packages.get(n).patches;return t.filter(s=>s.kind==="resource").forEach(s=>T0(a,s)),t.filter(s=>s.kind==="story.scene").forEach(s=>N0(a,s)),t.filter(s=>s.kind==="line.action").forEach(s=>j0(a,s)),t.filter(s=>s.kind==="line.dialogue").forEach(s=>D0(a,s)),a};var ta=Object.freeze({auto:1e3,skip:80,authored:1e3}),nn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),vd=new WeakMap,L0=new ArrayBuffer(8),na=new DataView(L0),M0=e=>{let r=vd.get(e);if(r)return r;let n={dispatchDepth:0};return vd.set(e,n),n},V0=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null},q0=(e,r)=>Object.keys(e).length===r.length&&r.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Sr=(e,r,n)=>{if(!V0(e)||!q0(e,r))throw new TypeError(`${n} has an invalid shape`)},rn=(e,r)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${r} must be a non-negative safe integer`)},tn=(e,r)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${r} must be a finite non-negative number`)},Ad=e=>{if(tn(e,"duration"),e===0)return 0n;na.setFloat64(0,e,!1);let r=na.getUint32(0,!1),n=na.getUint32(4,!1),o=r>>>20&2047,a=BigInt(r&1048575)<<32n|BigInt(n);if(o===0)return a;let t=1n<<52n|a,s=o-1;return t<<BigInt(s)},F0=e=>structuredClone(e),sa=(e,r)=>e===r?!0:!e||!r||e.mode!==r.mode||e.kind!==r.kind?!1:e.mode==="legacy"?e.instanceToken===r.instanceToken:e.delayMs!==r.delayMs?!1:e.kind==="auto"?e.contentKey===r.contentKey&&e.owner.sessionId===r.owner.sessionId&&e.owner.lineEntryId===r.owner.lineEntryId:e.kind==="skip"?e.owner.sessionId===r.owner.sessionId:e.trigger===r.trigger&&e.owner.lineEntryId===r.owner.lineEntryId,oa=(e,r,n)=>{if(r===null)return null;if(e==="auto"){if(Sr(r,["owner","delayMs","contentKey"],"auto timer"),Sr(r.owner,["sessionId","lineEntryId"],"auto timer owner"),rn(r.owner.sessionId,"auto owner sessionId"),rn(r.owner.lineEntryId,"auto owner lineEntryId"),r.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(tn(r.delayMs,"auto delayMs"),typeof r.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Sr(r,["owner","delayMs"],"skip timer"),Sr(r.owner,["sessionId"],"skip timer owner"),rn(r.owner.sessionId,"skip owner sessionId"),tn(r.delayMs,"skip delayMs");else{if(Sr(r,["owner","delayMs","trigger"],"authored timer"),Sr(r.owner,["lineEntryId"],"authored timer owner"),rn(r.owner.lineEntryId,"authored owner lineEntryId"),r.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(tn(r.delayMs,"authored delayMs"),r.trigger!=="fromStart"&&r.trigger!=="fromComplete")throw new TypeError('authored trigger must be "fromStart" or "fromComplete"')}return{mode:"reconciled",kind:e,...F0(r)}},U0=e=>{if(Sr(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(rn(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}}Sr(e.timers,["auto","skip","authored"],"playback schedule timers");let r={auto:oa("auto",e.timers.auto,e.lineEntryId),skip:oa("skip",e.timers.skip,e.lineEntryId),authored:oa("authored",e.timers.authored,e.lineEntryId)};if(r.auto&&r.skip)throw new TypeError("playback schedule cannot enable auto and skip together");return{contractVersion:1,status:"settled",lineEntryId:e.lineEntryId,timers:r}},ia=e=>({descriptor:e,remainingQuanta:Ad(e.delayMs)}),Hs=["auto","skip","authored"],Pd=({ticker:e,dispatchAutomaticAttempt:r,classifyAutomaticAttemptError:n=()=>"preCommit"})=>{if(!e||typeof e.add!="function"||typeof e.remove!="function")throw new TypeError("playback scheduler requires a ticker with add/remove");if(typeof r!="function")throw new TypeError("playback scheduler requires dispatchAutomaticAttempt");let o=M0(e),a=!0,t={},s={},i=null,l=null,c=null,u=null,p=!1,f=!1,d="legacy",m={auto:null,skip:null,authored:null},y={auto:null,skip:null,authored:null},g={auto:0,skip:0,authored:0},h=()=>Hs.some(L=>m[L]),w=()=>{l=null,c=null},b=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let L=c;if(L){if(o.dispatchDepth>0||f){b();return}a&&t===L.lifecycleToken&&s===L.generationToken&&i===L.callback&&h()&&!u&&(l=L.registrationToken),c===L&&(c=null)}}))},E=()=>{if(!u)return;let L=u;e.remove(L),u===L&&(u=null)},v=()=>{let L=i;L&&(w(),i=null,u=L,e.remove(L),u===L&&(u=null))},P=()=>{m={auto:null,skip:null,authored:null}},k=()=>{P(),s={},f||v()},O=L=>{if(o.dispatchDepth>0||f){c=L,b();return}a&&t===L.lifecycleToken&&s===L.generationToken&&i===L.callback&&h()&&(l=L.registrationToken),c===L&&(c=null)},D=()=>{if(!a||!h()||i)return;E();let L=t,ae=s,ue={},B=oe=>{if(!a||L!==t||ae!==s||ue!==l||B!==i||f)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 re=Ad(oe.deltaMS);f=!0,o.dispatchDepth+=1;let pe=s,te=null;try{let C=[];for(let _ of Hs){let F=m[_];F&&(F.remainingQuanta<=re?(C.push({kind:_,descriptor:F.descriptor,revision:g[_]}),m[_]=null):F.remainingQuanta-=re)}if(C.length>0){try{r({dueKinds:C.map(({kind:_})=>_)})}catch(_){let F=n(_);if(d==="reconciled"&&F==="preCommit")for(let{kind:K,descriptor:de}of C)y[K]=de;else d==="legacy"&&P();throw _}if(d==="legacy")for(let _ of C)_.kind==="skip"&&g.skip===_.revision&&m.skip===null&&(m.skip=ia(_.descriptor))}}catch(C){te=C}finally{o.dispatchDepth-=1,f=!1;try{pe===s?h()?D():v():i===B&&!h()&&v()}catch(C){throw te?new AggregateError([te,C],"Playback attempt and ticker cleanup both failed"):C}}if(te)throw te},Z={callback:B,lifecycleToken:L,generationToken:ae,registrationToken:ue};i=B,c=Z;try{e.add(B)}catch(oe){throw i=null,w(),P(),s={},u=B,oe}O(Z)},$=L=>{g[L]+=1,m[L]=null,y[L]=null,!h()&&!f&&v()},q=(L,ae)=>{tn(ae,`${L} delay`),d="legacy",g[L]+=1,y[L]=null,m[L]=ia({mode:"legacy",kind:L,instanceToken:{},delayMs:ae}),D()};return{handleLegacyEffect:L=>{switch(L.name){case"startAutoNextTimer":return q("auto",L.payload?.delay??ta.auto),!0;case"clearAutoNextTimer":return $("auto"),!0;case"startSkipNextTimer":return q("skip",L.payload?.delay??ta.skip),!0;case"clearSkipNextTimer":return $("skip"),!0;case"nextLineConfigTimer":return q("authored",L.payload?.delay??ta.authored),!0;case"clearNextLineConfigTimer":return $("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:L=>{let ae;try{ae=U0(L)}catch(B){try{k()}catch(Z){throw new AggregateError([B,Z],"Playback schedule validation and cleanup both failed")}throw B}if(d="reconciled",ae.status==="unsettled"){P(),f||v();return}let ue={};for(let B of Hs){let Z=ae.timers[B],oe=y[B];if(oe&&(!Z||!sa(oe,Z))&&(y[B]=null),Z&&y[B]&&sa(y[B],Z)){ue[B]=null;continue}let re=m[B];ue[B]=Z&&re&&sa(re.descriptor,Z)?re:Z?ia(Z):null}m=ue,h()?D():f||v()},reset:()=>{let L=[i,u].filter((B,Z,oe)=>B&&oe.indexOf(B)===Z);t={},s={},w(),i=null,u=null,P(),y={auto:null,skip:null,authored:null};for(let B of Hs)g[B]+=1;d="legacy",a=!0;let ae=null,ue=null;for(let B of L)try{e.remove(B)}catch(Z){ae??=Z,ue??=B}if(u=ue,ae)throw ae},dispose:()=>{a=!1,t={},s={},w(),P(),y={auto:null,skip:null,authored:null};let L=[i,u].filter((B,Z,oe)=>B&&oe.indexOf(B)===Z);i=null,u=null;let ae=null,ue=null;for(let B of L)try{e.remove(B)}catch(Z){ae??=Z,ue??=B}if(u=ue,ae)throw ae}}};var B0=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),Y0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),aa="conditional",sn="random",ca=Symbol("conditionalAutoContinue"),z0=new Set(["sectionTransition","resetStoryAtSection"]),G0=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),H0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),X0=new Set(["nextLine","nextLineFromSystem"]),W0=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),la="form",K0=new Set(["submitForm","cancelForm"]),J0="showImageGalleryVariant",Q0="playMusicRoomTrack",Z0="startSceneReplay",ek=new Set(["startAutoMode","stopAutoMode","toggleAutoMode","startSkipMode","stopSkipMode","toggleSkipMode","setAutoForwardDelay","setAutoForwardSpeed","setNextLineConfig","markLineCompleted","nextLine","nextLineFromSystem","jumpToLine","sectionTransition","resetStoryAtSection","loadSlot","rollbackByOffset","rollbackToLine","startSceneReplay","exitSceneReplay","updateProjectData","updateLocalizationPackage","submitForm","cancelForm"]),Le=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),rk=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,on=e=>e?.type===ca,Gr=(e,r)=>e?.sectionId===r?.sectionId&&e?.lineId===r?.lineId,tk=(e,r)=>[...new Set([...Object.keys(e??{}),...Object.keys(r??{})])].some(o=>!Object.is(e?.[o],r?.[o]));function ua(e){let r=rk(),n,o=0,a=!1,t=0,s=null,i=0,l=!1,c=0,u=[],p=null,f=null,d=new Map,m=new Map,y=new Map,g,h,w=null,b=!1,E=!1,v=0,P=new Map,k=hl(e.randomSource),{handlePendingEffects:O}=e;if(typeof O!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let D=O.bind(O),$=typeof O.reconcilePlaybackScheduleV1=="function"?O.reconcilePlaybackScheduleV1.bind(O):null,q=typeof O.reset=="function"?O.reset.bind(O):null,Y=typeof O.dispose=="function"?O.dispose.bind(O):null;if($&&(!q||!Y))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let T=I=>{if(E)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},U=I=>{if(T(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},ie=(I,A)=>{if(v===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=P.get(I);(R===void 0||S[A]>S[R])&&P.set(I,A)},L=I=>{let A=P.get(I)??"preCommit";return P.delete(I),A},ae=I=>{if($){E=!0;try{let A=$(structuredClone(I));if(A!==null&&(typeof A=="object"||typeof A=="function")&&typeof A.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{E=!1}}},ue=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),B=I=>{if(!(!$||!a||!n)){b=!0;try{ae(ue())}catch(A){if(I){let S=new AggregateError([I,A],"Playback work and schedule invalidation both failed");throw P.delete(I),ie(S,"reconcileFailed"),S}throw ie(A,"reconcileFailed"),A}}},Z=()=>{if(!$||!b||!a||!n||i>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(A){throw ie(A,"reconcileFailed"),B(A),A}try{ae({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(A){throw ie(A,"reconcileFailed"),B(A),A}b=!1},oe=(I=new Map,A=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>A<S.expiresAt).map(([S,R])=>[S,{animation:structuredClone(R.animation),startedAt:R.startedAt,expiresAt:R.expiresAt}])),re=(I=new Map)=>Array.from(I.values()).map(A=>structuredClone(A.animation)),pe=(I=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,A])=>I<A.expiresAt))},te=()=>{if(a&&!(i>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,A=[...n.selectPendingEffects()],S=A.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let R=$?S.filter(N=>!nn.has(N.name)):S;R.length>0&&D(R)}catch(R){throw n.clearPendingEffects(),A.forEach(N=>{n.appendPendingEffect(N)}),ie(R,"postCommitUnsettled"),B(R),R}}}finally{l=!1}Z()}},C=I=>{i+=1;let A=!1;try{let S=I();return A=!0,S}finally{i-=1,A&&te()}},_=({initialState:I,namespace:A})=>{T("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...N}=I,G=R===void 0?void 0:structuredClone(R),H=structuredClone(I.projectData),ne=kd({projectData:H,l10nData:G}),me=N.global??{};if(!Le(me))throw new Error("Malformed global state.");let Re=me.runtime??{};if(!Le(Re))throw new Error("Malformed global.runtime.");let xe=Re.localizationPackageId;if(xe!=null&&typeof xe!="string")throw new Error("localizationPackageId requires a string or null value");let Rr=new Set(ne.map(({l10nId:Xr})=>Xr).filter(Xr=>Xr!==null)),Hr=typeof xe=="string"&&Rr.has(xe)?xe:null,un=Gs({projectData:H,l10nData:G,l10nId:Hr}),Qs=rp({...N,global:{...me,localizationPackages:ne,runtime:{...Re,localizationPackageId:Hr}},projectData:un,initialAudioCommandId:S});q?.(),n=Qs,o+=1,a=!0,t=0,s=dt(A),i=0,l=!1,c=0,u=[],p=null,f=null,d=new Map,m=new Map,y=new Map,g=H,h=G,w=Hr,b=!0,E=!1,v=0,P.clear(),n.appendPendingEffect({name:"handleLineActions"}),te()},F=()=>{T("dispose"),a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,f=null,d=new Map,m=new Map,y=new Map,b=!1,P.clear(),Y?.())},K=()=>s,de=()=>n.selectPresentationState(),Pe=()=>n.selectPresentationChanges(),ge=I=>n.selectSectionLineChanges(I),fe=(I={})=>{U("rendering"),t+=1;let A=Date.now();pe(A);let S=m.size>0,R=oe(d,A),N=S?oe(m,A):new Map,H={...n.selectRenderState({activePersistentAnimations:re(R),restoredPersistentAnimations:re(N)}),id:`render-${r}-${o}-${t}`};return y.set(H.id,{builtAt:A,persistentAnimationSessions:new Map([...N.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S}),H},Or=(I={})=>fe(I),Xe=(I={})=>fe(I),an=I=>{if(!a||!n)return;let A=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=A?y.get(A):null;A&&y.delete(A);let R=new Map;Kl(I?.animations).forEach(N=>{let G=qn(N);if(!G)return;let H=S?.persistentAnimationSessions?.get(G)??d.get(G),ne=Math.max(0,Zl(N)),me=H?.startedAt??S?.builtAt??Date.now();R.set(G,{animation:structuredClone(N),startedAt:me,expiresAt:me+ne})}),d=R,S?.usedRestoredPersistentAnimationSessions&&(m=new Map)},yt=()=>n.selectSystemState(),ln=()=>n.selectAchievements(),Xs=I=>n.selectAchievement(I),ht=()=>n.selectSaveSlotMap(),Rd=I=>n.selectSaveSlot(I),Cd=I=>n.selectSaveSlotPage(I),$d=()=>n.selectImageGallery(),_d=()=>n.selectMusicRoom(),Td=()=>n.selectSceneReplay(),Nd=()=>n.selectIsSceneReplayActive(),yk=()=>n.selectSkipMode(),hk=()=>n.selectAutoMode(),jd=()=>n.selectRuntime(),Dd=()=>n.selectIsChoiceVisible(),Ld=()=>n.selectIsFormVisible(),Md=()=>n.selectActiveInteraction(),Vd=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),da=(I,A,S={})=>!Le(A)||I!=="nextLine"?A:S.bypassChoice===!0?{...A,bypassChoice:!0}:S.interactionSource===la?{...A,_interactionSource:la}:A,fa=(I={})=>({type:ca,payload:da("nextLine",{_conditionalContinuation:!0},I)}),Ws=(I,A)=>on(I)?{type:ca,payload:{...I.payload,...A.payload}}:A,qd=I=>{I.savedCheckpointOccurrences.forEach(A=>{n.markSavedRollbackCheckpointTransient(A)}),I.savedCheckpointOccurrences=[]},Fd=(I,A)=>{let S=p;return p=null,!S||!Gr(S.pointer,I)||S.checkpointIndex!==A?.checkpointIndex||S.checkpointIdentity!==A?.checkpoint?[]:S.savedCheckpointOccurrences},Ud=I=>{let A=f;return!A||!Gr(A.pointer,I)?null:(f=null,A)},Bd=({actionType:I,pointerBeforeAction:A,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:N,wasSceneReplayActive:G,isSceneReplayActive:H})=>{!S||!(!Gr(A,S)||R?.checkpoint!==N?.checkpoint||R?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(f={pointer:S,appendToPrevious:X0.has(I)&&G===H&&A?.sectionId===S.sectionId&&A?.lineId!==S.lineId,reuseExistingOccurrence:W0.has(I),forceNewOccurrence:I==="jumpToLine"})},ma=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),qd(I))},Yd=(I,A,S)=>G0.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==A?.checkpoint:S?.checkpoint!==A?.checkpoint&&S?.checkpointIndex>A?.checkpointIndex:!1,zd=I=>{let A=u.at(-1);if(!A?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&A.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:A.rollbackCursor?.checkpointIndex,sectionId:A.pointer?.sectionId,lineId:A.pointer?.lineId})},Gd=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(A=>{let S=n.selectSaveSlot({slotId:A.slotId});S&&(A.saveSlotIdentity=S)})},Hd=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},Xd=(I,A,S)=>{let R=u.at(-1);if(!R)return;let N=n.selectCurrentPointer()?.pointer,G=Yd(I,A,S);if(Gr(R.pointer,N)){let H=S?.checkpoint!==A?.checkpoint||S?.checkpointIndex!==A?.checkpointIndex;G||H&&H0.has(I)?(ma(R),R.pointer=N,R.rollbackCursor=S,R.markCurrentCheckpointTransient=G,R.savedCheckpointOccurrences=[]):H&&I==="updateProjectData"&&(R.rollbackCursor=S);return}ma(R),R.pointer=N,R.rollbackCursor=n.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=G,R.savedCheckpointOccurrences=[]},gt=(I,A)=>{if(U(`action "${I}"`),!n[I])return;let S=A,R,N;if(I==="updateProjectData")ya(A),R=structuredClone(A.projectData),S={...A,projectData:Gs({projectData:R,l10nData:h,l10nId:w})},ya(S);else if(I==="updateLocalizationPackage"){if(N=Wd(A),N===w)return;S={l10nId:N,projectData:Gs({projectData:g,l10nData:h,l10nId:N})}}z0.has(I)&&(c+=1);let G=n.selectAutoMode(),H=G?n.selectRuntime():null,ne=n.selectIsSceneReplayActive?.()===!0,me=Y0.has(I)?oe(d):null,Re=n.selectCurrentPointer()?.pointer??null,xe=n.selectRollbackCursor?.()??null,Rr=!1,Hr;try{Hr=n[I](S),Rr=!0}catch(bt){throw ie(bt,"preCommit"),bt}R!==void 0&&(g=R),N!==void 0&&(w=N),B0.has(I)&&(m=me??new Map,d=new Map);let un=n.selectIsSceneReplayActive?.()===!0;ne!==un&&(d=new Map,m=new Map);let Qs=n.selectCurrentPointer()?.pointer??null,Xr=n.selectRollbackCursor?.()??null;I==="saveSlot"?zd(A):I==="updateProjectData"&&Gd(),Xd(I,xe,Xr),Bd({actionType:I,pointerBeforeAction:Re,pointerAfterAction:Qs,cursorBeforeAction:xe,cursorAfterAction:Xr,wasSceneReplayActive:ne,isSceneReplayActive:un});let uf=n.selectAutoMode()&&(I==="updateVariable"||G&&tk(H,n.selectRuntime()));(ek.has(I)||uf)&&(b=!0);try{te()}catch(bt){throw Rr&&ie(bt,"postCommitUnsettled"),bt}return Hr},ya=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Dr(I?.projectData?.resources?.variables??{}),xt(I.projectData),Et(I.projectData),St(I.projectData)},Wd=I=>{if(!Le(I))throw new Error("updateLocalizationPackage requires an object payload");let A=Object.keys(I);if(A.length!==1||A[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},Kd=(I,A,S)=>{let R=n.selectCurrentPointer()?.pointer;A!==R||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),gt("nextLineFromSystem",I.payload))},Jd=()=>({renderSequence:t,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:f,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(m),renderPersistentAnimationMetadata:new Map(y),canonicalProjectData:g,localizationPackageId:w,playbackScheduleDirty:b}),Qd=I=>{t=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,f=I.pendingDialogueHistoryLineEntry,d=new Map(I.persistentAnimationSessions),m=new Map(I.restoredPersistentAnimationSessions),y=new Map(I.renderPersistentAnimationMetadata),g=I.canonicalProjectData,w=I.localizationPackageId,b=I.playbackScheduleDirty},ha=(I,A={})=>(U("action batch"),C(()=>{let S=Jd();try{return n[xo](()=>{let R,N=n.selectCurrentPointer()?.pointer??null,G=n.selectRollbackCursor?.()??null,H=c,ne={pointer:N,rollbackCursor:G,markCurrentCheckpointTransient:A.rollbackSource==="line",savedCheckpointOccurrences:A.savedCheckpointOccurrences?.slice()??[]};u.push(ne);try{n.beginRollbackActionBatch({source:A.rollbackSource});try{R=I()}finally{n.endRollbackActionBatch({})}on(R)&&Kd(R,N,H);let me=n.selectCurrentPointer()?.pointer??null;A.rollbackSource==="line"&&Gr(N,me)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:ne.savedCheckpointOccurrences,appendToPrevious:A.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:A.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:A.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!Gr(N,ne.pointer)||G?.checkpoint!==ne.rollbackCursor?.checkpoint)&&ne.markCurrentCheckpointTransient&&ne.savedCheckpointOccurrences.length>0&&(p={pointer:ne.pointer,checkpointIndex:ne.rollbackCursor?.checkpointIndex,checkpointIdentity:ne.rollbackCursor?.checkpoint,savedCheckpointOccurrences:ne.savedCheckpointOccurrences})}})}catch(R){throw Qd(S),R}})),Ks=(I,A,S,R={})=>{if(I===aa||I===sn)return ha(()=>{let N={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===sn)return Ia(A,S,N);let G=Js(S),H=$t({[I]:A},G);return ba(H[I],S,N)},R);gt(I,A)},Zd=(I,A)=>{if(I!=="nextLineFromSystem")return Ks(I,A);v+=1;try{return Ks(I,A)}finally{v=Math.max(0,v-1)}},ga=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Js=I=>{if(ga(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:A,...S}=I,R=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:A,variables:R,runtime:n.selectRuntime?n.selectRuntime():{}}},ef=I=>{if(!Le(I))return{templatePayload:I,literalTargetIds:null};let A=n.selectImageGalleryConfig();if(!Array.isArray(A?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?A.groups.find(N=>N.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let R=typeof I.variantId=="string"&&S.variants.some(N=>N.id===I.variantId);return{templatePayload:{...I,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...R?{variantId:I.variantId}:{}}}},rf=I=>!Le(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},tf=I=>!Le(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},nf=I=>{if(!Le(I))throw new Error("conditional action payload must be an object");if(!Array.isArray(I.branches))throw new Error("conditional action requires branches array");if(I.branches.length===0)throw new Error("conditional action requires at least one branch")},sf=(I,A,S)=>{if(!Le(I))throw new Error(`conditional branch at index ${A} must be an object`);if(!Le(I.actions))throw new Error(`conditional branch at index ${A} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&A!==S-1)throw new Error("conditional else branch must be the last branch")},ba=(I,A,S)=>{nf(I);let R=fa(S);for(let N=0;N<I.branches.length;N+=1){let G=I.branches[N];sf(G,N,I.branches.length);let H=Js(A);if(Object.prototype.hasOwnProperty.call(G,"when")&&!Pt(G.when,H))continue;let me=cn(G.actions,A,{...S,actionPath:[...S.actionPath??[aa],"branches",String(N),"actions"]});return on(me)?Ws(R,me):R}return R},of=I=>{if(!Le(I))throw new Error("random action payload must be an object");let A=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(A!==void 0)throw new Error(`random action.${A} is not supported`);if(!Le(I.distribution))throw new Error("random action requires distribution object");if(I.distribution.type==="weighted"){if(Object.prototype.hasOwnProperty.call(I,"variableId"))throw new Error("weighted random action does not support variableId")}else if(I.distribution.type==="integer"){if(typeof I.variableId!="string"||!I.variableId)throw new Error("integer random action requires variableId");let S=g?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||Se(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},Ia=(I,A,S)=>{of(I),ga(A);let R=gl(I.distribution,{randomSource:k});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let H=(S.actionPath??[sn]).join("."),ne=S.randomOutcomeOrdinals??new Map,me=ne.get(H)??0;ne.set(H,me+1),n.recordRandomOutcome({path:H,ordinal:me,type:R.type,result:R}),Hd()}let N;R.type==="integer"?gt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):N=cn(I.distribution.outcomes[R.outcomeIndex].actions,A,{...S,actionPath:[...S.actionPath??[sn],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let G=fa(S);return on(N)?Ws(G,N):G},af=(I,A)=>({...I??{},_form:A}),lf=(I,A,S,R)=>{let N=gt(I,A),G=N?.submitted===!0&&N.valid===!0,H=N?.cancelled===!0;if(!(!G&&!H)&&Le(A.actions))return cn(A.actions,af(S,N.form),{...R,interactionSource:la})},wa=(I,A,S,R)=>{if(I===sn)return Ia(A,S,R);let N=Js(S),G={templatePayload:A,literalTargetIds:null};I===J0?G=ef(A):I===Q0?G=rf(A):I===Z0&&(G=tf(A));let{templatePayload:H,literalTargetIds:ne}=G,Re=$t({[I]:H},N)[I],xe=ne?{...Re,...ne}:Re;if(I===aa)return ba(xe,S,R);let Rr=da(I,xe,R);if(K0.has(I))return lf(I,Rr,S,R);gt(I,Rr)},cn=(I,A,S)=>{let R,N=S?.executionContext??{depth:0,pendingNavigation:null},G=Nn(I);jn(G),N.depth+=1;try{for(let[H,ne]of G){let me={...S,executionContext:N,actionPath:[...S?.actionPath??[],H]};if($o(H)){let xe=N.pendingNavigation;if(xe)throw new Error(`action batch cannot execute multiple navigation actions: ${xe.actionType}, ${H}`);N.pendingNavigation={actionType:H,payload:ne,eventContext:A,options:me};continue}let Re=wa(H,ne,A,me);on(Re)&&(R=Ws(R,Re))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let H=N.pendingNavigation;N.pendingNavigation=null,wa(H.actionType,H.payload,H.eventContext,H.options)}return R},ka=(I,A,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return ha(()=>cn(I,A,R),R)},cf=I=>{let A=n.selectCurrentPointer()?.pointer;if(I!==A||n.selectActiveInteraction())return;let S=n.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&n.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:_,dispose:F,handleAction:Ks,handleInternalAction:Zd,handleActions:ka,selectRenderState:Or,prepareRenderState:Xe,commitRenderState:an,selectPresentationState:de,selectPresentationChanges:Pe,selectSectionLineChanges:ge,selectSystemState:yt,selectAchievements:ln,selectAchievement:Xs,selectSaveSlotMap:ht,selectSaveSlot:Rd,selectSaveSlotPage:Cd,selectSaveSlots:ht,selectImageGallery:$d,selectMusicRoom:_d,selectSceneReplay:Td,selectIsSceneReplayActive:Nd,selectRuntime:jd,selectIsChoiceVisible:Dd,selectIsFormVisible:Ld,selectActiveInteraction:Md,selectHasPendingRenderWork:Vd,handleLineActions:I=>{U("line action handling");let A=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!Gr(I.pointer,A))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return C(()=>{let S=n.selectCurrentPointer()?.pointer,R=n.selectRollbackCursor?.()??null,N=p,G=f,H=Fd(S,R),ne=Ud(S),me=n.selectCurrentLine(),Re=!1;if(me?.actions){try{ka(me.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:H,dialogueHistoryAppendToPrevious:ne?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ne?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ne?.forceNewOccurrence===!0})}catch(xe){throw p=N,f=G,xe}Re=!0}return cf(S),Re})},getNamespace:K,classifyAutomaticAttemptError:L}}var nk="music-room:player",Sd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),xd=(e,r)=>Sd.has(e)&&r?._event?.id===nk,Od=({engine:e,routeGraphics:r,trackRenderDispatch:n,lifecycleGeneration:o,isCurrentLifecycle:a},t)=>{if(e.selectHasPendingRenderWork?.())return;let s=e.prepareRenderState?.(t)??e.selectRenderState(t);n?.(s),r.render(s),a(o)&&e.commitRenderState?.(s)},sk=({engine:e,routeGraphics:r,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:t},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&Od({engine:e,routeGraphics:r,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:t},s)},ok=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveSlots(r?.saveSlots))},ik=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalDeviceVariables(r?.globalDeviceVariables))},ak=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalAccountVariables(r?.globalAccountVariables))},lk=({enqueuePersistenceWrite:e},r)=>{e(n=>n.saveGlobalRuntime(r?.globalRuntime))},ck=({enqueuePersistenceWrite:e},r)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(r?.updates)})},Ed={render:Od,saveSlots:ok,saveGlobalDeviceVariables:ik,saveGlobalAccountVariables:ak,saveGlobalRuntime:lk,applyScopedDataUpdates:ck,handleLineActions:sk},uk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),pa=(e,r,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(r,n)},pk=(e=[])=>{let r=new Set,n=[];for(let o=e.length-1;o>=0;o-=1){let a=e[o];if(typeof a?.name!="string"||a.name.length===0)throw new Error("Pending effect is missing a valid name.");if(!uk.has(a.name)){n.unshift(a);continue}r.has(a.name)||(r.add(a.name),n.unshift(a))}return n},dk=({getEngine:e,routeGraphics:r,ticker:n,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:t,persistence:s,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,f=!1,d=0,m=0,y=!0,g=Pd({ticker:n,dispatchAutomaticAttempt:()=>pa(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),h=()=>{u=null,p=null,f=!1,d=0},w=()=>{g.reset(),m+=1,h(),y=!0},b=()=>{m+=1,y=!1,h(),g.dispose()},E=C=>y&&C===m,v=C=>{if(a){a(C);return}console.error("RouteEngine persistence write failed.",C)},P=C=>{if(s)return s;let _=dt(C),F=l.get(_);if(F)return F;let K=Zi({indexedDB:t,namespace:_});return l.set(_,K),K},k=C=>{let _=s?null:dt(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=P(_),C(F))).catch(K=>{!s&&l.get(_)===F&&l.delete(_),v(K)})},O=C=>{if(!y)return;let _=typeof C?.id=="string"&&C.id.length>0?C.id:null;d+=1,u=_,f=!1},D=()=>d,$=(C={})=>{if(!y||C?.aborted===!0)return!1;let _=typeof C?.id=="string"&&C.id.length>0?C.id:null;return _?_!==u||_===p?!1:(p=_,!0):u!==null||f?!1:(f=!0,!0)},q=(C,_={})=>{if(!y)return!1;if(xd(C,_)){let K=Sd.get(C),de=e();return pa(de,K,_?._event),!0}if(C!=="renderComplete"||!$(_))return!1;let F=e();return pa(F,"markLineCompleted",{}),!0},Y=new Set(["updateFormField","submitForm","cancelForm"]),T=new Set(["updateVariable"]),U=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,ie=C=>C?._formKey??C?.formKey,L=(C,_)=>ie(C)===_?.formKey,ae=(C,_)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===_?.source,ue=(C,_)=>ae(C,_)?_.source==="form"?L(C,_):!0:!1,B=(C,_)=>!C||typeof C!="object"||Array.isArray(C)||_?.source!=="form"?!1:L(C,_),Z=(C={},_)=>Object.keys(C).length>0&&Object.entries(C).every(([F,K])=>Y.has(F)?B(K,_):T.has(F)),oe=(C={},_)=>{let F=C?.actions;return _?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:Z(F,_):ue(C,_)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(K=>ue(K,_))},re=(C,_={})=>{if(!_?.actions)return!1;let F=U(C);return!F||F.source==="choice"?!1:!oe(_,F)},pe=({preprocessPayload:C,onEvent:_}={})=>async(F,K={})=>{if(!y)return!1;if(xd(F,K))return q(F,K),_?.(F,K);let de=e(),Pe=m,ge=d;if(re(de,K))return _?.(F,K);let fe=await C?.(F,K)??K;if(!E(Pe)||e()!==de||d!==ge)return!1;if(re(de,fe))return _?.(F,fe);if(q(F,fe),fe?.actions){let Or=fe?._event?{_event:fe._event}:fe?.event?{_event:fe.event}:void 0,Xe;fe?.bypassChoice===!0?Xe={bypassChoice:!0}:fe?._interactionSource&&(Xe={interactionSource:fe._interactionSource}),Xe?de.handleActions(fe.actions,Or,Xe):de.handleActions(fe.actions,Or)}return _?.(F,fe)},te=C=>{if(!y)return;let _=m,F=e(),K=pk(C),de=K.some(ge=>ge.name==="handleLineActions");K.forEach(ge=>{if(!Ed[ge.name]&&!nn.has(ge.name)&&!o)throw new Error(`Unhandled pending effect "${ge.name}".`)});let Pe={engine:F,routeGraphics:r,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:D,enqueuePersistenceWrite:k,lifecycleGeneration:m,isCurrentLifecycle:E};for(let ge of K){if(!E(_))break;if(de&&ge.name==="render")continue;if(nn.has(ge.name)){g.handleLegacyEffect(ge);continue}let fe=Ed[ge.name];if(fe){fe(Pe,ge.payload);continue}o(ge,Pe)}};return te.handleRouteGraphicsEvent=q,te.createRouteGraphicsEventHandler=pe,te.reset=w,te.dispose=b,te.reconcilePlaybackScheduleV1=C=>g.reconcilePlaybackScheduleV1(C),te},fk=dk;var mk=(e,r={})=>{let{resources:n={}}=r;return oi(e,n)};var cA=ua;export{Lo as DEFAULT_VISUAL_LAYER,rt as RENDER_LAYER,nr as VISUAL_LAYER,fk as createEffectsHandler,zw as createIndexedDbPersistence,cA as default,So as formatDate,jm as resolveComputedVariables,mk as resolveLayoutReferences};
|
|
1
|
+
var Qd=Object.defineProperty;var Zd=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),em=(e,t)=>{for(var n in t)Qd(e,n,{get:t[n],enumerable:!0})};var Mp=Zd(Ea=>{"use strict";Object.defineProperty(Ea,"__esModule",{value:!0});function Lp(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}Ea.default=Lp;Lp.code='require("ajv/dist/runtime/ucs2length").default'});var rl=Symbol.for("immer-nothing"),Wa=Symbol.for("immer-draftable"),Ce=Symbol.for("immer-state");function Ue(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var rt=Object.getPrototypeOf;function Ae(e){return!!e&&!!e[Ce]}function Nr(e){return e?tl(e)||Array.isArray(e)||!!e[Wa]||!!e.constructor?.[Wa]||xn(e)||Sn(e):!1}var rm=Object.prototype.constructor.toString();function tl(e){if(!e||typeof e!="object")return!1;let t=rt(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)===rm}function Pn(e){return Ae(e)||Ue(15,e),e[Ce].base_}function vn(e,t){En(e)===0?Reflect.ownKeys(e).forEach(n=>{t(n,e[n],e)}):e.forEach((n,o)=>t(o,n,e))}function En(e){let t=e[Ce];return t?t.type_:Array.isArray(e)?1:xn(e)?2:Sn(e)?3:0}function Eo(e,t){return En(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function nl(e,t,n){let o=En(e);o===2?e.set(t,n):o===3?e.add(n):e[t]=n}function tm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function xn(e){return e instanceof Map}function Sn(e){return e instanceof Set}function jr(e){return e.copy_||e.base_}function xo(e,t){if(xn(e))return new Map(e);if(Sn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let n=tl(e);if(t===!0||t==="class_only"&&!n){let o=Object.getOwnPropertyDescriptors(e);delete o[Ce];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(rt(e),o)}else{let o=rt(e);if(o!==null&&n)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function Co(e,t=!1){return On(e)||Ae(e)||!Nr(e)||(En(e)>1&&(e.set=e.add=e.clear=e.delete=nm),Object.freeze(e),t&&Object.entries(e).forEach(([n,o])=>Co(o,!0))),e}function nm(){Ue(2)}function On(e){return Object.isFrozen(e)}var sm={};function Tr(e){let t=sm[e];return t||Ue(0,e),t}var xt;function sl(){return xt}function om(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Ja(e,t){t&&(Tr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function So(e){Oo(e),e.drafts_.forEach(im),e.drafts_=null}function Oo(e){e===xt&&(xt=e.parent_)}function Qa(e){return xt=om(xt,e)}function im(e){let t=e[Ce];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Za(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];return e!==void 0&&e!==n?(n[Ce].modified_&&(So(t),Ue(4)),Nr(e)&&(e=kn(t,e),t.parent_||An(t,e)),t.patches_&&Tr("Patches").generateReplacementPatches_(n[Ce].base_,e,t.patches_,t.inversePatches_)):e=kn(t,n,[]),So(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==rl?e:void 0}function kn(e,t,n){if(On(t))return t;let o=t[Ce];if(!o)return vn(t,(a,r)=>el(e,o,t,a,r,n)),t;if(o.scope_!==e)return t;if(!o.modified_)return An(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),vn(r,(i,l)=>el(e,o,a,i,l,n,s)),An(e,a,!1),n&&e.patches_&&Tr("Patches").generatePatches_(o,n,e.patches_,e.inversePatches_)}return o.copy_}function el(e,t,n,o,a,r,s){if(Ae(a)){let i=r&&t&&t.type_!==3&&!Eo(t.assigned_,o)?r.concat(o):void 0,l=kn(e,a,i);if(nl(n,o,l),Ae(l))e.canAutoFreeze_=!1;else return}else s&&n.add(a);if(Nr(a)&&!On(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;kn(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,o)&&An(e,a)}}function An(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Co(t,n)}function am(e,t){let n=Array.isArray(e),o={type_:n?1:0,scope_:t?t.scope_:sl(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=_o;n&&(a=[o],r=St);let{revoke:s,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=s,i}var _o={get(e,t){if(t===Ce)return e;let n=jr(e);if(!Eo(n,t))return lm(e,n,t);let o=n[t];return e.finalized_||!Nr(o)?o:o===Ao(e.base_,t)?(Po(e),e.copy_[t]=$o(o,e)):o},has(e,t){return t in jr(e)},ownKeys(e){return Reflect.ownKeys(jr(e))},set(e,t,n){let o=ol(jr(e),t);if(o?.set)return o.set.call(e.draft_,n),!0;if(!e.modified_){let a=Ao(jr(e),t),r=a?.[Ce];if(r&&r.base_===n)return e.copy_[t]=n,e.assigned_[t]=!1,!0;if(tm(n,a)&&(n!==void 0||Eo(e.base_,t)))return!0;Po(e),Ro(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 Ao(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Po(e),Ro(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=jr(e),o=Reflect.getOwnPropertyDescriptor(n,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:n[t]}},defineProperty(){Ue(11)},getPrototypeOf(e){return rt(e.base_)},setPrototypeOf(){Ue(12)}},St={};vn(_o,(e,t)=>{St[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});St.deleteProperty=function(e,t){return St.set.call(this,e,t,void 0)};St.set=function(e,t,n){return _o.set.call(this,e[0],t,n,e[0])};function Ao(e,t){let n=e[Ce];return(n?jr(n):e)[t]}function lm(e,t,n){let o=ol(t,n);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function ol(e,t){if(!(t in e))return;let n=rt(e);for(;n;){let o=Object.getOwnPropertyDescriptor(n,t);if(o)return o;n=rt(n)}}function Ro(e){e.modified_||(e.modified_=!0,e.parent_&&Ro(e.parent_))}function Po(e){e.copy_||(e.copy_=xo(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var cm=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"&&Ue(6),o!==void 0&&typeof o!="function"&&Ue(7);let a;if(Nr(t)){let r=Qa(this),s=$o(t,void 0),i=!0;try{a=n(s),i=!1}finally{i?So(r):Oo(r)}return Ja(r,o),Za(a,r)}else if(!t||typeof t!="object"){if(a=n(t),a===void 0&&(a=t),a===rl&&(a=void 0),this.autoFreeze_&&Co(a,!0),o){let r=[],s=[];Tr("Patches").generateReplacementPatches_(t,a,r,s),o(r,s)}return a}else Ue(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){Nr(e)||Ue(8),Ae(e)&&(e=gr(e));let t=Qa(this),n=$o(e,void 0);return n[Ce].isManual_=!0,Oo(t),n}finishDraft(e,t){let n=e&&e[Ce];(!n||!n.isManual_)&&Ue(9);let{scope_:o}=n;return Ja(o,t),Za(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=Tr("Patches").applyPatches_;return Ae(e)?o(e,t):this.produce(e,a=>o(a,t))}};function $o(e,t){let n=xn(e)?Tr("MapSet").proxyMap_(e,t):Sn(e)?Tr("MapSet").proxySet_(e,t):am(e,t);return(t?t.scope_:sl()).drafts_.push(n),n}function gr(e){return Ae(e)||Ue(10,e),il(e)}function il(e){if(!Nr(e)||On(e))return e;let t=e[Ce],n;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=xo(e,t.scope_.immer_.useStrictShallowCopy_)}else n=xo(e,!0);return vn(n,(o,a)=>{nl(n,o,il(a))}),t&&(t.finalized_=!1),n}var De=new cm,Rn=De.produce,yk=De.produceWithPatches.bind(De),hk=De.setAutoFreeze.bind(De),gk=De.setUseStrictShallowCopy.bind(De),bk=De.applyPatches.bind(De),wk=De.createDraft.bind(De),Ik=De.finishDraft.bind(De);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},Z={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},tt={NOT:0};var D=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},$e=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var jo=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}')`)},al=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 ll=(e,t,n=!1)=>{if(t===null)return new $e(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new $e(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return n?new $e(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new $e(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},cl=(e,t)=>{let n=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new $e(`Unknown function '${e}' (${n})`)};var um=(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 ve(e.var,n,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ve(e.path,n,o);if(e.type===x.INTERPOLATION)return fm(e.parts,t,n,o);switch(e.type){case x.FUNCTION:return pl(e,t,n,o);case x.BINARY:return fl(e,t,n,o);case x.UNARY:return dl(e,t,n,o);case x.CONDITIONAL:return mm(e,t,n,o);case x.LOOP:return wm(e,t,n,o);case x.OBJECT:return vm(e,t,n,o);case x.ARRAY:return km(e,t,n,o);case x.PARTIAL:return Am(e,t,n,o);case x.PATH_REFERENCE:return Pm(e,t,n,o);default:throw new Error(`Unknown node type: ${e.type}`)}},ul=new Map,pm=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},ve=(e,t,n)=>{if(!e)return;if(e in n)return n[e];let o=ul.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=pm(l.trim());o.push(...c)}ul.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},fm=(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("")},pl=(e,t,n,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw cl(e.name,a);let s=e.args.map(i=>ne(i,t,n,o));return r(...s)},br=(e,t,n,o)=>{if(e.var&&!e.type)return ve(e.var,n,o);switch(e.type){case x.VARIABLE:return ve(e.path,n,o);case x.LITERAL:return e.value;case x.BINARY:return fl(e,t,n,o);case x.UNARY:return dl(e,t,n,o);case x.FUNCTION:return pl(e,t,n,o);default:return ne(e,t,n,o)}},fl=(e,t,n,o)=>{if(e.op===Z.AND||e.op===Z.OR){let s=br(e.left,t,n,o),i=br(e.right,t,n,o);switch(e.op){case Z.AND:return s&&i;case Z.OR:return s||i}}let a=ne(e.left,t,n,o),r=ne(e.right,t,n,o);switch(e.op){case Z.EQ:return a==r;case Z.NEQ:return a!=r;case Z.GT:return a>r;case Z.LT:return a<r;case Z.GTE:return a>=r;case Z.LTE:return a<=r;case Z.IN:return Array.isArray(r)?r.includes(a):!1;case Z.ADD:if(typeof a!="number"||typeof r!="number")throw new $e(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case Z.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new $e(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},dl=(e,t,n,o)=>{let a=e.op===tt.NOT?br(e.operand,t,n,o):ne(e.operand,t,n,o);if(e.op===tt.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},dm=(e,t,n,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ve(a.path,n,o)){let s=e.bodies[0];if(s.type===x.OBJECT&&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]=ve(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let f of u.parts)if(typeof f=="string")p.push(f);else if(f.type===x.VARIABLE){let d=ve(f.path,n,o);p.push(d!=null?String(d):"")}else{let d=ne(f,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.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]=ve(u.path,n,o);else if(u.type===x.INTERPOLATION){let p=[];for(let f of u.parts)if(typeof f=="string")p.push(f);else if(f.type===x.VARIABLE){let d=ve(f.path,n,o);p.push(d!=null?String(d):"")}else{let d=ne(f,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},mm=(e,t,n,o)=>{let a=dm(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||br(s,t,n,o))return ne(e.bodies[r],t,n,o)}return ml},ym=(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 f=p.key,d=p.value;if(d.type===x.LITERAL)u[f]=d.value;else if(d.type===x.VARIABLE){let m=d.path;if(m===o)u[f]=c;else if(m.startsWith(o+".")){let b=m.substring(o.length+1);u[f]=c[b]}else return null}else if(d.type===x.INTERPOLATION){let m=[],b=!0;for(let h of d.parts)if(typeof h=="string")m.push(h);else if(h.type===x.VARIABLE){let y=h.path;if(y===o)m.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),g=c[w];m.push(g!=null?String(g):"")}else{b=!1;break}}else{b=!1;break}if(!b)return null;u[f]=m.join("")}else return null}i.push(u)}}return i}}}return null},hm=(e,t)=>{let n=e.body,o=e.itemVar,a=ym(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 f=p.substring(o.length+1);if(!f.includes(".")&&!f.includes("["))r.push({key:l,type:"prop_string",prop:f});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 f=c[p.prop];u[p.key]=f!=null?String(f):""}i[l]=u}return i}}return null},gm=(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={},f={...o,[i]:u,...l&&{[l]:c}};f.__paths__||(f.__paths__=o.__paths__||{});let d=e.iterable.path||"";if(o&&o.__paths__&&d){let m=d.split("."),b=m[0];b in o.__paths__&&(d=o.__paths__[b],m.length>1&&(d+="."+m.slice(1).join(".")))}f.__paths__={...f.__paths__,[i]:`${d}[${c}]`,...l&&{[l]:c}};for(let m of s.properties){let b=m.parsedKey?ne(m.parsedKey,t,n,f):m.key,h=m.value;if(h.type===x.LITERAL)p[b]=h.value;else if(h.type===x.VARIABLE){let y=h.path;if(y===i)p[b]=u;else if(y===l)p[b]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[b]=u[w]:p[b]=ve(y,n,{...o,[i]:u,...l&&{[l]:c}})}else p[b]=ve(y,n,{...o,[i]:u,...l&&{[l]:c}})}else if(h.type===x.INTERPOLATION){let y=[];for(let w of h.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=w.path,E;if(g===i)E=u;else if(g===l)E=c;else if(g.startsWith(i+".")){let k=g.substring(i.length+1);!k.includes(".")&&!k.includes("[")?E=u[k]:E=ve(g,n,{...o,[i]:u,...l&&{[l]:c}})}else E=ve(g,n,{...o,[i]:u,...l&&{[l]:c}});y.push(E!=null?String(E):"")}else{let g={...o,[i]:u,...l&&{[l]:c}},E=ne(w,t,n,g);y.push(E!=null?String(E):"")}p[b]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[b]=ne(h,t,n,y)}}r.push(p)}return r}return null},bm=(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 f={id:p.id};p.highlighted?(f.highlight=!0,f.message=`This item is highlighted: ${p.name}`):(f.highlight=!1,f.message=p.name),c.push(f)}}return c}}}}return null},wm=(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 f=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}(${f})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw ll(p,a,u)}if(!e.indexVar){let c=bm(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=hm(e,a);if(c!==null)return c}let r=gm(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 f=p[0];s.push(f===void 0?{}:f)}else s.push(p===void 0?{}:p)}return s},Im=(e,t,n,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?ne(a.parsedKey,t,n,o):a.key,s=a.value;if(s.type===x.OBJECT&&s.properties.length<=10&&!s.whenCondition){let i={},l={},c=!0;for(let u of s.properties){let p=u.parsedKey?ne(u.parsedKey,t,n,o):u.key,f=u.value;if(f.type===x.LITERAL)l[p]=f.value;else if(f.type===x.VARIABLE)l[p]=ve(f.path,n,o);else if(f.type===x.INTERPOLATION){let d=[];for(let m of f.parts)if(typeof m=="string")d.push(m);else if(m.type===x.VARIABLE){let b=ve(m.path,n,o);d.push(b!=null?String(b):"")}else{c=!1;break}if(!c)break;l[p]=d.join("")}else if(f.type===x.OBJECT&&f.properties.length<=5){let d={};for(let m of f.properties){let b=m.key,h=m.value;if(h.type===x.LITERAL)d[b]=h.value;else if(h.type===x.VARIABLE)d[b]=ve(h.path,n,o);else if(h.type===x.INTERPOLATION){let y=[];for(let w of h.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let g=ve(w.path,n,o);y.push(g!=null?String(g):"")}else{c=!1;break}if(!c)break;d[b]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=d}else{c=!1;break}}if(c)return i[r]=l,i}}return null},vm=(e,t,n,o)=>{let a=t.functions||t;if(e.whenCondition&&!br(e.whenCondition,a,n,o))return;let r=Im(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,f=u.value;if(f.type===x.LITERAL)c[p]=f.value;else if(f.type===x.VARIABLE)c[p]=ve(f.path,n,o);else if(f.type===x.INTERPOLATION){let d=[];for(let m of f.parts)if(typeof m=="string")d.push(m);else if(m.type===x.VARIABLE){let b=ve(m.path,n,o);d.push(b!=null?String(b):"")}else{let b=ne(m,t,n,o);d.push(b!=null?String(b):"")}c[p]=d.join("")}else c[p]=ne(f,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.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(f=>f.key.startsWith("$for "));if(p){let f=ne(p.value,t,n,o);f!==void 0&&(s[c.key]=f)}else{let f=ne(c.value,t,n,o);f!==void 0&&(s[c.key]=f)}}else{let p=c.parsedKey?ne(c.parsedKey,t,n,o):c.key,f=ne(c.value,t,n,o);f!==void 0&&(s[p]=f)}}return s},ml={},km=(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!==ml&&s!==void 0&&a.push(s)}return a},Am=(e,t,n,o)=>{let{name:a,data:r,whenCondition:s}=e,i=t.partials||{},l=t.functions||t;if(s&&!br(s,l,n,o))return;if(!i[a])throw new $e(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new $e(`Circular partial reference detected: ${a}`);let u=i[a],p=n,f={...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,f)},Pm=(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 $e(`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 $e(`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 $e(`Path reference '#{${a}}' - cannot access properties on index variable '${s}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var No=um;var Em=/\$\{([^}]*)\}/g,xm=/#\{([^}]*)\}/g,hl=(e,t={})=>{let n=e.match(/^(\w+)\((.*)\)$/);if(!n)return{isFunction:!1};let[,o,a]=n,r=Sm(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},Sm=(e,t={})=>e.trim()?Om(e).map(o=>Rm(o.trim(),t)):[],Om=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},Rm=(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=hl(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=Dr(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 Pe(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},gl=/^\w+\(.*\)$/,$m=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,Cm=e=>{if(!(!e||e.trim()===""||gl.test(e))&&$m.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}"`)},yl=e=>{let t=e.trim();if(gl.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}},Ot=(e,t={})=>{let n=e.trim();Cm(n);let o=hl(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}},To=(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(Em)],r=[...n.matchAll(xm)],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"?Ot(c[1],t):yl(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,f]=c,d=c.index;if(d>l){let m=n.substring(l,d);for(let b=0;b<o.length;b++)m=m.replace(`__ESCAPED_${b}__`,o[b]);m&&i.push(m)}try{let m;u==="variable"?m=Ot(f.trim(),t):m=yl(f.trim()),i.push(m)}catch(m){if(m.message==="Invalid array index syntax")i.push(p);else throw m}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 Mo=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Il=e=>Object.keys(e),Oe=e=>e.join("."),wr=(e,t,n)=>{let o=Il(e).filter(a=>!t.has(a));if(o.length>0)throw new D(`Unexpected key '${o[0]}' in condition JSON at '${Oe(n)}'`)},Ir=(e,t)=>typeof e=="string"?To(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?jm(e,t):Nm(e,t):{type:x.LITERAL,value:e},_m=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}},jm=(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=_m(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=wl(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=wl(i[0],r[i[0]],t);n.push(l),o=!0;continue}}let s=Ir(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}},Nm=(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,...f}=e,d={},m=!1;for(let[y,w]of Object.entries(f)){let g=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(g=y.slice(1)),d[g]=w,m=!0}let b=null;if(m&&(b=Ir(d,t),b.type===x.OBJECT)){let y=!1;for(let w of b.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&&(b.fast=!1)}let h={type:x.PARTIAL,name:u,data:b};return p!==void 0&&(h.whenCondition=bl(p,t)),h}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=bl(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=Tm(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=Ir(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=To(l,t),f={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(f.parsedKey=p),n.push(f),s++}}}let i={type:x.OBJECT,properties:n,fast:!o};return a&&(i.whenCondition=a),i},Tm=(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());jo(c);let u=Pe(c,n);for(o.push(u),a.push(Ir(i,n)),r++;r<e.length;){let[p,f]=e[r],d=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),d=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(d=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),d=!0):(p==="$else"||p==="$else:")&&(d=!0,m=null),d){if(m===null)o.push(null);else{jo(m);let b=Pe(m,n);o.push(b)}if(a.push(Ir(f,n)),r++,m===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Do={eq:Z.EQ,neq:Z.NEQ,gt:Z.GT,gte:Z.GTE,lt:Z.LT,lte:Z.LTE,in:Z.IN,add:Z.ADD,sub:Z.SUBTRACT},Lo={all:Z.AND,any:Z.OR},Dm=new Set(["var","literal","call","not",...Object.keys(Do),...Object.keys(Lo)]),Lm=(e,t,n)=>{if(!Array.isArray(e))throw new D(`Condition JSON operator '${t}' at '${Oe(n)}' requires an array`);if(e.length!==2)throw new D(`Condition JSON operator '${t}' at '${Oe(n)}' requires exactly 2 operands`);return e},Mm=(e,t,n,o,a)=>{if(!Array.isArray(e))throw new D(`Condition JSON operator '${t}' at '${Oe(a)}' requires an array`);if(e.length===0)throw new D(`Condition JSON operator '${t}' at '${Oe(a)}' requires at least 1 condition`);return e.map((s,i)=>_e(s,o,[...a,i])).reduce((s,i)=>({type:x.BINARY,op:n,left:s,right:i}))},qm=(e,t,n)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],wr(e,new Set(["call","args"]),n);else if(Mo(e.call))o=e.call.name,a=e.call.args??[],wr(e,new Set(["call"]),n),wr(e.call,new Set(["name","args"]),[...n,"call"]);else throw new D(`Condition JSON call at '${Oe(n)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new D(`Condition JSON call at '${Oe(n)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new D(`Invalid condition JSON function name '${o}' at '${Oe(n)}'`);if(!Array.isArray(a))throw new D(`Condition JSON call '${o}' at '${Oe(n)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,s)=>_e(r,t,[...n,"args",s]))}},_e=(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 '${Oe(n)}' must be wrapped in an operator or { literal: [...] }`);if(!Mo(e))throw new D(`Invalid condition JSON value at '${Oe(n)}'`);let o=Il(e);if(o.length===0)throw new D(`Condition JSON object at '${Oe(n)}' must contain an operator`);let a=o.filter(s=>Dm.has(s));if(a.length===0)throw new D(`Unknown condition JSON operator '${o[0]}' at '${Oe(n)}'`);if(a.length>1)throw new D(`Condition JSON at '${Oe(n)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(wr(e,new Set(["var"]),n),typeof e.var!="string"||e.var.trim()==="")throw new D(`Condition JSON var at '${Oe(n)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return wr(e,new Set(["literal"]),n),{type:x.LITERAL,value:e.literal};if(r==="call")return qm(e,t,n);if(r==="not")return wr(e,new Set(["not"]),n),{type:x.UNARY,op:tt.NOT,operand:_e(e.not,t,[...n,"not"])};if(r in Lo)return wr(e,new Set([r]),n),Mm(e[r],r,Lo[r],t,[...n,r]);if(r in Do){wr(e,new Set([r]),n);let s=Lm(e[r],r,[...n,r]);return{type:x.BINARY,op:Do[r],left:_e(s[0],t,[...n,r,0]),right:_e(s[1],t,[...n,r,1])}}throw new D(`Unknown condition JSON operator '${r}' at '${Oe(n)}'`)},bl=(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 Pe(e,t)}return Mo(e)||Array.isArray(e)?_e(e,t):{type:x.LITERAL,value:e}},Pe=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let f=0;f<c.length;f++)if(c[f]==="("?u++:c[f]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Pe(c,t)}let n=Dr(e,"||");if(n!==-1)return{type:x.BINARY,op:Z.OR,left:Pe(e.substring(0,n).trim(),t),right:Pe(e.substring(n+2).trim(),t)};let o=Dr(e,"&&");if(o!==-1)return{type:x.BINARY,op:Z.AND,left:Pe(e.substring(0,o).trim(),t),right:Pe(e.substring(o+2).trim(),t)};let a=[{op:">=",type:Z.GTE},{op:"<=",type:Z.LTE},{op:"==",type:Z.EQ},{op:"!=",type:Z.NEQ},{op:">",type:Z.GT},{op:"<",type:Z.LT},{op:" in ",type:Z.IN}];for(let{op:c,type:u}of a){let p=Dr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Pe(e.substring(0,p).trim(),t),right:Pe(e.substring(p+c.length).trim(),t)}}let r=-1,s=null,i=[{op:" + ",type:Z.ADD},{op:" - ",type:Z.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let f=Dr(e.substring(p),c);if(f===-1)break;let d=p+f;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:Pe(e.substring(0,r).trim(),t),right:Pe(e.substring(r+s.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Dr(e,c)!==-1)throw new D(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:tt.NOT,operand:Pe(e.substring(1).trim(),t)}:vl(e,t)},Dr=(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},Vm=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}},vl=(e,t)=>{let n=e.trim();if(n.match(/^(\w+)\((.*)\)$/))return Ot(n,t);let a=Vm(n);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(n))return{type:x.VARIABLE,path:n};try{return Ot(n,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Fm=(e,t=!1)=>{let n=t?"$each":"$for";try{al(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}},wl=(e,t,n,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let h=o?"$each":"$for";throw new D(`Invalid loop syntax (got: '${e.replace("$for",h)}')`)}let s=r[1],i=r[2].trim();Fm(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let h=o?"$each":"$for";throw new D(`Invalid loop syntax - missing 'in' keyword (got: '${h} ${i}')`)}let c=l[1].trim(),u=l[2].trim(),p,f=null;if(c.includes(",")){let h=c.split(",").map(y=>y.trim());if(h.length!==2)throw new D(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=h[0],f=h[1]}else p=c;let d=["this","undefined","null","true","false"];if(d.includes(p))throw new D(`Reserved variable name: ${p}`);if(f&&d.includes(f))throw new D(`Reserved variable name: ${f}`);let m=vl(u,n),b=Ir(t,n);return{type:x.LOOP,itemVar:p,indexVar:f,iterable:m,body:b,flatten:s!=="nested"}};var Um=(e,t={})=>{let{functions:n={}}=t;return Ir(e,n)},$n=Um;var Rt={};em(Rt,{now:()=>Bm});var Bm=()=>Date.now();var Ym=(e,t,n={})=>{let{functions:o={},partials:a={}}=n,r={...Rt,...o},s=$n(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=$n(c,{functions:r});return No(s,t,{functions:r,partials:i})},Lr=Ym;var zm=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Xm=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Gm=(e,t)=>{if(zm(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new D("Empty condition expression");return Pe(e,t)}return _e(e,t)},Hm=(e,t={},n={})=>{let o=Xm(n),a={...Rt,...o},r=Gm(e,a);return!!br(r,{functions:a,partials:{}},t,{})},qo=Hm;var Ho=Symbol("runStoreTransaction"),Bo="__routeEngineConditionComparison",Cn=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",vr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Cn(e,t)&&e>t,gte:(e,t)=>Cn(e,t)&&e>=t,lt:(e,t)=>Cn(e,t)&&e<t,lte:(e,t)=>Cn(e,t)&&e<=t}),Rl=Object.freeze(Object.fromEntries(Object.keys(vr).map(e=>[e,`${Bo}${e}`]))),Km=Object.freeze(Object.fromEntries(Object.entries(Rl).map(([e,t])=>[t,vr[e]]))),kl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Wm=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},_n=e=>{if(Array.isArray(e))return e.map(_n);if(e===null||typeof e!="object"||kl(e,"literal")||kl(e,"var"))return e;if(Wm(e)?.startsWith(Bo))throw new Error(`Condition function names beginning with "${Bo}" are reserved`);let n=Object.entries(e);if(n.length===1){let[[o,a]]=n,r=Rl[o];if(r)return{call:r,args:a.map(_n)}}return Object.fromEntries(n.map(([o,a])=>[o,_n(a)]))},Ct=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return _e(e),qo(_n(e),t,{functions:Km})},Jm=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],$l=(e,t,n={})=>{let o={},a={},{transformSelectorFirstArgument:r=b=>b,transformActionFirstArgument:s=b=>b,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=n,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},f=0,d=(b,h)=>!u||!c?b:Rn(b,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:h.state,previousTransactionalMetadata:h.transactionalMetadata})});for(let[b,h]of Object.entries(t))b!=="createInitialState"&&(b.startsWith("select")?o[b]=(...y)=>h(r(p.state,p.transactionalMetadata),...y):a[b]=(...y)=>{let w,g=p,E=Rn(p,k=>{let P=h(s(k.state,k.transactionalMetadata),...y);w=P!==void 0&&!Ae(P)?P:void 0,u&&l&&l({actionName:b,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:g.state,previousTransactionalMetadata:g.transactionalMetadata})});return f===0&&(E=d(E,g)),p=E,w});let m=b=>{if(typeof b!="function")throw new Error("Store transaction requires a callback");let h=p,y=f===0;f+=1;let w;try{w=b()}catch(g){throw f-=1,p=h,g}if(f-=1,y)try{p=d(p,h)}catch(g){throw p=h,g}return w};return{...o,...a,[Ho]:m}},Dn=(e,t)=>n=>{let o=e(),a=Array.isArray(n)?n:[n];return Rn(o,r=>{a.forEach(s=>{t.forEach(i=>{i(r,s)})})})};var Qm=(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{}}},J=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),Yo=(e,t,n)=>{Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0})},ke=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Zm=new Set(["pageSize","groups"]),ey=new Set(["id","variants"]),ry=new Set(["id","imageId"]),ty=new Set(["pageSize","tracks"]),ny=new Set(["id","soundId","title","artist","album","description","coverImageId"]),sy=new Set(["pageSize","replays"]),oy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Mr=(e,t,n)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)})},nt=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},_t=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!ke(t))throw new Error("resources.imageGallery must be an object");if(Mr(t,Zm,"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(!ke(a))throw new Error(`${r} must be an object`);if(Mr(a,ey,r),nt(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(!ke(l))throw new Error(`${c} must be an object`);if(Mr(l,ry,c),nt(l.id,`${c}.id`),nt(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),!J(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},jt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!ke(t))throw new Error("resources.musicRoom must be an object");if(Mr(t,ty,"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(!ke(a))throw new Error(`${r} must be an object`);Mr(a,ny,r);for(let l of["id","soundId","title"])nt(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&&nt(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(!J(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!ke(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&&!J(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},iy=(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}"`)}},Nt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!ke(t))throw new Error("resources.sceneReplay must be an object");if(Mr(t,sy,"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(!ke(r))throw new Error(`${s} must be an object`);Mr(r,oy,s);for(let u of["sceneId","title","thumbnailImageId"])nt(r[u],`${s}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!J(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(!ke(r.initialVariables))throw new Error(`${s}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let f=e?.resources?.variables?.[u];if(!f)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(Re(f))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(f.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(f.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);iy(u,f,p)}}}},Cl=e=>{let t=Ae(e)?gr(e):e;return structuredClone(t)},ay=({characterId:e,resourceCharacter:t,variables:n={}}={})=>{if(!J(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},Ln=({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=ay({characterId:e,resourceCharacter:r,variables:a});return s!==void 0?s:r?.name||""},Re=e=>J(e,"computed"),Ko=(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}},Tt=(e={},t={},{allowedScopes:n,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let s=t[a];return s===void 0?o:!Re(s)&&(!n||n.includes(s.scope))&&Ko(s,r)})),Ye=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),ly=(e,t,n)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Ye(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 Ye(t,n);a+=s;continue}if(r+=1,r>=e.length-1)throw Ye(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 Ye(t,n);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
+
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!J(l,i))throw Ye(t,n);a+=l[i]}return a},_l=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Ye(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 Ye(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 Ye(e,t);o+=1,n.push(p);return}if(s!=='"'&&s!=="'")throw Ye(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 Ye(e,t);o+=1,n.push(ly(p,e,t));return}o+=1}if(c||o>=e.length)throw Ye(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Ye(e,t)}return n},Vo=(e,t)=>{let n=e;for(let o of t){if(n==null||!J(n,o))return;n=n[o]}return n},jl=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let n=_l(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 Vo(s,r)}return o==="runtime"?Vo(t.runtime,n.slice(1)):Vo(t,n)},Nl=(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)`)},zo=(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`)},cy=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Ge=(e,t,n,o)=>(Nl(e,t,o),t.map(a=>Tn(a,n))),Be=(e,t,n,o)=>{let a=Ge(e,t,n,o);return a.forEach(r=>cy(e,r)),a},uy=(e,t,n)=>{switch(e){case"var":return jl(t,n);case"add":{let[o,a]=Be(e,t,n,2);return o+a}case"sub":{let[o,a]=Be(e,t,n,2);return o-a}case"mul":{let[o,a]=Be(e,t,n,2);return o*a}case"div":{let[o,a]=Be(e,t,n,2);return o/a}case"mod":{let[o,a]=Be(e,t,n,2);return o%a}case"neg":{let[o]=Be(e,t,n,1);return-o}case"round":{let[o]=Be(e,t,n,1);return Math.round(o)}case"floor":{let[o]=Be(e,t,n,1);return Math.floor(o)}case"ceil":{let[o]=Be(e,t,n,1);return Math.ceil(o)}case"min":{let[o,a]=Be(e,t,n,2);return Math.min(o,a)}case"max":{let[o,a]=Be(e,t,n,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=Be(e,t,n,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=Ge(e,t,n,2);return vr.eq(o,a)}case"neq":{let[o,a]=Ge(e,t,n,2);return vr.neq(o,a)}case"gt":{let[o,a]=Ge(e,t,n,2);return vr.gt(o,a)}case"gte":{let[o,a]=Ge(e,t,n,2);return vr.gte(o,a)}case"lt":{let[o,a]=Ge(e,t,n,2);return vr.lt(o,a)}case"lte":{let[o,a]=Ge(e,t,n,2);return vr.lte(o,a)}case"in":{let[o,a]=Ge(e,t,n,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return zo(e,t),t.every(o=>!!Tn(o,n));case"or":case"any":return zo(e,t),t.some(o=>!!Tn(o,n));case"not":{let[o]=Ge(e,t,n,1);return!o}case"length":{let[o]=Ge(e,t,n,1);return typeof o=="string"||Array.isArray(o)?o.length:ke(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Ge(e,t,n,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return Cl(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Tn=(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 uy(o,a,t)},Xo=(e,t)=>{if(e===null||typeof e!="object"||J(e,"literal"))return e;if(J(e,"var"))return{literal:jl(e.var,t)};if(J(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=>Xo(a,t)):Xo(o,t)]))},py=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return _e(e),Ct(Xo(e,t))},Tl=(e,t)=>{if(!ke(e))throw new Error(`${t} must be an object`);let n=J(e,"expr"),o=J(e,"value");if(n===o)throw new Error(`${t} must contain exactly one of expr or value`)},Fo=(e,t,n)=>(Tl(e,t),J(e,"value")?Cl(e.value):Tn(e.expr,n)),fy=(e,t={},n="unknown")=>{if(!ke(e))throw new Error(`Computed variable "${n}" computed must be an object`);let o=J(e,"expr"),a=J(e,"value");if(J(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(!ke(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(!ke(i))throw new Error(`Computed variable "${n}" branch ${s} must be an object`);if(!J(i,"when"))throw new Error(`Computed variable "${n}" branch ${s} requires when`);if(py(i.when,t))return Fo(i,`Computed variable "${n}" branch ${s}`,t)}return Fo(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 Fo(e,`Computed variable "${n}"`,t)},Dl=(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}`)}},dy=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}),my=new Set(["and","or","all","any"]),yy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),hy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),gy=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),by=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),Ll=new WeakMap,Al=e=>e===null?"null":Array.isArray(e)?"object":typeof e,jn=(e,t,n)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${n} contains unsupported property "${o}"`)},wy=(e,t,n,o)=>{if(n!==void 0&&n!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${n}`)},Ml=(e,{variableId:t,variableConfigs:n,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[s,i,...l]=_l(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(!J(n,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=n[i];return Re(c)&&o.add(i),l.length===0?c?.type:void 0},ql=(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 Al(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 Ml(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 Al(i)}let l=dy[s];if(l===void 0&&!my.has(s))throw new Error(`Unknown computed expression operator: ${s}`);l===void 0?zo(s,i):Nl(s,i,l);let c=i.map((u,p)=>ql(u,{variableId:t,variableConfigs:n,dependencies:o,path:`${a}.${s}[${p}]`}));if(hy.has(s)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${s}" requires numeric operands`)}),yy.has(s))return"number";if(gy.has(s))return"boolean"},Iy=(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{_e(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"||J(s,"literal"))return;if(J(s,"var")){Ml(s.var,{variableId:t,variableConfigs:n,dependencies:o,path:i});return}if(J(s,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(J(s,"not")){r(s.not,`${i}.not`);return}let l=Object.keys(s).find(c=>by.has(c));s[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},Uo=(e,{variableId:t,variableConfig:n,variableConfigs:o,dependencies:a,path:r,allowedKeys:s=new Set(["expr","value"])})=>{if(Tl(e,`Computed variable "${t}" ${r}`),jn(e,s,r),J(e,"value")){Dl(t,n.type,e.value);return}let i=ql(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});wy(t,n.type,i,`${r}.expr`)},vy=(e,t,n)=>{let o=t.computed;if(!ke(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=J(o,"expr"),s=J(o,"value");if(J(o,"branches")){if(jn(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(!ke(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!ke(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(jn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!J(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);Iy(l.when,{variableId:e,variableConfigs:n,dependencies:a,path:`computed.branches[${c}].when`}),Uo(l,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),Uo(o.default,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed.default"}),a}if(jn(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 Uo(o,{variableId:e,variableConfig:t,variableConfigs:n,dependencies:a,path:"computed"}),a},qr=(e={})=>{if(!ke(e))throw new Error("Variable configs must be an object");if(J(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(J(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,s])=>{if(Re(s)){if(!ke(s))throw new Error(`Computed variable "${r}" must be an object`);if(!J(s,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!J(s,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(J(s,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Dt(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,vy(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 f=[...i.slice(p).map(({variableId:d})=>d),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${f}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return Ll.set(e,a),a},st=({variables:e={},runtime:t={},variableConfigs:n={},eager:o=!0}={})=>{let{evaluationOrder:a}=Ll.get(n)??qr(n),r=Tt(e,n,{preserveUnknown:!0}),s=Object.entries(n).filter(([,h])=>Re(h)).map(([h])=>h),i=Object.create(null),l=[],c=new Map(a.map((h,y)=>[h,y])),u=-1,p=!1,f=h=>{if(J(i,h))return i[h];let y=n[h];if(!Re(y))return J(r,h)?r[h]:void 0;let w=l.indexOf(h);if(w>=0){let g=[...l.slice(w),h].join(" -> ");throw new Error(`Computed variable cycle detected: ${g}`)}l.push(h);try{let g=fy(y.computed,b,h);return Dl(h,y.type,g),Yo(i,h,g),g}finally{l.pop()}},d=h=>{if(J(i,h))return i[h];let y=n[h];if(!Re(y))return J(r,h)?r[h]:void 0;let w=c.get(h);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let g=u+1;g<=w;g+=1)f(a[g]),u=g}finally{p=!1}return i[h]}return f(h)},m=new Proxy({},{get:(h,y)=>{if(typeof y=="string")return d(y)},has:(h,y)=>typeof y=="string"&&(J(r,y)||s.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...s])],getOwnPropertyDescriptor:(h,y)=>{if(!(typeof y!="string"||!J(r,y)&&!s.includes(y)))return{enumerable:!0,configurable:!0}}}),b={variables:m,runtime:t,resolveVariable:d};return o?(s.forEach(h=>{d(h)}),{...r,...i}):m},ky=({variables:e={},runtime:t={},variableConfigs:n,projectData:o}={})=>{let a=n??o?.resources?.variables??{};return qr(a),st({variables:e,runtime:t,variableConfigs:a,eager:!0})},Mn=e=>{let t={},n={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(Re(a))return;let r=Qm(a,o);a.scope==="context"?Yo(t,o,r):Yo(n,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:n}},Dt=(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(", ")}`)},Lt=(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(", ")}`)},Ay=2,Pl=12,Vl=(e=Ay)=>{if(!Number.isInteger(e)||e<0||e>Pl)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Pl}.`);return e},Py=(e,t)=>{let n=10**t;return Math.round((e+Number.EPSILON)*n)/n},Nn=e=>typeof e=="number"&&Number.isFinite(e),qn=(e,t,n,o,a={})=>{if(e==="number"){if(t==="set"&&!Nn(n))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!Nn(n))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!Nn(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}".`);Vl(a.roundTo)}}},Vn=(e,t,n,o={})=>{let a=(s,i,l)=>{let c=s??i;if(!Nn(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 Py(a(e,0,"current value")/r(n),Vl(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 Wo=(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:Jm[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])},Ey=(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},$t=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,xy=(e,t)=>{let n=e?.character?.sprite,o=t?.character?.sprite,a=$t(n)?n:void 0,r=$t(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},El=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},xl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Sl=(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,Sy=(e,t)=>{let n={},o=Sl(El(e),El(t)),a=Sl(xl(e),xl(t));return o&&(n.resource=o),a&&(n.color=a),Object.keys(n).length>0?n:null},Jo=(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(f=>f.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=Sy(e.background,t.background);r&&(n.background=r),a("screen"),a("bgm"),a("voice");let s=Ey(e.dialogue,t.dialogue);s&&(n.dialogue=s);let i=xy(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},Qo=(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},Oy=(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},Ol=e=>e!==null&&typeof e=="object"?structuredClone(e):e,Ry=(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 Ol(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=Oy(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${n}".`);return Ol(r)},$y={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"])},Cy=(e,t)=>{let n=e[e.length-1];return n?$y[n]?.has(t)===!0:!1},Go=(e,t,n=[])=>Array.isArray(e)?e.map(o=>Go(o,t,n)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,Cy(n,o)?a:Go(a,t,[...n,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?Ry(e,t,"_event"):Lr(e,t):e,Mt=(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 Go(e,t)};var _y=11102230246251565e-32,Fl=128,Ul=1e3,Bl=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),qt=(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`)},Fn=(e,t)=>{if(!Bl(e))throw new Error(`${t} must be an object`)},Un=(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},jy=(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},Zo=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)},Ny=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),Yl=e=>{let t=e??Ny();if(!Bl(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}}},Ty=(e,t)=>{let n=4294967296-4294967296%t;for(let o=0;o<Fl;o+=1){let a=e.nextUint32();if(a<n)return a%t}throw new Error(`random source exhausted after ${Fl} rejected samples`)},Dy=e=>{let t=e.nextUint32()>>>5,n=e.nextUint32()>>>6;return(t*67108864+n)/9007199254740992},Ly=(e,t)=>{if(qt(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=Un(e.min,"random.distribution.min"),a=Un(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 Zo({type:"integer",value:a===1?n:n+Ty(t,a)})},My=(e,t)=>{if(qt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>Ul)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(Fn(c,p),qt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Fn(c.actions,`${p}.actions`),{weight:jy(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<=_y))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let s=Dy(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 Zo({type:"weighted",outcomeIndex:l})},zl=(e,{randomSource:t})=>{Fn(e,"random.distribution");let o={integer:Ly,weighted:My}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},Bn=(e,t)=>{if(Fn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")qt(e,new Set(["type","value"]),"random result"),Un(e.value,"random result.value");else if(t==="weighted")qt(e,new Set(["type","outcomeIndex"]),"random result"),Un(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:Ul-1});else throw new Error(`unsupported recorded random result type: ${t}`);return Zo(e)};var Vr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),Hl=Object.freeze([Vr("cleanup",["clearPendingEffects","cleanAll"]),Vr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Vr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Vr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Vr("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"]),Vr("persistence",["saveSlot"]),Vr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),ot=new Map;Hl.forEach(e=>{e.actions.forEach(t=>{if(ot.has(t))throw new Error(`duplicate action execution key: ${t}`);ot.set(t,ot.size)})});var qy=new Set(Hl.find(({name:e})=>e==="navigation").actions),Xl=ot.get("saveSlot")-.5,Gl=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",Vy=(e,t)=>e<t?-1:e>t?1:0,Yn=e=>Object.entries(e).sort((t,n)=>{let o=Gl(...t),a=Gl(...n),r=ot.get(o),s=ot.get(a),i=r??Xl,l=s??Xl;return i!==l?i-l:r!==void 0&&s!==void 0?0:Vy(o,a)}),zn=e=>qy.has(e),Xn=e=>{let t=e.map(([n])=>n).filter(zn);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var le=e=>structuredClone(Ae(e)?gr(e):e),ae=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Vt=e=>e?.animations?.playback?.continuity==="persistent",H=(e,t)=>ae(e??{},t)&&e[t]!==void 0,Gn=e=>H(e,"alpha")||H(e,"opacity"),Fy=e=>H(e,"alpha")?e.alpha:e?.opacity,tc=e=>(H(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Uy=e=>e?.applyMode==="persistent",By="default",Yy=e=>Array.isArray(e?.channels)?e.channels.filter(Uy).map(le):[],Ft=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:le(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},zy=e=>Gn(e)||H(e,"blur"),ri=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],nc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],ei=["animationName","animationSpeed","loop"],Xy=e=>H(e,"transformId")||H(e,"transform")||ri.some(t=>H(e,t)),sc=e=>e?.text&&H(e.text,"content")&&H(e.text,"textStyleId"),oc=e=>e?.layout&&Array.isArray(e.layout.elements),Gy=e=>H(e,"text")||H(e,"layout"),Kl=(e,t)=>e.resourceId?!0:sc(e)?!t?.text:oc(e)?!t?.layout:!1,Wl=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Hy=(e,t)=>{let n={...le(e),...t};if(t.text&&e.text&&(n.text={...le(e.text),...le(t.text)}),t.transform&&e.transform&&(n.transform={...le(e.transform),...le(t.transform)}),H(t,"transform")){delete n.transformId;for(let o of ri)H(t,o)||delete n[o]}else H(t,"transformId")&&delete n.transform;return n},Ky=(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(H(e,"text")&&!sc(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(H(e,"layout")&&!oc(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Jl=e=>nc.some(t=>H(e,t)),Ql=e=>ei.some(t=>H(e,t)),Wy=(e,t,{hasAuthoredTransformId:n=!1}={})=>{if(!t)return e;for(let o of nc)!n&&!H(e,o)&&H(t,o)&&(e[o]=t[o]),ae(e,o)&&e[o]===void 0&&delete e[o];return e},ic=(e,t,n)=>{let o=e[n];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},Jy=(e,t)=>{if(!t)return e;let n=H(e,"transform");for(let o of ri)!n&&!H(e,o)&&H(t,o)&&(e[o]=t[o]),ae(e,o)&&e[o]===void 0&&delete e[o];return e},Qy=(e,t)=>(t&&(!H(e,"opacity")&&H(t,"opacity")&&(e.opacity=t.opacity),!H(e,"blur")&&H(t,"blur")&&(e.blur=le(t.blur)),ae(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ae(e,"blur")&&e.blur===void 0&&delete e.blur),e),ac=(e,t,n=[],{hasPatchFn:o=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let r=e.map((s,i)=>{let l=ic(n,s,i),c=t(s,l),u=zy(s),p=Xy(s),f=o(s),d=ae(s,"animations"),m=tc(le(s));if(!c&&(u||p||f)&&l&&(m=a?a(l,m):{...le(l),...m}),!d){let b=l?t(l):!1,h=t(m);b&&h&&Vt(l)?m.animations=le(l.animations):delete m.animations}return Qy(Jy(m,l),l)}).filter(s=>t(s)||s.animations);return{hasValidItems:r.length>0,processedItems:r}},Zy=e=>{if(e){if(e.character&&ae(e.character,"name"))return e.character.name;if(ae(e,"characterName"))return e.characterName}},lc=e=>!!e?.character&&ae(e.character,"sprite"),eh=e=>{let t={},n=!1,o=Zy(e);return o!==void 0&&(t.name=o,n=!0),lc(e)&&(t.sprite=le(e.character.sprite),n=!0),n?t:void 0},Zl=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},ec=({dialogueState:e,dialogueAction:t,persistCharacter:n})=>ae(t,"persistSprite")?t.persistSprite===!0:ae(e,"persistSprite")?e.persistSprite===!0:n&&!ae(t,"characterId"),rc=({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 ae(c,"name")?i.name=c.name:(o&&!n||u)&&ae(l,"name")&&(i.name=le(l.name)),ae(c,"sprite")?i.sprite=le(c.sprite):(a||p)&&ae(l,"sprite")&&(i.sprite=le(l.sprite)),Object.keys(i).length>0?i:void 0},rh=({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=>le(a)):delete e.initialRevealedContent,e.content=[...o,...t]},th=()=>({}),nh=(e,t)=>{if(!t.screen)return;let n=Gn(t.screen),o=H(t.screen,"blur"),a=ae(t.screen,"animations");if(!n&&!o){a||delete e.screen;return}let r=e.screen,s={};if(n?s.opacity=Fy(t.screen):H(r,"opacity")&&(s.opacity=r.opacity),o?s.blur=le(t.screen.blur):H(r,"blur")&&(s.blur=le(r.blur)),ae(s,"opacity")&&s.opacity===void 0&&delete s.opacity,ae(s,"blur")&&s.blur===void 0&&delete s.blur,Object.keys(s).length===0){delete e.screen;return}e.screen=s},sh=(e,t)=>{if(t.background){let n=H(t.background,"resourceId"),o=H(t.background,"colorId"),a=Gn(t.background),r=H(t.background,"blur"),s=H(t.background,"transformId"),i=Jl(t.background),l=Ql(t.background),{animationsOnly:c,state:u}=Ft(t.background,d=>H(d,"resourceId")||H(d,"colorId")||Gn(d)||H(d,"blur")||H(d,"transformId")||Jl(d)||Ql(d));if(c){e.background=e.background?{...le(e.background),...u}:u;return}if(!n&&!o&&!a&&!r&&!s&&!i&&!l){delete e.background;return}let p=e.background,f=tc(le(t.background));if(!n&&p?.resourceId){f.resourceId=p.resourceId,!ae(f,"transformId")&&p.transformId&&(f.transformId=p.transformId);for(let d of ei)!H(f,d)&&H(p,d)&&(f[d]=p[d])}Wy(f,p,{hasAuthoredTransformId:s}),!o&&p?.colorId&&(f.colorId=p.colorId),!a&&H(p,"opacity")&&(f.opacity=p.opacity),!r&&H(p,"blur")&&(f.blur=le(p.blur)),ae(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,ae(f,"colorId")&&f.colorId===void 0&&delete f.colorId,ae(f,"animations")&&f.animations===void 0&&delete f.animations,ae(f,"transformId")&&f.transformId===void 0&&delete f.transformId,ae(f,"opacity")&&f.opacity===void 0&&delete f.opacity,ae(f,"blur")&&f.blur===void 0&&delete f.blur;for(let d of ei)ae(f,d)&&f[d]===void 0&&delete f[d];if(!f.resourceId&&!f.colorId){delete e.background;return}p?.resourceId===f.resourceId&&p?.transformId===f.transformId&&!ae(f,"animations")&&Vt(p)&&(f.animations=le(p.animations)),e.background=f}else e.background?.animations&&!Vt(e.background)&&(e.background.animations={})},oh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&(Zl(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=ec({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=rc({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}=Ft(t.dialogue.ui,f=>!!f.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&&rh({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ae(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ae(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=ec({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ae(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let s=ae(t.dialogue,"characterId"),i=eh(t.dialogue),l=lc(t.dialogue);s?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=rc({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:s,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ae(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||Zl(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=le(e.dialogue.character)),e.dialogue.lines.push(u)}},ih=(e,t)=>{let n=Yy(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!==By);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=le(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(le(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},ah=(e,t)=>{if(t.bgm){let n=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!n||n&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=le(t.bgm),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},lh=(e,t)=>{if(t.visual){let n=e.visual?.items||[];t.visual.items?.forEach((r,s)=>{Ky(r,ic(n,r,s))});let{hasValidItems:o,processedItems:a}=ac(t.visual.items,Kl,n,{hasPatchFn:Gy,mergeItemFn:Hy});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(n=>n.animations&&(!Kl(n)||!Vt(n))?{...n,animations:{}}:n))},ch=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!Wl(a)||!Vt(a))?{...a,animations:{}}:a));return}let{hasValidItems:n,processedItems:o}=ac(t.character.items,Wl,e.character?.items||[]);n?e.character={items:o}:delete e.character},uh=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},ph=(e,t)=>{if(t.layout){let{animationsOnly:n,state:o}=Ft(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},fh=(e,t)=>{if(t.choice){let{animationsOnly:n,state:o}=Ft(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},dh=(e,t)=>{if(t.form){let{animationsOnly:n,state:o}=Ft(t.form,a=>!!a.resourceId);if(n){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=le(t.form)}else e.form&&delete e.form},mh=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},yh=(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=le(t.voice)}else e.voice&&delete e.voice},hh=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(n=>{delete e[n]})},Fr=e=>Dn(th,[hh,nh,sh,ih,ah,lh,oh,ch,uh,ph,fh,dh,mh,yh])(e);var it=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let n=Lr(e,t);return n&&typeof n=="object"?e:n};var gh=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"}}),kr=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}),Ut=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),bh=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),ti=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),cc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),ni=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),uc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),wh=(e,t)=>{let n=bh[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}"`)},Hn=(e,t)=>{if(wh(e,t),e==="autoForwardDelay"&&t<0)throw new Error("autoForwardDelay requires a value greater than or equal to 0");if(["autoForwardSpeed","soundVolume","musicVolume"].includes(e)&&(t<0||t>100))throw new Error(`${e} requires a value between 0 and 100`);return e==="saveLoadPagination"?Math.max(1,Math.trunc(t)):t},si=(e={})=>{let t=e?.config;if(t===void 0)return{...kr};if(!uc(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{...kr};if(!uc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(cc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let s={...kr};return cc.forEach(i=>{o[i]!==void 0&&(s[i]=Hn(i,o[i]))}),s},Ih=(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]}},Ar=e=>Object.fromEntries(Object.entries(gh).map(([t,n])=>{let o=Ih(e,n.source),a=o!==void 0?o:kr[t]??Ut[t];return[t,a]})),Ze=(e,t)=>Ar(e)[t],pc=(e={})=>Object.fromEntries(ti.map(t=>[t,e[t]??kr[t]]));var at=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}),lr=Object.freeze({BEHIND_BACKGROUND:at.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:at.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:at.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:at.VISUAL_BEHIND_CHOICE,FOREGROUND:at.VISUAL_FOREGROUND}),oi=lr.BEHIND_DIALOGUE,ii=Object.freeze(Object.values(lr).sort((e,t)=>e-t));var vh={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,n])=>({id:t,...n})),formatDate:Wo},kh=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,Bt=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return Bt(t);let[n]=Object.keys(t),o=kh.exec(n);if(!o)return Bt(t);let[,a,r,s]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${s.trim()})`,l=Array.isArray(t[n])?t[n]:[];return{[i]:Bt(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,Bt(n)])),cr=(e,t)=>{let n={functions:vh};return Lr(Bt(e),t,n)},Pi=({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".`)},Ah=({id:e,targetId:t,animation:n,playback:o,animationPath:a="animation"})=>{let r=structuredClone(n);if(Pi({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let s=Sh(o,`${a}.playback`);if(s!==void 0){let i=s.loop===!0?Rc(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},Ph=(e,{animationId:t="animation",animationPath:n="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return Pi({animationType:e.type,animationId:t,animationPath:n}),e.type},Eh=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},xh=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},Sh=(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},Oh=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},He=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Ec=(e={})=>He(e,"alpha")&&typeof e.alpha=="number"?e.alpha:He(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,xc=e=>e?.playback?.continuity==="persistent",mi=e=>Array.isArray(e)?e.map(mi):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=mi(e[n]),t),{}),Zn=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=structuredClone(e);return t.playback&&(delete t.playback.continuity,t.playback.speed===1&&delete t.playback.speed,Object.keys(t.playback).length===0&&delete t.playback),JSON.stringify(mi(t))},Sc=(e=[])=>e.filter(t=>xc(t)).map(t=>structuredClone(t)),Oc=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,ai=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,n)=>Math.max(t,Oc(n)),0),Rc=e=>Math.max(ai(e?.tween),ai(e?.prev?.tween),ai(e?.next?.tween),Oc(e?.mask?.progress)),$c=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:Rc(e)/Oh(e),Rh=e=>e.some(t=>t?.playback?.loop===!0),fc=({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(Zn).filter(Boolean));return e.some(o=>{if(!xc(o))return!1;let a=Zn(o);return a?n.has(a):!1})},Ke=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:n,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||n?!1:Rh(e)||r&&!t||fc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:fc({animationInstances:e,activePersistentAnimations:a}),Cc=(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 He(s??{},"animations")},$h=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Ch=(e,t)=>{if($h(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},_h=({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?Ah({id:o,targetId:a,animation:s,playback:n,animationPath:r}):null},jh=(e,{defaultTargetId:t,defaultId:n,animationPath:o="animation"}={})=>{if(!e||typeof e!="object"||Array.isArray(e))return e;let a=structuredClone(e);return Pi({animationType:a.type,animationId:a.id??n,animationPath:o}),a.id??=n,a.targetId??=t,a},Ei=({animations:e,transitions:t,defaultTargetId:n,idPrefix:o,animationPathPrefix:a=o})=>{t.forEach((r,s)=>{e.push(jh(r,{defaultTargetId:n,defaultId:`${o}-transition-${s}`,animationPath:`${a}.transitions[${s}]`}))})},yi=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(n=>n===null||typeof n!="object"||Array.isArray(n)))throw new Error(`${t} must be an array of objects`);return e},Nh=({content:e,path:t,variables:n})=>yi(e,t).reduce((o,a)=>{let r=it(a.text,{variables:n});return o+`${r??""}`.length},0),dc=(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))},Kn=(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("-")}`},ct=(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},Th=(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},Dh=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Lh=(e={})=>Dh.some(t=>He(e,t)),_c=(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"}},Jn=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},Mh=(e={})=>e.textStyles||{},qh=(e={})=>e.images||{},Vh=.5,Fh=(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]},xi=({id:e,resourceId:t,spritesheet:n,animationName:o,animationSpeed:a,loop:r,width:s,height:i,transform:l={}}={})=>{let c=Fh(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??Vh,loop:r??u.loop??!0}}},jc=({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 xi({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}`)},Uh=(e={})=>e.colors||{},Bh=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,zt=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,ut=(e,t,n)=>{if(typeof e!="string"||e.length===0)throw new Error(`${n} at "${t}" must resolve to a non-empty string`)},li=(e,t,n)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${n}" must be a number between 0 and 1`);return e},ci=(e,t,n,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},ts=(e,t)=>{if(typeof e!="string"||!Bh.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},mc=(e,t,n)=>{let o=ts(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})`},Yh=(e={},t)=>{let n=Mh(e)?.[t];if(!n)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(n.fontId)?n.fontId:[n.fontId]).map(l=>{let c=e.fonts?.[l];if(!c)throw new Error(`Font "${l}" not found for text style "${t}"`);return c.fileId}),r=e.colors?.[n.colorId];if(!r)throw new Error(`Color "${n.colorId}" not found for text style "${t}"`);let s=li(n.colorAlpha,"colorAlpha",t),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:mc(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=li(n.strokeAlpha,"strokeAlpha",t);i.strokeColor=mc(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:ts(l.hex,`Shadow color "${n.shadow.colorId}" for text style "${t}"`),alpha:li(n.shadow.alpha,"shadow.alpha",t),blur:ci(n.shadow.blur,"blur",t,0,{minimum:0}),offsetX:ci(n.shadow.offsetX,"offsetX",t,2),offsetY:ci(n.shadow.offsetY,"offsetY",t,2)}}return i},hi=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>hi(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(Object.prototype.hasOwnProperty.call(e,"textStyle"))throw new Error(`Inline textStyle is not allowed in layout elements at "${n}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e))a!=="textStyleId"&&(o[a]=hi(r,t,zt(n,a)));return e.textStyleId!==void 0&&(ut(e.textStyleId,n,"textStyleId"),o.textStyle=Yh(t,e.textStyleId)),o},Si=(e={},t)=>{let n=Uh(e)?.[t];if(!n)throw new Error(`Color "${t}" not found`);return ts(n.hex,`Color "${t}"`)},Nc=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",ui=(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 ${Nc(`${t}.fill`)} instead`)},zh=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Xt(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]=Xt(r,t,zt(n,a)));return e.colorId!==void 0&&(ut(e.colorId,n,"colorId"),o.fill=Si(t,e.colorId)),o},Xt=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>Xt(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 ${Nc("fill")} instead`);ui(e,"hover",n),ui(e,"click",n),ui(e,"rightClick",n)}let o={};for(let[a,r]of Object.entries(e))if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=zh(r,t,zt(n,a));continue}o[a]=Xt(r,t,zt(n,a))}return e.type==="rect"&&e.colorId!==void 0&&(ut(e.colorId,n,"colorId"),o.fill=Si(t,e.colorId)),o},pi=(e={},t)=>{let n=qh(e)?.[t];return n||null},Tc=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",yc=(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 ${Tc(`${t}.${o}`)} instead`)},hc=(e,t,n)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:n}},gi=(e,t={},n="root")=>{if(Array.isArray(e))return e.map((a,r)=>gi(a,t,`${n}[${r}]`));if(!e||typeof e!="object")return e;if(e.type==="sprite"){for(let a of["url","src","hoverUrl","hoverSrc","clickUrl","clickSrc"])if(Object.prototype.hasOwnProperty.call(e,a))throw new Error(`Inline ${a} is not allowed in sprite layout elements at "${n}". Use ${Tc(a)} instead`);yc(e,"hover",n,"src"),yc(e,"click",n,"src")}let o={};for(let[a,r]of Object.entries(e))e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=gi(r,t,zt(n,a)));if(e.type==="sprite"&&e.imageId!==void 0){ut(e.imageId,n,"imageId");let a=pi(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&&(ut(e.hoverImageId,n,"hoverImageId"),hc(o,"hover",pi(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(ut(e.clickImageId,n,"clickImageId"),hc(o,"click",pi(t,e.clickImageId)?.fileId??e.clickImageId)),o},bi=e=>Array.isArray(e)?e.map(bi):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,bi(n)])),Xh=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),Qn=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>Qn(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let n=bi(e),o=typeof e.type=="string";(o||t)&&He(e,"opacity")&&(He(e,"alpha")||(n.alpha=e.opacity),delete n.opacity);for(let a of["elements","children"])He(e,a)&&(n[a]=Qn(e[a]));for(let[a,r]of Object.entries(e))Xh(a)&&(n[a]=Qn(r,{isElementPatch:o||t}));return n},Oi=(e,t={},n="root")=>Qn(gi(Xt(hi(e,t,n),t,n),t,n)),ur=Oi,Br=(e=[])=>e.find(t=>t.id==="story"),Gh="#000000",wi="bg-cg-background-color",Hh=({resources:e={},background:t={},screen:n})=>t?.colorId===void 0?ts(n?.backgroundColor??Gh,"screen.backgroundColor"):Si(e,t.colorId),Dc=(e={})=>Ec(e),Kh=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},gc=(e={},{includeDefaultAlpha:t=!1}={})=>{let n=Dc(e),o=Kh(e),a={};return(t||n!==void 0)&&(a.alpha=n??1),o&&(a.blur=o),a},Wh=(e={})=>Ec(e),Jh=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Lc=(e={})=>{let t=Wh(e),n=Jh(e),o={};return t!==void 0&&(o.alpha=t),n&&(o.blur=n),o},Ur=(e={})=>Lc(e),bc=(e,t,n,o)=>{let a=t[n]??e[n];return t[o]??e[o]??!1?(a??1)*-1:a},er=(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:bc(e,t,"scaleX","flipX"),scaleY:bc(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},Qh=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","animations"],Ri=(e={})=>e.text&&He(e.text,"content")&&He(e.text,"textStyleId"),$i=(e={})=>e.layout&&Array.isArray(e.layout.elements),wc=(e={})=>{if(e.resourceId)return e.resourceId;if(Ri(e))return"text";if($i(e))return"inline-layout"},Ic=(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,Zh=({item:e,particle:t,resources:n})=>{let o=ct(n,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=Ic(r,n)),a.texture!==void 0&&(a.texture=Ic(a.texture,n));let s={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...er(o,e)};return Object.assign(s,Ur(e)),s},eg=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&&!Ri(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!$i(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let n of Qh)if(He(e.text,n))throw new Error(`Visual item "${e.id}" text.${n} is reserved for the visual item`)}},rg=({resources:e,background:t,screen:n={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:wi,type:"rect",x:0,y:0,width:n?.width??1920,height:n?.height??1080,fill:Hh({resources:e,background:t,screen:n})};if(o){let r=Dc(t);r!==void 0&&(a.alpha=r)}return a},tg=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,vc=({resources:e={},resourceId:t,colorId:n})=>{let o=_c(e,t);return t&&(o||n===void 0)?{resourceId:t,targetId:Jn({resourceId:t,kind:o})}:n!==void 0?{resourceId:wi,targetId:wi}:{resourceId:void 0,targetId:void 0}},Mc=100,Pr=Mc,ng="channel:bgm",sg="channel:music-room",og="music-room:player",ig="channel:voice",ag="default",lg=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Yt=(...e)=>e.map(lg).join(":"),es=(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)})},qc=(e,t)=>e*t/Mc,Ci=(e={},t)=>e?.[t]??kr[t],_i=(e={},t,n=Pr)=>qc(n,Ci(e,t)),ns=({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},Wn=(e,t,n,o)=>e[n]!==void 0?e[n]:t[n]!==void 0?t[n]:o,cg=["muted","pan","playbackRate","startAt","endAt"],ss=({id:e,sound:t,resource:n,defaultLoop:o=!1})=>{let a={id:e,type:"sound",src:n.fileId,loop:Wn(t,n,"loop",o),volume:Wn(t,n,"volume",Pr),startDelayMs:Wn(t,n,"startDelayMs",0)};cg.forEach(s=>{let i=Wn(t,n,s,void 0);i!==void 0&&(a[s]=i)}),t.playback!==void 0&&(a.playback=structuredClone(t.playback));let r=a.startAt??0;if(a.endAt!==void 0&&a.endAt!==null&&a.endAt<r)throw new Error(`Sound "${e}" endAt (${a.endAt}) must be greater than or equal to startAt (${r}).`);return a},ug=e=>Math.max(-1,Math.min(1,e)),pg=({node:e,bgm:t,sound:n,resource:o,usesLegacySound:a})=>{a||(e.volume=qc(t.volume??Pr,e.volume??Pr));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=ug((t.pan??0)+(e.pan??0))),e},ze=({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:f,canRollback:d,confirmDialog:m,form:b,historyDialogue:h=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:g,skipTransitionsAndAnimations:E}={})=>{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},P=hg({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:f,canRollback:d,confirmDialog:m,form:b,historyDialogue:h,characters:y};return P&&(v.dialogue=P,v.dialogueLines=P.lines),v},kc=100,rs=(e,t)=>{if(Array.isArray(e))return e.map(o=>rs(o,t));if(!e||typeof e!="object")return e;let n={...e};return Object.keys(n).forEach(o=>{n[o]=rs(n[o],t)}),n.type==="text-revealing"?t(n):n},fg=e=>rs(e,t=>({...t,revealEffect:"none"})),dg=e=>rs(e,t=>{let n=Number(t.speed??t.displaySpeed),o=Number.isFinite(n)?Math.max(n,kc):kc;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),Er=(e,{isLineCompleted:t=!1,skipMode:n=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?fg(e):n?dg(e):e,Vc=({id:e,screen:t={width:1920,height:1080}})=>({id:e,type:"rect",fill:"transparent",width:t.width,height:t.height,x:0,y:0,click:{payload:{actions:{}}}}),Ii=e=>{if(Array.isArray(e))return e.map(Ii);if(!e||typeof e!="object")return e;let t={};for(let[r,s]of Object.entries(e))t[r]=Ii(s);let n=t.click?.payload;if(!n||typeof n!="object"||Array.isArray(n))return t;let 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}}:{}}}}},mg=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),Ac="submit",fi=(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}}},vi=(e,t,n={})=>{if(Array.isArray(e))return e.map(c=>vi(c,t,n));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===Ac,r=o&&n.submitRoleAncestor,s=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=vi(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:fi(l.change,u),submit:fi(l.submit,t.submitActions)}}}return l.formRole===Ac||r?{...l,click:fi(l.click,t.submitActions,{replaceActions:!0})}:l},ki=(e,t)=>{if(Array.isArray(e))return e.map(o=>ki(o,t));if(!e||typeof e!="object")return e;let n={};for(let[o,a]of Object.entries(e))n[o]=ki(a,t);for(let o of mg){let a=n[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(n[o]={...n[o],payload:{...a,_interactionSource:"form"}})}return n},Ai=({characterId:e,character:t,characterName:n,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,s=Ln({characterId:e,character:t,characterName:n,characters:o,variables:a});return{...r||{},...t||{},name:s}},Fc=(e=[],t={},n={})=>e.map(o=>{let a=Ai({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}}),yg=e=>!(!e||e.mode==="adv"&&e.content===void 0),hg=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:n={},variables:o,runtime:a}={})=>{if(!t&&!yg(e))return;let r=e.content===void 0?[{text:""}]:yi(e.content,"dialogue.content"),s=e.content===void 0?0:Nh({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??kr.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,f)=>{let d=yi(p.content,`dialogue.lines[${f}].content`),m=Ai({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:n,variables:o});return{...p,textSpeed:p.textSpeed??i,content:d.map(b=>({...b,text:it(b.text,{variables:o})})),character:m,characterName:m.name}}),u=Ai({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:it(p.text,{variables:o})})),initialRevealedCharacters:s,lines:c}},ji=({container:e,resources:t,templateData:n,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let s=cr(e,n);return ur(Er(s,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},di=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),Pc=({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:di(s)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:di(a.keyup)});return}e[o]={...r,[n]:{payload:di(a)}}})},gg=(e={},t={})=>{let n={};return Pc({renderStateKeyboard:n,keyboard:e,phase:"keydown"}),Pc({renderStateKeyboard:n,keyboard:t,phase:"keyup"}),Object.keys(n).length>0?n:void 0},pr=({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 g=_h({resources:t,animationId:d,playback:m,instanceId:y,targetId:w,animationPath:s});g&&l.push(g)},u=n!=null&&n!==!1,p=o!=null&&o!==!1,f=a&&r&&a===r;Ch(e,s);let d=Eh(e),m=xh(e),b=t?.animations?.[d],h=Ph(b,{animationId:d,animationPath:s});if(h==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(h==="transition"){let y=`${i}-animation-transition`,w=m?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&f)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},bg=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),wg=(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:f,activePersistentAnimations:d,restoredPersistentAnimations:m,autoMode:b,skipMode:h,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:E,saveSlots:k=[]})=>{let{elements:P,animations:v}=e;if(t.background){let O=o===void 0?!0:He(o?.background??{},"animations"),T=P.find(oe=>oe.id==="story");if(!T)return e;let R=Th(a,t.background),L=R||Lh(t.background),U=n?.background?.resourceId,_=n?.background?.colorId,X=t.background.resourceId??(t.background.animations?U:void 0),re=t.background.colorId??(t.background.animations?_:void 0),M=tg(a,X),se={...t.background,colorId:re};if((re!==void 0||M)&&T.children.push(rg({resources:a,background:se,screen:r,includeAlpha:!M})),X){let{images:oe={},videos:K={},spritesheets:pe={}}=a,ie=_c(a,X),C;if(ie==="sprite"?C=oe[X]:ie==="video"?C=K[X]:ie==="spritesheet-animation"&&(C=pe[X]),C){let j=ie==="video",F=ie==="spritesheet-animation",W={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...R},fe={...gc(t.background,{includeDefaultAlpha:!0}),...er(W,t.background)},Se;F?Se=xi({id:Jn({resourceId:X,kind:ie}),resourceId:X,spritesheet:C,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:fe}):Se={id:Jn({resourceId:X,kind:ie}),type:j?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...fe},j&&(Se.loop=t.background.loop??!1,Se.volume=C.volume??50),Se&&T.children.push(Se)}}if(X){let{layouts:oe={}}=a,K=oe[X];if(K){let pe={id:Jn({resourceId:X,kind:"container"}),type:"container",children:K.elements,...gc(t.background)};L&&Object.assign(pe,er({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...R},t.background));let ie=cr(pe,ze({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:f,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:s,autoMode:b,skipMode:h,isChoiceVisible:y,isFormVisible:w,canRollback:g,form:E,characters:a.characters||{},skipTransitionsAndAnimations:i}));T.children.push(ur(Er(ie,{isLineCompleted:s,skipMode:h,skipTransitionsAndAnimations:i}),a))}}let ue=vc({resources:a,resourceId:U,colorId:_}),z=vc({resources:a,resourceId:X,colorId:re}),Q=pr({animationsDef:t.background.animations,resources:a,previousResourceId:ue.resourceId,currentResourceId:z.resourceId,previousTargetId:ue.targetId,currentTargetId:z.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ke({animationInstances:Q,isLineCompleted:s,skipTransitionsAndAnimations:i,activePersistentAnimations:d,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:O})&&v.push(...Q)}return e},Ig=(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(h=>h.id==="story");if(!p)return e;let f=t.character.items||[],d=n?.character?.items||[],m=dc(f),b=dc(d);for(let h=0;h<f.length;h++){let y=f[h],{transformId:w,sprites:g}=y,E=d.find(X=>X.id===y.id),k=d.findIndex(X=>X.id===y.id),P=E?.sprites&&E.sprites.length>0,v=g&&g.length>0,O=k>=0?Kn(E,k,b):void 0,T=Cc(o,"character",y.id,h,f),R=pr({animationsDef:y.animations,resources:a,previousResourceId:O,currentResourceId:v?Kn(y,h,m):void 0,previousTargetId:O,currentTargetId:v?Kn(y,h,m):void 0,animationPath:`character.items[${h}].animations`,idPrefix:"character"});if(y.animations&&!g&&!w&&P&&Ke({animationInstances:R,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:T})){u.push(...R);continue}if(y.animations&&!g&&!w)continue;if(!g||g.length===0||!w){console.warn("Character item missing sprites or transformId:",y);continue}let L=Kn(y,h,m),U=a.transforms[w];if(!U){console.warn("Transform not found:",w);continue}let _={type:"container",id:L,...er(U,y),...Ur(y),children:[]};for(let X of g){let re=jc({id:`${L}-${X.id}`,item:X,resources:a});re&&_.children.push(re)}p.children.push(_),Ke({animationInstances:R,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:T})&&u.push(...R)}}return e},Uc=(e,t)=>{if(!ii.includes(e))throw new Error(`${t} must be one of: ${ii.join(", ")}.`)},vg=(e,t)=>{let n=!!e.resourceId||Ri(e)||$i(e),o=e.layer??(n?void 0:t?.layer)??oi;return Uc(o,`Visual item "${e.id}" layer`),o},kg=(e,{presentationState:t,previousPresentationState:n,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:f,restoredPersistentAnimations:d,autoMode:m,skipMode:b,isChoiceVisible:h,isFormVisible:y,canRollback:w,form:g,saveSlots:E=[],visualLayer:k})=>{let{elements:P,animations:v}=e;if(t.visual&&a){let O=P.find(U=>U.id==="story");if(!O)return e;let T=t.visual.items,R=n?.visual?.items||[],L=ze({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:E,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:b,isChoiceVisible:h,isFormVisible:y,canRollback:w,form:g,characters:a.characters||{},skipTransitionsAndAnimations:s});k!==void 0&&Uc(k,"visualLayer");for(let[U,_]of T.entries()){let X=R.find(K=>K.id===_.id),re=Cc(o,"visual",_.id,U,T),M=vg(_,X);if(k!==void 0&&M!==k)continue;if(eg(_),_.layout){let K=ct(a,_),pe={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...er(K,_)};Object.assign(pe,Ur(_)),O.children.push(ji({container:pe,resources:a,templateData:L,isLineCompleted:r,skipMode:b,skipTransitionsAndAnimations:s}))}if(_.text){let K=ct(a,_),pe={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...er(K,_)};Object.assign(pe,Ur(_)),O.children.push(ur(cr(pe,L),a))}if(_.resourceId){let{images:K={},videos:pe={},spritesheets:ie={}}=a,C=ie[_.resourceId];if(C){let j=ct(a,_),F=Ur(_),W=xi({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:C,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...er(j,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{}}});W&&O.children.push(structuredClone(W))}else{let j=K[_.resourceId]||pe[_.resourceId];if(j){let F=pe[_.resourceId]!==void 0,W=ct(a,_),fe={id:`visual-${_.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...er(W,_)};Object.assign(fe,Ur(_)),F&&(fe.loop=j.loop??!1,fe.volume=j.volume??50),O.children.push(fe)}}}let se=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!se){let K=a.particles?.[_.resourceId];K&&O.children.push(Zh({item:_,particle:K,resources:a}))}let ue=!!a.particles?.[_.resourceId];if(_.resourceId&&!se&&!ue){let{layouts:K={}}=a,pe=K[_.resourceId];if(pe){let ie=ct(a,_),C={id:`visual-${_.id}`,type:"container",children:structuredClone(pe.elements),...er(ie,_)};Object.assign(C,Ur(_));let j=cr(C,L);O.children.push(ur(Er(j,{isLineCompleted:r,skipMode:b,skipTransitionsAndAnimations:s}),a))}}let z=wc(X),Q=wc(_),oe=pr({animationsDef:_.animations,resources:a,previousResourceId:z,currentResourceId:Q,previousTargetId:z?`visual-${_.id}`:void 0,currentTargetId:Q?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ke({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:f,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:re})&&v.push(...oe)}}return e},lt="dialogue-character-sprite",Ag=(e,{presentationState:t,previousPresentationState:n,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})=>{let{animations:i}=e,l=Br(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=n?.dialogue?.character?.sprite,p=$t(c),f=$t(u),d=pr({animationsDef:c?.animations,resources:o,previousResourceId:f?lt:void 0,currentResourceId:p?lt:void 0,previousTargetId:f?lt:void 0,currentTargetId:p?lt:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&f&&Ke({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e;let m=o.transforms?.[c.transformId];if(!m)return console.warn("Transform not found:",c.transformId),e;let b={type:"container",id:lt,...er(m),children:[]};for(let h of c.items){let y=jc({id:`${lt}-${h.id}`,item:h,resources:o});y&&b.children.push(y)}return l.children.push(b),Ke({animationInstances:d,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...d),e},Pg=(e,{presentationState:t,previousPresentationState:n,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:f,skipTransitionsAndAnimations:d,variables:m,imageGallery:b,musicRoom:h,sceneReplay:y,runtime:w,activePersistentAnimations:g,saveSlots:E=[]})=>{let{elements:k,animations:P}=e;if(!t.dialogue||a)return e;let v=k.find(T=>T.id==="story");if(!v)return e;if(t.dialogue.ui&&t.dialogue.ui.resourceId){let{layouts:T={}}=o,R=T[t.dialogue.ui.resourceId];if(R){let L={elements:R.elements},U=ze({variables:m,imageGallery:b,musicRoom:h,sceneReplay:y,runtime:w,saveSlots:E,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:f,autoMode:r,skipMode:s,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:d}),_=cr(L,U),X=ur(Er(_?.elements,{isLineCompleted:f,skipMode:s,skipTransitionsAndAnimations:d}),o);if(Array.isArray(X))for(let re of X)v.children.push(re);else X&&v.children.push(X)}}Ag(e,{presentationState:t,previousPresentationState:n,resources:o,isLineCompleted:f,skipTransitionsAndAnimations:d,activePersistentAnimations:g});let O=pr({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 Ke({animationInstances:O,isLineCompleted:f,skipTransitionsAndAnimations:d,activePersistentAnimations:g})&&P.push(...O),e},Eg=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:f,skipMode:d,isChoiceVisible:m,isFormVisible:b,canRollback:h,form:y,activePersistentAnimations:w,saveSlots:g=[]})=>{let{elements:E,animations:k}=e;if(t.choice&&o){let P=Br(E);if(!P)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let T={elements:v.elements},R=cr(T,{...ze({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:r,autoMode:f,skipMode:d,isChoiceVisible:m??!!t.choice,isFormVisible:b,canRollback:h,form:y,characters:o.characters||{},skipTransitionsAndAnimations:s}),choice:{items:t.choice?.items??[]}}),L=Ii(ur(Er(R?.elements,{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o));if(Array.isArray(L))for(let U of L)P.children.push(U);else L&&P.children.push(L)}let O=pr({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"});Ke({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:w})&&k.push(...O)}return e},xg=(e,{presentationState:t,previousPresentationState:n,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:s,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:f,skipMode:d,isChoiceVisible:m,isFormVisible:b,canRollback:h,activePersistentAnimations:y,saveSlots:w=[],form:g})=>{let{elements:E,animations:k}=e;if(!g?.resourceId||!o)return e;let P=Br(E);if(!P)return e;let v=o?.layouts?.[g.resourceId];if(!v)return console.warn(`Form layout not found: ${g.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},T={...ze({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:f,skipMode:d,isChoiceVisible:m,isFormVisible:b,canRollback:h,characters:o.characters||{},skipTransitionsAndAnimations:s,form:g}),form:g},R=cr(O,T),L=ki(ur(Er(vi(R,g),{isLineCompleted:r,skipMode:d,skipTransitionsAndAnimations:s}),o),g);L&&P.children.push(L);let U=pr({animationsDef:g.animations,resources:o,previousResourceId:n?.form?.resourceId,currentResourceId:g.resourceId,previousTargetId:n?.form?.resourceId?"form-container":void 0,currentTargetId:g.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ke({animationInstances:U,isLineCompleted:r,skipTransitionsAndAnimations:s,activePersistentAnimations:y})&&k.push(...U),e},Sg=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,saveSlots:b=[],skipTransitionsAndAnimations:h})=>{if(!t.control?.resourceId)return e;let y=n.controls?.[t.control.resourceId];if(!y)return e;let w=gg(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 g=Br(e.elements);if(!g)return e;let E={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return g.children.push(ji({container:E,resources:n,templateData:ze({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,characters:n.characters||{},skipTransitionsAndAnimations:h}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:h})),e},Ni=({presentationState:e,resources:t={},runtime:n,variables:o,musicRoomPlayer:a})=>{if(e?.bgm&&t){let r=e.bgm,s=!Array.isArray(r.sounds),i=s?r.resourceId?[{id:"default",resourceId:r.resourceId,loop:r.loop??!0,volume:r.volume,startDelayMs:r.startDelayMs??0}]:[]:r.sounds,l=!s&&r.loop===!0,c=[];if(s||es(i,"BGM sound"),l){let p=i.find(f=>f.loop===!0);if(p)throw new Error(`BGM sound "${p.id}" cannot loop inside a looping BGM channel.`)}if(i.forEach(p=>{let f=t.sounds?.[p.resourceId];if(!f)return;let d=l?{...p,loop:p.loop??!1}:p;c.push(pg({node:ss({id:Yt("bgm",s?"default":p.id),sound:d,resource:f,defaultLoop:!l}),bgm:r,sound:d,resource:f,usesLegacySound:s}))}),c.length===0)return null;let u=ze({variables:o,runtime:n}).runtime;return ns({id:ng,volume:Ci(u,"musicVolume"),muted:!1,pan:0,loop:s?void 0:r.loop,playback:a?.bgmPlayback,interruption:r.interruption,children:c,runtime:u})}return null},Og=(e,t)=>{if(!Br(e.elements))return e;let o=Ni(t);return o&&e.audio.push(o),e},Rg=(e,{activeAudioEffect:t,skipTransitionsAndAnimations:n})=>(t&&!n&&(e.audioEffects=[structuredClone(t)]),e),$g=(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=ze({variables:o,runtime:n}).runtime,c=ss({id:og,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i});return e.audio.push(ns({id:sg,volume:_i(l,"musicVolume",Pr),children:[c],runtime:l})),e},Cg=(e,{presentationState:t,resources:n,runtime:o})=>{let{audio:a}=e;if(t.sfx&&n){let r=t.sfx,s=Array.isArray(r.channels)?r.channels:[],i=s.map(l=>({channel:l,usesLegacyChannel:!1}));es(s,"SFX channel"),Array.isArray(r.items)&&i.push({channel:{id:ag,sounds:r.items},usesLegacyChannel:!0}),i.forEach(({channel:l,usesLegacyChannel:c})=>{let u=!c&&l.loop===!0,p=[];if(c||es(l.sounds,"SFX sound",`SFX channel "${l.id}"`),u){let f=l.sounds.find(d=>d.loop===!0);if(f)throw new Error(`SFX sound "${f.id}" cannot loop inside looping SFX channel "${l.id}".`)}l.sounds.forEach((f,d)=>{let m=n.sounds?.[f.resourceId];if(!m)return;let b=u?{...f,loop:f.loop??!1}:f;p.push(ss({id:c?Yt("sfx","default",d,f.id):Yt("sfx",l.id,f.id),sound:b,resource:m,defaultLoop:u?!1:void 0}))}),p.length!==0&&a.push(ns({id:Yt("channel","sfx",l.id),volume:_i(o,"soundVolume",l.volume??Pr),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:c?void 0:l.interruption,children:p,runtime:o}))})}return e},_g=(e,t,n)=>{if(!(!t||!n))return e?.voices?.[t]?.[n]},jg=(e,{presentationState:t,resources:n,currentSceneId:o,runtime:a,variables:r})=>{let{audio:s}=e;if(!t?.voice)return e;let i=t.voice,l=!Array.isArray(i.sounds),c=l?i.resourceId?[{id:"default",resourceId:i.resourceId,loop:i.loop??!1,volume:Pr,startDelayMs:i.startDelayMs??0}]:[]:i.sounds,u=!l&&i.loop===!0,p=[];if(l||es(c,"Voice sound"),u){let d=c.find(m=>m.loop===!0);if(d)throw new Error(`Voice sound "${d.id}" cannot loop inside a looping Voice channel.`)}if(c.forEach(d=>{let m=_g(n,o,d.resourceId);if(!m)return;let b=u?{...d,loop:d.loop??!1}:d;p.push(ss({id:Yt("voice",o,l?"default":d.id),sound:b,resource:m,defaultLoop:u?!1:void 0}))}),p.length===0)return e;let f=ze({variables:r,runtime:a}).runtime;return s.push(ns({id:ig,volume:l?i.volume??Ci(f,"soundVolume"):_i(f,"soundVolume",i.volume??Pr),muted:i.muted,pan:i.pan,loop:l?void 0:i.loop,interruption:i.interruption,children:p,runtime:f})),e},Ng=(e,{presentationState:t,previousPresentationState:n,resources:o={},variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,saveSlots:b=[],isLineCompleted:h,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:g,animations:E}=e;if(t.layout){let O=Br(g);if(!O)return e;let T=o.layouts?.[t.layout.resourceId];if(!T)return e;Array.isArray(T.transitions)&&!h&&!y&&Ei({animations:E,transitions:T.transitions,defaultTargetId:`layout-${t.layout.resourceId}`,idPrefix:`layout-${t.layout.resourceId}`,animationPathPrefix:"layout"});let R={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:T.elements||[]};O.children.push(ji({container:R,resources:o,templateData:ze({variables:a,imageGallery:r,musicRoom:s,sceneReplay:i,runtime:l,saveSlots:b,dialogueState:t.dialogue,isLineCompleted:h,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:h,skipMode:u,skipTransitionsAndAnimations:y}))}let k=n?.layout?.resourceId,P=t.layout?.resourceId,v=pr({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:P,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:P?`layout-${P}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ke({animationInstances:v,isLineCompleted:h,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&E.push(...v),e},Tg=(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=pr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ke({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:s})&&i.push(...u),e},Dg=(e,{presentationState:t})=>{let n=Br(e.elements);return!n||!t?.screen||Object.assign(n,Lc(t.screen)),e},Lg=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:f,form:d,overlayStack:m=[],dialogueHistory:b=[],saveSlots:h=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:E,animations:k}=e;return m&&m.length>0&&m.forEach((P,v)=>{let O=n.layouts?.[P.resourceId];if(!O){console.warn(`Overlay layout not found: ${P.resourceId}`);return}Array.isArray(O.transitions)&&(g||Ei({animations:k,transitions:O.transitions,defaultTargetId:`overlayStack-${v}`,idPrefix:`overlayStack-${v}`,animationPathPrefix:`overlayStack[${v}]`}));let T={id:`overlayStack-${v}`,type:"container",x:0,y:0,children:[Vc({id:`overlayStack-${v}-blocker`,screen:y}),...O.elements||[]]},R=Fc(b,n.characters,o),L=ze({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:h,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:f,form:d,historyDialogue:R,characters:n.characters||{},skipTransitionsAndAnimations:g}),U=cr(T,L),[_,...X]=U.children||[],re=ur(Er({...U,children:X},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:g}),n);E.push({...re,children:_?[_,...re.children||[]]:re.children})}),e},Mg=(e,{presentationState:t,resources:n={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,confirmDialog:b,dialogueHistory:h=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:g})=>{let{elements:E,animations:k}=e;if(!b?.resourceId)return e;let P=n.layouts?.[b.resourceId];if(!P)return console.warn(`ConfirmDialog layout not found: ${b.resourceId}`),e;Array.isArray(P.transitions)&&!g&&Ei({animations:k,transitions:P.transitions,defaultTargetId:"confirmDialog",idPrefix:"confirmDialog",animationPathPrefix:"confirmDialog"});let v={id:"confirmDialog",type:"container",x:0,y:0,children:[Vc({id:"confirmDialog-blocker",screen:y}),...P.elements||[]]},O=Fc(h,n.characters,o),T=cr(v,ze({variables:o,imageGallery:a,musicRoom:r,sceneReplay:s,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:f,canRollback:d,form:m,confirmDialog:b,historyDialogue:O,characters:n.characters||{},skipTransitionsAndAnimations:g})),[R,...L]=T.children||[],U=ur(Er({...T,children:L},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:g}),n);return E.push({...U,children:R?[R,...U.children||[]]:U.children}),e},Gt=e=>(t,n)=>kg(t,{...n,visualLayer:e}),qg=Gt(lr.BEHIND_BACKGROUND),Vg=Gt(lr.BEHIND_CHARACTER),Fg=Gt(lr.BEHIND_DIALOGUE),Ug=Gt(lr.BEHIND_CHOICE),Bg=Gt(lr.FOREGROUND),Bc=e=>Dn(bg,[Sg,qg,wg,Vg,Ig,Fg,Pg,Ug,Eg,xg,Ng,Bg,Dg,Tg,Og,$g,Cg,jg,Rg,Lg,Mg])(e);function Yc(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 zc(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 Xc="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",Gc="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Hc="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Kc=65535,Ti=40960,os=126976,Qc=new Uint8Array(12288),Zc=new Uint8Array(3072),eu=new Uint8Array(2816),ru,tu;{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 Yc(Xc,Gc))e(Qc,0,a,r,s),e(Zc,Ti,a,r,s),e(eu,os,a,r,s),r>=65040&&!(a>=os&&r<=129791)&&(t[o]=a,n[o++]=r<<5|s);ru=t.slice(0,o),tu=n.slice(0,o)}function Wc(e){return e<12288?Qc[e]:e<Ti?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?Zc[e-Ti]: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>=os&&e<129792?eu[e-os]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:zc(e,ru,tu)}var nu=Uint8Array.from(Hc,Number);function Yg(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 Jc(e,t,n){switch(t){case 3:return e&24?n===8204?e&6:(e&24)===16||Yg(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*su(e){let t=e.length;if(t===0)return;let n=e.codePointAt(0),o=n>Kc?2:1,a=Wc(n),r=50200>>a&1?Jc(0,a,n):0,s=0,i=n,l=a;for(;o<t;){n=e.codePointAt(o);let c=n>Kc?2:1,u=Wc(n),p=nu[a<<4|u],f;p===0?f=!0:p===1?f=!1:p===2?f=!(r&1):p===3?f=!(r&4):f=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?Jc(r,u,n):0,f&&(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*ou(e){for(let t of su(e))yield t.segment}{let e=su("_");nu._keep=[e,e.next()]}var iu=1e3,uu=50,zg=0,au=100,lu=50,Xg=60,Gg=3,Hg=.5,Kg=2e4,Wg=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Jg=/^\s+$/u,cu,Qg=e=>{let t=`${e??""}`.normalize("NFC"),n=globalThis.Intl?.Segmenter;return typeof n!="function"?Array.from(ou(t)):(cu??=new n(void 0,{granularity:"grapheme"}),Array.from(cu.segment(t),({segment:o})=>o))},Zg=e=>Qg(e).reduce((t,n)=>Jg.test(n)?t+Hg:Wg.test(n)?t+Gg:t+1,0),eb=e=>2**(((Number.isFinite(e)?Math.min(au,Math.max(zg,e)):uu)-lu)/(au-lu)),Di=({text:e="",baseDelay:t=iu,speed:n=uu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):iu,a=eb(n),r=Zg(e)*Xg/a,s=Math.max(o,Kg);return Math.min(o+r,s)};var is={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},hu=1,fr=1,ft="choice",Sr="form",Jt=()=>({manual:{...is.manual},auto:{...is.auto},applyMode:is.applyMode}),Hi=()=>({groupId:null,variantId:null,pageIndex:0}),rb="music-room:player",tb=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),cs=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),Ki=new Set,nb=new Set(["groupId","variantId"]),sb=new Set(["pageIndex"]),dt=new Set,ob=new Set(["trackId"]),ib=new Set(["positionMs"]),ab=new Set(["pageIndex"]),Wi=new Set,lb=new Set(["sceneId"]),cb=new Set(["pageIndex"]),Ji=()=>({pageIndex:0}),Qi=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let n=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...Jt()},n&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},Mi=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let t=Ae(e)?gr(e):e;return structuredClone(t)},q=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),us=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},gu=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},Qt=(e,t,n)=>({commandId:us(e),operation:t,...n===void 0?{}:{positionMs:n}}),Zi=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,n=t.bgmPlayback;t.trackId!==null&&(n={commandId:us(e),operation:"resume"}),e.global.musicRoomPlayer=cs({bgmPlayback:n})},bu=(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},wu=(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`)},Xr=e=>String(e),Iu=()=>({sections:[],resources:[]}),vu=()=>({sceneIds:[]}),ub=e=>q(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Iu(),pb=e=>q(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):vu(),fb=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",db=({sectionId:e,lineId:t,content:n,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:n,text:fb(n),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),ku=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),mb=e=>q(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,ea=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},yb=e=>{if(!q(e?.dialogueHistory))return e.dialogueHistory=ku(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},ra=e=>{let t=ea(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},hb=()=>({resourceId:void 0}),gb=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},dr=(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}},Au=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)}}},Pu=e=>e,Eu=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==hu)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},bb=(e,t={})=>{let n;try{n=Eu(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:n,slotId:Pu(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},wb=(e={})=>Object.fromEntries(Object.entries(e).map(([t,n])=>[t,bb(t,n)])),Ib=(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||Re(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Lt(l.type,r,a),qn(l.type,r,s,a,{roundTo:i}),r!=="set"||Ko(l,s)}catch{return!1}});return n.length>0?{...e,operations:n}:null},xu=(e,t)=>{if(!Array.isArray(e))return;let n=e.flatMap(o=>{if(!q(o)||!s0(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=Ib(o.payload,t);return a?[{...o,payload:a}]:[]});return n.length>0?n:void 0},vb=(e,t,n)=>{let{section:o}=dr(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},Su=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},Ou=(e,t,n)=>e.filter(({path:o,type:a,result:r})=>{let s=vb(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&&!Re(i)&&Su(s.distribution)&&r.value>=s.distribution.min&&r.value<=s.distribution.max}return!1}),ta=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==fr)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:Bn(V(a.result),a.type)}});return t===void 0?o:Ou(o,e,t)},kb=(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=xu(n.executedActions,t);o?n.executedActions=o:delete n.executedActions;let a=ta(n,t);a?(n.randomOutcomeVersion=fr,n.randomOutcomes=a):(delete n.randomOutcomeVersion,delete n.randomOutcomes)})},Ab=(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=ta(i,t);l?(i.randomOutcomeVersion=fr,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),n},pu=(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}},Pb=(e,t="viewedRegistry")=>{if(e===void 0)return Iu();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=pu(a,"sections",r,t);return[s.sectionId,s]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let s=pu(a,"resources",r,t);return[s.resourceId,s]})))}},Eb=(e,t="accountReplayRegistry")=>{if(e===void 0)return vu();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}))]}},Ht=(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}=dr(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}},Ru=e=>{let t=e.story.initialSceneId,n=e.story.scenes[t],o=n.initialSectionId,a=n.sections[o];return Ht({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},xb=e=>{try{return Ru(e),!0}catch{return!1}},Sb=(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 Ht(o,t,n);try{return Ht(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 Ht(a[s],t,`${n} compatibility checkpoint`)}catch{}return Ru(t)}};var $u=(e,t)=>{let{section:n}=dr(e,t?.sectionId);return n?.lines?.find(o=>o.id===t?.lineId)},Ob=(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}=dr(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}},Rb=(e,t)=>q($u(e,t)?.actions?.dialogue),Cu=(e,t,n)=>{if(!t||t.sectionId!==n.sectionId)return!1;let{section:o}=dr(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},$b=(e,t)=>{let n=ku();return e.timeline.forEach(o=>{if(o.returnable!==!1&&Rb(t,o)){let a=$u(t,o),r=n.entries.at(-1),s=a.actions.dialogue.append===!0&&Cu(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},Cb=(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},_b=(e,t,n)=>{if(!q(e)||!Array.isArray(e.timeline))return{rollback:Wt({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!q(c))return[];let p=ta(c);try{let f=Ht(c,n,`rollback.timeline[${u}]`),d=p?Ou(p,f,n):void 0,m=ls({sectionId:f.sectionId,lineId:f.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...d?{randomOutcomeVersion:fr,randomOutcomes:d}:{}}),b=xu(V(c.executedActions),n);return b&&(m.executedActions=b),o.push(u),[m]}catch{return[]}});if(a.length===0)return{rollback:Wt({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(ls({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}},_u=(e,t,n)=>{if(!q(e))throw new Error(`Malformed save slot contexts[${n}] entry.`);let o=sa(t),a=Sb(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?Tt(V(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},s=zb({loadedContextRuntime:q(e.runtime)?V(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=_b(e.rollback,a,t),u=e.dialogueHistory===void 0?$b(i,t):Cb(Ob(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},jb=(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)=>_u(n,t,o))}},Nb=(e,t)=>{if(!q(e))throw new Error("Malformed save slot.");let n=Eu(e.formatVersion);return{...e,formatVersion:n,state:jb(e.state,t)}},fu=(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}},Tb=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:fu(e.confirmActions,"confirmActions",{required:!0}),cancelActions:fu(e.cancelActions,"cancelActions")}},mt=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Db=e=>(q(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),yt=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},ju=e=>{if(!(!q(e)||!e.animations))return{animations:V(e.animations)}},Lb=(e,t)=>{let n=ju(t);if(n){e.global.pendingScreenTransition=n;return}delete e.global.pendingScreenTransition},Mb=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},qb=(e,t)=>{let n=e?.sectionId,o=e?.lineId;if(!(!n||!o||!t))return`${n}:${o}:${t}`},as=e=>String(e??""),Nu=(e,t)=>{let n=as(t);return e?.trim===!0?n.trim():n},Vb=e=>q(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>q(t)).map(([t,n])=>[t,{id:t,...V(n)}])):{},Fb=(e,t)=>{if(!t||!q(e.global.formDrafts))return;let n=e.global.formDrafts[t];return q(n)?n:void 0},Tu=(e,t)=>{let n=Db(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},na=(e,t)=>{let n=Nu(e,t);return e?.required===!0&&n.length===0?"required":null},Ub=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let o=Ee({state:e},{sectionId:t.sectionId})?.lines||[],a=o.findIndex(r=>r.id===t.lineId);return a<0?{}:Fr(o.slice(0,a+1).map(r=>r.actions||{}))},Bb=({state:e,form:t,pointer:n})=>{if(!t?.resourceId)return null;let o=Mb(t),a=qb(n,o);if(!o||!a)return null;let r=Fb(e,a),s=Vb(t),i=ga({state:e}),l={},c=[],u={},p=!0;return Object.entries(s).forEach(([f,d])=>{let m=as(i?.[d.variableId]),b=Object.prototype.hasOwnProperty.call(r?.values??{},f)?as(r.values[f]):m,h=r?.touched?.[f]===!0,y=na(d,b),w=r?.submitted||h?y:null,g=typeof d.maxLength=="number"?Math.max(0,Math.round(d.maxLength)):void 0,E={id:f,variableId:d.variableId,value:b,initialValue:m,valid:!y,error:w,touched:h,required:d.required===!0,trim:d.trim===!0,placeholder:d.placeholder===void 0?"":String(d.placeholder),multiline:d.multiline===!0,...g!==void 0?{maxLength:g}:{}};y&&(p=!1),l[f]=E,c.push(E),u[f]=b}),{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??{})}}}},pt="line",xr="interaction",ls=({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===fr?{randomOutcomeVersion:fr,randomOutcomes:V(r??[])}:{}}),sa=e=>{let t=Ae(e)?gr(e):e,{contextVariableDefaultValues:n}=Mn(t??{});return V(n)},Du=()=>({...V(Ut)}),Lu=({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]=Hn(s,V(e[s])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Yb=({projectData:e,loadedGlobalRuntime:t={}})=>Lu({loadedRuntime:t,runtimeIds:ti,defaults:si(e),path:"global.runtime"}).runtimeState,zb=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:n}=Lu({loadedRuntime:e,runtimeIds:ni,defaults:Du(),path:"context.runtime"});return n?t:void 0},Rr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},he=e=>{let t=Rr(e);return t?.kind==="sceneReplay"&&q(t.sceneReplay)?t:null},Mu=(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)})},Xb=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)}}),Gb=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=Jt(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Hb=(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:mr({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}})},Kb=e=>e.runtime?(ni.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=V(Ut[t]))}),e.runtime):(e.runtime=Du(),e.runtime),Wb=e=>pc(e.global),qu=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Wb(e)}})},oa=(e,t,n)=>{let o=Hn(t,n);if(t in Ut){let a=Rr(e);if(!a)return o;let r=Kb(a);return r[t]=o,o}return e.global[t]=o,o},ia=({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:hb(),variables:sa(t),rollback:Wt({pointer:e})}),ht=e=>e?(e.currentPointerMode="read",q(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,Jb=(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=ia({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,Qb(e,{queueRender:t}),a},Qb=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,mt(e),yt(e),e.global.nextLineConfig=Jt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,Zi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},Vu=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},Wt=({pointer:e,replayStartIndex:t=0})=>{let n=e?.sectionId&&e?.lineId;return{currentIndex:n?0:-1,isRestoring:!1,replayStartIndex:t,timeline:n?[ls({sectionId:e.sectionId,lineId:e.lineId})]:[]}},$r=(e,t={})=>{if(e?.rollback)return Vu(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=Wt({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=$r(n);if(o.isRestoring)return;let a=ra(n);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(ls(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},Zb=({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}},ew=({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(Ae(l)?Pn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},rw=({state:e},t={})=>{let{slotId:n,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:s}=t,i=Xr(n),l=e.global.saveSlots?.[i],c=Ae(l)?Pn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,f=p?.rollback,d=f?.timeline?.[a];return!Number.isInteger(a)||f?.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},Fu=(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=ra(n);s&&(s.checkpointLengths=s.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},tw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n},o={})=>{let a=o?.source===pt?pt:xr,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=ra(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,s.currentIndex+1))}let i=r?.pointers?.read,l=n?.lineEntryId,c=a===pt&&(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===pt?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},nw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),sw=({state:e,rollbackActionBatchStack:t,playbackOwnership:n})=>{let o=t?.at(-1);if(o?.source!==pt||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},ow=({state:e,rollbackActionBatchStack:t},n)=>{if(t?.at(-1)?.source!==pt)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=Bn(n.result,n.type),r=Fu(e,t);if(!r)return e;if(r.randomOutcomeVersion!==fr&&(r.randomOutcomeVersion=fr,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},rr=(e,t,n,o)=>{let r=o?.at(-1)?.source??xr;if(!o0(t,r))return;let s=Fu(e,o);s&&(Array.isArray(s.executedActions)||(s.executedActions=[]),s.executedActions.push({type:t,payload:V(n)}))},qi=(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(Re(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Dt(c,a),Lt(u,r,a),qn(u,r,s,a,{roundTo:i}),c==="context"&&(n.variables[a]=Vn(n.variables[a],r,s,{roundTo:i}))}},iw=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:n,payload:o})=>{i0(e,n,o)})},aw=(e,t)=>{let{sectionId:n,lineId:o}=t,s=Ee({state:e},{sectionId:n})?.lines?.find(i=>i.id===o)?.actions;s&&va(e,s,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},Uu=(e,t)=>{let n=e.contexts?.[e.contexts.length-1];if(!n)return e;let o=$r(n),a=o.timeline[t];if(!a)return e;e.global.autoMode&&tn({state:e}),e.global.skipMode&&Or({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{n.variables=sa(e.projectData),n.kind==="sceneReplay"&&(Mu(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=[],mt(e),yt(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&Qi(e),aw(e,o.timeline[l]),iw(e,o.timeline[l]);let s=ht(n);s.read={sectionId:a.sectionId,lineId:a.lineId};let i=ea(n);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),n.kind==="sceneReplay"&&(n.sceneReplay.entryId=gu(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},lw=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;Au(t),_t(t),jt(t),Nt(t),qr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],f=p.initialSectionId,d=p.sections[f],m={sceneId:u,sectionId:f,lineId:d.initialLineId??d.lines[0].id},{globalVariablesDefaultValues:b}=Mn(t),h={...b,...Tt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:Pb(i,"accountViewedRegistry"),accountReplayRegistry:Eb(l),nextLineConfig:Jt(),imageGalleryNavigation:Hi(),sceneReplayNavigation:Ji(),sceneReplayEntryId:0,audioCommandId:n,musicRoomPlayer:cs(),saveSlots:wb(a),localizationPackages:V(c),overlayStack:[],variables:h,...Yb({projectData:t,loadedGlobalRuntime:s})},contexts:[ia({pointer:m,projectData:t})]}},cw=({state:e})=>e.global.overlayStack||[],uw=({state:e})=>e.global.pendingEffects,Bu=({state:e})=>e.global.skipMode,pw=({state:e})=>e.global.autoMode,Yu=({state:e})=>e.global.dialogueUIHidden,zu=({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:c,lineId:u}=n.pointers.read,p=Ee({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let f=p.lines.findIndex(d=>d.id===u);o=p.lines.slice(0,f+1).map(d=>({sectionId:c,lineId:d.id}))}let r=[],s=st({variables:{...e.global?.variables??{},...Rr(e)?.variables??{}},runtime:Ar(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let f=Ee({state:e},{sectionId:c.sectionId}),d=Array.isArray(f?.lines)?f.lines:[];u={lines:d,lineIndexes:new Map(d.map((m,b)=>[m.id,b])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let f=u.lines[u.nextLineIndex],d=f.actions||{};u.presentationState=Fr([u.presentationState,d]),u.projections.set(f.id,{line:f,lineActions:d,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!mb(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:f,dialogueState:d}=u;if(!f.dialogue)continue;let m=Ln({characterId:d.characterId,character:d.character,characters:e.projectData.resources?.characters??{},variables:s}),b=db({sectionId:c.sectionId,lineId:p.id,content:f.dialogue.append===!0?d.content:f.dialogue.content,dialogueState:d,characterName:m}),h=r[r.length-1];if((a?c.appendToPrevious===!0:f.dialogue.append===!0)&&h?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:b.content,text:b.text,characterId:b.characterId,character:b.character,characterName:b.characterName};continue}r.push(b)}return r},fw=(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?.[Xr(r)],u=Ae(c)?Pn(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}}})},dw=({state:e},t={})=>{let n=Rr(e),o=n?.pointers?.read,a=en({state:e});if(!n||!q(a?.actions?.dialogue))return e;let r=$r(n),s=r.timeline?.[r.currentIndex],i=s?.sectionId===o?.sectionId&&s?.lineId===o?.lineId,l=ea(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 f=yb(n);f.currentLength<f.entries.length&&(f.entries=f.entries.slice(0,f.currentLength));let d=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&Cu(e.projectData,p,o);if(f.entries.push({sectionId:o.sectionId,lineId:o.lineId,...d?{appendToPrevious:!0}:{}}),f.currentLength=f.entries.length,i){for(;f.checkpointLengths.length<r.timeline.length;)f.checkpointLengths.push(f.checkpointLengths.at(-1)??0);f.checkpointLengths[r.currentIndex]=f.currentLength}return fw(e,t.savedCheckpointOccurrences,f),e},mw=({state:e})=>e.global.confirmDialog??null,Zt=({state:e},{pointer:t}={})=>{let n=t??Le({state:e})?.pointer,o=Ub({state:e,pointer:n});return Bb({state:e,form:o.form,pointer:n})},yw=({state:e},{pointer:t}={})=>!!Zt({state:e},{pointer:t}),xe=({state:e},{pointer:t}={})=>{let n=Zt({state:e},{pointer:t});if(n)return{source:Sr,formId:n.id,formKey:n.key};let o=Ju({state:e,pointer:t});return o?{source:ft,resourceId:o}:null},hw=({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=Ee({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return s.lastLineId===a;let l=i.lines.findIndex(u=>u.id===s.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?s.lastLineId===a:c<=l},aa=({registry:e},t)=>{let{resourceId:n}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===n)},la=({state:e},t)=>hw({state:e,registry:e.global.accountViewedRegistry},t),gw=({state:e},t)=>aa({registry:e.global.accountViewedRegistry},t),Kt=(e,t)=>!aa({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),ca=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),ua=(e,t)=>{let n=ca(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Vi=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!Kt(e,t[a]))return t[a]},bw=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:V(t)},Xu=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let n=e.global.imageGalleryNavigation??Hi(),o=ca(t),a=ua(t,n),r=a*t.pageSize,s=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:Kt(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:Kt(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],f=l<0?-1:Math.floor(l/t.pageSize);p&&f===a&&!Kt(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:Vi(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:Vi(e,c.variants,u,1)!==void 0})}return{pageGroups:s,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},pa=(e,t)=>!aa({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),fa=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),da=(e,t)=>{let n=fa(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},Fi=(e,t,n,o)=>{for(let a=n+o;a>=0&&a<t.length;a+=o)if(!pa(e,t[a]))return t[a]},Gu=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}),ww=(e,t)=>({...Gu(t),locked:pa(e,t)}),du=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")}`},Iw=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:V(t)},Hu=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let n=e.global.musicRoomPlayer??cs(),o=fa(t),a=da(t,n),r=a*t.pageSize,s=t.tracks.slice(r,r+t.pageSize).map(u=>ww(e,u)),i=t.tracks.findIndex(u=>u.id===n.trackId),l=t.tracks[i],c=l?{...Gu(l),canPlayPreviousTrack:Fi(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:Fi(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:du(n.positionMs),durationText:n.durationMs===null?null:du(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}}},ma=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),ya=(e,t)=>{let n=ma(e);if(n===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),n-1)},vw=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:V(t)},kw=({state:e})=>he(e)!==null,Aw=({state:e})=>{let t=he(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Ku=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,Wu=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let n=e.global.sceneReplayNavigation??Ji(),o=ma(t),a=ya(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:!Ku(e,l.sceneId)})),i=he(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:s,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Pw=({state:e})=>e.global.nextLineConfig,Ju=({state:e,pointer:t}={})=>{let n=t??Le({state:e})?.pointer;if(!n)return;let o=n?.sectionId,a=n?.lineId,s=Ee({state:e},{sectionId:o})?.lines||[],i=s.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of s.slice(0,i+1)){let u=c?.actions;if(u?.cleanAll&&(l=void 0),!u||!Object.prototype.hasOwnProperty.call(u,"choice")){l=void 0;continue}let p=u.choice;if(p?.resourceId){l=p.resourceId;continue}p?.animations||(l=void 0)}return l},Qu=({state:e})=>!!Ju({state:e}),Ew=({state:e})=>structuredClone(e),xw=({state:e})=>V(e.projectData.resources?.achievements??{}),Sw=({state:e},t)=>{let n=e.projectData.resources?.achievements?.[t?.resourceId];return n===void 0?void 0:V(n)},Zu=({state:e})=>e.global.saveSlots,Ow=({state:e},t)=>{let n=t?.slotId,o=Xr(n);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},ep=({state:e})=>V(e.global.localizationPackages),ha=({state:e})=>Ar(e),Rw=({state:e},t)=>Ze(e,t?.runtimeId),ga=({state:e})=>{let t={...e.global?.variables??{},...Rr(e)?.variables??{}};return st({variables:t,runtime:Ar(e),variableConfigs:e.projectData.resources?.variables??{}})},Le=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],n=t[t.length-1];if(n)return{currentPointerMode:"read",pointer:n.pointers?.read}},Ee=({state:e},t)=>{let{sectionId:n}=t;return dr(e.projectData,n).section},en=({state:e})=>{let t=Le({state:e});if(!t?.pointer)return;let{sectionId:n,lineId:o}=t.pointer,a=Ee({state:e},{sectionId:n});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===o)},rp=({state:e})=>{let{sectionId:t,lineId:n}=Le({state:e}).pointer,a=Ee({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===n),i=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(f=>{p[f]=u[f]}),p});return Fr(i)},tp=e=>{let t=en({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let n=st({variables:{...e.global?.variables??{},...Rr(e)?.variables??{}},runtime:Ar(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${it(o?.text,{variables:n})??""}`).join("")},mr=({state:e})=>Di({text:tp(e),baseDelay:Ze(e,"autoForwardDelay"),speed:Ze(e,"autoForwardSpeed")}),$w=({state:e})=>{let t=np({state:e}),o=en({state:e})?.actions??{},a=Fr([t??{},o]);return Jo(t??{},a??{})},Cw=({state:e},{sectionId:t})=>{let n=Ee({state:e},{sectionId:t});if(!n?.lines)return[];let o=[],a={};for(let r of n.lines){let s=r.actions||{},i=Fr([a,s]),l=Jo(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=Qo(i)}return o},_w=({state:e},{sectionId:t,includePresentationState:n=!1})=>{let o=Cw({state:e},{sectionId:t});return n?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},np=({state:e})=>{let{sectionId:t,lineId:n}=Le({state:e}).pointer,a=Ee({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===n);if(r<=0)return null;let i=a.slice(0,r).map(l=>{let c=l.actions||{},u={};return Object.keys(c).forEach(p=>{u[p]=c[p]}),u});return Qo(Fr(i))},ba=({state:e},{slotsPerPage:t=6}={})=>{let a=((ha({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[Xr(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},jw=Zu,Nw=ba,Tw=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},Dw=({state:e},t={})=>{let n=rp({state:e}),o=np({state:e}),a=en({state:e})?.actions??{},r=e.global.pendingScreenTransition,s=r?.animations?{...a,screen:V(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=Le({state:e}).pointer,{sceneId:c}=dr(e.projectData,l),u={...ha({state:e}),localizationPackages:ep({state:e})},p=t?.activePersistentAnimations??[],f=t?.restoredPersistentAnimations??[],d=Zt({state:e}),m=Qu({state:e}),b=Xu({state:e}),h=Hu({state:e}),y=Wu({state:e}),w=ga({state:e}),{saveSlots:g}=ba({state:e}),E=Tw(e);return Bc({presentationState:n,previousPresentationState:i,currentLineActions:s,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:m,isFormVisible:!!d,canRollback:xp({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||E,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:d,dialogueHistory:zu({state:e}),saveSlots:g,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:f,imageGallery:b,musicRoom:h,sceneReplay:y,musicRoomPlayer:V(e.global.musicRoomPlayer),activeAudioEffect:t?.activeAudioEffect??null})},Lw=({state:e},t)=>(e.global.confirmDialog=Tb(t),e.global.pendingEffects.push({name:"render"}),e),Mw=({state:e})=>(e.global.confirmDialog&&(mt(e),e.global.pendingEffects.push({name:"render"})),e),qw=({state:e,rollbackActionBatchStack:t},n)=>(e.global.overlayStack.push(n),e.global.pendingEffects.push({name:"render"}),rr(e,"pushOverlay",n,t),e),Vw=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),rr(e,"popOverlay",void 0,t),e),Fw=({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"}),rr(e,"replaceLastOverlay",n,t),e),Uw=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],mt(e),yt(e),e.global.pendingEffects.push({name:"render"}),rr(e,"clearOverlays",void 0,t),e),Bw=(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"})},rn=(e,t,{screenTransition:n}={})=>{e.global.isLineCompleted=!1,Lb(e,n),yt(e);let o=xe({state:e},{pointer:t}),a=o?.source===ft,r=o?.source===Sr;Bw(e,{activeInteraction:o});let s=he(e),i={name:"handleLineActions"};if(typeof s?.sceneReplay?.sceneId=="string"){let l=gu(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}},fs=(e,t,n)=>{!(t?.source===ft||t?.source===Sr)||n||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},sp=({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:mr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),tn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Yw=({state:e})=>{let t=e.global.autoMode;return xe({state:e})&&!t||(t?tn({state:e}):sp({state:e})),e},op=({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),Or=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),zw=({state:e})=>{let t=Bu({state:e});return xe({state:e})&&!t||(t?Or({state:e}):op({state:e})),e},ds=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),rr(e,"showDialogueUI",void 0,t),e),ip=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),rr(e,"hideDialogueUI",void 0,t),e),Xw=e=>{let{state:t}=e;return Yu({state:t})?ds(e):ip(e),t},Cr=(e,t,n)=>(oa(e,t,n),qu(e),e.global.pendingEffects.push({name:"render"}),e),nn=(e,t,n,o,a)=>{let r=oa(e,t,n);return e.global.pendingEffects.push({name:"render"}),rr(e,o,{value:r},a),e},Gw=({state:e},t)=>Cr(e,"dialogueTextSpeed",t?.value),Hw=({state:e},t)=>(Cr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:mr({state:e})}}),e),Kw=({state:e},t)=>(Cr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:mr({state:e})}}),e),Ww=({state:e},t)=>Cr(e,"skipUnseenText",t?.value),Jw=({state:e},t)=>Cr(e,"skipTransitionsAndAnimations",t?.value),Qw=({state:e},t)=>Cr(e,"soundVolume",t?.value),Zw=({state:e},t)=>Cr(e,"musicVolume",t?.value),eI=({state:e},t)=>Cr(e,"muteAll",t?.value),Ui=({state:e,rollbackActionBatchStack:t},n)=>nn(e,"saveLoadPagination",n?.value,"setSaveLoadPagination",t),Bi=({state:e,rollbackActionBatchStack:t})=>{let n=Ze(e,"saveLoadPagination")+1;return nn(e,"saveLoadPagination",n,"incrementSaveLoadPagination",t),e},Yi=({state:e,rollbackActionBatchStack:t})=>{let n=Ze(e,"saveLoadPagination")-1;return nn(e,"saveLoadPagination",n,"decrementSaveLoadPagination",t),e},zi=({state:e,rollbackActionBatchStack:t},n)=>nn(e,"menuPage",n?.value,"setMenuPage",t),Xi=({state:e,rollbackActionBatchStack:t},n)=>nn(e,"menuEntryPoint",n?.value,"setMenuEntryPoint",t),rI=({state:e})=>(e.global.pendingEffects=[],e),tI=({state:e},t)=>(e.global.pendingEffects.push(t),e),nI=({state:e},t)=>{if(he(e))return e;let n=t?.resourceId;return bu(e,n),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:n}}),e},sI=({state:e},t)=>{if(he(e))return e;let n=t?.resourceId,o=bu(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},ap=e=>e?.lines?.[0],lp=(e,{sectionId:t,resetStoryState:n=!1,screen:o})=>{let a=!!ju(o),r=Ee({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let s=ap(r);if(!s)return console.warn(`Section ${t} has no lines`),e;if(n&&!Jb(e,{queueRender:!a}))return e;let i=xe({state:e});n&&e.global.skipMode&&Or({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=ht(l),p=u.read;n||zr(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||$r(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:s.id},n?l.rollback=Wt({pointer:u.read}):ps(e,{sectionId:t,lineId:s.id})}let{activeInteraction:c}=rn(e,l?.pointers?.read,{screenTransition:o});return fs(e,i,c),e},oI=({state:e},t)=>{if(he(e))throw new Error("Cannot reset the story while a scene replay is active");return lp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},cp=e=>(e.global.accountViewedRegistry=ub(e.global.accountViewedRegistry),e.global.accountViewedRegistry),ms=(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)}))}})},up=(e,t)=>{ms(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:[]}}])},iI=(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=Ee({state:e},{sectionId:n});if(s?.lines){let i=s.lines.findIndex(c=>c.id===r.lastLineId),l=s.lines.findIndex(c=>c.id===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},zr=(e,t)=>{if(he(e)||e.global.accountViewedRegistry===void 0)return;iI(e,cp(e),t)&&up(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},aI=({state:e},t)=>(zr(e,t),e.global.pendingEffects.push({name:"render"}),e),lI=({state:e},t)=>{if(he(e))return e;let{resourceId:n}=t;if(e.global.accountViewedRegistry!==void 0){let o=cp(e);o.resources.find(r=>r.resourceId===n)||(o.resources.push({resourceId:n}),up(e,{sections:[],resources:[{resourceId:n}]}))}return e.global.pendingEffects.push({name:"render"}),e},tr=(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}"`)})},Gi=(e,t,n)=>{if(typeof n!="string"||n.length===0)throw new Error(`${e} requires a non-empty ${t}`)},ys=(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"}))},cI=({state:e},t)=>{let n="showImageGalleryVariant";tr(n,t,nb),Gi(n,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&Gi(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||Kt(e,s)||ys(e,{groupId:r.id,variantId:s.id,pageIndex:Math.floor(a/o.pageSize)}),e},pp=(e,t,n,o)=>{tr(o,t,Ki);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=Vi(e,s.variants,i,n);return l&&ys(e,{...r,variantId:l.id}),e},uI=({state:e},t)=>pp(e,t,-1,"moveToPreviousImageGalleryVariant"),pI=({state:e},t)=>pp(e,t,1,"moveToNextImageGalleryVariant"),fI=({state:e},t)=>{if(tr("clearImageGallerySelection",t,Ki),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return ys(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},fp=(e,t)=>{let n=e.projectData?.resources?.imageGallery;if(n===void 0)return e;let o=ca(n);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=ua(n,a);return t===r||ys(e,{groupId:null,variantId:null,pageIndex:t}),e},dI=({state:e},t)=>{if(tr("moveToImageGalleryPage",t,sb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return fp(e,t.pageIndex)},dp=(e,t,n,o)=>{tr(o,t,Ki);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let s=ua(a,e.global.imageGalleryNavigation)+n;return s<0?e:fp(e,s)},mI=({state:e},t)=>dp(e,t,1,"moveToNextImageGalleryPage"),yI=({state:e},t)=>dp(e,t,-1,"moveToPreviousImageGalleryPage"),yr=(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}"`)})},hI=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},We=e=>{e.global.pendingEffects.push({name:"render"})},mp=(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:us(e),operation:"pause"});let i=Qt(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},We(e)},gI=({state:e},t)=>{let n="playMusicRoomTrack";yr(n,t,ob),hI(n,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||pa(e,a)||mp(e,a),e},bI=({state:e},t)=>{yr("playMusicRoom",t,dt);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=Qt(e,s,s==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),We(e),e},wI=({state:e},t)=>{yr("pauseMusicRoom",t,dt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=Qt(e,"pause"),o.seekFallback=null,o.status="paused",We(e)),e},II=({state:e},t)=>{yr("stopMusicRoom",t,dt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=Qt(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,We(e)),e},vI=({state:e},t)=>{if(yr("seekMusicRoom",t,ib),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=Qt(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"),We(e),e},yp=(e,t,n,o)=>{yr(o,t,dt);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=Fi(e,a.tracks,s,n);return i&&mp(e,i),e},kI=({state:e},t)=>yp(e,t,-1,"playPreviousMusicRoomTrack"),AI=({state:e},t)=>yp(e,t,1,"playNextMusicRoomTrack"),PI=({state:e},t)=>{yr("clearMusicRoomSelection",t,dt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:us(e),operation:"resume"};return e.global.musicRoomPlayer={...cs({bgmPlayback:r}),pageIndex:a},We(e),e},hp=(e,t)=>{let n=e.projectData?.resources?.musicRoom;if(!n||t>=fa(n))return e;let o=e.global.musicRoomPlayer,a=da(n,o);return t===a||(o.pageIndex=t,We(e)),e},EI=({state:e},t)=>{if(yr("moveToMusicRoomPage",t,ab),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return hp(e,t.pageIndex)},gp=(e,t,n,o)=>{yr(o,t,dt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=da(a,e.global.musicRoomPlayer)+n;return r<0?e:hp(e,r)},xI=({state:e},t)=>gp(e,t,1,"moveToNextMusicRoomPage"),SI=({state:e},t)=>gp(e,t,-1,"moveToPreviousMusicRoomPage"),Yr=e=>{let t=he(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(),Hb(e,n),e.global.pendingEffects.push({name:"render"}),!0},OI=({state:e},t)=>{let n="startSceneReplay";if(tr(n,t,lb),Gi(n,"sceneId",t.sceneId),he(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||!Ku(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=Xb(e);Gb(e);let u=ia({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 Mu(e,u),e.contexts.push(u),rn(e,u.pointers.read),e},bp=({state:e},t)=>{tr("finishSceneReplay",t,Wi);let o=he(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Rr(e)?.rollback?.isRestoring===!0)return e;let r=Le({state:e})?.pointer,{sceneId:s}=dr(e.projectData,r?.sectionId);return!(typeof s=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===s))||(e.global.accountReplayRegistry=pb(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(s))||(e.global.accountReplayRegistry.sceneIds.push(s),ms(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[s]}}]),e.global.pendingEffects.push({name:"render"})),e},RI=({state:e},t)=>(tr("exitSceneReplay",t,Wi),Yr(e),e),wp=(e,t)=>{let n=e.projectData?.resources?.sceneReplay;if(!n||t>=ma(n))return e;let o=ya(n,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},$I=({state:e},t)=>{if(tr("moveToSceneReplayPage",t,cb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return wp(e,t.pageIndex)},Ip=(e,t,n,o)=>{tr(o,t,Wi);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=ya(a,e.global.sceneReplayNavigation)+n;return r<0?e:wp(e,r)},CI=({state:e},t)=>Ip(e,t,1,"moveToNextSceneReplayPage"),_I=({state:e},t)=>Ip(e,t,-1,"moveToPreviousSceneReplayPage"),hs=(e,t)=>{let n=e.global.musicRoomPlayer;return!q(t)||t.id!==rb||n.trackId===null||!n.playback||t.commandId!==n.playback.commandId?null:n},wa=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,vp=(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,We(e)),e),jI=({state:e},t)=>{let n=hs(e,t);return!n||n.readiness!=="loading"||!wa(t)?e:vp(e,n,t,{readiness:"ready"})},NI=({state:e},t)=>{let n=hs(e,t);return!n||n.readiness!=="ready"||!wa(t)||n.status==="stopped"&&t.positionMs!==0||n.status==="ended"&&t.positionMs!==t.durationMs?e:vp(e,n,t)},TI=({state:e},t)=>{let n=hs(e,t);return!n||n.readiness!=="ready"||n.status!=="playing"||!wa(t)||t.positionMs!==t.durationMs||(n.status="ended",n.positionMs=t.positionMs,n.durationMs=t.durationMs,n.seekFallback=null,We(e)),e},DI=({state:e},t)=>{let n=hs(e,t);if(!n||typeof t.errorCode!="string"||!tb.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&&We(e),e}return n.readiness="error",n.status="stopped",n.positionMs=0,n.seekFallback=null,We(e),e},kp=({state:e,rollbackActionBatchStack:t},n)=>{let o=gb(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,f=e.global.nextLineConfig.auto?.trigger,d=e.global.nextLineConfig.auto?.delay,m=xe({state:e});return!u&&(a!==void 0&&(p!==s||f!==i||d!==l))&&(!m&&p===!0&&(f==="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"}),rr(e,"setNextLineConfig",n,t),e},LI=({state:e},t)=>{if(he(e))throw new Error("Cannot save while a scene replay is active");let n=t?.slotId;wu(n,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=Xr(n),s=V(e.contexts);s?.forEach(c=>{ht(c),Vu(c.rollback),kb(c.rollback,e.projectData)});let i={contexts:s},l={formatVersion:hu,slotId:Pu(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},MI=({state:e},t)=>{if(he(e))throw new Error("Cannot load while a scene replay is active");let n=t?.slotId;wu(n,"loadSlot");let o=Xr(n),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=Nb(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=Jt(),e.global.overlayStack=[],e.global.isLineCompleted=!0,mt(e),yt(e),Zi(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},qI=({state:e},t)=>{if(he(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:n}=t;Au(n),_t(n),jt(n),Nt(n),qr(n?.resources?.variables??{}),si(n);let o=xb(n),a=o?e.contexts?.map((s,i)=>_u(V(s),n,i)):void 0,r=o?Ab(e.global.saveSlots,n):void 0;if(e.projectData=n,e.global.imageGalleryNavigation=Hi(),e.global.sceneReplayNavigation=Ji(),Zi(e),o){let s=n?.resources?.variables??{},{globalVariablesDefaultValues:i}=Mn(n??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Tt(e.global.variables,s,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return mt(e),yt(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},VI=({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),qu(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!xe({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:mr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},FI=({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&&!Ee({state:e},{sectionId:n}))return console.warn(`Section not found: ${n}`),e;let s=Ee({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=ht(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=rn(e,c.read);return fs(e,l,u),e},UI=({state:e,rollbackActionBatchStack:t},n)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return ds({state:e,rollbackActionBatchStack:t}),e;let o=xe({state:e});if(o?.source===ft&&n?.bypassChoice!==!0||o?.source===Sr&&n?._interactionSource!==Sr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,he(e)?.sceneReplay.exitOnLineCompleted)return Yr(e),e;let d=Le({state:e})?.pointer,m=d?.sectionId,b=d?.lineId;m&&b&&zr(e,{sectionId:m,lineId:b}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:mr({state:e})}});let h=e.global.nextLineConfig,y=Ee({state:e},{sectionId:m});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===b?Mi(e):h?.auto?.enabled&&!o&&h.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:h.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(he(e)?.sceneReplay.finishOnNextAdvance)return Yr(e),e;let r=Le({state:e})?.pointer,s=r?.sectionId,i=Ee({state:e},{sectionId:s}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(f=>f.id===r?.lineId)+1;if(p<c.length){let f=c[p],d=!Ze(e,"skipUnseenText");if(e.global.skipMode&&d&&!la({state:e},{sectionId:s,lineId:f.id}))return Or({state:e}),e;if(l&&!l.rollback&&$r(l,{compatibilityAnchor:!0}),l){let b=ht(l),h=b.read?.lineId;h&&s&&zr(e,{sectionId:s,lineId:h}),b.read={sectionId:s,lineId:f.id}}ps(e,{sectionId:s,lineId:f.id}),Qi(e);let{activeInteraction:m}=rn(e,{sectionId:s,lineId:f.id});fs(e,o,m)}else{if(he(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Yr(e),e;e.global.autoMode&&tn({state:e}),e.global.skipMode&&Or({state:e}),Mi(e)}return e},BI=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,he(e)?.sceneReplay.exitOnLineCompleted)return Yr(e),e;let n=xe({state:e});e.global.autoMode&&!n&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:mr({state:e})}});let o=Le({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&zr(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},YI=({state:e},t)=>lp(e,{sectionId:t?.sectionId,screen:t?.screen}),zI=({state:e,rollbackActionBatchStack:t},n)=>{let o=n?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return ds({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:mr({state:e})}}),e;let a=xe({state:e});if(a?.source===ft&&n?.bypassChoice!==!0||a?.source===Sr&&n?._interactionSource!==Sr||a&&a.source!==ft&&a.source!==Sr)return e;let r=he(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(Yr(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let s=Le({state:e})?.pointer,i=s?.sectionId,l=Ee({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],f=u.findIndex(d=>d.id===s?.lineId)+1;if(f<u.length){let d=u[f],m=!Ze(e,"skipUnseenText");if(e.global.skipMode&&m&&!la({state:e},{sectionId:i,lineId:d.id})&&(Or({state:e}),!o))return e;if(c&&!c.rollback&&$r(c,{compatibilityAnchor:!0}),c){let h=ht(c),y=h.read?.lineId;y&&i&&zr(e,{sectionId:i,lineId:y}),h.read={sectionId:i,lineId:d.id}}ps(e,{sectionId:i,lineId:d.id}),Qi(e);let{activeInteraction:b}=rn(e,{sectionId:i,lineId:d.id});fs(e,a,b)}else{if(he(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),Yr(e),e;e.global.autoMode&&tn({state:e}),e.global.skipMode&&Or({state:e}),Mi(e)}return e},Ia=(e,t={})=>{let n=Zt({state:e});return!n||t.formKey&&t.formKey!==n.key||t.formId&&t.formId!==n.id?null:n},XI=(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(Re(n))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(n?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Dt(o,t.variableId),Lt(a,"set",t.variableId),he(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:n,scope:o}},GI=(e,t)=>({id:e.id,key:e.key,valid:!0,values:V(t),fields:V(e.fields),fieldList:V(e.fieldList)}),HI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Le({state:e})?.pointer,n=t?.sectionId,o=t?.lineId;n&&o&&zr(e,{sectionId:n,lineId:o})},KI=({state:e},t={})=>{let n=Ia(e,t),o=t.field;if(!n?.fields?.[o])return e;let a=Tu(e,n.key),r=as(t.value),s=n.fields[o],i=na(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},WI=({state:e,rollbackActionBatchStack:t},n={})=>{let o=Ia(e,n);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=Tu(e,o.key);a.submitted=!0;let r={},s={};if(Object.entries(o.fields).forEach(([f,d])=>{let m=Object.prototype.hasOwnProperty.call(a.values,f)?a.values[f]:d.value,b=na(d,m);a.touched[f]=!0,b&&(s[f]=b),r[f]=Nu(d,m)}),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(([f,d])=>{let{scope:m}=XI(e,d),b=m==="context"?i.variables:e.global.variables,h=r[f];b[d.variableId]=Vn(b[d.variableId],"set",h),m==="context"&&(l=!0,u.push({variableId:d.variableId,op:"set",value:h})),(m==="device"||m==="account")&&c.push({scope:m,path:`variables.${d.variableId}`,op:"set",value:V(b[d.variableId])})}),l&&rr(e,"updateVariable",{id:"submitForm",operations:u},t),ms(e,c);let p=GI(o,r);return HI(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},JI=({state:e},t={})=>{let n=Ia(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"}},QI=({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:f})=>{let d=e.projectData.resources?.variables?.[c],m=d?.scope,b=d?.type;if(Re(d))throw new Error(`Cannot update computed variable: ${c}`);if(d?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Dt(m,c),Lt(b,u,c),qn(b,u,p,c,{roundTo:f}),he(e)&&m!=="context")throw new Error(`Cannot update ${m}-scoped variable "${c}" while a scene replay is active`);let h=m==="context"?r.variables:e.global.variables;if(m==="context"){s=!0;let y={variableId:c,op:u,value:p};f!==void 0&&(y.roundTo=f),l.push(y)}h[c]=Vn(h[c],u,p,{roundTo:f}),(m==="device"||m==="account")&&i.push({scope:m,path:`variables.${c}`,op:"set",value:V(h[c])})}),s&&rr(e,"updateVariable",{id:o,operations:l},t),ms(e,i),e.global.pendingEffects.push({name:"render"}),e},Xe=e=>(t,n)=>e({state:t},n),Ap=e=>({variables:st({variables:{...e.global?.variables??{},...Rr(e)?.variables??{}},runtime:Ar(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Ar(e)}),ZI=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")},e0=(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")},r0=(e,t,n,o)=>{ZI(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(e0(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Ct(r.when,{...Ap(e),...n?.bindings??{}}))){va(e,r.actions,n,[...o,"branches",String(a),"actions"]);return}}},t0=(e,t,n,o)=>{let a=n?.checkpoint;if(a?.randomOutcomeVersion!==fr)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=Bn(V(l.result),l.type);if(c.type==="integer"){if(!Su(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}`);qi(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}`);va(e,u,n,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},n0={conditional:{replayLine:r0},random:{replayLine:t0},updateVariable:{recordSources:[xr],replayLine:qi,replayRecorded:qi,persistInSaveSlot:!0},setNextLineConfig:{replayLine:Xe(kp)},setSaveLoadPagination:{recordSources:[xr],replayLine:Xe(Ui),replayRecorded:Xe(Ui),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[xr],replayLine:Xe(Bi),replayRecorded:Xe(Bi),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[xr],replayLine:Xe(Yi),replayRecorded:Xe(Yi),persistInSaveSlot:!0},setMenuPage:{recordSources:[xr],replayLine:Xe(zi),replayRecorded:Xe(zi),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[xr],replayLine:Xe(Xi),replayRecorded:Xe(Xi),persistInSaveSlot:!0},finishSceneReplay:{replayLine:Xe(bp)}},gs=e=>n0[e]??null,s0=e=>gs(e)?.persistInSaveSlot===!0,o0=(e,t)=>{let n=gs(e)?.recordSources;return Array.isArray(n)&&n.includes(t)},i0=(e,t,n)=>{gs(t)?.replayRecorded?.(e,n)},a0=(e,t,n,o,a)=>{let r=gs(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,n,o,a);return}let s=o?.bindings??{},i=Mt({[t]:n},{...Ap(e),...s})[t];r.replayLine(e,i)},va=(e,t,n,o)=>{let a=Yn(t);Xn(a);for(let[r,s]of a)a0(e,r,s,n,[...o,r])},l0=e=>e?.returnable!==!1,Pp=(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(l0(e.timeline[o])&&(n-=1,n===0))return o;return-1},Ep=({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=Pp(a,n);if(r<0||r>=a.timeline.length)return null;let s=a.timeline[r];return{sectionId:s.sectionId,lineId:s.lineId}},xp=({state:e})=>Ep({state:e},{offset:-1})!==null,c0=({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=$r(o,{compatibilityAnchor:!o.rollback}),r=Pp(a,n);return r<0||r>=a.timeline.length?e:Uu(e,r)},u0=({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=$r(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:Uu(e,i)},p0=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),Li=(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]},mu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,yu=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},f0=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Sp=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}},ka=e=>JSON.stringify(Sp(e)),d0=({actionName:e,args:t,state:n,previousState:o})=>{let a=mu(o),r=mu(n);if(!f0(a,r)||o.contexts?.length!==n.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&yu(o)!==yu(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=dr(n.projectData,s.sectionId).section,l=ap(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??{},Xr(i))}return!1},m0=({actionName:e,args:t,state:n,transactionalMetadata:o,previousState:a})=>{if(d0({actionName:e,args:t,state:n,previousState:a})){let u=Li(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:ka(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)&&Li(o,"autoSessionId"),n.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||s&&a.global.skipMode!==!0)&&Li(o,"skipSessionId")},y0=({state:e,transactionalMetadata:t})=>{let n=t.rollbackAuthoredSuppression;n&&(n.lineEntryId!==t.lineEntryId||n.configKey!==ka(e))&&(t.rollbackAuthoredSuppression=null)},h0=({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=Sp(e),i=t.rollbackAuthoredSuppression,l=!n&&s.enabled&&(s.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===ka(e)),c=a?tp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:Di({text:c,baseDelay:Ze(e,"autoForwardDelay"),speed:Ze(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}},g0=({playbackOwnership:e})=>e.lineEntryId,Op=(e,t={})=>{let n=lw(e),o=[],a=t.createPlaybackOwnership??p0;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return $l(n,{selectPendingEffects:uw,selectSkipMode:Bu,selectAutoMode:pw,selectIsChoiceVisible:Qu,selectIsFormVisible:yw,selectActiveInteraction:xe,selectActiveForm:Zt,selectDialogueUIHidden:Yu,selectDialogueHistory:zu,selectConfirmDialog:mw,selectIsLineAccountViewed:la,selectIsResourceAccountViewed:gw,selectImageGalleryConfig:bw,selectImageGallery:Xu,selectMusicRoomConfig:Iw,selectMusicRoom:Hu,selectSceneReplayConfig:vw,selectSceneReplay:Wu,selectIsSceneReplayActive:kw,selectActiveSceneReplayEntry:Aw,selectNextLineConfig:Pw,selectSystemState:Ew,selectAchievements:xw,selectAchievement:Sw,selectSaveSlotMap:Zu,selectSaveSlots:jw,selectSaveSlot:Ow,selectLocalizationPackages:ep,selectRuntime:ha,selectRuntimeValue:Rw,selectAllVariables:ga,selectCurrentPointer:Le,selectSection:Ee,selectCurrentLine:en,selectPresentationState:rp,selectAutoForwardTimerDelay:mr,selectPresentationChanges:$w,selectSectionLineChanges:_w,selectSaveSlotPage:ba,selectCurrentPageSlots:Nw,selectRenderState:Dw,selectOverlayStack:cw,selectLineIdByOffset:Ep,selectCanRollback:xp,selectRollbackCursor:Zb,selectDesiredPlaybackTimers:h0,selectPlaybackLineEntryId:g0,startAutoMode:sp,stopAutoMode:tn,toggleAutoMode:Yw,startSkipMode:op,stopSkipMode:Or,toggleSkipMode:zw,showDialogueUI:ds,hideDialogueUI:ip,toggleDialogueUI:Xw,setDialogueTextSpeed:Gw,setAutoForwardDelay:Hw,setAutoForwardSpeed:Kw,setSkipUnseenText:Ww,setSkipTransitionsAndAnimations:Jw,setSoundVolume:Qw,setMusicVolume:Zw,setMuteAll:eI,setSaveLoadPagination:Ui,incrementSaveLoadPagination:Bi,decrementSaveLoadPagination:Yi,setMenuPage:zi,setMenuEntryPoint:Xi,showConfirmDialog:Lw,hideConfirmDialog:Mw,resetStoryAtSection:oI,clearPendingEffects:rI,appendPendingEffect:tI,completeAchievement:nI,setAchievementProgress:sI,beginRollbackActionBatch:tw,endRollbackActionBatch:nw,ensureRandomReplayOccurrence:sw,recordRandomOutcome:ow,markRollbackCheckpointTransient:ew,markSavedRollbackCheckpointTransient:rw,recordCurrentDialogueHistory:dw,addViewedLine:aI,addViewedResource:lI,showImageGalleryVariant:cI,moveToPreviousImageGalleryVariant:uI,moveToNextImageGalleryVariant:pI,clearImageGallerySelection:fI,moveToImageGalleryPage:dI,moveToNextImageGalleryPage:mI,moveToPreviousImageGalleryPage:yI,playMusicRoomTrack:gI,playMusicRoom:bI,pauseMusicRoom:wI,stopMusicRoom:II,seekMusicRoom:vI,playPreviousMusicRoomTrack:kI,playNextMusicRoomTrack:AI,clearMusicRoomSelection:PI,moveToMusicRoomPage:EI,moveToNextMusicRoomPage:xI,moveToPreviousMusicRoomPage:SI,musicRoomSoundReady:jI,musicRoomSoundProgress:NI,musicRoomSoundComplete:TI,musicRoomSoundError:DI,startSceneReplay:OI,finishSceneReplay:bp,exitSceneReplay:RI,moveToSceneReplayPage:$I,moveToNextSceneReplayPage:CI,moveToPreviousSceneReplayPage:_I,setNextLineConfig:kp,saveSlot:LI,loadSlot:MI,updateProjectData:qI,updateLocalizationPackage:VI,sectionTransition:YI,jumpToLine:FI,nextLine:UI,markLineCompleted:BI,rollbackToLine:u0,rollbackByOffset:c0,pushOverlay:qw,popOverlay:Vw,replaceLastOverlay:Fw,clearOverlays:Uw,updateFormField:KI,submitForm:WI,cancelForm:JI,updateVariable:QI,nextLineFromSystem:zI},{createTransactionalMetadata:a,updateTransactionalMetadata:m0,finalizeTransactionalMetadata:y0,transformActionFirstArgument:(s,i)=>({state:s,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(s,i)=>({state:s,playbackOwnership:i})})};var b0="route-engine",w0="projectPersistence";var $p=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),Ie=e=>Object.prototype.toString.call(e)==="[object Object]",Rp="variables.",I0=(e={})=>{let t=Ie(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!Ie(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)}:!Ie(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},v0=(e={})=>{let t=Ie(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(n=>typeof n=="string"||typeof n=="number"?{sectionId:String(n)}:!Ie(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)}:!Ie(n)||typeof n.resourceId!="string"||n.resourceId.length===0?null:{resourceId:n.resourceId}).filter(Boolean)}},k0=(e,t)=>{let n=v0(e),o=I0(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}},A0=(e={})=>{let t=Ie(e)?e:{},n=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(n.filter(o=>typeof o=="string"&&o.length>0))]}},P0=(e,t)=>{let n=A0(e),o=Ie(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...n.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},Cp=(e={})=>{let t=Ie(e)?e:{};return{saveSlots:Ie(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:Ie(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:Ie(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:Ie(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:Ie(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:Ie(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},E0=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,n)=>{if(!Ie(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${n}] entry.`);let o=t.path?.startsWith(Rp)?t.path.slice(Rp.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(!Ie(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}].`)})},x0=(e,t)=>{let n={};return E0(t).forEach(o=>{if(o.path==="viewedRegistry"){n.accountViewedRegistry=k0(n.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){n.accountReplayRegistry=P0(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},gt=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},S0=e=>{let t=gt(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},O0=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},R0=({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}".`))}}),$0=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.`))}})},sn=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))},f=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${n}" before updating IndexedDB.`))},c.onsuccess=()=>{let d=Cp(c.result),m=typeof o=="function"?o(d):o,b={namespace:n,version:1,...$p(),...d,...m},h=l.put(b);h.onerror=()=>{p(h.error??new Error(`Failed to persist namespace "${n}" to IndexedDB.`))}},i.oncomplete=()=>{f()},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}".`))}})},C0=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=f=>{c||(c=!0,r(f))},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}".`))}})},Aa=(e={})=>{let{indexedDB:t,databaseName:n=b0,objectStoreName:o=w0,namespace:a}=e,r=O0(t),s=S0(a),i=R0({indexedDB:r,databaseName:n,objectStoreName:o});return{namespace:s,load:async()=>{let l=await $0({databasePromise:i,objectStoreName:o,namespace:s});return{...$p(),...Cp(l)}},clear:async()=>C0({databasePromise:i,objectStoreName:o,namespace:s}),saveSlots:async l=>sn({databasePromise:i,objectStoreName:o,namespace:s,patch:{saveSlots:Ie(l)?l:{}}}),saveGlobalDeviceVariables:async l=>sn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalDeviceVariables:Ie(l)?l:{}}}),saveGlobalAccountVariables:async l=>sn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalAccountVariables:Ie(l)?l:{}}}),saveGlobalRuntime:async l=>sn({databasePromise:i,objectStoreName:o,namespace:s,patch:{globalRuntime:Ie(l)?l:{}}}),applyScopedDataUpdates:async l=>sn({databasePromise:i,objectStoreName:o,namespace:s,patch:c=>x0(c,l)})}},_0=Aa;var Tp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Pa=Object.freeze({volume:100,pan:0,playbackRate:1}),j0=["src","startAt","endAt","startDelayMs"],_p=(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]},N0=(e,t)=>e?.id===t?.id&&j0.every(n=>(e?.[n]??(n==="endAt"?null:0))===(t?.[n]??(n==="endAt"?null:0))),T0=(e,t)=>JSON.stringify(e)===JSON.stringify(t),D0=(e,t)=>{let n=e?.playback?.speed??1;if(typeof n!="number"||!Number.isFinite(n)||n<=0)throw new Error(`[${t}.audioEffects.playback.speed] Audio effect speed must be a finite number greater than 0.`);return n},L0=(e,t,n)=>({...Tp(e,"startValue")?{startValue:e.startValue}:{},value:e.value==="target"?n:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),jp=(e,t,n,o)=>{if(e)return{...t==="enter"?{initialValue:0}:{},keyframes:[{value:t==="exit"?0:o,delay:(e.delay??0)/n,duration:e.duration/n,easing:e.easing??"linear"}]}},M0=({property:e,authored:t,target:n,speed:o,resourcePath:a})=>{let r=t.keyframes.at(-1);if(r?.value!=="target"||r.relative===!0)throw new Error(`[${a}.tween.${e}.keyframes] The final keyframe must use the absolute value "target".`);return{keyframes:t.keyframes.map(s=>L0(s,o,n))}},Np=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),Dp=({occurrence:e,resources:t={},previousChannel:n,nextChannel:o})=>{if(!e?.selection)return null;let a=e.selection,r=e.actionPath??"bgm",s=a.resourceId,i=`resources.audioEffects.${s}`,l=t.audioEffects?.[s];if(!l)throw new Error(`[${r}.audioEffects.resourceId]
|
|
3
|
+
[${i}] Unknown audio effect resource "${s}".`);let c=D0(a,r),u=_p(n,r),p=_p(o,r);if(!u&&!p)return null;if(u&&p&&u.id!==p.id)throw new Error(`[${r}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let f=u?.id??p.id,d=N0(u,p),m=T0(u,p);if(l.type==="transition"){if(d){if(m)return null;throw new Error(`[${r}.audioEffects]
|
|
4
|
+
[${i}] Audio effect resource "${s}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let h={},y=jp(u?l.prev?.fade:void 0,"exit",c,0),w=jp(p?l.next?.fade:void 0,"enter",c,p?.volume??Pa.volume);return y&&(h.exit=y),w&&(h.enter=w),Object.keys(h).length===0?null:{...Np(e,f),properties:{volume:h}}}if(l.type!=="update")throw new Error(`[${i}.type] Unsupported audio effect type "${l.type}".`);if(!u||!p||!d)throw new Error(`[${r}.audioEffects]
|
|
5
|
+
[${i}] Audio effect resource "${s}" has type "update", but the BGM action changes source identity. Use a transition resource.`);if(m)return null;let b={};for(let h of["volume","pan","playbackRate"]){if(!Tp(l.tween,h))continue;let y=u[h]??Pa[h],w=p[h]??Pa[h];Object.is(y,w)||(b[h]={update:M0({property:h,authored:l.tween[h],target:w,speed:c,resourcePath:i})})}if(Object.keys(b).length===0)throw new Error(`[${r}.audioEffects]
|
|
6
|
+
[${i}] Audio update resource "${s}" does not animate a BGM sound property changed by this action.`);return{...Np(e,f),properties:b}};var Xp=Gp;var q0={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"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Je=Object.prototype.hasOwnProperty,V0={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 qe(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 m={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),s++}if(e.x!==void 0){let d=e.x;if(typeof d=="number"){if(d<0||isNaN(d)){let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.y!==void 0){let d=e.y;if(typeof d=="number"){if(d<0||isNaN(d)){let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.quality!==void 0){let d=e.quality;if(typeof d=="number"){if(d<1||isNaN(d)){let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[m]:r.push(m),s++}}else{let m={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),s++}}if(e.kernelSize!==void 0){let d=e.kernelSize;if(!(typeof d=="number"&&!(d%1)&&!isNaN(d))){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[m]:r.push(m),s++}if(!(d===5||d===7||d===9||d===11||d===13||d===15)){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:V0.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[m]:r.push(m),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 qe.errors=r,s===0}var F0={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},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)){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:F0.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 ws.errors=r,s===0}function ce(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&&(ws(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?ws.errors:r.concat(ws.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 ce.errors=r,s===0}function Is(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(!Je.call(q0.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&&(qe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),e.animations!==void 0&&(ce(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 Is.errors=r,s===0}function Gp(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Is(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Is.errors:r.concat(Is.errors),s=r.length),Gp.errors=r,s===0}var Hp=Kp;var qp={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/audioSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},Vp={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0}},required:["id","resourceId"],additionalProperties:!1},je=Mp().default;function Me(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(!Je.call(Vp.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(je(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(je(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:Vp.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 Me.errors=r,s===0}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!=="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 vs.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.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(je(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&&(vs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?vs.errors:r.concat(vs.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 ks.errors=r,s===0}function As(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 f=p===s;if(f){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,m=!0,b=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 h=b===s;if(s=d,r!==null&&(d?r.length=d:r=null),h){let y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let g={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),s++}var h=y===s;m=h}if(!m){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(!Je.call(qp.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 g=0;g<w;g++)Me(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Me.errors:r.concat(Me.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:qp.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&&(ks(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?ks.errors:r.concat(ks.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 As.errors=r,s===0}function Kp(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return As(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?As.errors:r.concat(As.errors),s=r.length),Kp.errors=r,s===0}var Wp=Jp;var U0={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"},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 Ps(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],f=s,d=!0,m=s;if(p&&typeof p=="object"&&!Array.isArray(p)){let b;if(p.sprites===void 0&&(b="sprites")){let h={};r===null?r=[h]:r.push(h),s++}}var i=m===s;if(s=f,r!==null&&(f?r.length=f:r=null),i){let b=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=b===s;d=i}if(!d){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),s++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[b]:r.push(b),s++}for(let b in p)if(!Je.call(U0.properties.items.items.properties,b)){let h={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[h]:r.push(h),s++}if(p.id!==void 0&&typeof p.id!="string"){let b={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let b={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(p.x!==void 0&&typeof p.x!="number"){let b={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.y!==void 0&&typeof p.y!="number"){let b={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let b={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let b={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let b={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let b={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let b={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let b={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),s++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let b={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.originX!==void 0&&typeof p.originX!="number"){let b={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.originY!==void 0&&typeof p.originY!="number"){let b={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}if(p.alpha!==void 0){let b=p.alpha;if(typeof b=="number"){if(b>1||isNaN(b)){let h={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=[h]:r.push(h),s++}if(b<0||isNaN(b)){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(p.opacity!==void 0){let b=p.opacity;if(typeof b=="number"){if(b>1||isNaN(b)){let h={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=[h]:r.push(h),s++}if(b<0||isNaN(b)){let h={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=[h]:r.push(h),s++}}else{let h={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),s++}}if(p.blur!==void 0&&(qe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),p.sprites!==void 0){let b=p.sprites;if(Array.isArray(b)){let h=b.length;for(let y=0;y<h;y++){let w=b[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let g in w)if(!(g==="id"||g==="resourceId"||g==="animationName"||g==="animationSpeed"||g==="loop")){let E={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(w.id!==void 0&&typeof w.id!="string"){let g={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=[g]:r.push(g),s++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let g={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=[g]:r.push(g),s++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let g={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=[g]:r.push(g),s++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let g={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=[g]:r.push(g),s++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let g={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=[g]:r.push(g),s++}}else{let g={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=[g]:r.push(g),s++}}}else{let h={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[h]:r.push(h),s++}}p.animations!==void 0&&(ce(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.errors),s=r.length))}else{let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),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 Ps.errors=r,s===0}function Jp(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ps(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ps.errors:r.concat(Ps.errors),s=r.length),Jp.errors=r,s===0}var Qp=Zp;function Es(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 f={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),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 f=p.click;if(!(f&&typeof f=="object"&&!Array.isArray(f))){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 f={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),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&&(ce(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 Es.errors=r,s===0}function Zp(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Es(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Es.errors:r.concat(Es.errors),s=r.length),Zp.errors=r,s===0}var ef=rf;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!=="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 xs.errors=r,s===0}function rf(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),rf.errors=r,s===0}var tf=nf;function Ss(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 Ss.errors=r,s===0}function nf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Ss(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Ss.errors:r.concat(Ss.errors),s=r.length),nf.errors=r,s===0}var sf=of;var Fp={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 Os(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(!Je.call(Fp.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&&(ce(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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:Fp.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 f=c[p];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.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(f.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 f)if(!(d==="id"||d==="resourceId"||d==="animationName"||d==="animationSpeed"||d==="loop")){let m={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=[m]:r.push(m),s++}if(f.id!==void 0&&typeof f.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(f.resourceId!==void 0&&typeof f.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(f.animationName!==void 0&&typeof f.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(f.animationSpeed!==void 0&&typeof f.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(f.loop!==void 0&&typeof f.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&&(ce(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 Os.errors=r,s===0}function of(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Os(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Os.errors:r.concat(Os.errors),s=r.length),of.errors=r,s===0}var af=lf;function Rs(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&&(ce(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 Rs.errors=r,s===0}function lf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Rs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Rs.errors:r.concat(Rs.errors),s=r.length),lf.errors=r,s===0}var cf=uf;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)){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&&(ce(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 $s.errors=r,s===0}function uf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return $s(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?$s.errors:r.concat($s.errors),s=r.length),uf.errors=r,s===0}var pf=ff;function Cs(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&&(qe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),e.animations!==void 0&&(ce(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 Cs.errors=r,s===0}function ff(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return Cs(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),s=r.length),ff.errors=r,s===0}var df=mf;var Up={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};function _s(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 f=0;f<p;f++)Me(u[f],{instancePath:t+"/items/"+f,parentData:u,parentDataProperty:f,rootData:a})||(r=r===null?Me.errors:r.concat(Me.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 f=0;f<p;f++){let d=u[f];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let m={instancePath:t+"/channels/"+f,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[m]:r.push(m),s++}if(d.sounds===void 0){let m={instancePath:t+"/channels/"+f,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[m]:r.push(m),s++}for(let m in d)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="applyMode"||m==="sounds")){let b={instancePath:t+"/channels/"+f,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),s++}if(d.id!==void 0){let m=d.id;if(typeof m=="string"){if(je(m)<1){let b={instancePath:t+"/channels/"+f+"/id",schemaPath:"#/properties/channels/items/properties/id/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+"/channels/"+f+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}}if(d.volume!==void 0){let m=d.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let b={instancePath:t+"/channels/"+f+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[b]:r.push(b),s++}if(m<0||isNaN(m)){let b={instancePath:t+"/channels/"+f+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/channels/"+f+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(d.muted!==void 0&&typeof d.muted!="boolean"){let m={instancePath:t+"/channels/"+f+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(d.pan!==void 0){let m=d.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let b={instancePath:t+"/channels/"+f+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[b]:r.push(b),s++}if(m<-1||isNaN(m)){let b={instancePath:t+"/channels/"+f+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[b]:r.push(b),s++}}else{let b={instancePath:t+"/channels/"+f+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),s++}}if(d.loop!==void 0&&typeof d.loop!="boolean"){let m={instancePath:t+"/channels/"+f+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),s++}if(d.interruption!==void 0){let m=d.interruption;if(typeof m!="string"){let b={instancePath:t+"/channels/"+f+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(m==="immediate"||m==="loopEnd")){let b={instancePath:t+"/channels/"+f+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:Up.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(d.applyMode!==void 0){let m=d.applyMode;if(typeof m!="string"){let b={instancePath:t+"/channels/"+f+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),s++}if(!(m==="singleLine"||m==="persistent")){let b={instancePath:t+"/channels/"+f+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:Up.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[b]:r.push(b),s++}}if(d.sounds!==void 0){let m=d.sounds;if(Array.isArray(m)){let b=m.length;for(let h=0;h<b;h++)Me(m[h],{instancePath:t+"/channels/"+f+"/sounds/"+h,parentData:m,parentDataProperty:h,rootData:a})||(r=r===null?Me.errors:r.concat(Me.errors),s=r.length)}else{let b={instancePath:t+"/channels/"+f+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),s++}}}else{let m={instancePath:t+"/channels/"+f,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),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 _s.errors=r,s===0}function mf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return _s(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),s=r.length),mf.errors=r,s===0}var yf=hf;var Bp={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"},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 js(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 m=0;m<d;m++){let b=e[m];if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.text!==void 0&&typeof b.text!="string"){let h={instancePath:t+"/"+m+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(b.textStyleId!==void 0&&typeof b.textStyleId!="string"){let h={instancePath:t+"/"+m+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),s++}if(b.furigana!==void 0){let h=b.furigana;if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.text!==void 0&&typeof h.text!="string"){let y={instancePath:t+"/"+m+"/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(h.textStyleId!==void 0&&typeof h.textStyleId!="string"){let y={instancePath:t+"/"+m+"/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+"/"+m+"/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 h={instancePath:t+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),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 js.errors=r,s===0}function Ns(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 g={};r===null?r=[g]:r.push(g),s++}}var f=p===s;if(u=u||f,!u){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.type===void 0&&(E="type")){let k={};r===null?r=[k]:r.push(k),s++}}var f=w===s;if(u=u||f,!u){let E=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.resourceId===void 0&&(P="resourceId")){let v={};r===null?r=[v]:r.push(v),s++}}var f=E===s;if(u=u||f,!u){let P=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let O;if(e.layout===void 0&&(O="layout")){let T={};r===null?r=[T]:r.push(T),s++}}var f=P===s;if(u=u||f,!u){let O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.transformId===void 0&&(R="transformId")){let L={};r===null?r=[L]:r.push(L),s++}}var f=O===s;if(u=u||f,!u){let R=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let U;if(e.transform===void 0&&(U="transform")){let _={};r===null?r=[_]:r.push(_),s++}}var f=R===s;if(u=u||f,!u){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let X;if(e.x===void 0&&(X="x")){let re={};r===null?r=[re]:r.push(re),s++}}var f=U===s;if(u=u||f,!u){let X=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let se={};r===null?r=[se]:r.push(se),s++}}var f=X===s;if(u=u||f,!u){let M=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ue;if(e.anchorX===void 0&&(ue="anchorX")){let z={};r===null?r=[z]:r.push(z),s++}}var f=M===s;if(u=u||f,!u){let ue=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Q;if(e.anchorY===void 0&&(Q="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),s++}}var f=ue===s;if(u=u||f,!u){let Q=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let K;if(e.scaleX===void 0&&(K="scaleX")){let pe={};r===null?r=[pe]:r.push(pe),s++}}var f=Q===s;if(u=u||f,!u){let K=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let ie;if(e.scaleY===void 0&&(ie="scaleY")){let C={};r===null?r=[C]:r.push(C),s++}}var f=K===s;if(u=u||f,!u){let ie=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 f=ie===s;if(u=u||f,!u){let j=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let W;if(e.flipY===void 0&&(W="flipY")){let fe={};r===null?r=[fe]:r.push(fe),s++}}var f=j===s;if(u=u||f,!u){let W=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Se;if(e.rotation===void 0&&(Se="rotation")){let be={};r===null?r=[be]:r.push(be),s++}}var f=W===s;if(u=u||f,!u){let Se=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let ar={};r===null?r=[ar]:r.push(ar),s++}}var f=Se===s;if(u=u||f,!u){let me=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Fe;if(e.originY===void 0&&(Fe="originY")){let mn={};r===null?r=[mn]:r.push(mn),s++}}var f=me===s;if(u=u||f,!u){let Fe=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let It;if(e.layer===void 0&&(It="layer")){let vt={};r===null?r=[vt]:r.push(vt),s++}}var f=Fe===s;if(u=u||f,!u){let It=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let kt;if(e.alpha===void 0&&(kt="alpha")){let yn={};r===null?r=[yn]:r.push(yn),s++}}var f=It===s;if(u=u||f,!u){let kt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let At;if(e.opacity===void 0&&(At="opacity")){let hn={};r===null?r=[hn]:r.push(hn),s++}}var f=kt===s;if(u=u||f,!u){let At=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let Pt;if(e.blur===void 0&&(Pt="blur")){let gn={};r===null?r=[gn]:r.push(gn),s++}}var f=At===s;if(u=u||f,!u){let Pt=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let bn;if(e.animations===void 0&&(bn="animations")){let wn={};r===null?r=[wn]:r.push(wn),s++}}var f=Pt===s;u=u||f}}}}}}}}}}}}}}}}}}}}}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 m=s,b=!1,h=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=h===s;if(b=b||y,!b){let w=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let E={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[E]:r.push(E),s++}var y=w===s;b=b||y}if(b)s=m,r!==null&&(m?r.length=m: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&&(js(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?js.errors:r.concat(js.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 Ns.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)){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 Ts.errors=r,s===0}var B0={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 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(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(!Je.call(B0.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 Ds.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)){for(let p in e)if(p!=="items"){let f={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[f]:r.push(f),s++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let f=p.length;for(let d=0;d<f;d++){let m=p[d],b=s,h=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),s++}}var i=h===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=b,r!==null&&(b?r.length=b:r=null);let y=s,w=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.resourceId===void 0&&(v="resourceId")||m.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 g=s,E=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.text===void 0&&(v="text")||m.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),s++}}var c=E===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=g,r!==null&&(g?r.length=g:r=null);let k=s,P=s;if(m&&typeof m=="object"&&!Array.isArray(m)){let v;if(m.transformId===void 0&&(v="transformId")||m.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),s++}}var u=P===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(m&&typeof m=="object"&&!Array.isArray(m)){if(m.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 m)if(!Je.call(Bp.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(m.id!==void 0&&typeof m.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(m.animationName!==void 0&&typeof m.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(m.animationSpeed!==void 0&&typeof m.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(m.resourceId!==void 0&&typeof m.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(m.text!==void 0&&(Ns(m.text,{instancePath:t+"/items/"+d+"/text",parentData:m,parentDataProperty:"text",rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),s=r.length)),m.layout!==void 0&&(Ts(m.layout,{instancePath:t+"/items/"+d+"/layout",parentData:m,parentDataProperty:"layout",rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),s=r.length)),m.transformId!==void 0&&typeof m.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(m.transform!==void 0&&(Ds(m.transform,{instancePath:t+"/items/"+d+"/transform",parentData:m,parentDataProperty:"transform",rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),s=r.length)),m.x!==void 0&&typeof m.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(m.y!==void 0&&typeof m.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(m.anchorX!==void 0&&typeof m.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(m.anchorY!==void 0&&typeof m.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(m.scaleX!==void 0&&typeof m.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(m.scaleY!==void 0&&typeof m.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(m.flipX!==void 0&&typeof m.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(m.flipY!==void 0&&typeof m.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(m.rotation!==void 0&&typeof m.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(m.originX!==void 0&&typeof m.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(m.originY!==void 0&&typeof m.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(m.layer!==void 0){let v=m.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:Bp.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(m.alpha!==void 0){let v=m.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(m.opacity!==void 0){let v=m.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++}}m.blur!==void 0&&(qe(m.blur,{instancePath:t+"/items/"+d+"/blur",parentData:m,parentDataProperty:"blur",rootData:a})||(r=r===null?qe.errors:r.concat(qe.errors),s=r.length)),m.animations!==void 0&&(ce(m.animations,{instancePath:t+"/items/"+d+"/animations",parentData:m,parentDataProperty:"animations",rootData:a})||(r=r===null?ce.errors:r.concat(ce.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 f={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),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 Ls.errors=r,s===0}function hf(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),hf.errors=r,s===0}var gf=bf;var Y0={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 Ms(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 g={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[g]:r.push(g),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,f=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=f===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 m=s,b=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 h=b===s;if(h){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=m,r!==null&&(m?r.length=m: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 g=0;g<w;g++)Me(y[g],{instancePath:t+"/sounds/"+g,parentData:y,parentDataProperty:g,rootData:a})||(r=r===null?Me.errors:r.concat(Me.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:Y0.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 Ms.errors=r,s===0}function bf(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),bf.errors=r,s===0}var wf=If;var z0={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 qs(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 h={};r===null?r=[h]:r.push(h),s++}var u=c===s;if(s=i,r!==null&&(i?r.length=i:r=null),u){let h=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=h===s;l=u}if(!l){let h={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let p=s,f=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let h={};r===null?r=[h]:r.push(h),s++}var m=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let h=s,y=s,w=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.target===void 0&&(E="target")){let k={};r===null?r=[k]:r.push(k),s++}}var b=w===s;if(b){let E={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[E]:r.push(E),s++}else s=y,r!==null&&(y?r.length=y:r=null);var m=h===s;f=m}if(!f){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[h]:r.push(h),s++}if(e.name===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[h]:r.push(h),s++}if(e.description===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[h]:r.push(h),s++}for(let h in e)if(!(h==="type"||h==="target"||h==="name"||h==="description"||h==="lockedName"||h==="lockedDescription"||h==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),s++}if(e.type!==void 0){let h=e.type;if(typeof h!="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(!(h==="boolean"||h==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:z0.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 h=e.target;if(!(typeof h=="number"&&!(h%1)&&!isNaN(h))){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 h=="number"&&(h<1||isNaN(h))){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 h=e.name;if(typeof h=="string"){if(je(h)<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 h=e.description;if(typeof h=="string"){if(je(h)<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 h=e.lockedName;if(typeof h=="string"){if(je(h)<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 h=e.lockedDescription;if(typeof h=="string"){if(je(h)<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 h={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),s++}}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),s++}return qs.errors=r,s===0}function If(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),If.errors=r,s===0}var vf=kf;var X0={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 G0={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 Kr(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:G0.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 Kr.errors=r,s===0}function ee(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++)Kr(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Kr.errors:r.concat(Kr.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 ee.errors=r,s===0}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)){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&&(ee(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.x!==void 0&&(ee(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.y!==void 0&&(ee(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.scaleX!==void 0&&(ee(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.scaleY!==void 0&&(ee(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.rotation!==void 0&&(ee(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?ee.errors:r.concat(ee.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 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(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&&(ee(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.translateY!==void 0&&(ee(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.alpha!==void 0&&(ee(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.scaleX!==void 0&&(ee(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.scaleY!==void 0&&(ee(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?ee.errors:r.concat(ee.errors),s=r.length)),e.rotation!==void 0&&(ee(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?ee.errors:r.concat(ee.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 Fs.errors=r,s===0}function Gr(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&&(Fs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.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 Gr.errors=r,s===0}var bs={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"]}}]},H0={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{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)){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:H0.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 Us.errors=r,s===0}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.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++)Kr(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Kr.errors:r.concat(Kr.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 Bs.errors=r,s===0}function Ys(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 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.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=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,f=!0,d=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let g={};r===null?r=[g]:r.push(g),s++}var m=d===s;if(s=p,r!==null&&(p?r.length=p:r=null),m){let g=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 m=g===s;f=m}if(!f){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 b=s,h=!0,y=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let g={};r===null?r=[g]:r.push(g),s++}var w=y===s;if(s=b,r!==null&&(b?r.length=b:r=null),w){let g=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=g===s;h=w}if(!h){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++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let g={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[g]:r.push(g),s++}for(let g in e)if(!Je.call(bs.properties,g)){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.kind!==void 0){let g=e.kind;if(typeof g!="string"){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="single"||g==="sequence"||g==="composite")){let E={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:bs.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.texture!==void 0&&typeof e.texture!="string"){let g={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.textures!==void 0){let g=e.textures;if(Array.isArray(g)){if(g.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 E=g.length;for(let k=0;k<E;k++)if(typeof g[k]!="string"){let P={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),s++}}else{let E={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.items!==void 0){let g=e.items;if(Array.isArray(g)){if(g.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 E=g.length;for(let k=0;k<E;k++)Us(g[k],{instancePath:t+"/items/"+k,parentData:g,parentDataProperty:k,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),s=r.length)}else{let E={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),s++}}if(e.combine!==void 0){let g=e.combine;if(typeof g!="string"){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="max"||g==="min"||g==="multiply"||g==="add")){let E={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:bs.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.channel!==void 0){let g=e.channel;if(typeof g!="string"){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="red"||g==="green"||g==="blue"||g==="alpha")){let E={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:bs.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.softness!==void 0&&typeof e.softness!="number"){let g={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),s++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let g={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),s++}if(e.sample!==void 0&&typeof e.sample!="string"){let g={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}e.progress!==void 0&&(Bs(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),s=r.length))}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 Ys.errors=r,s===0}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!=="update"){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,E=s,k=s,P=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.prev===void 0&&(R="prev")){let L={};r===null?r=[L]:r.push(L),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 _={};r===null?r=[_]:r.push(_),s++}}var p=R===s;if(v=v||p,!v){let U=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let X;if(e.mask===void 0&&(X="mask")){let re={};r===null?r=[re]:r.push(re),s++}}var p=U===s;v=v||p}}if(v)s=P,r!==null&&(P?r.length=P:r=null);else{let R={};r===null?r=[R]:r.push(R),s++}var f=k===s;if(f){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=E,r!==null&&(E?r.length=E: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=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 d=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var h=b===s;if(s=d,r!==null&&(d?r.length=d:r=null),h){let g=s,E=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.tween===void 0&&(R="tween")){let L={};r===null?r=[L]:r.push(L),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=E,r!==null&&(E?r.length=E:r=null);let P=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 X={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[X]:r.push(X),s++}var w=U===s;v=v||w}}if(v)s=P,r!==null&&(P?r.length=P: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 h=g===s;m=h}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++}for(let g in e)if(!(g==="name"||g==="type"||g==="complete"||g==="tween"||g==="prev"||g==="next"||g==="mask")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(typeof g!="string"){let E={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),s++}if(!(g==="update"||g==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:X0.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}if(e.complete!==void 0){let g=e.complete;if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.payload!==void 0){let E=g.payload;if(!(E&&typeof E=="object"&&!Array.isArray(E))){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 E={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(Vs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),s=r.length)),e.prev!==void 0&&(Gr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Gr.errors:r.concat(Gr.errors),s=r.length)),e.next!==void 0&&(Gr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Gr.errors:r.concat(Gr.errors),s=r.length)),e.mask!==void 0&&(Ys(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),s=r.length))}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 kf(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),kf.errors=r,s===0}var Af=Pf;var K0={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"]},fade:{type:"object",required:["duration"],properties:{delay:{type:"number",minimum:0},duration:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1},transitionSide:{type:"object",minProperties:1,properties:{fade:{$ref:"#/$defs/fade"}},additionalProperties:!1},keyframeValue:{oneOf:[{type:"number"},{const:"target"}]},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:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},updateTween:{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/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"}},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 Xs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0,i=s,l=!1,c=null,u=s;if(typeof e!="number"){let d={instancePath:t,schemaPath:"#/oneOf/0/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),s++}var f=u===s;f&&(l=!0,c=0);let p=s;if(e!=="target"){let d={instancePath:t,schemaPath:"#/oneOf/1/const",keyword:"const",params:{allowedValue:"target"},message:"must be equal to constant"};r===null?r=[d]:r.push(d),s++}var f=p===s;if(f&&l?(l=!1,c=[c,1]):f&&(l=!0,c=1),l)s=i,r!==null&&(i?r.length=i:r=null);else{let d={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[d]:r.push(d),s++}return Xs.errors=r,s===0}var W0={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 Wr(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:W0.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),s++}return Wr.errors=r,s===0}function nr(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&&(Xs(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.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&&(Wr(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?Wr.errors:r.concat(Wr.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 nr.errors=r,s===0}function Gs(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;nr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 g={};r===null?r=[g]:r.push(g),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 h=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 g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let f=s,d=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=f,r!==null&&(f?r.length=f:r=null),b){let h=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 g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),s++}if(w<0||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}}var b=h===s;d=b}if(!d){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}return Gs.errors=r,s===0}function Hs(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!=="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.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++)Gs(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.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 Hs.errors=r,s===0}function Ks(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;nr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 g={};r===null?r=[g]:r.push(g),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 h=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 g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let f=s,d=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=f,r!==null&&(f?r.length=f:r=null),b){let h=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 g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),s++}if(w<-1||isNaN(w)){let g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),s++}}}var b=h===s;d=b}if(!d){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),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.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!=="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.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++)Ks(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.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 Ws.errors=r,s===0}function Js(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;nr(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?nr.errors:r.concat(nr.errors),s=r.length);let i=s,l=!0,c=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let h;if(e.value===void 0&&(h="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 g={};r===null?r=[g]:r.push(g),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 h=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 g={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var p=h===s;l=p}if(!l){let h={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),s++}let f=s,d=!0,m=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let h={};r===null?r=[h]:r.push(h),s++}var b=m===s;if(s=f,r!==null&&(f?r.length=f:r=null),b){let h=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 g={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),s++}}var b=h===s;d=b}if(!d){let h={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[h]:r.push(h),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)){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!=="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.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++)Js(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Js.errors:r.concat(Js.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 Qs.errors=r,s===0}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)){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&&(Hs(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),s=r.length)),e.pan!==void 0&&(Ws(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),s=r.length)),e.playbackRate!==void 0&&(Qs(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.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 eo(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.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==="delay"||i==="duration"||i==="easing")){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.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.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++}}e.easing!==void 0&&(Wr(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?Wr.errors:r.concat(Wr.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 eo.errors=r,s===0}function Hr(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!=="fade"){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.fade!==void 0&&(eo(e.fade,{instancePath:t+"/fade",parentData:e,parentDataProperty:"fade",rootData:a})||(r=r===null?eo.errors:r.concat(eo.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 Hr.errors=r,s===0}function ro(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 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,E=s,k=s,P=s,v=!1,O=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.prev===void 0&&(R="prev")){let L={};r===null?r=[L]:r.push(L),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 _={};r===null?r=[_]:r.push(_),s++}}var p=R===s;v=v||p}if(v)s=P,r!==null&&(P?r.length=P:r=null);else{let R={};r===null?r=[R]:r.push(R),s++}var f=k===s;if(f){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=E,r!==null&&(E?r.length=E: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=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 d=s,m=!0,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let g={};r===null?r=[g]:r.push(g),s++}var h=b===s;if(s=d,r!==null&&(d?r.length=d:r=null),h){let g=s,E=s,k=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let R;if(e.tween===void 0&&(R="tween")){let L={};r===null?r=[L]:r.push(L),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=E,r!==null&&(E?r.length=E:r=null);let P=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=P,r!==null&&(P?r.length=P: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 h=g===s;m=h}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++}for(let g in e)if(!(g==="name"||g==="type"||g==="tween"||g==="prev"||g==="next")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),s++}if(e.name!==void 0&&typeof e.name!="string"){let g={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}if(e.type!==void 0){let g=e.type;if(!(g==="update"||g==="transition")){let E={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:K0.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[E]:r.push(E),s++}}e.tween!==void 0&&(Zs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Zs.errors:r.concat(Zs.errors),s=r.length)),e.prev!==void 0&&(Hr(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?Hr.errors:r.concat(Hr.errors),s=r.length)),e.next!==void 0&&(Hr(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?Hr.errors:r.concat(Hr.errors),s=r.length))}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 ro.errors=r,s===0}function Pf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ro(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ro.errors:r.concat(ro.errors),s=r.length),Pf.errors=r,s===0}var Ef=xf;function to(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(je(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 to.errors=r,s===0}function xf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return to(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?to.errors:r.concat(to.errors),s=r.length),xf.errors=r,s===0}var Sf=Of;var J0=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function no(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(!J0.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 no.errors=r,s===0}function Of(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return no(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?no.errors:r.concat(no.errors),s=r.length),Of.errors=r,s===0}var Rf=$f;function so(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 f={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=[f]:r.push(f),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 f={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=[f]:r.push(f),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 so.errors=r,s===0}function $f(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return so(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?so.errors:r.concat(so.errors),s=r.length),$f.errors=r,s===0}var Cf=_f;function oo(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 oo.errors=r,s===0}function _f(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return oo(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?oo.errors:r.concat(oo.errors),s=r.length),_f.errors=r,s===0}var jf=Nf;function io(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 io.errors=r,s===0}function Nf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return io(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?io.errors:r.concat(io.errors),s=r.length),Nf.errors=r,s===0}var Tf=Df;function ao(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++){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 ao.errors=r,s===0}function Df(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return ao(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?ao.errors:r.concat(ao.errors),s=r.length),Df.errors=r,s===0}var Lf=Mf;function lo(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,f=s,d=s,m=!1,b=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let P={};r===null?r=[P]:r.push(P),s++}}var h=b===s;if(m=m||h,!m){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 h=k===s;if(m=m||h,!m){let v=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.behaviors===void 0&&(T="behaviors")){let R={};r===null?r=[R]:r.push(R),s++}}var h=v===s;if(m=m||h,!m){let T=s;if(e&&typeof e=="object"&&!Array.isArray(e)){let L;if(e.emitter===void 0&&(L="emitter")){let U={};r===null?r=[U]:r.push(U),s++}}var h=T===s;m=m||h}}}if(m)s=d,r!==null&&(d?r.length=d:r=null);else{let k={};r===null?r=[k]:r.push(k),s++}var y=f===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 g=u===s;g&&(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 g=w===s;if(g&&l?(l=!1,c=[c,1]):g&&(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 P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),s++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let P={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[P]:r.push(P),s++}}else{let P={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[P]:r.push(P),s++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let P={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[P]:r.push(P),s++}}else{let P={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[P]:r.push(P),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 P={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[P]:r.push(P),s++}if(k.appearance===void 0){let P={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[P]:r.push(P),s++}for(let P in k)if(!(P==="emission"||P==="movement"||P==="appearance"||P==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:P},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),s++}if(k.emission!==void 0){let P=k.emission;if(!(P&&typeof P=="object"&&!Array.isArray(P))){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 P=k.movement;if(!(P&&typeof P=="object"&&!Array.isArray(P))){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 P=k.appearance;if(!(P&&typeof P=="object"&&!Array.isArray(P))){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 P=k.bounds;if(!(P&&typeof P=="object"&&!Array.isArray(P))){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 P={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),s++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let P={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[P]:r.push(P),s++}if(typeof k=="number"&&(k<1||isNaN(k))){let P={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[P]:r.push(P),s++}}if(e.texture!==void 0){let k=e.texture,P=s,v=!1,O=null,T=s;if(typeof k=="string"){if(je(k)<1){let L={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=[L]:r.push(L),s++}}else{let L={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[L]:r.push(L),s++}var E=T===s;E&&(v=!0,O=0);let R=s;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let L={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[L]:r.push(L),s++}var E=R===s;if(E&&v?(v=!1,O=[O,1]):E&&(v=!0,O=1),v)s=P,r!==null&&(P?r.length=P:r=null);else{let L={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[L]:r.push(L),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 P=k.length;for(let v=0;v<P;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let T={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[T]:r.push(T),s++}for(let T in O)if(!(T==="type"||T==="config")){let R={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:T},message:"must NOT have additional properties"};r===null?r=[R]:r.push(R),s++}if(O.type!==void 0){let T=O.type;if(typeof T=="string"){if(je(T)<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 T=O.config;if(!(T&&typeof T=="object"&&!Array.isArray(T))){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 T={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[T]:r.push(T),s++}}}else{let P={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[P]:r.push(P),s++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let P={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[P]:r.push(P),s++}if(k.lifetime!==void 0){let P=k.lifetime;if(P&&typeof P=="object"&&!Array.isArray(P)){if(P.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(P.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(P.min!==void 0){let v=P.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(P.max!==void 0){let v=P.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 P={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),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 lo.errors=r,s===0}function Mf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return lo(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?lo.errors:r.concat(lo.errors),s=r.length),Mf.errors=r,s===0}var qf=Vf;var Yp={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 co(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(!Je.call(Yp.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:Yp.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 co.errors=r,s===0}function Vf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return co(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?co.errors:r.concat(co.errors),s=r.length),Vf.errors=r,s===0}var Ff=Uf;var Q0=new RegExp("^.+$","u");function uo(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(Q0.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 f=0;f<p;f++)if(typeof u[f]!="number"){let d={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+f,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 uo.errors=r,s===0}function Uf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return uo(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?uo.errors:r.concat(uo.errors),s=r.length),Uf.errors=r,s===0}var Bf=Yf;var zp={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 po(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(!Je.call(zp.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,f=s;if(typeof l=="string"){if(je(l)<1){let m={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=[m]:r.push(m),s++}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[m]:r.push(m),s++}var i=f===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 m=l.length;for(let y=0;y<m;y++){let w=l[y];if(typeof w=="string"){if(je(w)<1){let g={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=[g]:r.push(g),s++}}else{let g={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),s++}}let b=l.length,h;if(b>1){let y={};for(;b--;){let w=l[b];if(typeof w=="string"){if(typeof y[w]=="number"){h=y[w];let g={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:b,j:h},message:"must NOT have duplicate items (items ## "+h+" and "+b+" are identical)"};r===null?r=[g]:r.push(g),s++;break}y[w]=b}}}}else{let m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),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 m={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[m]:r.push(m),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:zp.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),s++}}if(e.lineHeight!==void 0&&typeof e.lineHeight!="number"){let l={instancePath:t+"/lineHeight",schemaPath:"#/properties/lineHeight/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.align!==void 0&&typeof e.align!="string"){let l={instancePath:t+"/align",schemaPath:"#/properties/align/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.wordWrap!==void 0&&typeof e.wordWrap!="boolean"){let l={instancePath:t+"/wordWrap",schemaPath:"#/properties/wordWrap/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.breakWords!==void 0&&typeof e.breakWords!="boolean"){let l={instancePath:t+"/breakWords",schemaPath:"#/properties/breakWords/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[l]:r.push(l),s++}if(e.wordWrapWidth!==void 0&&typeof e.wordWrapWidth!="number"){let l={instancePath:t+"/wordWrapWidth",schemaPath:"#/properties/wordWrapWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeColorId!==void 0&&typeof e.strokeColorId!="string"){let l={instancePath:t+"/strokeColorId",schemaPath:"#/properties/strokeColorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[l]:r.push(l),s++}if(e.strokeAlpha!==void 0&&typeof e.strokeAlpha!="number"){let l={instancePath:t+"/strokeAlpha",schemaPath:"#/properties/strokeAlpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.strokeWidth!==void 0&&typeof e.strokeWidth!="number"){let l={instancePath:t+"/strokeWidth",schemaPath:"#/properties/strokeWidth/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),s++}if(e.shadow!==void 0){let l=e.shadow;if(l&&typeof l=="object"&&!Array.isArray(l)){if(l.colorId===void 0){let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/required",keyword:"required",params:{missingProperty:"colorId"},message:"must have required property 'colorId'"};r===null?r=[c]:r.push(c),s++}for(let c in l)if(!(c==="colorId"||c==="alpha"||c==="blur"||c==="offsetX"||c==="offsetY")){let u={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:c},message:"must NOT have additional properties"};r===null?r=[u]:r.push(u),s++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(je(c)<1){let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/colorId",schemaPath:"#/properties/shadow/properties/colorId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[u]:r.push(u),s++}}if(l.alpha!==void 0){let c=l.alpha;if(typeof c=="number"){if(c>1||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[u]:r.push(u),s++}if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/alpha",schemaPath:"#/properties/shadow/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.blur!==void 0){let c=l.blur;if(typeof c=="number"){if(c<0||isNaN(c)){let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[u]:r.push(u),s++}}else{let u={instancePath:t+"/shadow/blur",schemaPath:"#/properties/shadow/properties/blur/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[u]:r.push(u),s++}}if(l.offsetX!==void 0&&typeof l.offsetX!="number"){let c={instancePath:t+"/shadow/offsetX",schemaPath:"#/properties/shadow/properties/offsetX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}if(l.offsetY!==void 0&&typeof l.offsetY!="number"){let c={instancePath:t+"/shadow/offsetY",schemaPath:"#/properties/shadow/properties/offsetY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[c]:r.push(c),s++}}else{let c={instancePath:t+"/shadow",schemaPath:"#/properties/shadow/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[c]:r.push(c),s++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),s++}return po.errors=r,s===0}function Yf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return po(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?po.errors:r.concat(po.errors),s=r.length),Yf.errors=r,s===0}var zf=Xf;var Z0={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 fo(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(!Je.call(Z0.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 fo.errors=r,s===0}function Xf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return fo(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?fo.errors:r.concat(fo.errors),s=r.length),Xf.errors=r,s===0}var Gf=Hf;function mo(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 mo.errors=r,s===0}function Hf(e,{instancePath:t="",parentData:n,parentDataProperty:o,rootData:a=e}={}){let r=null,s=0;return mo(e,{instancePath:t,parentData:n,parentDataProperty:o,rootData:a})||(r=r===null?mo.errors:r.concat(mo.errors),s=r.length),Hf.errors=r,s===0}var ln=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),an=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),hr=e=>e===void 0?void 0:structuredClone(e),ev=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"}),rv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),tv=Object.freeze({background:Xp,bgm:Hp,character:Wp,choice:Qp,cleanAll:ef,control:tf,dialogue:sf,form:af,layout:cf,screen:pf,sfx:df,visual:yf,voice:gf}),nv=Object.freeze({achievement:wf,animation:vf,audioEffect:Af,character:Ef,color:Sf,control:Rf,font:Cf,image:jf,layout:Tf,particle:Lf,sound:qf,spritesheet:Ff,textStyle:Bf,transform:zf,video:Gf}),sv=new Set(["files","language","patches"]),ov=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),iv=new Set(["lineId","mode","payload","type"]),av=new Set(["mode","payload","sceneId","type"]),lv=new Set(["mode","operation","payload","resourceId","type"]),cv=new Set(["fileId","mimeType"]),G=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},Qe=(e,t)=>{an(e)||G(t,"expected an object")},xa=(e,t)=>{Array.isArray(e)||G(t,"expected an array")},bt=(e,t)=>{(typeof e!="string"||e.length===0)&&G(t,"expected a non-empty string")},Qf=(e,t)=>{typeof e!="string"&&G(t,"expected a string")},or=(e,t,n)=>{for(let o of Object.keys(e))t.has(o)||G(`${n}.${o}`,"unknown field")},ir=(e,t,n)=>{for(let o of t)ln(e,o)||G(n,`missing required field "${o}"`)},uv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),pv=(e,t)=>{let n=(t?.instancePath??"").split("/").slice(1).map(uv);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)},fv=(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],Zf=({value:e,validator:t,path:n,contract:o})=>{if(t(e))return;let a=fv(t.errors);G(pv(n,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},yo=(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)=>yo(o,`${t}[${a}]`,n));return}Object.entries(e).forEach(([o,a])=>yo(a,`${t}.${o}`,n))}},sr=(e,t)=>{e===""&&G(t,"expected a non-empty resourceId")},dv=(e,t,n)=>{let o=(s,i)=>sr(s?.resourceId,`${i}.resourceId`),a=(s,i)=>(s??[]).forEach((l,c)=>sr(l?.resourceId,`${i}[${c}].resourceId`)),r=(s,i)=>{sr(s?.resourceId,`${i}.resourceId`),a(s?.sounds,`${i}.sounds`)};switch(e){case"background":sr(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)=>sr(l?.resourceId,`${n}.items[${i}].sprites[${c}].resourceId`)),o(s.animations,`${n}.items[${i}].animations`)});break;case"choice":case"form":case"layout":sr(t.resourceId,`${n}.resourceId`),o(t.animations,`${n}.animations`);break;case"control":sr(t.resourceId,`${n}.resourceId`);break;case"dialogue":sr(t.ui?.resourceId,`${n}.ui.resourceId`),o(t.ui?.animations,`${n}.ui.animations`),(t.character?.sprite?.items??[]).forEach((s,i)=>sr(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)=>{sr(s?.resourceId,`${n}.items[${i}].resourceId`),o(s?.animations,`${n}.items[${i}].animations`)});break;default:break}},wt=(e,t)=>{bt(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&G(t,`"${e}" is not a safe ID`)},mv=(e,t)=>{bt(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&G(t,"must be a safe single filename")},on=(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)=>on(a,t[r]));if(!an(e)||!an(t))return!1;let n=Object.keys(e).sort(),o=Object.keys(t).sort();return on(n,o)&&n.every(a=>on(e[a],t[a]))},ho=(e,t=new Set,n=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>ho(o,t,n)),t;if(!an(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),ho(a,t,n);return t},yv=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},ed=(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]},rd=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Kf=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),Wf=e=>{let t=hr(e??{});delete t.resourceId,delete t.animations;for(let n of Object.values(t.fields??{}))an(n)&&delete n.placeholder;return t},hv=(e,t,n,o)=>{e==="choice"&&!on(Kf(t),Kf(n))&&G(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!on(Wf(t),Wf(n))&&G(o,"form behavior must remain identical; only presentation fields and placeholders may change")},gv=({patch:e,path:t,lineIndex:n})=>{or(e,ov,t),ir(e,["type","lineId","actionType","payload"],t),wt(e.lineId,`${t}.lineId`),bt(e.actionType,`${t}.actionType`),Qe(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'line.action supports only "replace"'),rv.has(e.actionType)||G(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=ed(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"]'),ln(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"),hv(e.actionType,a,e.payload,`${t}.payload`),Zf({value:e.payload,validator:tv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),yo(e.payload,`${t}.payload`),dv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},bv=(e,t)=>{xa(e,t),e.forEach((n,o)=>{Qe(n,`${t}[${o}]`),or(n,new Set(["text"]),`${t}[${o}]`),ir(n,["text"],`${t}[${o}]`),Qf(n.text,`${t}[${o}].text`)})},wv=({patch:e,path:t,lineIndex:n})=>{or(e,iv,t),ir(e,["type","lineId","payload"],t),wt(e.lineId,`${t}.lineId`),Qe(e.payload,`${t}.payload`),or(e.payload,new Set(["content"]),`${t}.payload`),ir(e.payload,["content"],`${t}.payload`),bv(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&G(`${t}.mode`,'line.dialogue supports only "replace"');let o=ed(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}},Iv=({patch:e,path:t,projectData:n})=>(or(e,av,t),ir(e,["type","mode","sceneId","payload"],t),wt(e.sceneId,`${t}.sceneId`),Qe(e.payload,`${t}.payload`),or(e.payload,new Set(["name"]),`${t}.payload`),ir(e.payload,["name"],`${t}.payload`),Qf(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&G(`${t}.mode`,'story.scene requires "patch"'),ln(n?.story?.scenes??{},e.sceneId)||G(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),vv=(e,t,n)=>{Qe(t,n),["font","image","sound","spritesheet","video"].includes(e)&&bt(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"&&(Qe(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"),Zf({value:t,validator:nv[e],path:n,contract:`the resource.${e} schema`}),yo(t,n)},kv=({patch:e,path:t,projectData:n,packageFileIds:o,canonicalFileIds:a})=>{or(e,lv,t),ir(e,["type","resourceId","payload"],t),wt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),s=ev[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"'),vv(r,e.payload,`${t}.payload`);let i=n?.resources?.[s]??{},l=ln(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 ho(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}},Jf=({resources:e,collectionName:t,resourceId:n,path:o,label:a})=>{n!==void 0&&(typeof n!="string"||n.length===0||!ln(e?.[t]??{},n))&&G(o,`${a} resource "${n}" was not found`)},Av=(e,t)=>{let n=hr(e);for(let a of t.patches)a.kind==="resource"&&(n.resources[a.collectionName]??={},n.resources[a.collectionName][a.patch.resourceId]=hr(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)=>Jf({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]])Jf({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},Pv=({patch:e,path:t,projectData:n,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(Qe(e,t),bt(e.type,`${t}.type`),e.type==="line.action")return gv({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return wv({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return Iv({patch:e,path:t,projectData:n});if(e.type.startsWith("resource."))return kv({patch:e,path:t,projectData:n,packageFileIds:a,canonicalFileIds:r});G(`${t}.type`,`unsupported patch type "${e.type}"`)},Ev=(e,t)=>{xa(e,t);let n=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;Qe(o,r),or(o,cv,r),ir(o,["fileId"],r),mv(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},xv=({packageId:e,packageData:t,path:n,projectData:o,lineIndex:a,canonicalFileIds:r})=>{Qe(t,n),or(t,sv,n),ir(t,["language","files","patches"],n),bt(t.language,`${n}.language`);let s=Ev(t.files,`${n}.files`);xa(t.patches,`${n}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=Pv({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}},td=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};Qe(t,"l10nData"),or(t,new Set(["packages"]),"l10nData"),ir(t,["packages"],"l10nData"),Qe(t.packages,"l10nData.packages");let n=yv(e),o=ho(e?.resources??{}),a=new Map,r=new Map;for(let[s,i]of Object.entries(t.packages)){wt(s,`l10nData.packages.${s}`);let l=xv({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)}Av(e,l),a.set(s,l)}return{packages:a}},Sv=(e,t)=>{let{collectionName:n,patch:o}=t;e.resources[n]??={},e.resources[n][o.resourceId]=hr(o.payload)},Ov=(e,t)=>{let{patch:n}=t,o=e.story.scenes[n.sceneId];o.name=n.payload.name},Rv=(e,t)=>{let{location:n,patch:o}=t,a=rd(e,n);if(o.actionType!=="dialogue"){a.actions[o.actionType]=hr(o.payload);return}let r=hr(n.line.actions.dialogue.content);a.actions.dialogue=hr(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},$v=(e,t)=>{let{location:n,patch:o}=t,a=rd(e,n);a.actions.dialogue.content=hr(o.payload.content)},nd=({projectData:e,l10nData:t})=>{let n=td({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(n.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},go=({projectData:e,l10nData:t,l10nId:n=null})=>{let o=td({projectData:e,l10nData:t});if(n!==null&&(wt(n,"l10nId"),o.packages.has(n)||G("l10nId",`package "${n}" was not imported`)),n===null)return e;let a=hr(e),r=o.packages.get(n).patches;return r.filter(s=>s.kind==="resource").forEach(s=>Sv(a,s)),r.filter(s=>s.kind==="story.scene").forEach(s=>Ov(a,s)),r.filter(s=>s.kind==="line.action").forEach(s=>Rv(a,s)),r.filter(s=>s.kind==="line.dialogue").forEach(s=>$v(a,s)),a};var Sa=Object.freeze({auto:1e3,skip:80,authored:1e3}),pn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),sd=new WeakMap,Cv=new ArrayBuffer(8),Oa=new DataView(Cv),_v=e=>{let t=sd.get(e);if(t)return t;let n={dispatchDepth:0};return sd.set(e,n),n},jv=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Nv=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),_r=(e,t,n)=>{if(!jv(e)||!Nv(e,t))throw new TypeError(`${n} has an invalid shape`)},cn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},un=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},od=e=>{if(un(e,"duration"),e===0)return 0n;Oa.setFloat64(0,e,!1);let t=Oa.getUint32(0,!1),n=Oa.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)},Tv=e=>structuredClone(e),Ra=(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,$a=(e,t,n)=>{if(t===null)return null;if(e==="auto"){if(_r(t,["owner","delayMs","contentKey"],"auto timer"),_r(t.owner,["sessionId","lineEntryId"],"auto timer owner"),cn(t.owner.sessionId,"auto owner sessionId"),cn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(un(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")_r(t,["owner","delayMs"],"skip timer"),_r(t.owner,["sessionId"],"skip timer owner"),cn(t.owner.sessionId,"skip owner sessionId"),un(t.delayMs,"skip delayMs");else{if(_r(t,["owner","delayMs","trigger"],"authored timer"),_r(t.owner,["lineEntryId"],"authored timer owner"),cn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==n)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(un(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,...Tv(t)}},Dv=e=>{if(_r(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(cn(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}}_r(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:$a("auto",e.timers.auto,e.lineEntryId),skip:$a("skip",e.timers.skip,e.lineEntryId),authored:$a("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}},Ca=e=>({descriptor:e,remainingQuanta:od(e.delayMs)}),bo=["auto","skip","authored"],id=({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=_v(e),a=!0,r={},s={},i=null,l=null,c=null,u=null,p=!1,f=!1,d="legacy",m={auto:null,skip:null,authored:null},b={auto:null,skip:null,authored:null},h={auto:0,skip:0,authored:0},y=()=>bo.some(M=>m[M]),w=()=>{l=null,c=null},g=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||f){g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},E=()=>{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))},P=()=>{m={auto:null,skip:null,authored:null}},v=()=>{P(),s={},f||k()},O=M=>{if(o.dispatchDepth>0||f){c=M,g();return}a&&r===M.lifecycleToken&&s===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},T=()=>{if(!a||!y()||i)return;E();let M=r,se=s,ue={},z=oe=>{if(!a||M!==r||se!==s||ue!==l||z!==i||f)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 K=od(oe.deltaMS);f=!0,o.dispatchDepth+=1;let pe=s,ie=null;try{let C=[];for(let j of bo){let F=m[j];F&&(F.remainingQuanta<=K?(C.push({kind:j,descriptor:F.descriptor,revision:h[j]}),m[j]=null):F.remainingQuanta-=K)}if(C.length>0){try{t({dueKinds:C.map(({kind:j})=>j)})}catch(j){let F=n(j);if(d==="reconciled"&&F==="preCommit")for(let{kind:W,descriptor:fe}of C)b[W]=fe;else d==="legacy"&&P();throw j}if(d==="legacy")for(let j of C)j.kind==="skip"&&h.skip===j.revision&&m.skip===null&&(m.skip=Ca(j.descriptor))}}catch(C){ie=C}finally{o.dispatchDepth-=1,f=!1;try{pe===s?y()?T():k():i===z&&!y()&&k()}catch(C){throw ie?new AggregateError([ie,C],"Playback attempt and ticker cleanup both failed"):C}}if(ie)throw ie},Q={callback:z,lifecycleToken:M,generationToken:se,registrationToken:ue};i=z,c=Q;try{e.add(z)}catch(oe){throw i=null,w(),P(),s={},u=z,oe}O(Q)},R=M=>{h[M]+=1,m[M]=null,b[M]=null,!y()&&!f&&k()},L=(M,se)=>{un(se,`${M} delay`),d="legacy",h[M]+=1,b[M]=null,m[M]=Ca({mode:"legacy",kind:M,instanceToken:{},delayMs:se}),T()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return L("auto",M.payload?.delay??Sa.auto),!0;case"clearAutoNextTimer":return R("auto"),!0;case"startSkipNextTimer":return L("skip",M.payload?.delay??Sa.skip),!0;case"clearSkipNextTimer":return R("skip"),!0;case"nextLineConfigTimer":return L("authored",M.payload?.delay??Sa.authored),!0;case"clearNextLineConfigTimer":return R("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let se;try{se=Dv(M)}catch(z){try{v()}catch(Q){throw new AggregateError([z,Q],"Playback schedule validation and cleanup both failed")}throw z}if(d="reconciled",se.status==="unsettled"){P(),f||k();return}let ue={};for(let z of bo){let Q=se.timers[z],oe=b[z];if(oe&&(!Q||!Ra(oe,Q))&&(b[z]=null),Q&&b[z]&&Ra(b[z],Q)){ue[z]=null;continue}let K=m[z];ue[z]=Q&&K&&Ra(K.descriptor,Q)?K:Q?Ca(Q):null}m=ue,y()?T():f||k()},reset:()=>{let M=[i,u].filter((z,Q,oe)=>z&&oe.indexOf(z)===Q);r={},s={},w(),i=null,u=null,P(),b={auto:null,skip:null,authored:null};for(let z of bo)h[z]+=1;d="legacy",a=!0;let se=null,ue=null;for(let z of M)try{e.remove(z)}catch(Q){se??=Q,ue??=z}if(u=ue,se)throw se},dispose:()=>{a=!1,r={},s={},w(),P(),b={auto:null,skip:null,authored:null};let M=[i,u].filter((z,Q,oe)=>z&&oe.indexOf(z)===Q);i=null,u=null;let se=null,ue=null;for(let z of M)try{e.remove(z)}catch(Q){se??=Q,ue??=z}if(u=ue,se)throw se}}};var Lv=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),Mv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),_a="conditional",fn="random",Na=Symbol("conditionalAutoContinue"),qv=new Set(["sectionTransition","resetStoryAtSection"]),Vv=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),Fv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Uv=new Set(["nextLine","nextLineFromSystem"]),Bv=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),ja="form",Yv=new Set(["submitForm","cancelForm"]),zv="showImageGalleryVariant",Xv="playMusicRoomTrack",Gv="startSceneReplay",Hv="channel:bgm",Kv=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"]),Ve=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Wv=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,dn=e=>e?.type===Na,Jr=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Jv=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function Ta(e){let t=Wv(),n,o=0,a=!1,r=0,s=null,i=0,l=!1,c=0,u=[],p=null,f=null,d=new Map,m=new Map,b=new Map,h=0,y=null,w=[],g=!1,E=null,k=null,P=new Map,v,O,T=null,R=!1,L=!1,U=0,_=new Map,X=Yl(e.randomSource),{handlePendingEffects:re}=e;if(typeof re!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let M=re.bind(re),se=typeof re.reconcilePlaybackScheduleV1=="function"?re.reconcilePlaybackScheduleV1.bind(re):null,ue=typeof re.reset=="function"?re.reset.bind(re):null,z=typeof re.dispose=="function"?re.dispose.bind(re):null;if(se&&(!ue||!z))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let Q=I=>{if(L)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},oe=I=>{if(Q(I),!a||!n)throw new Error(`RouteEngine ${I} requires an active engine`)},K=(I,A)=>{if(U===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},$=_.get(I);($===void 0||S[A]>S[$])&&_.set(I,A)},pe=I=>{let A=_.get(I)??"preCommit";return _.delete(I),A},ie=I=>{if(se){L=!0;try{let A=se(structuredClone(I));if(A!==null&&(typeof A=="object"||typeof A=="function")&&typeof A.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{L=!1}}},C=()=>({contractVersion:1,status:"unsettled",lineEntryId:n?.selectPlaybackLineEntryId?.()??0,timers:null}),j=I=>{if(!(!se||!a||!n)){R=!0;try{ie(C())}catch(A){if(I){let S=new AggregateError([I,A],"Playback work and schedule invalidation both failed");throw _.delete(I),K(S,"reconcileFailed"),S}throw K(A,"reconcileFailed"),A}}},F=()=>{if(!se||!R||!a||!n||i>0||l)return;let I;try{I=n.selectDesiredPlaybackTimers()}catch(A){throw K(A,"reconcileFailed"),j(A),A}try{ie({contractVersion:1,status:"settled",lineEntryId:n.selectPlaybackLineEntryId(),timers:I})}catch(A){throw K(A,"reconcileFailed"),j(A),A}R=!1},W=(I=new Map,A=Date.now())=>new Map(Array.from(I.entries()).filter(([,S])=>A<S.expiresAt).map(([S,$])=>[S,{animation:structuredClone($.animation),startedAt:$.startedAt,expiresAt:$.expiresAt}])),fe=(I=new Map)=>Array.from(I.values()).map(A=>structuredClone(A.animation)),Se=(I=Date.now())=>{d=new Map(Array.from(d.entries()).filter(([,A])=>I<A.expiresAt))},be=()=>{if(a&&!(i>0||l)){l=!0;try{for(;n.selectPendingEffects().length>0;){let I=n.selectCurrentPointer()?.pointer??null,A=[...n.selectPendingEffects()],S=A.map($=>$.name!=="handleLineActions"?$:{...$,payload:{...$.payload,pointer:structuredClone(I)}});n.clearPendingEffects();try{let $=se?S.filter(N=>!pn.has(N.name)):S;$.length>0&&M($)}catch($){throw n.clearPendingEffects(),A.forEach(N=>{n.appendPendingEffect(N)}),K($,"postCommitUnsettled"),j($),$}}}finally{l=!1}F()}},me=I=>{i+=1;let A=!1;try{let S=I();return A=!0,S}finally{i-=1,A&&be()}},ar=()=>{let I=n.selectSystemState();return Ni({presentationState:n.selectPresentationState(),resources:I.projectData?.resources,runtime:n.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer})},Fe=()=>structuredClone(g?E:ar()),mn=I=>{let A=n.selectSystemState().projectData?.story?.scenes??{};return Object.entries(A).find(([,S])=>S?.sections?.[I])?.[0]},It=()=>{if(w.length===0)return;let I=n.selectRuntime()?.skipTransitionsAndAnimations===!0,A=I?null:y?.id;w.forEach(S=>{S.status=S.effect?.id===A?"active":"settled"}),I&&(y=null),w=[]},vt=(I,A,S,$)=>{I?.audioEffects||(y=null);let N=n.selectPlaybackLineEntryId?.()??0,Y=(A.actionPath??["bgm"]).join("."),B=n.selectCurrentPointer()?.pointer,te=B?.sceneId??mn(B?.sectionId),de=A.rollbackSource==="line"&&B?`story.scenes[${JSON.stringify(te)}].sections[${JSON.stringify(B.sectionId)}].lines[${JSON.stringify(B.lineId)}].actions.${Y}`:Y,ye=A.rollbackSource==="line"?`${o}:${N}:${de}`:null,we=ye?P.get(ye):null;if(we)return we;h+=1;let ge={occurrenceId:`${t}:g${o}:l${N}:audio${h}`,actionPath:de,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Ne=n.selectSystemState().projectData?.resources,Te=Dp({occurrence:ge,resources:Ne,previousChannel:S,nextChannel:$});if(ge.effect=Te?structuredClone(Te):null,ge.status=Te?"pending":"settled",y=Te?structuredClone(Te):null,w.push(ge),ye)for(P.set(ye,ge);P.size>512;){let Zr=P.keys().next().value;P.delete(Zr)}return ge},kt=({initialState:I,namespace:A})=>{Q("initialize");let S=n?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:$,...N}=I,Y=$===void 0?void 0:structuredClone($),B=structuredClone(I.projectData),te=nd({projectData:B,l10nData:Y}),de=N.global??{};if(!Ve(de))throw new Error("Malformed global state.");let ye=de.runtime??{};if(!Ve(ye))throw new Error("Malformed global.runtime.");let we=ye.localizationPackageId;if(we!=null&&typeof we!="string")throw new Error("localizationPackageId requires a string or null value");let ge=new Set(te.map(({l10nId:et})=>et).filter(et=>et!==null)),Ne=typeof we=="string"&&ge.has(we)?we:null,Te=go({projectData:B,l10nData:Y,l10nId:Ne}),Zr=Op({...N,global:{...de,localizationPackages:te,runtime:{...ye,localizationPackageId:Ne}},projectData:Te,initialAudioCommandId:S});ue?.(),n=Zr,o+=1,a=!0,r=0,s=gt(A),i=0,l=!1,c=0,u=[],p=null,f=null,d=new Map,m=new Map,b=new Map,h=0,y=null,w=[],g=!1,E=null,k={lineEntryId:n.selectPlaybackLineEntryId?.()??0,channel:null},P=new Map,v=B,O=Y,T=Ne,R=!0,L=!1,U=0,_.clear(),n.appendPendingEffect({name:"handleLineActions"}),be()},yn=()=>{Q("dispose"),a&&(a=!1,o+=1,n?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,f=null,d=new Map,m=new Map,b=new Map,y=null,w=[],g=!1,E=null,k=null,P=new Map,R=!1,_.clear(),z?.())},At=()=>s,hn=()=>n.selectPresentationState(),Pt=()=>n.selectPresentationChanges(),gn=I=>n.selectSectionLineChanges(I),bn=(I={})=>{oe("rendering"),r+=1;let A=Date.now();Se(A);let S=m.size>0,$=W(d,A),N=S?W(m,A):new Map,Y=n.selectRenderState({activePersistentAnimations:fe($),restoredPersistentAnimations:fe(N),activeAudioEffect:y?structuredClone(y):null}),B={...Y,id:`render-${t}-${o}-${r}`};return b.set(B.id,{builtAt:A,persistentAnimationSessions:new Map([...N.entries(),...$.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectId:y?.id??null,retainsActiveAudioEffect:!!y&&(Y.audioEffects??[]).some(te=>te.id===y.id)}),B},wn=(I={})=>bn(I),pd=(I={})=>bn(I),fd=I=>{if(!a||!n)return;let A=I?.audio?.find(Y=>Y?.id===Hv);g=!0,E=A?structuredClone(A):null;let S=typeof I?.id=="string"&&I.id.length>0?I.id:null,$=S?b.get(S):null;S&&b.delete(S);let N=new Map;Sc(I?.animations).forEach(Y=>{let B=Zn(Y);if(!B)return;let te=$?.persistentAnimationSessions?.get(B)??d.get(B),de=Math.max(0,$c(Y)),ye=te?.startedAt??$?.builtAt??Date.now();N.set(B,{animation:structuredClone(Y),startedAt:ye,expiresAt:ye+de})}),d=N,$?.usedRestoredPersistentAnimationSessions&&(m=new Map),$?.activeAudioEffectId&&!$.retainsActiveAudioEffect&&y?.id===$.activeAudioEffectId&&(y=null)},dd=()=>n.selectSystemState(),md=()=>n.selectAchievements(),yd=I=>n.selectAchievement(I),La=()=>n.selectSaveSlotMap(),hd=I=>n.selectSaveSlot(I),gd=I=>n.selectSaveSlotPage(I),bd=()=>n.selectImageGallery(),wd=()=>n.selectMusicRoom(),Id=()=>n.selectSceneReplay(),vd=()=>n.selectIsSceneReplayActive(),uk=()=>n.selectSkipMode(),pk=()=>n.selectAutoMode(),kd=()=>n.selectRuntime(),Ad=()=>n.selectIsChoiceVisible(),Pd=()=>n.selectIsFormVisible(),Ed=()=>n.selectActiveInteraction(),xd=()=>n.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),Ma=(I,A,S={})=>!Ve(A)||I!=="nextLine"?A:S.bypassChoice===!0?{...A,bypassChoice:!0}:S.interactionSource===ja?{...A,_interactionSource:ja}:A,qa=(I={})=>({type:Na,payload:Ma("nextLine",{_conditionalContinuation:!0},I)}),wo=(I,A)=>dn(I)?{type:Na,payload:{...I.payload,...A.payload}}:A,Sd=I=>{I.savedCheckpointOccurrences.forEach(A=>{n.markSavedRollbackCheckpointTransient(A)}),I.savedCheckpointOccurrences=[]},Od=(I,A)=>{let S=p;return p=null,!S||!Jr(S.pointer,I)||S.checkpointIndex!==A?.checkpointIndex||S.checkpointIdentity!==A?.checkpoint?[]:S.savedCheckpointOccurrences},Rd=I=>{let A=f;return!A||!Jr(A.pointer,I)?null:(f=null,A)},$d=({actionType:I,pointerBeforeAction:A,pointerAfterAction:S,cursorBeforeAction:$,cursorAfterAction:N,wasSceneReplayActive:Y,isSceneReplayActive:B})=>{!S||!(!Jr(A,S)||$?.checkpoint!==N?.checkpoint||$?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(f={pointer:S,appendToPrevious:Uv.has(I)&&Y===B&&A?.sectionId===S.sectionId&&A?.lineId!==S.lineId,reuseExistingOccurrence:Bv.has(I),forceNewOccurrence:I==="jumpToLine"})},Va=I=>{I.markCurrentCheckpointTransient&&(n.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),Sd(I))},Cd=(I,A,S)=>Vv.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==A?.checkpoint:S?.checkpoint!==A?.checkpoint&&S?.checkpointIndex>A?.checkpointIndex:!1,_d=I=>{let A=u.at(-1);if(!A?.markCurrentCheckpointTransient)return;let S=n.selectSaveSlot({slotId:I?.slotId});S&&A.savedCheckpointOccurrences.push({slotId:I.slotId,saveSlotIdentity:S,checkpointIndex:A.rollbackCursor?.checkpointIndex,sectionId:A.pointer?.sectionId,lineId:A.pointer?.lineId})},jd=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(A=>{let S=n.selectSaveSlot({slotId:A.slotId});S&&(A.saveSlotIdentity=S)})},Nd=()=>{let I=u.at(-1);I&&(I.rollbackCursor=n.selectRollbackCursor?.()??null)},Td=(I,A,S)=>{let $=u.at(-1);if(!$)return;let N=n.selectCurrentPointer()?.pointer,Y=Cd(I,A,S);if(Jr($.pointer,N)){let B=S?.checkpoint!==A?.checkpoint||S?.checkpointIndex!==A?.checkpointIndex;Y||B&&Fv.has(I)?(Va($),$.pointer=N,$.rollbackCursor=S,$.markCurrentCheckpointTransient=Y,$.savedCheckpointOccurrences=[]):B&&I==="updateProjectData"&&($.rollbackCursor=S);return}Va($),$.pointer=N,$.rollbackCursor=n.selectRollbackCursor?.()??null,$.markCurrentCheckpointTransient=Y,$.savedCheckpointOccurrences=[]},Qr=(I,A)=>{if(oe(`action "${I}"`),!n[I])return;let S=A,$,N;if(I==="updateProjectData")Fa(A),$=structuredClone(A.projectData),S={...A,projectData:go({projectData:$,l10nData:O,l10nId:T})},Fa(S);else if(I==="updateLocalizationPackage"){if(N=Dd(A),N===T)return;S={l10nId:N,projectData:go({projectData:v,l10nData:O,l10nId:N})}}qv.has(I)&&(c+=1);let Y=n.selectAutoMode(),B=Y?n.selectRuntime():null,te=n.selectIsSceneReplayActive?.()===!0,de=Mv.has(I)?W(d):null,ye=n.selectCurrentPointer()?.pointer??null,we=n.selectRollbackCursor?.()??null,ge=zn(I),Ne=ge?n.selectPlaybackLineEntryId?.()??0:null,Te=ge?Fe():null,Zr=!1,et;try{et=n[I](S),Zr=!0}catch(Et){throw K(Et,"preCommit"),Et}$!==void 0&&(v=$),N!==void 0&&(T=N),Lv.has(I)&&(m=de??new Map,d=new Map,y=null),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=null);let Ga=n.selectIsSceneReplayActive?.()===!0;te!==Ga&&(d=new Map,m=new Map);let Wd=n.selectCurrentPointer()?.pointer??null,Ha=n.selectRollbackCursor?.()??null,Ka=ge?n.selectPlaybackLineEntryId?.()??0:null;ge&&Ka!==Ne&&(k={lineEntryId:Ka,channel:Te}),I==="saveSlot"?_d(A):I==="updateProjectData"&&jd(),Td(I,we,Ha),$d({actionType:I,pointerBeforeAction:ye,pointerAfterAction:Wd,cursorBeforeAction:we,cursorAfterAction:Ha,wasSceneReplayActive:te,isSceneReplayActive:Ga});let Jd=n.selectAutoMode()&&(I==="updateVariable"||Y&&Jv(B,n.selectRuntime()));(Kv.has(I)||Jd)&&(R=!0);try{be()}catch(Et){throw Zr&&K(Et,"postCommitUnsettled"),Et}return et},Fa=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");qr(I?.projectData?.resources?.variables??{}),_t(I.projectData),jt(I.projectData),Nt(I.projectData)},Dd=I=>{if(!Ve(I))throw new Error("updateLocalizationPackage requires an object payload");let A=Object.keys(I);if(A.length!==1||A[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},Ld=(I,A,S)=>{let $=n.selectCurrentPointer()?.pointer;A!==$||S!==c||(n.appendPendingEffect({name:"clearAutoNextTimer"}),n.appendPendingEffect({name:"clearNextLineConfigTimer"}),Qr("nextLineFromSystem",I.payload))},Md=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:f,persistentAnimationSessions:new Map(d),restoredPersistentAnimationSessions:new Map(m),renderPersistentAnimationMetadata:new Map(b),audioEffectOccurrenceSequence:h,activeAudioEffect:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:k?structuredClone(k):null,acceptedLineBgmActionOccurrences:new Map(P),canonicalProjectData:v,localizationPackageId:T,playbackScheduleDirty:R}),qd=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,f=I.pendingDialogueHistoryLineEntry,d=new Map(I.persistentAnimationSessions),m=new Map(I.restoredPersistentAnimationSessions),b=new Map(I.renderPersistentAnimationMetadata),h=I.audioEffectOccurrenceSequence,y=I.activeAudioEffect,w=I.pendingAudioEffectOccurrences.slice(),k=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,P=new Map(I.acceptedLineBgmActionOccurrences),v=I.canonicalProjectData,T=I.localizationPackageId,R=I.playbackScheduleDirty},Io=(I,A={})=>(oe("action batch"),me(()=>{let S=Md();try{return n[Ho](()=>{let $,N=n.selectCurrentPointer()?.pointer??null,Y=n.selectRollbackCursor?.()??null,B=c,te={pointer:N,rollbackCursor:Y,markCurrentCheckpointTransient:A.rollbackSource==="line",savedCheckpointOccurrences:A.savedCheckpointOccurrences?.slice()??[]};u.push(te);try{n.beginRollbackActionBatch({source:A.rollbackSource});try{$=I()}finally{n.endRollbackActionBatch({})}dn($)&&Ld($,N,B),It();let de=n.selectCurrentPointer()?.pointer??null;A.rollbackSource==="line"&&Jr(N,de)&&n.recordCurrentDialogueHistory({savedCheckpointOccurrences:te.savedCheckpointOccurrences,appendToPrevious:A.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:A.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:A.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!Jr(N,te.pointer)||Y?.checkpoint!==te.rollbackCursor?.checkpoint)&&te.markCurrentCheckpointTransient&&te.savedCheckpointOccurrences.length>0&&(p={pointer:te.pointer,checkpointIndex:te.rollbackCursor?.checkpointIndex,checkpointIdentity:te.rollbackCursor?.checkpoint,savedCheckpointOccurrences:te.savedCheckpointOccurrences})}})}catch($){throw qd(S),$}})),vo=(I,A,S,$={})=>{if(I===_a||I===fn)return Io(()=>{let N={...$,executionContext:$.executionContext??{depth:0,pendingNavigation:null},actionPath:$.actionPath??[I],randomOutcomeOrdinals:$.randomOutcomeOrdinals??new Map};if(I===fn)return Ya(A,S,N);let Y=ko(S),B=Mt({[I]:A},Y);return Ba(B[I],S,N)},$);if(I==="bgm")return Io(()=>{let N=A?.audioEffects?Fe():null;Qr(I,A),vt(A,{...$,actionPath:$.actionPath??[I]},N,A?.audioEffects?ar():null)},$);Qr(I,A)},Vd=(I,A)=>{if(I!=="nextLineFromSystem")return vo(I,A);U+=1;try{return vo(I,A)}finally{U=Math.max(0,U-1)}},Ua=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},ko=I=>{if(Ua(I),!I)return{variables:n.selectAllVariables?n.selectAllVariables():void 0,runtime:n.selectRuntime?n.selectRuntime():{}};let{_event:A,...S}=I,$=n.selectAllVariables?n.selectAllVariables():void 0;return{...S,_event:A,variables:$,runtime:n.selectRuntime?n.selectRuntime():{}}},Fd=I=>{if(!Ve(I))return{templatePayload:I,literalTargetIds:null};let A=n.selectImageGalleryConfig();if(!Array.isArray(A?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?A.groups.find(N=>N.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let $=typeof I.variantId=="string"&&S.variants.some(N=>N.id===I.variantId);return{templatePayload:{...I,groupId:null,...$?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...$?{variantId:I.variantId}:{}}}},Ud=I=>!Ve(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectMusicRoomConfig()?.tracks?.some($=>$.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Bd=I=>!Ve(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:n.selectSceneReplayConfig()?.replays?.some($=>$.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},Yd=I=>{if(!Ve(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")},zd=(I,A,S)=>{if(!Ve(I))throw new Error(`conditional branch at index ${A} must be an object`);if(!Ve(I.actions))throw new Error(`conditional branch at index ${A} requires actions object`);if(!Object.prototype.hasOwnProperty.call(I,"when")&&A!==S-1)throw new Error("conditional else branch must be the last branch")},Ba=(I,A,S)=>{Yd(I);let $=qa(S);for(let N=0;N<I.branches.length;N+=1){let Y=I.branches[N];zd(Y,N,I.branches.length);let B=ko(A);if(Object.prototype.hasOwnProperty.call(Y,"when")&&!Ct(Y.when,B))continue;let de=In(Y.actions,A,{...S,actionPath:[...S.actionPath??[_a],"branches",String(N),"actions"]});return dn(de)?wo($,de):$}return $},Xd=I=>{if(!Ve(I))throw new Error("random action payload must be an object");let A=Object.keys(I).find(S=>S!=="distribution"&&S!=="variableId");if(A!==void 0)throw new Error(`random action.${A} is not supported`);if(!Ve(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=v?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||Re(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},Ya=(I,A,S)=>{Xd(I),Ua(A);let $=zl(I.distribution,{randomSource:X});if(S.rollbackSource==="line"){n.ensureRandomReplayOccurrence({});let B=(S.actionPath??[fn]).join("."),te=S.randomOutcomeOrdinals??new Map,de=te.get(B)??0;te.set(B,de+1),n.recordRandomOutcome({path:B,ordinal:de,type:$.type,result:$}),Nd()}let N;$.type==="integer"?Qr("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:$.value}]}):N=In(I.distribution.outcomes[$.outcomeIndex].actions,A,{...S,actionPath:[...S.actionPath??[fn],"distribution","outcomes",String($.outcomeIndex),"actions"]});let Y=qa(S);return dn(N)?wo(Y,N):Y},Gd=(I,A)=>({...I??{},_form:A}),Hd=(I,A,S,$)=>{let N=Qr(I,A),Y=N?.submitted===!0&&N.valid===!0,B=N?.cancelled===!0;if(!(!Y&&!B)&&Ve(A.actions))return In(A.actions,Gd(S,N.form),{...$,interactionSource:ja})},za=(I,A,S,$)=>{if(I===fn)return Ya(A,S,$);let N=ko(S),Y={templatePayload:A,literalTargetIds:null};I===zv?Y=Fd(A):I===Xv?Y=Ud(A):I===Gv&&(Y=Bd(A));let{templatePayload:B,literalTargetIds:te}=Y,ye=Mt({[I]:B},N)[I],we=te?{...ye,...te}:ye;if(I===_a)return Ba(we,S,$);let ge=Ma(I,we,$);if(Yv.has(I))return Hd(I,ge,S,$);let Ne=null;if(I==="bgm"&&ge?.audioEffects){let Te=$.audioEffectHandoff;Te?.available?(Te.available=!1,Ne=structuredClone(Te.channel)):Ne=Fe()}Qr(I,ge),I==="bgm"&&vt(ge,$,Ne,ge?.audioEffects?ar():null)},In=(I,A,S)=>{let $,N=S?.executionContext??{depth:0,pendingNavigation:null},Y=Yn(I);Xn(Y),N.depth+=1;try{for(let[B,te]of Y){let de={...S,executionContext:N,actionPath:[...S?.actionPath??[],B]};if(zn(B)){let we=N.pendingNavigation;if(we)throw new Error(`action batch cannot execute multiple navigation actions: ${we.actionType}, ${B}`);N.pendingNavigation={actionType:B,payload:te,eventContext:A,options:de};continue}let ye=za(B,te,A,de);dn(ye)&&($=wo($,ye))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let B=N.pendingNavigation;N.pendingNavigation=null,za(B.actionType,B.payload,B.eventContext,B.options)}return $},Xa=(I,A,S={})=>{let $={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Io(()=>In(I,A,$),$)},Kd=I=>{let A=n.selectCurrentPointer()?.pointer;if(I!==A||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:kt,dispose:yn,handleAction:vo,handleInternalAction:Vd,handleActions:Xa,selectRenderState:wn,prepareRenderState:pd,commitRenderState:fd,selectPresentationState:hn,selectPresentationChanges:Pt,selectSectionLineChanges:gn,selectSystemState:dd,selectAchievements:md,selectAchievement:yd,selectSaveSlotMap:La,selectSaveSlot:hd,selectSaveSlotPage:gd,selectSaveSlots:La,selectImageGallery:bd,selectMusicRoom:wd,selectSceneReplay:Id,selectIsSceneReplayActive:vd,selectRuntime:kd,selectIsChoiceVisible:Ad,selectIsFormVisible:Pd,selectActiveInteraction:Ed,selectHasPendingRenderWork:xd,handleLineActions:I=>{oe("line action handling");let A=n.selectCurrentPointer()?.pointer;if(I?.pointer&&!Jr(I.pointer,A))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=n.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return me(()=>{let S=n.selectCurrentPointer()?.pointer,$=n.selectPlaybackLineEntryId?.()??0,N=k?.lineEntryId===$?k:null,Y=n.selectRollbackCursor?.()??null,B=p,te=f,de=Od(S,Y),ye=Rd(S),we=n.selectCurrentLine(),ge=!1;if(we?.actions){try{Xa(we.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:de,dialogueHistoryAppendToPrevious:ye?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ye?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ye?.forceNewOccurrence===!0,audioEffectHandoff:N?{available:!0,channel:structuredClone(N.channel)}:null})}catch(Ne){throw p=B,f=te,Ne}ge=!0}return k?.lineEntryId===$&&(k=null),Kd(S),ge})},getNamespace:At,classifyAutomaticAttemptError:pe}}var Qv="music-room:player",cd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),ad=(e,t)=>cd.has(e)&&t?._event?.id===Qv,ud=({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)},Zv=({engine:e,routeGraphics:t,trackRenderDispatch:n,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},s)=>{let i=o?.()??0,l=e.handleLineActions(s);(o?.()??0)===i&&ud({engine:e,routeGraphics:t,trackRenderDispatch:n,lifecycleGeneration:a,isCurrentLifecycle:r},s)},ek=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveSlots(t?.saveSlots))},rk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalDeviceVariables(t?.globalDeviceVariables))},tk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalAccountVariables(t?.globalAccountVariables))},nk=({enqueuePersistenceWrite:e},t)=>{e(n=>n.saveGlobalRuntime(t?.globalRuntime))},sk=({enqueuePersistenceWrite:e},t)=>{e(n=>{if(typeof n.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return n.applyScopedDataUpdates(t?.updates)})},ld={render:ud,saveSlots:ek,saveGlobalDeviceVariables:rk,saveGlobalAccountVariables:tk,saveGlobalRuntime:nk,applyScopedDataUpdates:sk,handleLineActions:Zv},ok=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Da=(e,t,n)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,n)},ik=(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(!ok.has(a.name)){n.unshift(a);continue}t.has(a.name)||(t.add(a.name),n.unshift(a))}return n},ak=({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,f=!1,d=0,m=0,b=!0,h=id({ticker:n,dispatchAutomaticAttempt:()=>Da(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),y=()=>{u=null,p=null,f=!1,d=0},w=()=>{h.reset(),m+=1,y(),b=!0},g=()=>{m+=1,b=!1,y(),h.dispose()},E=C=>b&&C===m,k=C=>{if(a){a(C);return}console.error("RouteEngine persistence write failed.",C)},P=C=>{if(s)return s;let j=gt(C),F=l.get(j);if(F)return F;let W=Aa({indexedDB:r,namespace:j});return l.set(j,W),W},v=C=>{let j=s?null:gt(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=P(j),C(F))).catch(W=>{!s&&l.get(j)===F&&l.delete(j),k(W)})},O=C=>{if(!b)return;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;d+=1,u=j,f=!1},T=()=>d,R=(C={})=>{if(!b||C?.aborted===!0)return!1;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;return j?j!==u||j===p?!1:(p=j,!0):u!==null||f?!1:(f=!0,!0)},L=(C,j={})=>{if(!b)return!1;if(ad(C,j)){let W=cd.get(C),fe=e();return Da(fe,W,j?._event),!0}if(C!=="renderComplete"||!R(j))return!1;let F=e();return Da(F,"markLineCompleted",{}),!0},U=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),X=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,re=C=>C?._formKey??C?.formKey,M=(C,j)=>re(C)===j?.formKey,se=(C,j)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===j?.source,ue=(C,j)=>se(C,j)?j.source==="form"?M(C,j):!0:!1,z=(C,j)=>!C||typeof C!="object"||Array.isArray(C)||j?.source!=="form"?!1:M(C,j),Q=(C={},j)=>Object.keys(C).length>0&&Object.entries(C).every(([F,W])=>U.has(F)?z(W,j):_.has(F)),oe=(C={},j)=>{let F=C?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:Q(F,j):ue(C,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(W=>ue(W,j))},K=(C,j={})=>{if(!j?.actions)return!1;let F=X(C);return!F||F.source==="choice"?!1:!oe(j,F)},pe=({preprocessPayload:C,onEvent:j}={})=>async(F,W={})=>{if(!b)return!1;if(ad(F,W))return L(F,W),j?.(F,W);let fe=e(),Se=m,be=d;if(K(fe,W))return j?.(F,W);let me=await C?.(F,W)??W;if(!E(Se)||e()!==fe||d!==be)return!1;if(K(fe,me))return j?.(F,me);if(L(F,me),me?.actions){let ar=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,Fe;me?.bypassChoice===!0?Fe={bypassChoice:!0}:me?._interactionSource&&(Fe={interactionSource:me._interactionSource}),Fe?fe.handleActions(me.actions,ar,Fe):fe.handleActions(me.actions,ar)}return j?.(F,me)},ie=C=>{if(!b)return;let j=m,F=e(),W=ik(C),fe=W.some(be=>be.name==="handleLineActions");W.forEach(be=>{if(!ld[be.name]&&!pn.has(be.name)&&!o)throw new Error(`Unhandled pending effect "${be.name}".`)});let Se={engine:F,routeGraphics:t,ticker:n,trackRenderDispatch:O,getRenderDispatchCount:T,enqueuePersistenceWrite:v,lifecycleGeneration:m,isCurrentLifecycle:E};for(let be of W){if(!E(j))break;if(fe&&be.name==="render")continue;if(pn.has(be.name)){h.handleLegacyEffect(be);continue}let me=ld[be.name];if(me){me(Se,be.payload);continue}o(be,Se)}};return ie.handleRouteGraphicsEvent=L,ie.createRouteGraphicsEventHandler=pe,ie.reset=w,ie.dispose=g,ie.reconcilePlaybackScheduleV1=C=>h.reconcilePlaybackScheduleV1(C),ie},lk=ak;var ck=(e,t={})=>{let{resources:n={}}=t;return Oi(e,n)};var iP=Ta;export{oi as DEFAULT_VISUAL_LAYER,at as RENDER_LAYER,lr as VISUAL_LAYER,lk as createEffectsHandler,_0 as createIndexedDbPersistence,iP as default,Wo as formatDate,ky as resolveComputedVariables,ck as resolveLayoutReferences};
|