route-engine-js 1.45.0 → 1.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteEngine.js +7 -7
- package/package.json +1 -1
package/dist/RouteEngine.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var Nm=Object.defineProperty;var Dm=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Tm=(e,t)=>{for(var s in t)Nm(e,s,{get:t[s],enumerable:!0})};var df=Dm(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});function ff(e){let t=e.length,s=0,o=0,a;for(;o<t;)s++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<t&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return s}Fa.default=ff;ff.code='require("ajv/dist/runtime/ucs2length").default'});var Il=Symbol.for("immer-nothing"),yl=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state");function Ye(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var yt=Object.getPrototypeOf;function Pe(e){return!!e&&!!e[Le]}function zr(e){return e?vl(e)||Array.isArray(e)||!!e[yl]||!!e.constructor?.[yl]||Mn(e)||qn(e):!1}var Lm=Object.prototype.constructor.toString();function vl(e){if(!e||typeof e!="object")return!1;let t=yt(e);if(t===null)return!0;let s=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return s===Object?!0:typeof s=="function"&&Function.toString.call(s)===Lm}function Tn(e){return Pe(e)||Ye(15,e),e[Le].base_}function jn(e,t){Ln(e)===0?Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)}):e.forEach((s,o)=>t(o,s,e))}function Ln(e){let t=e[Le];return t?t.type_:Array.isArray(e)?1:Mn(e)?2:qn(e)?3:0}function qi(e,t){return Ln(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function kl(e,t,s){let o=Ln(e);o===2?e.set(t,s):o===3?e.add(s):e[t]=s}function Mm(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Mn(e){return e instanceof Map}function qn(e){return e instanceof Set}function Yr(e){return e.copy_||e.base_}function Vi(e,t){if(Mn(e))return new Map(e);if(qn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=vl(e);if(t===!0||t==="class_only"&&!s){let o=Object.getOwnPropertyDescriptors(e);delete o[Le];let a=Reflect.ownKeys(o);for(let r=0;r<a.length;r++){let n=a[r],i=o[n];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[n]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[n]})}return Object.create(yt(e),o)}else{let o=yt(e);if(o!==null&&s)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function zi(e,t=!1){return Vn(e)||Pe(e)||!zr(e)||(Ln(e)>1&&(e.set=e.add=e.clear=e.delete=qm),Object.freeze(e),t&&Object.entries(e).forEach(([s,o])=>zi(o,!0))),e}function qm(){Ye(2)}function Vn(e){return Object.isFrozen(e)}var Vm={};function Xr(e){let t=Vm[e];return t||Ye(0,e),t}var Mt;function Al(){return Mt}function Fm(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hl(e,t){t&&(Xr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Fi(e){Bi(e),e.drafts_.forEach(Bm),e.drafts_=null}function Bi(e){e===Mt&&(Mt=e.parent_)}function gl(e){return Mt=Fm(Mt,e)}function Bm(e){let t=e[Le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function bl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let s=t.drafts_[0];return e!==void 0&&e!==s?(s[Le].modified_&&(Fi(t),Ye(4)),zr(e)&&(e=Nn(t,e),t.parent_||Dn(t,e)),t.patches_&&Xr("Patches").generateReplacementPatches_(s[Le].base_,e,t.patches_,t.inversePatches_)):e=Nn(t,s,[]),Fi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Il?e:void 0}function Nn(e,t,s){if(Vn(t))return t;let o=t[Le];if(!o)return jn(t,(a,r)=>wl(e,o,t,a,r,s)),t;if(o.scope_!==e)return t;if(!o.modified_)return Dn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,r=a,n=!1;o.type_===3&&(r=new Set(a),a.clear(),n=!0),jn(r,(i,l)=>wl(e,o,a,i,l,s,n)),Dn(e,a,!1),s&&e.patches_&&Xr("Patches").generatePatches_(o,s,e.patches_,e.inversePatches_)}return o.copy_}function wl(e,t,s,o,a,r,n){if(Pe(a)){let i=r&&t&&t.type_!==3&&!qi(t.assigned_,o)?r.concat(o):void 0,l=Nn(e,a,i);if(kl(s,o,l),Pe(l))e.canAutoFreeze_=!1;else return}else n&&s.add(a);if(zr(a)&&!Vn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;Nn(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(s,o)&&Dn(e,a)}}function Dn(e,t,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&zi(t,s)}function Um(e,t){let s=Array.isArray(e),o={type_:s?1:0,scope_:t?t.scope_:Al(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=Xi;s&&(a=[o],r=qt);let{revoke:n,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=n,i}var Xi={get(e,t){if(t===Le)return e;let s=Yr(e);if(!qi(s,t))return Ym(e,s,t);let o=s[t];return e.finalized_||!zr(o)?o:o===Li(e.base_,t)?(Mi(e),e.copy_[t]=Yi(o,e)):o},has(e,t){return t in Yr(e)},ownKeys(e){return Reflect.ownKeys(Yr(e))},set(e,t,s){let o=Pl(Yr(e),t);if(o?.set)return o.set.call(e.draft_,s),!0;if(!e.modified_){let a=Li(Yr(e),t),r=a?.[Le];if(r&&r.base_===s)return e.copy_[t]=s,e.assigned_[t]=!1,!0;if(Mm(s,a)&&(s!==void 0||qi(e.base_,t)))return!0;Mi(e),Ui(e)}return e.copy_[t]===s&&(s!==void 0||t in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=s,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Li(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mi(e),Ui(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let s=Yr(e),o=Reflect.getOwnPropertyDescriptor(s,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:s[t]}},defineProperty(){Ye(11)},getPrototypeOf(e){return yt(e.base_)},setPrototypeOf(){Ye(12)}},qt={};jn(Xi,(e,t)=>{qt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});qt.deleteProperty=function(e,t){return qt.set.call(this,e,t,void 0)};qt.set=function(e,t,s){return Xi.set.call(this,e[0],t,s,e[0])};function Li(e,t){let s=e[Le];return(s?Yr(s):e)[t]}function Ym(e,t,s){let o=Pl(t,s);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Pl(e,t){if(!(t in e))return;let s=yt(e);for(;s;){let o=Object.getOwnPropertyDescriptor(s,t);if(o)return o;s=yt(s)}}function Ui(e){e.modified_||(e.modified_=!0,e.parent_&&Ui(e.parent_))}function Mi(e){e.copy_||(e.copy_=Vi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var zm=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,s,o)=>{if(typeof t=="function"&&typeof s!="function"){let r=s;s=t;let n=this;return function(l=r,...c){return n.produce(l,u=>s.call(this,u,...c))}}typeof s!="function"&&Ye(6),o!==void 0&&typeof o!="function"&&Ye(7);let a;if(zr(t)){let r=gl(this),n=Yi(t,void 0),i=!0;try{a=s(n),i=!1}finally{i?Fi(r):Bi(r)}return hl(r,o),bl(a,r)}else if(!t||typeof t!="object"){if(a=s(t),a===void 0&&(a=t),a===Il&&(a=void 0),this.autoFreeze_&&zi(a,!0),o){let r=[],n=[];Xr("Patches").generateReplacementPatches_(t,a,r,n),o(r,n)}return a}else Ye(1,t)},this.produceWithPatches=(t,s)=>{if(typeof t=="function")return(n,...i)=>this.produceWithPatches(n,l=>t(l,...i));let o,a;return[this.produce(t,s,(n,i)=>{o=n,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){zr(e)||Ye(8),Pe(e)&&(e=Ar(e));let t=gl(this),s=Yi(e,void 0);return s[Le].isManual_=!0,Bi(t),s}finishDraft(e,t){let s=e&&e[Le];(!s||!s.isManual_)&&Ye(9);let{scope_:o}=s;return hl(o,t),bl(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let s;for(s=t.length-1;s>=0;s--){let a=t[s];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}s>-1&&(t=t.slice(s+1));let o=Xr("Patches").applyPatches_;return Pe(e)?o(e,t):this.produce(e,a=>o(a,t))}};function Yi(e,t){let s=Mn(e)?Xr("MapSet").proxyMap_(e,t):qn(e)?Xr("MapSet").proxySet_(e,t):Um(e,t);return(t?t.scope_:Al()).drafts_.push(s),s}function Ar(e){return Pe(e)||Ye(10,e),El(e)}function El(e){if(!zr(e)||Vn(e))return e;let t=e[Le],s;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,s=Vi(e,t.scope_.immer_.useStrictShallowCopy_)}else s=Vi(e,!0);return jn(s,(o,a)=>{kl(s,o,El(a))}),t&&(t.finalized_=!1),s}var qe=new zm,Fn=qe.produce,Kk=qe.produceWithPatches.bind(qe),Wk=qe.setAutoFreeze.bind(qe),Jk=qe.setUseStrictShallowCopy.bind(qe),Qk=qe.applyPatches.bind(qe),Zk=qe.createDraft.bind(qe),eA=qe.finishDraft.bind(qe);var x={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},ht={NOT:0};var L=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},Ne=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Gi=e=>{if(!e||e.trim()==="")throw new L("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let s=e.includes("===")?"==":"!=";throw new L(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${s}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let s of t)if(e.trim().endsWith(s))throw new L(`Incomplete comparison expression - missing right operand (got: '${e}')`)},xl=e=>{if(e.trim().endsWith(" in"))throw new L(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new L(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,s]=e.split(" in ");if(!s||s.trim()==="")throw new L(`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 L(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new L(`Invalid loop syntax (got: '$for ${e}')`)}};var Sl=(e,t,s=!1)=>{if(t===null)return new Ne(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new Ne(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return s?new Ne(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new Ne(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Ol=(e,t)=>{let s=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new Ne(`Unknown function '${e}' (${s})`)};var Xm=(e,t,s={})=>{let o={},a={};s&&typeof s=="object"&&(s.functions!==void 0||s.partials!==void 0?(o=s.functions||{},a=s.partials||{}):typeof s=="object"&&(o=s));let n=se(e,{functions:o,partials:a},t,{});return n===void 0?{}:n},se=(e,t,s,o)=>{let a=t.functions||t;if(e.var&&!e.type)return ke(e.var,s,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ke(e.path,s,o);if(e.type===x.INTERPOLATION)return Hm(e.parts,t,s,o);switch(e.type){case x.FUNCTION:return $l(e,t,s,o);case x.BINARY:return Cl(e,t,s,o);case x.UNARY:return _l(e,t,s,o);case x.CONDITIONAL:return Wm(e,t,s,o);case x.LOOP:return ry(e,t,s,o);case x.OBJECT:return ny(e,t,s,o);case x.ARRAY:return sy(e,t,s,o);case x.PARTIAL:return iy(e,t,s,o);case x.PATH_REFERENCE:return oy(e,t,s,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Rl=new Map,Gm=e=>{let t=[],s="",o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")s&&(t.push({type:"property",value:s}),s=""),o=!0;else if(r==="]"){if(o&&s){let n=s.trim();if(/^\d+$/.test(n))t.push({type:"index",value:parseInt(n,10)});else if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")){let i=n.slice(1,-1);t.push({type:"property",value:i})}else t.push({type:"property",value:n});s=""}o=!1}else s+=r}return s&&t.push({type:"property",value:s}),t},ke=(e,t,s)=>{if(!e)return;if(e in s)return s[e];let o=Rl.get(e);if(!o){let r=[],n="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,n+=c):c==="]"?(i--,n+=c):c==="."&&i===0?n&&(r.push(n),n=""):n+=c}n&&r.push(n),o=[];for(let l of r){let c=Gm(l.trim());o.push(...c)}Rl.set(e,o)}let a=t;for(let r=0;r<o.length;r++){let n=o[r];if(n.type==="property"&&n.value in s){a=s[n.value];continue}if(a==null)return;(n.type==="property"||n.type==="index")&&(a=a[n.value])}return a},Hm=(e,t,s,o)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let n=se(r,t,s,o);a.push(n!=null?String(n):"")}return a.join("")},$l=(e,t,s,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Ol(e.name,a);let n=e.args.map(i=>se(i,t,s,o));return r(...n)},Pr=(e,t,s,o)=>{if(e.var&&!e.type)return ke(e.var,s,o);switch(e.type){case x.VARIABLE:return ke(e.path,s,o);case x.LITERAL:return e.value;case x.BINARY:return Cl(e,t,s,o);case x.UNARY:return _l(e,t,s,o);case x.FUNCTION:return $l(e,t,s,o);default:return se(e,t,s,o)}},Cl=(e,t,s,o)=>{if(e.op===ee.AND||e.op===ee.OR){let n=Pr(e.left,t,s,o),i=Pr(e.right,t,s,o);switch(e.op){case ee.AND:return n&&i;case ee.OR:return n||i}}let a=se(e.left,t,s,o),r=se(e.right,t,s,o);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new Ne(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},_l=(e,t,s,o)=>{let a=e.op===ht.NOT?Pr(e.operand,t,s,o):se(e.operand,t,s,o);if(e.op===ht.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Km=(e,t,s,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ke(a.path,s,o)){let n=e.bodies[0];if(n.type===x.OBJECT&&n.properties.length<=5){let i={};for(let l of n.properties){let c=l.parsedKey?se(l.parsedKey,t,s,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,s,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let f=ke(m.path,s,o);p.push(f!=null?String(f):"")}else{let f=se(m,t,s,o);p.push(f!=null?String(f):"")}i[c]=p.join("")}else i[c]=se(u,t,s,o)}return i}}else{let n=e.bodies[1];if(n.type===x.OBJECT&&n.properties.length<=5){let i={};for(let l of n.properties){let c=l.parsedKey?se(l.parsedKey,t,s,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,s,o);else if(u.type===x.INTERPOLATION){let p=[];for(let m of u.parts)if(typeof m=="string")p.push(m);else if(m.type===x.VARIABLE){let f=ke(m.path,s,o);p.push(f!=null?String(f):"")}else{let f=se(m,t,s,o);p.push(f!=null?String(f):"")}i[c]=p.join("")}else i[c]=se(u,t,s,o)}return i}}}return null},Wm=(e,t,s,o)=>{let a=Km(e,t,s,o);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let n=e.conditions[r];if(n===null||Pr(n,t,s,o))return se(e.bodies[r],t,s,o)}return jl},Jm=(e,t)=>{let s=e.body,o=e.itemVar;if(s.type===x.CONDITIONAL&&s.conditions.length===1&&s.conditions[0].type===x.VARIABLE){let a=s.conditions[0].path,r=s.bodies[0];if(a.startsWith(o+".")){let n=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[n]){let u={};for(let p of r.properties){let m=p.key,f=p.value;if(f.type===x.LITERAL)u[m]=f.value;else if(f.type===x.VARIABLE){let d=f.path;if(d===o)u[m]=c;else if(d.startsWith(o+".")){let g=d.substring(o.length+1);u[m]=c[g]}else return null}else if(f.type===x.INTERPOLATION){let d=[],g=!0;for(let b of f.parts)if(typeof b=="string")d.push(b);else if(b.type===x.VARIABLE){let y=b.path;if(y===o)d.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),h=c[w];d.push(h!=null?String(h):"")}else{g=!1;break}}else{g=!1;break}if(!g)return null;u[m]=d.join("")}else return null}i.push(u)}}return i}}}return null},Qm=(e,t)=>{let s=e.body,o=e.itemVar,a=Jm(e,t);if(a!==null)return a;if(s.type===x.OBJECT&&s.properties.length<=5&&!s.whenCondition){for(let i of s.properties)if(i.parsedKey)return null;let r=[],n=!0;for(let i of s.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{n=!1;break}}else{n=!1;break}}else if(c.type===x.INTERPOLATION&&c.parts.length===1){let u=c.parts[0];if(u.type===x.VARIABLE){let p=u.path;if(p===o)r.push({key:l,type:"item_string"});else if(p.startsWith(o+".")){let m=p.substring(o.length+1);if(!m.includes(".")&&!m.includes("["))r.push({key:l,type:"prop_string",prop:m});else{n=!1;break}}else{n=!1;break}}else{n=!1;break}}else{n=!1;break}}if(n){let i=new Array(t.length);if(r.length===3&&r[0].type==="prop"&&r[0].key==="id"&&r[1].type==="prop_string"&&r[1].key==="title"&&r[2].type==="prop"&&r[2].key==="completed")for(let l=0;l<t.length;l++){let c=t[l];i[l]={id:c.id,title:c.title!=null?String(c.title):"",completed:c.completed}}else for(let l=0;l<t.length;l++){let c=t[l],u={};for(let p of r)if(p.type==="literal")u[p.key]=p.value;else if(p.type==="item")u[p.key]=c;else if(p.type==="prop")u[p.key]=c[p.prop];else if(p.type==="item_string")u[p.key]=c!=null?String(c):"";else if(p.type==="prop_string"){let m=c[p.prop];u[p.key]=m!=null?String(m):""}i[l]=u}return i}}return null},Zm=(e,t,s,o,a)=>{let r=[],n=e.body;if(n.type===x.OBJECT&&n.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},m={...o,[i]:u,...l&&{[l]:c}};m.__paths__||(m.__paths__=o.__paths__||{});let f=e.iterable.path||"";if(o&&o.__paths__&&f){let d=f.split("."),g=d[0];g in o.__paths__&&(f=o.__paths__[g],d.length>1&&(f+="."+d.slice(1).join(".")))}m.__paths__={...m.__paths__,[i]:`${f}[${c}]`,...l&&{[l]:c}};for(let d of n.properties){let g=d.parsedKey?se(d.parsedKey,t,s,m):d.key,b=d.value;if(b.type===x.LITERAL)p[g]=b.value;else if(b.type===x.VARIABLE){let y=b.path;if(y===i)p[g]=u;else if(y===l)p[g]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[g]=u[w]:p[g]=ke(y,s,{...o,[i]:u,...l&&{[l]:c}})}else p[g]=ke(y,s,{...o,[i]:u,...l&&{[l]:c}})}else if(b.type===x.INTERPOLATION){let y=[];for(let w of b.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let h=w.path,P;if(h===i)P=u;else if(h===l)P=c;else if(h.startsWith(i+".")){let k=h.substring(i.length+1);!k.includes(".")&&!k.includes("[")?P=u[k]:P=ke(h,s,{...o,[i]:u,...l&&{[l]:c}})}else P=ke(h,s,{...o,[i]:u,...l&&{[l]:c}});y.push(P!=null?String(P):"")}else{let h={...o,[i]:u,...l&&{[l]:c}},P=se(w,t,s,h);y.push(P!=null?String(P):"")}p[g]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[g]=se(b,t,s,y)}}r.push(p)}return r}return null},ey=(e,t,s)=>{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 n=r.bodies[0];if(n.type===x.OBJECT&&n.properties.length===2){let i=n.properties[0],l=n.properties[1];if(i.key==="id"&&i.value.type===x.VARIABLE&&i.value.path==="item.id"&&l.key==="$if item.highlighted"&&l.value.type===x.CONDITIONAL){let c=[];for(let u=0;u<t.length;u++){let p=t[u];if(p.visible){let m={id:p.id};p.highlighted?(m.highlight=!0,m.message=`This item is highlighted: ${p.name}`):(m.highlight=!1,m.message=p.name),c.push(m)}}return c}}}}return null},ry=(e,t,s,o)=>{let a=se(e.iterable,t,s,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let m=e.iterable.args.map(f=>f.type===x.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===x.VARIABLE?f.path:f.type===x.FUNCTION?`${f.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${m})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Sl(p,a,u)}if(!e.indexVar){let c=ey(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=Qm(e,a);if(c!==null)return c}let r=Zm(e,t,s,o,a);if(r!==null)return r;let n=[],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=se(e.body,t,s,u);if(Array.isArray(p)&&p.length===1&&!l){let m=p[0];n.push(m===void 0?{}:m)}else n.push(p===void 0?{}:p)}return n},ty=(e,t,s,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?se(a.parsedKey,t,s,o):a.key,n=a.value;if(n.type===x.OBJECT&&n.properties.length<=10&&!n.whenCondition){let i={},l={},c=!0;for(let u of n.properties){let p=u.parsedKey?se(u.parsedKey,t,s,o):u.key,m=u.value;if(m.type===x.LITERAL)l[p]=m.value;else if(m.type===x.VARIABLE)l[p]=ke(m.path,s,o);else if(m.type===x.INTERPOLATION){let f=[];for(let d of m.parts)if(typeof d=="string")f.push(d);else if(d.type===x.VARIABLE){let g=ke(d.path,s,o);f.push(g!=null?String(g):"")}else{c=!1;break}if(!c)break;l[p]=f.join("")}else if(m.type===x.OBJECT&&m.properties.length<=5){let f={};for(let d of m.properties){let g=d.key,b=d.value;if(b.type===x.LITERAL)f[g]=b.value;else if(b.type===x.VARIABLE)f[g]=ke(b.path,s,o);else if(b.type===x.INTERPOLATION){let y=[];for(let w of b.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let h=ke(w.path,s,o);y.push(h!=null?String(h):"")}else{c=!1;break}if(!c)break;f[g]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=f}else{c=!1;break}}if(c)return i[r]=l,i}}return null},ny=(e,t,s,o)=>{let a=t.functions||t;if(e.whenCondition&&!Pr(e.whenCondition,a,s,o))return;let r=ty(e,t,s,o);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?se(u.parsedKey,t,s,o):u.key,m=u.value;if(m.type===x.LITERAL)c[p]=m.value;else if(m.type===x.VARIABLE)c[p]=ke(m.path,s,o);else if(m.type===x.INTERPOLATION){let f=[];for(let d of m.parts)if(typeof d=="string")f.push(d);else if(d.type===x.VARIABLE){let g=ke(d.path,s,o);f.push(g!=null?String(g):"")}else{let g=se(d,t,s,o);f.push(g!=null?String(g):"")}c[p]=f.join("")}else c[p]=se(m,t,s,o)}return c}let n={},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=se(c.value,t,s,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(n,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return se(c.value,t,s,o)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(m=>m.key.startsWith("$for "));if(p){let m=se(p.value,t,s,o);m!==void 0&&(n[c.key]=m)}else{let m=se(c.value,t,s,o);m!==void 0&&(n[c.key]=m)}}else{let p=c.parsedKey?se(c.parsedKey,t,s,o):c.key,m=se(c.value,t,s,o);m!==void 0&&(n[p]=m)}}return n},jl={},sy=(e,t,s,o)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let n=se(r,t,s,o);Array.isArray(n)&&r.flatten!==!1?a.push(...n):a.push(n)}else{let n=se(r,t,s,o);n!==jl&&n!==void 0&&a.push(n)}return a},iy=(e,t,s,o)=>{let{name:a,data:r,whenCondition:n}=e,i=t.partials||{},l=t.functions||t;if(n&&!Pr(n,l,s,o))return;if(!i[a])throw new Ne(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new Ne(`Circular partial reference detected: ${a}`);let u=i[a],p=s,m={...o,_partialStack:[...c,a]};if(o){p={...s};for(let f of Object.keys(o))f.startsWith("_")||(p[f]=o[f])}if(r){let f=se(r,t,s,o);p={...p,...f}}return se(u,t,p,m)},oy=(e,t,s,o)=>{let{path:a}=e,r=a.split("."),n=r[0],i=r.slice(1);if(!o||!(n in o))throw new Ne(`Path reference '#{${a}}' refers to '${n}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(n in o.__paths__))throw new Ne(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[n];if(typeof l=="number"){if(i.length>0)throw new Ne(`Path reference '#{${a}}' - cannot access properties on index variable '${n}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Hi=Xm;var ay=/\$\{([^}]*)\}/g,ly=/#\{([^}]*)\}/g,Dl=(e,t={})=>{let s=e.match(/^(\w+)\((.*)\)$/);if(!s)return{isFunction:!1};let[,o,a]=s,r=cy(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},cy=(e,t={})=>e.trim()?uy(e).map(o=>py(o.trim(),t)):[],uy=e=>{let t=[],s="",o=0,a=!1,r="";for(let n=0;n<e.length;n++){let i=e[n],l=n>0?e[n-1]:"";!a&&(i==='"'||i==="'")?(a=!0,r=i,s+=i):a&&i===r&&l!=="\\"?(a=!1,r="",s+=i):!a&&i==="("?(o++,s+=i):!a&&i===")"?(o--,s+=i):!a&&i===","&&o===0?(t.push(s),s=""):s+=i}return s&&t.push(s),t},py=(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 s=Dl(e,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,n=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Gr(o.substring(c),i);if(u===-1)break;let p=c+u;p>r&&(r=p,n={op:i,type:l}),c=p+i.length}}if(r!==-1)try{return Ee(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Tl=/^\w+\(.*\)$/,fy=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,dy=e=>{if(!(!e||e.trim()===""||Tl.test(e))&&fy.test(e))throw e.includes("?")&&e.includes(":")?new L(`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 L(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new L(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},Nl=e=>{let t=e.trim();if(Tl.test(t))throw new L(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new L(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new L(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new L(`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 L(`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}},Vt=(e,t={})=>{let s=e.trim();dy(s);let o=Dl(s,t);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(s.includes("[")&&!/[\s+\-*/%|&?:]/.test(s)){let a=0;for(let r of s)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:s}},Ki=(e,t={})=>{let s=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(s=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),s=s.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),s=s.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),s=s.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),s=s.replace(/\\DOUBLE_ESC_VAR/g,"\\"),s=s.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...s.matchAll(ay)],r=[...s.matchAll(ly)],n=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(n.length===0){let c=s;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:x.LITERAL,value:c}}if(n.length===1&&n[0].match[0]===s&&o.length===0){let{match:c,type:u}=n[0];try{return u==="variable"?Vt(c[1],t):Nl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:s};throw p}}let i=[],l=0;for(let{match:c,type:u}of n){let[p,m]=c,f=c.index;if(f>l){let d=s.substring(l,f);for(let g=0;g<o.length;g++)d=d.replace(`__ESCAPED_${g}__`,o[g]);d&&i.push(d)}try{let d;u==="variable"?d=Vt(m.trim(),t):d=Nl(m.trim()),i.push(d)}catch(d){if(d.message==="Invalid array index syntax")i.push(p);else throw d}l=f+p.length}if(l<s.length){let c=s.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 Qi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ql=e=>Object.keys(e),Ce=e=>e.join("."),Er=(e,t,s)=>{let o=ql(e).filter(a=>!t.has(a));if(o.length>0)throw new L(`Unexpected key '${o[0]}' in condition JSON at '${Ce(s)}'`)},xr=(e,t)=>typeof e=="string"?Ki(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?yy(e,t):hy(e,t):{type:x.LITERAL,value:e},my=e=>{let{$each:t,...s}=e;if(typeof t!="string")throw new L("$each value must be a non-empty string");let o=t.trim();if(o==="")throw new L("$each value must be a non-empty string");if(Object.keys(s).length===0)throw new L("Empty $each body not allowed");if(s.$partial!==void 0)throw new L("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:s}},yy=(e,t)=>{let s=[],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=my(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=Ml(c[0],l[c[0]],t,!0);s.push(u),o=!0;continue}}catch(l){throw l instanceof L?l:new L(l.message)}let i=Object.keys(r);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Ml(i[0],r[i[0]],t);s.push(l),o=!0;continue}}let n=xr(r,t);s.push(n),(n.type===x.FUNCTION||n.type===x.CONDITIONAL||n.type===x.LOOP||n.type===x.PARTIAL||n.type===x.OBJECT&&!n.fast||n.type===x.ARRAY&&!n.fast)&&(o=!0)}return{type:x.ARRAY,items:s,fast:!o}},hy=(e,t)=>{let s=[],o=!1,a=null,r=Object.entries(e),n=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new L("$partial value must be a string");if(e.$partial.trim()==="")throw new L("$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 L(`Cannot use $partial with ${c.join(", ")} at the same level. Wrap $partial in a parent object if you need conditionals.`);let{$partial:u,$when:p,...m}=e,f={},d=!1;for(let[y,w]of Object.entries(m)){let h=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(h=y.slice(1)),f[h]=w,d=!0}let g=null;if(d&&(g=xr(f,t),g.type===x.OBJECT)){let y=!1;for(let w of g.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&&(g.fast=!1)}let b={type:x.PARTIAL,name:u,data:g};return p!==void 0&&(b.whenCondition=Ll(p,t)),b}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new L("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new L("Missing condition expression after '$when'");a=Ll(c,t),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new L("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;n<r.length;){let[l,c]=r[n];if(l==="$when"){n++;continue}if(l==="$each")throw new L("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=gy(r,n,t);s.push({key:l,value:u.node}),o=!0,n=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new L(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new L(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new L("Missing condition expression after '$if'");{let u=xr(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=Ki(l,t),m={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(m.parsedKey=p),s.push(m),n++}}}let i={type:x.OBJECT,properties:s,fast:!o};return a&&(i.whenCondition=a),i},gy=(e,t,s={})=>{let o=[],a=[],r=t,[n,i]=e[r],l=null,c;if(n.startsWith("$if#")){let p=n.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new L(`Invalid conditional syntax: ${n}`)}else c=n.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Gi(c);let u=Ee(c,s);for(o.push(u),a.push(xr(i,s)),r++;r<e.length;){let[p,m]=e[r],f=!1,d;if(l?p.startsWith(`$elif#${l} `)?(d=p.substring(`$elif#${l} `.length),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(f=!0,d=null):p.startsWith("$elif ")?(d=p.substring(6),d.endsWith(":")&&(d=d.slice(0,-1).trim()),f=!0):(p==="$else"||p==="$else:")&&(f=!0,d=null),f){if(d===null)o.push(null);else{Gi(d);let g=Ee(d,s);o.push(g)}if(a.push(xr(m,s)),r++,d===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Wi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},Ji={all:ee.AND,any:ee.OR},by=new Set(["var","literal","call","not",...Object.keys(Wi),...Object.keys(Ji)]),wy=(e,t,s)=>{if(!Array.isArray(e))throw new L(`Condition JSON operator '${t}' at '${Ce(s)}' requires an array`);if(e.length!==2)throw new L(`Condition JSON operator '${t}' at '${Ce(s)}' requires exactly 2 operands`);return e},Iy=(e,t,s,o,a)=>{if(!Array.isArray(e))throw new L(`Condition JSON operator '${t}' at '${Ce(a)}' requires an array`);if(e.length===0)throw new L(`Condition JSON operator '${t}' at '${Ce(a)}' requires at least 1 condition`);return e.map((n,i)=>Me(n,o,[...a,i])).reduce((n,i)=>({type:x.BINARY,op:s,left:n,right:i}))},vy=(e,t,s)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],Er(e,new Set(["call","args"]),s);else if(Qi(e.call))o=e.call.name,a=e.call.args??[],Er(e,new Set(["call"]),s),Er(e.call,new Set(["name","args"]),[...s,"call"]);else throw new L(`Condition JSON call at '${Ce(s)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new L(`Condition JSON call at '${Ce(s)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new L(`Invalid condition JSON function name '${o}' at '${Ce(s)}'`);if(!Array.isArray(a))throw new L(`Condition JSON call '${o}' at '${Ce(s)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,n)=>Me(r,t,[...s,"args",n]))}},Me=(e,t={},s=["$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 L(`Condition JSON array at '${Ce(s)}' must be wrapped in an operator or { literal: [...] }`);if(!Qi(e))throw new L(`Invalid condition JSON value at '${Ce(s)}'`);let o=ql(e);if(o.length===0)throw new L(`Condition JSON object at '${Ce(s)}' must contain an operator`);let a=o.filter(n=>by.has(n));if(a.length===0)throw new L(`Unknown condition JSON operator '${o[0]}' at '${Ce(s)}'`);if(a.length>1)throw new L(`Condition JSON at '${Ce(s)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(Er(e,new Set(["var"]),s),typeof e.var!="string"||e.var.trim()==="")throw new L(`Condition JSON var at '${Ce(s)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return Er(e,new Set(["literal"]),s),{type:x.LITERAL,value:e.literal};if(r==="call")return vy(e,t,s);if(r==="not")return Er(e,new Set(["not"]),s),{type:x.UNARY,op:ht.NOT,operand:Me(e.not,t,[...s,"not"])};if(r in Ji)return Er(e,new Set([r]),s),Iy(e[r],r,Ji[r],t,[...s,r]);if(r in Wi){Er(e,new Set([r]),s);let n=wy(e[r],r,[...s,r]);return{type:x.BINARY,op:Wi[r],left:Me(n[0],t,[...s,r,0]),right:Me(n[1],t,[...s,r,1])}}throw new L(`Unknown condition JSON operator '${r}' at '${Ce(s)}'`)},Ll=(e,t={})=>{if(e==null)throw new L("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new L("Empty condition expression after '$when'");return Ee(e,t)}return Qi(e)||Array.isArray(e)?Me(e,t):{type:x.LITERAL,value:e}},Ee=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let m=0;m<c.length;m++)if(c[m]==="("?u++:c[m]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Ee(c,t)}let s=Gr(e,"||");if(s!==-1)return{type:x.BINARY,op:ee.OR,left:Ee(e.substring(0,s).trim(),t),right:Ee(e.substring(s+2).trim(),t)};let o=Gr(e,"&&");if(o!==-1)return{type:x.BINARY,op:ee.AND,left:Ee(e.substring(0,o).trim(),t),right:Ee(e.substring(o+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Gr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Ee(e.substring(0,p).trim(),t),right:Ee(e.substring(p+c.length).trim(),t)}}let r=-1,n=null,i=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let m=Gr(e.substring(p),c);if(m===-1)break;let f=p+m;f>r&&(r=f,n={op:c,type:u}),p=f+c.length}}if(r!==-1&&n)return{type:x.BINARY,op:n.type,left:Ee(e.substring(0,r).trim(),t),right:Ee(e.substring(r+n.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Gr(e,c)!==-1)throw new L(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:ht.NOT,operand:Ee(e.substring(1).trim(),t)}:Vl(e,t)},Gr=(e,t)=>{let s=0,o=0;for(;o<=e.length-t.length;){if(e[o]==="(")s++;else if(e[o]===")")s--;else if(s===0&&e.substring(o,o+t.length)===t)return o;o++}return-1},ky=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 s=e.trim();if(s.match(/^(\w+)\((.*)\)$/))return Vt(s,t);let a=ky(s);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(s))return{type:x.VARIABLE,path:s};try{return Vt(s,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Ay=(e,t=!1)=>{let s=t?"$each":"$for";try{xl(e)}catch(o){if(o instanceof L&&t){let a=o.message.replace(/\$for/g,"$each");throw new L(a.replace("Parse Error: ",""))}throw o}},Ml=(e,t,s,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let b=o?"$each":"$for";throw new L(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let n=r[1],i=r[2].trim();Ay(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let b=o?"$each":"$for";throw new L(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${i}')`)}let c=l[1].trim(),u=l[2].trim(),p,m=null;if(c.includes(",")){let b=c.split(",").map(y=>y.trim());if(b.length!==2)throw new L(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=b[0],m=b[1]}else p=c;let f=["this","undefined","null","true","false"];if(f.includes(p))throw new L(`Reserved variable name: ${p}`);if(m&&f.includes(m))throw new L(`Reserved variable name: ${m}`);let d=Vl(u,s),g=xr(t,s);return{type:x.LOOP,itemVar:p,indexVar:m,iterable:d,body:g,flatten:n!=="nested"}};var Py=(e,t={})=>{let{functions:s={}}=t;return xr(e,s)},Bn=Py;var Ft={};Tm(Ft,{now:()=>Ey});var Ey=()=>Date.now();var xy=(e,t,s={})=>{let{functions:o={},partials:a={}}=s,r={...Ft,...o},n=Bn(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=Bn(c,{functions:r});return Hi(n,t,{functions:r,partials:i})},Hr=xy;var Sy=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Oy=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Ry=(e,t)=>{if(Sy(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new L("Empty condition expression");return Ee(e,t)}return Me(e,t)},$y=(e,t={},s={})=>{let o=Oy(s),a={...Ft,...o},r=Ry(e,a);return!!Pr(r,{functions:a,partials:{}},t,{})},Zi=$y;var lo=Symbol("runStoreTransaction"),no="__routeEngineConditionComparison",Un=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",Sr=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Un(e,t)&&e>t,gte:(e,t)=>Un(e,t)&&e>=t,lt:(e,t)=>Un(e,t)&&e<t,lte:(e,t)=>Un(e,t)&&e<=t}),Hl=Object.freeze(Object.fromEntries(Object.keys(Sr).map(e=>[e,`${no}${e}`]))),Cy=Object.freeze(Object.fromEntries(Object.entries(Hl).map(([e,t])=>[t,Sr[e]]))),Fl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),_y=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},Yn=e=>{if(Array.isArray(e))return e.map(Yn);if(e===null||typeof e!="object"||Fl(e,"literal")||Fl(e,"var"))return e;if(_y(e)?.startsWith(no))throw new Error(`Condition function names beginning with "${no}" are reserved`);let s=Object.entries(e);if(s.length===1){let[[o,a]]=s,r=Hl[o];if(r)return{call:r,args:a.map(Yn)}}return Object.fromEntries(s.map(([o,a])=>[o,Yn(a)]))},Ut=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Zi(Yn(e),t,{functions:Cy})},jy=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Kl=(e,t,s={})=>{let o={},a={},{transformSelectorFirstArgument:r=g=>g,transformActionFirstArgument:n=g=>g,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=s,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},m=0,f=(g,b)=>!u||!c?g:Fn(g,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});for(let[g,b]of Object.entries(t))g!=="createInitialState"&&(g.startsWith("select")?o[g]=(...y)=>b(r(p.state,p.transactionalMetadata),...y):a[g]=(...y)=>{let w,h=p,P=Fn(p,k=>{let E=b(n(k.state,k.transactionalMetadata),...y);w=E!==void 0&&!Pe(E)?E:void 0,u&&l&&l({actionName:g,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:h.state,previousTransactionalMetadata:h.transactionalMetadata})});return m===0&&(P=f(P,h)),p=P,w});let d=g=>{if(typeof g!="function")throw new Error("Store transaction requires a callback");let b=p,y=m===0;m+=1;let w;try{w=g()}catch(h){throw m-=1,p=b,h}if(m-=1,y)try{p=f(p,b)}catch(h){throw p=b,h}return w};return{...o,...a,[lo]:d}},Hn=(e,t)=>s=>{let o=e(),a=Array.isArray(s)?s:[s];return Fn(o,r=>{a.forEach(n=>{t.forEach(i=>{i(r,n)})})})};var Ny=(e,t)=>{if(e.default!==void 0)return e.default;let s=["number","boolean","string","object"];if(!s.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${s.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},Q=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),so=(e,t,s)=>{Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0})},Ae=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Dy=new Set(["pageSize","groups"]),Ty=new Set(["id","variants"]),Ly=new Set(["id","imageId"]),My=new Set(["pageSize","tracks"]),qy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),Vy=new Set(["pageSize","replays"]),Fy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Kr=(e,t,s)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${s} contains unsupported property "${o}"`)})},gt=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Yt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!Ae(t))throw new Error("resources.imageGallery must be an object");if(Kr(t,Dy,"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 s=new Set;for(let[o,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);if(Kr(a,Ty,r),gt(a.id,`${r}.id`),s.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(s.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let n=new Set;for(let[i,l]of a.variants.entries()){let c=`${r}.variants[${i}]`;if(!Ae(l))throw new Error(`${c} must be an object`);if(Kr(l,Ly,c),gt(l.id,`${c}.id`),gt(l.imageId,`${c}.imageId`),n.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(n.add(l.id),!Q(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},zt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!Ae(t))throw new Error("resources.musicRoom must be an object");if(Kr(t,My,"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 s=new Set;for(let[o,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);Kr(a,qy,r);for(let l of["id","soundId","title"])gt(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&>(a[l],`${r}.${l}`);if(s.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);s.add(a.id);let n=e?.resources?.sounds?.[a.soundId];if(!Q(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Ae(n))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(n.playbackRate!==void 0&&(typeof n.playbackRate!="number"||!Number.isFinite(n.playbackRate)||n.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let i=n.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(n.endAt!==void 0&&n.endAt!==null&&(typeof n.endAt!="number"||!Number.isFinite(n.endAt)||n.endAt<=i))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!Q(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},By=(e,t,s)=>{let o=Array.isArray(s)?"array":typeof s;switch(t.type){case"number":if(typeof s!="number"||!Number.isFinite(s))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof s!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof s!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(s===null||typeof s!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},Xt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!Ae(t))throw new Error("resources.sceneReplay must be an object");if(Kr(t,Vy,"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 s=e?.story?.scenes??{},o=new Set;for(let[a,r]of t.replays.entries()){let n=`resources.sceneReplay.replays[${a}]`;if(!Ae(r))throw new Error(`${n} must be an object`);Kr(r,Fy,n);for(let u of["sceneId","title","thumbnailImageId"])gt(r[u],`${n}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!Q(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let i=s[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(!Ae(r.initialVariables))throw new Error(`${n}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let m=e?.resources?.variables?.[u];if(!m)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(_e(m))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(m.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(m.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);By(u,m,p)}}}},Wl=e=>{let t=Pe(e)?Ar(e):e;return structuredClone(t)},Uy=({characterId:e,resourceCharacter:t,variables:s={}}={})=>{if(!Q(t,"nameVariableId"))return;let o=t.nameVariableId,a=s?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Kn=({characterId:e,character:t,characterName:s,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0;if(t?.name!==void 0)return t.name;if(s!==void 0)return s;let n=Uy({characterId:e,resourceCharacter:r,variables:a});return n!==void 0?n:r?.name||""},_e=e=>Q(e,"computed"),co=(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}},Gt=(e={},t={},{allowedScopes:s,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let n=t[a];return n===void 0?o:!_e(n)&&(!s||s.includes(n.scope))&&co(n,r)})),Xe=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),Yy=(e,t,s)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Xe(t,s)}let a="";for(let r=1;r<e.length-1;r+=1){let n=e[r];if(n!=="\\"){if(n.charCodeAt(0)<32)throw Xe(t,s);a+=n;continue}if(r+=1,r>=e.length-1)throw Xe(t,s);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 Xe(t,s);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
-
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!Q(l,i))throw Xe(t,s);a+=l[i]}return a},Jl=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Xe(e,t);let s=[],o=0,a=()=>{let n=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(n,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw Xe(e,t);s.push(i)},r=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let n=e[o];if(/\d/.test(n??"")){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 Xe(e,t);o+=1,s.push(p);return}if(n!=='"'&&n!=="'")throw Xe(e,t);let i=n,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 Xe(e,t);o+=1,s.push(Yy(p,e,t));return}o+=1}if(c||o>=e.length)throw Xe(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Xe(e,t)}return s},eo=(e,t)=>{let s=e;for(let o of t){if(s==null||!Q(s,o))return;s=s[o]}return s},Ql=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let s=Jl(e),[o,a,...r]=s;if(o==="variables"){if(!a)return t.variables;let n=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return eo(n,r)}return o==="runtime"?eo(t.runtime,s.slice(1)):eo(t,s)},Zl=(e,t,s)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(s!==void 0&&t.length!==s)throw new Error(`Computed expression operator "${e}" requires ${s} operand(s)`)},io=(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`)},zy=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Je=(e,t,s,o)=>(Zl(e,t,o),t.map(a=>Gn(a,s))),ze=(e,t,s,o)=>{let a=Je(e,t,s,o);return a.forEach(r=>zy(e,r)),a},Xy=(e,t,s)=>{switch(e){case"var":return Ql(t,s);case"add":{let[o,a]=ze(e,t,s,2);return o+a}case"sub":{let[o,a]=ze(e,t,s,2);return o-a}case"mul":{let[o,a]=ze(e,t,s,2);return o*a}case"div":{let[o,a]=ze(e,t,s,2);return o/a}case"mod":{let[o,a]=ze(e,t,s,2);return o%a}case"neg":{let[o]=ze(e,t,s,1);return-o}case"round":{let[o]=ze(e,t,s,1);return Math.round(o)}case"floor":{let[o]=ze(e,t,s,1);return Math.floor(o)}case"ceil":{let[o]=ze(e,t,s,1);return Math.ceil(o)}case"min":{let[o,a]=ze(e,t,s,2);return Math.min(o,a)}case"max":{let[o,a]=ze(e,t,s,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=ze(e,t,s,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=Je(e,t,s,2);return Sr.eq(o,a)}case"neq":{let[o,a]=Je(e,t,s,2);return Sr.neq(o,a)}case"gt":{let[o,a]=Je(e,t,s,2);return Sr.gt(o,a)}case"gte":{let[o,a]=Je(e,t,s,2);return Sr.gte(o,a)}case"lt":{let[o,a]=Je(e,t,s,2);return Sr.lt(o,a)}case"lte":{let[o,a]=Je(e,t,s,2);return Sr.lte(o,a)}case"in":{let[o,a]=Je(e,t,s,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return io(e,t),t.every(o=>!!Gn(o,s));case"or":case"any":return io(e,t),t.some(o=>!!Gn(o,s));case"not":{let[o]=Je(e,t,s,1);return!o}case"length":{let[o]=Je(e,t,s,1);return typeof o=="string"||Array.isArray(o)?o.length:Ae(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Je(e,t,s,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return Wl(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Gn=(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 s=Object.entries(e);if(s.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=s;return Xy(o,a,t)},oo=(e,t)=>{if(e===null||typeof e!="object"||Q(e,"literal"))return e;if(Q(e,"var"))return{literal:Ql(e.var,t)};if(Q(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,Array.isArray(o)?o.map(a=>oo(a,t)):oo(o,t)]))},Gy=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Ut(oo(e,t))},ec=(e,t)=>{if(!Ae(e))throw new Error(`${t} must be an object`);let s=Q(e,"expr"),o=Q(e,"value");if(s===o)throw new Error(`${t} must contain exactly one of expr or value`)},ro=(e,t,s)=>(ec(e,t),Q(e,"value")?Wl(e.value):Gn(e.expr,s)),Hy=(e,t={},s="unknown")=>{if(!Ae(e))throw new Error(`Computed variable "${s}" computed must be an object`);let o=Q(e,"expr"),a=Q(e,"value");if(Q(e,"branches")){if(o||a)throw new Error(`Computed variable "${s}" cannot combine branches with expr or value`);if(!Array.isArray(e.branches))throw new Error(`Computed variable "${s}" branches must be an array`);if(e.branches.length===0)throw new Error(`Computed variable "${s}" branches must not be empty`);if(!Ae(e.default))throw new Error(`Computed variable "${s}" requires default`);for(let n=0;n<e.branches.length;n+=1){let i=e.branches[n];if(!Ae(i))throw new Error(`Computed variable "${s}" branch ${n} must be an object`);if(!Q(i,"when"))throw new Error(`Computed variable "${s}" branch ${n} requires when`);if(Gy(i.when,t))return ro(i,`Computed variable "${s}" branch ${n}`,t)}return ro(e.default,`Computed variable "${s}" default`,t)}if(o===a)throw new Error(`Computed variable "${s}" must contain exactly one of expr, value, or branches`);return ro(e,`Computed variable "${s}"`,t)},rc=(e,t,s)=>{switch(t){case"number":if(typeof s!="number"||!Number.isFinite(s))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(s)?"array":typeof s}`);return;case"boolean":if(typeof s!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(s)?"array":typeof s}`);return;case"string":if(typeof s!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(s)?"array":typeof s}`);return;case"object":if(s===null||typeof s!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof s}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},Ky=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}),Wy=new Set(["and","or","all","any"]),Jy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Qy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Zy=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),eh=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),tc=new WeakMap,Bl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,zn=(e,t,s)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${s} contains unsupported property "${o}"`)},rh=(e,t,s,o)=>{if(s!==void 0&&s!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${s}`)},nc=(e,{variableId:t,variableConfigs:s,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[n,i,...l]=Jl(e,r);if(n!=="variables"&&n!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${r} must reference a concrete ${n} member, got ${JSON.stringify(e)}`);if(n==="runtime")return;if(!Q(s,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=s[i];return _e(c)&&o.add(i),l.length===0?c?.type:void 0},sc=(e,{variableId:t,variableConfigs:s,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 Bl(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[[n,i]]=r;if(n==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return nc(i,{variableId:t,variableConfigs:s,dependencies:o,path:a})}if(n==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Bl(i)}let l=Ky[n];if(l===void 0&&!Wy.has(n))throw new Error(`Unknown computed expression operator: ${n}`);l===void 0?io(n,i):Zl(n,i,l);let c=i.map((u,p)=>sc(u,{variableId:t,variableConfigs:s,dependencies:o,path:`${a}.${n}[${p}]`}));if(Qy.has(n)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${n}" requires numeric operands`)}),Jy.has(n))return"number";if(Zy.has(n))return"boolean"},th=(e,{variableId:t,variableConfigs:s,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Me(e)}catch(n){throw new Error(`Computed variable "${t}" ${a} is invalid: ${n.message}`,{cause:n})}let r=(n,i)=>{if(n===null||typeof n!="object"||Q(n,"literal"))return;if(Q(n,"var")){nc(n.var,{variableId:t,variableConfigs:s,dependencies:o,path:i});return}if(Q(n,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(Q(n,"not")){r(n.not,`${i}.not`);return}let l=Object.keys(n).find(c=>eh.has(c));n[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},to=(e,{variableId:t,variableConfig:s,variableConfigs:o,dependencies:a,path:r,allowedKeys:n=new Set(["expr","value"])})=>{if(ec(e,`Computed variable "${t}" ${r}`),zn(e,n,r),Q(e,"value")){rc(t,s.type,e.value);return}let i=sc(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});rh(t,s.type,i,`${r}.expr`)},nh=(e,t,s)=>{let o=t.computed;if(!Ae(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=Q(o,"expr"),n=Q(o,"value");if(Q(o,"branches")){if(zn(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||n)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(!Ae(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Ae(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(zn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!Q(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);th(l.when,{variableId:e,variableConfigs:s,dependencies:a,path:`computed.branches[${c}].when`}),to(l,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),to(o.default,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:"computed.default"}),a}if(zn(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===n)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return to(o,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:"computed"}),a},Wr=(e={})=>{if(!Ae(e))throw new Error("Variable configs must be an object");if(Q(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(Q(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,n])=>{if(_e(n)){if(!Ae(n))throw new Error(`Computed variable "${r}" must be an object`);if(!Q(n,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!Q(n,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(Q(n,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Ht(n.scope,r),!["number","boolean","string","object"].includes(n.type))throw new Error(`Invalid variable type: ${n.type} for computed variable ${r}`);t.set(r,nh(r,n,e))}});let s=new Set,o=[];t.forEach((r,n)=>{if(s.has(n))return;let i=[{variableId:n,dependencies:[...t.get(n)??[]],nextDependencyIndex:0}],l=new Map([[n,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),s.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,s.has(u))continue;let p=l.get(u);if(p!==void 0){let m=[...i.slice(p).map(({variableId:f})=>f),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${m}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return tc.set(e,a),a},bt=({variables:e={},runtime:t={},variableConfigs:s={},eager:o=!0}={})=>{let{evaluationOrder:a}=tc.get(s)??Wr(s),r=Gt(e,s,{preserveUnknown:!0}),n=Object.entries(s).filter(([,b])=>_e(b)).map(([b])=>b),i=Object.create(null),l=[],c=new Map(a.map((b,y)=>[b,y])),u=-1,p=!1,m=b=>{if(Q(i,b))return i[b];let y=s[b];if(!_e(y))return Q(r,b)?r[b]:void 0;let w=l.indexOf(b);if(w>=0){let h=[...l.slice(w),b].join(" -> ");throw new Error(`Computed variable cycle detected: ${h}`)}l.push(b);try{let h=Hy(y.computed,g,b);return rc(b,y.type,h),so(i,b,h),h}finally{l.pop()}},f=b=>{if(Q(i,b))return i[b];let y=s[b];if(!_e(y))return Q(r,b)?r[b]:void 0;let w=c.get(b);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let h=u+1;h<=w;h+=1)m(a[h]),u=h}finally{p=!1}return i[b]}return m(b)},d=new Proxy({},{get:(b,y)=>{if(typeof y=="string")return f(y)},has:(b,y)=>typeof y=="string"&&(Q(r,y)||n.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...n])],getOwnPropertyDescriptor:(b,y)=>{if(!(typeof y!="string"||!Q(r,y)&&!n.includes(y)))return{enumerable:!0,configurable:!0}}}),g={variables:d,runtime:t,resolveVariable:f};return o?(n.forEach(b=>{f(b)}),{...r,...i}):d},sh=({variables:e={},runtime:t={},variableConfigs:s,projectData:o}={})=>{let a=s??o?.resources?.variables??{};return Wr(a),bt({variables:e,runtime:t,variableConfigs:a,eager:!0})},Wn=e=>{let t={},s={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(_e(a))return;let r=Ny(a,o);a.scope==="context"?so(t,o,r):so(s,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:s}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:s}},Ht=(e,t)=>{let s=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!s.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${s.join(", ")}`)},Kt=(e,t,s)=>{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 ${s}`);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 "${s}" of type "${e}". Valid operations: ${a.join(", ")}`)},ih=2,Ul=12,ic=(e=ih)=>{if(!Number.isInteger(e)||e<0||e>Ul)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Ul}.`);return e},oh=(e,t)=>{let s=10**t;return Math.round((e+Number.EPSILON)*s)/s},Xn=e=>typeof e=="number"&&Number.isFinite(e),Jn=(e,t,s,o,a={})=>{if(e==="number"){if(t==="set"&&!Xn(s))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!Xn(s))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!Xn(s))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(t==="divide"){if(s===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);ic(a.roundTo)}}},Qn=(e,t,s,o={})=>{let a=(n,i,l)=>{let c=n??i;if(!Xn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=n=>{let i=a(n,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 s;case"multiply":return a(e,1,"current value")*a(s,void 0,"value");case"divide":return oh(a(e,0,"current value")/r(s),ic(o.roundTo));case"increment":return a(e,0,"current value")+a(s,1,"value");case"decrement":return a(e,0,"current value")-a(s,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var uo=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let s=new Date(e),o=n=>String(n).padStart(2,"0"),a=String(s.getFullYear()),r={DD:o(s.getDate()),MM:o(s.getMonth()+1),MMM:jy[s.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(s.getHours()),mm:o(s.getMinutes()),ss:o(s.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,n=>r[n])},ah=(e,t)=>{let s=r=>r?.ui,o=s(e),a=s(t);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:t}:a&&o?{changeType:"update",data:t}:null},Bt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,lh=(e,t)=>{let s=e?.character?.sprite,o=t?.character?.sprite,a=Bt(s)?s:void 0,r=Bt(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},Yl=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let s of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[s]!==void 0&&(t[s]=e[s]);for(let s of["animationName","animationSpeed","loop"])e[s]!==void 0&&(t[s]=e[s]);return t},zl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Xl=(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,ch=(e,t)=>{let s={},o=Xl(Yl(e),Yl(t)),a=Xl(zl(e),zl(t));return o&&(s.resource=o),a&&(s.color=a),Object.keys(s).length>0?s:null},po=(e={},t={})=>{let s={},o=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)s[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(m=>m.applyMode==="persistent");!o.includes(l)&&(l!=="sfx"||p)&&(s[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(s[l]={changeType:"update",data:u})},r=ch(e.background,t.background);r&&(s.background=r),a("screen"),a("bgm"),a("voice");let n=ah(e.dialogue,t.dialogue);n&&(s.dialogue=n);let i=lh(e.dialogue,t.dialogue);return i&&(s.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),s},fo=(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 s=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};s("layout"),s("choice"),s("form"),s("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 n=t[a]?.items;Array.isArray(n)&&(t[a].items=n.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},uh=(e,t)=>{if(!e||!t)return;let s=e;for(let o of t.split(".")){if(s==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(s),o))return;s=s[o]}return s},Gl=e=>e!==null&&typeof e=="object"?structuredClone(e):e,ph=(e,t,s)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(t??{},s)?t[s]:void 0;if(e===s){if(o==null)throw new Error(`Action template binding "${s}" requires event context "${s}".`);return Gl(o)}if(!e.startsWith(`${s}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${s}".`);let a=e.slice(s.length+1),r=uh(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${s}".`);return Gl(r)},fh={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"])},dh=(e,t)=>{let s=e[e.length-1];return s?fh[s]?.has(t)===!0:!1},ao=(e,t,s=[])=>Array.isArray(e)?e.map(o=>ao(o,t,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,dh(s,o)?a:ao(a,t,[...s,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?ph(e,t,"_event"):Hr(e,t):e,Wt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return ao(e,t)};var mh=11102230246251565e-32,oc=128,ac=1e3,lc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Jt=(e,t,s)=>{let o=Object.keys(e).find(a=>!t.has(a));if(o!==void 0)throw new Error(`${s}.${o} is not supported`)},Zn=(e,t)=>{if(!lc(e))throw new Error(`${t} must be an object`)},es=(e,t,{min:s,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(s!==void 0&&e<s)throw new Error(`${t} must be at least ${s}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},yh=(e,t,{min:s,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(s!==void 0&&e<s)throw new Error(`${t} must be at least ${s}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},mo=e=>{let t=structuredClone(e),s=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(s),Object.freeze(o)),o);return s(t)},hh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),cc=e=>{let t=e??hh();if(!lc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let s=t.nextUint32();if(!Number.isInteger(s)||s<0||s>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return s}}},gh=(e,t)=>{let s=4294967296-4294967296%t;for(let o=0;o<oc;o+=1){let a=e.nextUint32();if(a<s)return a%t}throw new Error(`random source exhausted after ${oc} rejected samples`)},bh=e=>{let t=e.nextUint32()>>>5,s=e.nextUint32()>>>6;return(t*67108864+s)/9007199254740992},wh=(e,t)=>{if(Jt(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let s=es(e.min,"random.distribution.min"),a=es(e.max,"random.distribution.max")-s+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return mo({type:"integer",value:a===1?s:s+gh(t,a)})},Ih=(e,t)=>{if(Jt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>ac)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let s=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(Zn(c,p),Jt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Zn(c.actions,`${p}.actions`),{weight:yh(c.weight,`${p}.weight`,{min:0})}}),o=Math.max(...s.map(({weight:c})=>c));if(o<=0)throw new Error("random weighted total weight must be positive");let a=s.map(c=>({...c,weight:c.weight/o})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(s[u].weight>0&&(c.weight===0||c.weight/r<=mh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let n=bh(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,n<i){l=c;break}}return mo({type:"weighted",outcomeIndex:l})},uc=(e,{randomSource:t})=>{Zn(e,"random.distribution");let o={integer:wh,weighted:Ih}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},rs=(e,t)=>{if(Zn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Jt(e,new Set(["type","value"]),"random result"),es(e.value,"random result.value");else if(t==="weighted")Jt(e,new Set(["type","outcomeIndex"]),"random result"),es(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:ac-1});else throw new Error(`unsupported recorded random result type: ${t}`);return mo(e)};var Jr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),dc=Object.freeze([Jr("cleanup",["clearPendingEffects","cleanAll"]),Jr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Jr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Jr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Jr("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"]),Jr("persistence",["saveSlot"]),Jr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),wt=new Map;dc.forEach(e=>{e.actions.forEach(t=>{if(wt.has(t))throw new Error(`duplicate action execution key: ${t}`);wt.set(t,wt.size)})});var vh=new Set(dc.find(({name:e})=>e==="navigation").actions),pc=wt.get("saveSlot")-.5,fc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",kh=(e,t)=>e<t?-1:e>t?1:0,ts=e=>Object.entries(e).sort((t,s)=>{let o=fc(...t),a=fc(...s),r=wt.get(o),n=wt.get(a),i=r??pc,l=n??pc;return i!==l?i-l:r!==void 0&&n!==void 0?0:kh(o,a)}),ns=e=>vh.has(e),ss=e=>{let t=e.map(([s])=>s).filter(ns);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var Ah=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Or=(...e)=>e.map(Ah).join(":");var Rr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),It=Object.freeze({volume:100,pan:0,playbackRate:1}),go=["volume","pan","playbackRate"],Ph=["src","startAt","endAt","startDelayMs"],mc=(e,t)=>{if(!e)return null;let s=e.children??[];if(s.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return s[0]},bc=(e,t)=>e?.id===t?.id&&Ph.every(s=>(e?.[s]??(s==="endAt"?null:0))===(t?.[s]??(s==="endAt"?null:0))),wc=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Eh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),yo=e=>Math.max(-1,Math.min(1,e)),ho=({bgm:e,resources:t,renderedSound:s,property:o})=>{let a=e?.sounds?.find(({id:n})=>Or("bgm",n)===s?.id),r=t.sounds?.[a?.resourceId];return a?.[o]??r?.[o]??It[o]},xh=({property:e,value:t,relative:s,nextBgm:o,nextResources:a,nextSound:r})=>{if(!o||!r)return t;if(e==="volume"){let n=ho({bgm:o,resources:a,renderedSound:r,property:e});return t*n/100}if(e==="pan"&&!s){let n=ho({bgm:o,resources:a,renderedSound:r,property:e});return yo(t+n)}return t},Sh=({authoredKeyframes:e,compiledKeyframes:t,previousBgm:s,nextBgm:o,nextResources:a,nextSound:r})=>{if(!o||!r)return t;let n=ho({bgm:o,resources:a,renderedSound:r,property:"pan"}),i=s?.pan??It.pan;return t.map((l,c)=>{let u=e[c];if(u.relative!==!0)return i=u.value,l;let p=Rr(u,"startValue")?i+u.startValue:i,m=p+u.value,{relative:f,...d}=l;return i=m,{...d,...Rr(u,"startValue")?{startValue:yo(p+n)}:{},value:yo(m+n)}})},Ic=(e,t)=>{let s=e?.playback?.speed??1;if(typeof s!="number"||!Number.isFinite(s)||s<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return s},vc=(e,t)=>({...Rr(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Oh=(e,t,s)=>{let o=vc(e,t);return o.value=o.value*s/100,Rr(o,"startValue")&&(o.startValue=o.startValue*s/100),o},yc=(e,t,s,o,a)=>{if(!e)return;let r=e.keyframes;if(r){if(r.some(i=>i.relative===!0))throw new Error(`[${a}.keyframes] Transition fade keyframes must use absolute values.`);if(t==="enter"&&r.at(-1)?.value!==100)throw new Error(`[${a}.keyframes] The final incoming transition fade value must be 100.`);let n=r.map(i=>Oh(i,s,o));return t==="enter"&&(n.at(-1).value=o),{...t==="enter"?{initialValue:0}:{},keyframes:n}}return{...t==="enter"?{initialValue:0}:{},keyframes:[{value:t==="exit"?0:o,delay:(e.delay??0)/s,duration:e.duration/s,easing:e.easing??"linear"}]}},kc=({property:e,authored:t,speed:s,resourcePath:o,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${o}.tween.${e}.keyframes] The final keyframe must use an absolute finite numeric value.`);return{keyframes:t.keyframes.map(n=>{let i=vc(n,s),l=i.relative===!0;return i.value=a({property:e,value:i.value,relative:l}),Rr(i,"startValue")&&(i.startValue=a({property:e,value:i.startValue,relative:l})),i})}},Ac=({selection:e,selectionPath:t,resources:s={}})=>{if(!e)return;let o=e.resourceId,a=`resources.audioEffects.${o}`,r=s.audioEffects?.[o];if(!r)throw new Error(`[${t}.resourceId]
|
|
1
|
+
var jd=Object.defineProperty;var Dd=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Td=(e,t)=>{for(var s in t)jd(e,s,{get:t[s],enumerable:!0})};var mf=Dd(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});function ff(e){let t=e.length,s=0,o=0,a;for(;o<t;)s++,a=e.charCodeAt(o++),a>=55296&&a<=56319&&o<t&&(a=e.charCodeAt(o),(a&64512)===56320&&o++);return s}Fa.default=ff;ff.code='require("ajv/dist/runtime/ucs2length").default'});var Il=Symbol.for("immer-nothing"),yl=Symbol.for("immer-draftable"),Le=Symbol.for("immer-state");function Ye(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var yt=Object.getPrototypeOf;function Pe(e){return!!e&&!!e[Le]}function zr(e){return e?vl(e)||Array.isArray(e)||!!e[yl]||!!e.constructor?.[yl]||Mn(e)||Vn(e):!1}var Ld=Object.prototype.constructor.toString();function vl(e){if(!e||typeof e!="object")return!1;let t=yt(e);if(t===null)return!0;let s=Object.hasOwnProperty.call(t,"constructor")&&t.constructor;return s===Object?!0:typeof s=="function"&&Function.toString.call(s)===Ld}function Tn(e){return Pe(e)||Ye(15,e),e[Le].base_}function Nn(e,t){Ln(e)===0?Reflect.ownKeys(e).forEach(s=>{t(s,e[s],e)}):e.forEach((s,o)=>t(o,s,e))}function Ln(e){let t=e[Le];return t?t.type_:Array.isArray(e)?1:Mn(e)?2:Vn(e)?3:0}function Vi(e,t){return Ln(e)===2?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function kl(e,t,s){let o=Ln(e);o===2?e.set(t,s):o===3?e.add(s):e[t]=s}function Md(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}function Mn(e){return e instanceof Map}function Vn(e){return e instanceof Set}function Yr(e){return e.copy_||e.base_}function qi(e,t){if(Mn(e))return new Map(e);if(Vn(e))return new Set(e);if(Array.isArray(e))return Array.prototype.slice.call(e);let s=vl(e);if(t===!0||t==="class_only"&&!s){let o=Object.getOwnPropertyDescriptors(e);delete o[Le];let a=Reflect.ownKeys(o);for(let r=0;r<a.length;r++){let n=a[r],i=o[n];i.writable===!1&&(i.writable=!0,i.configurable=!0),(i.get||i.set)&&(o[n]={configurable:!0,writable:!0,enumerable:i.enumerable,value:e[n]})}return Object.create(yt(e),o)}else{let o=yt(e);if(o!==null&&s)return{...e};let a=Object.create(o);return Object.assign(a,e)}}function zi(e,t=!1){return qn(e)||Pe(e)||!zr(e)||(Ln(e)>1&&(e.set=e.add=e.clear=e.delete=Vd),Object.freeze(e),t&&Object.entries(e).forEach(([s,o])=>zi(o,!0))),e}function Vd(){Ye(2)}function qn(e){return Object.isFrozen(e)}var qd={};function Xr(e){let t=qd[e];return t||Ye(0,e),t}var Mt;function Al(){return Mt}function Fd(e,t){return{drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function hl(e,t){t&&(Xr("Patches"),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Fi(e){Bi(e),e.drafts_.forEach(Bd),e.drafts_=null}function Bi(e){e===Mt&&(Mt=e.parent_)}function gl(e){return Mt=Fd(Mt,e)}function Bd(e){let t=e[Le];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function bl(e,t){t.unfinalizedDrafts_=t.drafts_.length;let s=t.drafts_[0];return e!==void 0&&e!==s?(s[Le].modified_&&(Fi(t),Ye(4)),zr(e)&&(e=jn(t,e),t.parent_||Dn(t,e)),t.patches_&&Xr("Patches").generateReplacementPatches_(s[Le].base_,e,t.patches_,t.inversePatches_)):e=jn(t,s,[]),Fi(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Il?e:void 0}function jn(e,t,s){if(qn(t))return t;let o=t[Le];if(!o)return Nn(t,(a,r)=>wl(e,o,t,a,r,s)),t;if(o.scope_!==e)return t;if(!o.modified_)return Dn(e,o.base_,!0),o.base_;if(!o.finalized_){o.finalized_=!0,o.scope_.unfinalizedDrafts_--;let a=o.copy_,r=a,n=!1;o.type_===3&&(r=new Set(a),a.clear(),n=!0),Nn(r,(i,l)=>wl(e,o,a,i,l,s,n)),Dn(e,a,!1),s&&e.patches_&&Xr("Patches").generatePatches_(o,s,e.patches_,e.inversePatches_)}return o.copy_}function wl(e,t,s,o,a,r,n){if(Pe(a)){let i=r&&t&&t.type_!==3&&!Vi(t.assigned_,o)?r.concat(o):void 0,l=jn(e,a,i);if(kl(s,o,l),Pe(l))e.canAutoFreeze_=!1;else return}else n&&s.add(a);if(zr(a)&&!qn(a)){if(!e.immer_.autoFreeze_&&e.unfinalizedDrafts_<1)return;jn(e,a),(!t||!t.scope_.parent_)&&typeof o!="symbol"&&Object.prototype.propertyIsEnumerable.call(s,o)&&Dn(e,a)}}function Dn(e,t,s=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&zi(t,s)}function Ud(e,t){let s=Array.isArray(e),o={type_:s?1:0,scope_:t?t.scope_:Al(),modified_:!1,finalized_:!1,assigned_:{},parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1},a=o,r=Xi;s&&(a=[o],r=Vt);let{revoke:n,proxy:i}=Proxy.revocable(a,r);return o.draft_=i,o.revoke_=n,i}var Xi={get(e,t){if(t===Le)return e;let s=Yr(e);if(!Vi(s,t))return Yd(e,s,t);let o=s[t];return e.finalized_||!zr(o)?o:o===Li(e.base_,t)?(Mi(e),e.copy_[t]=Yi(o,e)):o},has(e,t){return t in Yr(e)},ownKeys(e){return Reflect.ownKeys(Yr(e))},set(e,t,s){let o=Pl(Yr(e),t);if(o?.set)return o.set.call(e.draft_,s),!0;if(!e.modified_){let a=Li(Yr(e),t),r=a?.[Le];if(r&&r.base_===s)return e.copy_[t]=s,e.assigned_[t]=!1,!0;if(Md(s,a)&&(s!==void 0||Vi(e.base_,t)))return!0;Mi(e),Ui(e)}return e.copy_[t]===s&&(s!==void 0||t in e.copy_)||Number.isNaN(s)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=s,e.assigned_[t]=!0),!0},deleteProperty(e,t){return Li(e.base_,t)!==void 0||t in e.base_?(e.assigned_[t]=!1,Mi(e),Ui(e)):delete e.assigned_[t],e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let s=Yr(e),o=Reflect.getOwnPropertyDescriptor(s,t);return o&&{writable:!0,configurable:e.type_!==1||t!=="length",enumerable:o.enumerable,value:s[t]}},defineProperty(){Ye(11)},getPrototypeOf(e){return yt(e.base_)},setPrototypeOf(){Ye(12)}},Vt={};Nn(Xi,(e,t)=>{Vt[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}});Vt.deleteProperty=function(e,t){return Vt.set.call(this,e,t,void 0)};Vt.set=function(e,t,s){return Xi.set.call(this,e[0],t,s,e[0])};function Li(e,t){let s=e[Le];return(s?Yr(s):e)[t]}function Yd(e,t,s){let o=Pl(t,s);return o?"value"in o?o.value:o.get?.call(e.draft_):void 0}function Pl(e,t){if(!(t in e))return;let s=yt(e);for(;s;){let o=Object.getOwnPropertyDescriptor(s,t);if(o)return o;s=yt(s)}}function Ui(e){e.modified_||(e.modified_=!0,e.parent_&&Ui(e.parent_))}function Mi(e){e.copy_||(e.copy_=qi(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var zd=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(t,s,o)=>{if(typeof t=="function"&&typeof s!="function"){let r=s;s=t;let n=this;return function(l=r,...c){return n.produce(l,u=>s.call(this,u,...c))}}typeof s!="function"&&Ye(6),o!==void 0&&typeof o!="function"&&Ye(7);let a;if(zr(t)){let r=gl(this),n=Yi(t,void 0),i=!0;try{a=s(n),i=!1}finally{i?Fi(r):Bi(r)}return hl(r,o),bl(a,r)}else if(!t||typeof t!="object"){if(a=s(t),a===void 0&&(a=t),a===Il&&(a=void 0),this.autoFreeze_&&zi(a,!0),o){let r=[],n=[];Xr("Patches").generateReplacementPatches_(t,a,r,n),o(r,n)}return a}else Ye(1,t)},this.produceWithPatches=(t,s)=>{if(typeof t=="function")return(n,...i)=>this.produceWithPatches(n,l=>t(l,...i));let o,a;return[this.produce(t,s,(n,i)=>{o=n,a=i}),o,a]},typeof e?.autoFreeze=="boolean"&&this.setAutoFreeze(e.autoFreeze),typeof e?.useStrictShallowCopy=="boolean"&&this.setUseStrictShallowCopy(e.useStrictShallowCopy)}createDraft(e){zr(e)||Ye(8),Pe(e)&&(e=Pr(e));let t=gl(this),s=Yi(e,void 0);return s[Le].isManual_=!0,Bi(t),s}finishDraft(e,t){let s=e&&e[Le];(!s||!s.isManual_)&&Ye(9);let{scope_:o}=s;return hl(o,t),bl(void 0,o)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}applyPatches(e,t){let s;for(s=t.length-1;s>=0;s--){let a=t[s];if(a.path.length===0&&a.op==="replace"){e=a.value;break}}s>-1&&(t=t.slice(s+1));let o=Xr("Patches").applyPatches_;return Pe(e)?o(e,t):this.produce(e,a=>o(a,t))}};function Yi(e,t){let s=Mn(e)?Xr("MapSet").proxyMap_(e,t):Vn(e)?Xr("MapSet").proxySet_(e,t):Ud(e,t);return(t?t.scope_:Al()).drafts_.push(s),s}function Pr(e){return Pe(e)||Ye(10,e),El(e)}function El(e){if(!zr(e)||qn(e))return e;let t=e[Le],s;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,s=qi(e,t.scope_.immer_.useStrictShallowCopy_)}else s=qi(e,!0);return Nn(s,(o,a)=>{kl(s,o,El(a))}),t&&(t.finalized_=!1),s}var Ve=new zd,Fn=Ve.produce,Kk=Ve.produceWithPatches.bind(Ve),Wk=Ve.setAutoFreeze.bind(Ve),Jk=Ve.setUseStrictShallowCopy.bind(Ve),Qk=Ve.applyPatches.bind(Ve),Zk=Ve.createDraft.bind(Ve),eA=Ve.finishDraft.bind(Ve);var x={LITERAL:0,VARIABLE:1,INTERPOLATION:2,FUNCTION:3,BINARY:4,UNARY:5,CONDITIONAL:6,LOOP:7,OBJECT:8,ARRAY:9,PARTIAL:10,PATH_REFERENCE:11},ee={EQ:0,NEQ:1,GT:2,LT:3,GTE:4,LTE:5,AND:6,OR:7,IN:8,ADD:10,SUBTRACT:11},ht={NOT:0};var L=class extends Error{constructor(t){super(`Parse Error: ${t}`),this.name="JemplParseError"}},je=class extends Error{constructor(t){super(`Render Error: ${t}`),this.name="JemplRenderError"}};var Gi=e=>{if(!e||e.trim()==="")throw new L("Missing condition expression after '$if'");if(e.includes("===")||e.includes("!==")){let s=e.includes("===")?"==":"!=";throw new L(`Invalid comparison operator '${e.includes("===")?"===":"!=="}' - did you mean '${s}'? (got: '${e}')`)}let t=["<",">","<=",">=","==","!="];for(let s of t)if(e.trim().endsWith(s))throw new L(`Incomplete comparison expression - missing right operand (got: '${e}')`)},xl=e=>{if(e.trim().endsWith(" in"))throw new L(`Missing iterable expression after 'in' (got: '$for ${e}')`);if(!e.includes(" in "))throw new L(`Invalid loop syntax - missing 'in' keyword (got: '$for ${e}')`);let[t,s]=e.split(" in ");if(!s||s.trim()==="")throw new L(`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 L(`Invalid loop variable - variable name cannot be empty (got: '$for ${e}')`);if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))throw new L(`Invalid loop syntax (got: '$for ${e}')`)}};var Sl=(e,t,s=!1)=>{if(t===null)return new je(`Cannot iterate over null value at '$for ${e}'`);if(t===void 0)return new je(`Cannot iterate over undefined value at '$for ${e}'`);let o=typeof t;return s?new je(`Cannot iterate over non-array value in loop '${e}' - got ${o} instead`):new je(`Cannot iterate over non-array value (got: ${o}) at '$for ${e}'`)},Ol=(e,t)=>{let s=t&&Object.keys(t).length>0?Object.keys(t).join(", "):"no custom functions provided";return new je(`Unknown function '${e}' (${s})`)};var Xd=(e,t,s={})=>{let o={},a={};s&&typeof s=="object"&&(s.functions!==void 0||s.partials!==void 0?(o=s.functions||{},a=s.partials||{}):typeof s=="object"&&(o=s));let n=se(e,{functions:o,partials:a},t,{});return n===void 0?{}:n},se=(e,t,s,o)=>{let a=t.functions||t;if(e.var&&!e.type)return ke(e.var,s,o);if(e.type===x.LITERAL)return e.value;if(e.type===x.VARIABLE)return ke(e.path,s,o);if(e.type===x.INTERPOLATION)return Hd(e.parts,t,s,o);switch(e.type){case x.FUNCTION:return $l(e,t,s,o);case x.BINARY:return Cl(e,t,s,o);case x.UNARY:return _l(e,t,s,o);case x.CONDITIONAL:return Wd(e,t,s,o);case x.LOOP:return ry(e,t,s,o);case x.OBJECT:return ny(e,t,s,o);case x.ARRAY:return sy(e,t,s,o);case x.PARTIAL:return iy(e,t,s,o);case x.PATH_REFERENCE:return oy(e,t,s,o);default:throw new Error(`Unknown node type: ${e.type}`)}},Rl=new Map,Gd=e=>{let t=[],s="",o=!1;for(let a=0;a<e.length;a++){let r=e[a];if(r==="[")s&&(t.push({type:"property",value:s}),s=""),o=!0;else if(r==="]"){if(o&&s){let n=s.trim();if(/^\d+$/.test(n))t.push({type:"index",value:parseInt(n,10)});else if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'")){let i=n.slice(1,-1);t.push({type:"property",value:i})}else t.push({type:"property",value:n});s=""}o=!1}else s+=r}return s&&t.push({type:"property",value:s}),t},ke=(e,t,s)=>{if(!e)return;if(e in s)return s[e];let o=Rl.get(e);if(!o){let r=[],n="",i=0;for(let l=0;l<e.length;l++){let c=e[l];c==="["?(i++,n+=c):c==="]"?(i--,n+=c):c==="."&&i===0?n&&(r.push(n),n=""):n+=c}n&&r.push(n),o=[];for(let l of r){let c=Gd(l.trim());o.push(...c)}Rl.set(e,o)}let a=t;for(let r=0;r<o.length;r++){let n=o[r];if(n.type==="property"&&n.value in s){a=s[n.value];continue}if(a==null)return;(n.type==="property"||n.type==="index")&&(a=a[n.value])}return a},Hd=(e,t,s,o)=>{let a=[];for(let r of e)if(typeof r=="string")a.push(r);else{let n=se(r,t,s,o);a.push(n!=null?String(n):"")}return a.join("")},$l=(e,t,s,o)=>{let a=t.functions||t,r=a[e.name];if(!r)throw Ol(e.name,a);let n=e.args.map(i=>se(i,t,s,o));return r(...n)},Er=(e,t,s,o)=>{if(e.var&&!e.type)return ke(e.var,s,o);switch(e.type){case x.VARIABLE:return ke(e.path,s,o);case x.LITERAL:return e.value;case x.BINARY:return Cl(e,t,s,o);case x.UNARY:return _l(e,t,s,o);case x.FUNCTION:return $l(e,t,s,o);default:return se(e,t,s,o)}},Cl=(e,t,s,o)=>{if(e.op===ee.AND||e.op===ee.OR){let n=Er(e.left,t,s,o),i=Er(e.right,t,s,o);switch(e.op){case ee.AND:return n&&i;case ee.OR:return n||i}}let a=se(e.left,t,s,o),r=se(e.right,t,s,o);switch(e.op){case ee.EQ:return a==r;case ee.NEQ:return a!=r;case ee.GT:return a>r;case ee.LT:return a<r;case ee.GTE:return a>=r;case ee.LTE:return a<=r;case ee.IN:return Array.isArray(r)?r.includes(a):!1;case ee.ADD:if(typeof a!="number"||typeof r!="number")throw new je(`Arithmetic operations require numbers. Got ${typeof a} + ${typeof r}`);return a+r;case ee.SUBTRACT:if(typeof a!="number"||typeof r!="number")throw new je(`Arithmetic operations require numbers. Got ${typeof a} - ${typeof r}`);return a-r;default:throw new Error(`Unknown binary operator: ${e.op}`)}},_l=(e,t,s,o)=>{let a=e.op===ht.NOT?Er(e.operand,t,s,o):se(e.operand,t,s,o);if(e.op===ht.NOT)return!a;throw new Error(`Unknown unary operator: ${e.op}`)},Kd=(e,t,s,o)=>{if(e.conditions.length===2&&e.conditions[1]===null){let a=e.conditions[0];if(a.type===x.VARIABLE)if(ke(a.path,s,o)){let n=e.bodies[0];if(n.type===x.OBJECT&&n.properties.length<=5){let i={};for(let l of n.properties){let c=l.parsedKey?se(l.parsedKey,t,s,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,s,o);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ke(d.path,s,o);p.push(f!=null?String(f):"")}else{let f=se(d,t,s,o);p.push(f!=null?String(f):"")}i[c]=p.join("")}else i[c]=se(u,t,s,o)}return i}}else{let n=e.bodies[1];if(n.type===x.OBJECT&&n.properties.length<=5){let i={};for(let l of n.properties){let c=l.parsedKey?se(l.parsedKey,t,s,o):l.key,u=l.value;if(u.type===x.LITERAL)i[c]=u.value;else if(u.type===x.VARIABLE)i[c]=ke(u.path,s,o);else if(u.type===x.INTERPOLATION){let p=[];for(let d of u.parts)if(typeof d=="string")p.push(d);else if(d.type===x.VARIABLE){let f=ke(d.path,s,o);p.push(f!=null?String(f):"")}else{let f=se(d,t,s,o);p.push(f!=null?String(f):"")}i[c]=p.join("")}else i[c]=se(u,t,s,o)}return i}}}return null},Wd=(e,t,s,o)=>{let a=Kd(e,t,s,o);if(a!==null)return a;for(let r=0;r<e.conditions.length;r++){let n=e.conditions[r];if(n===null||Er(n,t,s,o))return se(e.bodies[r],t,s,o)}return Nl},Jd=(e,t)=>{let s=e.body,o=e.itemVar;if(s.type===x.CONDITIONAL&&s.conditions.length===1&&s.conditions[0].type===x.VARIABLE){let a=s.conditions[0].path,r=s.bodies[0];if(a.startsWith(o+".")){let n=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[n]){let u={};for(let p of r.properties){let d=p.key,f=p.value;if(f.type===x.LITERAL)u[d]=f.value;else if(f.type===x.VARIABLE){let m=f.path;if(m===o)u[d]=c;else if(m.startsWith(o+".")){let g=m.substring(o.length+1);u[d]=c[g]}else return null}else if(f.type===x.INTERPOLATION){let m=[],g=!0;for(let b of f.parts)if(typeof b=="string")m.push(b);else if(b.type===x.VARIABLE){let y=b.path;if(y===o)m.push(c!=null?String(c):"");else if(y.startsWith(o+".")){let w=y.substring(o.length+1),h=c[w];m.push(h!=null?String(h):"")}else{g=!1;break}}else{g=!1;break}if(!g)return null;u[d]=m.join("")}else return null}i.push(u)}}return i}}}return null},Qd=(e,t)=>{let s=e.body,o=e.itemVar,a=Jd(e,t);if(a!==null)return a;if(s.type===x.OBJECT&&s.properties.length<=5&&!s.whenCondition){for(let i of s.properties)if(i.parsedKey)return null;let r=[],n=!0;for(let i of s.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{n=!1;break}}else{n=!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 d=p.substring(o.length+1);if(!d.includes(".")&&!d.includes("["))r.push({key:l,type:"prop_string",prop:d});else{n=!1;break}}else{n=!1;break}}else{n=!1;break}}else{n=!1;break}}if(n){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 d=c[p.prop];u[p.key]=d!=null?String(d):""}i[l]=u}return i}}return null},Zd=(e,t,s,o,a)=>{let r=[],n=e.body;if(n.type===x.OBJECT&&n.fast!==!1){let i=e.itemVar,l=e.indexVar;for(let c=0;c<a.length;c++){let u=a[c],p={},d={...o,[i]:u,...l&&{[l]:c}};d.__paths__||(d.__paths__=o.__paths__||{});let f=e.iterable.path||"";if(o&&o.__paths__&&f){let m=f.split("."),g=m[0];g in o.__paths__&&(f=o.__paths__[g],m.length>1&&(f+="."+m.slice(1).join(".")))}d.__paths__={...d.__paths__,[i]:`${f}[${c}]`,...l&&{[l]:c}};for(let m of n.properties){let g=m.parsedKey?se(m.parsedKey,t,s,d):m.key,b=m.value;if(b.type===x.LITERAL)p[g]=b.value;else if(b.type===x.VARIABLE){let y=b.path;if(y===i)p[g]=u;else if(y===l)p[g]=c;else if(y.startsWith(i+".")){let w=y.substring(i.length+1);!w.includes(".")&&!w.includes("[")?p[g]=u[w]:p[g]=ke(y,s,{...o,[i]:u,...l&&{[l]:c}})}else p[g]=ke(y,s,{...o,[i]:u,...l&&{[l]:c}})}else if(b.type===x.INTERPOLATION){let y=[];for(let w of b.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let h=w.path,P;if(h===i)P=u;else if(h===l)P=c;else if(h.startsWith(i+".")){let k=h.substring(i.length+1);!k.includes(".")&&!k.includes("[")?P=u[k]:P=ke(h,s,{...o,[i]:u,...l&&{[l]:c}})}else P=ke(h,s,{...o,[i]:u,...l&&{[l]:c}});y.push(P!=null?String(P):"")}else{let h={...o,[i]:u,...l&&{[l]:c}},P=se(w,t,s,h);y.push(P!=null?String(P):"")}p[g]=y.join("")}else{let y={...o,[i]:u,...l&&{[l]:c}};p[g]=se(b,t,s,y)}}r.push(p)}return r}return null},ey=(e,t,s)=>{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 n=r.bodies[0];if(n.type===x.OBJECT&&n.properties.length===2){let i=n.properties[0],l=n.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 d={id:p.id};p.highlighted?(d.highlight=!0,d.message=`This item is highlighted: ${p.name}`):(d.highlight=!1,d.message=p.name),c.push(d)}}return c}}}}return null},ry=(e,t,s,o)=>{let a=se(e.iterable,t,s,o);if(!Array.isArray(a)){let c,u=!1;if(e.iterable.type===x.FUNCTION){u=!0;let d=e.iterable.args.map(f=>f.type===x.LITERAL?typeof f.value=="string"?`'${f.value}'`:String(f.value):f.type===x.VARIABLE?f.path:f.type===x.FUNCTION?`${f.name}(...)`:"?").join(", ");c=`${e.iterable.name}(${d})`}else c=e.iterable.path||"undefined";let p=`${e.itemVar}${e.indexVar?`, ${e.indexVar}`:""} in ${c}`;throw Sl(p,a,u)}if(!e.indexVar){let c=ey(e,a,e.itemVar);if(c!==null)return c}if(!e.indexVar){let c=Qd(e,a);if(c!==null)return c}let r=Zd(e,t,s,o,a);if(r!==null)return r;let n=[],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=se(e.body,t,s,u);if(Array.isArray(p)&&p.length===1&&!l){let d=p[0];n.push(d===void 0?{}:d)}else n.push(p===void 0?{}:p)}return n},ty=(e,t,s,o)=>{if(e.whenCondition)return null;if(e.properties.length===1){let a=e.properties[0],r=a.parsedKey?se(a.parsedKey,t,s,o):a.key,n=a.value;if(n.type===x.OBJECT&&n.properties.length<=10&&!n.whenCondition){let i={},l={},c=!0;for(let u of n.properties){let p=u.parsedKey?se(u.parsedKey,t,s,o):u.key,d=u.value;if(d.type===x.LITERAL)l[p]=d.value;else if(d.type===x.VARIABLE)l[p]=ke(d.path,s,o);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let g=ke(m.path,s,o);f.push(g!=null?String(g):"")}else{c=!1;break}if(!c)break;l[p]=f.join("")}else if(d.type===x.OBJECT&&d.properties.length<=5){let f={};for(let m of d.properties){let g=m.key,b=m.value;if(b.type===x.LITERAL)f[g]=b.value;else if(b.type===x.VARIABLE)f[g]=ke(b.path,s,o);else if(b.type===x.INTERPOLATION){let y=[];for(let w of b.parts)if(typeof w=="string")y.push(w);else if(w.type===x.VARIABLE){let h=ke(w.path,s,o);y.push(h!=null?String(h):"")}else{c=!1;break}if(!c)break;f[g]=y.join("")}else{c=!1;break}}if(!c)break;l[p]=f}else{c=!1;break}}if(c)return i[r]=l,i}}return null},ny=(e,t,s,o)=>{let a=t.functions||t;if(e.whenCondition&&!Er(e.whenCondition,a,s,o))return;let r=ty(e,t,s,o);if(r!==null)return r;if(e.fast){let c={};for(let u of e.properties){let p=u.parsedKey?se(u.parsedKey,t,s,o):u.key,d=u.value;if(d.type===x.LITERAL)c[p]=d.value;else if(d.type===x.VARIABLE)c[p]=ke(d.path,s,o);else if(d.type===x.INTERPOLATION){let f=[];for(let m of d.parts)if(typeof m=="string")f.push(m);else if(m.type===x.VARIABLE){let g=ke(m.path,s,o);f.push(g!=null?String(g):"")}else{let g=se(m,t,s,o);f.push(g!=null?String(g):"")}c[p]=f.join("")}else c[p]=se(d,t,s,o)}return c}let n={},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=se(c.value,t,s,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(n,u)}else if(c.key.startsWith("$for ")){if(e.properties.length===1)return se(c.value,t,s,o)}else{let u=c.value;if(u&&u.type===x.OBJECT&&u.properties){let p=u.properties.find(d=>d.key.startsWith("$for "));if(p){let d=se(p.value,t,s,o);d!==void 0&&(n[c.key]=d)}else{let d=se(c.value,t,s,o);d!==void 0&&(n[c.key]=d)}}else{let p=c.parsedKey?se(c.parsedKey,t,s,o):c.key,d=se(c.value,t,s,o);d!==void 0&&(n[p]=d)}}return n},Nl={},sy=(e,t,s,o)=>{let a=[];for(let r of e.items)if(r.type===x.LOOP){let n=se(r,t,s,o);Array.isArray(n)&&r.flatten!==!1?a.push(...n):a.push(n)}else{let n=se(r,t,s,o);n!==Nl&&n!==void 0&&a.push(n)}return a},iy=(e,t,s,o)=>{let{name:a,data:r,whenCondition:n}=e,i=t.partials||{},l=t.functions||t;if(n&&!Er(n,l,s,o))return;if(!i[a])throw new je(`Partial '${a}' is not defined`);let c=o._partialStack||[];if(c.includes(a))throw new je(`Circular partial reference detected: ${a}`);let u=i[a],p=s,d={...o,_partialStack:[...c,a]};if(o){p={...s};for(let f of Object.keys(o))f.startsWith("_")||(p[f]=o[f])}if(r){let f=se(r,t,s,o);p={...p,...f}}return se(u,t,p,d)},oy=(e,t,s,o)=>{let{path:a}=e,r=a.split("."),n=r[0],i=r.slice(1);if(!o||!(n in o))throw new je(`Path reference '#{${a}}' refers to '${n}' which is not a loop variable in the current scope`);if(o.__paths__||(o.__paths__={}),!(n in o.__paths__))throw new je(`Path reference '#{${a}}' cannot be resolved - path tracking may not be initialized properly`);let l=o.__paths__[n];if(typeof l=="number"){if(i.length>0)throw new je(`Path reference '#{${a}}' - cannot access properties on index variable '${n}'`);return String(l)}return i.length>0&&(l+="."+i.join(".")),l};var Hi=Xd;var ay=/\$\{([^}]*)\}/g,ly=/#\{([^}]*)\}/g,Dl=(e,t={})=>{let s=e.match(/^(\w+)\((.*)\)$/);if(!s)return{isFunction:!1};let[,o,a]=s,r=cy(a,t);return{isFunction:!0,type:x.FUNCTION,name:o,args:r}},cy=(e,t={})=>e.trim()?uy(e).map(o=>py(o.trim(),t)):[],uy=e=>{let t=[],s="",o=0,a=!1,r="";for(let n=0;n<e.length;n++){let i=e[n],l=n>0?e[n-1]:"";!a&&(i==='"'||i==="'")?(a=!0,r=i,s+=i):a&&i===r&&l!=="\\"?(a=!1,r="",s+=i):!a&&i==="("?(o++,s+=i):!a&&i===")"?(o--,s+=i):!a&&i===","&&o===0?(t.push(s),s=""):s+=i}return s&&t.push(s),t},py=(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 s=Dl(e,t);if(s.isFunction)return{type:s.type,name:s.name,args:s.args};let o=e.trim(),a=[{op:" + ",type:"ADD"},{op:" - ",type:"SUBTRACT"}],r=-1,n=null;for(let{op:i,type:l}of a){let c=0;for(;c<o.length;){let u=Gr(o.substring(c),i);if(u===-1)break;let p=c+u;p>r&&(r=p,n={op:i,type:l}),c=p+i.length}}if(r!==-1)try{return Ee(o,t)}catch{return{type:x.VARIABLE,path:o}}return{type:x.VARIABLE,path:o}},Tl=/^\w+\(.*\)$/,fy=/\s[+\-*/%]\s|\|\||&&|\?\?|.*\?.*:/,my=e=>{if(!(!e||e.trim()===""||Tl.test(e))&&fy.test(e))throw e.includes("?")&&e.includes(":")?new L(`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 L(`Logical operators not supported in variable replacements - consider calculating the value in your data instead (operators like ||, &&, ?? are not supported). Offending expression: "${e}"`):new L(`Arithmetic expressions not supported in variable replacements - consider calculating '${e}' in your data instead (expressions with +, -, *, /, % are not supported). Offending expression: "${e}"`)},jl=e=>{let t=e.trim();if(Tl.test(t))throw new L(`Functions are not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(t.includes("["))throw new L(`Array indices not supported in path references - use simple variable names or properties. Offending expression: "#{${e}}"`);if(/[+\-*/%]/.test(t))throw new L(`Arithmetic expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);if(/\|\||&&/.test(t))throw new L(`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 L(`Complex expressions not supported in path references - path references can only refer to loop variables. Offending expression: "#{${e}}"`);return{type:x.PATH_REFERENCE,path:t}},qt=(e,t={})=>{let s=e.trim();my(s);let o=Dl(s,t);if(o.isFunction)return{type:o.type,name:o.name,args:o.args};if(s.includes("[")&&!/[\s+\-*/%|&?:]/.test(s)){let a=0;for(let r of s)r==="["?a++:r==="]"&&a--;if(a!==0)throw new Error("Invalid array index syntax")}return{type:x.VARIABLE,path:s}},Ki=(e,t={})=>{let s=e,o=[];(e.includes("\\${")||e.includes("\\#{"))&&(s=e.replace(/\\\\(\$\{[^}]*\})/g,"\\DOUBLE_ESC_VAR$1"),s=s.replace(/\\\\(#\{[^}]*\})/g,"\\DOUBLE_ESC_PATH$1"),s=s.replace(/\\(\$\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),s=s.replace(/\\(#\{[^}]*\})/g,(c,u)=>{let p=`__ESCAPED_${o.length}__`;return o.push(u),p}),s=s.replace(/\\DOUBLE_ESC_VAR/g,"\\"),s=s.replace(/\\DOUBLE_ESC_PATH/g,"\\"));let a=[...s.matchAll(ay)],r=[...s.matchAll(ly)],n=[...a.map(c=>({match:c,type:"variable"})),...r.map(c=>({match:c,type:"pathref"}))].sort((c,u)=>c.match.index-u.match.index);if(n.length===0){let c=s;for(let u=0;u<o.length;u++)c=c.replace(`__ESCAPED_${u}__`,o[u]);return{type:x.LITERAL,value:c}}if(n.length===1&&n[0].match[0]===s&&o.length===0){let{match:c,type:u}=n[0];try{return u==="variable"?qt(c[1],t):jl(c[1])}catch(p){if(p.message==="Invalid array index syntax")return{type:x.LITERAL,value:s};throw p}}let i=[],l=0;for(let{match:c,type:u}of n){let[p,d]=c,f=c.index;if(f>l){let m=s.substring(l,f);for(let g=0;g<o.length;g++)m=m.replace(`__ESCAPED_${g}__`,o[g]);m&&i.push(m)}try{let m;u==="variable"?m=qt(d.trim(),t):m=jl(d.trim()),i.push(m)}catch(m){if(m.message==="Invalid array index syntax")i.push(p);else throw m}l=f+p.length}if(l<s.length){let c=s.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 Qi=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Vl=e=>Object.keys(e),Ce=e=>e.join("."),xr=(e,t,s)=>{let o=Vl(e).filter(a=>!t.has(a));if(o.length>0)throw new L(`Unexpected key '${o[0]}' in condition JSON at '${Ce(s)}'`)},Sr=(e,t)=>typeof e=="string"?Ki(e,t):typeof e=="object"&&e!==null?Array.isArray(e)?yy(e,t):hy(e,t):{type:x.LITERAL,value:e},dy=e=>{let{$each:t,...s}=e;if(typeof t!="string")throw new L("$each value must be a non-empty string");let o=t.trim();if(o==="")throw new L("$each value must be a non-empty string");if(Object.keys(s).length===0)throw new L("Empty $each body not allowed");if(s.$partial!==void 0)throw new L("Cannot use $partial with $each at the same level. Wrap $partial in a parent object if you need conditionals.");return{[`$for ${o}`]:s}},yy=(e,t)=>{let s=[],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=dy(r),c=Object.keys(l);if(c.length===1&&/^\$for(?::\w+)?\s/.test(c[0])){let u=Ml(c[0],l[c[0]],t,!0);s.push(u),o=!0;continue}}catch(l){throw l instanceof L?l:new L(l.message)}let i=Object.keys(r);if(i.length===1&&/^\$for(?::\w+)?\s/.test(i[0])){let l=Ml(i[0],r[i[0]],t);s.push(l),o=!0;continue}}let n=Sr(r,t);s.push(n),(n.type===x.FUNCTION||n.type===x.CONDITIONAL||n.type===x.LOOP||n.type===x.PARTIAL||n.type===x.OBJECT&&!n.fast||n.type===x.ARRAY&&!n.fast)&&(o=!0)}return{type:x.ARRAY,items:s,fast:!o}},hy=(e,t)=>{let s=[],o=!1,a=null,r=Object.entries(e),n=0;if(e.$partial!==void 0){if(typeof e.$partial!="string")throw new L("$partial value must be a string");if(e.$partial.trim()==="")throw new L("$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 L(`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,...d}=e,f={},m=!1;for(let[y,w]of Object.entries(d)){let h=y;(y.startsWith("\\$")||y.startsWith("$$"))&&(h=y.slice(1)),f[h]=w,m=!0}let g=null;if(m&&(g=Sr(f,t),g.type===x.OBJECT)){let y=!1;for(let w of g.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&&(g.fast=!1)}let b={type:x.PARTIAL,name:u,data:g};return p!==void 0&&(b.whenCondition=Ll(p,t)),b}for(let[l,c]of r)if(l==="$when"){if(a!==null)throw new L("Multiple '$when' directives on the same object are not allowed");if(c==null)throw new L("Missing condition expression after '$when'");a=Ll(c,t),o=!0}else if(l.startsWith("$when#")||l.startsWith("$when "))throw new L("'$when' does not support ID syntax or inline conditions - use '$when' as a property");for(;n<r.length;){let[l,c]=r[n];if(l==="$when"){n++;continue}if(l==="$each")throw new L("$each can only be used inside arrays");if(l.startsWith("$if ")||l.match(/^\$if#\w+\s/)||l.match(/^\$if\s+\w+.*:$/)){let u=gy(r,n,t);s.push({key:l,value:u.node}),o=!0,n=u.nextIndex}else if(/^\$for(?::\w+)?\s/.test(l)){let u=l.match(/^\$for(?::(\w+))?\s/)?.[1]||"",p=u?`:${u}`:"";throw new L(`$for loops must be inside arrays - use '- $for${p} item in items:' instead of '$for${p} item in items:'. For cleaner object generation syntax, consider using $each.`)}else{if(l.startsWith("$elif ")||l.startsWith("$else"))throw new L(`'${l.split(" ")[0]}' without matching '$if'`);if(l==="$if"||l==="$if:")throw new L("Missing condition expression after '$if'");{let u=Sr(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=Ki(l,t),d={key:l,value:u};(p.type!==x.LITERAL||p.value!==l)&&(d.parsedKey=p),s.push(d),n++}}}let i={type:x.OBJECT,properties:s,fast:!o};return a&&(i.whenCondition=a),i},gy=(e,t,s={})=>{let o=[],a=[],r=t,[n,i]=e[r],l=null,c;if(n.startsWith("$if#")){let p=n.match(/^\$if#(\w+)\s+(.+)$/);if(p)l=p[1],c=p[2];else throw new L(`Invalid conditional syntax: ${n}`)}else c=n.substring(4),c.endsWith(":")&&(c=c.slice(0,-1).trim());Gi(c);let u=Ee(c,s);for(o.push(u),a.push(Sr(i,s)),r++;r<e.length;){let[p,d]=e[r],f=!1,m;if(l?p.startsWith(`$elif#${l} `)?(m=p.substring(`$elif#${l} `.length),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p===`$else#${l}`||p===`$else#${l}:`)&&(f=!0,m=null):p.startsWith("$elif ")?(m=p.substring(6),m.endsWith(":")&&(m=m.slice(0,-1).trim()),f=!0):(p==="$else"||p==="$else:")&&(f=!0,m=null),f){if(m===null)o.push(null);else{Gi(m);let g=Ee(m,s);o.push(g)}if(a.push(Sr(d,s)),r++,m===null)break}else break}return{node:{type:x.CONDITIONAL,conditions:o,bodies:a,id:l},nextIndex:r}},Wi={eq:ee.EQ,neq:ee.NEQ,gt:ee.GT,gte:ee.GTE,lt:ee.LT,lte:ee.LTE,in:ee.IN,add:ee.ADD,sub:ee.SUBTRACT},Ji={all:ee.AND,any:ee.OR},by=new Set(["var","literal","call","not",...Object.keys(Wi),...Object.keys(Ji)]),wy=(e,t,s)=>{if(!Array.isArray(e))throw new L(`Condition JSON operator '${t}' at '${Ce(s)}' requires an array`);if(e.length!==2)throw new L(`Condition JSON operator '${t}' at '${Ce(s)}' requires exactly 2 operands`);return e},Iy=(e,t,s,o,a)=>{if(!Array.isArray(e))throw new L(`Condition JSON operator '${t}' at '${Ce(a)}' requires an array`);if(e.length===0)throw new L(`Condition JSON operator '${t}' at '${Ce(a)}' requires at least 1 condition`);return e.map((n,i)=>Me(n,o,[...a,i])).reduce((n,i)=>({type:x.BINARY,op:s,left:n,right:i}))},vy=(e,t,s)=>{let o,a;if(typeof e.call=="string")o=e.call,a=e.args??[],xr(e,new Set(["call","args"]),s);else if(Qi(e.call))o=e.call.name,a=e.call.args??[],xr(e,new Set(["call"]),s),xr(e.call,new Set(["name","args"]),[...s,"call"]);else throw new L(`Condition JSON call at '${Ce(s)}' requires a function name`);if(typeof o!="string"||o.trim()==="")throw new L(`Condition JSON call at '${Ce(s)}' requires a non-empty function name`);if(!/^\w+$/.test(o))throw new L(`Invalid condition JSON function name '${o}' at '${Ce(s)}'`);if(!Array.isArray(a))throw new L(`Condition JSON call '${o}' at '${Ce(s)}' requires args to be an array`);return{type:x.FUNCTION,name:o,args:a.map((r,n)=>Me(r,t,[...s,"args",n]))}},Me=(e,t={},s=["$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 L(`Condition JSON array at '${Ce(s)}' must be wrapped in an operator or { literal: [...] }`);if(!Qi(e))throw new L(`Invalid condition JSON value at '${Ce(s)}'`);let o=Vl(e);if(o.length===0)throw new L(`Condition JSON object at '${Ce(s)}' must contain an operator`);let a=o.filter(n=>by.has(n));if(a.length===0)throw new L(`Unknown condition JSON operator '${o[0]}' at '${Ce(s)}'`);if(a.length>1)throw new L(`Condition JSON at '${Ce(s)}' must contain exactly one operator`);let r=a.includes("call")?"call":a[0];if(r==="var"){if(xr(e,new Set(["var"]),s),typeof e.var!="string"||e.var.trim()==="")throw new L(`Condition JSON var at '${Ce(s)}' requires a non-empty path`);return{type:x.VARIABLE,path:e.var}}if(r==="literal")return xr(e,new Set(["literal"]),s),{type:x.LITERAL,value:e.literal};if(r==="call")return vy(e,t,s);if(r==="not")return xr(e,new Set(["not"]),s),{type:x.UNARY,op:ht.NOT,operand:Me(e.not,t,[...s,"not"])};if(r in Ji)return xr(e,new Set([r]),s),Iy(e[r],r,Ji[r],t,[...s,r]);if(r in Wi){xr(e,new Set([r]),s);let n=wy(e[r],r,[...s,r]);return{type:x.BINARY,op:Wi[r],left:Me(n[0],t,[...s,r,0]),right:Me(n[1],t,[...s,r,1])}}throw new L(`Unknown condition JSON operator '${r}' at '${Ce(s)}'`)},Ll=(e,t={})=>{if(e==null)throw new L("Missing condition expression after '$when'");if(typeof e=="string"){if(e.trim()==="")throw new L("Empty condition expression after '$when'");return Ee(e,t)}return Qi(e)||Array.isArray(e)?Me(e,t):{type:x.LITERAL,value:e}},Ee=(e,t={})=>{if(e=e.trim(),e.startsWith("(")&&e.endsWith(")")){let c=e.slice(1,-1),u=0,p=!0;for(let d=0;d<c.length;d++)if(c[d]==="("?u++:c[d]===")"&&u--,u<0){p=!1;break}if(p&&u===0)return Ee(c,t)}let s=Gr(e,"||");if(s!==-1)return{type:x.BINARY,op:ee.OR,left:Ee(e.substring(0,s).trim(),t),right:Ee(e.substring(s+2).trim(),t)};let o=Gr(e,"&&");if(o!==-1)return{type:x.BINARY,op:ee.AND,left:Ee(e.substring(0,o).trim(),t),right:Ee(e.substring(o+2).trim(),t)};let a=[{op:">=",type:ee.GTE},{op:"<=",type:ee.LTE},{op:"==",type:ee.EQ},{op:"!=",type:ee.NEQ},{op:">",type:ee.GT},{op:"<",type:ee.LT},{op:" in ",type:ee.IN}];for(let{op:c,type:u}of a){let p=Gr(e,c);if(p!==-1)return{type:x.BINARY,op:u,left:Ee(e.substring(0,p).trim(),t),right:Ee(e.substring(p+c.length).trim(),t)}}let r=-1,n=null,i=[{op:" + ",type:ee.ADD},{op:" - ",type:ee.SUBTRACT}];for(let{op:c,type:u}of i){let p=0;for(;p<e.length;){let d=Gr(e.substring(p),c);if(d===-1)break;let f=p+d;f>r&&(r=f,n={op:c,type:u}),p=f+c.length}}if(r!==-1&&n)return{type:x.BINARY,op:n.type,left:Ee(e.substring(0,r).trim(),t),right:Ee(e.substring(r+n.op.length).trim(),t)};let l=[" * "," / "," % "];for(let c of l)if(Gr(e,c)!==-1)throw new L(`Arithmetic operations are not allowed in conditionals: "${c}"`);return e.startsWith("!")?{type:x.UNARY,op:ht.NOT,operand:Ee(e.substring(1).trim(),t)}:ql(e,t)},Gr=(e,t)=>{let s=0,o=0;for(;o<=e.length-t.length;){if(e[o]==="(")s++;else if(e[o]===")")s--;else if(s===0&&e.substring(o,o+t.length)===t)return o;o++}return-1},ky=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}},ql=(e,t)=>{let s=e.trim();if(s.match(/^(\w+)\((.*)\)$/))return qt(s,t);let a=ky(s);if(a.type===x.LITERAL)return a;if(/^[a-zA-Z_$][\w.$]*$/.test(s))return{type:x.VARIABLE,path:s};try{return qt(s,t)}catch(r){if(r.message&&r.message.includes("not supported"))return a;throw r}},Ay=(e,t=!1)=>{let s=t?"$each":"$for";try{xl(e)}catch(o){if(o instanceof L&&t){let a=o.message.replace(/\$for/g,"$each");throw new L(a.replace("Parse Error: ",""))}throw o}},Ml=(e,t,s,o=!1)=>{let a=/^\$for(?::(\w+))?\s+(.+)$/,r=e.match(a);if(!r){let b=o?"$each":"$for";throw new L(`Invalid loop syntax (got: '${e.replace("$for",b)}')`)}let n=r[1],i=r[2].trim();Ay(i,o);let l=i.match(/^(.+?)\s+in\s+(.+)$/);if(!l){let b=o?"$each":"$for";throw new L(`Invalid loop syntax - missing 'in' keyword (got: '${b} ${i}')`)}let c=l[1].trim(),u=l[2].trim(),p,d=null;if(c.includes(",")){let b=c.split(",").map(y=>y.trim());if(b.length!==2)throw new L(`Invalid loop variables: ${c}. Expected format: "item" or "item, index"`);p=b[0],d=b[1]}else p=c;let f=["this","undefined","null","true","false"];if(f.includes(p))throw new L(`Reserved variable name: ${p}`);if(d&&f.includes(d))throw new L(`Reserved variable name: ${d}`);let m=ql(u,s),g=Sr(t,s);return{type:x.LOOP,itemVar:p,indexVar:d,iterable:m,body:g,flatten:n!=="nested"}};var Py=(e,t={})=>{let{functions:s={}}=t;return Sr(e,s)},Bn=Py;var Ft={};Td(Ft,{now:()=>Ey});var Ey=()=>Date.now();var xy=(e,t,s={})=>{let{functions:o={},partials:a={}}=s,r={...Ft,...o},n=Bn(e,{functions:r}),i={};for(let[l,c]of Object.entries(a))i[l]=Bn(c,{functions:r});return Hi(n,t,{functions:r,partials:i})},Hr=xy;var Sy=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&typeof e.type=="number",Oy=(e={})=>!e||typeof e!="object"?{}:Object.prototype.hasOwnProperty.call(e,"functions")||Object.prototype.hasOwnProperty.call(e,"partials")?e.functions||{}:e,Ry=(e,t)=>{if(Sy(e))return e;if(typeof e=="string"){if(e.trim()==="")throw new L("Empty condition expression");return Ee(e,t)}return Me(e,t)},$y=(e,t={},s={})=>{let o=Oy(s),a={...Ft,...o},r=Ry(e,a);return!!Er(r,{functions:a,partials:{}},t,{})},Zi=$y;var lo=Symbol("runStoreTransaction"),no="__routeEngineConditionComparison",Un=(e,t)=>typeof e=="number"&&typeof t=="number"&&Number.isFinite(e)&&Number.isFinite(t)||typeof e=="string"&&typeof t=="string",Or=Object.freeze({eq:(e,t)=>e===t,neq:(e,t)=>e!==t,gt:(e,t)=>Un(e,t)&&e>t,gte:(e,t)=>Un(e,t)&&e>=t,lt:(e,t)=>Un(e,t)&&e<t,lte:(e,t)=>Un(e,t)&&e<=t}),Hl=Object.freeze(Object.fromEntries(Object.keys(Or).map(e=>[e,`${no}${e}`]))),Cy=Object.freeze(Object.fromEntries(Object.entries(Hl).map(([e,t])=>[t,Or[e]]))),Fl=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),_y=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},Yn=e=>{if(Array.isArray(e))return e.map(Yn);if(e===null||typeof e!="object"||Fl(e,"literal")||Fl(e,"var"))return e;if(_y(e)?.startsWith(no))throw new Error(`Condition function names beginning with "${no}" are reserved`);let s=Object.entries(e);if(s.length===1){let[[o,a]]=s,r=Hl[o];if(r)return{call:r,args:a.map(Yn)}}return Object.fromEntries(s.map(([o,a])=>[o,Yn(a)]))},Ut=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Zi(Yn(e),t,{functions:Cy})},Ny=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Kl=(e,t,s={})=>{let o={},a={},{transformSelectorFirstArgument:r=g=>g,transformActionFirstArgument:n=g=>g,createTransactionalMetadata:i,updateTransactionalMetadata:l,finalizeTransactionalMetadata:c}=s,u=typeof i=="function",p={state:structuredClone(e),...u?{transactionalMetadata:structuredClone(i())}:{}},d=0,f=(g,b)=>!u||!c?g:Fn(g,y=>{c({state:y.state,transactionalMetadata:y.transactionalMetadata,previousState:b.state,previousTransactionalMetadata:b.transactionalMetadata})});for(let[g,b]of Object.entries(t))g!=="createInitialState"&&(g.startsWith("select")?o[g]=(...y)=>b(r(p.state,p.transactionalMetadata),...y):a[g]=(...y)=>{let w,h=p,P=Fn(p,k=>{let E=b(n(k.state,k.transactionalMetadata),...y);w=E!==void 0&&!Pe(E)?E:void 0,u&&l&&l({actionName:g,args:y,state:k.state,transactionalMetadata:k.transactionalMetadata,previousState:h.state,previousTransactionalMetadata:h.transactionalMetadata})});return d===0&&(P=f(P,h)),p=P,w});let m=g=>{if(typeof g!="function")throw new Error("Store transaction requires a callback");let b=p,y=d===0;d+=1;let w;try{w=g()}catch(h){throw d-=1,p=b,h}if(d-=1,y)try{p=f(p,b)}catch(h){throw p=b,h}return w};return{...o,...a,[lo]:m}},Hn=(e,t)=>s=>{let o=e(),a=Array.isArray(s)?s:[s];return Fn(o,r=>{a.forEach(n=>{t.forEach(i=>{i(r,n)})})})};var jy=(e,t)=>{if(e.default!==void 0)return e.default;let s=["number","boolean","string","object"];if(!s.includes(e.type))throw new Error(`Invalid variable type: ${e.type} for variable ${t}. Expected one of: ${s.join(", ")}`);switch(e.type){case"number":return 0;case"boolean":return!1;case"string":return"";case"object":return{}}},Q=(e,t)=>Object.prototype.hasOwnProperty.call(e??{},t),so=(e,t,s)=>{Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0})},Ae=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Dy=new Set(["pageSize","groups"]),Ty=new Set(["id","variants"]),Ly=new Set(["id","imageId"]),My=new Set(["pageSize","tracks"]),Vy=new Set(["id","soundId","title","artist","album","description","coverImageId"]),qy=new Set(["pageSize","replays"]),Fy=new Set(["sceneId","title","thumbnailImageId","initialVariables"]),Kr=(e,t,s)=>{Object.keys(e).forEach(o=>{if(!t.has(o))throw new Error(`${s} contains unsupported property "${o}"`)})},gt=(e,t)=>{if(typeof e!="string"||e.length===0)throw new Error(`${t} must be a non-empty string`)},Yt=(e={})=>{let t=e?.resources?.imageGallery;if(t===void 0)return;if(!Ae(t))throw new Error("resources.imageGallery must be an object");if(Kr(t,Dy,"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 s=new Set;for(let[o,a]of t.groups.entries()){let r=`resources.imageGallery.groups[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);if(Kr(a,Ty,r),gt(a.id,`${r}.id`),s.has(a.id))throw new Error(`Duplicate image gallery group id "${a.id}"`);if(s.add(a.id),!Array.isArray(a.variants)||a.variants.length===0)throw new Error(`${r}.variants must be a non-empty array`);let n=new Set;for(let[i,l]of a.variants.entries()){let c=`${r}.variants[${i}]`;if(!Ae(l))throw new Error(`${c} must be an object`);if(Kr(l,Ly,c),gt(l.id,`${c}.id`),gt(l.imageId,`${c}.imageId`),n.has(l.id))throw new Error(`Duplicate image gallery variant id "${l.id}" in group "${a.id}"`);if(n.add(l.id),!Q(e?.resources?.images,l.imageId))throw new Error(`Image gallery variant "${a.id}.${l.id}" references unknown image "${l.imageId}"`)}}},zt=(e={})=>{let t=e?.resources?.musicRoom;if(t===void 0)return;if(!Ae(t))throw new Error("resources.musicRoom must be an object");if(Kr(t,My,"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 s=new Set;for(let[o,a]of t.tracks.entries()){let r=`resources.musicRoom.tracks[${o}]`;if(!Ae(a))throw new Error(`${r} must be an object`);Kr(a,Vy,r);for(let l of["id","soundId","title"])gt(a[l],`${r}.${l}`);for(let l of["artist","album","description","coverImageId"])a[l]!==void 0&>(a[l],`${r}.${l}`);if(s.has(a.id))throw new Error(`Duplicate music room track id "${a.id}"`);s.add(a.id);let n=e?.resources?.sounds?.[a.soundId];if(!Q(e?.resources?.sounds,a.soundId))throw new Error(`Music room track "${a.id}" references unknown sound "${a.soundId}"`);if(!Ae(n))throw new Error(`Music room track "${a.id}" references invalid sound "${a.soundId}"`);if(n.playbackRate!==void 0&&(typeof n.playbackRate!="number"||!Number.isFinite(n.playbackRate)||n.playbackRate<=0))throw new Error(`Music room sound "${a.soundId}" playbackRate must be a finite number greater than 0`);let i=n.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(n.endAt!==void 0&&n.endAt!==null&&(typeof n.endAt!="number"||!Number.isFinite(n.endAt)||n.endAt<=i))throw new Error(`Music room sound "${a.soundId}" endAt must be a finite number greater than startAt`);if(a.coverImageId!==void 0&&!Q(e?.resources?.images,a.coverImageId))throw new Error(`Music room track "${a.id}" references unknown cover image "${a.coverImageId}"`)}},By=(e,t,s)=>{let o=Array.isArray(s)?"array":typeof s;switch(t.type){case"number":if(typeof s!="number"||!Number.isFinite(s))throw new Error(`Scene replay initial variable "${e}" expected type number, got ${o}`);return;case"boolean":if(typeof s!="boolean")throw new Error(`Scene replay initial variable "${e}" expected type boolean, got ${o}`);return;case"string":if(typeof s!="string")throw new Error(`Scene replay initial variable "${e}" expected type string, got ${o}`);return;case"object":if(s===null||typeof s!="object")throw new Error(`Scene replay initial variable "${e}" expected type object, got ${o}`);return;default:throw new Error(`Scene replay initial variable "${e}" has invalid variable type "${t.type}"`)}},Xt=(e={})=>{let t=e?.resources?.sceneReplay;if(t===void 0)return;if(!Ae(t))throw new Error("resources.sceneReplay must be an object");if(Kr(t,qy,"resources.sceneReplay"),!Number.isInteger(t.pageSize)||t.pageSize<1)throw new Error("resources.sceneReplay.pageSize must be an integer greater than or equal to 1");if(!Array.isArray(t.replays))throw new Error("resources.sceneReplay.replays must be an array");let s=e?.story?.scenes??{},o=new Set;for(let[a,r]of t.replays.entries()){let n=`resources.sceneReplay.replays[${a}]`;if(!Ae(r))throw new Error(`${n} must be an object`);Kr(r,Fy,n);for(let u of["sceneId","title","thumbnailImageId"])gt(r[u],`${n}.${u}`);if(o.has(r.sceneId))throw new Error(`Duplicate scene replay sceneId "${r.sceneId}"`);if(o.add(r.sceneId),!Q(e?.resources?.images,r.thumbnailImageId))throw new Error(`Scene replay scene "${r.sceneId}" references unknown thumbnail image "${r.thumbnailImageId}"`);let i=s[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(!Ae(r.initialVariables))throw new Error(`${n}.initialVariables must be an object`);for(let[u,p]of Object.entries(r.initialVariables)){let d=e?.resources?.variables?.[u];if(!d)throw new Error(`Scene replay scene "${r.sceneId}" initialVariables references unknown variable "${u}"`);if(_e(d))throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize computed variable "${u}"`);if(d.readonly===!0)throw new Error(`Scene replay scene "${r.sceneId}" cannot initialize readonly variable "${u}"`);if(d.scope!=="context")throw new Error(`Scene replay scene "${r.sceneId}" can only initialize context variable "${u}"`);By(u,d,p)}}}},Wl=e=>{let t=Pe(e)?Pr(e):e;return structuredClone(t)},Uy=({characterId:e,resourceCharacter:t,variables:s={}}={})=>{if(!Q(t,"nameVariableId"))return;let o=t.nameVariableId,a=s?.[o];if(typeof a!="string")throw new Error(`Character "${e}" nameVariableId "${o}" must resolve to a string variable`);return a},Kn=({characterId:e,character:t,characterName:s,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0;if(t?.name!==void 0)return t.name;if(s!==void 0)return s;let n=Uy({characterId:e,resourceCharacter:r,variables:a});return n!==void 0?n:r?.name||""},_e=e=>Q(e,"computed"),co=(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}},Gt=(e={},t={},{allowedScopes:s,preserveUnknown:o=!1}={})=>Object.fromEntries(Object.entries(e??{}).filter(([a,r])=>{let n=t[a];return n===void 0?o:!_e(n)&&(!s||s.includes(n.scope))&&co(n,r)})),Xe=(e,t)=>new Error(`${t} has invalid path: ${JSON.stringify(e)}`),Yy=(e,t,s)=>{if(e[0]==='"')try{return JSON.parse(e)}catch{throw Xe(t,s)}let a="";for(let r=1;r<e.length-1;r+=1){let n=e[r];if(n!=="\\"){if(n.charCodeAt(0)<32)throw Xe(t,s);a+=n;continue}if(r+=1,r>=e.length-1)throw Xe(t,s);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 Xe(t,s);a+=String.fromCharCode(Number.parseInt(c,16)),r+=4;continue}let l={"\\":"\\",'"':'"',"'":"'","/":"/",n:`
|
|
2
|
+
`,r:"\r",t:" ",b:"\b",f:"\f"};if(!Q(l,i))throw Xe(t,s);a+=l[i]}return a},Jl=(e,t="Computed expression var")=>{if(typeof e!="string"||e.length===0||e.trim()!==e)throw Xe(e,t);let s=[],o=0,a=()=>{let n=o;for(;o<e.length&&e[o]!=="."&&e[o]!=="["&&e[o]!=="]";)o+=1;let i=e.slice(n,o);if(i.length===0||i.trim()!==i||/\s/.test(i))throw Xe(e,t);s.push(i)},r=()=>{for(o+=1;o<e.length&&/\s/.test(e[o]);)o+=1;let n=e[o];if(/\d/.test(n??"")){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 Xe(e,t);o+=1,s.push(p);return}if(n!=='"'&&n!=="'")throw Xe(e,t);let i=n,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 Xe(e,t);o+=1,s.push(Yy(p,e,t));return}o+=1}if(c||o>=e.length)throw Xe(e,t)};for(a();o<e.length;){if(e[o]==="."){o+=1,a();continue}if(e[o]==="["){r();continue}throw Xe(e,t)}return s},eo=(e,t)=>{let s=e;for(let o of t){if(s==null||!Q(s,o))return;s=s[o]}return s},Ql=(e,t={})=>{if(typeof e!="string"||e.trim()==="")throw new Error("Computed expression var requires a non-empty string path");let s=Jl(e),[o,a,...r]=s;if(o==="variables"){if(!a)return t.variables;let n=typeof t.resolveVariable=="function"?t.resolveVariable(a):t.variables?.[a];return eo(n,r)}return o==="runtime"?eo(t.runtime,s.slice(1)):eo(t,s)},Zl=(e,t,s)=>{if(!Array.isArray(t))throw new Error(`Computed expression operator "${e}" requires an array`);if(s!==void 0&&t.length!==s)throw new Error(`Computed expression operator "${e}" requires ${s} operand(s)`)},io=(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`)},zy=(e,t)=>{if(typeof t!="number"||!Number.isFinite(t))throw new Error(`Computed expression operator "${e}" requires finite numeric operands`)},Je=(e,t,s,o)=>(Zl(e,t,o),t.map(a=>Gn(a,s))),ze=(e,t,s,o)=>{let a=Je(e,t,s,o);return a.forEach(r=>zy(e,r)),a},Xy=(e,t,s)=>{switch(e){case"var":return Ql(t,s);case"add":{let[o,a]=ze(e,t,s,2);return o+a}case"sub":{let[o,a]=ze(e,t,s,2);return o-a}case"mul":{let[o,a]=ze(e,t,s,2);return o*a}case"div":{let[o,a]=ze(e,t,s,2);return o/a}case"mod":{let[o,a]=ze(e,t,s,2);return o%a}case"neg":{let[o]=ze(e,t,s,1);return-o}case"round":{let[o]=ze(e,t,s,1);return Math.round(o)}case"floor":{let[o]=ze(e,t,s,1);return Math.floor(o)}case"ceil":{let[o]=ze(e,t,s,1);return Math.ceil(o)}case"min":{let[o,a]=ze(e,t,s,2);return Math.min(o,a)}case"max":{let[o,a]=ze(e,t,s,2);return Math.max(o,a)}case"clamp":{let[o,a,r]=ze(e,t,s,3);return Math.min(r,Math.max(a,o))}case"eq":{let[o,a]=Je(e,t,s,2);return Or.eq(o,a)}case"neq":{let[o,a]=Je(e,t,s,2);return Or.neq(o,a)}case"gt":{let[o,a]=Je(e,t,s,2);return Or.gt(o,a)}case"gte":{let[o,a]=Je(e,t,s,2);return Or.gte(o,a)}case"lt":{let[o,a]=Je(e,t,s,2);return Or.lt(o,a)}case"lte":{let[o,a]=Je(e,t,s,2);return Or.lte(o,a)}case"in":{let[o,a]=Je(e,t,s,2);return Array.isArray(a)?a.includes(o):!1}case"and":case"all":return io(e,t),t.every(o=>!!Gn(o,s));case"or":case"any":return io(e,t),t.some(o=>!!Gn(o,s));case"not":{let[o]=Je(e,t,s,1);return!o}case"length":{let[o]=Je(e,t,s,1);return typeof o=="string"||Array.isArray(o)?o.length:Ae(o)?Object.keys(o).length:0}case"includes":{let[o,a]=Je(e,t,s,2);return typeof o=="string"?typeof a=="string"&&o.includes(a):Array.isArray(o)?o.includes(a):!1}case"literal":return Wl(t);default:throw new Error(`Unknown computed expression operator: ${e}`)}},Gn=(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 s=Object.entries(e);if(s.length!==1)throw new Error("Computed expression objects must contain exactly one operator");let[[o,a]]=s;return Xy(o,a,t)},oo=(e,t)=>{if(e===null||typeof e!="object"||Q(e,"literal"))return e;if(Q(e,"var"))return{literal:Ql(e.var,t)};if(Q(e,"call"))throw new Error("Function calls are not supported in computed-variable conditions");return Object.fromEntries(Object.entries(e).map(([s,o])=>[s,Array.isArray(o)?o.map(a=>oo(a,t)):oo(o,t)]))},Gy=(e,t={})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");return Me(e),Ut(oo(e,t))},ec=(e,t)=>{if(!Ae(e))throw new Error(`${t} must be an object`);let s=Q(e,"expr"),o=Q(e,"value");if(s===o)throw new Error(`${t} must contain exactly one of expr or value`)},ro=(e,t,s)=>(ec(e,t),Q(e,"value")?Wl(e.value):Gn(e.expr,s)),Hy=(e,t={},s="unknown")=>{if(!Ae(e))throw new Error(`Computed variable "${s}" computed must be an object`);let o=Q(e,"expr"),a=Q(e,"value");if(Q(e,"branches")){if(o||a)throw new Error(`Computed variable "${s}" cannot combine branches with expr or value`);if(!Array.isArray(e.branches))throw new Error(`Computed variable "${s}" branches must be an array`);if(e.branches.length===0)throw new Error(`Computed variable "${s}" branches must not be empty`);if(!Ae(e.default))throw new Error(`Computed variable "${s}" requires default`);for(let n=0;n<e.branches.length;n+=1){let i=e.branches[n];if(!Ae(i))throw new Error(`Computed variable "${s}" branch ${n} must be an object`);if(!Q(i,"when"))throw new Error(`Computed variable "${s}" branch ${n} requires when`);if(Gy(i.when,t))return ro(i,`Computed variable "${s}" branch ${n}`,t)}return ro(e.default,`Computed variable "${s}" default`,t)}if(o===a)throw new Error(`Computed variable "${s}" must contain exactly one of expr, value, or branches`);return ro(e,`Computed variable "${s}"`,t)},rc=(e,t,s)=>{switch(t){case"number":if(typeof s!="number"||!Number.isFinite(s))throw new Error(`Computed variable "${e}" expected type number, got ${Array.isArray(s)?"array":typeof s}`);return;case"boolean":if(typeof s!="boolean")throw new Error(`Computed variable "${e}" expected type boolean, got ${Array.isArray(s)?"array":typeof s}`);return;case"string":if(typeof s!="string")throw new Error(`Computed variable "${e}" expected type string, got ${Array.isArray(s)?"array":typeof s}`);return;case"object":if(s===null||typeof s!="object")throw new Error(`Computed variable "${e}" expected type object, got ${typeof s}`);return;default:throw new Error(`Invalid variable type: ${t} for computed variable ${e}`)}},Ky=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}),Wy=new Set(["and","or","all","any"]),Jy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp","length"]),Qy=new Set(["add","sub","mul","div","mod","neg","round","floor","ceil","min","max","clamp"]),Zy=new Set(["eq","neq","gt","gte","lt","lte","in","and","or","all","any","not","includes"]),eh=new Set(["all","any","eq","neq","gt","gte","lt","lte","in","add","sub"]),tc=new WeakMap,Bl=e=>e===null?"null":Array.isArray(e)?"object":typeof e,zn=(e,t,s)=>{for(let o of Object.keys(e))if(!t.has(o))throw new Error(`${s} contains unsupported property "${o}"`)},rh=(e,t,s,o)=>{if(s!==void 0&&s!==t)throw new Error(`Computed variable "${e}" ${o} expected type ${t}, got ${s}`)},nc=(e,{variableId:t,variableConfigs:s,dependencies:o,path:a})=>{let r=`Computed variable "${t}" ${a} var`,[n,i,...l]=Jl(e,r);if(n!=="variables"&&n!=="runtime")throw new Error(`${r} must reference variables.* or runtime.*, got ${JSON.stringify(e)}`);if(!i)throw new Error(`${r} must reference a concrete ${n} member, got ${JSON.stringify(e)}`);if(n==="runtime")return;if(!Q(s,i))throw new Error(`Computed variable "${t}" ${a} references unknown variable "${i}"`);let c=s[i];return _e(c)&&o.add(i),l.length===0?c?.type:void 0},sc=(e,{variableId:t,variableConfigs:s,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 Bl(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[[n,i]]=r;if(n==="var"){if(typeof i!="string"||i.trim()==="")throw new Error("Computed expression var requires a non-empty string path");return nc(i,{variableId:t,variableConfigs:s,dependencies:o,path:a})}if(n==="literal"){if(typeof i=="number"&&!Number.isFinite(i))throw new Error(`Computed variable "${t}" ${a} must use finite numeric literals`);return Bl(i)}let l=Ky[n];if(l===void 0&&!Wy.has(n))throw new Error(`Unknown computed expression operator: ${n}`);l===void 0?io(n,i):Zl(n,i,l);let c=i.map((u,p)=>sc(u,{variableId:t,variableConfigs:s,dependencies:o,path:`${a}.${n}[${p}]`}));if(Qy.has(n)&&c.forEach(u=>{if(u!==void 0&&u!=="number")throw new Error(`Computed expression operator "${n}" requires numeric operands`)}),Jy.has(n))return"number";if(Zy.has(n))return"boolean"},th=(e,{variableId:t,variableConfigs:s,dependencies:o,path:a})=>{if(typeof e=="string")throw new Error("String condition expressions are not supported; use semantic JSON conditions");try{Me(e)}catch(n){throw new Error(`Computed variable "${t}" ${a} is invalid: ${n.message}`,{cause:n})}let r=(n,i)=>{if(n===null||typeof n!="object"||Q(n,"literal"))return;if(Q(n,"var")){nc(n.var,{variableId:t,variableConfigs:s,dependencies:o,path:i});return}if(Q(n,"call"))throw new Error(`Computed variable "${t}" ${i} function calls are not supported`);if(Q(n,"not")){r(n.not,`${i}.not`);return}let l=Object.keys(n).find(c=>eh.has(c));n[l].forEach((c,u)=>{r(c,`${i}.${l}[${u}]`)})};r(e,a)},to=(e,{variableId:t,variableConfig:s,variableConfigs:o,dependencies:a,path:r,allowedKeys:n=new Set(["expr","value"])})=>{if(ec(e,`Computed variable "${t}" ${r}`),zn(e,n,r),Q(e,"value")){rc(t,s.type,e.value);return}let i=sc(e.expr,{variableId:t,variableConfigs:o,dependencies:a,path:`${r}.expr`});rh(t,s.type,i,`${r}.expr`)},nh=(e,t,s)=>{let o=t.computed;if(!Ae(o))throw new Error(`Computed variable "${e}" computed must be an object`);let a=new Set,r=Q(o,"expr"),n=Q(o,"value");if(Q(o,"branches")){if(zn(o,new Set(["branches","default"]),`Computed variable "${e}" computed`),r||n)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(!Ae(o.default))throw new Error(`Computed variable "${e}" requires default`);return o.branches.forEach((l,c)=>{if(!Ae(l))throw new Error(`Computed variable "${e}" branch ${c} must be an object`);if(zn(l,new Set(["when","expr","value"]),`Computed variable "${e}" branch ${c}`),!Q(l,"when"))throw new Error(`Computed variable "${e}" branch ${c} requires when`);th(l.when,{variableId:e,variableConfigs:s,dependencies:a,path:`computed.branches[${c}].when`}),to(l,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:`computed.branches[${c}]`,allowedKeys:new Set(["when","expr","value"])})}),to(o.default,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:"computed.default"}),a}if(zn(o,new Set(["expr","value"]),`Computed variable "${e}" computed`),r===n)throw new Error(`Computed variable "${e}" must contain exactly one of expr, value, or branches`);return to(o,{variableId:e,variableConfig:t,variableConfigs:s,dependencies:a,path:"computed"}),a},Wr=(e={})=>{if(!Ae(e))throw new Error("Variable configs must be an object");if(Q(e,"__proto__"))throw new Error('Variable id "__proto__" is reserved');if(Q(e,""))throw new Error("Variable ids must not be empty");let t=new Map;Object.entries(e).forEach(([r,n])=>{if(_e(n)){if(!Ae(n))throw new Error(`Computed variable "${r}" must be an object`);if(!Q(n,"type"))throw new Error(`Computed variable "${r}" requires type`);if(!Q(n,"scope"))throw new Error(`Computed variable "${r}" requires scope`);if(Q(n,"default"))throw new Error(`Computed variable "${r}" must not declare a top-level default`);if(Ht(n.scope,r),!["number","boolean","string","object"].includes(n.type))throw new Error(`Invalid variable type: ${n.type} for computed variable ${r}`);t.set(r,nh(r,n,e))}});let s=new Set,o=[];t.forEach((r,n)=>{if(s.has(n))return;let i=[{variableId:n,dependencies:[...t.get(n)??[]],nextDependencyIndex:0}],l=new Map([[n,0]]);for(;i.length>0;){let c=i.at(-1);if(c.nextDependencyIndex>=c.dependencies.length){i.pop(),l.delete(c.variableId),s.add(c.variableId),o.push(c.variableId);continue}let u=c.dependencies[c.nextDependencyIndex];if(c.nextDependencyIndex+=1,s.has(u))continue;let p=l.get(u);if(p!==void 0){let d=[...i.slice(p).map(({variableId:f})=>f),u].join(" -> ");throw new Error(`Computed variable cycle detected: ${d}`)}l.set(u,i.length),i.push({variableId:u,dependencies:[...t.get(u)??[]],nextDependencyIndex:0})}});let a=Object.freeze({evaluationOrder:Object.freeze(o)});return tc.set(e,a),a},bt=({variables:e={},runtime:t={},variableConfigs:s={},eager:o=!0}={})=>{let{evaluationOrder:a}=tc.get(s)??Wr(s),r=Gt(e,s,{preserveUnknown:!0}),n=Object.entries(s).filter(([,b])=>_e(b)).map(([b])=>b),i=Object.create(null),l=[],c=new Map(a.map((b,y)=>[b,y])),u=-1,p=!1,d=b=>{if(Q(i,b))return i[b];let y=s[b];if(!_e(y))return Q(r,b)?r[b]:void 0;let w=l.indexOf(b);if(w>=0){let h=[...l.slice(w),b].join(" -> ");throw new Error(`Computed variable cycle detected: ${h}`)}l.push(b);try{let h=Hy(y.computed,g,b);return rc(b,y.type,h),so(i,b,h),h}finally{l.pop()}},f=b=>{if(Q(i,b))return i[b];let y=s[b];if(!_e(y))return Q(r,b)?r[b]:void 0;let w=c.get(b);if(o&&!p&&w!==void 0&&w>u){p=!0;try{for(let h=u+1;h<=w;h+=1)d(a[h]),u=h}finally{p=!1}return i[b]}return d(b)},m=new Proxy({},{get:(b,y)=>{if(typeof y=="string")return f(y)},has:(b,y)=>typeof y=="string"&&(Q(r,y)||n.includes(y)),ownKeys:()=>[...new Set([...Object.keys(r),...n])],getOwnPropertyDescriptor:(b,y)=>{if(!(typeof y!="string"||!Q(r,y)&&!n.includes(y)))return{enumerable:!0,configurable:!0}}}),g={variables:m,runtime:t,resolveVariable:f};return o?(n.forEach(b=>{f(b)}),{...r,...i}):m},sh=({variables:e={},runtime:t={},variableConfigs:s,projectData:o}={})=>{let a=s??o?.resources?.variables??{};return Wr(a),bt({variables:e,runtime:t,variableConfigs:a,eager:!0})},Wn=e=>{let t={},s={};return e.resources?.variables?(Object.entries(e.resources.variables).forEach(([o,a])=>{if(_e(a))return;let r=jy(a,o);a.scope==="context"?so(t,o,r):so(s,o,r)}),{contextVariableDefaultValues:t,globalVariablesDefaultValues:s}):{contextVariableDefaultValues:t,globalVariablesDefaultValues:s}},Ht=(e,t)=>{let s=["context","device","account"];if(!e)throw new Error(`Variable scope is required for variable: ${t}`);if(!s.includes(e))throw new Error(`Invalid variable scope: ${e} for variable ${t}. Expected one of: ${s.join(", ")}`)},Kt=(e,t,s)=>{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 ${s}`);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 "${s}" of type "${e}". Valid operations: ${a.join(", ")}`)},ih=2,Ul=12,ic=(e=ih)=>{if(!Number.isInteger(e)||e<0||e>Ul)throw new Error(`Operation "divide" requires roundTo to be an integer between 0 and ${Ul}.`);return e},oh=(e,t)=>{let s=10**t;return Math.round((e+Number.EPSILON)*s)/s},Xn=e=>typeof e=="number"&&Number.isFinite(e),Jn=(e,t,s,o,a={})=>{if(e==="number"){if(t==="set"&&!Xn(s))throw new Error(`Operation "set" requires value to be a number for variable "${o}".`);if(t==="multiply"&&!Xn(s))throw new Error(`Operation "multiply" requires value to be a number for variable "${o}".`);if(t==="divide"&&!Xn(s))throw new Error(`Operation "divide" requires value to be a number for variable "${o}".`);if(t==="divide"){if(s===0)throw new Error(`Operation "divide" requires value to be a non-zero number for variable "${o}".`);ic(a.roundTo)}}},Qn=(e,t,s,o={})=>{let a=(n,i,l)=>{let c=n??i;if(!Xn(c))throw new Error(`Operation "${t}" requires ${l} to be a number.`);return c},r=n=>{let i=a(n,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 s;case"multiply":return a(e,1,"current value")*a(s,void 0,"value");case"divide":return oh(a(e,0,"current value")/r(s),ic(o.roundTo));case"increment":return a(e,0,"current value")+a(s,1,"value");case"decrement":return a(e,0,"current value")-a(s,1,"value");case"toggle":return!e;default:throw new Error(`Unknown operation: ${t}`)}};var uo=(e,t="DD/MM/YYYY - HH:mm")=>{if(!e)return"";let s=new Date(e),o=n=>String(n).padStart(2,"0"),a=String(s.getFullYear()),r={DD:o(s.getDate()),MM:o(s.getMonth()+1),MMM:Ny[s.getMonth()],YYYY:a,YY:a.slice(-2),HH:o(s.getHours()),mm:o(s.getMinutes()),ss:o(s.getSeconds())};return t.replace(/YYYY|MMM|YY|MM|DD|HH|mm|ss/g,n=>r[n])},ah=(e,t)=>{let s=r=>r?.ui,o=s(e),a=s(t);return JSON.stringify(o)===JSON.stringify(a)?null:o&&!a?{changeType:"delete",data:e}:a&&!o?{changeType:"add",data:t}:a&&o?{changeType:"update",data:t}:null},Bt=e=>!!e?.transformId&&Array.isArray(e.items)&&e.items.length>0,lh=(e,t)=>{let s=e?.character?.sprite,o=t?.character?.sprite,a=Bt(s)?s:void 0,r=Bt(o)?o:void 0;return JSON.stringify(a)===JSON.stringify(r)?null:a&&!r?{changeType:"delete",data:a}:r&&!a?{changeType:"add",data:r}:r&&a?{changeType:"update",data:r}:null},Yl=e=>{if(e?.resourceId===void 0)return;let t={resourceId:e.resourceId};e.transformId!==void 0&&(t.transformId=e.transformId);for(let s of["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"])e[s]!==void 0&&(t[s]=e[s]);for(let s of["animationName","animationSpeed","loop"])e[s]!==void 0&&(t[s]=e[s]);return t},zl=e=>{if(e?.colorId!==void 0)return{colorId:e.colorId}},Xl=(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,ch=(e,t)=>{let s={},o=Xl(Yl(e),Yl(t)),a=Xl(zl(e),zl(t));return o&&(s.resource=o),a&&(s.color=a),Object.keys(s).length>0?s:null},po=(e={},t={})=>{let s={},o=["voice"],a=l=>{let c=e[l],u=t[l];if(u&&!c)s[l]={changeType:"add",data:u};else if(c&&!u){let p=l==="sfx"&&c.channels?.some(d=>d.applyMode==="persistent");!o.includes(l)&&(l!=="sfx"||p)&&(s[l]={changeType:"delete",data:c})}else c&&u&&JSON.stringify(c)!==JSON.stringify(u)&&(s[l]={changeType:"update",data:u})},r=ch(e.background,t.background);r&&(s.background=r),a("screen"),a("bgm"),a("voice");let n=ah(e.dialogue,t.dialogue);n&&(s.dialogue=n);let i=lh(e.dialogue,t.dialogue);return i&&(s.dialogueSprite=i),a("choice"),a("form"),a("layout"),a("animation"),a("control"),a("character"),a("visual"),a("sfx"),s},fo=(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 s=a=>{t[a]&&(delete t[a].animations,Object.keys(t[a]).length===0&&delete t[a])};s("layout"),s("choice"),s("form"),s("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 n=t[a]?.items;Array.isArray(n)&&(t[a].items=n.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},uh=(e,t)=>{if(!e||!t)return;let s=e;for(let o of t.split(".")){if(s==null||o==="__proto__"||o==="prototype"||o==="constructor"||!Object.prototype.hasOwnProperty.call(Object(s),o))return;s=s[o]}return s},Gl=e=>e!==null&&typeof e=="object"?structuredClone(e):e,ph=(e,t,s)=>{if(typeof e!="string")return e;let o=Object.prototype.hasOwnProperty.call(t??{},s)?t[s]:void 0;if(e===s){if(o==null)throw new Error(`Action template binding "${s}" requires event context "${s}".`);return Gl(o)}if(!e.startsWith(`${s}.`))return e;if(o==null)throw new Error(`Action template binding "${e}" requires event context "${s}".`);let a=e.slice(s.length+1),r=uh(o,a);if(r===void 0)throw new Error(`Action template binding "${e}" could not be resolved from "${s}".`);return Gl(r)},fh={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"])},mh=(e,t)=>{let s=e[e.length-1];return s?fh[s]?.has(t)===!0:!1},ao=(e,t,s=[])=>Array.isArray(e)?e.map(o=>ao(o,t,s)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([o,a])=>[o,mh(s,o)?a:ao(a,t,[...s,o])])):typeof e=="string"?e==="_event"||e.startsWith("_event.")?ph(e,t,"_event"):Hr(e,t):e,Wt=(e,t)=>{if(!t)return e;if(Object.prototype.hasOwnProperty.call(t,"event"))throw new Error('Action template context key "event" is no longer supported. Use "_event".');return ao(e,t)};var dh=11102230246251565e-32,oc=128,ac=1e3,lc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Jt=(e,t,s)=>{let o=Object.keys(e).find(a=>!t.has(a));if(o!==void 0)throw new Error(`${s}.${o} is not supported`)},Zn=(e,t)=>{if(!lc(e))throw new Error(`${t} must be an object`)},es=(e,t,{min:s,max:o}={})=>{if(!Number.isSafeInteger(e))throw new Error(`${t} must be a safe integer`);if(s!==void 0&&e<s)throw new Error(`${t} must be at least ${s}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},yh=(e,t,{min:s,max:o}={})=>{if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} must be a finite number`);if(s!==void 0&&e<s)throw new Error(`${t} must be at least ${s}`);if(o!==void 0&&e>o)throw new Error(`${t} must be at most ${o}`);return e},mo=e=>{let t=structuredClone(e),s=o=>(o&&typeof o=="object"&&!Object.isFrozen(o)&&(Object.values(o).forEach(s),Object.freeze(o)),o);return s(t)},hh=()=>({nextUint32(){return typeof globalThis.crypto?.getRandomValues=="function"?globalThis.crypto.getRandomValues(new Uint32Array(1))[0]:Math.floor(Math.random()*4294967296)}}),cc=e=>{let t=e??hh();if(!lc(t)||typeof t.nextUint32!="function")throw new TypeError("randomSource must provide nextUint32()");return{nextUint32(){let s=t.nextUint32();if(!Number.isInteger(s)||s<0||s>=4294967296)throw new Error("randomSource.nextUint32() must return an integer from 0 through 4294967295");return s}}},gh=(e,t)=>{let s=4294967296-4294967296%t;for(let o=0;o<oc;o+=1){let a=e.nextUint32();if(a<s)return a%t}throw new Error(`random source exhausted after ${oc} rejected samples`)},bh=e=>{let t=e.nextUint32()>>>5,s=e.nextUint32()>>>6;return(t*67108864+s)/9007199254740992},wh=(e,t)=>{if(Jt(e,new Set(["type","min","max"]),"random.distribution"),!Object.prototype.hasOwnProperty.call(e,"min"))throw new Error("random.distribution.min is required");if(!Object.prototype.hasOwnProperty.call(e,"max"))throw new Error("random.distribution.max is required");let s=es(e.min,"random.distribution.min"),a=es(e.max,"random.distribution.max")-s+1;if(!Number.isSafeInteger(a)||a<1||a>4294967296)throw new Error("random integer range must contain from 1 through 4294967296 values");return mo({type:"integer",value:a===1?s:s+gh(t,a)})},Ih=(e,t)=>{if(Jt(e,new Set(["type","outcomes"]),"random.distribution"),!Array.isArray(e.outcomes)||e.outcomes.length<1||e.outcomes.length>ac)throw new Error("random.distribution.outcomes must contain from 1 through 1000 items");let s=e.outcomes.map((c,u)=>{let p=`random.distribution.outcomes[${u}]`;if(Zn(c,p),Jt(c,new Set(["weight","actions"]),p),!Object.prototype.hasOwnProperty.call(c,"weight"))throw new Error(`${p}.weight is required`);return Zn(c.actions,`${p}.actions`),{weight:yh(c.weight,`${p}.weight`,{min:0})}}),o=Math.max(...s.map(({weight:c})=>c));if(o<=0)throw new Error("random weighted total weight must be positive");let a=s.map(c=>({...c,weight:c.weight/o})),r=a.reduce((c,u)=>c+u.weight,0);a.forEach((c,u)=>{if(s[u].weight>0&&(c.weight===0||c.weight/r<=dh))throw new Error(`random.distribution.outcomes[${u}].weight is below the supported probability resolution`)});let n=bh(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,n<i){l=c;break}}return mo({type:"weighted",outcomeIndex:l})},uc=(e,{randomSource:t})=>{Zn(e,"random.distribution");let o={integer:wh,weighted:Ih}[e.type];if(!o)throw new Error('random.distribution.type must be "integer" or "weighted"');return o(e,t)},rs=(e,t)=>{if(Zn(e,"random result"),e.type!==t)throw new Error("random result type does not match its recorded type");if(t==="integer")Jt(e,new Set(["type","value"]),"random result"),es(e.value,"random result.value");else if(t==="weighted")Jt(e,new Set(["type","outcomeIndex"]),"random result"),es(e.outcomeIndex,"random result.outcomeIndex",{min:0,max:ac-1});else throw new Error(`unsupported recorded random result type: ${t}`);return mo(e)};var Jr=(e,t)=>Object.freeze({name:e,actions:Object.freeze(t)}),mc=Object.freeze([Jr("cleanup",["clearPendingEffects","cleanAll"]),Jr("state",["addViewedLine","addViewedResource","updateVariable","updateFormField","updateProjectData","updateLocalizationPackage","markLineCompleted","random:integer"]),Jr("decision",["submitForm","cancelForm","random:weighted","conditional"]),Jr("presentation",["screen","background","dialogue","character","visual","choice","form","sfx","bgm","voice","control","layout"]),Jr("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"]),Jr("persistence",["saveSlot"]),Jr("navigation",["loadSlot","rollbackByOffset","rollbackToLine","resetStoryAtSection","sectionTransition","jumpToLine","startSceneReplay","exitSceneReplay","nextLine","nextLineFromSystem"])]),wt=new Map;mc.forEach(e=>{e.actions.forEach(t=>{if(wt.has(t))throw new Error(`duplicate action execution key: ${t}`);wt.set(t,wt.size)})});var vh=new Set(mc.find(({name:e})=>e==="navigation").actions),pc=wt.get("saveSlot")-.5,fc=(e,t)=>e!=="random"?e:t?.distribution?.type==="weighted"?"random:weighted":"random:integer",kh=(e,t)=>e<t?-1:e>t?1:0,ts=e=>Object.entries(e).sort((t,s)=>{let o=fc(...t),a=fc(...s),r=wt.get(o),n=wt.get(a),i=r??pc,l=n??pc;return i!==l?i-l:r!==void 0&&n!==void 0?0:kh(o,a)}),ns=e=>vh.has(e),ss=e=>{let t=e.map(([s])=>s).filter(ns);if(!(t.length<=1))throw new Error(`action batch cannot contain multiple navigation actions: ${t.join(", ")}`)};var Ah=e=>String(e).replaceAll("%","%25").replaceAll(":","%3A"),Rr=(...e)=>e.map(Ah).join(":");var tr=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),It=Object.freeze({volume:100,pan:0,playbackRate:1}),go=["volume","pan","playbackRate"],Ph=["src","startAt","endAt","startDelayMs"],dc=(e,t)=>{if(!e)return null;let s=e.children??[];if(s.length!==1)throw new Error(`[${t}.audioEffects] Audio effects require exactly one BGM sound on each present side.`);return s[0]},bc=(e,t)=>e?.id===t?.id&&Ph.every(s=>(e?.[s]??(s==="endAt"?null:0))===(t?.[s]??(s==="endAt"?null:0))),wc=(e,t)=>JSON.stringify(e)===JSON.stringify(t),Eh=(e,t)=>e===t||Math.abs(e-t)<=Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)),yo=e=>Math.max(-1,Math.min(1,e)),ho=({bgm:e,resources:t,renderedSound:s,property:o})=>{let a=e?.sounds?.find(({id:n})=>Rr("bgm",n)===s?.id),r=t.sounds?.[a?.resourceId];return a?.[o]??r?.[o]??It[o]},xh=({property:e,value:t,relative:s,nextBgm:o,nextResources:a,nextSound:r})=>{if(!o||!r)return t;if(e==="volume"){let n=ho({bgm:o,resources:a,renderedSound:r,property:e});return t*n/100}if(e==="pan"&&!s){let n=ho({bgm:o,resources:a,renderedSound:r,property:e});return yo(t+n)}return t},Sh=({authoredInitialValue:e,authoredKeyframes:t,compiledKeyframes:s,previousBgm:o,nextBgm:a,nextResources:r,nextSound:n})=>{if(!a||!n)return s;let i=ho({bgm:a,resources:r,renderedSound:n,property:"pan"}),l=e??o?.pan??It.pan;return s.map((c,u)=>{let p=t[u];if(p.relative!==!0)return l=p.value,c;let d=tr(p,"startValue")?l+p.startValue:l,f=d+p.value,{relative:m,...g}=c;return l=f,{...g,...tr(p,"startValue")?{startValue:yo(d+i)}:{},value:yo(f+i)}})},Ic=(e,t)=>{let s=e?.playback?.speed??1;if(typeof s!="number"||!Number.isFinite(s)||s<=0)throw new Error(`[${t}.playback.speed] Audio effect speed must be a finite number greater than 0.`);return s},vc=(e,t)=>({...tr(e,"startValue")?{startValue:e.startValue}:{},value:e.value,delay:(e.delay??0)/t,duration:e.duration/t,easing:e.easing??"linear",...e.relative===!0?{relative:!0}:{}}),Oh=(e,t,s)=>{let o=vc(e,t);return o.value=o.value*s/100,tr(o,"startValue")&&(o.startValue=o.startValue*s/100),o},yc=(e,t,s,o,a)=>{if(!e)return;let r;tr(e,"initialValue")?r=e.initialValue*o/100:t==="enter"&&(r=0);let n=e.keyframes;if(n){if(n.some(l=>l.relative===!0))throw new Error(`[${a}.keyframes] Transition fade keyframes must use absolute values.`);if(t==="enter"&&n.at(-1)?.value!==100)throw new Error(`[${a}.keyframes] The final incoming transition fade value must be 100.`);let i=n.map(l=>Oh(l,s,o));return t==="enter"&&(i.at(-1).value=o),{...r===void 0?{}:{initialValue:r},keyframes:i}}return{...r===void 0?{}:{initialValue:r},keyframes:[{value:t==="exit"?0:o,delay:(e.delay??0)/s,duration:e.duration/s,easing:e.easing??"linear"}]}},kc=({property:e,authored:t,speed:s,resourcePath:o,normalizeValue:a=({value:r})=>r})=>{let r=t.keyframes.at(-1);if(typeof r?.value!="number"||!Number.isFinite(r.value)||r.relative===!0)throw new Error(`[${o}.tween.${e}.keyframes] The final keyframe must use an absolute finite numeric value.`);let n={keyframes:t.keyframes.map(i=>{let l=vc(i,s),c=l.relative===!0;return l.value=a({property:e,value:l.value,relative:c}),tr(l,"startValue")&&(l.startValue=a({property:e,value:l.startValue,relative:c})),l})};return tr(t,"initialValue")&&(n.initialValue=a({property:e,value:t.initialValue,relative:!1})),n},Ac=({selection:e,selectionPath:t,resources:s={}})=>{if(!e)return;let o=e.resourceId,a=`resources.audioEffects.${o}`,r=s.audioEffects?.[o];if(!r)throw new Error(`[${t}.resourceId]
|
|
3
3
|
[${a}] Unknown audio effect resource "${o}".`);if(r.type!=="update")throw new Error(`[${t}]
|
|
4
|
-
[${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let n=Ic(e,t),i={};for(let l of go)
|
|
5
|
-
[${u}] Unknown audio effect resource "${c}".`);let
|
|
6
|
-
[${u}] Audio effect resource "${c}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let h={},P=yc(f?p.prev?.fade:void 0,"exit",
|
|
7
|
-
[${u}] Audio effect resource "${c}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let w={};for(let h of go){if(!
|
|
8
|
-
[${u}.tween.${h}.keyframes] The final keyframe value must match the persistent BGM ${h} value.`);P.keyframes.at(-1).value=k,(f[h]??It[h])!==k&&(w[h]={update:P})}return Object.keys(w).length===0?null:{...hc(e,g),properties:w}},Ec=e=>{let t=e.nextResources??e.resources,s=e.occurrence;if(!s?.selection)return[];let o=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=s.selection.resourceId,n=t?.audioEffects?.[r],i=(f,d)=>d?{...f,children:[d]}:null,l=f=>f.map(({previousSound:d,nextSound:g},b)=>Rh({...e,occurrence:b===0?s:{...s,occurrenceId:`${s.occurrenceId}:${b}`},resources:t,previousChannel:i(e.previousChannel,d),nextChannel:i(e.nextChannel,g)})).filter(Boolean);if(!n||!["transition","update"].includes(n.type))return l([{previousSound:o[0],nextSound:a[0]}]);let c=new Map(o.map(f=>[f.id,f])),u=new Map(a.map(f=>[f.id,f]));if(n.type==="update"){let f=a.map(b=>({previousSound:c.get(b.id),nextSound:b})),d=f.find(({previousSound:b})=>!b);if(d)return l([d]);let g=o.find(b=>!u.has(b.id));return l(g?[{previousSound:g}]:f)}let p=[];for(let f of o){let d=u.get(f.id);(!d||!bc(f,d))&&p.push({previousSound:f,nextSound:d})}for(let f of a)c.has(f.id)||p.push({nextSound:f});if(p.length>0)return l(p);let m=o.find(f=>{let d=u.get(f.id);return d&&!wc(f,d)});return l([{previousSound:m??o[0],nextSound:m?u.get(m.id):a[0]}])};var ae=e=>structuredClone(Pe(e)?Ar(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Qt=e=>e?.animations?.playback?.continuity==="persistent",X=(e,t)=>ie(e??{},t)&&e[t]!==void 0,is=e=>X(e,"alpha")||X(e,"opacity"),$h=e=>X(e,"alpha")?e.alpha:e?.opacity,jc=e=>(X(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Ch=e=>e?.applyMode==="persistent",_h="default",jh=e=>Array.isArray(e?.channels)?e.channels.filter(Ch).map(ae):[],Zt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},Nh=e=>is(e)||X(e,"blur")||X(e,"filters"),wo=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Nc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],bo=["animationName","animationSpeed","loop"],Dh=e=>X(e,"transformId")||X(e,"transform")||wo.some(t=>X(e,t)),Dc=e=>e?.text&&X(e.text,"content")&&X(e.text,"textStyleId"),Tc=e=>e?.layout&&Array.isArray(e.layout.elements),Th=e=>X(e,"text")||X(e,"layout"),xc=(e,t)=>e.resourceId?!0:Dc(e)?!t?.text:Tc(e)?!t?.layout:!1,Sc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Lh=(e,t)=>{let s={...ae(e),...t};if(t.text&&e.text&&(s.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(s.transform={...ae(e.transform),...ae(t.transform)}),X(t,"transform")){delete s.transformId;for(let o of wo)X(t,o)||delete s[o]}else X(t,"transformId")&&delete s.transform;return s},Mh=(e,t)=>{let s=[e.resourceId,e.text,e.layout].filter(o=>o!==void 0).length;if(s>1)throw s===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")&&!Dc(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(X(e,"layout")&&!Tc(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Oc=e=>Nc.some(t=>X(e,t)),Rc=e=>bo.some(t=>X(e,t)),qh=(e,t,{hasAuthoredTransformId:s=!1}={})=>{if(!t)return e;for(let o of Nc)!s&&!X(e,o)&&X(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Lc=(e,t,s)=>{let o=e[s];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},Vh=(e,t)=>{if(!t)return e;let s=X(e,"transform");for(let o of wo)!s&&!X(e,o)&&X(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Fh=(e,t)=>(t&&(!X(e,"opacity")&&X(t,"opacity")&&(e.opacity=t.opacity),!X(e,"blur")&&X(t,"blur")&&(e.blur=ae(t.blur)),!X(e,"filters")&&X(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Mc=(e,t,s=[],{hasPatchFn:o=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let r=e.map((n,i)=>{let l=Lc(s,n,i),c=t(n,l),u=Nh(n),p=Dh(n),m=o(n),f=ie(n,"animations"),d=jc(ae(n));if(!c&&(u||p||m)&&l&&(d=a?a(l,d):{...ae(l),...d}),!f){let g=l?t(l):!1,b=t(d);g&&b&&Qt(l)?d.animations=ae(l.animations):delete d.animations}return Fh(Vh(d,l),l)}).filter(n=>t(n)||n.animations);return{hasValidItems:r.length>0,processedItems:r}},Bh=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},qc=e=>!!e?.character&&ie(e.character,"sprite"),Uh=e=>{let t={},s=!1,o=Bh(e);return o!==void 0&&(t.name=o,s=!0),qc(e)&&(t.sprite=ae(e.character.sprite),s=!0),s?t:void 0},$c=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Cc=({dialogueState:e,dialogueAction:t,persistCharacter:s})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:s&&!ie(t,"characterId"),_c=({previousCharacter:e,characterFields:t,hasCharacterId:s,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:n})=>{let i={},l=e??{},c=t??{},u=n&&!s,p=u&&!r;return ie(c,"name")?i.name=c.name:(o&&!s||u)&&ie(l,"name")&&(i.name=ae(l.name)),ie(c,"sprite")?i.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(i.sprite=ae(l.sprite)),Object.keys(i).length>0?i:void 0},Yh=({dialogueState:e,content:t,append:s=!1})=>{if(!s||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...o,...t]},zh=()=>({}),Xh=(e,t)=>{if(!t.screen)return;let s=is(t.screen),o=X(t.screen,"blur"),a=ie(t.screen,"animations");if(!s&&!o){a||delete e.screen;return}let r=e.screen,n={};if(s?n.opacity=$h(t.screen):X(r,"opacity")&&(n.opacity=r.opacity),o?n.blur=ae(t.screen.blur):X(r,"blur")&&(n.blur=ae(r.blur)),ie(n,"opacity")&&n.opacity===void 0&&delete n.opacity,ie(n,"blur")&&n.blur===void 0&&delete n.blur,Object.keys(n).length===0){delete e.screen;return}e.screen=n},Gh=(e,t)=>{if(t.background){let s=X(t.background,"resourceId"),o=X(t.background,"colorId"),a=is(t.background),r=X(t.background,"blur"),n=X(t.background,"filters"),i=X(t.background,"transformId"),l=Oc(t.background),c=Rc(t.background),{animationsOnly:u,state:p}=Zt(t.background,d=>X(d,"resourceId")||X(d,"colorId")||is(d)||X(d,"blur")||X(d,"filters")||X(d,"transformId")||Oc(d)||Rc(d));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!s&&!o&&!a&&!r&&!n&&!i&&!l&&!c){delete e.background;return}let m=e.background,f=jc(ae(t.background));if(!s&&m?.resourceId){f.resourceId=m.resourceId,!ie(f,"transformId")&&m.transformId&&(f.transformId=m.transformId);for(let d of bo)!X(f,d)&&X(m,d)&&(f[d]=m[d])}qh(f,m,{hasAuthoredTransformId:i}),!o&&m?.colorId&&(f.colorId=m.colorId),!a&&X(m,"opacity")&&(f.opacity=m.opacity),!r&&X(m,"blur")&&(f.blur=ae(m.blur)),!n&&X(m,"filters")&&(f.filters=ae(m.filters)),ie(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,ie(f,"colorId")&&f.colorId===void 0&&delete f.colorId,ie(f,"animations")&&f.animations===void 0&&delete f.animations,ie(f,"transformId")&&f.transformId===void 0&&delete f.transformId,ie(f,"opacity")&&f.opacity===void 0&&delete f.opacity,ie(f,"blur")&&f.blur===void 0&&delete f.blur,ie(f,"filters")&&f.filters===void 0&&delete f.filters;for(let d of bo)ie(f,d)&&f[d]===void 0&&delete f[d];if(!f.resourceId&&!f.colorId){delete e.background;return}m?.resourceId===f.resourceId&&m?.transformId===f.transformId&&!ie(f,"animations")&&Qt(m)&&(f.animations=ae(m.animations)),e.background=f}else e.background?.animations&&!Qt(e.background)&&(e.background.animations={})},Hh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&($c(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=Cc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=_c({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 s=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=Zt(t.dialogue.ui,m=>!!m.resourceId);u?e.dialogue.ui={...e.dialogue.ui,...p}:e.dialogue.ui={...t.dialogue.ui}}else e.dialogue?.ui?.animations&&(e.dialogue.ui.animations={});t.dialogue.mode==="adv"&&(e.dialogue.content=e.dialogue.content||void 0,e.dialogue.characterId=e.dialogue.characterId||void 0,e.dialogue.mode="adv"),t.dialogue.mode==="nvl"&&(e.dialogue?.mode!=="nvl"&&(e.dialogue.lines=[]),e.dialogue.mode="nvl");let o=t.dialogue.append===!0&&s!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&Yh({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Cc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let n=ie(t.dialogue,"characterId"),i=Uh(t.dialogue),l=qc(t.dialogue);n?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=_c({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:n,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||$c(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},Kh=(e,t)=>{let s=jh(e.sfx);if(!t.sfx){if(s.length>0){e.sfx={channels:s};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=s.filter(n=>n.id!==_h);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(s.length>0){e.sfx={channels:s};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=s.filter(r=>!o.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Wh=(e,t,s)=>{if(t.bgm){let o=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!o||o&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Pc({bgm:ae(t.bgm),resources:s}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},Jh=(e,t)=>{if(t.visual){let s=e.visual?.items||[];t.visual.items?.forEach((r,n)=>{Mh(r,Lc(s,r,n))});let{hasValidItems:o,processedItems:a}=Mc(t.visual.items,xc,s,{hasPatchFn:Th,mergeItemFn:Lh});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(s=>s.animations&&(!xc(s)||!Qt(s))?{...s,animations:{}}:s))},Qh=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!Sc(a)||!Qt(a))?{...a,animations:{}}:a));return}let{hasValidItems:s,processedItems:o}=Mc(t.character.items,Sc,e.character?.items||[]);s?e.character={items:o}:delete e.character},Zh=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},eg=(e,t)=>{if(t.layout){let{animationsOnly:s,state:o}=Zt(t.layout,a=>!!a.resourceId);if(s){e.layout=o;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},rg=(e,t)=>{if(t.choice){let{animationsOnly:s,state:o}=Zt(t.choice,a=>!!a.resourceId);if(s){e.choice={...e.choice,...o};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},tg=(e,t)=>{if(t.form){let{animationsOnly:s,state:o}=Zt(t.form,a=>!!a.resourceId);if(s){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},ng=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},sg=(e,t)=>{if(t.voice){let s=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!s||s&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},ig=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(s=>{delete e[s]})},Qr=(e,{resources:t}={})=>Hn(zh,[ig,Xh,Gh,Kh,(a,r)=>Wh(a,r,t),Jh,Hh,Qh,Zh,eg,rg,tg,ng,sg])(e);var vt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let s=Hr(e,t);return s&&typeof s=="object"?e:s};var og=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"}}),$r=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}),en=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),ag=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Io=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),Vc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),vo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Fc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),lg=(e,t)=>{let s=ag[e];if(s==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(s==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(s==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(s==="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}"`)},os=(e,t)=>{if(lg(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},ko=(e={})=>{let t=e?.config;if(t===void 0)return{...$r};if(!Fc(t))throw new Error("projectData.config must be an object");let s=Object.keys(t).find(i=>i!=="runtimeDefaults");if(s)throw new Error(`projectData.config contains unsupported field "${s}"`);let o=t.runtimeDefaults;if(o===void 0)return{...$r};if(!Fc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(Vc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let n={...$r};return Vc.forEach(i=>{o[i]!==void 0&&(n[i]=os(i,o[i]))}),n},cg=(e,t)=>{if(t.startsWith("global.")){let s=t.slice(7);return e?.global?.[s]}if(t.startsWith("context.runtime.")){let s=t.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[s]}},Cr=e=>Object.fromEntries(Object.entries(og).map(([t,s])=>{let o=cg(e,s.source),a=o!==void 0?o:$r[t]??en[t];return[t,a]})),tr=(e,t)=>Cr(e)[t],Bc=(e={})=>Object.fromEntries(Io.map(t=>[t,e[t]??$r[t]]));var kt=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}),dr=Object.freeze({BEHIND_BACKGROUND:kt.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:kt.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:kt.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:kt.VISUAL_BEHIND_CHOICE,FOREGROUND:kt.VISUAL_FOREGROUND}),Ao=dr.BEHIND_DIALOGUE,Po=Object.freeze(Object.values(dr).sort((e,t)=>e-t));var ug={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,s])=>({id:t,...s})),formatDate:uo},pg=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,rn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return rn(t);let[s]=Object.keys(t),o=pg.exec(s);if(!o)return rn(t);let[,a,r,n]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${n.trim()})`,l=Array.isArray(t[s])?t[s]:[];return{[i]:rn(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,s])=>[t,rn(s)])),mr=(e,t)=>{let s={functions:ug};return Hr(rn(e),t,s)},nu=({animationType:e,animationId:t,animationPath:s})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${s}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},fg=({id:e,targetId:t,animation:s,playback:o,animationPath:a="animation"})=>{let r=structuredClone(s);if(nu({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let n=hg(o,`${a}.playback`);if(n!==void 0){let i=n.loop===!0?lu(r):null;if(n.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(n.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(n.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=n}}return r},dg=(e,{animationId:t="animation",animationPath:s="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return nu({animationType:e.type,animationId:t,animationPath:s}),e.type},mg=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},yg=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},hg=(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 s={};return e.continuity!==void 0&&(s.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(s.speed=e.speed),e.loop===!0&&(s.loop=!0),Object.keys(s).length>0?s:void 0},gg=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},Qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),su=(e={})=>Qe(e,"alpha")&&typeof e.alpha=="number"?e.alpha:Qe(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,iu=e=>e?.playback?.continuity==="persistent",_o=e=>Array.isArray(e)?e.map(_o):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,s)=>(t[s]=_o(e[s]),t),{}),us=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(_o(t))},ou=(e=[])=>e.filter(t=>iu(t)).map(t=>structuredClone(t)),au=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,s)=>{let o=typeof s?.duration=="number"&&Number.isFinite(s.duration)?s.duration:0;return t+o},0):0,Eo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,s)=>Math.max(t,au(s)),0),lu=e=>Math.max(Eo(e?.tween),Eo(e?.prev?.tween),Eo(e?.next?.tween),au(e?.mask?.progress)),cu=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:lu(e)/gg(e),bg=e=>e.some(t=>t?.playback?.loop===!0),Uc=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let s=new Set(t.map(us).filter(Boolean));return e.some(o=>{if(!iu(o))return!1;let a=us(o);return a?s.has(a):!1})},Ze=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||s?!1:bg(e)||r&&!t||Uc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:Uc({animationInstances:e,activePersistentAnimations:a}),uu=(e,t,s,o,a)=>{if(e===void 0)return!0;let r=a.slice(0,o).filter(i=>i?.id===s).length,n=e?.[t]?.items?.filter(i=>i?.id===s).at(r);return Qe(n??{},"animations")},wg=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Ig=(e,t)=>{if(wg(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},vg=({resources:e,animationId:t,playback:s,instanceId:o,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let n=e?.animations?.[t];return n?fg({id:o,targetId:a,animation:n,playback:s,animationPath:r}):null},jo=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(s=>s===null||typeof s!="object"||Array.isArray(s)))throw new Error(`${t} must be an array of objects`);return e},kg=({content:e,path:t,variables:s})=>jo(e,t).reduce((o,a)=>{let r=vt(a.text,{variables:s});return o+`${r??""}`.length},0),Yc=(e=[])=>{let t=new Map;for(let s of e)s?.id&&t.set(s.id,(t.get(s.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,s])=>s>1).map(([s])=>s))},zc=(e,t=0,s=new Set)=>{if(!s.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("-")}`},Pt=(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 s=e.transforms?.[t.transformId];if(!s)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return s},Ag=(e,t={})=>{if(!t?.transformId)return;let s=e.transforms?.[t.transformId];if(!s)throw new Error(`Transform "${t.transformId}" not found for background`);return s},Pg=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Eg=(e={})=>Pg.some(t=>Qe(e,t)),pu=(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"}},ls=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},xg=(e={})=>e.textStyles||{},Sg=(e={})=>e.images||{},Og=.5,Rg=(e={},t,s)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${s}'`);return t}return Object.keys(e.animations??{})[0]},Fo=({id:e,resourceId:t,spritesheet:s,animationName:o,animationSpeed:a,loop:r,width:n,height:i,transform:l={}}={})=>{let c=Rg(s,o,t),u=c?s.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:n??s.width,height:i??s.height,src:s.fileId,atlas:s.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Og,loop:r??u.loop??!0}}},fu=({id:e,item:t,resources:s={}}={})=>{let o=s.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=s.spritesheets?.[t.resourceId];if(a)return Fo({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}`)},$g=(e={})=>e.colors||{},Cg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,tn=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,Et=(e,t,s)=>{if(typeof e!="string"||e.length===0)throw new Error(`${s} at "${t}" must resolve to a non-empty string`)},xo=(e,t,s)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${s}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${s}" must be a number between 0 and 1`);return e},So=(e,t,s,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 "${s}" must be ${r}`)}return e},ds=(e,t)=>{if(typeof e!="string"||!Cg.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(s=>s.repeat(2)).join("")}`:e},Xc=(e,t,s)=>{let o=ds(e,s);if(t===1)return o;let a=Number.parseInt(o.slice(1,3),16),r=Number.parseInt(o.slice(3,5),16),n=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${r}, ${n}, ${t})`},_g=(e={},t)=>{let s=xg(e)?.[t];if(!s)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(s.fontId)?s.fontId:[s.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?.[s.colorId];if(!r)throw new Error(`Color "${s.colorId}" not found for text style "${t}"`);let n=xo(s.colorAlpha,"colorAlpha",t),i={fontFamily:Array.isArray(s.fontId)?a.join(", "):a[0],fontSize:s.fontSize??16,fontWeight:s.fontWeight??"400",fontStyle:s.fontStyle??"normal",lineHeight:s.lineHeight??1.2,fill:Xc(r.hex,n,`Color "${s.colorId}" for text style "${t}"`)};if(s.align!==void 0&&(i.align=s.align),s.wordWrap!==void 0&&(i.wordWrap=s.wordWrap),s.breakWords!==void 0&&(i.breakWords=s.breakWords),s.wordWrapWidth!==void 0&&(i.wordWrapWidth=s.wordWrapWidth),s.strokeColorId){let l=e.colors?.[s.strokeColorId];if(!l)throw new Error(`Stroke color "${s.strokeColorId}" not found for text style "${t}"`);let c=xo(s.strokeAlpha,"strokeAlpha",t);i.strokeColor=Xc(l.hex,c,`Stroke color "${s.strokeColorId}" for text style "${t}"`)}else if(s.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(s.strokeWidth!==void 0&&(i.strokeWidth=s.strokeWidth),s.shadow!==void 0){let l=e.colors?.[s.shadow.colorId];if(!l)throw new Error(`Shadow color "${s.shadow.colorId}" not found for text style "${t}"`);i.shadow={color:ds(l.hex,`Shadow color "${s.shadow.colorId}" for text style "${t}"`),alpha:xo(s.shadow.alpha,"shadow.alpha",t),blur:So(s.shadow.blur,"blur",t,0,{minimum:0}),offsetX:So(s.shadow.offsetX,"offsetX",t,2),offsetY:So(s.shadow.offsetY,"offsetY",t,2)}}return i},xt=e=>Array.isArray(e)?e.map(xt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,s])=>[t,xt(s)])),No=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>No(a,t,`${s}[${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 "${s}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=xt(r);continue}a!=="textStyleId"&&(o[a]=No(r,t,tn(s,a)))}return e.textStyleId!==void 0&&(Et(e.textStyleId,s,"textStyleId"),o.textStyle=_g(t,e.textStyleId)),o},Bo=(e={},t)=>{let s=$g(e)?.[t];if(!s)throw new Error(`Color "${t}" not found`);return ds(s.hex,`Color "${t}"`)},du=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",Oo=(e,t,s)=>{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 "${s}". Use ${du(`${t}.fill`)} instead`)},jg=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>nn(a,t,`${s}[${r}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(o[a]=nn(r,t,tn(s,a)));return e.colorId!==void 0&&(Et(e.colorId,s,"colorId"),o.fill=Bo(t,e.colorId)),o},nn=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>nn(a,t,`${s}[${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 "${s}". Use ${du("fill")} instead`);Oo(e,"hover",s),Oo(e,"click",s),Oo(e,"rightClick",s)}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=xt(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=jg(r,t,tn(s,a));continue}o[a]=nn(r,t,tn(s,a))}}return e.type==="rect"&&e.colorId!==void 0&&(Et(e.colorId,s,"colorId"),o.fill=Bo(t,e.colorId)),o},Ro=(e={},t)=>{let s=Sg(e)?.[t];return s||null},mu=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Gc=(e,t,s,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 "${s}". Use ${mu(`${t}.${o}`)} instead`)},Hc=(e,t,s)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:s}},Do=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>Do(a,t,`${s}[${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 "${s}". Use ${mu(a)} instead`);Gc(e,"hover",s,"src"),Gc(e,"click",s,"src")}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=xt(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=Do(r,t,tn(s,a)))}if(e.type==="sprite"&&e.imageId!==void 0){Et(e.imageId,s,"imageId");let a=Ro(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&&(Et(e.hoverImageId,s,"hoverImageId"),Hc(o,"hover",Ro(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Et(e.clickImageId,s,"clickImageId"),Hc(o,"click",Ro(t,e.clickImageId)?.fileId??e.clickImageId)),o},Ng=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),cs=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>cs(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let s=xt(e),o=typeof e.type=="string";(o||t)&&Qe(e,"opacity")&&(Qe(e,"alpha")||(s.alpha=e.opacity),delete s.opacity);for(let a of["elements","children"])Qe(e,a)&&(s[a]=cs(e[a]));for(let[a,r]of Object.entries(e))Ng(a)&&(s[a]=cs(r,{isElementPatch:o||t}));return s},Uo=(e,t={},s="root")=>cs(Do(nn(No(e,t,s),t,s),t,s)),yr=Uo,et=(e=[])=>e.find(t=>t.id==="story"),Dg="#000000",To="bg-cg-background-color",Tg=({resources:e={},background:t={},screen:s})=>t?.colorId===void 0?ds(s?.backgroundColor??Dg,"screen.backgroundColor"):Bo(e,t.colorId),yu=(e={})=>su(e),Lg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Yo=(e={})=>Array.isArray(e.filters)?e.filters:void 0,Kc=(e={},{includeDefaultAlpha:t=!1}={})=>{let s=yu(e),o=Lg(e),a=Yo(e),r={};return(t||s!==void 0)&&(r.alpha=s??1),o&&(r.blur=o),a&&(r.filters=a),r},Mg=(e={})=>su(e),qg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},hu=(e={})=>{let t=Mg(e),s=qg(e),o={};return t!==void 0&&(o.alpha=t),s&&(o.blur=s),o},Zr=(e={})=>{let t=hu(e),s=Yo(e);return s&&(t.filters=s),t},Wc=(e,t,s,o)=>{let a=t[s]??e[s];return t[o]??e[o]??!1?(a??1)*-1:a},nr=(e={},t={})=>{let s={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:Wc(e,t,"scaleX","flipX"),scaleY:Wc(e,t,"scaleY","flipY")},o=t.originX??e.originX,a=t.originY??e.originY;return o!==void 0&&(s.originX=o),a!==void 0&&(s.originY=a),s},Vg=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],zo=(e={})=>e.text&&Qe(e.text,"content")&&Qe(e.text,"textStyleId"),Xo=(e={})=>e.layout&&Array.isArray(e.layout.elements),Jc=(e={})=>{if(e.resourceId)return e.resourceId;if(zo(e))return"text";if(Xo(e))return"inline-layout"},Qc=(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(s=>{if(typeof s=="string")return t.images?.[s]?.fileId??s;if(!s||typeof s!="object"||Array.isArray(s))return s;if(s.imageId){let{imageId:o,...a}=s;return{...a,src:t.images?.[o]?.fileId??o}}return typeof s.src=="string"?{...s,src:t.images?.[s.src]?.fileId??s.src}:s})}:e,Fg=({item:e,particle:t,resources:s})=>{let o=Pt(s,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=Qc(r,s)),a.texture!==void 0&&(a.texture=Qc(a.texture,s));let n={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...nr(o,e)};return Object.assign(n,Zr(e)),n},Bg=e=>{let t=[e.resourceId,e.text,e.layout].filter(s=>s!==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&&!zo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Xo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let s of Vg)if(Qe(e.text,s))throw new Error(`Visual item "${e.id}" text.${s} is reserved for the visual item`)}},Ug=({resources:e,background:t,screen:s={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:To,type:"rect",x:0,y:0,width:s?.width??1920,height:s?.height??1080,fill:Tg({resources:e,background:t,screen:s})};if(o){let r=yu(t);r!==void 0&&(a.alpha=r);let n=Yo(t);n&&(a.filters=n)}return a},Yg=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Zc=({resources:e={},resourceId:t,colorId:s})=>{let o=pu(e,t);return t&&(o||s===void 0)?{resourceId:t,targetId:ls({resourceId:t,kind:o})}:s!==void 0?{resourceId:To,targetId:To}:{resourceId:void 0,targetId:void 0}},gu=100,_r=gu,zg="channel:bgm",Xg="channel:music-room",Gg="music-room:player",Hg="channel:voice",Kg="default",ps=(e,t,s)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let r=s?` in ${s}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}o.add(a)})},bu=(e,t)=>e*t/gu,Go=(e={},t)=>e?.[t]??$r[t],Ho=(e={},t,s=_r)=>bu(s,Go(e,t)),ms=({id:e,volume:t,muted:s,pan:o,loop:a,playback:r,interruption:n,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(s??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),n!==void 0&&(c.interruption=n),c},as=(e,t,s,o)=>e[s]!==void 0?e[s]:t[s]!==void 0?t[s]:o,Wg=["muted","pan","playbackRate","startAt","endAt"],ys=({id:e,sound:t,resource:s,projectResources:o,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:n=!1})=>{let i={id:e,type:"sound",src:s.fileId,loop:as(t,s,"loop",r),volume:as(t,s,"volume",_r),startDelayMs:as(t,s,"startDelayMs",0)};Wg.forEach(c=>{let u=as(t,s,c,void 0);u!==void 0&&(i[c]=u)}),t.playback!==void 0&&(i.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=Ac({selection:t[c],selectionPath:`${a}.${c}`,resources:o});u&&!n&&(i[c]=u)}let l=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<l)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${l}).`);return i},Jg=e=>Math.max(-1,Math.min(1,e)),Qg=({node:e,bgm:t,sound:s,resource:o,usesLegacySound:a})=>{a||(e.volume=bu(t.volume??_r,e.volume??_r));let r=t.muted!==void 0,n=s.muted!==void 0||o.muted!==void 0;(r||n)&&(e.muted=t.muted===!0||e.muted===!0);let i=t.pan!==void 0,l=s.pan!==void 0||o.pan!==void 0;return(i||l)&&(e.pan=Jg((t.pan??0)+(e.pan??0))),e},Ge=({variables:e,imageGallery:t,musicRoom:s,sceneReplay:o,runtime:a,saveSlots:r=[],dialogueState:n,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,confirmDialog:d,form:g,historyDialogue:b=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:h,skipTransitionsAndAnimations:P}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},E=nb({dialogueState:n,includeInactiveAdvDialogue:i,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:s,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:m,canRollback:f,confirmDialog:d,form:g,historyDialogue:b,characters:y};return E&&(v.dialogue=E,v.dialogueLines=E.lines),v},eu=100,fs=(e,t)=>{if(Array.isArray(e))return e.map(o=>fs(o,t));if(!e||typeof e!="object")return e;let s={...e};return Object.keys(s).forEach(o=>{s[o]=fs(s[o],t)}),s.type==="text-revealing"?t(s):s},Zg=e=>fs(e,t=>({...t,revealEffect:"none"})),eb=e=>fs(e,t=>{let s=Number(t.speed??t.displaySpeed),o=Number.isFinite(s)?Math.max(s,eu):eu;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),jr=(e,{isLineCompleted:t=!1,skipMode:s=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?Zg(e):s?eb(e):e,wu=({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:{}}}}),Lo=e=>{if(Array.isArray(e))return e.map(Lo);if(!e||typeof e!="object")return e;let t={};for(let[r,n]of Object.entries(e))t[r]=Lo(n);let s=t.click?.payload;if(!s||typeof s!="object"||Array.isArray(s))return t;let o=s.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:{...s,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},rb=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),ru="submit",$o=(e,t,s={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},r=s.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...o,actions:r}}},Mo=(e,t,s={})=>{if(Array.isArray(e))return e.map(c=>Mo(c,t,s));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===ru,r=o&&s.submitRoleAncestor,n=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Mo(u,t,c==="children"?n:{});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:$o(l.change,u),submit:$o(l.submit,t.submitActions)}}}return l.formRole===ru||r?{...l,click:$o(l.click,t.submitActions,{replaceActions:!0})}:l},qo=(e,t)=>{if(Array.isArray(e))return e.map(o=>qo(o,t));if(!e||typeof e!="object")return e;let s={};for(let[o,a]of Object.entries(e))s[o]=qo(a,t);for(let o of rb){let a=s[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(s[o]={...s[o],payload:{...a,_interactionSource:"form"}})}return s},Vo=({characterId:e,character:t,characterName:s,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,n=Kn({characterId:e,character:t,characterName:s,characters:o,variables:a});return{...r||{},...t||{},name:n}},Iu=(e=[],t={},s={})=>e.map(o=>{let a=Vo({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:t,variables:s}),r=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(n=>n?.text??"").join(""):"";return{...o,text:r,character:a,characterName:a.name}}),tb=e=>!(!e||e.mode==="adv"&&e.content===void 0),nb=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:s={},variables:o,runtime:a}={})=>{if(!t&&!tb(e))return;let r=e.content===void 0?[{text:""}]:jo(e.content,"dialogue.content"),n=e.content===void 0?0:kg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??$r.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,m)=>{let f=jo(p.content,`dialogue.lines[${m}].content`),d=Vo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:s,variables:o});return{...p,textSpeed:p.textSpeed??i,content:f.map(g=>({...g,text:vt(g.text,{variables:o})})),character:d,characterName:d.name}}),u=Vo({characterId:e.characterId,character:e.character,characters:s,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:vt(p.text,{variables:o})})),initialRevealedCharacters:n,lines:c}},Ko=({container:e,resources:t,templateData:s,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let n=mr(e,s);return yr(jr(n,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},Co=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),tu=({renderStateKeyboard:e,keyboard:t,phase:s})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([o,a])=>{let r=e[o]??{},n=s==="keydown"?a?.keydown:a?.keyup;if(s==="keydown"&&n&&typeof n=="object"){e[o]={...r,keydown:{payload:Co(n)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:Co(a.keyup)});return}e[o]={...r,[s]:{payload:Co(a)}}})},sb=(e={},t={})=>{let s={};return tu({renderStateKeyboard:s,keyboard:e,phase:"keydown"}),tu({renderStateKeyboard:s,keyboard:t,phase:"keyup"}),Object.keys(s).length>0?s:void 0},hr=({animationsDef:e,resources:t,previousResourceId:s,currentResourceId:o,previousTargetId:a,currentTargetId:r,animationPath:n,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:w})=>{let h=vg({resources:t,animationId:f,playback:d,instanceId:y,targetId:w,animationPath:n});h&&l.push(h)},u=s!=null&&s!==!1,p=o!=null&&o!==!1,m=a&&r&&a===r;Ig(e,n);let f=mg(e),d=yg(e),g=t?.animations?.[f],b=dg(g,{animationId:f,animationPath:n});if(b==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(b==="transition"){let y=`${i}-animation-transition`,w=d?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&m)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},ib=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),ob=(e,{presentationState:t,previousPresentationState:s,currentLineActions:o,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:n,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,activePersistentAnimations:f,restoredPersistentAnimations:d,autoMode:g,skipMode:b,isChoiceVisible:y,isFormVisible:w,canRollback:h,form:P,saveSlots:k=[]})=>{let{elements:E,animations:v}=e;if(t.background){let O=o===void 0?!0:Qe(o?.background??{},"animations"),T=E.find(oe=>oe.id==="story");if(!T)return e;let $=Ag(a,t.background),D=$||Eg(t.background),B=s?.background?.resourceId,_=s?.background?.colorId,G=t.background.resourceId??(t.background.animations?B:void 0),fe=t.background.colorId??(t.background.animations?_:void 0),M=Yg(a,G),K={...t.background,colorId:fe};if((fe!==void 0||M)&&T.children.push(Ug({resources:a,background:K,screen:r,includeAlpha:!M})),G){let{images:oe={},videos:ne={},spritesheets:ue={}}=a,Z=pu(a,G),C;if(Z==="sprite"?C=oe[G]:Z==="video"?C=ne[G]:Z==="spritesheet-animation"&&(C=ue[G]),C){let j=Z==="video",F=Z==="spritesheet-animation",J={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...$},de={...Kc(t.background,{includeDefaultAlpha:!0}),...nr(J,t.background)},Ie;F?Ie=Fo({id:ls({resourceId:G,kind:Z}),resourceId:G,spritesheet:C,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:de}):Ie={id:ls({resourceId:G,kind:Z}),type:j?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...de},j&&(Ie.loop=t.background.loop??!1,Ie.volume=C.volume??50),Ie&&T.children.push(Ie)}}if(G){let{layouts:oe={}}=a,ne=oe[G];if(ne){let ue={id:ls({resourceId:G,kind:"container"}),type:"container",children:ne.elements,...Kc(t.background)};D&&Object.assign(ue,nr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...$},t.background));let Z=mr(ue,Ge({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:m,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:n,autoMode:g,skipMode:b,isChoiceVisible:y,isFormVisible:w,canRollback:h,form:P,characters:a.characters||{},skipTransitionsAndAnimations:i}));T.children.push(yr(jr(Z,{isLineCompleted:n,skipMode:b,skipTransitionsAndAnimations:i}),a))}}let le=Zc({resources:a,resourceId:B,colorId:_}),z=Zc({resources:a,resourceId:G,colorId:fe}),te=hr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:z.resourceId,previousTargetId:le.targetId,currentTargetId:z.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ze({animationInstances:te,isLineCompleted:n,skipTransitionsAndAnimations:i,activePersistentAnimations:f,restoredPersistentAnimations:d,isAuthoredOnCurrentLine:O})&&v.push(...te)}return e},ab=(e,{presentationState:t,previousPresentationState:s,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(w=>w.id==="story");if(!p)return e;let m=t.character.items||[],f=s?.character?.items||[],d=Yc(m),g=Yc(f),b=new Map,y=new Map;for(let w=0;w<f.length;w++){let h=f[w],P=b.get(h.id)??[];P.push(w),b.set(h.id,P)}for(let w=0;w<m.length;w++){let h=m[w],{transformId:P,sprites:k}=h,E=y.get(h.id)??0;y.set(h.id,E+1);let v=b.get(h.id)?.[E]??-1,O=f[v],T=O?.sprites&&O.sprites.length>0,$=k&&k.length>0,D=v>=0?zc(O,v,g):void 0,B=$?zc(h,w,d):void 0,_=uu(o,"character",h.id,w,m),G=hr({animationsDef:h.animations,resources:a,previousResourceId:D,currentResourceId:B,previousTargetId:D,currentTargetId:B,animationPath:`character.items[${w}].animations`,idPrefix:B??D??`character-${w}`});if(h.animations&&!k&&!P&&T&&Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})){u.push(...G);continue}if(h.animations&&!k&&!P)continue;if(!k||k.length===0||!P){console.warn("Character item missing sprites or transformId:",h);continue}let fe=a.transforms[P];if(!fe){console.warn("Transform not found:",P);continue}let M={type:"container",id:B,...nr(fe,h),...Zr(h),children:[]};for(let K of k){let le=fu({id:`${B}-${K.id}`,item:K,resources:a});le&&M.children.push(le)}p.children.push(M),Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})&&u.push(...G)}}return e},vu=(e,t)=>{if(!Po.includes(e))throw new Error(`${t} must be one of: ${Po.join(", ")}.`)},lb=(e,t)=>{let s=!!e.resourceId||zo(e)||Xo(e),o=e.layer??(s?void 0:t?.layer)??Ao;return vu(o,`Visual item "${e.id}" layer`),o},cb=(e,{presentationState:t,previousPresentationState:s,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:m,restoredPersistentAnimations:f,autoMode:d,skipMode:g,isChoiceVisible:b,isFormVisible:y,canRollback:w,form:h,saveSlots:P=[],visualLayer:k})=>{let{elements:E,animations:v}=e;if(t.visual&&a){let O=E.find(B=>B.id==="story");if(!O)return e;let T=t.visual.items,$=s?.visual?.items||[],D=Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:P,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:g,isChoiceVisible:b,isFormVisible:y,canRollback:w,form:h,characters:a.characters||{},skipTransitionsAndAnimations:n});k!==void 0&&vu(k,"visualLayer");for(let[B,_]of T.entries()){let G=$.find(ne=>ne.id===_.id),fe=uu(o,"visual",_.id,B,T),M=lb(_,G);if(k!==void 0&&M!==k)continue;if(Bg(_),_.layout){let ne=Pt(a,_),ue={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...nr(ne,_)};Object.assign(ue,Zr(_)),O.children.push(Ko({container:ue,resources:a,templateData:D,isLineCompleted:r,skipMode:g,skipTransitionsAndAnimations:n}))}if(_.text){let ne=Pt(a,_),ue={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...nr(ne,_)};Object.assign(ue,Zr(_)),O.children.push(yr(mr(ue,D),a))}if(_.resourceId){let{images:ne={},videos:ue={},spritesheets:Z={}}=a,C=Z[_.resourceId];if(C){let j=Pt(a,_),F=Zr(_),J=Fo({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:C,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...nr(j,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});J&&O.children.push(structuredClone(J))}else{let j=ne[_.resourceId]||ue[_.resourceId];if(j){let F=ue[_.resourceId]!==void 0,J=Pt(a,_),de={id:`visual-${_.id}`,type:F?"video":"sprite",src:j.fileId,width:j.width,height:j.height,...nr(J,_)};Object.assign(de,Zr(_)),F&&(de.loop=j.loop??!1,de.volume=j.volume??50),O.children.push(de)}}}let K=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!K){let ne=a.particles?.[_.resourceId];ne&&O.children.push(Fg({item:_,particle:ne,resources:a}))}let le=!!a.particles?.[_.resourceId];if(_.resourceId&&!K&&!le){let{layouts:ne={}}=a,ue=ne[_.resourceId];if(ue){let Z=Pt(a,_),C={id:`visual-${_.id}`,type:"container",children:structuredClone(ue.elements),...nr(Z,_)};Object.assign(C,Zr(_));let j=mr(C,D);O.children.push(yr(jr(j,{isLineCompleted:r,skipMode:g,skipTransitionsAndAnimations:n}),a))}}let z=Jc(G),te=Jc(_),oe=hr({animationsDef:_.animations,resources:a,previousResourceId:z,currentResourceId:te,previousTargetId:z?`visual-${_.id}`:void 0,currentTargetId:te?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ze({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:m,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:fe})&&v.push(...oe)}}return e},At="dialogue-character-sprite",ub=(e,{presentationState:t,previousPresentationState:s,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})=>{let{animations:i}=e,l=et(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=s?.dialogue?.character?.sprite,p=Bt(c),m=Bt(u),f=hr({animationsDef:c?.animations,resources:o,previousResourceId:m?At:void 0,currentResourceId:p?At:void 0,previousTargetId:m?At:void 0,currentTargetId:p?At:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&m&&Ze({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&i.push(...f),e;let d=o.transforms?.[c.transformId];if(!d)return console.warn("Transform not found:",c.transformId),e;let g={type:"container",id:At,...nr(d),children:[]};for(let b of c.items){let y=fu({id:`${At}-${b.id}`,item:b,resources:o});y&&g.children.push(y)}return l.children.push(g),Ze({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&i.push(...f),e},pb=(e,{presentationState:t,previousPresentationState:s,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:n,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:m,skipTransitionsAndAnimations:f,variables:d,imageGallery:g,musicRoom:b,sceneReplay:y,runtime:w,activePersistentAnimations:h,saveSlots:P=[]})=>{let{elements:k,animations:E}=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,$=T[t.dialogue.ui.resourceId];if($){let D={elements:$.elements},B=Ge({variables:d,imageGallery:g,musicRoom:b,sceneReplay:y,runtime:w,saveSlots:P,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:m,autoMode:r,skipMode:n,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:f}),_=mr(D,B),G=yr(jr(_?.elements,{isLineCompleted:m,skipMode:n,skipTransitionsAndAnimations:f}),o);if(Array.isArray(G))for(let fe of G)v.children.push(fe);else G&&v.children.push(G)}}ub(e,{presentationState:t,previousPresentationState:s,resources:o,isLineCompleted:m,skipTransitionsAndAnimations:f,activePersistentAnimations:h});let O=hr({animationsDef:t.dialogue.ui?.animations,resources:o,previousResourceId:s?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:s?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return Ze({animationInstances:O,isLineCompleted:m,skipTransitionsAndAnimations:f,activePersistentAnimations:h})&&E.push(...O),e},fb=(e,{presentationState:t,previousPresentationState:s,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:f,isChoiceVisible:d,isFormVisible:g,canRollback:b,form:y,activePersistentAnimations:w,saveSlots:h=[]})=>{let{elements:P,animations:k}=e;if(t.choice&&o){let E=et(P);if(!E)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let T={elements:v.elements},$=mr(T,{...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:f,isChoiceVisible:d??!!t.choice,isFormVisible:g,canRollback:b,form:y,characters:o.characters||{},skipTransitionsAndAnimations:n}),choice:{items:t.choice?.items??[]}}),D=Lo(yr(jr($?.elements,{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:n}),o));if(Array.isArray(D))for(let B of D)E.children.push(B);else D&&E.children.push(D)}let O=hr({animationsDef:t.choice.animations,resources:o,previousResourceId:s?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:s?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});Ze({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:w})&&k.push(...O)}return e},db=(e,{presentationState:t,previousPresentationState:s,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:m,skipMode:f,isChoiceVisible:d,isFormVisible:g,canRollback:b,activePersistentAnimations:y,saveSlots:w=[],form:h})=>{let{elements:P,animations:k}=e;if(!h?.resourceId||!o)return e;let E=et(P);if(!E)return e;let v=o?.layouts?.[h.resourceId];if(!v)return console.warn(`Form layout not found: ${h.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},T={...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:f,isChoiceVisible:d,isFormVisible:g,canRollback:b,characters:o.characters||{},skipTransitionsAndAnimations:n,form:h}),form:h},$=mr(O,T),D=qo(yr(jr(Mo($,h),{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:n}),o),h);D&&E.children.push(D);let B=hr({animationsDef:h.animations,resources:o,previousResourceId:s?.form?.resourceId,currentResourceId:h.resourceId,previousTargetId:s?.form?.resourceId?"form-container":void 0,currentTargetId:h.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ze({animationInstances:B,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:y})&&k.push(...B),e},mb=(e,{presentationState:t,resources:s={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,form:d,saveSlots:g=[],skipTransitionsAndAnimations:b})=>{if(!t.control?.resourceId)return e;let y=s.controls?.[t.control.resourceId];if(!y)return e;let w=sb(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 h=et(e.elements);if(!h)return e;let P={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return h.children.push(Ko({container:P,resources:s,templateData:Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,form:d,characters:s.characters||{},skipTransitionsAndAnimations:b}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:b})),e},Wo=({presentationState:e,resources:t={},runtime:s,variables:o,musicRoomPlayer:a,skipTransitionsAndAnimations:r=!1})=>{if(e?.bgm&&t){let n=e.bgm,i=!Array.isArray(n.sounds),l=i?n.resourceId?[{id:"default",resourceId:n.resourceId,loop:n.loop??!0,volume:n.volume,startDelayMs:n.startDelayMs??0}]:[]:n.sounds,c=!i&&n.loop===!0,u=[];if(i||ps(l,"BGM sound"),c){let m=l.find(f=>f.loop===!0);if(m)throw new Error(`BGM sound "${m.id}" cannot loop inside a looping BGM channel.`)}if(l.forEach(m=>{let f=t.sounds?.[m.resourceId];if(!f)return;let d=c?{...m,loop:m.loop??!1}:m;u.push(Qg({node:ys({id:Or("bgm",i?"default":m.id),sound:d,resource:f,projectResources:t,soundPath:`bgm.sounds[${JSON.stringify(m.id)}]`,defaultLoop:!c,skipTransitionsAndAnimations:r}),bgm:n,sound:d,resource:f,usesLegacySound:i}))}),u.length===0)return null;let p=Ge({variables:o,runtime:s}).runtime;return ms({id:zg,volume:Go(p,"musicVolume"),muted:!1,pan:0,loop:i?void 0:n.loop,playback:a?.bgmPlayback,interruption:n.interruption,children:u,runtime:p})}return null},yb=(e,t)=>{if(!et(e.elements))return e;let o=Wo(t);return o&&e.audio.push(o),e},hb=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:s})=>(t?.length>0&&!s&&(e.audioEffects=structuredClone(t)),e),gb=(e,{resources:t={},runtime:s,variables:o,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let n=r.tracks.find(u=>u.id===a.trackId),i=n?t.sounds?.[n.soundId]:void 0;if(!n||!i)return e;let l=Ge({variables:o,runtime:s}).runtime,c=ys({id:Gg,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(ms({id:Xg,volume:Ho(l,"musicVolume",_r),children:[c],runtime:l})),e},bb=(e,{presentationState:t,resources:s,runtime:o,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&s){let n=t.sfx,i=Array.isArray(n.channels)?n.channels:[],l=i.map(c=>({channel:c,usesLegacyChannel:!1}));ps(i,"SFX channel"),Array.isArray(n.items)&&l.push({channel:{id:Kg,sounds:n.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,m=[];if(u||ps(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let f=c.sounds.find(d=>d.loop===!0);if(f)throw new Error(`SFX sound "${f.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((f,d)=>{let g=s.sounds?.[f.resourceId];if(!g)return;let b=p?{...f,loop:f.loop??!1}:f;m.push(ys({id:u?Or("sfx","default",d,f.id):Or("sfx",c.id,f.id),sound:b,resource:g,projectResources:s,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),m.length!==0&&r.push(ms({id:Or("channel","sfx",c.id),volume:Ho(o,"soundVolume",c.volume??_r),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:m,runtime:o}))})}return e},wb=(e,t,s)=>{if(!(!t||!s))return e?.voices?.[t]?.[s]},Ib=(e,{presentationState:t,resources:s,currentSceneId:o,runtime:a,variables:r,skipTransitionsAndAnimations:n})=>{let{audio:i}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:_r,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,m=[];if(c||ps(u,"Voice sound"),p){let d=u.find(g=>g.loop===!0);if(d)throw new Error(`Voice sound "${d.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(d=>{let g=wb(s,o,d.resourceId);if(!g)return;let b=p?{...d,loop:d.loop??!1}:d;m.push(ys({id:Or("voice",o,c?"default":d.id),sound:b,resource:g,projectResources:s,soundPath:`voice.sounds[${JSON.stringify(d.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:n}))}),m.length===0)return e;let f=Ge({variables:r,runtime:a}).runtime;return i.push(ms({id:Hg,volume:c?l.volume??Go(f,"soundVolume"):Ho(f,"soundVolume",l.volume??_r),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:m,runtime:f})),e},vb=(e,{presentationState:t,previousPresentationState:s,resources:o={},variables:a,imageGallery:r,musicRoom:n,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,form:d,saveSlots:g=[],isLineCompleted:b,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:h,animations:P}=e;if(t.layout){let O=et(h);if(!O)return e;let T=o.layouts?.[t.layout.resourceId];if(!T)return e;let $={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:T.elements||[]};O.children.push(Ko({container:$,resources:o,templateData:Ge({variables:a,imageGallery:r,musicRoom:n,sceneReplay:i,runtime:l,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:b,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,form:d,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:b,skipMode:u,skipTransitionsAndAnimations:y}))}let k=s?.layout?.resourceId,E=t.layout?.resourceId,v=hr({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:E,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:E?`layout-${E}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ze({animationInstances:v,isLineCompleted:b,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&P.push(...v),e},kb=(e,{currentLineActions:t,previousPresentationState:s,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})=>{let{animations:i}=e,l=t?.screen?.animations;if(!l)return e;let c=s!=null,u=hr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ze({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&i.push(...u),e},Ab=(e,{presentationState:t})=>{let s=et(e.elements);return!s||!t?.screen||Object.assign(s,hu(t.screen)),e},Pb=(e,{presentationState:t,resources:s={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:f,overlayStack:d=[],dialogueHistory:g=[],saveSlots:b=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:h})=>{let{elements:P}=e;return d&&d.length>0&&d.forEach((k,E)=>{let v=s.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[wu({id:`overlayStack-${E}-blocker`,screen:y}),...v.elements||[]]},T=Iu(g,s.characters,o),$=Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:b,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:m,form:f,historyDialogue:T,characters:s.characters||{},skipTransitionsAndAnimations:h}),D=mr(O,$),[B,..._]=D.children||[],G=yr(jr({...D,children:_},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:h}),s);P.push({...G,children:B?[B,...G.children||[]]:G.children})}),e},Eb=(e,{presentationState:t,resources:s={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,form:d,confirmDialog:g,dialogueHistory:b=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:h})=>{let{elements:P}=e;if(!g?.resourceId)return e;let k=s.layouts?.[g.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${g.resourceId}`),e;let E={id:"confirmDialog",type:"container",x:0,y:0,children:[wu({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=Iu(b,s.characters,o),O=mr(E,Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:m,canRollback:f,form:d,confirmDialog:g,historyDialogue:v,characters:s.characters||{},skipTransitionsAndAnimations:h})),[T,...$]=O.children||[],D=yr(jr({...O,children:$},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:h}),s);return P.push({...D,children:T?[T,...D.children||[]]:D.children}),e},sn=e=>(t,s)=>cb(t,{...s,visualLayer:e}),xb=sn(dr.BEHIND_BACKGROUND),Sb=sn(dr.BEHIND_CHARACTER),Ob=sn(dr.BEHIND_DIALOGUE),Rb=sn(dr.BEHIND_CHOICE),$b=sn(dr.FOREGROUND),ku=e=>Hn(ib,[mb,xb,ob,Sb,ab,Ob,pb,Rb,fb,db,vb,$b,Ab,kb,yb,gb,bb,Ib,hb,Pb,Eb])(e);function Au(e,t=""){let s=[],o=e.length,a=0,r=0,n=-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=n+1+i();n=l+i(),s.push([l,n,t?parseInt(t[r++],36):0])}return s}function Pu(e,t,s){let o=0,a=t.length-1;for(;o<=a;){let r=o+a>>>1,n=s[r];if(e<t[r])a=r-1;else if(e>n>>>5)o=r+1;else return n&31}return 0}var Eu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",xu="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Su="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Ou=65535,Jo=40960,hs=126976,Cu=new Uint8Array(12288),_u=new Uint8Array(3072),ju=new Uint8Array(2816),Nu,Du;{let e=(a,r,n,i,l)=>{let c=r+a.length-1;for(let u=n<r?r:n,p=i>c?c:i;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),s=new Uint32Array(320),o=0;for(let[a,r,n]of Au(Eu,xu))e(Cu,0,a,r,n),e(_u,Jo,a,r,n),e(ju,hs,a,r,n),r>=65040&&!(a>=hs&&r<=129791)&&(t[o]=a,s[o++]=r<<5|n);Nu=t.slice(0,o),Du=s.slice(0,o)}function Ru(e){return e<12288?Cu[e]:e<Jo?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?_u[e-Jo]: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>=hs&&e<129792?ju[e-hs]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Pu(e,Nu,Du)}var Tu=Uint8Array.from(Su,Number);function Cb(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 $u(e,t,s){switch(t){case 3:return e&24?s===8204?e&6:(e&24)===16||Cb(s)?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*Lu(e){let t=e.length;if(t===0)return;let s=e.codePointAt(0),o=s>Ou?2:1,a=Ru(s),r=50200>>a&1?$u(0,a,s):0,n=0,i=s,l=a;for(;o<t;){s=e.codePointAt(o);let c=s>Ou?2:1,u=Ru(s),p=Tu[a<<4|u],m;p===0?m=!0:p===1?m=!1:p===2?m=!(r&1):p===3?m=!(r&4):m=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?$u(r,u,s):0,m&&(yield{segment:e.slice(n,o),index:n,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},n=o,i=s,l=u),o+=c,a=u}yield{segment:e.slice(n),index:n,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Mu(e){for(let t of Lu(e))yield t.segment}{let e=Lu("_");Tu._keep=[e,e.next()]}var qu=1e3,Uu=50,_b=0,Vu=100,Fu=50,jb=60,Nb=3,Db=.5,Tb=2e4,Lb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Mb=/^\s+$/u,Bu,qb=e=>{let t=`${e??""}`.normalize("NFC"),s=globalThis.Intl?.Segmenter;return typeof s!="function"?Array.from(Mu(t)):(Bu??=new s(void 0,{granularity:"grapheme"}),Array.from(Bu.segment(t),({segment:o})=>o))},Vb=e=>qb(e).reduce((t,s)=>Mb.test(s)?t+Db:Lb.test(s)?t+Nb:t+1,0),Fb=e=>2**(((Number.isFinite(e)?Math.min(Vu,Math.max(_b,e)):Uu)-Fu)/(Vu-Fu)),Qo=({text:e="",baseDelay:t=qu,speed:s=Uu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):qu,a=Fb(s),r=Vb(e)*jb/a,n=Math.max(o,Tb);return Math.min(o+r,n)};var gs={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Ku=1,gr=1,Ot="choice",Dr="form",cn=()=>({manual:{...gs.manual},auto:{...gs.auto},applyMode:gs.applyMode}),ua=()=>({groupId:null,variantId:null,pageIndex:0}),Bb="music-room:player",Ub=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Is=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),pa=new Set,Yb=new Set(["groupId","variantId"]),zb=new Set(["pageIndex"]),Rt=new Set,Xb=new Set(["trackId"]),Gb=new Set(["positionMs"]),Hb=new Set(["pageIndex"]),fa=new Set,Kb=new Set(["sceneId"]),Wb=new Set(["pageIndex"]),da=()=>({pageIndex:0}),ma=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let s=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...cn()},s&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ea=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},V=e=>{let t=Pe(e)?Ar(e):e;return structuredClone(t)},q=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),vs=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},Wu=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},un=(e,t,s)=>({commandId:vs(e),operation:t,...s===void 0?{}:{positionMs:s}}),ya=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,s=t.bgmPlayback;t.trackId!==null&&(s={commandId:vs(e),operation:"resume"}),e.global.musicRoomPlayer=Is({bgmPlayback:s})},Ju=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let s=e.projectData.resources?.achievements?.[t];if(!s)throw new Error(`Achievement resource "${t}" not found`);if(s.type!=="boolean"&&s.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${s.type}"`);return s},Qu=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let s=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!s&&!o)throw new Error(`${t} requires a non-empty string or finite number slotId`)},nt=e=>String(e),Zu=()=>({sections:[],resources:[]}),ep=()=>({sceneIds:[]}),Jb=e=>q(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Zu(),Qb=e=>q(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):ep(),Zb=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",ew=({sectionId:e,lineId:t,content:s,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:s,text:Zb(s),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),rp=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),rw=e=>q(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,ha=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},tw=e=>{if(!q(e?.dialogueHistory))return e.dialogueHistory=rp(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},ga=e=>{let t=ha(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},nw=()=>({resourceId:void 0}),sw=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},br=(e,t)=>{let s=e?.story?.scenes??{};for(let[o,a]of Object.entries(s))if(a?.sections?.[t])return{sceneId:o,section:a.sections[t]};return{sceneId:void 0,section:void 0}},tp=e=>{let t=e?.story?.scenes??{},s=new Map;for(let[o,a]of Object.entries(t)){let r=a?.sections??{};for(let n of Object.keys(r)){let i=s.get(n);if(i!==void 0)throw new Error(`Duplicate sectionId "${n}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);s.set(n,o)}}},np=e=>e,sp=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Ku)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},iw=(e,t={})=>{let s;try{s=sp(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:s,slotId:np(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},ow=(e={})=>Object.fromEntries(Object.entries(e).map(([t,s])=>[t,iw(t,s)])),aw=(e,t)=>{if(!q(e)||!Array.isArray(e.operations))return null;let s=e.operations.filter(o=>{if(!q(o))return!1;let{variableId:a,op:r,value:n,roundTo:i}=o,l=t?.resources?.variables?.[a];if(!l||_e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Kt(l.type,r,a),Jn(l.type,r,n,a,{roundTo:i}),r!=="set"||co(l,n)}catch{return!1}});return s.length>0?{...e,operations:s}:null},ip=(e,t)=>{if(!Array.isArray(e))return;let s=e.flatMap(o=>{if(!q(o)||!YI(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=aw(o.payload,t);return a?[{...o,payload:a}]:[]});return s.length>0?s:void 0},lw=(e,t,s)=>{let{section:o}=br(e,t?.sectionId),r=o?.lines?.find(({id:i})=>i===t?.lineId)?.actions,n=s.split(".");for(let i of n){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 n.at(-1)==="random"&&q(r?.distribution)?r:void 0},op=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},ap=(e,t,s)=>e.filter(({path:o,type:a,result:r})=>{let n=lw(s,t,o);if(n?.distribution?.type!==a)return!1;if(a==="weighted")return q(n.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let i=s?.resources?.variables?.[n.variableId];return typeof n.variableId=="string"&&i?.type==="number"&&i.scope==="context"&&i.readonly!==!0&&!_e(i)&&op(n.distribution)&&r.value>=n.distribution.min&&r.value<=n.distribution.max}return!1}),ba=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==gr)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 s=new Set,o=e.randomOutcomes.map((a,r)=>{let n=`${a?.path}\0${a?.ordinal}`;if(!q(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||s.has(n))throw new Error(`invalid rollback random outcome at index ${r}`);return s.add(n),{path:a.path,ordinal:a.ordinal,type:a.type,result:rs(V(a.result),a.type)}});return t===void 0?o:ap(o,e,t)},cw=(e,t)=>{!q(e)||!Array.isArray(e.timeline)||e.timeline.forEach(s=>{if(!q(s))return;typeof s.returnable!="boolean"&&delete s.returnable;let o=ip(s.executedActions,t);o?s.executedActions=o:delete s.executedActions;let a=ba(s,t);a?(s.randomOutcomeVersion=gr,s.randomOutcomes=a):(delete s.randomOutcomeVersion,delete s.randomOutcomes)})},uw=(e,t)=>{let s=e??{};return Object.values(s).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let n=r?.rollback?.timeline;Array.isArray(n)&&n.forEach(i=>{if(!q(i))return;let l=ba(i,t);l?(i.randomOutcomeVersion=gr,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),s},Yu=(e,t,s,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}[${s}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${t}[${s}] 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[${s}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},pw=(e,t="viewedRegistry")=>{if(e===void 0)return Zu();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 s=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(s.map((a,r)=>{let n=Yu(a,"sections",r,t);return[n.sectionId,n]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let n=Yu(a,"resources",r,t);return[n.resourceId,n]})))}},fw=(e,t="accountReplayRegistry")=>{if(e===void 0)return ep();if(!q(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let s=e.sceneIds??[];return{sceneIds:[...new Set(s.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return o}))]}},on=(e,t,s)=>{if(!q(e))throw new Error(`Malformed save slot ${s}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${s}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${s}: missing lineId.`);let{sceneId:r,section:n}=br(t,o);if(!n)throw new Error(`Malformed save slot ${s}: section "${o}" does not exist in projectData.`);if(!n.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${s}: line "${a}" does not exist in section "${o}".`);return{sceneId:r,sectionId:o,lineId:a}},lp=e=>{let t=e.story.initialSceneId,s=e.story.scenes[t],o=s.initialSectionId,a=s.sections[o];return on({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},dw=e=>{try{return lp(e),!0}catch{return!1}},mw=(e,t,s)=>{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 on(o,t,s);try{return on(o,t,s)}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 n=r;n>=0;n-=1)try{return on(a[n],t,`${s} compatibility checkpoint`)}catch{}return lp(t)}};var cp=(e,t)=>{let{section:s}=br(e,t?.sectionId);return s?.lines?.find(o=>o.id===t?.lineId)},yw=(e,t,s)=>{if(!q(e))throw new Error(`Malformed save slot ${s}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${s}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${s}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${s}.checkpointLengths.`);let o=[],a=[0],r=!1;if(e.entries.forEach((i,l)=>{if(!q(i))throw new Error(`Malformed save slot ${s}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${s}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${s}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${s}.entries[${l}].appendToPrevious.`);let{section:c}=br(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 ${s}.currentLength: must reference the retained entries.`);let n=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${s}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:n}},hw=(e,t)=>q(cp(e,t)?.actions?.dialogue),up=(e,t,s)=>{if(!t||t.sectionId!==s.sectionId)return!1;let{section:o}=br(e,s.sectionId),a=o?.lines?.findIndex(n=>n.id===s.lineId);return typeof a!="number"||a<=0?!1:o.lines.slice(0,a).findLast(n=>q(n.actions?.dialogue))?.id===t.lineId},gw=(e,t)=>{let s=rp();return e.timeline.forEach(o=>{if(o.returnable!==!1&&hw(t,o)){let a=cp(t,o),r=s.entries.at(-1),n=a.actions.dialogue.append===!0&&up(t,r,o);s.entries.push({sectionId:o.sectionId,lineId:o.lineId,...n?{appendToPrevious:!0}:{}})}s.checkpointLengths.push(s.entries.length)}),s.currentLength=s.checkpointLengths[e.currentIndex]??0,s.entries.length>0?s:null},bw=(e,t,s,o)=>{if(s.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=s.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,n)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${n}]: lengths must be chronological.`);a=r}),e},ww=(e,t,s)=>{if(!q(e)||!Array.isArray(e.timeline))return{rollback:ln({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!q(c))return[];let p=ba(c);try{let m=on(c,s,`rollback.timeline[${u}]`),f=p?ap(p,m,s):void 0,d=ws({sectionId:m.sectionId,lineId:m.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...f?{randomOutcomeVersion:gr,randomOutcomes:f}:{}}),g=ip(V(c.executedActions),s);return g&&(d.executedActions=g),o.push(u),[d]}catch{return[]}});if(a.length===0)return{rollback:ln({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,n=o.indexOf(r);n<0&&(n=a.length-1);let i=a[n];if(i?.sectionId!==t.sectionId||i?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?n=c:(a.push(ws({sectionId:t.sectionId,lineId:t.lineId})),o.push(null),n=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),n):0;return{rollback:{currentIndex:n,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:o,sourceTimelineLength:e.timeline.length}},pp=(e,t,s)=>{if(!q(e))throw new Error(`Malformed save slot contexts[${s}] entry.`);let o=Ia(t),a=mw(e,t,`contexts[${s}].pointers.read`);if(e.variables!==void 0&&!q(e.variables))throw new Error(`Malformed save slot contexts[${s}].variables entry.`);if(e.runtime!==void 0&&!q(e.runtime))throw new Error(`Malformed save slot contexts[${s}].runtime entry.`);let r=e.variables?Gt(V(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},n=_w({loadedContextRuntime:q(e.runtime)?V(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=ww(e.rollback,a,t),u=e.dialogueHistory===void 0?gw(i,t):bw(yw(e.dialogueHistory,t,`contexts[${s}].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 n&&(p.runtime=n),p},Iw=(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((s,o)=>pp(s,t,o))}},vw=(e,t)=>{if(!q(e))throw new Error("Malformed save slot.");let s=sp(e.formatVersion);return{...e,formatVersion:s,state:Iw(e.state,t)}},zu=(e,t,{required:s=!1}={})=>{if(e===void 0){if(s)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}},kw=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:zu(e.confirmActions,"confirmActions",{required:!0}),cancelActions:zu(e.cancelActions,"cancelActions")}},$t=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},Aw=e=>(q(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Ct=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},fp=e=>{if(!(!q(e)||!e.animations))return{animations:V(e.animations)}},Pw=(e,t)=>{let s=fp(t);if(s){e.global.pendingScreenTransition=s;return}delete e.global.pendingScreenTransition},Ew=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},xw=(e,t)=>{let s=e?.sectionId,o=e?.lineId;if(!(!s||!o||!t))return`${s}:${o}:${t}`},bs=e=>String(e??""),dp=(e,t)=>{let s=bs(t);return e?.trim===!0?s.trim():s},Sw=e=>q(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>q(t)).map(([t,s])=>[t,{id:t,...V(s)}])):{},Ow=(e,t)=>{if(!t||!q(e.global.formDrafts))return;let s=e.global.formDrafts[t];return q(s)?s:void 0},mp=(e,t)=>{let s=Aw(e);q(s[t])||(s[t]={values:{},touched:{},errors:{},submitted:!1});let o=s[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},wa=(e,t)=>{let s=dp(e,t);return e?.required===!0&&s.length===0?"required":null},Rw=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let o=xe({state:e},{sectionId:t.sectionId})?.lines||[],a=o.findIndex(r=>r.id===t.lineId);return a<0?{}:Qr(o.slice(0,a+1).map(r=>r.actions||{}),{resources:e.projectData.resources})},$w=({state:e,form:t,pointer:s})=>{if(!t?.resourceId)return null;let o=Ew(t),a=xw(s,o);if(!o||!a)return null;let r=Ow(e,a),n=Sw(t),i=ja({state:e}),l={},c=[],u={},p=!0;return Object.entries(n).forEach(([m,f])=>{let d=bs(i?.[f.variableId]),g=Object.prototype.hasOwnProperty.call(r?.values??{},m)?bs(r.values[m]):d,b=r?.touched?.[m]===!0,y=wa(f,g),w=r?.submitted||b?y:null,h=typeof f.maxLength=="number"?Math.max(0,Math.round(f.maxLength)):void 0,P={id:m,variableId:f.variableId,value:g,initialValue:d,valid:!y,error:w,touched:b,required:f.required===!0,trim:f.trim===!0,placeholder:f.placeholder===void 0?"":String(f.placeholder),multiline:f.multiline===!0,...h!==void 0?{maxLength:h}:{}};y&&(p=!1),l[m]=P,c.push(P),u[m]=g}),{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??{})}}}},St="line",Nr="interaction",ws=({sectionId:e,lineId:t,rollbackPolicy:s,returnable:o,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:s??"free",...typeof o=="boolean"?{returnable:o}:{},...a===gr?{randomOutcomeVersion:gr,randomOutcomes:V(r??[])}:{}}),Ia=e=>{let t=Pe(e)?Ar(e):e,{contextVariableDefaultValues:s}=Wn(t??{});return V(s)},yp=()=>({...V(en)}),hp=({loadedRuntime:e,runtimeIds:t,defaults:s={},path:o})=>{if(e===void 0)return{runtimeState:V(s),hasLoadedValues:!1};if(!q(e))throw new Error(`Malformed ${o}.`);let a=V(s),r=!1;return t.forEach(n=>{e[n]!==void 0&&(a[n]=os(n,V(e[n])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},Cw=({projectData:e,loadedGlobalRuntime:t={}})=>hp({loadedRuntime:t,runtimeIds:Io,defaults:ko(e),path:"global.runtime"}).runtimeState,_w=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:s}=hp({loadedRuntime:e,runtimeIds:vo,defaults:yp(),path:"context.runtime"});return s?t:void 0},Lr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ye=e=>{let t=Lr(e);return t?.kind==="sceneReplay"&&q(t.sceneReplay)?t:null},gp=(e,t)=>{let s=t?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===s);Object.entries(o?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=V(r)})},jw=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)}}),Nw=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},Dw=(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 s=Se({state:e});e.global.autoMode&&e.global.isLineCompleted&&!s&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}}),e.global.skipMode&&!s&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!s&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},Tw=e=>e.runtime?(vo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=V(en[t]))}),e.runtime):(e.runtime=yp(),e.runtime),Lw=e=>Bc(e.global),bp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:Lw(e)}})},va=(e,t,s)=>{let o=os(t,s);if(t in en){let a=Lr(e);if(!a)return o;let r=Tw(a);return r[t]=o,o}return e.global[t]=o,o},ka=({pointer:e,projectData:t,kind:s,sceneReplay:o})=>({...s===void 0?{}:{kind:s},...o===void 0?{}:{sceneReplay:V(o)},currentPointerMode:"read",pointers:{read:V(e)},configuration:{},views:[],bgm:nw(),variables:Ia(t),rollback:ln({pointer:e})}),_t=e=>e?(e.currentPointerMode="read",q(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,Mw=(e,{queueRender:t=!0}={})=>{let s=e.contexts?.[e.contexts.length-1],o=s?.pointers?.read;if(!s||!o?.sectionId||!o?.lineId)return null;let a=ka({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,qw(e,{queueRender:t}),a},qw=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,$t(e),Ct(e),e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,ya(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},wp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},ln=({pointer:e,replayStartIndex:t=0})=>{let s=e?.sectionId&&e?.lineId;return{currentIndex:s?0:-1,isRestoring:!1,replayStartIndex:t,timeline:s?[ws({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Mr=(e,t={})=>{if(e?.rollback)return wp(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 s=e?.pointers?.read;return e.rollback=ln({pointer:s,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},ks=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return;let o=Mr(s);if(o.isRestoring)return;let a=ga(s);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(ws(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},Vw=({state:e})=>{let s=e.contexts?.[e.contexts.length-1]?.rollback;return!Array.isArray(s?.timeline)||typeof s.currentIndex!="number"?null:{checkpointIndex:s.currentIndex,checkpoint:s.timeline[s.currentIndex]??null}},Fw=({state:e},t={})=>{let{checkpointIndex:s,checkpointIdentity:o,sectionId:a,lineId:r}=t,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(s)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[s];return(Pe(l)?Tn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},Bw=({state:e},t={})=>{let{slotId:s,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:n}=t,i=nt(s),l=e.global.saveSlots?.[i],c=Pe(l)?Tn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,m=p?.rollback,f=m?.timeline?.[a];return!Number.isInteger(a)||m?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==n||f?.sectionId!==r||f?.lineId!==n||(f.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Ip=(e,t)=>{let s=e.contexts?.[e.contexts.length-1],o=s?.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 n=ga(s);n&&(n.checkpointLengths=n.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},Uw=({state:e,rollbackActionBatchStack:t,playbackOwnership:s},o={})=>{let a=o?.source===St?St:Nr,r=e.contexts?.[e.contexts.length-1],n=r?.rollback;if(!n||n.isRestoring||!Array.isArray(n.timeline)||typeof n.currentIndex!="number"||n.currentIndex<0||n.currentIndex>=n.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(n.currentIndex<n.timeline.length-1){n.timeline=n.timeline.slice(0,n.currentIndex+1);let u=ga(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,n.currentIndex+1))}let i=r?.pointers?.read,l=s?.lineEntryId,c=a===St&&(s?.rollbackCheckpointLineEntryId===void 0?n.timeline[n.currentIndex]?.sectionId===i?.sectionId&&n.timeline[n.currentIndex]?.lineId===i?.lineId:s.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:n.currentIndex,source:a,...a===St?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Yw=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),zw=({state:e,rollbackActionBatchStack:t,playbackOwnership:s})=>{let o=t?.at(-1);if(o?.source!==St||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;ks(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let n=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=n.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,s?.lineEntryId===o.lineEntryId&&(s.rollbackCheckpointLineEntryId=o.lineEntryId),e},Xw=({state:e,rollbackActionBatchStack:t},s)=>{if(t?.at(-1)?.source!==St)return e;if(typeof s?.path!="string"||s.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(s.ordinal)||s.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=rs(s.result,s.type),r=Ip(e,t);if(!r)return e;if(r.randomOutcomeVersion!==gr&&(r.randomOutcomeVersion=gr,r.randomOutcomes=[]),r.randomOutcomes.some(({path:n,ordinal:i})=>n===s.path&&i===s.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${s.path}#${s.ordinal}`);return r.randomOutcomes.push({path:s.path,ordinal:s.ordinal,type:s.type,result:a}),e},sr=(e,t,s,o)=>{let r=o?.at(-1)?.source??Nr;if(!zI(t,r))return;let n=Ip(e,o);n&&(Array.isArray(n.executedActions)||(n.executedActions=[]),n.executedActions.push({type:t,payload:V(s)}))},ra=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return;let o=t?.operations??[];for(let{variableId:a,op:r,value:n,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(_e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Ht(c,a),Kt(u,r,a),Jn(u,r,n,a,{roundTo:i}),c==="context"&&(s.variables[a]=Qn(s.variables[a],r,n,{roundTo:i}))}},Gw=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:s,payload:o})=>{XI(e,s,o)})},Hw=(e,t)=>{let{sectionId:s,lineId:o}=t,n=xe({state:e},{sectionId:s})?.lines?.find(i=>i.id===o)?.actions;n&&Ma(e,n,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},vp=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return e;let o=Mr(s),a=o.timeline[t];if(!a)return e;e.global.autoMode&&mn({state:e}),e.global.skipMode&&Tr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{s.variables=Ia(e.projectData),s.kind==="sceneReplay"&&(gp(e,s),s.sceneReplay.finishOnNextAdvance=!1,s.sceneReplay.exitOnLineCompleted=!1),delete s.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=V(gs),e.global.overlayStack=[],$t(e),Ct(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&ma(e),Hw(e,o.timeline[l]),Gw(e,o.timeline[l]);let n=_t(s);n.read={sectionId:a.sectionId,lineId:a.lineId};let i=ha(s);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),s.kind==="sceneReplay"&&(s.sceneReplay.entryId=Wu(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},Kw=e=>{let{projectData:t}=e,s=e.initialAudioCommandId??0;if(!Number.isSafeInteger(s)||s<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:r={},runtime:n={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;tp(t),Yt(t),zt(t),Xt(t),Wr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],m=p.initialSectionId,f=p.sections[m],d={sceneId:u,sectionId:m,lineId:f.initialLineId??f.lines[0].id},{globalVariablesDefaultValues:g}=Wn(t),b={...g,...Gt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:pw(i,"accountViewedRegistry"),accountReplayRegistry:fw(l),nextLineConfig:cn(),imageGalleryNavigation:ua(),sceneReplayNavigation:da(),sceneReplayEntryId:0,audioCommandId:s,musicRoomPlayer:Is(),saveSlots:ow(a),localizationPackages:V(c),overlayStack:[],variables:b,...Cw({projectData:t,loadedGlobalRuntime:n})},contexts:[ka({pointer:d,projectData:t})]}},Ww=({state:e})=>e.global.overlayStack||[],Jw=({state:e})=>e.global.pendingEffects,kp=({state:e})=>e.global.skipMode,Qw=({state:e})=>e.global.autoMode,Ap=({state:e})=>e.global.dialogueUIHidden,Pp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],s=t[t.length-1];if(!s)return[];let o,a=q(s.dialogueHistory)&&Array.isArray(s.dialogueHistory.entries)&&Number.isInteger(s.dialogueHistory.currentLength);if(a)o=s.dialogueHistory.entries.slice(0,s.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=s.pointers.read,p=xe({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let m=p.lines.findIndex(f=>f.id===u);o=p.lines.slice(0,m+1).map(f=>({sectionId:c,lineId:f.id}))}let r=[],n=bt({variables:{...e.global?.variables??{},...Lr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let m=xe({state:e},{sectionId:c.sectionId}),f=Array.isArray(m?.lines)?m.lines:[];u={lines:f,lineIndexes:new Map(f.map((d,g)=>[d.id,g])),projections:new Map,nextLineIndex:0,presentationState:{}},i.set(c.sectionId,u)}let p=u.lineIndexes.get(c.lineId);if(p===void 0)return null;for(;u.nextLineIndex<=p;){let m=u.lines[u.nextLineIndex],f=m.actions||{};u.presentationState=Qr([u.presentationState,f],{resources:e.projectData.resources}),u.projections.set(m.id,{line:m,lineActions:f,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!rw(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:m,dialogueState:f}=u;if(!m.dialogue)continue;let d=Kn({characterId:f.characterId,character:f.character,characters:e.projectData.resources?.characters??{},variables:n}),g=ew({sectionId:c.sectionId,lineId:p.id,content:m.dialogue.append===!0?f.content:m.dialogue.content,dialogueState:f,characterName:d}),b=r[r.length-1];if((a?c.appendToPrevious===!0:m.dialogue.append===!0)&&b?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:g.content,text:g.text,characterId:g.characterId,character:g.character,characterName:g.characterName};continue}r.push(g)}return r},Zw=(e,t,s)=>{let o=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:n,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[nt(r)],u=Pe(c)?Tn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==n||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=V(s),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},e0=({state:e},t={})=>{let s=Lr(e),o=s?.pointers?.read,a=fn({state:e});if(!s||!q(a?.actions?.dialogue))return e;let r=Mr(s),n=r.timeline?.[r.currentIndex],i=n?.sectionId===o?.sectionId&&n?.lineId===o?.lineId,l=ha(s),c=l?.checkpointLengths?.[r.currentIndex],u=r.currentIndex>0?l?.checkpointLengths?.[r.currentIndex-1]??0:0,p=l?.entries?.[l.currentLength-1];if(t.reuseExistingOccurrence===!0&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId||t.forceNewOccurrence!==!0&&i&&l&&c===l.currentLength&&c>u&&p?.sectionId===o.sectionId&&p?.lineId===o.lineId)return e;let m=tw(s);m.currentLength<m.entries.length&&(m.entries=m.entries.slice(0,m.currentLength));let f=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&up(e.projectData,p,o);if(m.entries.push({sectionId:o.sectionId,lineId:o.lineId,...f?{appendToPrevious:!0}:{}}),m.currentLength=m.entries.length,i){for(;m.checkpointLengths.length<r.timeline.length;)m.checkpointLengths.push(m.checkpointLengths.at(-1)??0);m.checkpointLengths[r.currentIndex]=m.currentLength}return Zw(e,t.savedCheckpointOccurrences,m),e},r0=({state:e})=>e.global.confirmDialog??null,pn=({state:e},{pointer:t}={})=>{let s=t??Ve({state:e})?.pointer,o=Rw({state:e,pointer:s});return $w({state:e,form:o.form,pointer:s})},t0=({state:e},{pointer:t}={})=>!!pn({state:e},{pointer:t}),Se=({state:e},{pointer:t}={})=>{let s=pn({state:e},{pointer:t});if(s)return{source:Dr,formId:s.id,formKey:s.key};let o=$p({state:e,pointer:t});return o?{source:Ot,resourceId:o}:null},n0=({state:e,registry:t},s)=>{let{sectionId:o,lineId:a}=s,n=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===o);if(!n)return!1;if(n.lastLineId===void 0||a===void 0)return!0;let i=xe({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return n.lastLineId===a;let l=i.lines.findIndex(u=>u.id===n.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?n.lastLineId===a:c<=l},Aa=({registry:e},t)=>{let{resourceId:s}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===s)},Pa=({state:e},t)=>n0({state:e,registry:e.global.accountViewedRegistry},t),s0=({state:e},t)=>Aa({registry:e.global.accountViewedRegistry},t),an=(e,t)=>!Aa({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Ea=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),xa=(e,t)=>{let s=Ea(e);if(s===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),s-1)},ta=(e,t,s,o)=>{for(let a=s+o;a>=0&&a<t.length;a+=o)if(!an(e,t[a]))return t[a]},i0=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:V(t)},Ep=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let s=e.global.imageGalleryNavigation??ua(),o=Ea(t),a=xa(t,s),r=a*t.pageSize,n=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:an(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:an(e,c)}))})),i=null;if(typeof s.groupId=="string"&&typeof s.variantId=="string"){let l=t.groups.findIndex(f=>f.id===s.groupId),c=t.groups[l],u=c?.variants.findIndex(f=>f.id===s.variantId),p=u===void 0||u<0?void 0:c.variants[u],m=l<0?-1:Math.floor(l/t.pageSize);p&&m===a&&!an(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ta(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:ta(e,c.variants,u,1)!==void 0})}return{pageGroups:n,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Sa=(e,t)=>!Aa({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Oa=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ra=(e,t)=>{let s=Oa(e);if(s===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),s-1)},na=(e,t,s,o)=>{for(let a=s+o;a>=0&&a<t.length;a+=o)if(!Sa(e,t[a]))return t[a]},xp=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}),o0=(e,t)=>({...xp(t),locked:Sa(e,t)}),Xu=e=>{let t=Math.floor(e/1e3),s=t%60,o=Math.floor(t/60);if(o<60)return`${o}:${String(s).padStart(2,"0")}`;let a=Math.floor(o/60),r=o%60;return`${a}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`},a0=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:V(t)},Sp=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let s=e.global.musicRoomPlayer??Is(),o=Oa(t),a=Ra(t,s),r=a*t.pageSize,n=t.tracks.slice(r,r+t.pageSize).map(u=>o0(e,u)),i=t.tracks.findIndex(u=>u.id===s.trackId),l=t.tracks[i],c=l?{...xp(l),canPlayPreviousTrack:na(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:na(e,t.tracks,i,1)!==void 0}:null;return{pageTracks:n,selection:c,playback:c?{status:s.status,readiness:s.readiness,positionMs:s.positionMs,durationMs:s.durationMs,positionText:Xu(s.positionMs),durationText:s.durationMs===null?null:Xu(s.durationMs),canPlay:s.status!=="playing",canPause:s.status==="playing",canSeek:s.readiness==="ready"&&s.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},$a=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Ca=(e,t)=>{let s=$a(e);if(s===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),s-1)},l0=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:V(t)},c0=({state:e})=>ye(e)!==null,u0=({state:e})=>{let t=ye(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Op=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,Rp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let s=e.global.sceneReplayNavigation??da(),o=$a(t),a=Ca(t,s),r=a*t.pageSize,n=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!Op(e,l.sceneId)})),i=ye(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:n,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},p0=({state:e})=>e.global.nextLineConfig,$p=({state:e,pointer:t}={})=>{let s=t??Ve({state:e})?.pointer;if(!s)return;let o=s?.sectionId,a=s?.lineId,n=xe({state:e},{sectionId:o})?.lines||[],i=n.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of n.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},Cp=({state:e})=>!!$p({state:e}),f0=({state:e})=>structuredClone(e),d0=({state:e})=>V(e.projectData.resources?.achievements??{}),m0=({state:e},t)=>{let s=e.projectData.resources?.achievements?.[t?.resourceId];return s===void 0?void 0:V(s)},_p=({state:e})=>e.global.saveSlots,y0=({state:e},t)=>{let s=t?.slotId,o=nt(s);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},jp=({state:e})=>V(e.global.localizationPackages),_a=({state:e})=>Cr(e),h0=({state:e},t)=>tr(e,t?.runtimeId),ja=({state:e})=>{let t={...e.global?.variables??{},...Lr(e)?.variables??{}};return bt({variables:t,runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{}})},Ve=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],s=t[t.length-1];if(s)return{currentPointerMode:"read",pointer:s.pointers?.read}},xe=({state:e},t)=>{let{sectionId:s}=t;return br(e.projectData,s).section},fn=({state:e})=>{let t=Ve({state:e});if(!t?.pointer)return;let{sectionId:s,lineId:o}=t.pointer,a=xe({state:e},{sectionId:s});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===o)},Np=({state:e})=>{let{sectionId:t,lineId:s}=Ve({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===s),i=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(m=>{p[m]=u[m]}),p});return Qr(i,{resources:e.projectData.resources})},Dp=e=>{let t=fn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let s=bt({variables:{...e.global?.variables??{},...Lr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${vt(o?.text,{variables:s})??""}`).join("")},wr=({state:e})=>Qo({text:Dp(e),baseDelay:tr(e,"autoForwardDelay"),speed:tr(e,"autoForwardSpeed")}),g0=({state:e})=>{let t=Tp({state:e}),o=fn({state:e})?.actions??{},a=Qr([t??{},o],{resources:e.projectData.resources});return po(t??{},a??{})},b0=({state:e},{sectionId:t})=>{let s=xe({state:e},{sectionId:t});if(!s?.lines)return[];let o=[],a={};for(let r of s.lines){let n=r.actions||{},i=Qr([a,n],{resources:e.projectData.resources}),l=po(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=fo(i)}return o},w0=({state:e},{sectionId:t,includePresentationState:s=!1})=>{let o=b0({state:e},{sectionId:t});return s?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},Tp=({state:e})=>{let{sectionId:t,lineId:s}=Ve({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===s);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 fo(Qr(i,{resources:e.projectData.resources}))},Na=({state:e},{slotsPerPage:t=6}={})=>{let a=((_a({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let n=0;n<t;n++){let i=a+n,l=e.global.saveSlots&&e.global.saveSlots[nt(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},I0=_p,v0=Na,Da=e=>{let s=e.contexts?.[e.contexts.length-1]?.rollback;return!s||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"?!1:s.currentIndex>=0&&s.currentIndex<s.timeline.length-1},k0=({state:e},t={})=>{let s=Np({state:e}),o=Tp({state:e}),a=fn({state:e})?.actions??{},r=e.global.pendingScreenTransition,n=r?.animations?{...a,screen:V(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=Ve({state:e}).pointer,{sceneId:c}=br(e.projectData,l),u={..._a({state:e}),localizationPackages:jp({state:e})},p=t?.activePersistentAnimations??[],m=t?.restoredPersistentAnimations??[],f=pn({state:e}),d=Cp({state:e}),g=Ep({state:e}),b=Sp({state:e}),y=Rp({state:e}),w=ja({state:e}),{saveSlots:h}=Na({state:e}),P=Da(e);return ku({presentationState:s,previousPresentationState:i,currentLineActions:n,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:d,isFormVisible:!!f,canRollback:of({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||P,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:f,dialogueHistory:Pp({state:e}),saveSlots:h,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:m,imageGallery:g,musicRoom:b,sceneReplay:y,musicRoomPlayer:V(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},A0=({state:e},t)=>(e.global.confirmDialog=kw(t),e.global.pendingEffects.push({name:"render"}),e),P0=({state:e})=>(e.global.confirmDialog&&($t(e),e.global.pendingEffects.push({name:"render"})),e),E0=({state:e,rollbackActionBatchStack:t},s)=>(e.global.overlayStack.push(s),e.global.pendingEffects.push({name:"render"}),sr(e,"pushOverlay",s,t),e),x0=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),sr(e,"popOverlay",void 0,t),e),S0=({state:e,rollbackActionBatchStack:t},s)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=s),e.global.pendingEffects.push({name:"render"}),sr(e,"replaceLastOverlay",s,t),e),O0=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],$t(e),Ct(e),e.global.pendingEffects.push({name:"render"}),sr(e,"clearOverlays",void 0,t),e),R0=(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"})},dn=(e,t,{screenTransition:s}={})=>{e.global.isLineCompleted=!1,Pw(e,s),Ct(e);let o=Se({state:e},{pointer:t}),a=o?.source===Ot,r=o?.source===Dr;R0(e,{activeInteraction:o});let n=ye(e),i={name:"handleLineActions"};if(typeof n?.sceneReplay?.sceneId=="string"){let l=Wu(e);n.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:n.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:r,activeInteraction:o}},As=(e,t,s)=>{!(t?.source===Ot||t?.source===Dr)||s||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Lp=({state:e})=>(Se({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),mn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),$0=({state:e})=>{let t=e.global.autoMode;return Se({state:e})&&!t||(t?mn({state:e}):Lp({state:e})),e},Mp=({state:e})=>(Se({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),Tr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),C0=({state:e})=>{let t=kp({state:e});return Se({state:e})&&!t||(t?Tr({state:e}):Mp({state:e})),e},Ps=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),sr(e,"showDialogueUI",void 0,t),e),qp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),sr(e,"hideDialogueUI",void 0,t),e),_0=e=>{let{state:t}=e;return Ap({state:t})?Ps(e):qp(e),t},qr=(e,t,s)=>(va(e,t,s),bp(e),e.global.pendingEffects.push({name:"render"}),e),yn=(e,t,s,o,a)=>{let r=va(e,t,s);return e.global.pendingEffects.push({name:"render"}),sr(e,o,{value:r},a),e},j0=({state:e},t)=>qr(e,"dialogueTextSpeed",t?.value),N0=({state:e},t)=>(qr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}}),e),D0=({state:e},t)=>(qr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}}),e),T0=({state:e},t)=>qr(e,"skipUnseenText",t?.value),L0=({state:e},t)=>qr(e,"skipTransitionsAndAnimations",t?.value),M0=({state:e},t)=>qr(e,"soundVolume",t?.value),q0=({state:e},t)=>qr(e,"musicVolume",t?.value),V0=({state:e},t)=>qr(e,"muteAll",t?.value),sa=({state:e,rollbackActionBatchStack:t},s)=>yn(e,"saveLoadPagination",s?.value,"setSaveLoadPagination",t),ia=({state:e,rollbackActionBatchStack:t})=>{let s=tr(e,"saveLoadPagination")+1;return yn(e,"saveLoadPagination",s,"incrementSaveLoadPagination",t),e},oa=({state:e,rollbackActionBatchStack:t})=>{let s=tr(e,"saveLoadPagination")-1;return yn(e,"saveLoadPagination",s,"decrementSaveLoadPagination",t),e},aa=({state:e,rollbackActionBatchStack:t},s)=>yn(e,"menuPage",s?.value,"setMenuPage",t),la=({state:e,rollbackActionBatchStack:t},s)=>yn(e,"menuEntryPoint",s?.value,"setMenuEntryPoint",t),F0=({state:e})=>(e.global.pendingEffects=[],e),B0=({state:e},t)=>(e.global.pendingEffects.push(t),e),U0=({state:e},t)=>{if(ye(e))return e;let s=t?.resourceId;return Ju(e,s),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:s}}),e},Y0=({state:e},t)=>{if(ye(e))return e;let s=t?.resourceId,o=Ju(e,s);if(o.type!=="number")throw new Error(`Achievement resource "${s}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${s}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${s}" must have a positive integer target`);let r=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:s,current:r,target:o.target,completed:r>=o.target}}),e},Vp=e=>e?.lines?.[0],Fp=(e,{sectionId:t,resetStoryState:s=!1,screen:o})=>{let a=!!fp(o),r=xe({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let n=Vp(r);if(!n)return console.warn(`Section ${t} has no lines`),e;if(s&&!Mw(e,{queueRender:!a}))return e;let i=Se({state:e});s&&e.global.skipMode&&Tr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=_t(l),p=u.read;s||tt(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Mr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:n.id},s?l.rollback=ln({pointer:u.read}):ks(e,{sectionId:t,lineId:n.id})}let{activeInteraction:c}=dn(e,l?.pointers?.read,{screenTransition:o});return As(e,i,c),e},z0=({state:e},t)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return Fp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Bp=e=>(e.global.accountViewedRegistry=Jb(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Es=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(s=>({scope:s.scope,path:s.path,op:s.op,value:V(s.value)}))}})},Up=(e,t)=>{Es(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(s=>({sectionId:s.sectionId,...s.lastLineId===void 0?{}:{lineId:s.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},X0=(e,t,{sectionId:s,lineId:o})=>{if(!s||!o)return!1;let a=q(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(n=>n.sectionId===s);if(r){if(r.lastLineId===void 0)return!1;let n=xe({state:e},{sectionId:s});if(n?.lines){let i=n.lines.findIndex(c=>c.id===r.lastLineId),l=n.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:s,lastLineId:o}),!0},tt=(e,t)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;X0(e,Bp(e),t)&&Up(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},G0=({state:e},t)=>(tt(e,t),e.global.pendingEffects.push({name:"render"}),e),H0=({state:e},t)=>{if(ye(e))return e;let{resourceId:s}=t;if(e.global.accountViewedRegistry!==void 0){let o=Bp(e);o.resources.find(r=>r.resourceId===s)||(o.resources.push({resourceId:s}),Up(e,{sections:[],resources:[{resourceId:s}]}))}return e.global.pendingEffects.push({name:"render"}),e},ir=(e,t,s)=>{if(!q(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!s.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},ca=(e,t,s)=>{if(typeof s!="string"||s.length===0)throw new Error(`${e} requires a non-empty ${t}`)},xs=(e,t)=>{let s=e.global.imageGalleryNavigation;s.groupId===t.groupId&&s.variantId===t.variantId&&s.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},K0=({state:e},t)=>{let s="showImageGalleryVariant";ir(s,t,Yb),ca(s,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&ca(s,"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 n=t.variantId===void 0?r.variants[0]:r.variants.find(i=>i.id===t.variantId);return!n||an(e,n)||xs(e,{groupId:r.id,variantId:n.id,pageIndex:Math.floor(a/o.pageSize)}),e},Yp=(e,t,s,o)=>{ir(o,t,pa);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 n=a.groups.find(c=>c.id===r.groupId),i=n?.variants.findIndex(c=>c.id===r.variantId);if(!n||i===void 0||i<0)return e;let l=ta(e,n.variants,i,s);return l&&xs(e,{...r,variantId:l.id}),e},W0=({state:e},t)=>Yp(e,t,-1,"moveToPreviousImageGalleryVariant"),J0=({state:e},t)=>Yp(e,t,1,"moveToNextImageGalleryVariant"),Q0=({state:e},t)=>{if(ir("clearImageGallerySelection",t,pa),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return xs(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},zp=(e,t)=>{let s=e.projectData?.resources?.imageGallery;if(s===void 0)return e;let o=Ea(s);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=xa(s,a);return t===r||xs(e,{groupId:null,variantId:null,pageIndex:t}),e},Z0=({state:e},t)=>{if(ir("moveToImageGalleryPage",t,zb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return zp(e,t.pageIndex)},Xp=(e,t,s,o)=>{ir(o,t,pa);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let n=xa(a,e.global.imageGalleryNavigation)+s;return n<0?e:zp(e,n)},eI=({state:e},t)=>Xp(e,t,1,"moveToNextImageGalleryPage"),rI=({state:e},t)=>Xp(e,t,-1,"moveToPreviousImageGalleryPage"),Ir=(e,t,s)=>{if(!q(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!s.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},tI=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},er=e=>{e.global.pendingEffects.push({name:"render"})},Gp=(e,t)=>{let s=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,r=o.trackId===t.id,n=o.bgmPlayback;a||(n={commandId:vs(e),operation:"pause"});let i=un(e,"play",0),l=s.tracks.indexOf(t),c=r?o.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/s.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:n},er(e)},nI=({state:e},t)=>{let s="playMusicRoomTrack";Ir(s,t,Xb),tI(s,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Sa(e,a)||Gp(e,a),e},sI=({state:e},t)=>{Ir("playMusicRoom",t,Rt);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",r=o.readiness==="error",n=o.status==="paused"&&!r?"resume":"play",i=a?0:o.positionMs;return o.playback=un(e,n,n==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),er(e),e},iI=({state:e},t)=>{Ir("pauseMusicRoom",t,Rt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=un(e,"pause"),o.seekFallback=null,o.status="paused",er(e)),e},oI=({state:e},t)=>{Ir("stopMusicRoom",t,Rt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=un(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,er(e)),e},aI=({state:e},t)=>{if(Ir("seekMusicRoom",t,Gb),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=un(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"),er(e),e},Hp=(e,t,s,o)=>{Ir(o,t,Rt);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let n=a.tracks.findIndex(l=>l.id===r.trackId);if(n<0)return e;let i=na(e,a.tracks,n,s);return i&&Gp(e,i),e},lI=({state:e},t)=>Hp(e,t,-1,"playPreviousMusicRoomTrack"),cI=({state:e},t)=>Hp(e,t,1,"playNextMusicRoomTrack"),uI=({state:e},t)=>{Ir("clearMusicRoomSelection",t,Rt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:vs(e),operation:"resume"};return e.global.musicRoomPlayer={...Is({bgmPlayback:r}),pageIndex:a},er(e),e},Kp=(e,t)=>{let s=e.projectData?.resources?.musicRoom;if(!s||t>=Oa(s))return e;let o=e.global.musicRoomPlayer,a=Ra(s,o);return t===a||(o.pageIndex=t,er(e)),e},pI=({state:e},t)=>{if(Ir("moveToMusicRoomPage",t,Hb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Kp(e,t.pageIndex)},Wp=(e,t,s,o)=>{Ir(o,t,Rt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Ra(a,e.global.musicRoomPlayer)+s;return r<0?e:Kp(e,r)},fI=({state:e},t)=>Wp(e,t,1,"moveToNextMusicRoomPage"),dI=({state:e},t)=>Wp(e,t,-1,"moveToPreviousMusicRoomPage"),rt=e=>{let t=ye(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let s=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(),Dw(e,s),e.global.pendingEffects.push({name:"render"}),!0},mI=({state:e},t)=>{let s="startSceneReplay";if(ir(s,t,Kb),ca(s,"sceneId",t.sceneId),ye(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!Op(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],n=r?.initialSectionId,i=r?.sections?.[n],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=jw(e);Nw(e);let u=ka({pointer:{sceneId:a.sceneId,sectionId:n,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return gp(e,u),e.contexts.push(u),dn(e,u.pointers.read),e},Jp=({state:e},t)=>{ir("finishSceneReplay",t,fa);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Lr(e)?.rollback?.isRestoring===!0)return e;let r=Ve({state:e})?.pointer,{sceneId:n}=br(e.projectData,r?.sectionId);return!(typeof n=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===n))||(e.global.accountReplayRegistry=Qb(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(n))||(e.global.accountReplayRegistry.sceneIds.push(n),Es(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[n]}}]),e.global.pendingEffects.push({name:"render"})),e},yI=({state:e},t)=>(ir("exitSceneReplay",t,fa),rt(e),e),Qp=(e,t)=>{let s=e.projectData?.resources?.sceneReplay;if(!s||t>=$a(s))return e;let o=Ca(s,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},hI=({state:e},t)=>{if(ir("moveToSceneReplayPage",t,Wb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Qp(e,t.pageIndex)},Zp=(e,t,s,o)=>{ir(o,t,fa);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Ca(a,e.global.sceneReplayNavigation)+s;return r<0?e:Qp(e,r)},gI=({state:e},t)=>Zp(e,t,1,"moveToNextSceneReplayPage"),bI=({state:e},t)=>Zp(e,t,-1,"moveToPreviousSceneReplayPage"),Ss=(e,t)=>{let s=e.global.musicRoomPlayer;return!q(t)||t.id!==Bb||s.trackId===null||!s.playback||t.commandId!==s.playback.commandId?null:s},Ta=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,ef=(e,t,s,{readiness:o=t.readiness}={})=>((t.readiness!==o||t.positionMs!==s.positionMs||t.durationMs!==s.durationMs||t.seekFallback!==null)&&(t.readiness=o,t.positionMs=s.positionMs,t.durationMs=s.durationMs,t.seekFallback=null,er(e)),e),wI=({state:e},t)=>{let s=Ss(e,t);return!s||s.readiness!=="loading"||!Ta(t)?e:ef(e,s,t,{readiness:"ready"})},II=({state:e},t)=>{let s=Ss(e,t);return!s||s.readiness!=="ready"||!Ta(t)||s.status==="stopped"&&t.positionMs!==0||s.status==="ended"&&t.positionMs!==t.durationMs?e:ef(e,s,t)},vI=({state:e},t)=>{let s=Ss(e,t);return!s||s.readiness!=="ready"||s.status!=="playing"||!Ta(t)||t.positionMs!==t.durationMs||(s.status="ended",s.positionMs=t.positionMs,s.durationMs=t.durationMs,s.seekFallback=null,er(e)),e},kI=({state:e},t)=>{let s=Ss(e,t);if(!s||typeof t.errorCode!="string"||!Ub.has(t.errorCode)||s.readiness==="error"&&s.status==="stopped")return e;if(t.errorCode==="invalid-position"){let o=s.seekFallback;if(s.playback.operation!=="seek"||o?.commandId!==t.commandId)return e;let a=s.status!==o.status||s.positionMs!==o.positionMs;return s.status=o.status,s.positionMs=o.positionMs,s.seekFallback=null,a&&er(e),e}return s.readiness="error",s.status="stopped",s.positionMs=0,s.seekFallback=null,er(e),e},rf=({state:e,rollbackActionBatchStack:t},s)=>{let o=sw(s.manual),{auto:a,applyMode:r}=s,n=e.global.nextLineConfig.auto?.enabled,i=e.global.nextLineConfig.auto?.trigger,l=e.global.nextLineConfig.auto?.delay,c=e.global.nextLineConfig?.applyMode,u=e.contexts?.[e.contexts.length-1]?.rollback?.isRestoring===!0;o&&a?(e.global.nextLineConfig={manual:o,auto:a},r!==void 0?e.global.nextLineConfig.applyMode=r:c!==void 0&&(e.global.nextLineConfig.applyMode=c)):(o&&(e.global.nextLineConfig.manual=o),a&&(e.global.nextLineConfig.auto=a),r!==void 0&&(e.global.nextLineConfig.applyMode=r));let p=e.global.nextLineConfig.auto?.enabled,m=e.global.nextLineConfig.auto?.trigger,f=e.global.nextLineConfig.auto?.delay,d=Se({state:e});return!u&&(a!==void 0&&(p!==n||m!==i||f!==l))&&(!d&&p===!0&&(m==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:f}}):n===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),sr(e,"setNextLineConfig",s,t),e},AI=({state:e},t)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let s=t?.slotId;Qu(s,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=nt(s),n=V(e.contexts);n?.forEach(c=>{_t(c),wp(c.rollback),cw(c.rollback,e.projectData)});let i={contexts:n},l={formatVersion:Ku,slotId:np(s),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},PI=({state:e},t)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let s=t?.slotId;Qu(s,"loadSlot");let o=nt(s),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=vw(a,e.projectData);e.contexts=r.state.contexts,e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,$t(e),Ct(e),ya(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},EI=({state:e},t)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:s}=t;tp(s),Yt(s),zt(s),Xt(s),Wr(s?.resources?.variables??{}),ko(s);let o=dw(s),a=o?e.contexts?.map((n,i)=>pp(V(n),s,i)):void 0,r=o?uw(e.global.saveSlots,s):void 0;if(e.projectData=s,e.global.imageGalleryNavigation=ua(),e.global.sceneReplayNavigation=da(),ya(e),o){let n=s?.resources?.variables??{},{globalVariablesDefaultValues:i}=Wn(s??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Gt(e.global.variables,n,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return $t(e),Ct(e),o&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},xI=({state:e},t)=>{let{l10nId:s,projectData:o}=t??{};if(s!==null&&(typeof s!="string"||s.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,va(e,"localizationPackageId",s),bp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},SI=({state:e},t)=>{let{sectionId:s,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=s||a.pointers.read?.sectionId;if(s&&!xe({state:e},{sectionId:s}))return console.warn(`Section not found: ${s}`),e;let n=xe({state:e},{sectionId:r});if(!n?.lines||!Array.isArray(n.lines))return console.warn(`Section ${r} has no lines`),e;if(!n.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${r}`),e;let l=Se({state:e}),c=_t(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=dn(e,c.read);return As(e,l,u),e},OI=({state:e,rollbackActionBatchStack:t},s)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Ps({state:e,rollbackActionBatchStack:t}),e;let o=Se({state:e});if(o?.source===Ot&&s?.bypassChoice!==!0||o?.source===Dr&&s?._interactionSource!==Dr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return rt(e),e;let f=Ve({state:e})?.pointer,d=f?.sectionId,g=f?.lineId;d&&g&&tt(e,{sectionId:d,lineId:g}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}});let b=e.global.nextLineConfig,y=xe({state:e},{sectionId:d});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===g?ea(e):b?.auto?.enabled&&!o&&b.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:b.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ye(e)?.sceneReplay.finishOnNextAdvance)return rt(e),e;let r=Ve({state:e})?.pointer,n=r?.sectionId,i=xe({state:e},{sectionId:n}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(m=>m.id===r?.lineId)+1;if(p<c.length){let m=c[p],f=!tr(e,"skipUnseenText");if(e.global.skipMode&&f&&!Pa({state:e},{sectionId:n,lineId:m.id}))return Tr({state:e}),e;if(l&&!l.rollback&&Mr(l,{compatibilityAnchor:!0}),l){let g=_t(l),b=g.read?.lineId;b&&n&&tt(e,{sectionId:n,lineId:b}),g.read={sectionId:n,lineId:m.id}}ks(e,{sectionId:n,lineId:m.id}),ma(e);let{activeInteraction:d}=dn(e,{sectionId:n,lineId:m.id});As(e,o,d)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),rt(e),e;e.global.autoMode&&mn({state:e}),e.global.skipMode&&Tr({state:e}),ea(e)}return e},RI=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return rt(e),e;let s=Se({state:e});e.global.autoMode&&!s&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}});let o=Ve({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&tt(e,{sectionId:a,lineId:r});let n=e.global.nextLineConfig;return n?.auto?.enabled&&!s&&n.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:n.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},$I=({state:e},t)=>Fp(e,{sectionId:t?.sectionId,screen:t?.screen}),CI=({state:e,rollbackActionBatchStack:t},s)=>{let o=s?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return Ps({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:wr({state:e})}}),e;let a=Se({state:e});if(a?.source===Ot&&s?.bypassChoice!==!0||a?.source===Dr&&s?._interactionSource!==Dr||a&&a.source!==Ot&&a.source!==Dr)return e;let r=ye(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(rt(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let n=Ve({state:e})?.pointer,i=n?.sectionId,l=xe({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],m=u.findIndex(f=>f.id===n?.lineId)+1;if(m<u.length){let f=u[m],d=!tr(e,"skipUnseenText");if(e.global.skipMode&&d&&!Pa({state:e},{sectionId:i,lineId:f.id})&&(Tr({state:e}),!o))return e;if(c&&!c.rollback&&Mr(c,{compatibilityAnchor:!0}),c){let b=_t(c),y=b.read?.lineId;y&&i&&tt(e,{sectionId:i,lineId:y}),b.read={sectionId:i,lineId:f.id}}ks(e,{sectionId:i,lineId:f.id}),ma(e);let{activeInteraction:g}=dn(e,{sectionId:i,lineId:f.id});As(e,a,g)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),rt(e),e;e.global.autoMode&&mn({state:e}),e.global.skipMode&&Tr({state:e}),ea(e)}return e},La=(e,t={})=>{let s=pn({state:e});return!s||t.formKey&&t.formKey!==s.key||t.formId&&t.formId!==s.id?null:s},_I=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let s=e.projectData.resources?.variables?.[t.variableId],o=s?.scope,a=s?.type;if(_e(s))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(s?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Ht(o,t.variableId),Kt(a,"set",t.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:s,scope:o}},jI=(e,t)=>({id:e.id,key:e.key,valid:!0,values:V(t),fields:V(e.fields),fieldList:V(e.fieldList)}),NI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=Ve({state:e})?.pointer,s=t?.sectionId,o=t?.lineId;s&&o&&tt(e,{sectionId:s,lineId:o})},DI=({state:e},t={})=>{let s=La(e,t),o=t.field;if(!s?.fields?.[o])return e;let a=mp(e,s.key),r=bs(t.value),n=s.fields[o],i=wa(n,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},TI=({state:e,rollbackActionBatchStack:t},s={})=>{let o=La(e,s);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=mp(e,o.key);a.submitted=!0;let r={},n={};if(Object.entries(o.fields).forEach(([m,f])=>{let d=Object.prototype.hasOwnProperty.call(a.values,m)?a.values[m]:f.value,g=wa(f,d);a.touched[m]=!0,g&&(n[m]=g),r[m]=dp(f,d)}),a.errors=n,Object.keys(n).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:V(n),form:{id:o.id,key:o.key,values:V(r)}};let i=e.contexts[e.contexts.length-1];if(i?.rollback?.isRestoring)return{submitted:!1,valid:!1,reason:"restoring"};let l=!1,c=[],u=[];Object.entries(o.fields).forEach(([m,f])=>{let{scope:d}=_I(e,f),g=d==="context"?i.variables:e.global.variables,b=r[m];g[f.variableId]=Qn(g[f.variableId],"set",b),d==="context"&&(l=!0,u.push({variableId:f.variableId,op:"set",value:b})),(d==="device"||d==="account")&&c.push({scope:d,path:`variables.${f.variableId}`,op:"set",value:V(g[f.variableId])})}),l&&sr(e,"updateVariable",{id:"submitForm",operations:u},t),Es(e,c);let p=jI(o,r);return NI(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},LI=({state:e},t={})=>{let s=La(e,t);return s?(delete e.global.formDrafts?.[s.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:s.id,key:s.key,values:V(s.values),fields:V(s.fields),fieldList:V(s.fieldList)}}):{cancelled:!1,reason:"inactive"}},MI=({state:e,rollbackActionBatchStack:t},s)=>{let{id:o,operations:a=[]}=s;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 n=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:m})=>{let f=e.projectData.resources?.variables?.[c],d=f?.scope,g=f?.type;if(_e(f))throw new Error(`Cannot update computed variable: ${c}`);if(f?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Ht(d,c),Kt(g,u,c),Jn(g,u,p,c,{roundTo:m}),ye(e)&&d!=="context")throw new Error(`Cannot update ${d}-scoped variable "${c}" while a scene replay is active`);let b=d==="context"?r.variables:e.global.variables;if(d==="context"){n=!0;let y={variableId:c,op:u,value:p};m!==void 0&&(y.roundTo=m),l.push(y)}b[c]=Qn(b[c],u,p,{roundTo:m}),(d==="device"||d==="account")&&i.push({scope:d,path:`variables.${c}`,op:"set",value:V(b[c])})}),n&&sr(e,"updateVariable",{id:o,operations:l},t),Es(e,i),e.global.pendingEffects.push({name:"render"}),e},He=e=>(t,s)=>e({state:t},s),tf=e=>({variables:bt({variables:{...e.global?.variables??{},...Lr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Cr(e)}),qI=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")},VI=(e,t,s)=>{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!==s-1)throw new Error("conditional else branch must be the last branch")},FI=(e,t,s,o)=>{qI(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(VI(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Ut(r.when,{...tf(e),...s?.bindings??{}}))){Ma(e,r.actions,s,[...o,"branches",String(a),"actions"]);return}}},BI=(e,t,s,o)=>{let a=s?.checkpoint;if(a?.randomOutcomeVersion!==gr)return;let r=o.join("."),n=s.randomOutcomeOrdinals,i=n.get(r)??0;n.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=rs(V(l.result),l.type);if(c.type==="integer"){if(!op(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}`);ra(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}`);Ma(e,u,s,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},UI={conditional:{replayLine:FI},random:{replayLine:BI},updateVariable:{recordSources:[Nr],replayLine:ra,replayRecorded:ra,persistInSaveSlot:!0},setNextLineConfig:{replayLine:He(rf)},setSaveLoadPagination:{recordSources:[Nr],replayLine:He(sa),replayRecorded:He(sa),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[Nr],replayLine:He(ia),replayRecorded:He(ia),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[Nr],replayLine:He(oa),replayRecorded:He(oa),persistInSaveSlot:!0},setMenuPage:{recordSources:[Nr],replayLine:He(aa),replayRecorded:He(aa),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[Nr],replayLine:He(la),replayRecorded:He(la),persistInSaveSlot:!0},finishSceneReplay:{replayLine:He(Jp)}},Os=e=>UI[e]??null,YI=e=>Os(e)?.persistInSaveSlot===!0,zI=(e,t)=>{let s=Os(e)?.recordSources;return Array.isArray(s)&&s.includes(t)},XI=(e,t,s)=>{Os(t)?.replayRecorded?.(e,s)},GI=(e,t,s,o,a)=>{let r=Os(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,s,o,a);return}let n=o?.bindings??{},i=Wt({[t]:s},{...tf(e),...n})[t];r.replayLine(e,i)},Ma=(e,t,s,o)=>{let a=ts(t);ss(a);for(let[r,n]of a)GI(e,r,n,s,[...o,r])},HI=e=>e?.returnable!==!1,nf=(e,t)=>{if(t>=0)return e.currentIndex+t;let s=Math.abs(t);for(let o=e.currentIndex-1;o>=0;o-=1)if(HI(e.timeline[o])&&(s-=1,s===0))return o;return-1},sf=({state:e},t)=>{let{offset:s}=t;if(s===void 0||typeof s!="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=nf(a,s);if(r<0||r>=a.timeline.length)return null;let n=a.timeline[r];return{sectionId:n.sectionId,lineId:n.lineId}},of=({state:e})=>sf({state:e},{offset:-1})!==null,KI=({state:e},t)=>{let{offset:s=-1}=t;if(s>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=Mr(o,{compatibilityAnchor:!o.rollback}),r=nf(a,s);return r<0||r>=a.timeline.length?e:vp(e,r)},WI=({state:e},t)=>{let{sectionId:s,lineId:o}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=Mr(a,{compatibilityAnchor:!a.rollback}),i=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===s&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${s} rollback timeline`);return i===r.currentIndex?e:vp(e,i)},JI=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),Zo=(e,t)=>{let s=e[t];if(!Number.isSafeInteger(s)||s<0)throw new RangeError(`Internal playback ${t} is invalid`);if(s===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=s+1,e[t]},Gu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Hu=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},QI=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,af=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}},qa=e=>JSON.stringify(af(e)),ZI=({actionName:e,args:t,state:s,previousState:o})=>{let a=Gu(o),r=Gu(s);if(!QI(a,r)||o.contexts?.length!==s.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Hu(o)!==Hu(s))return!0;let n=t[0]??{};if(e==="jumpToLine"){let i=n.sectionId??a?.sectionId;return typeof n.lineId=="string"&&r?.sectionId===i&&r?.lineId===n.lineId&&s.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=br(s.projectData,n.sectionId).section,l=Vp(i)?.id;return typeof l=="string"&&r?.sectionId===n.sectionId&&r?.lineId===l&&s.global.isLineCompleted===!1}if(e==="loadSlot"){let i=n.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},nt(i))}return!1},ev=({actionName:e,args:t,state:s,transactionalMetadata:o,previousState:a})=>{if(ZI({actionName:e,args:t,state:s,previousState:a})){let u=Zo(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:qa(s)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let n=(a.contexts?.length??0)>(s.contexts?.length??0),i=e==="startAutoMode"||e==="startSkipMode"?Se({state:a}):null;s.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||n&&a.global.autoMode!==!0)&&Zo(o,"autoSessionId"),s.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||n&&a.global.skipMode!==!0)&&Zo(o,"skipSessionId")},rv=({state:e,transactionalMetadata:t})=>{let s=t.rollbackAuthoredSuppression;s&&(s.lineEntryId!==t.lineEntryId||s.configKey!==qa(e))&&(t.rollbackAuthoredSuppression=null)},tv=({state:e,playbackOwnership:t})=>{let s=Se({state:e}),o=t.lineEntryId,a=!s&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!s&&e.global.skipMode===!0,n=af(e),i=t.rollbackAuthoredSuppression,l=!s&&n.enabled&&(n.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===qa(e)),c=a?Dp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:Qo({text:c,baseDelay:tr(e,"autoForwardDelay"),speed:tr(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:n.delayMs,trigger:n.trigger}:null}},nv=({playbackOwnership:e})=>e.lineEntryId,lf=(e,t={})=>{let s=Kw(e),o=[],a=t.createPlaybackOwnership??JI;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return Kl(s,{selectPendingEffects:Jw,selectSkipMode:kp,selectAutoMode:Qw,selectIsChoiceVisible:Cp,selectIsFormVisible:t0,selectActiveInteraction:Se,selectActiveForm:pn,selectDialogueUIHidden:Ap,selectDialogueHistory:Pp,selectConfirmDialog:r0,selectIsLineAccountViewed:Pa,selectIsResourceAccountViewed:s0,selectImageGalleryConfig:i0,selectImageGallery:Ep,selectMusicRoomConfig:a0,selectMusicRoom:Sp,selectSceneReplayConfig:l0,selectSceneReplay:Rp,selectIsSceneReplayActive:c0,selectActiveSceneReplayEntry:u0,selectNextLineConfig:p0,selectSystemState:f0,selectAchievements:d0,selectAchievement:m0,selectSaveSlotMap:_p,selectSaveSlots:I0,selectSaveSlot:y0,selectLocalizationPackages:jp,selectRuntime:_a,selectRuntimeValue:h0,selectAllVariables:ja,selectCurrentPointer:Ve,selectSection:xe,selectCurrentLine:fn,selectPresentationState:Np,selectAutoForwardTimerDelay:wr,selectPresentationChanges:g0,selectSectionLineChanges:w0,selectSaveSlotPage:Na,selectCurrentPageSlots:v0,selectRenderState:k0,selectOverlayStack:Ww,selectLineIdByOffset:sf,selectCanRollback:of,selectRollbackCursor:Vw,selectDesiredPlaybackTimers:tv,selectPlaybackLineEntryId:nv,startAutoMode:Lp,stopAutoMode:mn,toggleAutoMode:$0,startSkipMode:Mp,stopSkipMode:Tr,toggleSkipMode:C0,showDialogueUI:Ps,hideDialogueUI:qp,toggleDialogueUI:_0,setDialogueTextSpeed:j0,setAutoForwardDelay:N0,setAutoForwardSpeed:D0,setSkipUnseenText:T0,setSkipTransitionsAndAnimations:L0,setSoundVolume:M0,setMusicVolume:q0,setMuteAll:V0,setSaveLoadPagination:sa,incrementSaveLoadPagination:ia,decrementSaveLoadPagination:oa,setMenuPage:aa,setMenuEntryPoint:la,showConfirmDialog:A0,hideConfirmDialog:P0,resetStoryAtSection:z0,clearPendingEffects:F0,appendPendingEffect:B0,completeAchievement:U0,setAchievementProgress:Y0,beginRollbackActionBatch:Uw,endRollbackActionBatch:Yw,ensureRandomReplayOccurrence:zw,recordRandomOutcome:Xw,markRollbackCheckpointTransient:Fw,markSavedRollbackCheckpointTransient:Bw,recordCurrentDialogueHistory:e0,addViewedLine:G0,addViewedResource:H0,showImageGalleryVariant:K0,moveToPreviousImageGalleryVariant:W0,moveToNextImageGalleryVariant:J0,clearImageGallerySelection:Q0,moveToImageGalleryPage:Z0,moveToNextImageGalleryPage:eI,moveToPreviousImageGalleryPage:rI,playMusicRoomTrack:nI,playMusicRoom:sI,pauseMusicRoom:iI,stopMusicRoom:oI,seekMusicRoom:aI,playPreviousMusicRoomTrack:lI,playNextMusicRoomTrack:cI,clearMusicRoomSelection:uI,moveToMusicRoomPage:pI,moveToNextMusicRoomPage:fI,moveToPreviousMusicRoomPage:dI,musicRoomSoundReady:wI,musicRoomSoundProgress:II,musicRoomSoundComplete:vI,musicRoomSoundError:kI,startSceneReplay:mI,finishSceneReplay:Jp,exitSceneReplay:yI,moveToSceneReplayPage:hI,moveToNextSceneReplayPage:gI,moveToPreviousSceneReplayPage:bI,setNextLineConfig:rf,saveSlot:AI,loadSlot:PI,updateProjectData:EI,updateLocalizationPackage:xI,sectionTransition:$I,jumpToLine:SI,nextLine:OI,markLineCompleted:RI,rollbackToLine:WI,rollbackByOffset:KI,pushOverlay:E0,popOverlay:x0,replaceLastOverlay:S0,clearOverlays:O0,updateFormField:DI,submitForm:TI,cancelForm:LI,updateVariable:MI,nextLineFromSystem:CI},{createTransactionalMetadata:a,updateTransactionalMetadata:ev,finalizeTransactionalMetadata:rv,transformActionFirstArgument:(n,i)=>({state:n,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(n,i)=>({state:n,playbackOwnership:i})})};var sv="route-engine",iv="projectPersistence";var uf=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),be=e=>Object.prototype.toString.call(e)==="[object Object]",cf="variables.",ov=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(s=>typeof s=="string"||typeof s=="number"?{sectionId:String(s)}:!be(s)||typeof s.sectionId!="string"||s.sectionId.length===0?null:{sectionId:s.sectionId,...typeof s.lineId=="string"?{lineId:s.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(s=>typeof s=="string"||typeof s=="number"?{resourceId:String(s)}:!be(s)||typeof s.resourceId!="string"||s.resourceId.length===0?null:{resourceId:s.resourceId}).filter(Boolean)}},av=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(s=>typeof s=="string"||typeof s=="number"?{sectionId:String(s)}:!be(s)||typeof s.sectionId!="string"||s.sectionId.length===0?null:{sectionId:s.sectionId,...typeof s.lastLineId=="string"?{lastLineId:s.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(s=>typeof s=="string"||typeof s=="number"?{resourceId:String(s)}:!be(s)||typeof s.resourceId!="string"||s.resourceId.length===0?null:{resourceId:s.resourceId}).filter(Boolean)}},lv=(e,t)=>{let s=av(e),o=ov(t),a=s.sections.map(n=>({...n})),r=s.resources.map(n=>({...n}));return o.sections.forEach(n=>{let i=a.find(l=>l.sectionId===n.sectionId);if(!i){a.push({sectionId:n.sectionId,...n.lineId===void 0?{}:{lastLineId:n.lineId}});return}if(i.lastLineId!==void 0){if(n.lineId===void 0){delete i.lastLineId;return}i.lastLineId=n.lineId}}),o.resources.forEach(n=>{r.find(l=>l.resourceId===n.resourceId)||r.push({...n})}),{sections:a,resources:r}},cv=(e={})=>{let t=be(e)?e:{},s=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(s.filter(o=>typeof o=="string"&&o.length>0))]}},uv=(e,t)=>{let s=cv(e),o=be(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...s.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},pf=(e={})=>{let t=be(e)?e:{};return{saveSlots:be(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:be(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:be(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:be(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:be(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:be(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},pv=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,s)=>{if(!be(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${s}] entry.`);let o=t.path?.startsWith(cf)?t.path.slice(cf.length):null;if(o!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${s}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);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[${s}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);if(!be(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[${s}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${s}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${s}].`)})},fv=(e,t)=>{let s={};return pv(t).forEach(o=>{if(o.path==="viewedRegistry"){s.accountViewedRegistry=lv(s.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){s.accountReplayRegistry=uv(s.accountReplayRegistry??e.accountReplayRegistry,o.value);return}let a=o.scope==="device"?"globalDeviceVariables":"globalAccountVariables";s[a]={...e[a],...s[a],[o.variableId]:o.value}}),s},jt=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},dv=e=>{let t=jt(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},mv=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},yv=({indexedDB:e,databaseName:t,objectStoreName:s})=>new Promise((o,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let n=r.result;n.objectStoreNames.contains(s)||n.createObjectStore(s,{keyPath:"namespace"})},r.onsuccess=()=>{o(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),hv=async({databasePromise:e,objectStoreName:t,namespace:s})=>{let o=await e;return new Promise((a,r)=>{let l=o.transaction(t,"readonly").objectStore(t).get(s);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${s}" from IndexedDB.`))}})},hn=async({databasePromise:e,objectStoreName:t,namespace:s,patch:o})=>{let a=await e;return new Promise((r,n)=>{let i=a.transaction(t,"readwrite"),l=i.objectStore(t),c=l.get(s),u=!1,p=f=>{u||(u=!0,n(f))},m=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${s}" before updating IndexedDB.`))},c.onsuccess=()=>{let f=pf(c.result),d=typeof o=="function"?o(f):o,g={namespace:s,version:1,...uf(),...f,...d},b=l.put(g);b.onerror=()=>{p(b.error??new Error(`Failed to persist namespace "${s}" to IndexedDB.`))}},i.oncomplete=()=>{m()},i.onerror=()=>{p(i.error??new Error(`IndexedDB transaction failed while updating namespace "${s}".`))},i.onabort=()=>{p(i.error??new Error(`IndexedDB transaction aborted while updating namespace "${s}".`))}})},gv=async({databasePromise:e,objectStoreName:t,namespace:s})=>{let o=await e;return new Promise((a,r)=>{let n=o.transaction(t,"readwrite"),l=n.objectStore(t).delete(s),c=!1,u=m=>{c||(c=!0,r(m))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${s}" from IndexedDB.`))},n.oncomplete=()=>{p()},n.onerror=()=>{u(n.error??new Error(`IndexedDB transaction failed while clearing namespace "${s}".`))},n.onabort=()=>{u(n.error??new Error(`IndexedDB transaction aborted while clearing namespace "${s}".`))}})},Va=(e={})=>{let{indexedDB:t,databaseName:s=sv,objectStoreName:o=iv,namespace:a}=e,r=mv(t),n=dv(a),i=yv({indexedDB:r,databaseName:s,objectStoreName:o});return{namespace:n,load:async()=>{let l=await hv({databasePromise:i,objectStoreName:o,namespace:n});return{...uf(),...pf(l)}},clear:async()=>gv({databasePromise:i,objectStoreName:o,namespace:n}),saveSlots:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{saveSlots:be(l)?l:{}}}),saveGlobalDeviceVariables:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{globalDeviceVariables:be(l)?l:{}}}),saveGlobalAccountVariables:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{globalAccountVariables:be(l)?l:{}}}),saveGlobalRuntime:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{globalRuntime:be(l)?l:{}}}),applyScopedDataUpdates:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:c=>fv(c,l)})}},bv=Va;var Af=Pf;var wv={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ke=Object.prototype.hasOwnProperty,Iv={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 Fe(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;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),n++}var u=c===n;if(l=l||u,!l){let p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[f]:r.push(f),n++}if(e.y===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[f]:r.push(f),n++}for(let f in e)if(!(f==="x"||f==="y"||f==="quality"||f==="kernelSize"||f==="repeatEdgePixels")){let d={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),n++}if(e.x!==void 0){let f=e.x;if(typeof f=="number"){if(f<0||isNaN(f)){let d={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t+"/x",schemaPath:"#/anyOf/1/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),n++}}if(e.y!==void 0){let f=e.y;if(typeof f=="number"){if(f<0||isNaN(f)){let d={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t+"/y",schemaPath:"#/anyOf/1/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),n++}}if(e.quality!==void 0){let f=e.quality;if(typeof f=="number"){if(f<1||isNaN(f)){let d={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t+"/quality",schemaPath:"#/anyOf/1/properties/quality/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),n++}}if(e.kernelSize!==void 0){let f=e.kernelSize;if(!(typeof f=="number"&&!(f%1)&&!isNaN(f))){let d={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[d]:r.push(d),n++}if(!(f===5||f===7||f===9||f===11||f===13||f===15)){let d={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Iv.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[d]:r.push(d),n++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let f={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),n++}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}var u=p===n;l=l||u}if(l)n=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),n++}return Fe.errors=r,n===0}var Oe=df().default;function $s(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return $s.errors=r,n===0}function ar(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)$s(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?$s.errors:r.concat($s.errors),n=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),n++}return ar.errors=r,n===0}var vv={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Cs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(!(i==="render"||i==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:vv.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}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),n++}}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Cs.errors=r,n===0}function pe(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}e.playback!==void 0&&(Cs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),n=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),n++}return pe.errors=r,n===0}function _s(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(wv.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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}}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),n++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),e.filters!==void 0&&(ar(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),n=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return _s.errors=r,n===0}function Pf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return _s(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),n=r.length),Pf.errors=r,n===0}var Ef=xf;var mf={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},yf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function js(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return js.errors=r,n===0}function je(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}e.playback!==void 0&&(js(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?js.errors:r.concat(js.errors),n=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),n++}return je.errors=r,n===0}function Ns(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}for(let i in e)if(!Ke.call(yf.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),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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:yf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}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),n++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=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),n++}return Ns.errors=r,n===0}function Ds(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=n;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),n++}}var c=l===n;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),n++}else n=i,r!==null&&(i?r.length=i:r=null);let u=n,p=n;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),n++}}var m=p===n;if(m){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=u,r!==null&&(u?r.length=u:r=null);let f=n,d=!0,g=n;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),n++}}var b=g===n;if(n=f,r!==null&&(f?r.length=f:r=null),b){let y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let h={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[h]:r.push(h),n++}var b=y===n;d=b}if(!d){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),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Ke.call(mf.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),n++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let h=0;h<w;h++)Ns(y[h],{instancePath:t+"/sounds/"+h,parentData:y,parentDataProperty:h,rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),n=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),n++}}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),n++}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),n++}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),n++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:mf.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),n++}}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}e.audioEffects!==void 0&&(je(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=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),n++}return Ds.errors=r,n===0}function xf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ds(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),n=r.length),xf.errors=r,n===0}var Sf=Of;var kv={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ts(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}if(e.items!==void 0){let l=e.items;if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++){let p=l[u],m=n,f=!0,d=n;if(p&&typeof p=="object"&&!Array.isArray(p)){let g;if(p.sprites===void 0&&(g="sprites")){let b={};r===null?r=[b]:r.push(b),n++}}var i=d===n;if(n=m,r!==null&&(m?r.length=m:r=null),i){let g=n;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),n++}var i=g===n;f=i}if(!f){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[g]:r.push(g),n++}for(let g in p)if(!Ke.call(kv.properties.items.items.properties,g)){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),n++}if(p.id!==void 0&&typeof p.id!="string"){let g={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let g={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(p.x!==void 0&&typeof p.x!="number"){let g={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.y!==void 0&&typeof p.y!="number"){let g={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let g={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let g={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let g={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let g={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let g={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),n++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let g={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),n++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let g={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.originX!==void 0&&typeof p.originX!="number"){let g={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.originY!==void 0&&typeof p.originY!="number"){let g={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.alpha!==void 0){let g=p.alpha;if(typeof g=="number"){if(g>1||isNaN(g)){let b={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=[b]:r.push(b),n++}if(g<0||isNaN(g)){let b={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=[b]:r.push(b),n++}}else{let b={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(p.opacity!==void 0){let g=p.opacity;if(typeof g=="number"){if(g>1||isNaN(g)){let b={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=[b]:r.push(b),n++}if(g<0||isNaN(g)){let b={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=[b]:r.push(b),n++}}else{let b={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(p.blur!==void 0&&(Fe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),p.filters!==void 0&&(ar(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),n=r.length)),p.sprites!==void 0){let g=p.sprites;if(Array.isArray(g)){let b=g.length;for(let y=0;y<b;y++){let w=g[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let h in w)if(!(h==="id"||h==="resourceId"||h==="animationName"||h==="animationSpeed"||h==="loop")){let P={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(w.id!==void 0&&typeof w.id!="string"){let h={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=[h]:r.push(h),n++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let h={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=[h]:r.push(h),n++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let h={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=[h]:r.push(h),n++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let h={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=[h]:r.push(h),n++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let h={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=[h]:r.push(h),n++}}else{let h={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=[h]:r.push(h),n++}}}else{let b={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),n++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=r.length))}else{let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),n++}}}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),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return Ts.errors=r,n===0}function Of(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ts(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),n=r.length),Of.errors=r,n===0}var Rf=$f;function Ls(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.items!==void 0){let i=e.items;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++){let u=i[c];if(u&&typeof u=="object"&&!Array.isArray(u)){for(let p in u)if(!(p==="id"||p==="content"||p==="events")){let m={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}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),n++}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),n++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let m=p.click;if(!(m&&typeof m=="object"&&!Array.isArray(m))){let f={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=[f]:r.push(f),n++}}}else{let m={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}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),n++}}}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),n++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Ls.errors=r,n===0}function $f(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ls(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),n=r.length),$f.errors=r,n===0}var Cf=_f;function Ms(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ms.errors=r,n===0}function _f(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ms(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),n=r.length),_f.errors=r,n===0}var jf=Nf;function qs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return qs.errors=r,n===0}function Nf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return qs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),n=r.length),Nf.errors=r,n===0}var Df=Tf;var hf={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 Vs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(hf.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),n++}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),n++}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),n++}i.animations!==void 0&&(pe(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}}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),n++}if(!(i==="adv"||i==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:hf.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}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),n++}}}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),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}if(l.items!==void 0){let c=l.items;if(Array.isArray(c)){let u=c.length;for(let p=0;p<u;p++){let m=c[p];if(m&&typeof m=="object"&&!Array.isArray(m)){if(m.id===void 0){let f={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=[f]:r.push(f),n++}if(m.resourceId===void 0){let f={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=[f]:r.push(f),n++}for(let f in m)if(!(f==="id"||f==="resourceId"||f==="animationName"||f==="animationSpeed"||f==="loop")){let d={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),n++}if(m.id!==void 0&&typeof m.id!="string"){let f={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=[f]:r.push(f),n++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let f={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=[f]:r.push(f),n++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let f={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=[f]:r.push(f),n++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let f={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=[f]:r.push(f),n++}if(m.loop!==void 0&&typeof m.loop!="boolean"){let f={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=[f]:r.push(f),n++}}else{let f={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=[f]:r.push(f),n++}}}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),n++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}}}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),n++}}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Vs.errors=r,n===0}function Tf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Vs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),n=r.length),Tf.errors=r,n===0}var Lf=Mf;function Fs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}}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),n++}}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),n++}}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),n++}}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),n++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Fs.errors=r,n===0}function Mf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Fs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),n=r.length),Mf.errors=r,n===0}var qf=Vf;function Bs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Bs.errors=r,n===0}function Vf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Bs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),n=r.length),Vf.errors=r,n===0}var Ff=Bf;function Us(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}}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),n++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Us.errors=r,n===0}function Bf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Us(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),n=r.length),Bf.errors=r,n===0}var Uf=Yf;var gf={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},bf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function or(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}for(let i in e)if(!Ke.call(bf.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),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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:bf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}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),n++}}e.beginEffect!==void 0&&(je(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=r.length)),e.endEffect!==void 0&&(je(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?je.errors:r.concat(je.errors),n=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),n++}return or.errors=r,n===0}function Ys(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=n;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),n++}}var c=l===n;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),n++}else n=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),n++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)or(u[m],{instancePath:t+"/items/"+m,parentData:u,parentDataProperty:m,rootData:a})||(r=r===null?or.errors:r.concat(or.errors),n=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),n++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++){let f=u[m];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let d={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[d]:r.push(d),n++}if(f.sounds===void 0){let d={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[d]:r.push(d),n++}for(let d in f)if(!(d==="id"||d==="volume"||d==="muted"||d==="pan"||d==="loop"||d==="interruption"||d==="applyMode"||d==="sounds")){let g={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:d},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),n++}if(f.id!==void 0){let d=f.id;if(typeof d=="string"){if(Oe(d)<1){let g={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/channels/"+m+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}}if(f.volume!==void 0){let d=f.volume;if(typeof d=="number"){if(d>100||isNaN(d)){let g={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),n++}if(d<0||isNaN(d)){let g={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/channels/"+m+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}}if(f.muted!==void 0&&typeof f.muted!="boolean"){let d={instancePath:t+"/channels/"+m+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),n++}if(f.pan!==void 0){let d=f.pan;if(typeof d=="number"){if(d>1||isNaN(d)){let g={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),n++}if(d<-1||isNaN(d)){let g={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/channels/"+m+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}}if(f.loop!==void 0&&typeof f.loop!="boolean"){let d={instancePath:t+"/channels/"+m+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[d]:r.push(d),n++}if(f.interruption!==void 0){let d=f.interruption;if(typeof d!="string"){let g={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(!(d==="immediate"||d==="loopEnd")){let g={instancePath:t+"/channels/"+m+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:gf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[g]:r.push(g),n++}}if(f.applyMode!==void 0){let d=f.applyMode;if(typeof d!="string"){let g={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(!(d==="singleLine"||d==="persistent")){let g={instancePath:t+"/channels/"+m+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:gf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[g]:r.push(g),n++}}if(f.sounds!==void 0){let d=f.sounds;if(Array.isArray(d)){let g=d.length;for(let b=0;b<g;b++)or(d[b],{instancePath:t+"/channels/"+m+"/sounds/"+b,parentData:d,parentDataProperty:b,rootData:a})||(r=r===null?or.errors:r.concat(or.errors),n=r.length)}else{let g={instancePath:t+"/channels/"+m+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),n++}}}else{let d={instancePath:t+"/channels/"+m,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),n++}}}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),n++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),n++}return Ys.errors=r,n===0}function Yf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ys(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),n=r.length),Yf.errors=r,n===0}var zf=Xf;var wf={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function zs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;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),n++}var u=c===n;if(l=l||u,!l){let p=n;if(Array.isArray(e)){let f=e.length;for(let d=0;d<f;d++){let g=e[d];if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let b={instancePath:t+"/"+d+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let b={instancePath:t+"/"+d+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(g.furigana!==void 0){let b=g.furigana;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.text!==void 0&&typeof b.text!="string"){let y={instancePath:t+"/"+d+"/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),n++}if(b.textStyleId!==void 0&&typeof b.textStyleId!="string"){let y={instancePath:t+"/"+d+"/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),n++}}else{let y={instancePath:t+"/"+d+"/furigana",schemaPath:"#/anyOf/1/items/properties/furigana/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),n++}}}else{let b={instancePath:t+"/"+d,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),n++}}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),n++}var u=p===n;l=l||u}if(l)n=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),n++}return zs.errors=r,n===0}function Xs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=n,c=n,u=!1,p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let h={};r===null?r=[h]:r.push(h),n++}}var m=p===n;if(u=u||m,!u){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.type===void 0&&(P="type")){let k={};r===null?r=[k]:r.push(k),n++}}var m=w===n;if(u=u||m,!u){let P=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.resourceId===void 0&&(E="resourceId")){let v={};r===null?r=[v]:r.push(v),n++}}var m=P===n;if(u=u||m,!u){let E=n;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),n++}}var m=E===n;if(u=u||m,!u){let O=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let D={};r===null?r=[D]:r.push(D),n++}}var m=O===n;if(u=u||m,!u){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.transform===void 0&&(B="transform")){let _={};r===null?r=[_]:r.push(_),n++}}var m=$===n;if(u=u||m,!u){let B=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.x===void 0&&(G="x")){let fe={};r===null?r=[fe]:r.push(fe),n++}}var m=B===n;if(u=u||m,!u){let G=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let K={};r===null?r=[K]:r.push(K),n++}}var m=G===n;if(u=u||m,!u){let M=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let z={};r===null?r=[z]:r.push(z),n++}}var m=M===n;if(u=u||m,!u){let le=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.anchorY===void 0&&(te="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),n++}}var m=le===n;if(u=u||m,!u){let te=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let ne;if(e.scaleX===void 0&&(ne="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),n++}}var m=te===n;if(u=u||m,!u){let ne=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.scaleY===void 0&&(Z="scaleY")){let C={};r===null?r=[C]:r.push(C),n++}}var m=ne===n;if(u=u||m,!u){let Z=n;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),n++}}var m=Z===n;if(u=u||m,!u){let j=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let J;if(e.flipY===void 0&&(J="flipY")){let de={};r===null?r=[de]:r.push(de),n++}}var m=j===n;if(u=u||m,!u){let J=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ie;if(e.rotation===void 0&&(Ie="rotation")){let we={};r===null?r=[we]:r.push(we),n++}}var m=J===n;if(u=u||m,!u){let Ie=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let me;if(e.originX===void 0&&(me="originX")){let fr={};r===null?r=[fr]:r.push(fr),n++}}var m=Ie===n;if(u=u||m,!u){let me=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let We;if(e.originY===void 0&&(We="originY")){let Sn={};r===null?r=[Sn]:r.push(Sn),n++}}var m=me===n;if(u=u||m,!u){let We=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Fr;if(e.layer===void 0&&(Fr="layer")){let Br={};r===null?r=[Br]:r.push(Br),n++}}var m=We===n;if(u=u||m,!u){let Fr=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let kr;if(e.alpha===void 0&&(kr="alpha")){let On={};r===null?r=[On]:r.push(On),n++}}var m=Fr===n;if(u=u||m,!u){let kr=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let ut;if(e.opacity===void 0&&(ut="opacity")){let pt={};r===null?r=[pt]:r.push(pt),n++}}var m=kr===n;if(u=u||m,!u){let ut=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ur;if(e.blur===void 0&&(Ur="blur")){let ft={};r===null?r=[ft]:r.push(ft),n++}}var m=ut===n;if(u=u||m,!u){let Ur=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Tt;if(e.filters===void 0&&(Tt="filters")){let Rn={};r===null?r=[Rn]:r.push(Rn),n++}}var m=Ur===n;if(u=u||m,!u){let Tt=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $n;if(e.animations===void 0&&($n="animations")){let Cn={};r===null?r=[Cn]:r.push(Cn),n++}}var m=Tt===n;u=u||m}}}}}}}}}}}}}}}}}}}}}}if(u)n=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),n++}var f=l===n;if(f){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),n++}else n=i,r!==null&&(i?r.length=i:r=null);let d=n,g=!1,b=n;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),n++}var y=b===n;if(g=g||y,!g){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let P={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[P]:r.push(P),n++}var y=w===n;g=g||y}if(g)n=d,r!==null&&(d?r.length=d: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),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(zs(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),n=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),n++}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),n++}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),n++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),n++}return Xs.errors=r,n===0}function Gs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Gs.errors=r,n===0}var Av={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 Hs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}for(let i in e)if(!Ke.call(Av.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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Hs.errors=r,n===0}function Ks(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let m={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let m=p.length;for(let f=0;f<m;f++){let d=p[f],g=n,b=n;if(d&&typeof d=="object"&&!Array.isArray(d)){let v;if(d.resourceId===void 0&&(v="resourceId")||d.text===void 0&&(v="text")){let O={};r===null?r=[O]:r.push(O),n++}}var i=b===n;if(i){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=g,r!==null&&(g?r.length=g:r=null);let y=n,w=n;if(d&&typeof d=="object"&&!Array.isArray(d)){let v;if(d.resourceId===void 0&&(v="resourceId")||d.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),n++}}var l=w===n;if(l){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=y,r!==null&&(y?r.length=y:r=null);let h=n,P=n;if(d&&typeof d=="object"&&!Array.isArray(d)){let v;if(d.text===void 0&&(v="text")||d.layout===void 0&&(v="layout")){let O={};r===null?r=[O]:r.push(O),n++}}var c=P===n;if(c){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=h,r!==null&&(h?r.length=h:r=null);let k=n,E=n;if(d&&typeof d=="object"&&!Array.isArray(d)){let v;if(d.transformId===void 0&&(v="transformId")||d.transform===void 0&&(v="transform")){let O={};r===null?r=[O]:r.push(O),n++}}var u=E===n;if(u){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=k,r!==null&&(k?r.length=k:r=null);if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),n++}for(let v in d)if(!Ke.call(wf.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),n++}if(d.id!==void 0&&typeof d.id!="string"){let v={instancePath:t+"/items/"+f+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(d.animationName!==void 0&&typeof d.animationName!="string"){let v={instancePath:t+"/items/"+f+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(d.animationSpeed!==void 0&&typeof d.animationSpeed!="number"){let v={instancePath:t+"/items/"+f+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.resourceId!==void 0&&typeof d.resourceId!="string"){let v={instancePath:t+"/items/"+f+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(d.text!==void 0&&(Xs(d.text,{instancePath:t+"/items/"+f+"/text",parentData:d,parentDataProperty:"text",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),n=r.length)),d.layout!==void 0&&(Gs(d.layout,{instancePath:t+"/items/"+f+"/layout",parentData:d,parentDataProperty:"layout",rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),n=r.length)),d.transformId!==void 0&&typeof d.transformId!="string"){let v={instancePath:t+"/items/"+f+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(d.transform!==void 0&&(Hs(d.transform,{instancePath:t+"/items/"+f+"/transform",parentData:d,parentDataProperty:"transform",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),n=r.length)),d.x!==void 0&&typeof d.x!="number"){let v={instancePath:t+"/items/"+f+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.y!==void 0&&typeof d.y!="number"){let v={instancePath:t+"/items/"+f+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.anchorX!==void 0&&typeof d.anchorX!="number"){let v={instancePath:t+"/items/"+f+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.anchorY!==void 0&&typeof d.anchorY!="number"){let v={instancePath:t+"/items/"+f+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.scaleX!==void 0&&typeof d.scaleX!="number"){let v={instancePath:t+"/items/"+f+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.scaleY!==void 0&&typeof d.scaleY!="number"){let v={instancePath:t+"/items/"+f+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.flipX!==void 0&&typeof d.flipX!="boolean"){let v={instancePath:t+"/items/"+f+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),n++}if(d.flipY!==void 0&&typeof d.flipY!="boolean"){let v={instancePath:t+"/items/"+f+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),n++}if(d.rotation!==void 0&&typeof d.rotation!="number"){let v={instancePath:t+"/items/"+f+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.originX!==void 0&&typeof d.originX!="number"){let v={instancePath:t+"/items/"+f+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.originY!==void 0&&typeof d.originY!="number"){let v={instancePath:t+"/items/"+f+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(d.layer!==void 0){let v=d.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),n++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:wf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),n++}}if(d.alpha!==void 0){let v=d.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}}else{let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),n++}}if(d.opacity!==void 0){let v=d.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}}else{let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),n++}}d.blur!==void 0&&(Fe(d.blur,{instancePath:t+"/items/"+f+"/blur",parentData:d,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),d.filters!==void 0&&(ar(d.filters,{instancePath:t+"/items/"+f+"/filters",parentData:d,parentDataProperty:"filters",rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),n=r.length)),d.animations!==void 0&&(pe(d.animations,{instancePath:t+"/items/"+f+"/animations",parentData:d,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=r.length))}else{let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}}else{let m={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),n++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}return Ks.errors=r,n===0}function Xf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ks(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),n=r.length),Xf.errors=r,n===0}var Gf=Hf;var Pv={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 Ws(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;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),n++}var u=c===n;if(l=l||u,!l){let y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let h={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[h]:r.push(h),n++}var u=y===n;l=l||u}if(l)n=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),n++}let p=n,m=n;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),n++}}var f=m===n;if(f){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=p,r!==null&&(p?r.length=p:r=null);let d=n,g=n;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),n++}}var b=g===n;if(b){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=d,r!==null&&(d?r.length=d: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),n++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let h=0;h<w;h++)or(y[h],{instancePath:t+"/sounds/"+h,parentData:y,parentDataProperty:h,rootData:a})||(r=r===null?or.errors:r.concat(or.errors),n=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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Pv.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),n++}}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),n++}}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),n++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),n++}return Ws.errors=r,n===0}function Hf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ws(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),n=r.length),Hf.errors=r,n===0}var Kf=Wf;var Ev={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 Js(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let b={};r===null?r=[b]:r.push(b),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let b=n;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),n++}var u=b===n;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let p=n,m=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let b={};r===null?r=[b]:r.push(b),n++}var d=f===n;if(n=p,r!==null&&(p?r.length=p:r=null),d){let b=n,y=n,w=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.target===void 0&&(P="target")){let k={};r===null?r=[k]:r.push(k),n++}}var g=w===n;if(g){let P={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[P]:r.push(P),n++}else n=y,r!==null&&(y?r.length=y:r=null);var d=b===n;m=d}if(!m){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),n++}if(e.name===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[b]:r.push(b),n++}if(e.description===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[b]:r.push(b),n++}for(let b in e)if(!(b==="type"||b==="target"||b==="name"||b==="description"||b==="lockedName"||b==="lockedDescription"||b==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),n++}if(e.type!==void 0){let b=e.type;if(typeof b!="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),n++}if(!(b==="boolean"||b==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Ev.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),n++}}if(e.target!==void 0){let b=e.target;if(!(typeof b=="number"&&!(b%1)&&!isNaN(b))){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),n++}if(typeof b=="number"&&(b<1||isNaN(b))){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),n++}}if(e.name!==void 0){let b=e.name;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.description!==void 0){let b=e.description;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.lockedName!==void 0){let b=e.lockedName;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.lockedDescription!==void 0){let b=e.lockedDescription;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let b={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),n++}return Js.errors=r,n===0}function Wf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Js(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),n=r.length),Wf.errors=r,n===0}var Jf=Qf;var xv={type:"object",required:["type"],$defs:{keyframe:{type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}}},required:["keyframes"],additionalProperties:!1},updateTween:{type:"object",properties:{alpha:{$ref:"#/$defs/tweenProperty"},x:{$ref:"#/$defs/tweenProperty"},y:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionTween:{type:"object",properties:{translateX:{$ref:"#/$defs/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},alpha:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/tweenProperty"},compositeMaskItem:{type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1},mask:{type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]}},properties:{name:{type:"string"},type:{type:"string",enum:["update","transition"]},complete:{type:"object",properties:{payload:{type:"object"}},additionalProperties:!0},tween:{$ref:"#/$defs/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"},mask:{$ref:"#/$defs/mask"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{not:{required:["tween"]},anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/animationResource.yaml"};var Sv={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 ot(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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:Sv.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ot.errors=r,n===0}function re(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)ot(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return re.errors=r,n===0}function Qs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=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),n++}return Qs.errors=r,n===0}function Zs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.translateX!==void 0&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=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),n++}return Zs.errors=r,n===0}function st(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n=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),n++}return st.errors=r,n===0}var Rs={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"]}}]},Ov={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function ei(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Ov.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ei.errors=r,n===0}function ri(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)ot(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ri.errors=r,n===0}function ti(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let h={};r===null?r=[h]:r.push(h),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let h=n;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),n++}var u=h===n;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),n++}let p=n,m=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let h={};r===null?r=[h]:r.push(h),n++}var d=f===n;if(n=p,r!==null&&(p?r.length=p:r=null),d){let h=n;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),n++}var d=h===n;m=d}if(!m){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),n++}let g=n,b=!0,y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let h={};r===null?r=[h]:r.push(h),n++}var w=y===n;if(n=g,r!==null&&(g?r.length=g:r=null),w){let h=n;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),n++}var w=h===n;b=w}if(!b){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),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[h]:r.push(h),n++}for(let h in e)if(!Ke.call(Rs.properties,h)){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.kind!==void 0){let h=e.kind;if(typeof h!="string"){let P={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="single"||h==="sequence"||h==="composite")){let P={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Rs.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.texture!==void 0&&typeof e.texture!="string"){let h={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(e.textures!==void 0){let h=e.textures;if(Array.isArray(h)){if(h.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),n++}let P=h.length;for(let k=0;k<P;k++)if(typeof h[k]!="string"){let E={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),n++}}else{let P={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[P]:r.push(P),n++}}if(e.items!==void 0){let h=e.items;if(Array.isArray(h)){if(h.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),n++}let P=h.length;for(let k=0;k<P;k++)ei(h[k],{instancePath:t+"/items/"+k,parentData:h,parentDataProperty:k,rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),n=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),n++}}if(e.combine!==void 0){let h=e.combine;if(typeof h!="string"){let P={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="max"||h==="min"||h==="multiply"||h==="add")){let P={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Rs.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.channel!==void 0){let h=e.channel;if(typeof h!="string"){let P={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="red"||h==="green"||h==="blue"||h==="alpha")){let P={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Rs.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.softness!==void 0&&typeof e.softness!="number"){let h={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let h={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),n++}if(e.sample!==void 0&&typeof e.sample!="string"){let h={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}e.progress!==void 0&&(ri(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),n=r.length))}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}return ti.errors=r,n===0}function ni(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let h={};r===null?r=[h]:r.push(h),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let h=n,P=n,k=n,E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),n++}}var p=O===n;if(v=v||p,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),n++}}var p=$===n;if(v=v||p,!v){let B=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let fe={};r===null?r=[fe]:r.push(fe),n++}}var p=B===n;v=v||p}}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={};r===null?r=[$]:r.push($),n++}var m=k===n;if(m){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let $={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[$]:r.push($),n++}var u=h===n;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),n++}let f=n,d=!0,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let h={};r===null?r=[h]:r.push(h),n++}var b=g===n;if(n=f,r!==null&&(f?r.length=f:r=null),b){let h=n,P=n,k=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),n++}}var y=k===n;if(y){let $={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);let E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[$]:r.push($),n++}var w=O===n;if(v=v||w,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),n++}var w=$===n;if(v=v||w,!v){let B=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[G]:r.push(G),n++}var w=B===n;v=v||w}}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[$]:r.push($),n++}var b=h===n;d=b}if(!d){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),n++}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),n++}for(let h in e)if(!(h==="name"||h==="type"||h==="complete"||h==="tween"||h==="prev"||h==="next"||h==="mask")){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.name!==void 0&&typeof e.name!="string"){let h={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(e.type!==void 0){let h=e.type;if(typeof h!="string"){let P={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="update"||h==="transition")){let P={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:xv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.complete!==void 0){let h=e.complete;if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.payload!==void 0){let P=h.payload;if(!(P&&typeof P=="object"&&!Array.isArray(P))){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),n++}}}else{let P={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),n++}}e.tween!==void 0&&(Qs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),n=r.length)),e.prev!==void 0&&(st(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?st.errors:r.concat(st.errors),n=r.length)),e.next!==void 0&&(st(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?st.errors:r.concat(st.errors),n=r.length)),e.mask!==void 0&&(ti(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),n=r.length))}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}return ni.errors=r,n===0}function Qf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return ni(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),n=r.length),Qf.errors=r,n===0}var Zf=ed;var Rv={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:{oneOf:[{type:"object",required:["duration"],properties:{delay:{type:"number",minimum:0},duration:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1},{type:"object",required:["keyframes"],properties:{keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/fadeKeyframe"}}},additionalProperties:!1}]},transitionSide:{type:"object",minProperties:1,properties:{fade:{$ref:"#/$defs/fade"}},additionalProperties:!1},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},fadeKeyframe:{allOf:[{$ref:"#/$defs/boundedKeyframe"},{not:{properties:{relative:{const:!0}},required:["relative"]}}]},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 si(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(typeof e!="number"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),n++}return si.errors=r,n===0}var $v={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 at(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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:$v.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),n++}return at.errors=r,n===0}function lr(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}if(e.value!==void 0&&(si(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),n=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),n++}}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),n++}}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),n++}}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),n++}}if(e.easing!==void 0&&(at(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?at.errors:r.concat(at.errors),n=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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return lr.errors=r,n===0}function lt(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;lr(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),n=r.length);let i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let h={};r===null?r=[h]:r.push(h),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),p){let b=n;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 h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),n++}if(w<0||isNaN(w)){let h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}}var p=b===n;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let m=n,f=!0,d=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),n++}var g=d===n;if(n=m,r!==null&&(m?r.length=m:r=null),g){let b=n;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 h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),n++}if(w<0||isNaN(w)){let h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}}var g=b===n;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}return lt.errors=r,n===0}function ii(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)lt(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?lt.errors:r.concat(lt.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ii.errors=r,n===0}function oi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;lr(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),n=r.length);let i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let h={};r===null?r=[h]:r.push(h),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),p){let b=n;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 h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),n++}if(w<-1||isNaN(w)){let h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),n++}}}var p=b===n;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let m=n,f=!0,d=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),n++}var g=d===n;if(n=m,r!==null&&(m?r.length=m:r=null),g){let b=n;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 h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),n++}if(w<-1||isNaN(w)){let h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),n++}}}var g=b===n;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}return oi.errors=r,n===0}function ai(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)oi(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ai.errors=r,n===0}function li(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;lr(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),n=r.length);let i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let h={};r===null?r=[h]:r.push(h),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),p){let b=n;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 h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}var p=b===n;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let m=n,f=!0,d=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),n++}var g=d===n;if(n=m,r!==null&&(m?r.length=m:r=null),g){let b=n;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 h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}var g=b===n;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}return li.errors=r,n===0}function ci(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)li(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?li.errors:r.concat(li.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ci.errors=r,n===0}function ui(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.volume!==void 0&&(ii(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),n=r.length)),e.pan!==void 0&&(ai(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),n=r.length)),e.playbackRate!==void 0&&(ci(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),n=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),n++}return ui.errors=r,n===0}function pi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;lt(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?lt.errors:r.concat(lt.errors),n=r.length);let i=n,l=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.relative===void 0&&(u="relative")){let p={};r===null?r=[p]:r.push(p),n++}else if(e.relative!==void 0&&e.relative!==!0){let p={};r===null?r=[p]:r.push(p),n++}}var c=l===n;if(c){let u={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),n++}else n=i,r!==null&&(i?r.length=i:r=null);return pi.errors=r,n===0}function fi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=null,u=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.duration===void 0){let f={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[f]:r.push(f),n++}for(let f in e)if(!(f==="delay"||f==="duration"||f==="easing")){let d={instancePath:t,schemaPath:"#/oneOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),n++}if(e.delay!==void 0){let f=e.delay;if(typeof f=="number"){if(f<0||isNaN(f)){let d={instancePath:t+"/delay",schemaPath:"#/oneOf/0/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t+"/delay",schemaPath:"#/oneOf/0/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),n++}}if(e.duration!==void 0){let f=e.duration;if(typeof f=="number"){if(f<0||isNaN(f)){let d={instancePath:t+"/duration",schemaPath:"#/oneOf/0/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[d]:r.push(d),n++}}else{let d={instancePath:t+"/duration",schemaPath:"#/oneOf/0/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[d]:r.push(d),n++}}e.easing!==void 0&&(at(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?at.errors:r.concat(at.errors),n=r.length))}else{let f={instancePath:t,schemaPath:"#/oneOf/0/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}var m=u===n;m&&(l=!0,c=0);let p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let f={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[f]:r.push(f),n++}for(let f in e)if(f!=="keyframes"){let d={instancePath:t,schemaPath:"#/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),n++}if(e.keyframes!==void 0){let f=e.keyframes;if(Array.isArray(f)){if(f.length<1){let g={instancePath:t+"/keyframes",schemaPath:"#/oneOf/1/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[g]:r.push(g),n++}let d=f.length;for(let g=0;g<d;g++)pi(f[g],{instancePath:t+"/keyframes/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),n=r.length)}else{let d={instancePath:t+"/keyframes",schemaPath:"#/oneOf/1/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),n++}}}else{let f={instancePath:t,schemaPath:"#/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}var m=p===n;if(m&&l?(l=!1,c=[c,1]):m&&(l=!0,c=1),l)n=i,r!==null&&(i?r.length=i:r=null);else{let f={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),n++}return fi.errors=r,n===0}function it(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.fade!==void 0&&(fi(e.fade,{instancePath:t+"/fade",parentData:e,parentDataProperty:"fade",rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),n=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),n++}return it.errors=r,n===0}function di(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let h={};r===null?r=[h]:r.push(h),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let h=n,P=n,k=n,E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),n++}}var p=O===n;if(v=v||p,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),n++}}var p=$===n;v=v||p}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={};r===null?r=[$]:r.push($),n++}var m=k===n;if(m){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let $={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[$]:r.push($),n++}var u=h===n;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),n++}let f=n,d=!0,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let h={};r===null?r=[h]:r.push(h),n++}var b=g===n;if(n=f,r!==null&&(f?r.length=f:r=null),b){let h=n,P=n,k=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),n++}}var y=k===n;if(y){let $={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);let E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[$]:r.push($),n++}var w=O===n;if(v=v||w,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),n++}var w=$===n;v=v||w}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[$]:r.push($),n++}var b=h===n;d=b}if(!d){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),n++}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),n++}for(let h in e)if(!(h==="name"||h==="type"||h==="tween"||h==="prev"||h==="next")){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.name!==void 0&&typeof e.name!="string"){let h={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(e.type!==void 0){let h=e.type;if(!(h==="update"||h==="transition")){let P={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Rv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}e.tween!==void 0&&(ui(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),n=r.length)),e.prev!==void 0&&(it(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?it.errors:r.concat(it.errors),n=r.length)),e.next!==void 0&&(it(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?it.errors:r.concat(it.errors),n=r.length))}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}return di.errors=r,n===0}function ed(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return di(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),n=r.length),ed.errors=r,n===0}var rd=td;function mi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return mi.errors=r,n===0}function td(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return mi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),n=r.length),td.errors=r,n===0}var nd=sd;var Cv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function yi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!Cv.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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return yi.errors=r,n===0}function sd(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return yi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),n=r.length),sd.errors=r,n===0}var id=od;function hi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}}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),n++}}if(c.keydown!==void 0){let u=c.keydown;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keydown/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keydown/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}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),n++}}if(c.keyup!==void 0){let u=c.keyup;if(u&&typeof u=="object"&&!Array.isArray(u)){if(u.payload!==void 0){let p=u.payload;if(!(p&&typeof p=="object"&&!Array.isArray(p))){let m={instancePath:t+"/keyboard/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/keyup/payload",schemaPath:"#/properties/keyboard/additionalProperties/properties/keyup/properties/payload/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}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),n++}}}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),n++}}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),n++}}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),n++}}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),n++}}}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),n++}}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),n++}}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),n++}}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return hi.errors=r,n===0}function od(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return hi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),n=r.length),od.errors=r,n===0}var ad=ld;function gi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return gi.errors=r,n===0}function ld(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return gi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),n=r.length),ld.errors=r,n===0}var cd=ud;function bi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return bi.errors=r,n===0}function ud(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return bi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),n=r.length),ud.errors=r,n===0}var pd=fd;function wi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return wi.errors=r,n===0}var If=new RegExp("^\\$(if .+|for .+|else)$","u"),Ba={validate:gn};function Ii(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}for(let i in e)if(!If.test(i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}for(let i in e)if(If.test(i)){let l=e[i];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)Ba.validate(l[u],{instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?Ba.validate.errors:r.concat(Ba.validate.errors),n=r.length)}else{let c={instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ii.errors=r,n===0}function gn(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;wi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),n=r.length);var u=c===n;if(l=l||u,!l){let p=n;Ii(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),n=r.length);var u=p===n;l=l||u}if(l)n=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),n++}return gn.errors=r,n===0}function vi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)gn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?gn.errors:r.concat(gn.errors),n=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),n++}return vi.errors=r,n===0}var Ua={validate:bn};function bn(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(vi(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),n=r.length)),e.children!==void 0){let i=e.children;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)Ua.validate(i[c],{instancePath:t+"/children/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Ua.validate.errors:r.concat(Ua.validate.errors),n=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return bn.errors=r,n===0}function ki(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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++)bn(i[c],{instancePath:t+"/elements/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?bn.errors:r.concat(bn.errors),n=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}if(e.transitions!==void 0){let i={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[i]:r.push(i),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ki.errors=r,n===0}function fd(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return ki(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),n=r.length),fd.errors=r,n===0}var dd=md;function Ai(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=null,u=n,p=n,m=n,f=n,d=!1,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let E={};r===null?r=[E]:r.push(E),n++}}var b=g===n;if(d=d||b,!d){let k=n;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),n++}}var b=k===n;if(d=d||b,!d){let v=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.behaviors===void 0&&(T="behaviors")){let $={};r===null?r=[$]:r.push($),n++}}var b=v===n;if(d=d||b,!d){let T=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.emitter===void 0&&(D="emitter")){let B={};r===null?r=[B]:r.push(B),n++}}var b=T===n;d=d||b}}}if(d)n=f,r!==null&&(f?r.length=f:r=null);else{let k={};r===null?r=[k]:r.push(k),n++}var y=m===n;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),n++}else n=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),n++}var h=u===n;h&&(l=!0,c=0);let w=n;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),n++}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),n++}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),n++}}var h=w===n;if(h&&l?(l=!1,c=[c,1]):h&&(l=!0,c=1),l)n=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),n++}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),n++}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),n++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),n++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),n++}}else{let E={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),n++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),n++}}else{let E={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),n++}}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),n++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[E]:r.push(E),n++}if(k.appearance===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[E]:r.push(E),n++}for(let E in k)if(!(E==="emission"||E==="movement"||E==="appearance"||E==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),n++}if(k.emission!==void 0){let E=k.emission;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}if(k.movement!==void 0){let E=k.movement;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}if(k.appearance!==void 0){let E=k.appearance;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}if(k.bounds!==void 0){let E=k.bounds;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}}else{let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),n++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[E]:r.push(E),n++}if(typeof k=="number"&&(k<1||isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[E]:r.push(E),n++}}if(e.texture!==void 0){let k=e.texture,E=n,v=!1,O=null,T=n;if(typeof k=="string"){if(Oe(k)<1){let D={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=[D]:r.push(D),n++}}else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[D]:r.push(D),n++}var P=T===n;P&&(v=!0,O=0);let $=n;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),n++}var P=$===n;if(P&&v?(v=!1,O=[O,1]):P&&(v=!0,O=1),v)n=E,r!==null&&(E?r.length=E:r=null);else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[D]:r.push(D),n++}}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),n++}let E=k.length;for(let v=0;v<E;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let 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),n++}for(let T in O)if(!(T==="type"||T==="config")){let $={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:T},message:"must NOT have additional properties"};r===null?r=[$]:r.push($),n++}if(O.type!==void 0){let T=O.type;if(typeof T=="string"){if(Oe(T)<1){let $={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.push($),n++}}else{let $={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.push($),n++}}if(O.config!==void 0){let T=O.config;if(!(T&&typeof T=="object"&&!Array.isArray(T))){let $={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.push($),n++}}}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),n++}}}else{let E={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),n++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[E]:r.push(E),n++}if(k.lifetime!==void 0){let E=k.lifetime;if(E&&typeof E=="object"&&!Array.isArray(E)){if(E.min===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),n++}if(E.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),n++}if(E.min!==void 0){let v=E.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),n++}}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),n++}}if(E.max!==void 0){let v=E.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),n++}}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),n++}}}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),n++}}}else{let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),n++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),n++}return Ai.errors=r,n===0}function md(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ai(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),n=r.length),md.errors=r,n===0}var yd=hd;var vf={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 Pi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}for(let i in e)if(!Ke.call(vf.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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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:vf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Pi.errors=r,n===0}function hd(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Pi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),n=r.length),hd.errors=r,n===0}var gd=bd;var _v=new RegExp("^.+$","u");function Ei(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}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),n++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(_v.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),n++}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),n++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let m=0;m<p;m++)if(typeof u[m]!="number"){let f={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+m,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),n++}}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),n++}}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),n++}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),n++}}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),n++}}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ei.errors=r,n===0}function bd(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ei(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),n=r.length),bd.errors=r,n===0}var wd=Id;var kf={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 xi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}for(let l in e)if(!Ke.call(kf.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),n++}if(e.fontId!==void 0){let l=e.fontId,c=n,u=!1,p=null,m=n;if(typeof l=="string"){if(Oe(l)<1){let d={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=[d]:r.push(d),n++}}else{let d={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[d]:r.push(d),n++}var i=m===n;i&&(u=!0,p=0);let f=n;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),n++}let d=l.length;for(let y=0;y<d;y++){let w=l[y];if(typeof w=="string"){if(Oe(w)<1){let h={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=[h]:r.push(h),n++}}else{let h={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}}let g=l.length,b;if(g>1){let y={};for(;g--;){let w=l[g];if(typeof w=="string"){if(typeof y[w]=="number"){b=y[w];let h={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:g,j:b},message:"must NOT have duplicate items (items ## "+b+" and "+g+" are identical)"};r===null?r=[h]:r.push(h),n++;break}y[w]=g}}}}else{let d={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),n++}var i=f===n;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)n=c,r!==null&&(c?r.length=c:r=null);else{let d={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf",keyword:"oneOf",params:{passingSchemas:p},message:"must match exactly one schema in oneOf"};r===null?r=[d]:r.push(d),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:kf.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Oe(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),n++}}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),n++}}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}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),n++}}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),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return xi.errors=r,n===0}function Id(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return xi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),n=r.length),Id.errors=r,n===0}var vd=kd;var jv={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 Si(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(jv.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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Si.errors=r,n===0}function kd(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Si(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),n=r.length),kd.errors=r,n===0}var Ad=Pd;function Oi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Oi.errors=r,n===0}function Pd(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Oi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Oi.errors:r.concat(Oi.errors),n=r.length),Pd.errors=r,n===0}var vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),In=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),vr=e=>e===void 0?void 0:structuredClone(e),Nv=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"}),Dv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Tv=Object.freeze({background:Af,bgm:Ef,character:Sf,choice:Rf,cleanAll:Cf,control:jf,dialogue:Df,form:Lf,layout:qf,screen:Ff,sfx:Uf,visual:zf,voice:Gf}),Lv=Object.freeze({achievement:Kf,animation:Jf,audioEffect:Zf,character:rd,color:nd,control:id,font:ad,image:cd,layout:pd,particle:dd,sound:yd,spritesheet:gd,textStyle:wd,transform:vd,video:Ad}),Mv=new Set(["files","language","patches"]),qv=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),Vv=new Set(["lineId","mode","payload","type"]),Fv=new Set(["mode","payload","sceneId","type"]),Bv=new Set(["mode","operation","payload","resourceId","type"]),Uv=new Set(["fileId","mimeType"]),H=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},rr=(e,t)=>{In(e)||H(t,"expected an object")},Ya=(e,t)=>{Array.isArray(e)||H(t,"expected an array")},Nt=(e,t)=>{(typeof e!="string"||e.length===0)&&H(t,"expected a non-empty string")},Od=(e,t)=>{typeof e!="string"&&H(t,"expected a string")},ur=(e,t,s)=>{for(let o of Object.keys(e))t.has(o)||H(`${s}.${o}`,"unknown field")},pr=(e,t,s)=>{for(let o of t)vn(e,o)||H(s,`missing required field "${o}"`)},Yv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),zv=(e,t)=>{let s=(t?.instancePath??"").split("/").slice(1).map(Yv);return t?.keyword==="required"?s.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&s.push(t.params.additionalProperty),s.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},Xv=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,s)=>{if(t===void 0)return s;let o=s.instancePath.split("/").length,a=t.instancePath.split("/").length;return o>a?s:t},void 0)??e[0],Rd=({value:e,validator:t,path:s,contract:o})=>{if(t(e))return;let a=Xv(t.errors);H(zv(s,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Ri=(e,t,s=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||H(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||s.has(e))){if(s.add(e),Array.isArray(e)){e.forEach((o,a)=>Ri(o,`${t}[${a}]`,s));return}Object.entries(e).forEach(([o,a])=>Ri(a,`${t}.${o}`,s))}},cr=(e,t)=>{e===""&&H(t,"expected a non-empty resourceId")},Gv=(e,t,s)=>{let o=(n,i)=>cr(n?.resourceId,`${i}.resourceId`),a=(n,i)=>(n??[]).forEach((l,c)=>cr(l?.resourceId,`${i}[${c}].resourceId`)),r=(n,i)=>{cr(n?.resourceId,`${i}.resourceId`),a(n?.sounds,`${i}.sounds`)};switch(e){case"background":cr(t.resourceId,`${s}.resourceId`),o(t.animations,`${s}.animations`);break;case"bgm":o(t.audioEffects,`${s}.audioEffects`),r(t,s);break;case"voice":r(t,s);break;case"sfx":a(t.items,`${s}.items`),(t.channels??[]).forEach((n,i)=>a(n?.sounds,`${s}.channels[${i}].sounds`));break;case"character":(t.items??[]).forEach((n,i)=>{(n.sprites??[]).forEach((l,c)=>cr(l?.resourceId,`${s}.items[${i}].sprites[${c}].resourceId`)),o(n.animations,`${s}.items[${i}].animations`)});break;case"choice":case"form":case"layout":cr(t.resourceId,`${s}.resourceId`),o(t.animations,`${s}.animations`);break;case"control":cr(t.resourceId,`${s}.resourceId`);break;case"dialogue":cr(t.ui?.resourceId,`${s}.ui.resourceId`),o(t.ui?.animations,`${s}.ui.animations`),(t.character?.sprite?.items??[]).forEach((n,i)=>cr(n?.resourceId,`${s}.character.sprite.items[${i}].resourceId`)),o(t.character?.sprite?.animations,`${s}.character.sprite.animations`);break;case"screen":o(t.animations,`${s}.animations`);break;case"visual":(t.items??[]).forEach((n,i)=>{cr(n?.resourceId,`${s}.items[${i}].resourceId`),o(n?.animations,`${s}.items[${i}].animations`)});break;default:break}},Dt=(e,t)=>{Nt(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&H(t,`"${e}" is not a safe ID`)},Hv=(e,t)=>{Nt(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&H(t,"must be a safe single filename")},wn=(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)=>wn(a,t[r]));if(!In(e)||!In(t))return!1;let s=Object.keys(e).sort(),o=Object.keys(t).sort();return wn(s,o)&&s.every(a=>wn(e[a],t[a]))},$i=(e,t=new Set,s=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>$i(o,t,s)),t;if(!In(e)||s.has(e))return t;s.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&t.add(a),$i(a,t,s);return t},Kv=e=>{let t=new Map;for(let[s,o]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(o?.sections??{}))for(let[n,i]of(r?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=t.get(i.id)??[];l.push({sceneId:s,sectionId:a,lineIndex:n,line:i}),t.set(i.id,l)}return t},$d=(e,t,s)=>{let o=e.get(t)??[];return o.length===0&&H(s,`lineId "${t}" does not exist in projectData`),o.length>1&&H(s,`lineId "${t}" is not globally unique in projectData`),o[0]},Cd=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Ed=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),xd=e=>{let t=vr(e??{});delete t.resourceId,delete t.animations;for(let s of Object.values(t.fields??{}))In(s)&&delete s.placeholder;return t},Wv=(e,t,s,o)=>{e==="choice"&&!wn(Ed(t),Ed(s))&&H(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!wn(xd(t),xd(s))&&H(o,"form behavior must remain identical; only presentation fields and placeholders may change")},Jv=({patch:e,path:t,lineIndex:s})=>{ur(e,qv,t),pr(e,["type","lineId","actionType","payload"],t),Dt(e.lineId,`${t}.lineId`),Nt(e.actionType,`${t}.actionType`),rr(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.action supports only "replace"'),Dv.has(e.actionType)||H(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=$d(s,e.lineId,`${t}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&H(`${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")&&H(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),vn(e.payload,"content")&&H(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&H(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),Wv(e.actionType,a,e.payload,`${t}.payload`),Rd({value:e.payload,validator:Tv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Ri(e.payload,`${t}.payload`),Gv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},Qv=(e,t)=>{Ya(e,t),e.forEach((s,o)=>{rr(s,`${t}[${o}]`),ur(s,new Set(["text"]),`${t}[${o}]`),pr(s,["text"],`${t}[${o}]`),Od(s.text,`${t}[${o}].text`)})},Zv=({patch:e,path:t,lineIndex:s})=>{ur(e,Vv,t),pr(e,["type","lineId","payload"],t),Dt(e.lineId,`${t}.lineId`),rr(e.payload,`${t}.payload`),ur(e.payload,new Set(["content"]),`${t}.payload`),pr(e.payload,["content"],`${t}.payload`),Qv(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.dialogue supports only "replace"');let o=$d(s,e.lineId,`${t}.lineId`);return o.line?.actions?.dialogue===void 0&&H(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},ek=({patch:e,path:t,projectData:s})=>(ur(e,Fv,t),pr(e,["type","mode","sceneId","payload"],t),Dt(e.sceneId,`${t}.sceneId`),rr(e.payload,`${t}.payload`),ur(e.payload,new Set(["name"]),`${t}.payload`),pr(e.payload,["name"],`${t}.payload`),Od(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&H(`${t}.mode`,'story.scene requires "patch"'),vn(s?.story?.scenes??{},e.sceneId)||H(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),rk=(e,t,s)=>{rr(t,s),["font","image","sound","spritesheet","video"].includes(e)&&Nt(t.fileId,`${s}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||H(`${s}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${s}.height`,"expected an integer")),e==="spritesheet"&&(rr(t.jsonData,`${s}.jsonData`),Number.isInteger(t.width)||H(`${s}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${s}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&H(`${s}.hex`,"expected an opaque #RGB or #RRGGBB color"),Rd({value:t,validator:Lv[e],path:s,contract:`the resource.${e} schema`}),Ri(t,s)},tk=({patch:e,path:t,projectData:s,packageFileIds:o,canonicalFileIds:a})=>{ur(e,Bv,t),pr(e,["type","resourceId","payload"],t),Dt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),n=Nv[r];n||H(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&H(`${t}.operation`,'the only resource operation is "add"'),rk(r,e.payload,`${t}.payload`);let i=s?.resources?.[n]??{},l=vn(i,e.resourceId);e.operation==="add"&&l&&H(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&H(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of $i(e.payload))!o.has(c)&&!a.has(c)&&H(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:n,path:t,patch:e}},Sd=({resources:e,collectionName:t,resourceId:s,path:o,label:a})=>{s!==void 0&&(typeof s!="string"||s.length===0||!vn(e?.[t]??{},s))&&H(o,`${a} resource "${s}" was not found`)},nk=(e,t)=>{let s=vr(e);for(let a of t.patches)a.kind==="resource"&&(s.resources[a.collectionName]??={},s.resources[a.collectionName][a.patch.resourceId]=vr(a.patch.payload));let o=s.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,n=Array.isArray(r.fontId)?r.fontId:[r.fontId];n.forEach((i,l)=>Sd({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${n.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])Sd({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},sk=({patch:e,path:t,projectData:s,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(rr(e,t),Nt(e.type,`${t}.type`),e.type==="line.action")return Jv({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return Zv({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return ek({patch:e,path:t,projectData:s});if(e.type.startsWith("resource."))return tk({patch:e,path:t,projectData:s,packageFileIds:a,canonicalFileIds:r});H(`${t}.type`,`unsupported patch type "${e.type}"`)},ik=(e,t)=>{Ya(e,t);let s=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;rr(o,r),ur(o,Uv,r),pr(o,["fileId"],r),Hv(o.fileId,`${r}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&H(`${r}.mimeType`,"expected a non-empty string"),s.has(o.fileId)&&H(`${r}.fileId`,`duplicate fileId "${o.fileId}"`),s.add(o.fileId)}),s},ok=({packageId:e,packageData:t,path:s,projectData:o,lineIndex:a,canonicalFileIds:r})=>{rr(t,s),ur(t,Mv,s),pr(t,["language","files","patches"],s),Nt(t.language,`${s}.language`);let n=ik(t.files,`${s}.files`);Ya(t.patches,`${s}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=sk({patch:c,path:`${s}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:n,canonicalFileIds:r});return i.has(p.key)&&H(`${s}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:t,fileIds:n,patches:l}},_d=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};rr(t,"l10nData"),ur(t,new Set(["packages"]),"l10nData"),pr(t,["packages"],"l10nData"),rr(t.packages,"l10nData.packages");let s=Kv(e),o=$i(e?.resources??{}),a=new Map,r=new Map;for(let[n,i]of Object.entries(t.packages)){Dt(n,`l10nData.packages.${n}`);let l=ok({packageId:n,packageData:i,path:`l10nData.packages.${n}`,projectData:e,lineIndex:s,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&H(`l10nData.packages.${n}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&H(`l10nData.packages.${n}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,n)}nk(e,l),a.set(n,l)}return{packages:a}},ak=(e,t)=>{let{collectionName:s,patch:o}=t;e.resources[s]??={},e.resources[s][o.resourceId]=vr(o.payload)},lk=(e,t)=>{let{patch:s}=t,o=e.story.scenes[s.sceneId];o.name=s.payload.name},ck=(e,t)=>{let{location:s,patch:o}=t,a=Cd(e,s);if(o.actionType!=="dialogue"){a.actions[o.actionType]=vr(o.payload);return}let r=vr(s.line.actions.dialogue.content);a.actions.dialogue=vr(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},uk=(e,t)=>{let{location:s,patch:o}=t,a=Cd(e,s);a.actions.dialogue.content=vr(o.payload.content)},jd=({projectData:e,l10nData:t})=>{let s=_d({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(s.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},Ci=({projectData:e,l10nData:t,l10nId:s=null})=>{let o=_d({projectData:e,l10nData:t});if(s!==null&&(Dt(s,"l10nId"),o.packages.has(s)||H("l10nId",`package "${s}" was not imported`)),s===null)return e;let a=vr(e),r=o.packages.get(s).patches;return r.filter(n=>n.kind==="resource").forEach(n=>ak(a,n)),r.filter(n=>n.kind==="story.scene").forEach(n=>lk(a,n)),r.filter(n=>n.kind==="line.action").forEach(n=>ck(a,n)),r.filter(n=>n.kind==="line.dialogue").forEach(n=>uk(a,n)),a};var za=Object.freeze({auto:1e3,skip:80,authored:1e3}),Pn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),Nd=new WeakMap,pk=new ArrayBuffer(8),Xa=new DataView(pk),fk=e=>{let t=Nd.get(e);if(t)return t;let s={dispatchDepth:0};return Nd.set(e,s),s},dk=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},mk=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),Vr=(e,t,s)=>{if(!dk(e)||!mk(e,t))throw new TypeError(`${s} has an invalid shape`)},kn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},An=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},Dd=e=>{if(An(e,"duration"),e===0)return 0n;Xa.setFloat64(0,e,!1);let t=Xa.getUint32(0,!1),s=Xa.getUint32(4,!1),o=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(s);if(o===0)return a;let r=1n<<52n|a,n=o-1;return r<<BigInt(n)},yk=e=>structuredClone(e),Ga=(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,Ha=(e,t,s)=>{if(t===null)return null;if(e==="auto"){if(Vr(t,["owner","delayMs","contentKey"],"auto timer"),Vr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),kn(t.owner.sessionId,"auto owner sessionId"),kn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==s)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(An(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")Vr(t,["owner","delayMs"],"skip timer"),Vr(t.owner,["sessionId"],"skip timer owner"),kn(t.owner.sessionId,"skip owner sessionId"),An(t.delayMs,"skip delayMs");else{if(Vr(t,["owner","delayMs","trigger"],"authored timer"),Vr(t.owner,["lineEntryId"],"authored timer owner"),kn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==s)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(An(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,...yk(t)}},hk=e=>{if(Vr(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(kn(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}}Vr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:Ha("auto",e.timers.auto,e.lineEntryId),skip:Ha("skip",e.timers.skip,e.lineEntryId),authored:Ha("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}},Ka=e=>({descriptor:e,remainingQuanta:Dd(e.delayMs)}),_i=["auto","skip","authored"],Td=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:s=()=>"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=fk(e),a=!0,r={},n={},i=null,l=null,c=null,u=null,p=!1,m=!1,f="legacy",d={auto:null,skip:null,authored:null},g={auto:null,skip:null,authored:null},b={auto:0,skip:0,authored:0},y=()=>_i.some(M=>d[M]),w=()=>{l=null,c=null},h=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||m){h();return}a&&r===M.lifecycleToken&&n===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},P=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=i;M&&(w(),i=null,u=M,e.remove(M),u===M&&(u=null))},E=()=>{d={auto:null,skip:null,authored:null}},v=()=>{E(),n={},m||k()},O=M=>{if(o.dispatchDepth>0||m){c=M,h();return}a&&r===M.lifecycleToken&&n===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},T=()=>{if(!a||!y()||i)return;P();let M=r,K=n,le={},z=oe=>{if(!a||M!==r||K!==n||le!==l||z!==i||m)return;if(!oe||typeof oe.deltaMS!="number"||!Number.isFinite(oe.deltaMS)||oe.deltaMS<0)throw new TypeError("playback ticker deltaMS must be a finite non-negative number");let ne=Dd(oe.deltaMS);m=!0,o.dispatchDepth+=1;let ue=n,Z=null;try{let C=[];for(let j of _i){let F=d[j];F&&(F.remainingQuanta<=ne?(C.push({kind:j,descriptor:F.descriptor,revision:b[j]}),d[j]=null):F.remainingQuanta-=ne)}if(C.length>0){try{t({dueKinds:C.map(({kind:j})=>j)})}catch(j){let F=s(j);if(f==="reconciled"&&F==="preCommit")for(let{kind:J,descriptor:de}of C)g[J]=de;else f==="legacy"&&E();throw j}if(f==="legacy")for(let j of C)j.kind==="skip"&&b.skip===j.revision&&d.skip===null&&(d.skip=Ka(j.descriptor))}}catch(C){Z=C}finally{o.dispatchDepth-=1,m=!1;try{ue===n?y()?T():k():i===z&&!y()&&k()}catch(C){throw Z?new AggregateError([Z,C],"Playback attempt and ticker cleanup both failed"):C}}if(Z)throw Z},te={callback:z,lifecycleToken:M,generationToken:K,registrationToken:le};i=z,c=te;try{e.add(z)}catch(oe){throw i=null,w(),E(),n={},u=z,oe}O(te)},$=M=>{b[M]+=1,d[M]=null,g[M]=null,!y()&&!m&&k()},D=(M,K)=>{An(K,`${M} delay`),f="legacy",b[M]+=1,g[M]=null,d[M]=Ka({mode:"legacy",kind:M,instanceToken:{},delayMs:K}),T()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return D("auto",M.payload?.delay??za.auto),!0;case"clearAutoNextTimer":return $("auto"),!0;case"startSkipNextTimer":return D("skip",M.payload?.delay??za.skip),!0;case"clearSkipNextTimer":return $("skip"),!0;case"nextLineConfigTimer":return D("authored",M.payload?.delay??za.authored),!0;case"clearNextLineConfigTimer":return $("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let K;try{K=hk(M)}catch(z){try{v()}catch(te){throw new AggregateError([z,te],"Playback schedule validation and cleanup both failed")}throw z}if(f="reconciled",K.status==="unsettled"){E(),m||k();return}let le={};for(let z of _i){let te=K.timers[z],oe=g[z];if(oe&&(!te||!Ga(oe,te))&&(g[z]=null),te&&g[z]&&Ga(g[z],te)){le[z]=null;continue}let ne=d[z];le[z]=te&&ne&&Ga(ne.descriptor,te)?ne:te?Ka(te):null}d=le,y()?T():m||k()},reset:()=>{let M=[i,u].filter((z,te,oe)=>z&&oe.indexOf(z)===te);r={},n={},w(),i=null,u=null,E(),g={auto:null,skip:null,authored:null};for(let z of _i)b[z]+=1;f="legacy",a=!0;let K=null,le=null;for(let z of M)try{e.remove(z)}catch(te){K??=te,le??=z}if(u=le,K)throw K},dispose:()=>{a=!1,r={},n={},w(),E(),g={auto:null,skip:null,authored:null};let M=[i,u].filter((z,te,oe)=>z&&oe.indexOf(z)===te);i=null,u=null;let K=null,le=null;for(let z of M)try{e.remove(z)}catch(te){K??=te,le??=z}if(u=le,K)throw K}}};var gk=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),bk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Wa="conditional",En="random",Qa=Symbol("conditionalAutoContinue"),wk=new Set(["sectionTransition","resetStoryAtSection"]),Ik=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),vk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),kk=new Set(["nextLine","nextLineFromSystem"]),Ak=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ja="form",Pk=new Set(["submitForm","cancelForm"]),Ek="showImageGalleryVariant",xk="playMusicRoomTrack",Sk="startSceneReplay",Ok="channel:bgm",Rk=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"]),Be=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$k=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,xn=e=>e?.type===Qa,ct=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Ck=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function Za(e){let t=$k(),s,o=0,a=!1,r=0,n=null,i=0,l=!1,c=0,u=[],p=null,m=null,f=new Map,d=new Map,g=new Map,b=0,y=[],w=[],h=!1,P=null,k=null,E=null,v=null,O=new Map,T,$,D=null,B=!1,_=!1,G=0,fe=new Map,M=cc(e.randomSource),{handlePendingEffects:K}=e;if(typeof K!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=K.bind(K),z=typeof K.reconcilePlaybackScheduleV1=="function"?K.reconcilePlaybackScheduleV1.bind(K):null,te=typeof K.reset=="function"?K.reset.bind(K):null,oe=typeof K.dispose=="function"?K.dispose.bind(K):null;if(z&&(!te||!oe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let ne=I=>{if(_)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ue=I=>{if(ne(I),!a||!s)throw new Error(`RouteEngine ${I} requires an active engine`)},Z=(I,A)=>{if(G===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=fe.get(I);(R===void 0||S[A]>S[R])&&fe.set(I,A)},C=I=>{let A=fe.get(I)??"preCommit";return fe.delete(I),A},j=I=>{if(z){_=!0;try{let A=z(structuredClone(I));if(A!==null&&(typeof A=="object"||typeof A=="function")&&typeof A.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{_=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:s?.selectPlaybackLineEntryId?.()??0,timers:null}),J=I=>{if(!(!z||!a||!s)){B=!0;try{j(F())}catch(A){if(I){let S=new AggregateError([I,A],"Playback work and schedule invalidation both failed");throw fe.delete(I),Z(S,"reconcileFailed"),S}throw Z(A,"reconcileFailed"),A}}},de=()=>{if(!z||!B||!a||!s||i>0||l)return;let I;try{I=s.selectDesiredPlaybackTimers()}catch(A){throw Z(A,"reconcileFailed"),J(A),A}try{j({contractVersion:1,status:"settled",lineEntryId:s.selectPlaybackLineEntryId(),timers:I})}catch(A){throw Z(A,"reconcileFailed"),J(A),A}B=!1},Ie=(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}])),we=(I=new Map)=>Array.from(I.values()).map(A=>structuredClone(A.animation)),me=(I=Date.now())=>{f=new Map(Array.from(f.entries()).filter(([,A])=>I<A.expiresAt))},fr=()=>{if(a&&!(i>0||l)){l=!0;try{for(;s.selectPendingEffects().length>0;){let I=s.selectCurrentPointer()?.pointer??null,A=[...s.selectPendingEffects()],S=A.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});s.clearPendingEffects();try{let R=z?S.filter(N=>!Pn.has(N.name)):S;R.length>0&&le(R)}catch(R){throw s.clearPendingEffects(),A.forEach(N=>{s.appendPendingEffect(N)}),Z(R,"postCommitUnsettled"),J(R),R}}}finally{l=!1}de()}},We=I=>{i+=1;let A=!1;try{let S=I();return A=!0,S}finally{i-=1,A&&fr()}},Sn=()=>{let I=s.selectSystemState();return s.selectRuntime()?.skipTransitionsAndAnimations===!0||Da(I)},Fr=()=>{let I=s.selectSystemState();return I.projectData?Wo({presentationState:s.selectPresentationState(),resources:I.projectData?.resources,runtime:s.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer,skipTransitionsAndAnimations:Sn()}):null},Br=()=>s.selectSystemState().projectData?structuredClone(s.selectPresentationState()?.bgm??null):null,kr=()=>({audioEffects:structuredClone(s.selectSystemState().projectData?.resources?.audioEffects??{})}),On=()=>structuredClone(s.selectSystemState().projectData?.resources?.sounds??{}),ut=I=>!!I?.audioEffects,pt=()=>structuredClone(h?P:Fr()),Ur=()=>h?structuredClone(k):Br(),ft=()=>h?structuredClone(E):kr(),Tt=I=>{let A=s.selectSystemState().projectData?.story?.scenes??{};return Object.entries(A).find(([,S])=>S?.sections?.[I])?.[0]},Rn=()=>{if(w.length===0)return;let I=s.selectRuntime()?.skipTransitionsAndAnimations===!0,A=new Set(I?[]:y.map(S=>S.id));w.forEach(S=>{S.status=S.effects?.some(R=>A.has(R.id))?"active":"settled"}),I&&(y=[]),w=[]},$n=(I,A,S,R,N,U,Y)=>{let W=s.selectPlaybackLineEntryId?.()??0,ce=(A.actionPath??["bgm"]).join("."),he=s.selectCurrentPointer()?.pointer,ge=he?.sceneId??Tt(he?.sectionId),ve=A.rollbackSource==="line"&&he?`story.scenes[${JSON.stringify(ge)}].sections[${JSON.stringify(he.sectionId)}].lines[${JSON.stringify(he.lineId)}].actions.${ce}`:ce,Re=A.rollbackSource==="line"?`${o}:${W}:${ve}`:null,Ue=Re?O.get(Re):null;if(Ue)return Ue;b+=1;let De={occurrenceId:`${t}:g${o}:l${W}:audio${b}`,actionPath:ve,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Te={...kr(),sounds:On()},$e=Ec({occurrence:De,resources:Te,previousResources:Y??Te,nextResources:Te,previousChannel:S,nextChannel:R,previousBgm:N,nextBgm:U});if(De.effects=structuredClone($e),De.status=$e.length>0?"pending":"settled",y=structuredClone($e),w.push(De),Re)for(O.set(Re,De);O.size>512;){let mt=O.keys().next().value;O.delete(mt)}return De},Cn=({initialState:I,namespace:A})=>{ne("initialize");let S=s?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...N}=I,U=R===void 0?void 0:structuredClone(R),Y=structuredClone(I.projectData),W=jd({projectData:Y,l10nData:U}),ce=N.global??{};if(!Be(ce))throw new Error("Malformed global state.");let he=ce.runtime??{};if(!Be(he))throw new Error("Malformed global.runtime.");let ge=he.localizationPackageId;if(ge!=null&&typeof ge!="string")throw new Error("localizationPackageId requires a string or null value");let ve=new Set(W.map(({l10nId:Te})=>Te).filter(Te=>Te!==null)),Re=typeof ge=="string"&&ve.has(ge)?ge:null,Ue=Ci({projectData:Y,l10nData:U,l10nId:Re}),De=lf({...N,global:{...ce,localizationPackages:W,runtime:{...he,localizationPackageId:Re}},projectData:Ue,initialAudioCommandId:S});te?.(),s=De,o+=1,a=!0,r=0,n=jt(A),i=0,l=!1,c=0,u=[],p=null,m=null,f=new Map,d=new Map,g=new Map,b=0,y=[],w=[],h=!1,P=null,k=null,E=null,v={lineEntryId:s.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:kr()},O=new Map,T=Y,$=U,D=Re,B=!0,_=!1,G=0,fe.clear(),s.appendPendingEffect({name:"handleLineActions"}),fr()},Fd=()=>{ne("dispose"),a&&(a=!1,o+=1,s?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,m=null,f=new Map,d=new Map,g=new Map,y=[],w=[],h=!1,P=null,k=null,E=null,v=null,O=new Map,B=!1,fe.clear(),oe?.())},Bd=()=>n,Ud=()=>s.selectPresentationState(),Yd=()=>s.selectPresentationChanges(),zd=I=>s.selectSectionLineChanges(I),rl=(I={})=>{ue("rendering"),r+=1;let A=Date.now();me(A);let S=d.size>0,R=Ie(f,A),N=S?Ie(d,A):new Map,U=s.selectRenderState({activePersistentAnimations:we(R),restoredPersistentAnimations:we(N),activeAudioEffects:structuredClone(y)}),Y={...U,id:`render-${t}-${o}-${r}`};return g.set(Y.id,{builtAt:A,persistentAnimationSessions:new Map([...N.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectIds:y.map(W=>W.id),bgmPresentation:Br(),bgmResources:kr(),retainsActiveAudioEffects:y.length>0&&y.every(W=>(U.audioEffects??[]).some(ce=>ce.id===W.id))}),Y},Xd=(I={})=>rl(I),Gd=(I={})=>rl(I),Hd=I=>{if(!a||!s)return;let A=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=A?g.get(A):null;A&&g.delete(A);let R=I?.audio?.find(U=>U?.id===Ok);h=!0,P=R?structuredClone(R):null,k=structuredClone(S?.bgmPresentation??null),E=structuredClone(S?.bgmResources??null);let N=new Map;ou(I?.animations).forEach(U=>{let Y=us(U);if(!Y)return;let W=S?.persistentAnimationSessions?.get(Y)??f.get(Y),ce=Math.max(0,cu(U)),he=W?.startedAt??S?.builtAt??Date.now();N.set(Y,{animation:structuredClone(U),startedAt:he,expiresAt:he+ce})}),f=N,S?.usedRestoredPersistentAnimationSessions&&(d=new Map),S?.activeAudioEffectIds?.length>0&&!S.retainsActiveAudioEffects&&y.length===S.activeAudioEffectIds.length&&S.activeAudioEffectIds.every(U=>y.some(Y=>Y.id===U))&&(y=[])},Kd=()=>s.selectSystemState(),Wd=()=>s.selectAchievements(),Jd=I=>s.selectAchievement(I),tl=()=>s.selectSaveSlotMap(),Qd=I=>s.selectSaveSlot(I),Zd=I=>s.selectSaveSlotPage(I),em=()=>s.selectImageGallery(),rm=()=>s.selectMusicRoom(),tm=()=>s.selectSceneReplay(),nm=()=>s.selectIsSceneReplayActive(),Yk=()=>s.selectSkipMode(),zk=()=>s.selectAutoMode(),sm=()=>s.selectRuntime(),im=()=>s.selectIsChoiceVisible(),om=()=>s.selectIsFormVisible(),am=()=>s.selectActiveInteraction(),lm=()=>s.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),nl=(I,A,S={})=>!Be(A)||I!=="nextLine"?A:S.bypassChoice===!0?{...A,bypassChoice:!0}:S.interactionSource===Ja?{...A,_interactionSource:Ja}:A,sl=(I={})=>({type:Qa,payload:nl("nextLine",{_conditionalContinuation:!0},I)}),ji=(I,A)=>xn(I)?{type:Qa,payload:{...I.payload,...A.payload}}:A,cm=I=>{I.savedCheckpointOccurrences.forEach(A=>{s.markSavedRollbackCheckpointTransient(A)}),I.savedCheckpointOccurrences=[]},um=(I,A)=>{let S=p;return p=null,!S||!ct(S.pointer,I)||S.checkpointIndex!==A?.checkpointIndex||S.checkpointIdentity!==A?.checkpoint?[]:S.savedCheckpointOccurrences},pm=I=>{let A=m;return!A||!ct(A.pointer,I)?null:(m=null,A)},fm=({actionType:I,pointerBeforeAction:A,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:N,wasSceneReplayActive:U,isSceneReplayActive:Y})=>{!S||!(!ct(A,S)||R?.checkpoint!==N?.checkpoint||R?.checkpointIndex!==N?.checkpointIndex||I==="jumpToLine")||(m={pointer:S,appendToPrevious:kk.has(I)&&U===Y&&A?.sectionId===S.sectionId&&A?.lineId!==S.lineId,reuseExistingOccurrence:Ak.has(I),forceNewOccurrence:I==="jumpToLine"})},il=I=>{I.markCurrentCheckpointTransient&&(s.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),cm(I))},dm=(I,A,S)=>Ik.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==A?.checkpoint:S?.checkpoint!==A?.checkpoint&&S?.checkpointIndex>A?.checkpointIndex:!1,mm=I=>{let A=u.at(-1);if(!A?.markCurrentCheckpointTransient)return;let S=s.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})},ym=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(A=>{let S=s.selectSaveSlot({slotId:A.slotId});S&&(A.saveSlotIdentity=S)})},hm=()=>{let I=u.at(-1);I&&(I.rollbackCursor=s.selectRollbackCursor?.()??null)},gm=(I,A,S)=>{let R=u.at(-1);if(!R)return;let N=s.selectCurrentPointer()?.pointer,U=dm(I,A,S);if(ct(R.pointer,N)){let Y=S?.checkpoint!==A?.checkpoint||S?.checkpointIndex!==A?.checkpointIndex;U||Y&&vk.has(I)?(il(R),R.pointer=N,R.rollbackCursor=S,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]):Y&&I==="updateProjectData"&&(R.rollbackCursor=S);return}il(R),R.pointer=N,R.rollbackCursor=s.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]},dt=(I,A)=>{if(ue(`action "${I}"`),!s[I])return;let S=A,R,N;if(I==="updateProjectData")ol(A),R=structuredClone(A.projectData),S={...A,projectData:Ci({projectData:R,l10nData:$,l10nId:D})},ol(S);else if(I==="updateLocalizationPackage"){if(N=bm(A),N===D)return;S={l10nId:N,projectData:Ci({projectData:T,l10nData:$,l10nId:N})}}wk.has(I)&&(c+=1);let U=s.selectAutoMode(),Y=U?s.selectRuntime():null,W=s.selectIsSceneReplayActive?.()===!0,ce=bk.has(I)?Ie(f):null,he=s.selectCurrentPointer()?.pointer??null,ge=s.selectRollbackCursor?.()??null,ve=ns(I),Re=ve?s.selectPlaybackLineEntryId?.()??0:null,Ue=ve?pt():null,De=ve?Ur():null,Te=ve?ft():null,$e=!1,mt;try{mt=s[I](S),$e=!0}catch(Lt){throw Z(Lt,"preCommit"),Lt}R!==void 0&&(T=R),N!==void 0&&(D=N),gk.has(I)&&(d=ce??new Map,f=new Map,y=[]),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=[]);let fl=s.selectIsSceneReplayActive?.()===!0;W!==fl&&(f=new Map,d=new Map);let _m=s.selectCurrentPointer()?.pointer??null,dl=s.selectRollbackCursor?.()??null,ml=ve?s.selectPlaybackLineEntryId?.()??0:null;ve&&ml!==Re&&(v={lineEntryId:ml,channel:Ue,presentation:De,resources:Te}),I==="saveSlot"?mm(A):I==="updateProjectData"&&ym(),gm(I,ge,dl),fm({actionType:I,pointerBeforeAction:he,pointerAfterAction:_m,cursorBeforeAction:ge,cursorAfterAction:dl,wasSceneReplayActive:W,isSceneReplayActive:fl});let jm=s.selectAutoMode()&&(I==="updateVariable"||U&&Ck(Y,s.selectRuntime()));(Rk.has(I)||jm)&&(B=!0);try{fr()}catch(Lt){throw $e&&Z(Lt,"postCommitUnsettled"),Lt}return mt},ol=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Wr(I?.projectData?.resources?.variables??{}),Yt(I.projectData),zt(I.projectData),Xt(I.projectData)},bm=I=>{if(!Be(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},wm=(I,A,S)=>{let R=s.selectCurrentPointer()?.pointer;A!==R||S!==c||(s.appendPendingEffect({name:"clearAutoNextTimer"}),s.appendPendingEffect({name:"clearNextLineConfigTimer"}),dt("nextLineFromSystem",I.payload))},Im=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:m,persistentAnimationSessions:new Map(f),restoredPersistentAnimationSessions:new Map(d),renderPersistentAnimationMetadata:new Map(g),audioEffectOccurrenceSequence:b,activeAudioEffects:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:v?structuredClone(v):null,acceptedLineBgmActionOccurrences:new Map(O),canonicalProjectData:T,localizationPackageId:D,playbackScheduleDirty:B}),vm=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,m=I.pendingDialogueHistoryLineEntry,f=new Map(I.persistentAnimationSessions),d=new Map(I.restoredPersistentAnimationSessions),g=new Map(I.renderPersistentAnimationMetadata),b=I.audioEffectOccurrenceSequence,y=I.activeAudioEffects,w=I.pendingAudioEffectOccurrences.slice(),v=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,O=new Map(I.acceptedLineBgmActionOccurrences),T=I.canonicalProjectData,D=I.localizationPackageId,B=I.playbackScheduleDirty},Ni=(I,A={})=>(ue("action batch"),We(()=>{let S=Im();try{return s[lo](()=>{let R,N=s.selectCurrentPointer()?.pointer??null,U=s.selectRollbackCursor?.()??null,Y=c,W={pointer:N,rollbackCursor:U,markCurrentCheckpointTransient:A.rollbackSource==="line",savedCheckpointOccurrences:A.savedCheckpointOccurrences?.slice()??[]};u.push(W);try{s.beginRollbackActionBatch({source:A.rollbackSource});try{R=I()}finally{s.endRollbackActionBatch({})}xn(R)&&wm(R,N,Y),Rn();let ce=s.selectCurrentPointer()?.pointer??null;A.rollbackSource==="line"&&ct(N,ce)&&s.recordCurrentDialogueHistory({savedCheckpointOccurrences:W.savedCheckpointOccurrences,appendToPrevious:A.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:A.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:A.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!ct(N,W.pointer)||U?.checkpoint!==W.rollbackCursor?.checkpoint)&&W.markCurrentCheckpointTransient&&W.savedCheckpointOccurrences.length>0&&(p={pointer:W.pointer,checkpointIndex:W.rollbackCursor?.checkpointIndex,checkpointIdentity:W.rollbackCursor?.checkpoint,savedCheckpointOccurrences:W.savedCheckpointOccurrences})}})}catch(R){throw vm(S),R}})),Di=(I,A,S,R={})=>{if(I===Wa||I===En)return Ni(()=>{let N={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===En)return cl(A,S,N);let U=Ti(S),Y=Wt({[I]:A},U);return ll(Y[I],S,N)},R);if(I==="bgm")return Ni(()=>{let N=Ur(),U=ut(A),Y=U?pt():null,W=U?ft():null;dt(I,A);let ce=Br();$n(A,{...R,actionPath:R.actionPath??[I]},Y,U?Fr():null,N,ce,W)},R);dt(I,A)},km=(I,A)=>{if(I!=="nextLineFromSystem")return Di(I,A);G+=1;try{return Di(I,A)}finally{G=Math.max(0,G-1)}},al=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Ti=I=>{if(al(I),!I)return{variables:s.selectAllVariables?s.selectAllVariables():void 0,runtime:s.selectRuntime?s.selectRuntime():{}};let{_event:A,...S}=I,R=s.selectAllVariables?s.selectAllVariables():void 0;return{...S,_event:A,variables:R,runtime:s.selectRuntime?s.selectRuntime():{}}},Am=I=>{if(!Be(I))return{templatePayload:I,literalTargetIds:null};let A=s.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}:{}}}},Pm=I=>!Be(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:s.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Em=I=>!Be(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:s.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},xm=I=>{if(!Be(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")},Sm=(I,A,S)=>{if(!Be(I))throw new Error(`conditional branch at index ${A} must be an object`);if(!Be(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")},ll=(I,A,S)=>{xm(I);let R=sl(S);for(let N=0;N<I.branches.length;N+=1){let U=I.branches[N];Sm(U,N,I.branches.length);let Y=Ti(A);if(Object.prototype.hasOwnProperty.call(U,"when")&&!Ut(U.when,Y))continue;let ce=_n(U.actions,A,{...S,actionPath:[...S.actionPath??[Wa],"branches",String(N),"actions"]});return xn(ce)?ji(R,ce):R}return R},Om=I=>{if(!Be(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(!Be(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=T?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||_e(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},cl=(I,A,S)=>{Om(I),al(A);let R=uc(I.distribution,{randomSource:M});if(S.rollbackSource==="line"){s.ensureRandomReplayOccurrence({});let Y=(S.actionPath??[En]).join("."),W=S.randomOutcomeOrdinals??new Map,ce=W.get(Y)??0;W.set(Y,ce+1),s.recordRandomOutcome({path:Y,ordinal:ce,type:R.type,result:R}),hm()}let N;R.type==="integer"?dt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):N=_n(I.distribution.outcomes[R.outcomeIndex].actions,A,{...S,actionPath:[...S.actionPath??[En],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let U=sl(S);return xn(N)?ji(U,N):U},Rm=(I,A)=>({...I??{},_form:A}),$m=(I,A,S,R)=>{let N=dt(I,A),U=N?.submitted===!0&&N.valid===!0,Y=N?.cancelled===!0;if(!(!U&&!Y)&&Be(A.actions))return _n(A.actions,Rm(S,N.form),{...R,interactionSource:Ja})},ul=(I,A,S,R)=>{if(I===En)return cl(A,S,R);let N=Ti(S),U={templatePayload:A,literalTargetIds:null};I===Ek?U=Am(A):I===xk?U=Pm(A):I===Sk&&(U=Em(A));let{templatePayload:Y,literalTargetIds:W}=U,he=Wt({[I]:Y},N)[I],ge=W?{...he,...W}:he;if(I===Wa)return ll(ge,S,R);let ve=nl(I,ge,R);if(Pk.has(I))return $m(I,ve,S,R);let Re=null,Ue=null,De=null,Te=!1;if(I==="bgm"){let $e=R.audioEffectHandoff,mt=$e?.available?$e.presentation:Ur();Te=ut(ve),Te&&$e?.available?($e.available=!1,Re=structuredClone($e.channel),Ue=structuredClone($e.presentation),De=structuredClone($e.resources)):Te&&(Re=pt(),Ue=mt,De=ft())}if(dt(I,ve),I==="bgm"){let $e=Br();$n(ve,R,Re,Te?Fr():null,Ue,$e,De)}},_n=(I,A,S)=>{let R,N=S?.executionContext??{depth:0,pendingNavigation:null},U=ts(I);ss(U),N.depth+=1;try{for(let[Y,W]of U){let ce={...S,executionContext:N,actionPath:[...S?.actionPath??[],Y]};if(ns(Y)){let ge=N.pendingNavigation;if(ge)throw new Error(`action batch cannot execute multiple navigation actions: ${ge.actionType}, ${Y}`);N.pendingNavigation={actionType:Y,payload:W,eventContext:A,options:ce};continue}let he=ul(Y,W,A,ce);xn(he)&&(R=ji(R,he))}}finally{N.depth-=1}if(N.depth===0&&N.pendingNavigation){let Y=N.pendingNavigation;N.pendingNavigation=null,ul(Y.actionType,Y.payload,Y.eventContext,Y.options)}return R},pl=(I,A,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return Ni(()=>_n(I,A,R),R)},Cm=I=>{let A=s.selectCurrentPointer()?.pointer;if(I!==A||s.selectActiveInteraction())return;let S=s.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&s.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:Cn,dispose:Fd,handleAction:Di,handleInternalAction:km,handleActions:pl,selectRenderState:Xd,prepareRenderState:Gd,commitRenderState:Hd,selectPresentationState:Ud,selectPresentationChanges:Yd,selectSectionLineChanges:zd,selectSystemState:Kd,selectAchievements:Wd,selectAchievement:Jd,selectSaveSlotMap:tl,selectSaveSlot:Qd,selectSaveSlotPage:Zd,selectSaveSlots:tl,selectImageGallery:em,selectMusicRoom:rm,selectSceneReplay:tm,selectIsSceneReplayActive:nm,selectRuntime:sm,selectIsChoiceVisible:im,selectIsFormVisible:om,selectActiveInteraction:am,selectHasPendingRenderWork:lm,handleLineActions:I=>{ue("line action handling");let A=s.selectCurrentPointer()?.pointer;if(I?.pointer&&!ct(I.pointer,A))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=s.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return We(()=>{let S=s.selectCurrentPointer()?.pointer,R=s.selectPlaybackLineEntryId?.()??0,N=v?.lineEntryId===R?v:null,U=N?{available:!0,channel:structuredClone(N.channel),presentation:structuredClone(N.presentation),resources:structuredClone(N.resources)}:null,Y=s.selectRollbackCursor?.()??null,W=p,ce=m,he=um(S,Y),ge=pm(S),ve=s.selectCurrentLine(),Re=!1;if(ve?.actions){try{pl(ve.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:he,dialogueHistoryAppendToPrevious:ge?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ge?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ge?.forceNewOccurrence===!0,audioEffectHandoff:U})}catch(Ue){throw p=W,m=ce,Ue}Re=!0}return v?.lineEntryId===R&&(v=null),Cm(S),Re})},getNamespace:Bd,classifyAutomaticAttemptError:C}}var _k="music-room:player",qd=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Ld=(e,t)=>qd.has(e)&&t?._event?.id===_k,Vd=({engine:e,routeGraphics:t,trackRenderDispatch:s,lifecycleGeneration:o,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let n=e.prepareRenderState?.(r)??e.selectRenderState(r);s?.(n),t.render(n),a(o)&&e.commitRenderState?.(n)},jk=({engine:e,routeGraphics:t,trackRenderDispatch:s,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},n)=>{let i=o?.()??0,l=e.handleLineActions(n);(o?.()??0)===i&&Vd({engine:e,routeGraphics:t,trackRenderDispatch:s,lifecycleGeneration:a,isCurrentLifecycle:r},n)},Nk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveSlots(t?.saveSlots))},Dk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalDeviceVariables(t?.globalDeviceVariables))},Tk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalAccountVariables(t?.globalAccountVariables))},Lk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalRuntime(t?.globalRuntime))},Mk=({enqueuePersistenceWrite:e},t)=>{e(s=>{if(typeof s.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return s.applyScopedDataUpdates(t?.updates)})},Md={render:Vd,saveSlots:Nk,saveGlobalDeviceVariables:Dk,saveGlobalAccountVariables:Tk,saveGlobalRuntime:Lk,applyScopedDataUpdates:Mk,handleLineActions:jk},qk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),el=(e,t,s)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,s)},Vk=(e=[])=>{let t=new Set,s=[];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(!qk.has(a.name)){s.unshift(a);continue}t.has(a.name)||(t.add(a.name),s.unshift(a))}return s},Fk=({getEngine:e,routeGraphics:t,ticker:s,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:r,persistence:n,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,m=!1,f=0,d=0,g=!0,b=Td({ticker:s,dispatchAutomaticAttempt:()=>el(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),y=()=>{u=null,p=null,m=!1,f=0},w=()=>{b.reset(),d+=1,y(),g=!0},h=()=>{d+=1,g=!1,y(),b.dispose()},P=C=>g&&C===d,k=C=>{if(a){a(C);return}console.error("RouteEngine persistence write failed.",C)},E=C=>{if(n)return n;let j=jt(C),F=l.get(j);if(F)return F;let J=Va({indexedDB:r,namespace:j});return l.set(j,J),J},v=C=>{let j=n?null:jt(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=E(j),C(F))).catch(J=>{!n&&l.get(j)===F&&l.delete(j),k(J)})},O=C=>{if(!g)return;let j=typeof C?.id=="string"&&C.id.length>0?C.id:null;f+=1,u=j,m=!1},T=()=>f,$=(C={})=>{if(!g||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||m?!1:(m=!0,!0)},D=(C,j={})=>{if(!g)return!1;if(Ld(C,j)){let J=qd.get(C),de=e();return el(de,J,j?._event),!0}if(C!=="renderComplete"||!$(j))return!1;let F=e();return el(F,"markLineCompleted",{}),!0},B=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),G=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,fe=C=>C?._formKey??C?.formKey,M=(C,j)=>fe(C)===j?.formKey,K=(C,j)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===j?.source,le=(C,j)=>K(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),te=(C={},j)=>Object.keys(C).length>0&&Object.entries(C).every(([F,J])=>B.has(F)?z(J,j):_.has(F)),oe=(C={},j)=>{let F=C?.actions;return j?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:te(F,j):le(C,j)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(J=>le(J,j))},ne=(C,j={})=>{if(!j?.actions)return!1;let F=G(C);return!F||F.source==="choice"?!1:!oe(j,F)},ue=({preprocessPayload:C,onEvent:j}={})=>async(F,J={})=>{if(!g)return!1;if(Ld(F,J))return D(F,J),j?.(F,J);let de=e(),Ie=d,we=f;if(ne(de,J))return j?.(F,J);let me=await C?.(F,J)??J;if(!P(Ie)||e()!==de||f!==we)return!1;if(ne(de,me))return j?.(F,me);if(D(F,me),me?.actions){let fr=me?._event?{_event:me._event}:me?.event?{_event:me.event}:void 0,We;me?.bypassChoice===!0?We={bypassChoice:!0}:me?._interactionSource&&(We={interactionSource:me._interactionSource}),We?de.handleActions(me.actions,fr,We):de.handleActions(me.actions,fr)}return j?.(F,me)},Z=C=>{if(!g)return;let j=d,F=e(),J=Vk(C),de=J.some(we=>we.name==="handleLineActions");J.forEach(we=>{if(!Md[we.name]&&!Pn.has(we.name)&&!o)throw new Error(`Unhandled pending effect "${we.name}".`)});let Ie={engine:F,routeGraphics:t,ticker:s,trackRenderDispatch:O,getRenderDispatchCount:T,enqueuePersistenceWrite:v,lifecycleGeneration:d,isCurrentLifecycle:P};for(let we of J){if(!P(j))break;if(de&&we.name==="render")continue;if(Pn.has(we.name)){b.handleLegacyEffect(we);continue}let me=Md[we.name];if(me){me(Ie,we.payload);continue}o(we,Ie)}};return Z.handleRouteGraphicsEvent=D,Z.createRouteGraphicsEventHandler=ue,Z.reset=w,Z.dispose=h,Z.reconcilePlaybackScheduleV1=C=>b.reconcilePlaybackScheduleV1(C),Z},Bk=Fk;var Uk=(e,t={})=>{let{resources:s={}}=t;return Uo(e,s)};var zP=Za;export{Ao as DEFAULT_VISUAL_LAYER,kt as RENDER_LAYER,dr as VISUAL_LAYER,Bk as createEffectsHandler,bv as createIndexedDbPersistence,zP as default,uo as formatDate,sh as resolveComputedVariables,Uk as resolveLayoutReferences};
|
|
4
|
+
[${a}] Sound beginEffect and endEffect selections require an audio effect resource with type "update".`);let n=Ic(e,t),i={};for(let l of go)tr(r.tween,l)&&(i[l]=kc({property:l,authored:r.tween[l],speed:n,resourcePath:a}));return i},Pc=({bgm:e,resources:t={}})=>{let s=e?.audioEffects?.resourceId,o=t.audioEffects?.[s];if(o?.type!=="update"||(e.sounds??[]).length===0)return e;let r=structuredClone(e);for(let n of go){if(!tr(o.tween,n))continue;let i=o.tween[n].keyframes.at(-1);typeof i?.value!="number"||!Number.isFinite(i.value)||i.relative===!0||(n==="volume"?r.volume=i.value:n==="pan"?r.pan=i.value:r.sounds.forEach(l=>{l.playbackRate=i.value}))}return r},hc=(e,t)=>({id:`audio-effect:${e.occurrenceId}`,type:"audio-transition",targetId:t}),gc=e=>{if(!e)return e;let t={...e};return delete t.beginEffect,delete t.endEffect,t},Rh=({occurrence:e,resources:t={},nextResources:s=t,previousChannel:o,nextChannel:a,previousBgm:r,nextBgm:n})=>{if(!e?.selection)return null;let i=e.selection,l=e.actionPath??"bgm",c=i.resourceId,u=`resources.audioEffects.${c}`,p=t.audioEffects?.[c];if(!p)throw new Error(`[${l}.audioEffects.resourceId]
|
|
5
|
+
[${u}] Unknown audio effect resource "${c}".`);let d=Ic(i,`${l}.audioEffects`),f=dc(o,l),m=dc(a,l);if(!f&&!m)return null;if(f&&m&&f.id!==m.id)throw new Error(`[${l}.audioEffects] Audio effects require a stable BGM sound id across a handoff.`);let g=f?.id??m.id,b=bc(f,m),y=wc(gc(f),gc(m));if(p.type==="transition"){if(b){if(y)return null;throw new Error(`[${l}.audioEffects]
|
|
6
|
+
[${u}] Audio effect resource "${c}" has type "transition", but the BGM action only updates a retained sound. Use an update resource.`)}let h={},P=yc(f?p.prev?.fade:void 0,"exit",d,f?.volume??It.volume,`${u}.prev.fade`),k=yc(m?p.next?.fade:void 0,"enter",d,m?.volume??It.volume,`${u}.next.fade`);return P&&(h.exit=P),k&&(h.enter=k),Object.keys(h).length===0?null:{...hc(e,g),properties:{volume:h}}}if(p.type!=="update")throw new Error(`[${u}.type] Unsupported audio effect type "${p.type}".`);if(!f||!m||!b)throw new Error(`[${l}.audioEffects]
|
|
7
|
+
[${u}] Audio effect resource "${c}" has type "update", but the BGM action changes source identity. Use a transition resource.`);let w={};for(let h of go){if(!tr(p.tween,h))continue;let P=kc({property:h,authored:p.tween[h],speed:d,resourcePath:u,normalizeValue:({value:O,relative:T})=>xh({property:h,value:O,relative:T,nextBgm:n,nextResources:s,nextSound:m})});h==="pan"&&(P.keyframes=Sh({authoredInitialValue:p.tween[h].initialValue,authoredKeyframes:p.tween[h].keyframes,compiledKeyframes:P.keyframes,previousBgm:r,nextBgm:n,nextResources:s,nextSound:m}));let k=m[h]??It[h],E=P.keyframes.at(-1).value;if(!Eh(E,k))throw new Error(`[${l}.audioEffects]
|
|
8
|
+
[${u}.tween.${h}.keyframes] The final keyframe value must match the persistent BGM ${h} value.`);P.keyframes.at(-1).value=k,(f[h]??It[h])!==k&&(w[h]={update:P})}return Object.keys(w).length===0?null:{...hc(e,g),properties:w}},Ec=e=>{let t=e.nextResources??e.resources,s=e.occurrence;if(!s?.selection)return[];let o=e.previousChannel?.children??[],a=e.nextChannel?.children??[],r=s.selection.resourceId,n=t?.audioEffects?.[r],i=(f,m)=>m?{...f,children:[m]}:null,l=f=>f.map(({previousSound:m,nextSound:g},b)=>Rh({...e,occurrence:b===0?s:{...s,occurrenceId:`${s.occurrenceId}:${b}`},resources:t,previousChannel:i(e.previousChannel,m),nextChannel:i(e.nextChannel,g)})).filter(Boolean);if(!n||!["transition","update"].includes(n.type))return l([{previousSound:o[0],nextSound:a[0]}]);let c=new Map(o.map(f=>[f.id,f])),u=new Map(a.map(f=>[f.id,f]));if(n.type==="update"){let f=a.map(b=>({previousSound:c.get(b.id),nextSound:b})),m=f.find(({previousSound:b})=>!b);if(m)return l([m]);let g=o.find(b=>!u.has(b.id));return l(g?[{previousSound:g}]:f)}let p=[];for(let f of o){let m=u.get(f.id);(!m||!bc(f,m))&&p.push({previousSound:f,nextSound:m})}for(let f of a)c.has(f.id)||p.push({nextSound:f});if(p.length>0)return l(p);let d=o.find(f=>{let m=u.get(f.id);return m&&!wc(f,m)});return l([{previousSound:d??o[0],nextSound:d?u.get(d.id):a[0]}])};var ae=e=>structuredClone(Pe(e)?Pr(e):e),ie=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),Qt=e=>e?.animations?.playback?.continuity==="persistent",X=(e,t)=>ie(e??{},t)&&e[t]!==void 0,is=e=>X(e,"alpha")||X(e,"opacity"),$h=e=>X(e,"alpha")?e.alpha:e?.opacity,Nc=e=>(X(e,"alpha")&&(e.opacity=e.alpha),delete e.alpha,e),Ch=e=>e?.applyMode==="persistent",_h="default",Nh=e=>Array.isArray(e?.channels)?e.channels.filter(Ch).map(ae):[],Zt=(e,t)=>e?!t(e)&&e.animations?{animationsOnly:!0,state:{animations:ae(e.animations)}}:{animationsOnly:!1,state:null}:{animationsOnly:!1,state:null},jh=e=>is(e)||X(e,"blur")||X(e,"filters"),wo=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],jc=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],bo=["animationName","animationSpeed","loop"],Dh=e=>X(e,"transformId")||X(e,"transform")||wo.some(t=>X(e,t)),Dc=e=>e?.text&&X(e.text,"content")&&X(e.text,"textStyleId"),Tc=e=>e?.layout&&Array.isArray(e.layout.elements),Th=e=>X(e,"text")||X(e,"layout"),xc=(e,t)=>e.resourceId?!0:Dc(e)?!t?.text:Tc(e)?!t?.layout:!1,Sc=e=>e?.sprites&&e.sprites.length>0||e?.transformId||e?.resourceId,Lh=(e,t)=>{let s={...ae(e),...t};if(t.text&&e.text&&(s.text={...ae(e.text),...ae(t.text)}),t.transform&&e.transform&&(s.transform={...ae(e.transform),...ae(t.transform)}),X(t,"transform")){delete s.transformId;for(let o of wo)X(t,o)||delete s[o]}else X(t,"transformId")&&delete s.transform;return s},Mh=(e,t)=>{let s=[e.resourceId,e.text,e.layout].filter(o=>o!==void 0).length;if(s>1)throw s===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")&&!Dc(e)&&!t?.text)throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(X(e,"layout")&&!Tc(e))throw new Error(`Visual item "${e.id}" layout requires elements`)},Oc=e=>jc.some(t=>X(e,t)),Rc=e=>bo.some(t=>X(e,t)),Vh=(e,t,{hasAuthoredTransformId:s=!1}={})=>{if(!t)return e;for(let o of jc)!s&&!X(e,o)&&X(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Lc=(e,t,s)=>{let o=e[s];return o?.id===t?.id?o:e.find(a=>a.id===t?.id)},qh=(e,t)=>{if(!t)return e;let s=X(e,"transform");for(let o of wo)!s&&!X(e,o)&&X(t,o)&&(e[o]=t[o]),ie(e,o)&&e[o]===void 0&&delete e[o];return e},Fh=(e,t)=>(t&&(!X(e,"opacity")&&X(t,"opacity")&&(e.opacity=t.opacity),!X(e,"blur")&&X(t,"blur")&&(e.blur=ae(t.blur)),!X(e,"filters")&&X(t,"filters")&&(e.filters=ae(t.filters)),ie(e,"opacity")&&e.opacity===void 0&&delete e.opacity,ie(e,"blur")&&e.blur===void 0&&delete e.blur,ie(e,"filters")&&e.filters===void 0&&delete e.filters),e),Mc=(e,t,s=[],{hasPatchFn:o=()=>!1,mergeItemFn:a}={})=>{if(!e||e.length===0)return{hasValidItems:!1,processedItems:[]};let r=e.map((n,i)=>{let l=Lc(s,n,i),c=t(n,l),u=jh(n),p=Dh(n),d=o(n),f=ie(n,"animations"),m=Nc(ae(n));if(!c&&(u||p||d)&&l&&(m=a?a(l,m):{...ae(l),...m}),!f){let g=l?t(l):!1,b=t(m);g&&b&&Qt(l)?m.animations=ae(l.animations):delete m.animations}return Fh(qh(m,l),l)}).filter(n=>t(n)||n.animations);return{hasValidItems:r.length>0,processedItems:r}},Bh=e=>{if(e){if(e.character&&ie(e.character,"name"))return e.character.name;if(ie(e,"characterName"))return e.characterName}},Vc=e=>!!e?.character&&ie(e.character,"sprite"),Uh=e=>{let t={},s=!1,o=Bh(e);return o!==void 0&&(t.name=o,s=!0),Vc(e)&&(t.sprite=ae(e.character.sprite),s=!0),s?t:void 0},$c=e=>{e?.character?.sprite?.animations&&(e.character.sprite.animations={})},Cc=({dialogueState:e,dialogueAction:t,persistCharacter:s})=>ie(t,"persistSprite")?t.persistSprite===!0:ie(e,"persistSprite")?e.persistSprite===!0:s&&!ie(t,"characterId"),_c=({previousCharacter:e,characterFields:t,hasCharacterId:s,persistCharacter:o,persistSprite:a,hasExplicitPersistSprite:r,isAppendingAdvDialogueContent:n})=>{let i={},l=e??{},c=t??{},u=n&&!s,p=u&&!r;return ie(c,"name")?i.name=c.name:(o&&!s||u)&&ie(l,"name")&&(i.name=ae(l.name)),ie(c,"sprite")?i.sprite=ae(c.sprite):(a||p)&&ie(l,"sprite")&&(i.sprite=ae(l.sprite)),Object.keys(i).length>0?i:void 0},Yh=({dialogueState:e,content:t,append:s=!1})=>{if(!s||!Array.isArray(t)){e.content=t,delete e.initialRevealedContent;return}let o=Array.isArray(e.content)?e.content:[];o.length>0?e.initialRevealedContent=o.map(a=>ae(a)):delete e.initialRevealedContent,e.content=[...o,...t]},zh=()=>({}),Xh=(e,t)=>{if(!t.screen)return;let s=is(t.screen),o=X(t.screen,"blur"),a=ie(t.screen,"animations");if(!s&&!o){a||delete e.screen;return}let r=e.screen,n={};if(s?n.opacity=$h(t.screen):X(r,"opacity")&&(n.opacity=r.opacity),o?n.blur=ae(t.screen.blur):X(r,"blur")&&(n.blur=ae(r.blur)),ie(n,"opacity")&&n.opacity===void 0&&delete n.opacity,ie(n,"blur")&&n.blur===void 0&&delete n.blur,Object.keys(n).length===0){delete e.screen;return}e.screen=n},Gh=(e,t)=>{if(t.background){let s=X(t.background,"resourceId"),o=X(t.background,"colorId"),a=is(t.background),r=X(t.background,"blur"),n=X(t.background,"filters"),i=X(t.background,"transformId"),l=Oc(t.background),c=Rc(t.background),{animationsOnly:u,state:p}=Zt(t.background,m=>X(m,"resourceId")||X(m,"colorId")||is(m)||X(m,"blur")||X(m,"filters")||X(m,"transformId")||Oc(m)||Rc(m));if(u){e.background=e.background?{...ae(e.background),...p}:p;return}if(!s&&!o&&!a&&!r&&!n&&!i&&!l&&!c){delete e.background;return}let d=e.background,f=Nc(ae(t.background));if(!s&&d?.resourceId){f.resourceId=d.resourceId,!ie(f,"transformId")&&d.transformId&&(f.transformId=d.transformId);for(let m of bo)!X(f,m)&&X(d,m)&&(f[m]=d[m])}Vh(f,d,{hasAuthoredTransformId:i}),!o&&d?.colorId&&(f.colorId=d.colorId),!a&&X(d,"opacity")&&(f.opacity=d.opacity),!r&&X(d,"blur")&&(f.blur=ae(d.blur)),!n&&X(d,"filters")&&(f.filters=ae(d.filters)),ie(f,"resourceId")&&f.resourceId===void 0&&delete f.resourceId,ie(f,"colorId")&&f.colorId===void 0&&delete f.colorId,ie(f,"animations")&&f.animations===void 0&&delete f.animations,ie(f,"transformId")&&f.transformId===void 0&&delete f.transformId,ie(f,"opacity")&&f.opacity===void 0&&delete f.opacity,ie(f,"blur")&&f.blur===void 0&&delete f.blur,ie(f,"filters")&&f.filters===void 0&&delete f.filters;for(let m of bo)ie(f,m)&&f[m]===void 0&&delete f[m];if(!f.resourceId&&!f.colorId){delete e.background;return}d?.resourceId===f.resourceId&&d?.transformId===f.transformId&&!ie(f,"animations")&&Qt(d)&&(f.animations=ae(d.animations)),e.background=f}else e.background?.animations&&!Qt(e.background)&&(e.background.animations={})},Hh=(e,t)=>{if(!t.dialogue){if(e.dialogue&&($c(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=Cc({dialogueState:e.dialogue,dialogueAction:{},persistCharacter:u});u||delete e.dialogue.characterId,e.dialogue.character=_c({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 s=e.dialogue.mode;if(t.dialogue.ui){let{animationsOnly:u,state:p}=Zt(t.dialogue.ui,d=>!!d.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&&s!=="nvl"&&e.dialogue?.mode!=="nvl"&&Array.isArray(t.dialogue.content);t.dialogue.content!==void 0&&Yh({dialogueState:e.dialogue,content:t.dialogue.content,append:o}),ie(t.dialogue,"textSpeed")?e.dialogue.textSpeed=t.dialogue.textSpeed:delete e.dialogue.textSpeed;let a=ie(t.dialogue,"persistCharacter")?t.dialogue.persistCharacter===!0:e.dialogue.persistCharacter===!0;a?e.dialogue.persistCharacter=!0:delete e.dialogue.persistCharacter;let r=Cc({dialogueState:e.dialogue,dialogueAction:t.dialogue,persistCharacter:a});ie(t.dialogue,"persistSprite")&&(e.dialogue.persistSprite=r);let n=ie(t.dialogue,"characterId"),i=Uh(t.dialogue),l=Vc(t.dialogue);n?t.dialogue.characterId?e.dialogue.characterId=t.dialogue.characterId:delete e.dialogue.characterId:!a&&!o&&delete e.dialogue.characterId;let c=_c({previousCharacter:e.dialogue.character,characterFields:i,hasCharacterId:n,persistCharacter:a,persistSprite:r,hasExplicitPersistSprite:ie(t.dialogue,"persistSprite"),isAppendingAdvDialogueContent:o});if(c?e.dialogue.character=c:delete e.dialogue.character,l||$c(e.dialogue),t.dialogue.clear){delete e.dialogue;return}if(t.dialogue?.clearPage&&e.dialogue?.mode==="nvl"&&(e.dialogue.lines=[]),e.dialogue?.mode==="nvl"&&t.dialogue.content!==void 0){let u={content:t.dialogue.content,characterId:e.dialogue.characterId??null};e.dialogue.textSpeed!==void 0&&(u.textSpeed=e.dialogue.textSpeed),e.dialogue.character&&(u.character=ae(e.dialogue.character)),e.dialogue.lines.push(u)}},Kh=(e,t)=>{let s=Nh(e.sfx);if(!t.sfx){if(s.length>0){e.sfx={channels:s};return}delete e.sfx;return}if(Array.isArray(t.sfx.items)){let r=s.filter(n=>n.id!==_h);if(t.sfx.items.length===0){if(r.length>0){e.sfx={channels:r};return}delete e.sfx;return}e.sfx=ae(t.sfx),r.length>0&&(e.sfx.channels=r);return}if(!Array.isArray(t.sfx.channels)){if(s.length>0){e.sfx={channels:s};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=s.filter(r=>!o.has(r.id));for(let r of t.sfx.channels)Array.isArray(r.sounds)&&r.sounds.length>0&&a.push(ae(r));if(a.length===0){delete e.sfx;return}e.sfx={channels:a}},Wh=(e,t,s)=>{if(t.bgm){let o=Array.isArray(t.bgm.sounds);if(!t.bgm.resourceId&&!o||o&&t.bgm.sounds.length===0){e.bgm=void 0;return}e.bgm=Pc({bgm:ae(t.bgm),resources:s}),delete e.bgm.audioEffects,t.bgm.resourceId&&(e.bgm.loop=t.bgm.loop??!0)}},Jh=(e,t)=>{if(t.visual){let s=e.visual?.items||[];t.visual.items?.forEach((r,n)=>{Mh(r,Lc(s,r,n))});let{hasValidItems:o,processedItems:a}=Mc(t.visual.items,xc,s,{hasPatchFn:Th,mergeItemFn:Lh});o?e.visual={items:a}:delete e.visual}else e.visual?.items&&(e.visual.items=e.visual.items.map(s=>s.animations&&(!xc(s)||!Qt(s))?{...s,animations:{}}:s))},Qh=(e,t)=>{if(!t.character){e.character?.items&&(e.character.items=e.character.items.map(a=>a.animations&&(!Sc(a)||!Qt(a))?{...a,animations:{}}:a));return}let{hasValidItems:s,processedItems:o}=Mc(t.character.items,Sc,e.character?.items||[]);s?e.character={items:o}:delete e.character},Zh=(e,t)=>{t.animation?e.animation=t.animation:e.animation&&delete e.animation},eg=(e,t)=>{if(t.layout){let{animationsOnly:s,state:o}=Zt(t.layout,a=>!!a.resourceId);if(s){e.layout=o;return}if(!t.layout.resourceId){delete e.layout;return}e.layout=t.layout}else e.layout&&delete e.layout},rg=(e,t)=>{if(t.choice){let{animationsOnly:s,state:o}=Zt(t.choice,a=>!!a.resourceId);if(s){e.choice={...e.choice,...o};return}if(!t.choice.resourceId){delete e.choice;return}e.choice=t.choice}else e.choice&&delete e.choice},tg=(e,t)=>{if(t.form){let{animationsOnly:s,state:o}=Zt(t.form,a=>!!a.resourceId);if(s){e.form={...e.form,...o};return}if(!t.form.resourceId){delete e.form;return}e.form=ae(t.form)}else e.form&&delete e.form},ng=(e,t)=>{if(t.control){if(!t.control.resourceId){delete e.control;return}e.control=t.control}},sg=(e,t)=>{if(t.voice){let s=Array.isArray(t.voice.sounds);if(!t.voice.resourceId&&!s||s&&t.voice.sounds.length===0){delete e.voice;return}e.voice=ae(t.voice)}else e.voice&&delete e.voice},ig=(e,t)=>{t.cleanAll&&Object.keys(e).forEach(s=>{delete e[s]})},Qr=(e,{resources:t}={})=>Hn(zh,[ig,Xh,Gh,Kh,(a,r)=>Wh(a,r,t),Jh,Hh,Qh,Zh,eg,rg,tg,ng,sg])(e);var vt=(e,t)=>{if(!e||typeof e!="string"||!e.includes("${"))return e;let s=Hr(e,t);return s&&typeof s=="object"?e:s};var og=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"}}),$r=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}),en=Object.freeze({saveLoadPagination:1,menuPage:"",menuEntryPoint:""}),ag=Object.freeze({dialogueTextSpeed:"number",autoForwardDelay:"number",autoForwardSpeed:"number",skipUnseenText:"boolean",skipTransitionsAndAnimations:"boolean",soundVolume:"number",musicVolume:"number",muteAll:"boolean",localizationPackageId:"nullableString",saveLoadPagination:"number",menuPage:"string",menuEntryPoint:"string",autoMode:"boolean",skipMode:"boolean",dialogueUIHidden:"boolean",isLineCompleted:"boolean"}),Io=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll","localizationPackageId"]),qc=Object.freeze(["dialogueTextSpeed","autoForwardDelay","autoForwardSpeed","skipUnseenText","skipTransitionsAndAnimations","soundVolume","musicVolume","muteAll"]),vo=Object.freeze(["saveLoadPagination","menuPage","menuEntryPoint"]),Fc=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),lg=(e,t)=>{let s=ag[e];if(s==="number"){if(typeof t!="number"||!Number.isFinite(t))throw new Error(`${e} requires a finite numeric value`);return}if(s==="boolean"){if(typeof t!="boolean")throw new Error(`${e} requires a boolean value`);return}if(s==="string"){if(typeof t!="string")throw new Error(`${e} requires a string value`);return}if(s==="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}"`)},os=(e,t)=>{if(lg(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},ko=(e={})=>{let t=e?.config;if(t===void 0)return{...$r};if(!Fc(t))throw new Error("projectData.config must be an object");let s=Object.keys(t).find(i=>i!=="runtimeDefaults");if(s)throw new Error(`projectData.config contains unsupported field "${s}"`);let o=t.runtimeDefaults;if(o===void 0)return{...$r};if(!Fc(o))throw new Error("projectData.config.runtimeDefaults must be an object");let a=new Set(qc),r=Object.keys(o).find(i=>!a.has(i));if(r)throw new Error(`projectData.config.runtimeDefaults contains unsupported field "${r}"`);let n={...$r};return qc.forEach(i=>{o[i]!==void 0&&(n[i]=os(i,o[i]))}),n},cg=(e,t)=>{if(t.startsWith("global.")){let s=t.slice(7);return e?.global?.[s]}if(t.startsWith("context.runtime.")){let s=t.slice(16),o=Array.isArray(e?.contexts)?e.contexts:[];return o[o.length-1]?.runtime?.[s]}},Cr=e=>Object.fromEntries(Object.entries(og).map(([t,s])=>{let o=cg(e,s.source),a=o!==void 0?o:$r[t]??en[t];return[t,a]})),nr=(e,t)=>Cr(e)[t],Bc=(e={})=>Object.fromEntries(Io.map(t=>[t,e[t]??$r[t]]));var kt=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}),dr=Object.freeze({BEHIND_BACKGROUND:kt.VISUAL_BEHIND_BACKGROUND,BEHIND_CHARACTER:kt.VISUAL_BEHIND_CHARACTER,BEHIND_DIALOGUE:kt.VISUAL_BEHIND_DIALOGUE,BEHIND_CHOICE:kt.VISUAL_BEHIND_CHOICE,FOREGROUND:kt.VISUAL_FOREGROUND}),Ao=dr.BEHIND_DIALOGUE,Po=Object.freeze(Object.values(dr).sort((e,t)=>e-t));var ug={__arrayOrEmpty:e=>Array.isArray(e)?e:[],objectValues:e=>Object.entries(e).map(([t,s])=>({id:t,...s})),formatDate:uo},pg=/^\$for\s+([A-Za-z_][A-Za-z0-9_]*)(?:\s*,\s*([A-Za-z_][A-Za-z0-9_]*))?\s+in\s+(.+?)(?::)?$/,rn=e=>Array.isArray(e)?e.map(t=>{if(!t||typeof t!="object"||Array.isArray(t)||Object.keys(t).length!==1)return rn(t);let[s]=Object.keys(t),o=pg.exec(s);if(!o)return rn(t);let[,a,r,n]=o,i=`$for ${a}${r?`, ${r}`:""} in __arrayOrEmpty(${n.trim()})`,l=Array.isArray(t[s])?t[s]:[];return{[i]:rn(l)}}):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,s])=>[t,rn(s)])),yr=(e,t)=>{let s={functions:ug};return Hr(rn(e),t,s)},nu=({animationType:e,animationId:t,animationPath:s})=>{if(e!==void 0&&!(e==="update"||e==="transition"))throw new Error(`[${s}] Animation "${t}" has unsupported type "${e}". Use "update" or "transition".`)},fg=({id:e,targetId:t,animation:s,playback:o,animationPath:a="animation"})=>{let r=structuredClone(s);if(nu({animationType:r.type,animationId:e,animationPath:a}),delete r.name,delete r.playback,r.id=e,r.targetId=t,o!==void 0){let n=hg(o,`${a}.playback`);if(n!==void 0){let i=n.loop===!0?lu(r):null;if(n.loop===!0&&r.type!=="update")throw new Error(`[${a}.playback] playback.loop is only supported for type "update".`);if(n.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(n.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=n}}return r},mg=(e,{animationId:t="animation",animationPath:s="animation"}={})=>{if(!(!e||typeof e!="object"||Array.isArray(e))&&typeof e.type=="string")return nu({animationType:e.type,animationId:t,animationPath:s}),e.type},dg=e=>{if(typeof e=="string")return e;if(!(!e||typeof e!="object"||Array.isArray(e)))return e.resourceId},yg=e=>{if(!(!e||typeof e!="object"||Array.isArray(e)))return e.playback},hg=(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 s={};return e.continuity!==void 0&&(s.continuity=e.continuity),e.speed!==void 0&&e.speed!==1&&(s.speed=e.speed),e.loop===!0&&(s.loop=!0),Object.keys(s).length>0?s:void 0},gg=e=>{let t=e?.playback?.speed;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1},Qe=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),su=(e={})=>Qe(e,"alpha")&&typeof e.alpha=="number"?e.alpha:Qe(e,"opacity")&&typeof e.opacity=="number"?e.opacity:void 0,iu=e=>e?.playback?.continuity==="persistent",_o=e=>Array.isArray(e)?e.map(_o):!e||typeof e!="object"?e:Object.keys(e).sort().reduce((t,s)=>(t[s]=_o(e[s]),t),{}),us=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(_o(t))},ou=(e=[])=>e.filter(t=>iu(t)).map(t=>structuredClone(t)),au=e=>Array.isArray(e?.keyframes)?e.keyframes.reduce((t,s)=>{let o=typeof s?.duration=="number"&&Number.isFinite(s.duration)?s.duration:0;return t+o},0):0,Eo=e=>!e||typeof e!="object"||Array.isArray(e)?0:Object.values(e).reduce((t,s)=>Math.max(t,au(s)),0),lu=e=>Math.max(Eo(e?.tween),Eo(e?.prev?.tween),Eo(e?.next?.tween),au(e?.mask?.progress)),cu=e=>!e||typeof e!="object"||Array.isArray(e)?0:e.playback?.loop===!0?Number.POSITIVE_INFINITY:lu(e)/gg(e),bg=e=>e.some(t=>t?.playback?.loop===!0),Uc=({animationInstances:e,activePersistentAnimations:t})=>{if(!Array.isArray(e)||e.length===0||!Array.isArray(t)||t.length===0)return!1;let s=new Set(t.map(us).filter(Boolean));return e.some(o=>{if(!iu(o))return!1;let a=us(o);return a?s.has(a):!1})},Ze=({animationInstances:e,isLineCompleted:t,skipTransitionsAndAnimations:s,activePersistentAnimations:o,restoredPersistentAnimations:a,isAuthoredOnCurrentLine:r=!0})=>!Array.isArray(e)||e.length===0||s?!1:bg(e)||r&&!t||Uc({animationInstances:e,activePersistentAnimations:o})?!0:r?!1:Uc({animationInstances:e,activePersistentAnimations:a}),uu=(e,t,s,o,a)=>{if(e===void 0)return!0;let r=a.slice(0,o).filter(i=>i?.id===s).length,n=e?.[t]?.items?.filter(i=>i?.id===s).at(r);return Qe(n??{},"animations")},wg=e=>!e||typeof e!="object"||Array.isArray(e)?!1:["in","out","update"].some(t=>e[t]!==void 0),Ig=(e,t)=>{if(wg(e))throw new Error(`[${t}] Legacy animations.in/out/update is no longer supported. Use a single animations.resourceId reference.`)},vg=({resources:e,animationId:t,playback:s,instanceId:o,targetId:a,animationPath:r="animation"})=>{if(!t||!a)return!1;let n=e?.animations?.[t];return n?fg({id:o,targetId:a,animation:n,playback:s,animationPath:r}):null},No=(e,t)=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(s=>s===null||typeof s!="object"||Array.isArray(s)))throw new Error(`${t} must be an array of objects`);return e},kg=({content:e,path:t,variables:s})=>No(e,t).reduce((o,a)=>{let r=vt(a.text,{variables:s});return o+`${r??""}`.length},0),Yc=(e=[])=>{let t=new Map;for(let s of e)s?.id&&t.set(s.id,(t.get(s.id)??0)+1);return new Set(Array.from(t.entries()).filter(([,s])=>s>1).map(([s])=>s))},zc=(e,t=0,s=new Set)=>{if(!s.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("-")}`},Pt=(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 s=e.transforms?.[t.transformId];if(!s)throw new Error(`Transform "${t.transformId}" not found for visual item "${t.id}"`);return s},Ag=(e,t={})=>{if(!t?.transformId)return;let s=e.transforms?.[t.transformId];if(!s)throw new Error(`Transform "${t.transformId}" not found for background`);return s},Pg=["x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY"],Eg=(e={})=>Pg.some(t=>Qe(e,t)),pu=(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"}},ls=({resourceId:e,kind:t})=>{if(e)return t?`bg-cg-background-${t}`:`bg-cg-${e}`},xg=(e={})=>e.textStyles||{},Sg=(e={})=>e.images||{},Og=.5,Rg=(e={},t,s)=>{if(t){if(!e.animations?.[t])throw new Error(`Animation '${t}' not found in spritesheet resource '${s}'`);return t}return Object.keys(e.animations??{})[0]},Fo=({id:e,resourceId:t,spritesheet:s,animationName:o,animationSpeed:a,loop:r,width:n,height:i,transform:l={}}={})=>{let c=Rg(s,o,t),u=c?s.animations?.[c]:void 0;if(!u){console.warn(`Spritesheet animation not found: ${t}`);return}return{id:e,type:"spritesheet-animation",...l,width:n??s.width,height:i??s.height,src:s.fileId,atlas:s.jsonData,playback:{frames:u.frames,animationSpeed:a??u.animationSpeed??Og,loop:r??u.loop??!0}}},fu=({id:e,item:t,resources:s={}}={})=>{let o=s.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=s.spritesheets?.[t.resourceId];if(a)return Fo({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}`)},$g=(e={})=>e.colors||{},Cg=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,tn=(e,t)=>e==="root"?`${t}`:`${e}.${t}`,Et=(e,t,s)=>{if(typeof e!="string"||e.length===0)throw new Error(`${s} at "${t}" must resolve to a non-empty string`)},xo=(e,t,s)=>{if(e===void 0)return 1;if(typeof e!="number"||!Number.isFinite(e))throw new Error(`${t} for text style "${s}" must be a number between 0 and 1`);if(e<0||e>1)throw new Error(`${t} for text style "${s}" must be a number between 0 and 1`);return e},So=(e,t,s,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 "${s}" must be ${r}`)}return e},ms=(e,t)=>{if(typeof e!="string"||!Cg.test(e))throw new Error(`${t} must resolve to a hex color`);return e.length===4?`#${e.slice(1).split("").map(s=>s.repeat(2)).join("")}`:e},Xc=(e,t,s)=>{let o=ms(e,s);if(t===1)return o;let a=Number.parseInt(o.slice(1,3),16),r=Number.parseInt(o.slice(3,5),16),n=Number.parseInt(o.slice(5,7),16);return`rgba(${a}, ${r}, ${n}, ${t})`},_g=(e={},t)=>{let s=xg(e)?.[t];if(!s)throw new Error(`Text style "${t}" not found`);let a=(Array.isArray(s.fontId)?s.fontId:[s.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?.[s.colorId];if(!r)throw new Error(`Color "${s.colorId}" not found for text style "${t}"`);let n=xo(s.colorAlpha,"colorAlpha",t),i={fontFamily:Array.isArray(s.fontId)?a.join(", "):a[0],fontSize:s.fontSize??16,fontWeight:s.fontWeight??"400",fontStyle:s.fontStyle??"normal",lineHeight:s.lineHeight??1.2,fill:Xc(r.hex,n,`Color "${s.colorId}" for text style "${t}"`)};if(s.align!==void 0&&(i.align=s.align),s.wordWrap!==void 0&&(i.wordWrap=s.wordWrap),s.breakWords!==void 0&&(i.breakWords=s.breakWords),s.wordWrapWidth!==void 0&&(i.wordWrapWidth=s.wordWrapWidth),s.strokeColorId){let l=e.colors?.[s.strokeColorId];if(!l)throw new Error(`Stroke color "${s.strokeColorId}" not found for text style "${t}"`);let c=xo(s.strokeAlpha,"strokeAlpha",t);i.strokeColor=Xc(l.hex,c,`Stroke color "${s.strokeColorId}" for text style "${t}"`)}else if(s.strokeAlpha!==void 0)throw new Error(`strokeAlpha for text style "${t}" requires strokeColorId`);if(s.strokeWidth!==void 0&&(i.strokeWidth=s.strokeWidth),s.shadow!==void 0){let l=e.colors?.[s.shadow.colorId];if(!l)throw new Error(`Shadow color "${s.shadow.colorId}" not found for text style "${t}"`);i.shadow={color:ms(l.hex,`Shadow color "${s.shadow.colorId}" for text style "${t}"`),alpha:xo(s.shadow.alpha,"shadow.alpha",t),blur:So(s.shadow.blur,"blur",t,0,{minimum:0}),offsetX:So(s.shadow.offsetX,"offsetX",t,2),offsetY:So(s.shadow.offsetY,"offsetY",t,2)}}return i},xt=e=>Array.isArray(e)?e.map(xt):!e||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,s])=>[t,xt(s)])),jo=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>jo(a,t,`${s}[${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 "${s}". Use textStyleId instead`);let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=xt(r);continue}a!=="textStyleId"&&(o[a]=jo(r,t,tn(s,a)))}return e.textStyleId!==void 0&&(Et(e.textStyleId,s,"textStyleId"),o.textStyle=_g(t,e.textStyleId)),o},Bo=(e={},t)=>{let s=$g(e)?.[t];if(!s)throw new Error(`Color "${t}" not found`);return ms(s.hex,`Color "${t}"`)},mu=e=>e==="hover.fill"?"hover.colorId":e==="click.fill"?"click.colorId":e==="rightClick.fill"?"rightClick.colorId":"colorId",Oo=(e,t,s)=>{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 "${s}". Use ${mu(`${t}.fill`)} instead`)},Ng=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>nn(a,t,`${s}[${r}]`));if(!e||typeof e!="object")return e;let o={};for(let[a,r]of Object.entries(e))a!=="colorId"&&(o[a]=nn(r,t,tn(s,a)));return e.colorId!==void 0&&(Et(e.colorId,s,"colorId"),o.fill=Bo(t,e.colorId)),o},nn=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>nn(a,t,`${s}[${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 "${s}". Use ${mu("fill")} instead`);Oo(e,"hover",s),Oo(e,"click",s),Oo(e,"rightClick",s)}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=xt(r);continue}if(!(e.type==="rect"&&a==="colorId")){if(e.type==="rect"&&(a==="hover"||a==="click"||a==="rightClick")){o[a]=Ng(r,t,tn(s,a));continue}o[a]=nn(r,t,tn(s,a))}}return e.type==="rect"&&e.colorId!==void 0&&(Et(e.colorId,s,"colorId"),o.fill=Bo(t,e.colorId)),o},Ro=(e={},t)=>{let s=Sg(e)?.[t];return s||null},du=e=>e==="hoverUrl"||e==="hoverSrc"||e==="hover.src"?"hoverImageId":e==="clickUrl"||e==="clickSrc"||e==="click.src"?"clickImageId":"imageId",Gc=(e,t,s,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 "${s}". Use ${du(`${t}.${o}`)} instead`)},Hc=(e,t,s)=>{let o=e[t];e[t]={...o&&typeof o=="object"&&!Array.isArray(o)?o:{},src:s}},Do=(e,t={},s="root")=>{if(Array.isArray(e))return e.map((a,r)=>Do(a,t,`${s}[${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 "${s}". Use ${du(a)} instead`);Gc(e,"hover",s,"src"),Gc(e,"click",s,"src")}let o={};for(let[a,r]of Object.entries(e)){if(a==="filters"){o[a]=xt(r);continue}e.type==="sprite"&&(a==="imageId"||a==="hoverImageId"||a==="clickImageId")||(o[a]=Do(r,t,tn(s,a)))}if(e.type==="sprite"&&e.imageId!==void 0){Et(e.imageId,s,"imageId");let a=Ro(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&&(Et(e.hoverImageId,s,"hoverImageId"),Hc(o,"hover",Ro(t,e.hoverImageId)?.fileId??e.hoverImageId)),e.type==="sprite"&&e.clickImageId!==void 0&&(Et(e.clickImageId,s,"clickImageId"),Hc(o,"click",Ro(t,e.clickImageId)?.fileId??e.clickImageId)),o},jg=e=>e==="$else"||e.startsWith("$if ")||e.startsWith("$for "),cs=(e,{isElementPatch:t=!1}={})=>{if(Array.isArray(e))return e.map(a=>cs(a,{isElementPatch:t}));if(!e||typeof e!="object")return e;let s=xt(e),o=typeof e.type=="string";(o||t)&&Qe(e,"opacity")&&(Qe(e,"alpha")||(s.alpha=e.opacity),delete s.opacity);for(let a of["elements","children"])Qe(e,a)&&(s[a]=cs(e[a]));for(let[a,r]of Object.entries(e))jg(a)&&(s[a]=cs(r,{isElementPatch:o||t}));return s},Uo=(e,t={},s="root")=>cs(Do(nn(jo(e,t,s),t,s),t,s)),hr=Uo,et=(e=[])=>e.find(t=>t.id==="story"),Dg="#000000",To="bg-cg-background-color",Tg=({resources:e={},background:t={},screen:s})=>t?.colorId===void 0?ms(s?.backgroundColor??Dg,"screen.backgroundColor"):Bo(e,t.colorId),yu=(e={})=>su(e),Lg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},Yo=(e={})=>Array.isArray(e.filters)?e.filters:void 0,Kc=(e={},{includeDefaultAlpha:t=!1}={})=>{let s=yu(e),o=Lg(e),a=Yo(e),r={};return(t||s!==void 0)&&(r.alpha=s??1),o&&(r.blur=o),a&&(r.filters=a),r},Mg=(e={})=>su(e),Vg=(e={})=>{if(!(!e.blur||typeof e.blur!="object"||Array.isArray(e.blur)))return e.blur},hu=(e={})=>{let t=Mg(e),s=Vg(e),o={};return t!==void 0&&(o.alpha=t),s&&(o.blur=s),o},Zr=(e={})=>{let t=hu(e),s=Yo(e);return s&&(t.filters=s),t},Wc=(e,t,s,o)=>{let a=t[s]??e[s];return t[o]??e[o]??!1?(a??1)*-1:a},sr=(e={},t={})=>{let s={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:Wc(e,t,"scaleX","flipX"),scaleY:Wc(e,t,"scaleY","flipY")},o=t.originX??e.originX,a=t.originY??e.originY;return o!==void 0&&(s.originX=o),a!==void 0&&(s.originY=a),s},qg=["id","type","resourceId","layout","transformId","transform","x","y","anchorX","anchorY","scaleX","scaleY","flipX","flipY","rotation","originX","originY","layer","alpha","opacity","blur","filters","animations"],zo=(e={})=>e.text&&Qe(e.text,"content")&&Qe(e.text,"textStyleId"),Xo=(e={})=>e.layout&&Array.isArray(e.layout.elements),Jc=(e={})=>{if(e.resourceId)return e.resourceId;if(zo(e))return"text";if(Xo(e))return"inline-layout"},Qc=(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(s=>{if(typeof s=="string")return t.images?.[s]?.fileId??s;if(!s||typeof s!="object"||Array.isArray(s))return s;if(s.imageId){let{imageId:o,...a}=s;return{...a,src:t.images?.[o]?.fileId??o}}return typeof s.src=="string"?{...s,src:t.images?.[s.src]?.fileId??s.src}:s})}:e,Fg=({item:e,particle:t,resources:s})=>{let o=Pt(s,e),a=structuredClone(t),r=a.modules?.appearance?.texture;r!==void 0&&(a.modules.appearance.texture=Qc(r,s)),a.texture!==void 0&&(a.texture=Qc(a.texture,s));let n={id:`visual-${e.id}`,type:"container",children:[{...a,id:`visual-${e.id}-particles`,type:"particles",x:0,y:0}],...sr(o,e)};return Object.assign(n,Zr(e)),n},Bg=e=>{let t=[e.resourceId,e.text,e.layout].filter(s=>s!==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&&!zo(e))throw new Error(`Visual item "${e.id}" text requires content and textStyleId`);if(e.layout&&!Xo(e))throw new Error(`Visual item "${e.id}" layout requires elements`);if(e.text){for(let s of qg)if(Qe(e.text,s))throw new Error(`Visual item "${e.id}" text.${s} is reserved for the visual item`)}},Ug=({resources:e,background:t,screen:s={width:1920,height:1080},includeAlpha:o=!1})=>{let a={id:To,type:"rect",x:0,y:0,width:s?.width??1920,height:s?.height??1080,fill:Tg({resources:e,background:t,screen:s})};if(o){let r=yu(t);r!==void 0&&(a.alpha=r);let n=Yo(t);n&&(a.filters=n)}return a},Yg=(e={},t)=>t?!!(e.images?.[t]||e.videos?.[t]||e.spritesheets?.[t]||e.layouts?.[t]):!1,Zc=({resources:e={},resourceId:t,colorId:s})=>{let o=pu(e,t);return t&&(o||s===void 0)?{resourceId:t,targetId:ls({resourceId:t,kind:o})}:s!==void 0?{resourceId:To,targetId:To}:{resourceId:void 0,targetId:void 0}},gu=100,_r=gu,zg="channel:bgm",Xg="channel:music-room",Gg="music-room:player",Hg="channel:voice",Kg="default",ps=(e,t,s)=>{let o=new Set;e.forEach(({id:a})=>{if(o.has(a)){let r=s?` in ${s}`:"";throw new Error(`Duplicate ${t} id "${a}"${r}.`)}o.add(a)})},bu=(e,t)=>e*t/gu,Go=(e={},t)=>e?.[t]??$r[t],Ho=(e={},t,s=_r)=>bu(s,Go(e,t)),ds=({id:e,volume:t,muted:s,pan:o,loop:a,playback:r,interruption:n,children:i,runtime:l})=>{let c={id:e,type:"audio-channel",volume:t,muted:!!l?.muteAll||(s??!1),pan:o??0,children:i};return a!==void 0&&(c.loop=a),r!==void 0&&(c.playback=structuredClone(r)),n!==void 0&&(c.interruption=n),c},as=(e,t,s,o)=>e[s]!==void 0?e[s]:t[s]!==void 0?t[s]:o,Wg=["muted","pan","playbackRate","startAt","endAt"],ys=({id:e,sound:t,resource:s,projectResources:o,soundPath:a="sound",defaultLoop:r=!1,skipTransitionsAndAnimations:n=!1})=>{let i={id:e,type:"sound",src:s.fileId,loop:as(t,s,"loop",r),volume:as(t,s,"volume",_r),startDelayMs:as(t,s,"startDelayMs",0)};Wg.forEach(c=>{let u=as(t,s,c,void 0);u!==void 0&&(i[c]=u)}),t.playback!==void 0&&(i.playback=structuredClone(t.playback));for(let c of["beginEffect","endEffect"]){let u=Ac({selection:t[c],selectionPath:`${a}.${c}`,resources:o});u&&!n&&(i[c]=u)}let l=i.startAt??0;if(i.endAt!==void 0&&i.endAt!==null&&i.endAt<l)throw new Error(`Sound "${e}" endAt (${i.endAt}) must be greater than or equal to startAt (${l}).`);return i},Jg=e=>Math.max(-1,Math.min(1,e)),Qg=({node:e,bgm:t,sound:s,resource:o,usesLegacySound:a})=>{a||(e.volume=bu(t.volume??_r,e.volume??_r));let r=t.muted!==void 0,n=s.muted!==void 0||o.muted!==void 0;(r||n)&&(e.muted=t.muted===!0||e.muted===!0);let i=t.pan!==void 0,l=s.pan!==void 0||o.pan!==void 0;return(i||l)&&(e.pan=Jg((t.pan??0)+(e.pan??0))),e},Ge=({variables:e,imageGallery:t,musicRoom:s,sceneReplay:o,runtime:a,saveSlots:r=[],dialogueState:n,includeInactiveAdvDialogue:i=!1,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:g,historyDialogue:b=[],characters:y={},dialogueUIHidden:w,skipOnlyViewedLines:h,skipTransitionsAndAnimations:P}={})=>{let k={dialogueTextSpeed:a?.dialogueTextSpeed??50,autoForwardDelay:a?.autoForwardDelay??1e3,autoForwardSpeed:a?.autoForwardSpeed??50,skipUnseenText:a?.skipUnseenText??!1,skipTransitionsAndAnimations:a?.skipTransitionsAndAnimations??!1,soundVolume:a?.soundVolume??50,musicVolume:a?.musicVolume??50,muteAll:a?.muteAll??!1,localizationPackageId:a?.localizationPackageId??null,saveLoadPagination:a?.saveLoadPagination??1,menuPage:a?.menuPage??"",menuEntryPoint:a?.menuEntryPoint??"",autoMode:a?.autoMode??c??!1,skipMode:a?.skipMode??u??!1,dialogueUIHidden:a?.dialogueUIHidden??w??!1,isLineCompleted:a?.isLineCompleted??l??!1},E=nb({dialogueState:n,includeInactiveAdvDialogue:i,characters:y,variables:e,runtime:k}),v={variables:e,imageGallery:t,musicRoom:s,sceneReplay:o,localizationPackages:a?.localizationPackages??[],localizationPackageId:k.localizationPackageId,runtime:k,saveSlots:r,isChoiceVisible:p,isFormVisible:d,canRollback:f,confirmDialog:m,form:g,historyDialogue:b,characters:y};return E&&(v.dialogue=E,v.dialogueLines=E.lines),v},eu=100,fs=(e,t)=>{if(Array.isArray(e))return e.map(o=>fs(o,t));if(!e||typeof e!="object")return e;let s={...e};return Object.keys(s).forEach(o=>{s[o]=fs(s[o],t)}),s.type==="text-revealing"?t(s):s},Zg=e=>fs(e,t=>({...t,revealEffect:"none"})),eb=e=>fs(e,t=>{let s=Number(t.speed??t.displaySpeed),o=Number.isFinite(s)?Math.max(s,eu):eu;return{...t,speed:o,...Object.prototype.hasOwnProperty.call(t,"displaySpeed")?{displaySpeed:o}:{}}}),Nr=(e,{isLineCompleted:t=!1,skipMode:s=!1,skipTransitionsAndAnimations:o=!1}={})=>t||o?Zg(e):s?eb(e):e,wu=({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:{}}}}),Lo=e=>{if(Array.isArray(e))return e.map(Lo);if(!e||typeof e!="object")return e;let t={};for(let[r,n]of Object.entries(e))t[r]=Lo(n);let s=t.click?.payload;if(!s||typeof s!="object"||Array.isArray(s))return t;let o=s.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:{...s,bypassChoice:!0,...a?{actions:{...o,nextLine:a}}:{}}}}},rb=new Set(["click","change","submit","focusEvent","blurEvent","selectionChange","compositionStart","compositionUpdate","compositionEnd"]),ru="submit",$o=(e,t,s={})=>{let o=e?.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{},a=o.actions&&typeof o.actions=="object"?o.actions:{},r=s.replaceActions===!0?t:{...a,...t};return{...e||{},payload:{...o,actions:r}}},Mo=(e,t,s={})=>{if(Array.isArray(e))return e.map(c=>Mo(c,t,s));if(!e||typeof e!="object")return e;let o=typeof e.type=="string",a=o&&e.formRole===ru,r=o&&s.submitRoleAncestor,n=a||r?{submitRoleAncestor:!0}:{},i={};for(let[c,u]of Object.entries(e))i[c]=Mo(u,t,c==="children"?n:{});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:$o(l.change,u),submit:$o(l.submit,t.submitActions)}}}return l.formRole===ru||r?{...l,click:$o(l.click,t.submitActions,{replaceActions:!0})}:l},Vo=(e,t)=>{if(Array.isArray(e))return e.map(o=>Vo(o,t));if(!e||typeof e!="object")return e;let s={};for(let[o,a]of Object.entries(e))s[o]=Vo(a,t);for(let o of rb){let a=s[o]?.payload;!a||typeof a!="object"||Array.isArray(a)||(s[o]={...s[o],payload:{...a,_interactionSource:"form"}})}return s},qo=({characterId:e,character:t,characterName:s,characters:o={},variables:a={}}={})=>{let r=e?o?.[e]:void 0,n=Kn({characterId:e,character:t,characterName:s,characters:o,variables:a});return{...r||{},...t||{},name:n}},Iu=(e=[],t={},s={})=>e.map(o=>{let a=qo({characterId:o.characterId,character:o.character,characterName:o.characterName,characters:t,variables:s}),r=typeof o.text=="string"?o.text:Array.isArray(o.content)?o.content.map(n=>n?.text??"").join(""):"";return{...o,text:r,character:a,characterName:a.name}}),tb=e=>!(!e||e.mode==="adv"&&e.content===void 0),nb=({dialogueState:e,includeInactiveAdvDialogue:t=!1,characters:s={},variables:o,runtime:a}={})=>{if(!t&&!tb(e))return;let r=e.content===void 0?[{text:""}]:No(e.content,"dialogue.content"),n=e.content===void 0?0:kg({content:e.initialRevealedContent,path:"dialogue.initialRevealedContent",variables:o}),i=a?.dialogueTextSpeed??$r.dialogueTextSpeed,l=e.textSpeed??i,c=(e.lines||[]).map((p,d)=>{let f=No(p.content,`dialogue.lines[${d}].content`),m=qo({characterId:p.characterId,character:p.character,characterName:p.characterName,characters:s,variables:o});return{...p,textSpeed:p.textSpeed??i,content:f.map(g=>({...g,text:vt(g.text,{variables:o})})),character:m,characterName:m.name}}),u=qo({characterId:e.characterId,character:e.character,characters:s,variables:o});return{characterId:e.characterId,persistCharacter:e.persistCharacter,persistSprite:e.persistSprite,character:u,textSpeed:l,content:r.map(p=>({...p,text:vt(p.text,{variables:o})})),initialRevealedCharacters:n,lines:c}},Ko=({container:e,resources:t,templateData:s,isLineCompleted:o=!1,skipMode:a=!1,skipTransitionsAndAnimations:r=!1})=>{let n=yr(e,s);return hr(Nr(n,{isLineCompleted:o,skipMode:a,skipTransitionsAndAnimations:r}),t)},Co=(e,t={})=>e?.payload&&typeof e.payload=="object"?structuredClone(e.payload):e?.actions&&typeof e.actions=="object"?{actions:structuredClone(e.actions)}:structuredClone(t),tu=({renderStateKeyboard:e,keyboard:t,phase:s})=>{!t||typeof t!="object"||Array.isArray(t)||Object.entries(t).forEach(([o,a])=>{let r=e[o]??{},n=s==="keydown"?a?.keydown:a?.keyup;if(s==="keydown"&&n&&typeof n=="object"){e[o]={...r,keydown:{payload:Co(n)}},a?.keyup&&typeof a.keyup=="object"&&(e[o].keyup={payload:Co(a.keyup)});return}e[o]={...r,[s]:{payload:Co(a)}}})},sb=(e={},t={})=>{let s={};return tu({renderStateKeyboard:s,keyboard:e,phase:"keydown"}),tu({renderStateKeyboard:s,keyboard:t,phase:"keyup"}),Object.keys(s).length>0?s:void 0},gr=({animationsDef:e,resources:t,previousResourceId:s,currentResourceId:o,previousTargetId:a,currentTargetId:r,animationPath:n,idPrefix:i})=>{if(!e)return[];let l=[],c=({instanceId:y,targetId:w})=>{let h=vg({resources:t,animationId:f,playback:m,instanceId:y,targetId:w,animationPath:n});h&&l.push(h)},u=s!=null&&s!==!1,p=o!=null&&o!==!1,d=a&&r&&a===r;Ig(e,n);let f=dg(e),m=yg(e),g=t?.animations?.[f],b=mg(g,{animationId:f,animationPath:n});if(b==="update")return p&&r?c({instanceId:`${i}-animation-update`,targetId:r}):u&&a&&c({instanceId:`${i}-animation-update`,targetId:a}),l;if(b==="transition"){let y=`${i}-animation-transition`,w=m?.continuity==="persistent"?y:`${i}-animation-in`;if(u&&p&&d)return c({instanceId:y,targetId:r}),l;u&&c({instanceId:`${i}-animation-out`,targetId:a}),p&&c({instanceId:w,targetId:r})}return l},ib=()=>({elements:[{id:"story",type:"container",x:0,y:0,children:[]}],animations:[],audio:[],global:{}}),ob=(e,{presentationState:t,previousPresentationState:s,currentLineActions:o,resources:a={},screen:r={width:1920,height:1080},isLineCompleted:n,skipTransitionsAndAnimations:i,variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:d,activePersistentAnimations:f,restoredPersistentAnimations:m,autoMode:g,skipMode:b,isChoiceVisible:y,isFormVisible:w,canRollback:h,form:P,saveSlots:k=[]})=>{let{elements:E,animations:v}=e;if(t.background){let O=o===void 0?!0:Qe(o?.background??{},"animations"),T=E.find(oe=>oe.id==="story");if(!T)return e;let $=Ag(a,t.background),D=$||Eg(t.background),B=s?.background?.resourceId,_=s?.background?.colorId,G=t.background.resourceId??(t.background.animations?B:void 0),fe=t.background.colorId??(t.background.animations?_:void 0),M=Yg(a,G),K={...t.background,colorId:fe};if((fe!==void 0||M)&&T.children.push(Ug({resources:a,background:K,screen:r,includeAlpha:!M})),G){let{images:oe={},videos:ne={},spritesheets:ue={}}=a,Z=pu(a,G),C;if(Z==="sprite"?C=oe[G]:Z==="video"?C=ne[G]:Z==="spritesheet-animation"&&(C=ue[G]),C){let N=Z==="video",F=Z==="spritesheet-animation",J={x:(r?.width??1920)/2,y:(r?.height??1080)/2,anchorX:.5,anchorY:.5,rotation:0,scaleX:1,scaleY:1,...$},me={...Kc(t.background,{includeDefaultAlpha:!0}),...sr(J,t.background)},Ie;F?Ie=Fo({id:ls({resourceId:G,kind:Z}),resourceId:G,spritesheet:C,animationName:t.background.animationName,animationSpeed:t.background.animationSpeed,loop:t.background.loop,transform:me}):Ie={id:ls({resourceId:G,kind:Z}),type:N?"video":"sprite",src:C.fileId,width:C.width,height:C.height,...me},N&&(Ie.loop=t.background.loop??!1,Ie.volume=C.volume??50),Ie&&T.children.push(Ie)}}if(G){let{layouts:oe={}}=a,ne=oe[G];if(ne){let ue={id:ls({resourceId:G,kind:"container"}),type:"container",children:ne.elements,...Kc(t.background)};D&&Object.assign(ue,sr({x:0,y:0,anchorX:0,anchorY:0,rotation:0,scaleX:1,scaleY:1,...$},t.background));let Z=yr(ue,Ge({variables:l,imageGallery:c,musicRoom:u,sceneReplay:p,runtime:d,saveSlots:k,dialogueState:t.dialogue,isLineCompleted:n,autoMode:g,skipMode:b,isChoiceVisible:y,isFormVisible:w,canRollback:h,form:P,characters:a.characters||{},skipTransitionsAndAnimations:i}));T.children.push(hr(Nr(Z,{isLineCompleted:n,skipMode:b,skipTransitionsAndAnimations:i}),a))}}let le=Zc({resources:a,resourceId:B,colorId:_}),z=Zc({resources:a,resourceId:G,colorId:fe}),te=gr({animationsDef:t.background.animations,resources:a,previousResourceId:le.resourceId,currentResourceId:z.resourceId,previousTargetId:le.targetId,currentTargetId:z.targetId,animationPath:"background.animations",idPrefix:"bg-cg"});Ze({animationInstances:te,isLineCompleted:n,skipTransitionsAndAnimations:i,activePersistentAnimations:f,restoredPersistentAnimations:m,isAuthoredOnCurrentLine:O})&&v.push(...te)}return e},ab=(e,{presentationState:t,previousPresentationState:s,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:l})=>{let{elements:c,animations:u}=e;if(t.character&&a){let p=c.find(w=>w.id==="story");if(!p)return e;let d=t.character.items||[],f=s?.character?.items||[],m=Yc(d),g=Yc(f),b=new Map,y=new Map;for(let w=0;w<f.length;w++){let h=f[w],P=b.get(h.id)??[];P.push(w),b.set(h.id,P)}for(let w=0;w<d.length;w++){let h=d[w],{transformId:P,sprites:k}=h,E=y.get(h.id)??0;y.set(h.id,E+1);let v=b.get(h.id)?.[E]??-1,O=f[v],T=O?.sprites&&O.sprites.length>0,$=k&&k.length>0,D=v>=0?zc(O,v,g):void 0,B=$?zc(h,w,m):void 0,_=uu(o,"character",h.id,w,d),G=gr({animationsDef:h.animations,resources:a,previousResourceId:D,currentResourceId:B,previousTargetId:D,currentTargetId:B,animationPath:`character.items[${w}].animations`,idPrefix:B??D??`character-${w}`});if(h.animations&&!k&&!P&&T&&Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})){u.push(...G);continue}if(h.animations&&!k&&!P)continue;if(!k||k.length===0||!P){console.warn("Character item missing sprites or transformId:",h);continue}let fe=a.transforms[P];if(!fe){console.warn("Transform not found:",P);continue}let M={type:"container",id:B,...sr(fe,h),...Zr(h),children:[]};for(let K of k){let le=fu({id:`${B}-${K.id}`,item:K,resources:a});le&&M.children.push(le)}p.children.push(M),Ze({animationInstances:G,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:i,restoredPersistentAnimations:l,isAuthoredOnCurrentLine:_})&&u.push(...G)}}return e},vu=(e,t)=>{if(!Po.includes(e))throw new Error(`${t} must be one of: ${Po.join(", ")}.`)},lb=(e,t)=>{let s=!!e.resourceId||zo(e)||Xo(e),o=e.layer??(s?void 0:t?.layer)??Ao;return vu(o,`Visual item "${e.id}" layer`),o},cb=(e,{presentationState:t,previousPresentationState:s,currentLineActions:o,resources:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,activePersistentAnimations:d,restoredPersistentAnimations:f,autoMode:m,skipMode:g,isChoiceVisible:b,isFormVisible:y,canRollback:w,form:h,saveSlots:P=[],visualLayer:k})=>{let{elements:E,animations:v}=e;if(t.visual&&a){let O=E.find(B=>B.id==="story");if(!O)return e;let T=t.visual.items,$=s?.visual?.items||[],D=Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:P,dialogueState:t.dialogue,isLineCompleted:r,autoMode:m,skipMode:g,isChoiceVisible:b,isFormVisible:y,canRollback:w,form:h,characters:a.characters||{},skipTransitionsAndAnimations:n});k!==void 0&&vu(k,"visualLayer");for(let[B,_]of T.entries()){let G=$.find(ne=>ne.id===_.id),fe=uu(o,"visual",_.id,B,T),M=lb(_,G);if(k!==void 0&&M!==k)continue;if(Bg(_),_.layout){let ne=Pt(a,_),ue={id:`visual-${_.id}`,type:"container",children:structuredClone(_.layout.elements),...sr(ne,_)};Object.assign(ue,Zr(_)),O.children.push(Ko({container:ue,resources:a,templateData:D,isLineCompleted:r,skipMode:g,skipTransitionsAndAnimations:n}))}if(_.text){let ne=Pt(a,_),ue={...structuredClone(_.text),id:`visual-${_.id}`,type:"text",...sr(ne,_)};Object.assign(ue,Zr(_)),O.children.push(hr(yr(ue,D),a))}if(_.resourceId){let{images:ne={},videos:ue={},spritesheets:Z={}}=a,C=Z[_.resourceId];if(C){let N=Pt(a,_),F=Zr(_),J=Fo({id:`visual-${_.id}`,resourceId:_.resourceId,spritesheet:C,animationName:_.animationName,animationSpeed:_.animationSpeed,loop:_.loop,width:_.width,height:_.height,transform:{...sr(N,_),alpha:F.alpha??_.alpha??1,...F.blur?{blur:F.blur}:{},...F.filters?{filters:F.filters}:{}}});J&&O.children.push(structuredClone(J))}else{let N=ne[_.resourceId]||ue[_.resourceId];if(N){let F=ue[_.resourceId]!==void 0,J=Pt(a,_),me={id:`visual-${_.id}`,type:F?"video":"sprite",src:N.fileId,width:N.width,height:N.height,...sr(J,_)};Object.assign(me,Zr(_)),F&&(me.loop=N.loop??!1,me.volume=N.volume??50),O.children.push(me)}}}let K=!!(a.spritesheets?.[_.resourceId]||a.images?.[_.resourceId]||a.videos?.[_.resourceId]);if(_.resourceId&&!K){let ne=a.particles?.[_.resourceId];ne&&O.children.push(Fg({item:_,particle:ne,resources:a}))}let le=!!a.particles?.[_.resourceId];if(_.resourceId&&!K&&!le){let{layouts:ne={}}=a,ue=ne[_.resourceId];if(ue){let Z=Pt(a,_),C={id:`visual-${_.id}`,type:"container",children:structuredClone(ue.elements),...sr(Z,_)};Object.assign(C,Zr(_));let N=yr(C,D);O.children.push(hr(Nr(N,{isLineCompleted:r,skipMode:g,skipTransitionsAndAnimations:n}),a))}}let z=Jc(G),te=Jc(_),oe=gr({animationsDef:_.animations,resources:a,previousResourceId:z,currentResourceId:te,previousTargetId:z?`visual-${_.id}`:void 0,currentTargetId:te?`visual-${_.id}`:void 0,animationPath:`visual.items[${_.id}].animations`,idPrefix:_.id});Ze({animationInstances:oe,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:d,restoredPersistentAnimations:f,isAuthoredOnCurrentLine:fe})&&v.push(...oe)}}return e},At="dialogue-character-sprite",ub=(e,{presentationState:t,previousPresentationState:s,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})=>{let{animations:i}=e,l=et(e.elements);if(!l)return e;let c=t.dialogue?.character?.sprite,u=s?.dialogue?.character?.sprite,p=Bt(c),d=Bt(u),f=gr({animationsDef:c?.animations,resources:o,previousResourceId:d?At:void 0,currentResourceId:p?At:void 0,previousTargetId:d?At:void 0,currentTargetId:p?At:void 0,animationPath:"dialogue.character.sprite.animations",idPrefix:"dialogue-character-sprite"});if(!p)return c?.animations&&d&&Ze({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&i.push(...f),e;let m=o.transforms?.[c.transformId];if(!m)return console.warn("Transform not found:",c.transformId),e;let g={type:"container",id:At,...sr(m),children:[]};for(let b of c.items){let y=fu({id:`${At}-${b.id}`,item:b,resources:o});y&&g.children.push(y)}return l.children.push(g),Ze({animationInstances:f,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&i.push(...f),e},pb=(e,{presentationState:t,previousPresentationState:s,resources:o={},dialogueUIHidden:a,autoMode:r,skipMode:n,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,skipOnlyViewedLines:p,isLineCompleted:d,skipTransitionsAndAnimations:f,variables:m,imageGallery:g,musicRoom:b,sceneReplay:y,runtime:w,activePersistentAnimations:h,saveSlots:P=[]})=>{let{elements:k,animations:E}=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,$=T[t.dialogue.ui.resourceId];if($){let D={elements:$.elements},B=Ge({variables:m,imageGallery:g,musicRoom:b,sceneReplay:y,runtime:w,saveSlots:P,dialogueState:t.dialogue,includeInactiveAdvDialogue:!0,isLineCompleted:d,autoMode:r,skipMode:n,isChoiceVisible:i,isFormVisible:l,canRollback:c,form:u,characters:o.characters||{},dialogueUIHidden:a,skipOnlyViewedLines:p,skipTransitionsAndAnimations:f}),_=yr(D,B),G=hr(Nr(_?.elements,{isLineCompleted:d,skipMode:n,skipTransitionsAndAnimations:f}),o);if(Array.isArray(G))for(let fe of G)v.children.push(fe);else G&&v.children.push(G)}}ub(e,{presentationState:t,previousPresentationState:s,resources:o,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:h});let O=gr({animationsDef:t.dialogue.ui?.animations,resources:o,previousResourceId:s?.dialogue?.ui?.resourceId,currentResourceId:t.dialogue.ui?.resourceId,previousTargetId:s?.dialogue?.ui?.resourceId?"dialogue-container":void 0,currentTargetId:t.dialogue.ui?.resourceId?"dialogue-container":void 0,animationPath:"dialogue.ui.animations",idPrefix:"dialogue-ui"});return Ze({animationInstances:O,isLineCompleted:d,skipTransitionsAndAnimations:f,activePersistentAnimations:h})&&E.push(...O),e},fb=(e,{presentationState:t,previousPresentationState:s,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:g,canRollback:b,form:y,activePersistentAnimations:w,saveSlots:h=[]})=>{let{elements:P,animations:k}=e;if(t.choice&&o){let E=et(P);if(!E)return e;let v=o?.layouts?.[t.choice.resourceId];if(v&&v.elements){let T={elements:v.elements},$=yr(T,{...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:h,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m??!!t.choice,isFormVisible:g,canRollback:b,form:y,characters:o.characters||{},skipTransitionsAndAnimations:n}),choice:{items:t.choice?.items??[]}}),D=Lo(hr(Nr($?.elements,{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:n}),o));if(Array.isArray(D))for(let B of D)E.children.push(B);else D&&E.children.push(D)}let O=gr({animationsDef:t.choice.animations,resources:o,previousResourceId:s?.choice?.resourceId,currentResourceId:t.choice.resourceId,previousTargetId:s?.choice?.resourceId?"choice-container":void 0,currentTargetId:t.choice.resourceId?"choice-container":void 0,animationPath:"choice.animations",idPrefix:"choice"});Ze({animationInstances:O,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:w})&&k.push(...O)}return e},mb=(e,{presentationState:t,previousPresentationState:s,resources:o,screen:a,isLineCompleted:r,skipTransitionsAndAnimations:n,variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:g,canRollback:b,activePersistentAnimations:y,saveSlots:w=[],form:h})=>{let{elements:P,animations:k}=e;if(!h?.resourceId||!o)return e;let E=et(P);if(!E)return e;let v=o?.layouts?.[h.resourceId];if(!v)return console.warn(`Form layout not found: ${h.resourceId}`),e;let O={id:"form-container",type:"container",x:0,y:0,children:v.elements||[]},T={...Ge({variables:i,imageGallery:l,musicRoom:c,sceneReplay:u,runtime:p,saveSlots:w,dialogueState:t.dialogue,isLineCompleted:r,autoMode:d,skipMode:f,isChoiceVisible:m,isFormVisible:g,canRollback:b,characters:o.characters||{},skipTransitionsAndAnimations:n,form:h}),form:h},$=yr(O,T),D=Vo(hr(Nr(Mo($,h),{isLineCompleted:r,skipMode:f,skipTransitionsAndAnimations:n}),o),h);D&&E.children.push(D);let B=gr({animationsDef:h.animations,resources:o,previousResourceId:s?.form?.resourceId,currentResourceId:h.resourceId,previousTargetId:s?.form?.resourceId?"form-container":void 0,currentTargetId:h.resourceId?"form-container":void 0,animationPath:"form.animations",idPrefix:"form"});return Ze({animationInstances:B,isLineCompleted:r,skipTransitionsAndAnimations:n,activePersistentAnimations:y})&&k.push(...B),e},db=(e,{presentationState:t,resources:s={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:g=[],skipTransitionsAndAnimations:b})=>{if(!t.control?.resourceId)return e;let y=s.controls?.[t.control.resourceId];if(!y)return e;let w=sb(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 h=et(e.elements);if(!h)return e;let P={id:`control-${t.control.resourceId}`,type:"container",x:0,y:0,children:y.elements};return h.children.push(Ko({container:P,resources:s,templateData:Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:s.characters||{},skipTransitionsAndAnimations:b}),isLineCompleted:l,skipMode:u,skipTransitionsAndAnimations:b})),e},Wo=({presentationState:e,resources:t={},runtime:s,variables:o,musicRoomPlayer:a,skipTransitionsAndAnimations:r=!1})=>{if(e?.bgm&&t){let n=e.bgm,i=!Array.isArray(n.sounds),l=i?n.resourceId?[{id:"default",resourceId:n.resourceId,loop:n.loop??!0,volume:n.volume,startDelayMs:n.startDelayMs??0}]:[]:n.sounds,c=!i&&n.loop===!0,u=[];if(i||ps(l,"BGM sound"),c){let d=l.find(f=>f.loop===!0);if(d)throw new Error(`BGM sound "${d.id}" cannot loop inside a looping BGM channel.`)}if(l.forEach(d=>{let f=t.sounds?.[d.resourceId];if(!f)return;let m=c?{...d,loop:d.loop??!1}:d;u.push(Qg({node:ys({id:Rr("bgm",i?"default":d.id),sound:m,resource:f,projectResources:t,soundPath:`bgm.sounds[${JSON.stringify(d.id)}]`,defaultLoop:!c,skipTransitionsAndAnimations:r}),bgm:n,sound:m,resource:f,usesLegacySound:i}))}),u.length===0)return null;let p=Ge({variables:o,runtime:s}).runtime;return ds({id:zg,volume:Go(p,"musicVolume"),muted:!1,pan:0,loop:i?void 0:n.loop,playback:a?.bgmPlayback,interruption:n.interruption,children:u,runtime:p})}return null},yb=(e,t)=>{if(!et(e.elements))return e;let o=Wo(t);return o&&e.audio.push(o),e},hb=(e,{activeAudioEffects:t,skipTransitionsAndAnimations:s})=>(t?.length>0&&!s&&(e.audioEffects=structuredClone(t)),e),gb=(e,{resources:t={},runtime:s,variables:o,musicRoomPlayer:a})=>{let r=t.musicRoom;if(!r||!a?.trackId||!a.playback)return e;let n=r.tracks.find(u=>u.id===a.trackId),i=n?t.sounds?.[n.soundId]:void 0;if(!n||!i)return e;let l=Ge({variables:o,runtime:s}).runtime,c=ys({id:Gg,sound:{loop:!1,startDelayMs:0,playback:a.playback},resource:i,projectResources:t,soundPath:"musicRoom.sound"});return e.audio.push(ds({id:Xg,volume:Ho(l,"musicVolume",_r),children:[c],runtime:l})),e},bb=(e,{presentationState:t,resources:s,runtime:o,skipTransitionsAndAnimations:a})=>{let{audio:r}=e;if(t.sfx&&s){let n=t.sfx,i=Array.isArray(n.channels)?n.channels:[],l=i.map(c=>({channel:c,usesLegacyChannel:!1}));ps(i,"SFX channel"),Array.isArray(n.items)&&l.push({channel:{id:Kg,sounds:n.items},usesLegacyChannel:!0}),l.forEach(({channel:c,usesLegacyChannel:u})=>{let p=!u&&c.loop===!0,d=[];if(u||ps(c.sounds,"SFX sound",`SFX channel "${c.id}"`),p){let f=c.sounds.find(m=>m.loop===!0);if(f)throw new Error(`SFX sound "${f.id}" cannot loop inside looping SFX channel "${c.id}".`)}c.sounds.forEach((f,m)=>{let g=s.sounds?.[f.resourceId];if(!g)return;let b=p?{...f,loop:f.loop??!1}:f;d.push(ys({id:u?Rr("sfx","default",m,f.id):Rr("sfx",c.id,f.id),sound:b,resource:g,projectResources:s,soundPath:`sfx.channels[${JSON.stringify(c.id)}].sounds[${JSON.stringify(f.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:a}))}),d.length!==0&&r.push(ds({id:Rr("channel","sfx",c.id),volume:Ho(o,"soundVolume",c.volume??_r),muted:c.muted,pan:c.pan,loop:u?void 0:c.loop,interruption:u?void 0:c.interruption,children:d,runtime:o}))})}return e},wb=(e,t,s)=>{if(!(!t||!s))return e?.voices?.[t]?.[s]},Ib=(e,{presentationState:t,resources:s,currentSceneId:o,runtime:a,variables:r,skipTransitionsAndAnimations:n})=>{let{audio:i}=e;if(!t?.voice)return e;let l=t.voice,c=!Array.isArray(l.sounds),u=c?l.resourceId?[{id:"default",resourceId:l.resourceId,loop:l.loop??!1,volume:_r,startDelayMs:l.startDelayMs??0}]:[]:l.sounds,p=!c&&l.loop===!0,d=[];if(c||ps(u,"Voice sound"),p){let m=u.find(g=>g.loop===!0);if(m)throw new Error(`Voice sound "${m.id}" cannot loop inside a looping Voice channel.`)}if(u.forEach(m=>{let g=wb(s,o,m.resourceId);if(!g)return;let b=p?{...m,loop:m.loop??!1}:m;d.push(ys({id:Rr("voice",o,c?"default":m.id),sound:b,resource:g,projectResources:s,soundPath:`voice.sounds[${JSON.stringify(m.id)}]`,defaultLoop:p?!1:void 0,skipTransitionsAndAnimations:n}))}),d.length===0)return e;let f=Ge({variables:r,runtime:a}).runtime;return i.push(ds({id:Hg,volume:c?l.volume??Go(f,"soundVolume"):Ho(f,"soundVolume",l.volume??_r),muted:l.muted,pan:l.pan,loop:c?void 0:l.loop,interruption:l.interruption,children:d,runtime:f})),e},vb=(e,{presentationState:t,previousPresentationState:s,resources:o={},variables:a,imageGallery:r,musicRoom:n,sceneReplay:i,runtime:l,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,saveSlots:g=[],isLineCompleted:b,skipTransitionsAndAnimations:y,activePersistentAnimations:w})=>{let{elements:h,animations:P}=e;if(t.layout){let O=et(h);if(!O)return e;let T=o.layouts?.[t.layout.resourceId];if(!T)return e;let $={id:`layout-${t.layout.resourceId}`,type:"container",x:0,y:0,children:T.elements||[]};O.children.push(Ko({container:$,resources:o,templateData:Ge({variables:a,imageGallery:r,musicRoom:n,sceneReplay:i,runtime:l,saveSlots:g,dialogueState:t.dialogue,isLineCompleted:b,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,characters:o.characters||{},skipTransitionsAndAnimations:y}),isLineCompleted:b,skipMode:u,skipTransitionsAndAnimations:y}))}let k=s?.layout?.resourceId,E=t.layout?.resourceId,v=gr({animationsDef:t.layout?.animations,resources:o,previousResourceId:k,currentResourceId:E,previousTargetId:k?`layout-${k}`:void 0,currentTargetId:E?`layout-${E}`:void 0,animationPath:"layout.animations",idPrefix:"layout"});return Ze({animationInstances:v,isLineCompleted:b,skipTransitionsAndAnimations:y,activePersistentAnimations:w})&&P.push(...v),e},kb=(e,{currentLineActions:t,previousPresentationState:s,resources:o={},isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})=>{let{animations:i}=e,l=t?.screen?.animations;if(!l)return e;let c=s!=null,u=gr({animationsDef:l,resources:o,previousResourceId:c?"story":void 0,currentResourceId:"story",previousTargetId:c?"story":void 0,currentTargetId:"story",animationPath:"screen.animations",idPrefix:"screen"});return Ze({animationInstances:u,isLineCompleted:a,skipTransitionsAndAnimations:r,activePersistentAnimations:n})&&i.push(...u),e},Ab=(e,{presentationState:t})=>{let s=et(e.elements);return!s||!t?.screen||Object.assign(s,hu(t.screen)),e},Pb=(e,{presentationState:t,resources:s={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,overlayStack:m=[],dialogueHistory:g=[],saveSlots:b=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:h})=>{let{elements:P}=e;return m&&m.length>0&&m.forEach((k,E)=>{let v=s.layouts?.[k.resourceId];if(!v){console.warn(`Overlay layout not found: ${k.resourceId}`);return}let O={id:`overlayStack-${E}`,type:"container",x:0,y:0,children:[wu({id:`overlayStack-${E}-blocker`,screen:y}),...v.elements||[]]},T=Iu(g,s.characters,o),$=Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:b,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:l,skipMode:c,isChoiceVisible:u,isFormVisible:p,canRollback:d,form:f,historyDialogue:T,characters:s.characters||{},skipTransitionsAndAnimations:h}),D=yr(O,$),[B,..._]=D.children||[],G=hr(Nr({...D,children:_},{isLineCompleted:w,skipMode:c,skipTransitionsAndAnimations:h}),s);P.push({...G,children:B?[B,...G.children||[]]:G.children})}),e},Eb=(e,{presentationState:t,resources:s={},variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:l=[],autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:g,dialogueHistory:b=[],screen:y,isLineCompleted:w,skipTransitionsAndAnimations:h})=>{let{elements:P}=e;if(!g?.resourceId)return e;let k=s.layouts?.[g.resourceId];if(!k)return console.warn(`ConfirmDialog layout not found: ${g.resourceId}`),e;let E={id:"confirmDialog",type:"container",x:0,y:0,children:[wu({id:"confirmDialog-blocker",screen:y}),...k.elements||[]]},v=Iu(b,s.characters,o),O=yr(E,Ge({variables:o,imageGallery:a,musicRoom:r,sceneReplay:n,runtime:i,saveSlots:l,dialogueState:t?.dialogue,isLineCompleted:w,autoMode:c,skipMode:u,isChoiceVisible:p,isFormVisible:d,canRollback:f,form:m,confirmDialog:g,historyDialogue:v,characters:s.characters||{},skipTransitionsAndAnimations:h})),[T,...$]=O.children||[],D=hr(Nr({...O,children:$},{isLineCompleted:w,skipMode:u,skipTransitionsAndAnimations:h}),s);return P.push({...D,children:T?[T,...D.children||[]]:D.children}),e},sn=e=>(t,s)=>cb(t,{...s,visualLayer:e}),xb=sn(dr.BEHIND_BACKGROUND),Sb=sn(dr.BEHIND_CHARACTER),Ob=sn(dr.BEHIND_DIALOGUE),Rb=sn(dr.BEHIND_CHOICE),$b=sn(dr.FOREGROUND),ku=e=>Hn(ib,[db,xb,ob,Sb,ab,Ob,pb,Rb,fb,mb,vb,$b,Ab,kb,yb,gb,bb,Ib,hb,Pb,Eb])(e);function Au(e,t=""){let s=[],o=e.length,a=0,r=0,n=-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=n+1+i();n=l+i(),s.push([l,n,t?parseInt(t[r++],36):0])}return s}function Pu(e,t,s){let o=0,a=t.length-1;for(;o<=a;){let r=o+a>>>1,n=s[r];if(e<t[r])a=r-1;else if(e>n>>>5)o=r+1;else return n&31}return 0}var Eu="090001000h1v5g2903000hl2v6jh16ng1s210111110o35aa10u2k1g10l6600152113h2010u1q1r5aq3890o13181214r22k3158q2n1000v100h1k20000001207030001160721k171001h1j11610332010010321210090411021c1c02100o301201412230u1130b100h1j116111420120411001100k11l10051001h1j11611142011000321210072411021d0g10r3000000132120090o200200g1j11f2012031213711271t1001o301001000001121371b1f0c101h1l2011001031212000080a1t1001m40400102101600i11t301006c7i601008b6p41r10101041h3d0004115a1j290p3q223000511010100g1501010302003172030c0010016000e0i6v50n40n5tl12ir33s12t11u11cj30100060700010a90t220000l71i20m7203010241000502rd101004k300000006101027050920g3t22bk1300616g209030207u18c1000t10003010501b2o20000102000004g37070101o921c000640602001mcv3rg20000001o16d0c0m1fg6g2h30m10q55f1vm11c0ma0p1a42nc0ne1a090q3314902021204020112030318250105bb1201110i1021i15101131502141b15120511011k1155132040202510201010603060a1f02040104210b1g3290e0e0kn11vs12j11j3040pp12t80g6v1vmo7319g21g51gh103040n11010040j51i3f01q1h1d0m27p1a0000cs13200523j200010301010100v140018a4q2501010101c08000i1f12601011g3012215110u1a0001015000pcq181000100011000iji5fvc0u91g5bhg20ie0l94lo6002115303121s12240la1tj23h44tj11t45m4ah33q700000l3ep2021a200t220301012040a0i320j2040007f00100r20c100g3208000011531000s520201036020t900207l1101n311000000321210090a12634b910201l22001051020120011020000e1i520701020000n10h5001050000010000010001re0010323010001r11i520701000001q6000000107l600000230004gg12080001lc62027111n1000411230000000000t820321030030r10090n205001380800501020n2050c0001mc00002000000nc006150000i5l1100600010001q753011160000i441111000000rl11019100000c1h201043102n10ltk1f006eoss2b0202gs94r36si2033ku101m373h50b1rqs4113sli1t22m1uh2435070726u13k92rr7m34h380e0m141egl561g1261114k60ga6nn10t33sv13uf1jf0207150qt16t66pr60n23k6bf1f0e1l29g71c1e029j1n30p11ea0k1028139m16rb2v621122i52213040tf1u3b51n17127c0232041d120819052c28220104060306l5g3l4572g130152cqdl2c3o37a5o27u11c32d9m2cu2191obo57eh9gg1tv3",xu="262122424333333393233393339333333333393393bf3b3b3b3b3f3f3bffff33b3bb33ff3f33b3b3333333bffff3b33bb33f33bffff33b3bb33ff3f33b3bbb333b3ff33b333f33b3b3b3b3333b3bf33b3bb39333b33b33b3b3b333b333333b3b33333f3b33b3ffb3f3fff3f3b33f35dc33333f3b3b3b33323333b3bb3b33b3fb3b3333b33333bff3b3f33bfb3b3ff3b3b3b3b3b333b333b3323e22442344444444444444444444444444444444444444444444444444444444444444444444444444444443333333333b3b3bb33333b353bff3b3b3b3f3ff3b3b333bfff3f33333fb3bb3fb3b3bb33232333f333fff333333333b3b3333bb3b39393f3b3fbf33bb3b393b3b3b3333b33b33b3bbb33b33ffff3b3333bb3933b3b3b333b3b3b3b3b33b3b3b33b3b3b33b3b33b33b3b3b3fffff3bb39b9b3b33b3bf3f3b33f3b3f93b33b3b3bb33b33b3b3b3333393b3b3b33b39bffb3b332333b333dd3b3333233332333333333333333333333333333444444444444a4444444444444344444444444444444444444444444444444444444444",Su="0001000000010010000000100000000000000000000000000001000000010014000100000001001000010101100101100000000000000000000100000001111000010000000110101001110111111111000100000021001000010000000100100001000000011010000100000001111000013000000100140001000000010010";var Ou=65535,Jo=40960,hs=126976,Cu=new Uint8Array(12288),_u=new Uint8Array(3072),Nu=new Uint8Array(2816),ju,Du;{let e=(a,r,n,i,l)=>{let c=r+a.length-1;for(let u=n<r?r:n,p=i>c?c:i;u<=p;u++)a[u-r]=l},t=new Uint32Array(320),s=new Uint32Array(320),o=0;for(let[a,r,n]of Au(Eu,xu))e(Cu,0,a,r,n),e(_u,Jo,a,r,n),e(Nu,hs,a,r,n),r>=65040&&!(a>=hs&&r<=129791)&&(t[o]=a,s[o++]=r<<5|n);ju=t.slice(0,o),Du=s.slice(0,o)}function Ru(e){return e<12288?Cu[e]:e<Jo?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?_u[e-Jo]: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>=hs&&e<129792?Nu[e-hs]:e>=917504?e>921599?0:e>=917536&&e<917632||e>=917760&&e<918e3?3:2:Pu(e,ju,Du)}var Tu=Uint8Array.from(Su,Number);function Cb(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 $u(e,t,s){switch(t){case 3:return e&24?s===8204?e&6:(e&24)===16||Cb(s)?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*Lu(e){let t=e.length;if(t===0)return;let s=e.codePointAt(0),o=s>Ou?2:1,a=Ru(s),r=50200>>a&1?$u(0,a,s):0,n=0,i=s,l=a;for(;o<t;){s=e.codePointAt(o);let c=s>Ou?2:1,u=Ru(s),p=Tu[a<<4|u],d;p===0?d=!0:p===1?d=!1:p===2?d=!(r&1):p===3?d=!(r&4):d=(r&24)!==16,r=50200>>u&1&&(r!==0||u!==3)?$u(r,u,s):0,d&&(yield{segment:e.slice(n,o),index:n,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a},n=o,i=s,l=u),o+=c,a=u}yield{segment:e.slice(n),index:n,input:e,_hd:i,_catBegin:l===15?0:l,_catEnd:a===15?0:a}}function*Mu(e){for(let t of Lu(e))yield t.segment}{let e=Lu("_");Tu._keep=[e,e.next()]}var Vu=1e3,Uu=50,_b=0,qu=100,Fu=50,Nb=60,jb=3,Db=.5,Tb=2e4,Lb=/[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}]/u,Mb=/^\s+$/u,Bu,Vb=e=>{let t=`${e??""}`.normalize("NFC"),s=globalThis.Intl?.Segmenter;return typeof s!="function"?Array.from(Mu(t)):(Bu??=new s(void 0,{granularity:"grapheme"}),Array.from(Bu.segment(t),({segment:o})=>o))},qb=e=>Vb(e).reduce((t,s)=>Mb.test(s)?t+Db:Lb.test(s)?t+jb:t+1,0),Fb=e=>2**(((Number.isFinite(e)?Math.min(qu,Math.max(_b,e)):Uu)-Fu)/(qu-Fu)),Qo=({text:e="",baseDelay:t=Vu,speed:s=Uu}={})=>{let o=Number.isFinite(t)?Math.max(0,t):Vu,a=Fb(s),r=qb(e)*Nb/a,n=Math.max(o,Tb);return Math.min(o+r,n)};var gs={manual:{enabled:!0,requireLineCompleted:!1},auto:{enabled:!1},applyMode:"persistent"},Ku=1,br=1,Ot="choice",Dr="form",cn=()=>({manual:{...gs.manual},auto:{...gs.auto},applyMode:gs.applyMode}),ua=()=>({groupId:null,variantId:null,pageIndex:0}),Bb="music-room:player",Ub=new Set(["asset-unavailable","decode-failed","invalid-segment","invalid-position","playback-failed"]),Is=({bgmPlayback:e={commandId:0,operation:"resume"}}={})=>({trackId:null,pageIndex:0,status:"stopped",readiness:"idle",positionMs:0,durationMs:null,playback:null,seekFallback:null,bgmPlayback:e}),pa=new Set,Yb=new Set(["groupId","variantId"]),zb=new Set(["pageIndex"]),Rt=new Set,Xb=new Set(["trackId"]),Gb=new Set(["positionMs"]),Hb=new Set(["pageIndex"]),fa=new Set,Kb=new Set(["sceneId"]),Wb=new Set(["pageIndex"]),ma=()=>({pageIndex:0}),da=e=>{if((e.global.nextLineConfig?.applyMode??"persistent")!=="singleLine")return;let s=e.global.nextLineConfig?.auto?.enabled===!0;e.global.nextLineConfig={...cn()},s&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})},ea=e=>{e.global.nextLineConfig.auto?.enabled&&(e.global.nextLineConfig.auto.enabled=!1,e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}))},q=e=>{let t=Pe(e)?Pr(e):e;return structuredClone(t)},V=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),vs=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},Wu=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},un=(e,t,s)=>({commandId:vs(e),operation:t,...s===void 0?{}:{positionMs:s}}),ya=e=>{if(!Object.prototype.hasOwnProperty.call(e.global??{},"musicRoomPlayer"))return;let t=e.global.musicRoomPlayer,s=t.bgmPlayback;t.trackId!==null&&(s={commandId:vs(e),operation:"resume"}),e.global.musicRoomPlayer=Is({bgmPlayback:s})},Ju=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error("Achievement action requires a non-empty resourceId");let s=e.projectData.resources?.achievements?.[t];if(!s)throw new Error(`Achievement resource "${t}" not found`);if(s.type!=="boolean"&&s.type!=="number")throw new Error(`Achievement resource "${t}" has invalid type "${s.type}"`);return s},Qu=(e,t)=>{if(e==null||e==="")throw new Error(`${t} requires slotId`);let s=typeof e=="string"&&e.length>0,o=typeof e=="number"&&Number.isFinite(e);if(!s&&!o)throw new Error(`${t} requires a non-empty string or finite number slotId`)},nt=e=>String(e),Zu=()=>({sections:[],resources:[]}),ep=()=>({sceneIds:[]}),Jb=e=>V(e)?(Array.isArray(e.sections)||(e.sections=[]),Array.isArray(e.resources)||(e.resources=[]),e):Zu(),Qb=e=>V(e)?(Array.isArray(e.sceneIds)||(e.sceneIds=[]),e):ep(),Zb=e=>Array.isArray(e)?e.map(t=>t?.text??"").join(""):"",e0=({sectionId:e,lineId:t,content:s,dialogueState:o,characterName:a})=>({sectionId:e,lineId:t,content:s,text:Zb(s),characterId:o.characterId,character:{...o.character||{},name:a},characterName:a}),rp=(e=0)=>({entries:[],currentLength:0,checkpointLengths:Array(e).fill(0)}),r0=e=>V(e)&&typeof e.sectionId=="string"&&e.sectionId.length>0&&typeof e.lineId=="string"&&e.lineId.length>0,ha=e=>{if(!V(e?.dialogueHistory))return null;let t=e.dialogueHistory;return!Array.isArray(t.entries)||!Number.isInteger(t.currentLength)||!Array.isArray(t.checkpointLengths)?null:t},t0=e=>{if(!V(e?.dialogueHistory))return e.dialogueHistory=rp(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},ga=e=>{let t=ha(e);return t?(t.currentLength<t.entries.length&&(t.entries=t.entries.slice(0,t.currentLength)),t):null},n0=()=>({resourceId:void 0}),s0=e=>{if(!V(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},wr=(e,t)=>{let s=e?.story?.scenes??{};for(let[o,a]of Object.entries(s))if(a?.sections?.[t])return{sceneId:o,section:a.sections[t]};return{sceneId:void 0,section:void 0}},tp=e=>{let t=e?.story?.scenes??{},s=new Map;for(let[o,a]of Object.entries(t)){let r=a?.sections??{};for(let n of Object.keys(r)){let i=s.get(n);if(i!==void 0)throw new Error(`Duplicate sectionId "${n}" found in scenes "${i}" and "${o}". Section IDs must be globally unique.`);s.set(n,o)}}},np=e=>e,sp=e=>{if(!Number.isInteger(e)||e<1)throw new Error("Malformed save slot formatVersion.");if(e!==Ku)throw new Error(`Unsupported save slot formatVersion "${e}".`);return e},i0=(e,t={})=>{let s;try{s=sp(t.formatVersion)}catch(a){throw new Error(`Hydrated save slot "${e}" failed validation: ${a.message}`)}let o={...t,formatVersion:s,slotId:np(t.slotId??t.slotKey??e),savedAt:typeof t.savedAt=="number"?t.savedAt:t.date};return delete o.slotKey,delete o.date,o},o0=(e={})=>Object.fromEntries(Object.entries(e).map(([t,s])=>[t,i0(t,s)])),a0=(e,t)=>{if(!V(e)||!Array.isArray(e.operations))return null;let s=e.operations.filter(o=>{if(!V(o))return!1;let{variableId:a,op:r,value:n,roundTo:i}=o,l=t?.resources?.variables?.[a];if(!l||_e(l)||l.readonly===!0||l.scope!=="context")return!1;try{return Kt(l.type,r,a),Jn(l.type,r,n,a,{roundTo:i}),r!=="set"||co(l,n)}catch{return!1}});return s.length>0?{...e,operations:s}:null},ip=(e,t)=>{if(!Array.isArray(e))return;let s=e.flatMap(o=>{if(!V(o)||!YI(o.type))return[];if(o.type!=="updateVariable"||t===void 0)return[o];let a=a0(o.payload,t);return a?[{...o,payload:a}]:[]});return s.length>0?s:void 0},l0=(e,t,s)=>{let{section:o}=wr(e,t?.sectionId),r=o?.lines?.find(({id:i})=>i===t?.lineId)?.actions,n=s.split(".");for(let i of n){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(!V(r)||!Object.prototype.hasOwnProperty.call(r,i))return;r=r[i]}return n.at(-1)==="random"&&V(r?.distribution)?r:void 0},op=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},ap=(e,t,s)=>e.filter(({path:o,type:a,result:r})=>{let n=l0(s,t,o);if(n?.distribution?.type!==a)return!1;if(a==="weighted")return V(n.distribution.outcomes?.[r.outcomeIndex]?.actions);if(a==="integer"){let i=s?.resources?.variables?.[n.variableId];return typeof n.variableId=="string"&&i?.type==="number"&&i.scope==="context"&&i.readonly!==!0&&!_e(i)&&op(n.distribution)&&r.value>=n.distribution.min&&r.value<=n.distribution.max}return!1}),ba=(e,t)=>{if(!Object.prototype.hasOwnProperty.call(e??{},"randomOutcomeVersion"))return;if(e.randomOutcomeVersion!==br)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 s=new Set,o=e.randomOutcomes.map((a,r)=>{let n=`${a?.path}\0${a?.ordinal}`;if(!V(a)||typeof a.path!="string"||a.path.length===0||!Number.isSafeInteger(a.ordinal)||a.ordinal<0||s.has(n))throw new Error(`invalid rollback random outcome at index ${r}`);return s.add(n),{path:a.path,ordinal:a.ordinal,type:a.type,result:rs(q(a.result),a.type)}});return t===void 0?o:ap(o,e,t)},c0=(e,t)=>{!V(e)||!Array.isArray(e.timeline)||e.timeline.forEach(s=>{if(!V(s))return;typeof s.returnable!="boolean"&&delete s.returnable;let o=ip(s.executedActions,t);o?s.executedActions=o:delete s.executedActions;let a=ba(s,t);a?(s.randomOutcomeVersion=br,s.randomOutcomes=a):(delete s.randomOutcomeVersion,delete s.randomOutcomes)})},u0=(e,t)=>{let s=e??{};return Object.values(s).forEach(o=>{let a=o?.state?.contexts;Array.isArray(a)&&a.forEach(r=>{let n=r?.rollback?.timeline;Array.isArray(n)&&n.forEach(i=>{if(!V(i))return;let l=ba(i,t);l?(i.randomOutcomeVersion=br,JSON.stringify(i.randomOutcomes)!==JSON.stringify(l)&&(i.randomOutcomes=l)):(delete i.randomOutcomeVersion,delete i.randomOutcomes)})})}),s},Yu=(e,t,s,o="viewedRegistry")=>{let a=t==="sections"?"sectionId":"resourceId";if(typeof e=="string"||typeof e=="number")return{[a]:String(e)};if(!V(e))throw new Error(`Malformed ${o}.${t}[${s}] entry.`);if(typeof e[a]!="string"||e[a].length===0)throw new Error(`Malformed ${o}.${t}[${s}] 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[${s}] entry: invalid lastLineId.`);return typeof e.lastLineId=="string"&&e.lastLineId.length>0&&(r.lastLineId=e.lastLineId),r}return{resourceId:e.resourceId}},p0=(e,t="viewedRegistry")=>{if(e===void 0)return Zu();if(!V(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 s=e.sections??[],o=e.resources??[];return{sections:Object.values(Object.fromEntries(s.map((a,r)=>{let n=Yu(a,"sections",r,t);return[n.sectionId,n]}))),resources:Object.values(Object.fromEntries(o.map((a,r)=>{let n=Yu(a,"resources",r,t);return[n.resourceId,n]})))}},f0=(e,t="accountReplayRegistry")=>{if(e===void 0)return ep();if(!V(e))throw new Error(`Malformed ${t}.`);if(e.sceneIds!==void 0&&!Array.isArray(e.sceneIds))throw new Error(`Malformed ${t}.sceneIds.`);let s=e.sceneIds??[];return{sceneIds:[...new Set(s.map((o,a)=>{if(typeof o!="string"||o.length===0)throw new Error(`Malformed ${t}.sceneIds[${a}] entry.`);return o}))]}},on=(e,t,s)=>{if(!V(e))throw new Error(`Malformed save slot ${s}.`);let{sectionId:o,lineId:a}=e;if(typeof o!="string"||o.length===0)throw new Error(`Malformed save slot ${s}: missing sectionId.`);if(typeof a!="string"||a.length===0)throw new Error(`Malformed save slot ${s}: missing lineId.`);let{sceneId:r,section:n}=wr(t,o);if(!n)throw new Error(`Malformed save slot ${s}: section "${o}" does not exist in projectData.`);if(!n.lines?.some(l=>l.id===a))throw new Error(`Malformed save slot ${s}: line "${a}" does not exist in section "${o}".`);return{sceneId:r,sectionId:o,lineId:a}},lp=e=>{let t=e.story.initialSceneId,s=e.story.scenes[t],o=s.initialSectionId,a=s.sections[o];return on({sceneId:t,sectionId:o,lineId:a.initialLineId??a.lines[0].id},e,"projectData initial pointer")},m0=e=>{try{return lp(e),!0}catch{return!1}},d0=(e,t,s)=>{let o=e?.pointers?.read;if(!V(o)||typeof o.sectionId!="string"||o.sectionId.length===0||typeof o.lineId!="string"||o.lineId.length===0)return on(o,t,s);try{return on(o,t,s)}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 n=r;n>=0;n-=1)try{return on(a[n],t,`${s} compatibility checkpoint`)}catch{}return lp(t)}};var cp=(e,t)=>{let{section:s}=wr(e,t?.sectionId);return s?.lines?.find(o=>o.id===t?.lineId)},y0=(e,t,s)=>{if(!V(e))throw new Error(`Malformed save slot ${s}.`);if(!Array.isArray(e.entries))throw new Error(`Malformed save slot ${s}.entries.`);if(!Number.isInteger(e.currentLength))throw new Error(`Malformed save slot ${s}.currentLength.`);if(!Array.isArray(e.checkpointLengths))throw new Error(`Malformed save slot ${s}.checkpointLengths.`);let o=[],a=[0],r=!1;if(e.entries.forEach((i,l)=>{if(!V(i))throw new Error(`Malformed save slot ${s}.entries[${l}].`);if(typeof i.sectionId!="string"||i.sectionId.length===0)throw new Error(`Malformed save slot ${s}.entries[${l}]: missing sectionId.`);if(typeof i.lineId!="string"||i.lineId.length===0)throw new Error(`Malformed save slot ${s}.entries[${l}]: missing lineId.`);if(i.appendToPrevious!==void 0&&typeof i.appendToPrevious!="boolean")throw new Error(`Malformed save slot ${s}.entries[${l}].appendToPrevious.`);let{section:c}=wr(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 ${s}.currentLength: must reference the retained entries.`);let n=e.checkpointLengths.map((i,l)=>{if(!Number.isInteger(i)||i<0||i>e.entries.length)throw new Error(`Malformed save slot ${s}.checkpointLengths[${l}].`);return a[i]});return{entries:o,currentLength:a[e.currentLength],checkpointLengths:n}},h0=(e,t)=>V(cp(e,t)?.actions?.dialogue),up=(e,t,s)=>{if(!t||t.sectionId!==s.sectionId)return!1;let{section:o}=wr(e,s.sectionId),a=o?.lines?.findIndex(n=>n.id===s.lineId);return typeof a!="number"||a<=0?!1:o.lines.slice(0,a).findLast(n=>V(n.actions?.dialogue))?.id===t.lineId},g0=(e,t)=>{let s=rp();return e.timeline.forEach(o=>{if(o.returnable!==!1&&h0(t,o)){let a=cp(t,o),r=s.entries.at(-1),n=a.actions.dialogue.append===!0&&up(t,r,o);s.entries.push({sectionId:o.sectionId,lineId:o.lineId,...n?{appendToPrevious:!0}:{}})}s.checkpointLengths.push(s.entries.length)}),s.currentLength=s.checkpointLengths[e.currentIndex]??0,s.entries.length>0?s:null},b0=(e,t,s,o)=>{if(s.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=s.map(r=>r===null?e.currentLength:e.checkpointLengths[r]);let a=0;return e.checkpointLengths.forEach((r,n)=>{if(r<a)throw new Error(`Malformed save slot dialogueHistory.checkpointLengths[${n}]: lengths must be chronological.`);a=r}),e},w0=(e,t,s)=>{if(!V(e)||!Array.isArray(e.timeline))return{rollback:ln({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:0};let o=[],a=e.timeline.flatMap((c,u)=>{if(!V(c))return[];let p=ba(c);try{let d=on(c,s,`rollback.timeline[${u}]`),f=p?ap(p,d,s):void 0,m=ws({sectionId:d.sectionId,lineId:d.lineId,rollbackPolicy:c.rollbackPolicy,returnable:c.returnable,...f?{randomOutcomeVersion:br,randomOutcomes:f}:{}}),g=ip(q(c.executedActions),s);return g&&(m.executedActions=g),o.push(u),[m]}catch{return[]}});if(a.length===0)return{rollback:ln({pointer:t,replayStartIndex:1}),sourceCheckpointIndexes:[null],sourceTimelineLength:e.timeline.length};let r=typeof e.currentIndex=="number"?Math.trunc(e.currentIndex):e.timeline.length-1,n=o.indexOf(r);n<0&&(n=a.length-1);let i=a[n];if(i?.sectionId!==t.sectionId||i?.lineId!==t.lineId){let c=a.findLastIndex(u=>u.sectionId===t.sectionId&&u.lineId===t.lineId);c>=0?n=c:(a.push(ws({sectionId:t.sectionId,lineId:t.lineId})),o.push(null),n=a.length-1)}let l=typeof e.replayStartIndex=="number"?Math.min(Math.max(Math.trunc(e.replayStartIndex),0),n):0;return{rollback:{currentIndex:n,isRestoring:!1,replayStartIndex:l,timeline:a},sourceCheckpointIndexes:o,sourceTimelineLength:e.timeline.length}},pp=(e,t,s)=>{if(!V(e))throw new Error(`Malformed save slot contexts[${s}] entry.`);let o=Ia(t),a=d0(e,t,`contexts[${s}].pointers.read`);if(e.variables!==void 0&&!V(e.variables))throw new Error(`Malformed save slot contexts[${s}].variables entry.`);if(e.runtime!==void 0&&!V(e.runtime))throw new Error(`Malformed save slot contexts[${s}].runtime entry.`);let r=e.variables?Gt(q(e.variables),t.resources?.variables??{},{allowedScopes:["context"]}):{},n=_0({loadedContextRuntime:V(e.runtime)?q(e.runtime):{}}),{rollback:i,sourceCheckpointIndexes:l,sourceTimelineLength:c}=w0(e.rollback,a,t),u=e.dialogueHistory===void 0?g0(i,t):b0(y0(e.dialogueHistory,t,`contexts[${s}].dialogueHistory`),i,l,c),p={currentPointerMode:"read",pointers:{read:a},configuration:V(e.configuration)?q(e.configuration):{},views:Array.isArray(e.views)?q(e.views):[],bgm:V(e.bgm)?q(e.bgm):{resourceId:void 0},variables:{...o,...r},...u?{dialogueHistory:u}:{},rollback:i};return n&&(p.runtime=n),p},I0=(e,t)=>{if(!V(e))throw new Error("Malformed save slot state.");if(!Array.isArray(e.contexts)||e.contexts.length===0)throw new Error("Malformed save slot state: contexts must be a non-empty array.");return{contexts:e.contexts.map((s,o)=>pp(s,t,o))}},v0=(e,t)=>{if(!V(e))throw new Error("Malformed save slot.");let s=sp(e.formatVersion);return{...e,formatVersion:s,state:I0(e.state,t)}},zu=(e,t,{required:s=!1}={})=>{if(e===void 0){if(s)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=q(e),a=o.hideConfirmDialog??{};return delete o.hideConfirmDialog,{hideConfirmDialog:a,...o}},k0=(e={})=>{if(!e?.resourceId)throw new Error("showConfirmDialog requires resourceId");return{resourceId:e.resourceId,confirmActions:zu(e.confirmActions,"confirmActions",{required:!0}),cancelActions:zu(e.cancelActions,"cancelActions")}},$t=e=>{Object.prototype.hasOwnProperty.call(e.global,"confirmDialog")&&(e.global.confirmDialog=null)},A0=e=>(V(e.global.formDrafts)||(e.global.formDrafts={}),e.global.formDrafts),Ct=e=>{Object.prototype.hasOwnProperty.call(e.global,"formDrafts")&&(e.global.formDrafts={})},fp=e=>{if(!(!V(e)||!e.animations))return{animations:q(e.animations)}},P0=(e,t)=>{let s=fp(t);if(s){e.global.pendingScreenTransition=s;return}delete e.global.pendingScreenTransition},E0=e=>{let t=e?.id??e?.resourceId;return typeof t=="string"&&t.length>0?t:void 0},x0=(e,t)=>{let s=e?.sectionId,o=e?.lineId;if(!(!s||!o||!t))return`${s}:${o}:${t}`},bs=e=>String(e??""),mp=(e,t)=>{let s=bs(t);return e?.trim===!0?s.trim():s},S0=e=>V(e?.fields)?Object.fromEntries(Object.entries(e.fields).filter(([,t])=>V(t)).map(([t,s])=>[t,{id:t,...q(s)}])):{},O0=(e,t)=>{if(!t||!V(e.global.formDrafts))return;let s=e.global.formDrafts[t];return V(s)?s:void 0},dp=(e,t)=>{let s=A0(e);V(s[t])||(s[t]={values:{},touched:{},errors:{},submitted:!1});let o=s[t];return V(o.values)||(o.values={}),V(o.touched)||(o.touched={}),V(o.errors)||(o.errors={}),typeof o.submitted!="boolean"&&(o.submitted=!1),o},wa=(e,t)=>{let s=mp(e,t);return e?.required===!0&&s.length===0?"required":null},R0=({state:e,pointer:t})=>{if(!t?.sectionId||!t?.lineId)return{};let o=xe({state:e},{sectionId:t.sectionId})?.lines||[],a=o.findIndex(r=>r.id===t.lineId);return a<0?{}:Qr(o.slice(0,a+1).map(r=>r.actions||{}),{resources:e.projectData.resources})},$0=({state:e,form:t,pointer:s})=>{if(!t?.resourceId)return null;let o=E0(t),a=x0(s,o);if(!o||!a)return null;let r=O0(e,a),n=S0(t),i=Na({state:e}),l={},c=[],u={},p=!0;return Object.entries(n).forEach(([d,f])=>{let m=bs(i?.[f.variableId]),g=Object.prototype.hasOwnProperty.call(r?.values??{},d)?bs(r.values[d]):m,b=r?.touched?.[d]===!0,y=wa(f,g),w=r?.submitted||b?y:null,h=typeof f.maxLength=="number"?Math.max(0,Math.round(f.maxLength)):void 0,P={id:d,variableId:f.variableId,value:g,initialValue:m,valid:!y,error:w,touched:b,required:f.required===!0,trim:f.trim===!0,placeholder:f.placeholder===void 0?"":String(f.placeholder),multiline:f.multiline===!0,...h!==void 0?{maxLength:h}:{}};y&&(p=!1),l[d]=P,c.push(P),u[d]=g}),{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:q(t.submitActions??{})}},cancelActions:{cancelForm:{formKey:a,actions:q(t.cancelActions??{})}}}},St="line",jr="interaction",ws=({sectionId:e,lineId:t,rollbackPolicy:s,returnable:o,randomOutcomeVersion:a,randomOutcomes:r})=>({sectionId:e,lineId:t,rollbackPolicy:s??"free",...typeof o=="boolean"?{returnable:o}:{},...a===br?{randomOutcomeVersion:br,randomOutcomes:q(r??[])}:{}}),Ia=e=>{let t=Pe(e)?Pr(e):e,{contextVariableDefaultValues:s}=Wn(t??{});return q(s)},yp=()=>({...q(en)}),hp=({loadedRuntime:e,runtimeIds:t,defaults:s={},path:o})=>{if(e===void 0)return{runtimeState:q(s),hasLoadedValues:!1};if(!V(e))throw new Error(`Malformed ${o}.`);let a=q(s),r=!1;return t.forEach(n=>{e[n]!==void 0&&(a[n]=os(n,q(e[n])),r=!0)}),{runtimeState:a,hasLoadedValues:r}},C0=({projectData:e,loadedGlobalRuntime:t={}})=>hp({loadedRuntime:t,runtimeIds:Io,defaults:ko(e),path:"global.runtime"}).runtimeState,_0=({loadedContextRuntime:e={}})=>{let{runtimeState:t,hasLoadedValues:s}=hp({loadedRuntime:e,runtimeIds:vo,defaults:yp(),path:"context.runtime"});return s?t:void 0},Lr=e=>{let t=Array.isArray(e?.contexts)?e.contexts:[];return t[t.length-1]},ye=e=>{let t=Lr(e);return t?.kind==="sceneReplay"&&V(t.sceneReplay)?t:null},gp=(e,t)=>{let s=t?.sceneReplay?.sceneId,o=e.projectData?.resources?.sceneReplay?.replays?.find(a=>a.sceneId===s);Object.entries(o?.initialVariables??{}).forEach(([a,r])=>{t.variables[a]=q(r)})},N0=e=>({autoMode:e.global.autoMode,skipMode:e.global.skipMode,dialogueUIHidden:e.global.dialogueUIHidden,nextLineConfig:q(e.global.nextLineConfig),overlayStack:q(e.global.overlayStack),confirmDialog:q(e.global.confirmDialog),formDrafts:q(e.global.formDrafts),isLineCompleted:e.global.isLineCompleted,...e.global.isDialogueHistoryShowing===void 0?{}:{isDialogueHistoryShowing:e.global.isDialogueHistoryShowing},...e.global.pendingScreenTransition===void 0?{}:{pendingScreenTransition:q(e.global.pendingScreenTransition)}}),j0=e=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,delete e.global.pendingScreenTransition,e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.confirmDialog=null,e.global.formDrafts={},e.global.isLineCompleted=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"})},D0=(e,t)=>{e.global.autoMode=t.autoMode,e.global.skipMode=t.skipMode,e.global.dialogueUIHidden=t.dialogueUIHidden,e.global.nextLineConfig=q(t.nextLineConfig),e.global.overlayStack=q(t.overlayStack),e.global.confirmDialog=q(t.confirmDialog),e.global.formDrafts=q(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=q(t.pendingScreenTransition),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"});let s=Se({state:e});e.global.autoMode&&e.global.isLineCompleted&&!s&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e.global.skipMode&&!s&&e.global.pendingEffects.push({name:"startSkipNextTimer"}),e.global.nextLineConfig.auto?.enabled&&!s&&(e.global.nextLineConfig.auto.trigger==="fromStart"||e.global.isLineCompleted)&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:e.global.nextLineConfig.auto.delay}})},T0=e=>e.runtime?(vo.forEach(t=>{e.runtime[t]===void 0&&(e.runtime[t]=q(en[t]))}),e.runtime):(e.runtime=yp(),e.runtime),L0=e=>Bc(e.global),bp=e=>{e.global.pendingEffects.push({name:"saveGlobalRuntime",payload:{globalRuntime:L0(e)}})},va=(e,t,s)=>{let o=os(t,s);if(t in en){let a=Lr(e);if(!a)return o;let r=T0(a);return r[t]=o,o}return e.global[t]=o,o},ka=({pointer:e,projectData:t,kind:s,sceneReplay:o})=>({...s===void 0?{}:{kind:s},...o===void 0?{}:{sceneReplay:q(o)},currentPointerMode:"read",pointers:{read:q(e)},configuration:{},views:[],bgm:n0(),variables:Ia(t),rollback:ln({pointer:e})}),_t=e=>e?(e.currentPointerMode="read",V(e.pointers)||(e.pointers={}),Object.prototype.hasOwnProperty.call(e.pointers,"history")&&delete e.pointers.history,e.pointers):null,M0=(e,{queueRender:t=!0}={})=>{let s=e.contexts?.[e.contexts.length-1],o=s?.pointers?.read;if(!s||!o?.sectionId||!o?.lineId)return null;let a=ka({pointer:o,projectData:e.projectData});return e.contexts[e.contexts.length-1]=a,V0(e,{queueRender:t}),a},V0=(e,{queueRender:t=!0}={})=>{e.global.autoMode=!1,e.global.skipMode=!1,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,$t(e),Ct(e),e.global.nextLineConfig=cn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,ya(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"}),t&&e.global.pendingEffects.push({name:"render"})},wp=e=>{!e||!("baselineVariables"in e)||delete e.baselineVariables},ln=({pointer:e,replayStartIndex:t=0})=>{let s=e?.sectionId&&e?.lineId;return{currentIndex:s?0:-1,isRestoring:!1,replayStartIndex:t,timeline:s?[ws({sectionId:e.sectionId,lineId:e.lineId})]:[]}},Mr=(e,t={})=>{if(e?.rollback)return wp(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 s=e?.pointers?.read;return e.rollback=ln({pointer:s,replayStartIndex:t.compatibilityAnchor?1:0}),e.rollback},ks=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return;let o=Mr(s);if(o.isRestoring)return;let a=ga(s);o.currentIndex<o.timeline.length-1&&(o.timeline=o.timeline.slice(0,o.currentIndex+1)),o.timeline.push(ws(t)),o.currentIndex=o.timeline.length-1,a&&(a.checkpointLengths=a.checkpointLengths.slice(0,o.currentIndex),a.checkpointLengths.push(a.currentLength))},q0=({state:e})=>{let s=e.contexts?.[e.contexts.length-1]?.rollback;return!Array.isArray(s?.timeline)||typeof s.currentIndex!="number"?null:{checkpointIndex:s.currentIndex,checkpoint:s.timeline[s.currentIndex]??null}},F0=({state:e},t={})=>{let{checkpointIndex:s,checkpointIdentity:o,sectionId:a,lineId:r}=t,i=e.contexts?.[e.contexts.length-1]?.rollback;if(!Number.isInteger(s)||!Array.isArray(i?.timeline)||typeof i.currentIndex!="number")return e;let l=i.timeline[s];return(Pe(l)?Tn(l):l)!==o||l?.sectionId!==a||l?.lineId!==r||(l.returnable=!1),e},B0=({state:e},t={})=>{let{slotId:s,saveSlotIdentity:o,checkpointIndex:a,sectionId:r,lineId:n}=t,i=nt(s),l=e.global.saveSlots?.[i],c=Pe(l)?Tn(l):l;if(!l||c!==o)return e;let u=l.state?.contexts,p=Array.isArray(u)?u.at(-1):null,d=p?.rollback,f=d?.timeline?.[a];return!Number.isInteger(a)||d?.currentIndex!==a||p?.pointers?.read?.sectionId!==r||p?.pointers?.read?.lineId!==n||f?.sectionId!==r||f?.lineId!==n||(f.returnable=!1,e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})),e},Ip=(e,t)=>{let s=e.contexts?.[e.contexts.length-1],o=s?.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 n=ga(s);n&&(n.checkpointLengths=n.checkpointLengths.slice(0,r+1))}return o.timeline[r]??null},U0=({state:e,rollbackActionBatchStack:t,playbackOwnership:s},o={})=>{let a=o?.source===St?St:jr,r=e.contexts?.[e.contexts.length-1],n=r?.rollback;if(!n||n.isRestoring||!Array.isArray(n.timeline)||typeof n.currentIndex!="number"||n.currentIndex<0||n.currentIndex>=n.timeline.length)return t.push({checkpointIndex:null,source:a}),e;if(n.currentIndex<n.timeline.length-1){n.timeline=n.timeline.slice(0,n.currentIndex+1);let u=ga(r);u&&(u.checkpointLengths=u.checkpointLengths.slice(0,n.currentIndex+1))}let i=r?.pointers?.read,l=s?.lineEntryId,c=a===St&&(s?.rollbackCheckpointLineEntryId===void 0?n.timeline[n.currentIndex]?.sectionId===i?.sectionId&&n.timeline[n.currentIndex]?.lineId===i?.lineId:s.rollbackCheckpointLineEntryId===l);return t.push({checkpointIndex:n.currentIndex,source:a,...a===St?{lineEntryId:l,sourcePointer:i?{sectionId:i.sectionId,lineId:i.lineId}:null,hasTrackedLineEntryCheckpoint:c}:{}}),e},Y0=({state:e,rollbackActionBatchStack:t})=>(t.pop(),e),z0=({state:e,rollbackActionBatchStack:t,playbackOwnership:s})=>{let o=t?.at(-1);if(o?.source!==St||o.hasTrackedLineEntryCheckpoint)return e;let a=o.sourcePointer;if(!a)return e;ks(e,{sectionId:a.sectionId,lineId:a.lineId,returnable:!1});let n=(e.contexts?.at(-1)).rollback;return o.checkpointIndex=n.currentIndex,o.hasTrackedLineEntryCheckpoint=!0,s?.lineEntryId===o.lineEntryId&&(s.rollbackCheckpointLineEntryId=o.lineEntryId),e},X0=({state:e,rollbackActionBatchStack:t},s)=>{if(t?.at(-1)?.source!==St)return e;if(typeof s?.path!="string"||s.path.length===0)throw new Error("random rollback outcome requires a structural path");if(!Number.isSafeInteger(s.ordinal)||s.ordinal<0)throw new Error("random rollback outcome requires a non-negative ordinal");let a=rs(s.result,s.type),r=Ip(e,t);if(!r)return e;if(r.randomOutcomeVersion!==br&&(r.randomOutcomeVersion=br,r.randomOutcomes=[]),r.randomOutcomes.some(({path:n,ordinal:i})=>n===s.path&&i===s.ordinal))throw new Error(`duplicate random outcome identity in rollback occurrence: ${s.path}#${s.ordinal}`);return r.randomOutcomes.push({path:s.path,ordinal:s.ordinal,type:s.type,result:a}),e},ir=(e,t,s,o)=>{let r=o?.at(-1)?.source??jr;if(!zI(t,r))return;let n=Ip(e,o);n&&(Array.isArray(n.executedActions)||(n.executedActions=[]),n.executedActions.push({type:t,payload:q(s)}))},ra=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return;let o=t?.operations??[];for(let{variableId:a,op:r,value:n,roundTo:i}of o){let l=e.projectData.resources?.variables?.[a],c=l?.scope,u=l?.type;if(_e(l))throw new Error(`Cannot update computed variable: ${a}`);if(l?.readonly===!0)throw new Error(`Cannot update readonly variable: ${a}`);Ht(c,a),Kt(u,r,a),Jn(u,r,n,a,{roundTo:i}),c==="context"&&(s.variables[a]=Qn(s.variables[a],r,n,{roundTo:i}))}},G0=(e,t)=>{Array.isArray(t?.executedActions)&&t.executedActions.forEach(({type:s,payload:o})=>{XI(e,s,o)})},H0=(e,t)=>{let{sectionId:s,lineId:o}=t,n=xe({state:e},{sectionId:s})?.lines?.find(i=>i.id===o)?.actions;n&&Ma(e,n,{checkpoint:t,bindings:{},randomOutcomeOrdinals:new Map},[])},vp=(e,t)=>{let s=e.contexts?.[e.contexts.length-1];if(!s)return e;let o=Mr(s),a=o.timeline[t];if(!a)return e;e.global.autoMode&&dn({state:e}),e.global.skipMode&&Tr({state:e}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),o.isRestoring=!0,o.currentIndex=t;try{s.variables=Ia(e.projectData),s.kind==="sceneReplay"&&(gp(e,s),s.sceneReplay.finishOnNextAdvance=!1,s.sceneReplay.exitOnLineCompleted=!1),delete s.runtime,e.global.dialogueUIHidden=!1,delete e.global.isDialogueHistoryShowing,e.global.nextLineConfig=q(gs),e.global.overlayStack=[],$t(e),Ct(e),e.global.isLineCompleted=!0;let r=o.replayStartIndex??0;for(let l=r;l<=t;l++)l>r&&da(e),H0(e,o.timeline[l]),G0(e,o.timeline[l]);let n=_t(s);n.read={sectionId:a.sectionId,lineId:a.lineId};let i=ha(s);i&&(i.currentLength=Math.min(i.checkpointLengths[t]??0,i.entries.length)),s.kind==="sceneReplay"&&(s.sceneReplay.entryId=Wu(e)),e.global.pendingEffects=e.global.pendingEffects.filter(l=>l?.name!=="render"),e.global.pendingEffects.push({name:"render"})}finally{o.isRestoring=!1}return e},K0=e=>{let{projectData:t}=e,s=e.initialAudioCommandId??0;if(!Number.isSafeInteger(s)||s<0)throw new Error("Internal initial audio command counter is invalid");let o=e.global??{},{saveSlots:a={},variables:r={},runtime:n={},accountViewedRegistry:i={},accountReplayRegistry:l={},localizationPackages:c=[{l10nId:null,language:null}]}=o;tp(t),Yt(t),zt(t),Xt(t),Wr(t?.resources?.variables??{});let u=t.story.initialSceneId,p=t.story.scenes[u],d=p.initialSectionId,f=p.sections[d],m={sceneId:u,sectionId:d,lineId:f.initialLineId??f.lines[0].id},{globalVariablesDefaultValues:g}=Wn(t),b={...g,...Gt(r,t.resources?.variables??{},{allowedScopes:["device","account"],preserveUnknown:!0})};return{projectData:t,global:{pendingEffects:[],confirmDialog:null,formDrafts:{},accountViewedRegistry:p0(i,"accountViewedRegistry"),accountReplayRegistry:f0(l),nextLineConfig:cn(),imageGalleryNavigation:ua(),sceneReplayNavigation:ma(),sceneReplayEntryId:0,audioCommandId:s,musicRoomPlayer:Is(),saveSlots:o0(a),localizationPackages:q(c),overlayStack:[],variables:b,...C0({projectData:t,loadedGlobalRuntime:n})},contexts:[ka({pointer:m,projectData:t})]}},W0=({state:e})=>e.global.overlayStack||[],J0=({state:e})=>e.global.pendingEffects,kp=({state:e})=>e.global.skipMode,Q0=({state:e})=>e.global.autoMode,Ap=({state:e})=>e.global.dialogueUIHidden,Pp=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],s=t[t.length-1];if(!s)return[];let o,a=V(s.dialogueHistory)&&Array.isArray(s.dialogueHistory.entries)&&Number.isInteger(s.dialogueHistory.currentLength);if(a)o=s.dialogueHistory.entries.slice(0,s.dialogueHistory.currentLength);else{let{sectionId:c,lineId:u}=s.pointers.read,p=xe({state:e},{sectionId:c});if(!p?.lines||!Array.isArray(p.lines))return[];let d=p.lines.findIndex(f=>f.id===u);o=p.lines.slice(0,d+1).map(f=>({sectionId:c,lineId:f.id}))}let r=[],n=bt({variables:{...e.global?.variables??{},...Lr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),i=new Map,l=c=>{let u=i.get(c.sectionId);if(!u){let d=xe({state:e},{sectionId:c.sectionId}),f=Array.isArray(d?.lines)?d.lines:[];u={lines:f,lineIndexes:new Map(f.map((m,g)=>[m.id,g])),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 d=u.lines[u.nextLineIndex],f=d.actions||{};u.presentationState=Qr([u.presentationState,f],{resources:e.projectData.resources}),u.projections.set(d.id,{line:d,lineActions:f,dialogueState:u.presentationState.dialogue||{}}),u.nextLineIndex+=1}return u.projections.get(c.lineId)??null};for(let c of o){if(!r0(c))continue;let u=l(c);if(!u)continue;let{line:p,lineActions:d,dialogueState:f}=u;if(!d.dialogue)continue;let m=Kn({characterId:f.characterId,character:f.character,characters:e.projectData.resources?.characters??{},variables:n}),g=e0({sectionId:c.sectionId,lineId:p.id,content:d.dialogue.append===!0?f.content:d.dialogue.content,dialogueState:f,characterName:m}),b=r[r.length-1];if((a?c.appendToPrevious===!0:d.dialogue.append===!0)&&b?.sectionId===c.sectionId){r[r.length-1]={...r[r.length-1],content:g.content,text:g.text,characterId:g.characterId,character:g.character,characterName:g.characterName};continue}r.push(g)}return r},Z0=(e,t,s)=>{let o=!1;for(let a of t??[]){let{slotId:r,saveSlotIdentity:n,sectionId:i,lineId:l}=a,c=e.global.saveSlots?.[nt(r)],u=Pe(c)?Tn(c):c,p=c?.state?.contexts?.at(-1);!c||u!==n||p?.pointers?.read?.sectionId!==i||p?.pointers?.read?.lineId!==l||(p.dialogueHistory=q(s),o=!0)}o&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}})},ew=({state:e},t={})=>{let s=Lr(e),o=s?.pointers?.read,a=fn({state:e});if(!s||!V(a?.actions?.dialogue))return e;let r=Mr(s),n=r.timeline?.[r.currentIndex],i=n?.sectionId===o?.sectionId&&n?.lineId===o?.lineId,l=ha(s),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 d=t0(s);d.currentLength<d.entries.length&&(d.entries=d.entries.slice(0,d.currentLength));let f=a.actions.dialogue.append===!0&&t.appendToPrevious===!0&&up(e.projectData,p,o);if(d.entries.push({sectionId:o.sectionId,lineId:o.lineId,...f?{appendToPrevious:!0}:{}}),d.currentLength=d.entries.length,i){for(;d.checkpointLengths.length<r.timeline.length;)d.checkpointLengths.push(d.checkpointLengths.at(-1)??0);d.checkpointLengths[r.currentIndex]=d.currentLength}return Z0(e,t.savedCheckpointOccurrences,d),e},rw=({state:e})=>e.global.confirmDialog??null,pn=({state:e},{pointer:t}={})=>{let s=t??qe({state:e})?.pointer,o=R0({state:e,pointer:s});return $0({state:e,form:o.form,pointer:s})},tw=({state:e},{pointer:t}={})=>!!pn({state:e},{pointer:t}),Se=({state:e},{pointer:t}={})=>{let s=pn({state:e},{pointer:t});if(s)return{source:Dr,formId:s.id,formKey:s.key};let o=$p({state:e,pointer:t});return o?{source:Ot,resourceId:o}:null},nw=({state:e,registry:t},s)=>{let{sectionId:o,lineId:a}=s,n=(Array.isArray(t?.sections)?t.sections:[]).find(u=>u.sectionId===o);if(!n)return!1;if(n.lastLineId===void 0||a===void 0)return!0;let i=xe({state:e},{sectionId:o});if(!i||!i.lines||!Array.isArray(i.lines))return n.lastLineId===a;let l=i.lines.findIndex(u=>u.id===n.lastLineId),c=i.lines.findIndex(u=>u.id===a);return l===-1||c===-1?n.lastLineId===a:c<=l},Aa=({registry:e},t)=>{let{resourceId:s}=t;return!!(Array.isArray(e?.resources)?e.resources:[]).find(r=>r.resourceId===s)},Pa=({state:e},t)=>nw({state:e,registry:e.global.accountViewedRegistry},t),sw=({state:e},t)=>Aa({registry:e.global.accountViewedRegistry},t),an=(e,t)=>!Aa({registry:e.global.accountViewedRegistry},{resourceId:t.imageId}),Ea=e=>e.groups.length===0?0:Math.ceil(e.groups.length/e.pageSize),xa=(e,t)=>{let s=Ea(e);if(s===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),s-1)},ta=(e,t,s,o)=>{for(let a=s+o;a>=0&&a<t.length;a+=o)if(!an(e,t[a]))return t[a]},iw=({state:e})=>{let t=e.projectData?.resources?.imageGallery;return t===void 0?void 0:q(t)},Ep=({state:e})=>{let t=e.projectData?.resources?.imageGallery;if(t===void 0)return null;let s=e.global.imageGalleryNavigation??ua(),o=Ea(t),a=xa(t,s),r=a*t.pageSize,n=t.groups.slice(r,r+t.pageSize).map(l=>({groupId:l.id,locked:an(e,l.variants[0]),variants:l.variants.map(c=>({variantId:c.id,imageId:c.imageId,locked:an(e,c)}))})),i=null;if(typeof s.groupId=="string"&&typeof s.variantId=="string"){let l=t.groups.findIndex(f=>f.id===s.groupId),c=t.groups[l],u=c?.variants.findIndex(f=>f.id===s.variantId),p=u===void 0||u<0?void 0:c.variants[u],d=l<0?-1:Math.floor(l/t.pageSize);p&&d===a&&!an(e,p)&&(i={groupId:c.id,variantId:p.id,imageId:p.imageId,canMoveToPreviousVariant:ta(e,c.variants,u,-1)!==void 0,canMoveToNextVariant:ta(e,c.variants,u,1)!==void 0})}return{pageGroups:n,selection:i,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},Sa=(e,t)=>!Aa({registry:e.global.accountViewedRegistry},{resourceId:t.soundId}),Oa=e=>e.tracks.length===0?0:Math.ceil(e.tracks.length/e.pageSize),Ra=(e,t)=>{let s=Oa(e);if(s===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),s-1)},na=(e,t,s,o)=>{for(let a=s+o;a>=0&&a<t.length;a+=o)if(!Sa(e,t[a]))return t[a]},xp=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}),ow=(e,t)=>({...xp(t),locked:Sa(e,t)}),Xu=e=>{let t=Math.floor(e/1e3),s=t%60,o=Math.floor(t/60);if(o<60)return`${o}:${String(s).padStart(2,"0")}`;let a=Math.floor(o/60),r=o%60;return`${a}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`},aw=({state:e})=>{let t=e.projectData?.resources?.musicRoom;return t===void 0?void 0:q(t)},Sp=({state:e})=>{let t=e.projectData?.resources?.musicRoom;if(t===void 0)return null;let s=e.global.musicRoomPlayer??Is(),o=Oa(t),a=Ra(t,s),r=a*t.pageSize,n=t.tracks.slice(r,r+t.pageSize).map(u=>ow(e,u)),i=t.tracks.findIndex(u=>u.id===s.trackId),l=t.tracks[i],c=l?{...xp(l),canPlayPreviousTrack:na(e,t.tracks,i,-1)!==void 0,canPlayNextTrack:na(e,t.tracks,i,1)!==void 0}:null;return{pageTracks:n,selection:c,playback:c?{status:s.status,readiness:s.readiness,positionMs:s.positionMs,durationMs:s.durationMs,positionText:Xu(s.positionMs),durationText:s.durationMs===null?null:Xu(s.durationMs),canPlay:s.status!=="playing",canPause:s.status==="playing",canSeek:s.readiness==="ready"&&s.durationMs!==null}:null,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},$a=e=>e.replays.length===0?0:Math.ceil(e.replays.length/e.pageSize),Ca=(e,t)=>{let s=$a(e);if(s===0)return 0;let o=Number.isInteger(t?.pageIndex)?t.pageIndex:0;return Math.min(Math.max(o,0),s-1)},lw=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;return t===void 0?void 0:q(t)},cw=({state:e})=>ye(e)!==null,uw=({state:e})=>{let t=ye(e);return t?{sceneId:t.sceneReplay.sceneId,entryId:t.sceneReplay.entryId}:null},Op=(e,t)=>e.global.accountReplayRegistry?.sceneIds?.includes(t)===!0,Rp=({state:e})=>{let t=e.projectData?.resources?.sceneReplay;if(t===void 0)return null;let s=e.global.sceneReplayNavigation??ma(),o=$a(t),a=Ca(t,s),r=a*t.pageSize,n=t.replays.slice(r,r+t.pageSize).map(l=>({sceneId:l.sceneId,title:l.title,thumbnailImageId:l.thumbnailImageId,locked:!Op(e,l.sceneId)})),i=ye(e);return{isActive:i!==null,activeSceneId:i?.sceneReplay.sceneId??null,pageReplays:n,pagination:{pageIndex:a,pageCount:o,canMoveToPreviousPage:a>0,canMoveToNextPage:a+1<o}}},pw=({state:e})=>e.global.nextLineConfig,$p=({state:e,pointer:t}={})=>{let s=t??qe({state:e})?.pointer;if(!s)return;let o=s?.sectionId,a=s?.lineId,n=xe({state:e},{sectionId:o})?.lines||[],i=n.findIndex(c=>c.id===a);if(i<0)return;let l;for(let c of n.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},Cp=({state:e})=>!!$p({state:e}),fw=({state:e})=>structuredClone(e),mw=({state:e})=>q(e.projectData.resources?.achievements??{}),dw=({state:e},t)=>{let s=e.projectData.resources?.achievements?.[t?.resourceId];return s===void 0?void 0:q(s)},_p=({state:e})=>e.global.saveSlots,yw=({state:e},t)=>{let s=t?.slotId,o=nt(s);return Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0},Np=({state:e})=>q(e.global.localizationPackages),_a=({state:e})=>Cr(e),hw=({state:e},t)=>nr(e,t?.runtimeId),Na=({state:e})=>{let t={...e.global?.variables??{},...Lr(e)?.variables??{}};return bt({variables:t,runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{}})},qe=({state:e})=>{let t=Array.isArray(e.contexts)?e.contexts:[],s=t[t.length-1];if(s)return{currentPointerMode:"read",pointer:s.pointers?.read}},xe=({state:e},t)=>{let{sectionId:s}=t;return wr(e.projectData,s).section},fn=({state:e})=>{let t=qe({state:e});if(!t?.pointer)return;let{sectionId:s,lineId:o}=t.pointer,a=xe({state:e},{sectionId:s});if(!(!a?.lines||!Array.isArray(a.lines)))return a.lines.find(r=>r.id===o)},jp=({state:e})=>{let{sectionId:t,lineId:s}=qe({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(c=>c.id===s),i=a.slice(0,r+1).map(c=>{let u=c.actions||{},p={};return Object.keys(u).forEach(d=>{p[d]=u[d]}),p});return Qr(i,{resources:e.projectData.resources})},Dp=e=>{let t=fn({state:e})?.actions?.dialogue;if(t?.clear===!0||!Array.isArray(t?.content))return"";let s=bt({variables:{...e.global?.variables??{},...Lr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1});return t.content.map(o=>`${vt(o?.text,{variables:s})??""}`).join("")},Ir=({state:e})=>Qo({text:Dp(e),baseDelay:nr(e,"autoForwardDelay"),speed:nr(e,"autoForwardSpeed")}),gw=({state:e})=>{let t=Tp({state:e}),o=fn({state:e})?.actions??{},a=Qr([t??{},o],{resources:e.projectData.resources});return po(t??{},a??{})},bw=({state:e},{sectionId:t})=>{let s=xe({state:e},{sectionId:t});if(!s?.lines)return[];let o=[],a={};for(let r of s.lines){let n=r.actions||{},i=Qr([a,n],{resources:e.projectData.resources}),l=po(a,i);o.push({id:r.id,changes:l,presentationState:i}),a=fo(i)}return o},ww=({state:e},{sectionId:t,includePresentationState:s=!1})=>{let o=bw({state:e},{sectionId:t});return s?{lines:o}:{lines:o.map(({presentationState:a,...r})=>r)}},Tp=({state:e})=>{let{sectionId:t,lineId:s}=qe({state:e}).pointer,a=xe({state:e},{sectionId:t})?.lines||[],r=a.findIndex(l=>l.id===s);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 fo(Qr(i,{resources:e.projectData.resources}))},ja=({state:e},{slotsPerPage:t=6}={})=>{let a=((_a({state:e}).saveLoadPagination??1)-1)*t+1,r=[];for(let n=0;n<t;n++){let i=a+n,l=e.global.saveSlots&&e.global.saveSlots[nt(i)]||{};r.push({...l,slotId:i})}return{saveSlots:r}},Iw=_p,vw=ja,Da=e=>{let s=e.contexts?.[e.contexts.length-1]?.rollback;return!s||!Array.isArray(s.timeline)||typeof s.currentIndex!="number"?!1:s.currentIndex>=0&&s.currentIndex<s.timeline.length-1},kw=({state:e},t={})=>{let s=jp({state:e}),o=Tp({state:e}),a=fn({state:e})?.actions??{},r=e.global.pendingScreenTransition,n=r?.animations?{...a,screen:q(r)}:a,i=r?.animations&&o===null?{}:o,{sectionId:l}=qe({state:e}).pointer,{sceneId:c}=wr(e.projectData,l),u={..._a({state:e}),localizationPackages:Np({state:e})},p=t?.activePersistentAnimations??[],d=t?.restoredPersistentAnimations??[],f=pn({state:e}),m=Cp({state:e}),g=Ep({state:e}),b=Sp({state:e}),y=Rp({state:e}),w=Na({state:e}),{saveSlots:h}=ja({state:e}),P=Da(e);return ku({presentationState:s,previousPresentationState:i,currentLineActions:n,resources:e.projectData.resources,currentSceneId:c,screen:e.projectData.screen,dialogueUIHidden:u.dialogueUIHidden,autoMode:u.autoMode,skipMode:u.skipMode,isChoiceVisible:m,isFormVisible:!!f,canRollback:of({state:e}),skipOnlyViewedLines:!u.skipUnseenText,isLineCompleted:u.isLineCompleted,skipTransitionsAndAnimations:!!u.skipTransitionsAndAnimations||P,overlayStack:e.global.overlayStack,confirmDialog:e.global.confirmDialog,form:f,dialogueHistory:Pp({state:e}),saveSlots:h,variables:w,runtime:u,activePersistentAnimations:p,restoredPersistentAnimations:d,imageGallery:g,musicRoom:b,sceneReplay:y,musicRoomPlayer:q(e.global.musicRoomPlayer),activeAudioEffects:t?.activeAudioEffects??[]})},Aw=({state:e},t)=>(e.global.confirmDialog=k0(t),e.global.pendingEffects.push({name:"render"}),e),Pw=({state:e})=>(e.global.confirmDialog&&($t(e),e.global.pendingEffects.push({name:"render"})),e),Ew=({state:e,rollbackActionBatchStack:t},s)=>(e.global.overlayStack.push(s),e.global.pendingEffects.push({name:"render"}),ir(e,"pushOverlay",s,t),e),xw=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack.pop(),e.global.pendingEffects.push({name:"render"}),ir(e,"popOverlay",void 0,t),e),Sw=({state:e,rollbackActionBatchStack:t},s)=>(e.global.overlayStack.length>0&&(e.global.overlayStack[e.global.overlayStack.length-1]=s),e.global.pendingEffects.push({name:"render"}),ir(e,"replaceLastOverlay",s,t),e),Ow=({state:e,rollbackActionBatchStack:t})=>(e.global.overlayStack=[],$t(e),Ct(e),e.global.pendingEffects.push({name:"render"}),ir(e,"clearOverlays",void 0,t),e),Rw=(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"})},mn=(e,t,{screenTransition:s}={})=>{e.global.isLineCompleted=!1,P0(e,s),Ct(e);let o=Se({state:e},{pointer:t}),a=o?.source===Ot,r=o?.source===Dr;Rw(e,{activeInteraction:o});let n=ye(e),i={name:"handleLineActions"};if(typeof n?.sceneReplay?.sceneId=="string"){let l=Wu(e);n.sceneReplay.entryId=l,i.payload={sceneReplaySceneId:n.sceneReplay.sceneId,entryId:l}}return e.global.pendingEffects.push(i),{isChoiceVisible:a,isFormVisible:r,activeInteraction:o}},As=(e,t,s)=>{!(t?.source===Ot||t?.source===Dr)||s||!e.global.skipMode||e.global.pendingEffects.push({name:"startSkipNextTimer"})},Lp=({state:e})=>(Se({state:e})||(e.global.skipMode&&(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"})),e.global.autoMode=!0,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.isLineCompleted&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e.global.pendingEffects.push({name:"render"})),e),dn=({state:e})=>(e.global.autoMode=!1,e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),$w=({state:e})=>{let t=e.global.autoMode;return Se({state:e})&&!t||(t?dn({state:e}):Lp({state:e})),e},Mp=({state:e})=>(Se({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),Tr=({state:e})=>(e.global.skipMode=!1,e.global.pendingEffects.push({name:"clearSkipNextTimer"}),e.global.pendingEffects.push({name:"render"}),e),Cw=({state:e})=>{let t=kp({state:e});return Se({state:e})&&!t||(t?Tr({state:e}):Mp({state:e})),e},Ps=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!1,e.global.pendingEffects.push({name:"render"}),ir(e,"showDialogueUI",void 0,t),e),Vp=({state:e,rollbackActionBatchStack:t})=>(e.global.dialogueUIHidden=!0,e.global.pendingEffects.push({name:"render"}),ir(e,"hideDialogueUI",void 0,t),e),_w=e=>{let{state:t}=e;return Ap({state:t})?Ps(e):Vp(e),t},Vr=(e,t,s)=>(va(e,t,s),bp(e),e.global.pendingEffects.push({name:"render"}),e),yn=(e,t,s,o,a)=>{let r=va(e,t,s);return e.global.pendingEffects.push({name:"render"}),ir(e,o,{value:r},a),e},Nw=({state:e},t)=>Vr(e,"dialogueTextSpeed",t?.value),jw=({state:e},t)=>(Vr(e,"autoForwardDelay",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e),Dw=({state:e},t)=>(Vr(e,"autoForwardSpeed",t?.value),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e),Tw=({state:e},t)=>Vr(e,"skipUnseenText",t?.value),Lw=({state:e},t)=>Vr(e,"skipTransitionsAndAnimations",t?.value),Mw=({state:e},t)=>Vr(e,"soundVolume",t?.value),Vw=({state:e},t)=>Vr(e,"musicVolume",t?.value),qw=({state:e},t)=>Vr(e,"muteAll",t?.value),sa=({state:e,rollbackActionBatchStack:t},s)=>yn(e,"saveLoadPagination",s?.value,"setSaveLoadPagination",t),ia=({state:e,rollbackActionBatchStack:t})=>{let s=nr(e,"saveLoadPagination")+1;return yn(e,"saveLoadPagination",s,"incrementSaveLoadPagination",t),e},oa=({state:e,rollbackActionBatchStack:t})=>{let s=nr(e,"saveLoadPagination")-1;return yn(e,"saveLoadPagination",s,"decrementSaveLoadPagination",t),e},aa=({state:e,rollbackActionBatchStack:t},s)=>yn(e,"menuPage",s?.value,"setMenuPage",t),la=({state:e,rollbackActionBatchStack:t},s)=>yn(e,"menuEntryPoint",s?.value,"setMenuEntryPoint",t),Fw=({state:e})=>(e.global.pendingEffects=[],e),Bw=({state:e},t)=>(e.global.pendingEffects.push(t),e),Uw=({state:e},t)=>{if(ye(e))return e;let s=t?.resourceId;return Ju(e,s),e.global.pendingEffects.push({name:"completeAchievement",payload:{resourceId:s}}),e},Yw=({state:e},t)=>{if(ye(e))return e;let s=t?.resourceId,o=Ju(e,s);if(o.type!=="number")throw new Error(`Achievement resource "${s}" does not support numeric progress`);let a=t?.current;if(!Number.isInteger(a)||a<0)throw new Error(`Achievement progress for "${s}" must be a non-negative integer`);if(!Number.isInteger(o.target)||o.target<1)throw new Error(`Achievement resource "${s}" must have a positive integer target`);let r=Math.min(a,o.target);return e.global.pendingEffects.push({name:"setAchievementProgress",payload:{resourceId:s,current:r,target:o.target,completed:r>=o.target}}),e},qp=e=>e?.lines?.[0],Fp=(e,{sectionId:t,resetStoryState:s=!1,screen:o})=>{let a=!!fp(o),r=xe({state:e},{sectionId:t});if(!r)return console.warn(`Section not found: ${t}`),e;let n=qp(r);if(!n)return console.warn(`Section ${t} has no lines`),e;if(s&&!M0(e,{queueRender:!a}))return e;let i=Se({state:e});s&&e.global.skipMode&&Tr({state:e});let l=e.contexts?.[e.contexts.length-1];if(l){let u=_t(l),p=u.read;s||tt(e,{sectionId:p?.sectionId,lineId:p?.lineId}),l.rollback||Mr(l,{compatibilityAnchor:!0}),u.read={sectionId:t,lineId:n.id},s?l.rollback=ln({pointer:u.read}):ks(e,{sectionId:t,lineId:n.id})}let{activeInteraction:c}=mn(e,l?.pointers?.read,{screenTransition:o});return As(e,i,c),e},zw=({state:e},t)=>{if(ye(e))throw new Error("Cannot reset the story while a scene replay is active");return Fp(e,{sectionId:t?.sectionId,resetStoryState:!0,screen:t?.screen})},Bp=e=>(e.global.accountViewedRegistry=Jb(e.global.accountViewedRegistry),e.global.accountViewedRegistry),Es=(e,t)=>{!Array.isArray(t)||t.length===0||e.global.pendingEffects.push({name:"applyScopedDataUpdates",payload:{updates:t.map(s=>({scope:s.scope,path:s.path,op:s.op,value:q(s.value)}))}})},Up=(e,t)=>{Es(e,[{scope:"account",path:"viewedRegistry",op:"markViewed",value:{sections:(Array.isArray(t?.sections)?t.sections:[]).map(s=>({sectionId:s.sectionId,...s.lastLineId===void 0?{}:{lineId:s.lastLineId}})),resources:Array.isArray(t?.resources)?t.resources:[]}}])},Xw=(e,t,{sectionId:s,lineId:o})=>{if(!s||!o)return!1;let a=V(t)?t:{};Array.isArray(a.sections)||(a.sections=[]);let r=a.sections.find(n=>n.sectionId===s);if(r){if(r.lastLineId===void 0)return!1;let n=xe({state:e},{sectionId:s});if(n?.lines){let i=n.lines.findIndex(c=>c.id===r.lastLineId),l=n.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:s,lastLineId:o}),!0},tt=(e,t)=>{if(ye(e)||e.global.accountViewedRegistry===void 0)return;Xw(e,Bp(e),t)&&Up(e,{sections:[{sectionId:t.sectionId,lastLineId:t.lineId}],resources:[]})},Gw=({state:e},t)=>(tt(e,t),e.global.pendingEffects.push({name:"render"}),e),Hw=({state:e},t)=>{if(ye(e))return e;let{resourceId:s}=t;if(e.global.accountViewedRegistry!==void 0){let o=Bp(e);o.resources.find(r=>r.resourceId===s)||(o.resources.push({resourceId:s}),Up(e,{sections:[],resources:[{resourceId:s}]}))}return e.global.pendingEffects.push({name:"render"}),e},or=(e,t,s)=>{if(!V(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!s.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},ca=(e,t,s)=>{if(typeof s!="string"||s.length===0)throw new Error(`${e} requires a non-empty ${t}`)},xs=(e,t)=>{let s=e.global.imageGalleryNavigation;s.groupId===t.groupId&&s.variantId===t.variantId&&s.pageIndex===t.pageIndex||(e.global.imageGalleryNavigation=t,e.global.pendingEffects.push({name:"render"}))},Kw=({state:e},t)=>{let s="showImageGalleryVariant";or(s,t,Yb),ca(s,"groupId",t.groupId),Object.prototype.hasOwnProperty.call(t,"variantId")&&ca(s,"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 n=t.variantId===void 0?r.variants[0]:r.variants.find(i=>i.id===t.variantId);return!n||an(e,n)||xs(e,{groupId:r.id,variantId:n.id,pageIndex:Math.floor(a/o.pageSize)}),e},Yp=(e,t,s,o)=>{or(o,t,pa);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 n=a.groups.find(c=>c.id===r.groupId),i=n?.variants.findIndex(c=>c.id===r.variantId);if(!n||i===void 0||i<0)return e;let l=ta(e,n.variants,i,s);return l&&xs(e,{...r,variantId:l.id}),e},Ww=({state:e},t)=>Yp(e,t,-1,"moveToPreviousImageGalleryVariant"),Jw=({state:e},t)=>Yp(e,t,1,"moveToNextImageGalleryVariant"),Qw=({state:e},t)=>{if(or("clearImageGallerySelection",t,pa),e.projectData?.resources?.imageGallery===void 0)return e;let o=e.global.imageGalleryNavigation;return xs(e,{groupId:null,variantId:null,pageIndex:o.pageIndex}),e},zp=(e,t)=>{let s=e.projectData?.resources?.imageGallery;if(s===void 0)return e;let o=Ea(s);if(t>=o)return e;let a=e.global.imageGalleryNavigation,r=xa(s,a);return t===r||xs(e,{groupId:null,variantId:null,pageIndex:t}),e},Zw=({state:e},t)=>{if(or("moveToImageGalleryPage",t,zb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToImageGalleryPage requires a non-negative integer pageIndex");return zp(e,t.pageIndex)},Xp=(e,t,s,o)=>{or(o,t,pa);let a=e.projectData?.resources?.imageGallery;if(a===void 0)return e;let n=xa(a,e.global.imageGalleryNavigation)+s;return n<0?e:zp(e,n)},eI=({state:e},t)=>Xp(e,t,1,"moveToNextImageGalleryPage"),rI=({state:e},t)=>Xp(e,t,-1,"moveToPreviousImageGalleryPage"),vr=(e,t,s)=>{if(!V(t))throw new Error(`${e} payload must be an object`);Object.keys(t).forEach(o=>{if(!s.has(o))throw new Error(`${e} payload contains unsupported property "${o}"`)})},tI=(e,t)=>{if(typeof t!="string"||t.length===0)throw new Error(`${e} requires a non-empty trackId`)},er=e=>{e.global.pendingEffects.push({name:"render"})},Gp=(e,t)=>{let s=e.projectData.resources.musicRoom,o=e.global.musicRoomPlayer,a=o.trackId!==null,r=o.trackId===t.id,n=o.bgmPlayback;a||(n={commandId:vs(e),operation:"pause"});let i=un(e,"play",0),l=s.tracks.indexOf(t),c=r?o.durationMs:null;e.global.musicRoomPlayer={trackId:t.id,pageIndex:Math.floor(l/s.pageSize),status:"playing",readiness:c===null?"loading":"ready",positionMs:0,durationMs:c,playback:i,seekFallback:null,bgmPlayback:n},er(e)},nI=({state:e},t)=>{let s="playMusicRoomTrack";vr(s,t,Xb),tI(s,t.trackId);let a=e.projectData?.resources?.musicRoom?.tracks.find(r=>r.id===t.trackId);return!a||Sa(e,a)||Gp(e,a),e},sI=({state:e},t)=>{vr("playMusicRoom",t,Rt);let o=e.global.musicRoomPlayer;if(o.trackId===null||o.status==="playing")return e;let a=o.status==="ended",r=o.readiness==="error",n=o.status==="paused"&&!r?"resume":"play",i=a?0:o.positionMs;return o.playback=un(e,n,n==="play"?i:void 0),o.seekFallback=null,o.status="playing",o.positionMs=i,r&&(o.readiness=o.durationMs===null?"loading":"ready"),er(e),e},iI=({state:e},t)=>{vr("pauseMusicRoom",t,Rt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status!=="playing"||(o.playback=un(e,"pause"),o.seekFallback=null,o.status="paused",er(e)),e},oI=({state:e},t)=>{vr("stopMusicRoom",t,Rt);let o=e.global.musicRoomPlayer;return o.trackId===null||o.status==="stopped"&&o.positionMs===0||(o.playback=un(e,"stop"),o.seekFallback=null,o.status="stopped",o.positionMs=0,er(e)),e},aI=({state:e},t)=>{if(vr("seekMusicRoom",t,Gb),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=un(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"),er(e),e},Hp=(e,t,s,o)=>{vr(o,t,Rt);let a=e.projectData?.resources?.musicRoom,r=e.global.musicRoomPlayer;if(!a||r.trackId===null)return e;let n=a.tracks.findIndex(l=>l.id===r.trackId);if(n<0)return e;let i=na(e,a.tracks,n,s);return i&&Gp(e,i),e},lI=({state:e},t)=>Hp(e,t,-1,"playPreviousMusicRoomTrack"),cI=({state:e},t)=>Hp(e,t,1,"playNextMusicRoomTrack"),uI=({state:e},t)=>{vr("clearMusicRoomSelection",t,Rt);let o=e.global.musicRoomPlayer;if(o.trackId===null)return e;let a=o.pageIndex,r={commandId:vs(e),operation:"resume"};return e.global.musicRoomPlayer={...Is({bgmPlayback:r}),pageIndex:a},er(e),e},Kp=(e,t)=>{let s=e.projectData?.resources?.musicRoom;if(!s||t>=Oa(s))return e;let o=e.global.musicRoomPlayer,a=Ra(s,o);return t===a||(o.pageIndex=t,er(e)),e},pI=({state:e},t)=>{if(vr("moveToMusicRoomPage",t,Hb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToMusicRoomPage requires a non-negative integer pageIndex");return Kp(e,t.pageIndex)},Wp=(e,t,s,o)=>{vr(o,t,Rt);let a=e.projectData?.resources?.musicRoom;if(!a)return e;let r=Ra(a,e.global.musicRoomPlayer)+s;return r<0?e:Kp(e,r)},fI=({state:e},t)=>Wp(e,t,1,"moveToNextMusicRoomPage"),mI=({state:e},t)=>Wp(e,t,-1,"moveToPreviousMusicRoomPage"),rt=e=>{let t=ye(e);if(!t)return!1;if(e.contexts.length<2)throw new Error("Scene replay context has no caller context to restore");let s=q(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(),D0(e,s),e.global.pendingEffects.push({name:"render"}),!0},dI=({state:e},t)=>{let s="startSceneReplay";if(or(s,t,Kb),ca(s,"sceneId",t.sceneId),ye(e))throw new Error("Cannot start a scene replay while another replay is active");let a=e.projectData?.resources?.sceneReplay?.replays.find(p=>p.sceneId===t.sceneId);if(!a||!Op(e,a.sceneId))return e;let r=e.projectData.story.scenes[a.sceneId],n=r?.initialSectionId,i=r?.sections?.[n],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=N0(e);j0(e);let u=ka({pointer:{sceneId:a.sceneId,sectionId:n,lineId:l},projectData:e.projectData,kind:"sceneReplay",sceneReplay:{sceneId:a.sceneId,entryId:0,finishOnNextAdvance:!1,exitOnLineCompleted:!1,returnState:c}});return gp(e,u),e.contexts.push(u),mn(e,u.pointers.read),e},Jp=({state:e},t)=>{or("finishSceneReplay",t,fa);let o=ye(e);if(o)return o.sceneReplay.finishOnNextAdvance=!0,e;if(Lr(e)?.rollback?.isRestoring===!0)return e;let r=qe({state:e})?.pointer,{sceneId:n}=wr(e.projectData,r?.sectionId);return!(typeof n=="string"&&e.projectData?.resources?.sceneReplay?.replays?.some(l=>l.sceneId===n))||(e.global.accountReplayRegistry=Qb(e.global.accountReplayRegistry),e.global.accountReplayRegistry.sceneIds.includes(n))||(e.global.accountReplayRegistry.sceneIds.push(n),Es(e,[{scope:"account",path:"replayRegistry",op:"unlock",value:{sceneIds:[n]}}]),e.global.pendingEffects.push({name:"render"})),e},yI=({state:e},t)=>(or("exitSceneReplay",t,fa),rt(e),e),Qp=(e,t)=>{let s=e.projectData?.resources?.sceneReplay;if(!s||t>=$a(s))return e;let o=Ca(s,e.global.sceneReplayNavigation);return t===o||(e.global.sceneReplayNavigation.pageIndex=t,e.global.pendingEffects.push({name:"render"})),e},hI=({state:e},t)=>{if(or("moveToSceneReplayPage",t,Wb),!Number.isInteger(t.pageIndex)||t.pageIndex<0)throw new Error("moveToSceneReplayPage requires a non-negative integer pageIndex");return Qp(e,t.pageIndex)},Zp=(e,t,s,o)=>{or(o,t,fa);let a=e.projectData?.resources?.sceneReplay;if(!a)return e;let r=Ca(a,e.global.sceneReplayNavigation)+s;return r<0?e:Qp(e,r)},gI=({state:e},t)=>Zp(e,t,1,"moveToNextSceneReplayPage"),bI=({state:e},t)=>Zp(e,t,-1,"moveToPreviousSceneReplayPage"),Ss=(e,t)=>{let s=e.global.musicRoomPlayer;return!V(t)||t.id!==Bb||s.trackId===null||!s.playback||t.commandId!==s.playback.commandId?null:s},Ta=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,ef=(e,t,s,{readiness:o=t.readiness}={})=>((t.readiness!==o||t.positionMs!==s.positionMs||t.durationMs!==s.durationMs||t.seekFallback!==null)&&(t.readiness=o,t.positionMs=s.positionMs,t.durationMs=s.durationMs,t.seekFallback=null,er(e)),e),wI=({state:e},t)=>{let s=Ss(e,t);return!s||s.readiness!=="loading"||!Ta(t)?e:ef(e,s,t,{readiness:"ready"})},II=({state:e},t)=>{let s=Ss(e,t);return!s||s.readiness!=="ready"||!Ta(t)||s.status==="stopped"&&t.positionMs!==0||s.status==="ended"&&t.positionMs!==t.durationMs?e:ef(e,s,t)},vI=({state:e},t)=>{let s=Ss(e,t);return!s||s.readiness!=="ready"||s.status!=="playing"||!Ta(t)||t.positionMs!==t.durationMs||(s.status="ended",s.positionMs=t.positionMs,s.durationMs=t.durationMs,s.seekFallback=null,er(e)),e},kI=({state:e},t)=>{let s=Ss(e,t);if(!s||typeof t.errorCode!="string"||!Ub.has(t.errorCode)||s.readiness==="error"&&s.status==="stopped")return e;if(t.errorCode==="invalid-position"){let o=s.seekFallback;if(s.playback.operation!=="seek"||o?.commandId!==t.commandId)return e;let a=s.status!==o.status||s.positionMs!==o.positionMs;return s.status=o.status,s.positionMs=o.positionMs,s.seekFallback=null,a&&er(e),e}return s.readiness="error",s.status="stopped",s.positionMs=0,s.seekFallback=null,er(e),e},rf=({state:e,rollbackActionBatchStack:t},s)=>{let o=s0(s.manual),{auto:a,applyMode:r}=s,n=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,d=e.global.nextLineConfig.auto?.trigger,f=e.global.nextLineConfig.auto?.delay,m=Se({state:e});return!u&&(a!==void 0&&(p!==n||d!==i||f!==l))&&(!m&&p===!0&&(d==="fromStart"||e.global.isLineCompleted)?e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:f}}):n===!0&&e.global.pendingEffects.push({name:"clearNextLineConfigTimer"})),e.global.pendingEffects.push({name:"render"}),ir(e,"setNextLineConfig",s,t),e},AI=({state:e},t)=>{if(ye(e))throw new Error("Cannot save while a scene replay is active");let s=t?.slotId;Qu(s,"saveSlot");let{thumbnailImage:o}=t,a=t?.savedAt,r=nt(s),n=q(e.contexts);n?.forEach(c=>{_t(c),wp(c.rollback),c0(c.rollback,e.projectData)});let i={contexts:n},l={formatVersion:Ku,slotId:np(s),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},PI=({state:e},t)=>{if(ye(e))throw new Error("Cannot load while a scene replay is active");let s=t?.slotId;Qu(s,"loadSlot");let o=nt(s),a=Object.prototype.hasOwnProperty.call(e.global.saveSlots??{},o)?e.global.saveSlots[o]:void 0;if(a){let r=v0(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=cn(),e.global.overlayStack=[],e.global.isLineCompleted=!0,$t(e),Ct(e),ya(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"},{name:"clearSkipNextTimer"},{name:"clearNextLineConfigTimer"},{name:"render"})}return e},EI=({state:e},t)=>{if(ye(e))throw new Error("Cannot update project data while a scene replay is active");let{projectData:s}=t;tp(s),Yt(s),zt(s),Xt(s),Wr(s?.resources?.variables??{}),ko(s);let o=m0(s),a=o?e.contexts?.map((n,i)=>pp(q(n),s,i)):void 0,r=o?u0(e.global.saveSlots,s):void 0;if(e.projectData=s,e.global.imageGalleryNavigation=ua(),e.global.sceneReplayNavigation=ma(),ya(e),o){let n=s?.resources?.variables??{},{globalVariablesDefaultValues:i}=Wn(s??{});Object.prototype.hasOwnProperty.call(e.global??{},"variables")&&(e.global.variables={...i,...Gt(e.global.variables,n,{allowedScopes:["device","account"]})}),e.contexts=a,e.global.saveSlots=r}return $t(e),Ct(e),o&&Object.keys(e.global.saveSlots??{}).length>0&&e.global.pendingEffects.push({name:"saveSlots",payload:{saveSlots:{...e.global.saveSlots}}}),e.global.pendingEffects.push({name:"render"}),e},xI=({state:e},t)=>{let{l10nId:s,projectData:o}=t??{};if(s!==null&&(typeof s!="string"||s.length===0))throw new Error("updateLocalizationPackage requires l10nId or null");if(!V(o))throw new Error("updateLocalizationPackage requires resolved projectData internally");return e.projectData=o,va(e,"localizationPackageId",s),bp(e),e.global.pendingEffects.push({name:"clearAutoNextTimer"}),e.global.autoMode&&e.global.isLineCompleted&&!Se({state:e})&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e.global.pendingEffects.push({name:"render"}),e},SI=({state:e},t)=>{let{sectionId:s,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=s||a.pointers.read?.sectionId;if(s&&!xe({state:e},{sectionId:s}))return console.warn(`Section not found: ${s}`),e;let n=xe({state:e},{sectionId:r});if(!n?.lines||!Array.isArray(n.lines))return console.warn(`Section ${r} has no lines`),e;if(!n.lines.find(p=>p.id===o))return console.warn(`Line not found: ${o} in section ${r}`),e;let l=Se({state:e}),c=_t(a);c.read={sectionId:r,lineId:o};let{activeInteraction:u}=mn(e,c.read);return As(e,l,u),e},OI=({state:e,rollbackActionBatchStack:t},s)=>{if(!e.global.nextLineConfig.manual.enabled)return e;if(e.global.dialogueUIHidden)return Ps({state:e,rollbackActionBatchStack:t}),e;let o=Se({state:e});if(o?.source===Ot&&s?.bypassChoice!==!0||o?.source===Dr&&s?._interactionSource!==Dr)return e;if(!e.global.isLineCompleted){if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return rt(e),e;let f=qe({state:e})?.pointer,m=f?.sectionId,g=f?.lineId;m&&g&&tt(e,{sectionId:m,lineId:g}),e.global.pendingEffects.push({name:"clearNextLineConfigTimer"}),e.global.autoMode&&!o&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}});let b=e.global.nextLineConfig,y=xe({state:e},{sectionId:m});return Array.isArray(y?.lines)&&y.lines.at(-1)?.id===g?ea(e):b?.auto?.enabled&&!o&&b.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:b.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e}if(ye(e)?.sceneReplay.finishOnNextAdvance)return rt(e),e;let r=qe({state:e})?.pointer,n=r?.sectionId,i=xe({state:e},{sectionId:n}),l=e.contexts[e.contexts.length-1],c=i?.lines||[],p=c.findIndex(d=>d.id===r?.lineId)+1;if(p<c.length){let d=c[p],f=!nr(e,"skipUnseenText");if(e.global.skipMode&&f&&!Pa({state:e},{sectionId:n,lineId:d.id}))return Tr({state:e}),e;if(l&&!l.rollback&&Mr(l,{compatibilityAnchor:!0}),l){let g=_t(l),b=g.read?.lineId;b&&n&&tt(e,{sectionId:n,lineId:b}),g.read={sectionId:n,lineId:d.id}}ks(e,{sectionId:n,lineId:d.id}),da(e);let{activeInteraction:m}=mn(e,{sectionId:n,lineId:d.id});As(e,o,m)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),rt(e),e;e.global.autoMode&&dn({state:e}),e.global.skipMode&&Tr({state:e}),ea(e)}return e},RI=({state:e})=>{if(e.global.isLineCompleted)return e;if(e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition,ye(e)?.sceneReplay.exitOnLineCompleted)return rt(e),e;let s=Se({state:e});e.global.autoMode&&!s&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}});let o=qe({state:e})?.pointer,a=o?.sectionId,r=o?.lineId;a&&r&&tt(e,{sectionId:a,lineId:r});let n=e.global.nextLineConfig;return n?.auto?.enabled&&!s&&n.auto.trigger!=="fromStart"&&e.global.pendingEffects.push({name:"nextLineConfigTimer",payload:{delay:n.auto.delay}}),e.global.pendingEffects.push({name:"render"}),e},$I=({state:e},t)=>Fp(e,{sectionId:t?.sectionId,screen:t?.screen}),CI=({state:e,rollbackActionBatchStack:t},s)=>{let o=s?._conditionalContinuation===!0;if(e.global.dialogueUIHidden&&!o)return Ps({state:e,rollbackActionBatchStack:t}),e.global.autoMode&&e.global.pendingEffects.push({name:"startAutoNextTimer",payload:{delay:Ir({state:e})}}),e;let a=Se({state:e});if(a?.source===Ot&&s?.bypassChoice!==!0||a?.source===Dr&&s?._interactionSource!==Dr||a&&a.source!==Ot&&a.source!==Dr)return e;let r=ye(e);if(r?.sceneReplay.finishOnNextAdvance)return e.global.isLineCompleted?(rt(e),e):(r.sceneReplay.exitOnLineCompleted=!0,e);let n=qe({state:e})?.pointer,i=n?.sectionId,l=xe({state:e},{sectionId:i}),c=e.contexts[e.contexts.length-1],u=l?.lines||[],d=u.findIndex(f=>f.id===n?.lineId)+1;if(d<u.length){let f=u[d],m=!nr(e,"skipUnseenText");if(e.global.skipMode&&m&&!Pa({state:e},{sectionId:i,lineId:f.id})&&(Tr({state:e}),!o))return e;if(c&&!c.rollback&&Mr(c,{compatibilityAnchor:!0}),c){let b=_t(c),y=b.read?.lineId;y&&i&&tt(e,{sectionId:i,lineId:y}),b.read={sectionId:i,lineId:f.id}}ks(e,{sectionId:i,lineId:f.id}),da(e);let{activeInteraction:g}=mn(e,{sectionId:i,lineId:f.id});As(e,a,g)}else{if(ye(e))return console.warn("Scene replay reached the end of a section without finishSceneReplay; exiting replay."),rt(e),e;e.global.autoMode&&dn({state:e}),e.global.skipMode&&Tr({state:e}),ea(e)}return e},La=(e,t={})=>{let s=pn({state:e});return!s||t.formKey&&t.formKey!==s.key||t.formId&&t.formId!==s.id?null:s},_I=(e,t)=>{if(!t.variableId)throw new Error(`form field "${t.id}" requires variableId`);let s=e.projectData.resources?.variables?.[t.variableId],o=s?.scope,a=s?.type;if(_e(s))throw new Error(`Cannot update computed variable: ${t.variableId}`);if(s?.readonly===!0)throw new Error(`Cannot update readonly variable: ${t.variableId}`);if(Ht(o,t.variableId),Kt(a,"set",t.variableId),ye(e)&&o!=="context")throw new Error(`Cannot update ${o}-scoped variable "${t.variableId}" while a scene replay is active`);return{variableConfig:s,scope:o}},NI=(e,t)=>({id:e.id,key:e.key,valid:!0,values:q(t),fields:q(e.fields),fieldList:q(e.fieldList)}),jI=e=>{if(e.global.isLineCompleted)return;e.global.isLineCompleted=!0,delete e.global.pendingScreenTransition;let t=qe({state:e})?.pointer,s=t?.sectionId,o=t?.lineId;s&&o&&tt(e,{sectionId:s,lineId:o})},DI=({state:e},t={})=>{let s=La(e,t),o=t.field;if(!s?.fields?.[o])return e;let a=dp(e,s.key),r=bs(t.value),n=s.fields[o],i=wa(n,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},TI=({state:e,rollbackActionBatchStack:t},s={})=>{let o=La(e,s);if(!o)return{submitted:!1,valid:!1,reason:"inactive"};let a=dp(e,o.key);a.submitted=!0;let r={},n={};if(Object.entries(o.fields).forEach(([d,f])=>{let m=Object.prototype.hasOwnProperty.call(a.values,d)?a.values[d]:f.value,g=wa(f,m);a.touched[d]=!0,g&&(n[d]=g),r[d]=mp(f,m)}),a.errors=n,Object.keys(n).length>0)return e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!1,errors:q(n),form:{id:o.id,key:o.key,values:q(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(([d,f])=>{let{scope:m}=_I(e,f),g=m==="context"?i.variables:e.global.variables,b=r[d];g[f.variableId]=Qn(g[f.variableId],"set",b),m==="context"&&(l=!0,u.push({variableId:f.variableId,op:"set",value:b})),(m==="device"||m==="account")&&c.push({scope:m,path:`variables.${f.variableId}`,op:"set",value:q(g[f.variableId])})}),l&&ir(e,"updateVariable",{id:"submitForm",operations:u},t),Es(e,c);let p=NI(o,r);return jI(e),delete e.global.formDrafts[o.key],e.global.pendingEffects.push({name:"render"}),{submitted:!0,valid:!0,form:p}},LI=({state:e},t={})=>{let s=La(e,t);return s?(delete e.global.formDrafts?.[s.key],e.global.pendingEffects.push({name:"render"}),{cancelled:!0,form:{id:s.id,key:s.key,values:q(s.values),fields:q(s.fields),fieldList:q(s.fieldList)}}):{cancelled:!1,reason:"inactive"}},MI=({state:e,rollbackActionBatchStack:t},s)=>{let{id:o,operations:a=[]}=s;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 n=!1,i=[],l=[];return a.forEach(({variableId:c,op:u,value:p,roundTo:d})=>{let f=e.projectData.resources?.variables?.[c],m=f?.scope,g=f?.type;if(_e(f))throw new Error(`Cannot update computed variable: ${c}`);if(f?.readonly===!0)throw new Error(`Cannot update readonly variable: ${c}`);if(Ht(m,c),Kt(g,u,c),Jn(g,u,p,c,{roundTo:d}),ye(e)&&m!=="context")throw new Error(`Cannot update ${m}-scoped variable "${c}" while a scene replay is active`);let b=m==="context"?r.variables:e.global.variables;if(m==="context"){n=!0;let y={variableId:c,op:u,value:p};d!==void 0&&(y.roundTo=d),l.push(y)}b[c]=Qn(b[c],u,p,{roundTo:d}),(m==="device"||m==="account")&&i.push({scope:m,path:`variables.${c}`,op:"set",value:q(b[c])})}),n&&ir(e,"updateVariable",{id:o,operations:l},t),Es(e,i),e.global.pendingEffects.push({name:"render"}),e},He=e=>(t,s)=>e({state:t},s),tf=e=>({variables:bt({variables:{...e.global?.variables??{},...Lr(e)?.variables??{}},runtime:Cr(e),variableConfigs:e.projectData.resources?.variables??{},eager:!1}),runtime:Cr(e)}),VI=e=>{if(!V(e))throw new Error("conditional action payload must be an object");if(!Array.isArray(e.branches))throw new Error("conditional action requires branches array");if(e.branches.length===0)throw new Error("conditional action requires at least one branch")},qI=(e,t,s)=>{if(!V(e))throw new Error(`conditional branch at index ${t} must be an object`);if(!V(e.actions))throw new Error(`conditional branch at index ${t} requires actions object`);if(!Object.prototype.hasOwnProperty.call(e,"when")&&t!==s-1)throw new Error("conditional else branch must be the last branch")},FI=(e,t,s,o)=>{VI(t);for(let a=0;a<t.branches.length;a+=1){let r=t.branches[a];if(qI(r,a,t.branches.length),!(Object.prototype.hasOwnProperty.call(r,"when")&&!Ut(r.when,{...tf(e),...s?.bindings??{}}))){Ma(e,r.actions,s,[...o,"branches",String(a),"actions"]);return}}},BI=(e,t,s,o)=>{let a=s?.checkpoint;if(a?.randomOutcomeVersion!==br)return;let r=o.join("."),n=s.randomOutcomeOrdinals,i=n.get(r)??0;n.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=rs(q(l.result),l.type);if(c.type==="integer"){if(!op(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}`);ra(e,{id:"randomResult",operations:[{variableId:t.variableId,op:"set",value:c.value}]});return}let u=t.distribution.outcomes?.[c.outcomeIndex]?.actions;if(!V(u))throw new Error(`recorded random outcome does not match canonical action at ${r}`);Ma(e,u,s,[...o,"distribution","outcomes",String(c.outcomeIndex),"actions"])},UI={conditional:{replayLine:FI},random:{replayLine:BI},updateVariable:{recordSources:[jr],replayLine:ra,replayRecorded:ra,persistInSaveSlot:!0},setNextLineConfig:{replayLine:He(rf)},setSaveLoadPagination:{recordSources:[jr],replayLine:He(sa),replayRecorded:He(sa),persistInSaveSlot:!0},incrementSaveLoadPagination:{recordSources:[jr],replayLine:He(ia),replayRecorded:He(ia),persistInSaveSlot:!0},decrementSaveLoadPagination:{recordSources:[jr],replayLine:He(oa),replayRecorded:He(oa),persistInSaveSlot:!0},setMenuPage:{recordSources:[jr],replayLine:He(aa),replayRecorded:He(aa),persistInSaveSlot:!0},setMenuEntryPoint:{recordSources:[jr],replayLine:He(la),replayRecorded:He(la),persistInSaveSlot:!0},finishSceneReplay:{replayLine:He(Jp)}},Os=e=>UI[e]??null,YI=e=>Os(e)?.persistInSaveSlot===!0,zI=(e,t)=>{let s=Os(e)?.recordSources;return Array.isArray(s)&&s.includes(t)},XI=(e,t,s)=>{Os(t)?.replayRecorded?.(e,s)},GI=(e,t,s,o,a)=>{let r=Os(t);if(!r?.replayLine)return;if(t==="conditional"||t==="random"){r.replayLine(e,s,o,a);return}let n=o?.bindings??{},i=Wt({[t]:s},{...tf(e),...n})[t];r.replayLine(e,i)},Ma=(e,t,s,o)=>{let a=ts(t);ss(a);for(let[r,n]of a)GI(e,r,n,s,[...o,r])},HI=e=>e?.returnable!==!1,nf=(e,t)=>{if(t>=0)return e.currentIndex+t;let s=Math.abs(t);for(let o=e.currentIndex-1;o>=0;o-=1)if(HI(e.timeline[o])&&(s-=1,s===0))return o;return-1},sf=({state:e},t)=>{let{offset:s}=t;if(s===void 0||typeof s!="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=nf(a,s);if(r<0||r>=a.timeline.length)return null;let n=a.timeline[r];return{sectionId:n.sectionId,lineId:n.lineId}},of=({state:e})=>sf({state:e},{offset:-1})!==null,KI=({state:e},t)=>{let{offset:s=-1}=t;if(s>=0)throw new Error("rollbackByOffset requires a negative offset");let o=e.contexts?.[e.contexts.length-1];if(!o)return e;let a=Mr(o,{compatibilityAnchor:!o.rollback}),r=nf(a,s);return r<0||r>=a.timeline.length?e:vp(e,r)},WI=({state:e},t)=>{let{sectionId:s,lineId:o}=t,a=e.contexts[e.contexts.length-1];if(!a)throw new Error("No context available for rollbackToLine");let r=Mr(a,{compatibilityAnchor:!a.rollback}),i=r.timeline.slice(0,r.currentIndex+1).findLastIndex(l=>l.sectionId===s&&l.lineId===o);if(i===-1)throw new Error(`Line ${o} not found in section ${s} rollback timeline`);return i===r.currentIndex?e:vp(e,i)},JI=()=>({lineEntryId:1,rollbackCheckpointLineEntryId:1,autoSessionId:0,skipSessionId:0,rollbackAuthoredSuppression:null}),Zo=(e,t)=>{let s=e[t];if(!Number.isSafeInteger(s)||s<0)throw new RangeError(`Internal playback ${t} is invalid`);if(s===Number.MAX_SAFE_INTEGER)throw new RangeError(`Internal playback ${t} is exhausted`);return e[t]=s+1,e[t]},Gu=e=>e.contexts?.[e.contexts.length-1]?.pointers?.read??null,Hu=e=>{let t=e.contexts?.[e.contexts.length-1];return Number.isInteger(t?.rollback?.currentIndex)?t.rollback.currentIndex:null},QI=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,af=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}},Va=e=>JSON.stringify(af(e)),ZI=({actionName:e,args:t,state:s,previousState:o})=>{let a=Gu(o),r=Gu(s);if(!QI(a,r)||o.contexts?.length!==s.contexts?.length||(e==="rollbackByOffset"||e==="rollbackToLine")&&Hu(o)!==Hu(s))return!0;let n=t[0]??{};if(e==="jumpToLine"){let i=n.sectionId??a?.sectionId;return typeof n.lineId=="string"&&r?.sectionId===i&&r?.lineId===n.lineId&&s.global.isLineCompleted===!1}if(e==="sectionTransition"||e==="resetStoryAtSection"){let i=wr(s.projectData,n.sectionId).section,l=qp(i)?.id;return typeof l=="string"&&r?.sectionId===n.sectionId&&r?.lineId===l&&s.global.isLineCompleted===!1}if(e==="loadSlot"){let i=n.slotId;return Object.prototype.hasOwnProperty.call(o.global?.saveSlots??{},nt(i))}return!1},ev=({actionName:e,args:t,state:s,transactionalMetadata:o,previousState:a})=>{if(ZI({actionName:e,args:t,state:s,previousState:a})){let u=Zo(o,"lineEntryId");e==="rollbackByOffset"||e==="rollbackToLine"?o.rollbackAuthoredSuppression={lineEntryId:u,configKey:Va(s)}:o.rollbackAuthoredSuppression=null,o.rollbackCheckpointLineEntryId=e==="jumpToLine"?null:u}let n=(a.contexts?.length??0)>(s.contexts?.length??0),i=e==="startAutoMode"||e==="startSkipMode"?Se({state:a}):null;s.global.autoMode===!0&&(e==="startAutoMode"&&!i||e==="toggleAutoMode"&&a.global.autoMode!==!0||n&&a.global.autoMode!==!0)&&Zo(o,"autoSessionId"),s.global.skipMode===!0&&(e==="startSkipMode"&&!i||e==="toggleSkipMode"&&a.global.skipMode!==!0||n&&a.global.skipMode!==!0)&&Zo(o,"skipSessionId")},rv=({state:e,transactionalMetadata:t})=>{let s=t.rollbackAuthoredSuppression;s&&(s.lineEntryId!==t.lineEntryId||s.configKey!==Va(e))&&(t.rollbackAuthoredSuppression=null)},tv=({state:e,playbackOwnership:t})=>{let s=Se({state:e}),o=t.lineEntryId,a=!s&&e.global.autoMode===!0&&e.global.isLineCompleted===!0,r=!s&&e.global.skipMode===!0,n=af(e),i=t.rollbackAuthoredSuppression,l=!s&&n.enabled&&(n.trigger==="fromStart"||e.global.isLineCompleted===!0)&&!(i?.lineEntryId===o&&i.configKey===Va(e)),c=a?Dp(e):null;return{auto:a?{owner:{sessionId:t.autoSessionId,lineEntryId:o},delayMs:Qo({text:c,baseDelay:nr(e,"autoForwardDelay"),speed:nr(e,"autoForwardSpeed")}),contentKey:c}:null,skip:r?{owner:{sessionId:t.skipSessionId},delayMs:80}:null,authored:l?{owner:{lineEntryId:o},delayMs:n.delayMs,trigger:n.trigger}:null}},nv=({playbackOwnership:e})=>e.lineEntryId,lf=(e,t={})=>{let s=K0(e),o=[],a=t.createPlaybackOwnership??JI;if(typeof a!="function")throw new TypeError("createPlaybackOwnership must be a function");return Kl(s,{selectPendingEffects:J0,selectSkipMode:kp,selectAutoMode:Q0,selectIsChoiceVisible:Cp,selectIsFormVisible:tw,selectActiveInteraction:Se,selectActiveForm:pn,selectDialogueUIHidden:Ap,selectDialogueHistory:Pp,selectConfirmDialog:rw,selectIsLineAccountViewed:Pa,selectIsResourceAccountViewed:sw,selectImageGalleryConfig:iw,selectImageGallery:Ep,selectMusicRoomConfig:aw,selectMusicRoom:Sp,selectSceneReplayConfig:lw,selectSceneReplay:Rp,selectIsSceneReplayActive:cw,selectActiveSceneReplayEntry:uw,selectNextLineConfig:pw,selectSystemState:fw,selectAchievements:mw,selectAchievement:dw,selectSaveSlotMap:_p,selectSaveSlots:Iw,selectSaveSlot:yw,selectLocalizationPackages:Np,selectRuntime:_a,selectRuntimeValue:hw,selectAllVariables:Na,selectCurrentPointer:qe,selectSection:xe,selectCurrentLine:fn,selectPresentationState:jp,selectAutoForwardTimerDelay:Ir,selectPresentationChanges:gw,selectSectionLineChanges:ww,selectSaveSlotPage:ja,selectCurrentPageSlots:vw,selectRenderState:kw,selectOverlayStack:W0,selectLineIdByOffset:sf,selectCanRollback:of,selectRollbackCursor:q0,selectDesiredPlaybackTimers:tv,selectPlaybackLineEntryId:nv,startAutoMode:Lp,stopAutoMode:dn,toggleAutoMode:$w,startSkipMode:Mp,stopSkipMode:Tr,toggleSkipMode:Cw,showDialogueUI:Ps,hideDialogueUI:Vp,toggleDialogueUI:_w,setDialogueTextSpeed:Nw,setAutoForwardDelay:jw,setAutoForwardSpeed:Dw,setSkipUnseenText:Tw,setSkipTransitionsAndAnimations:Lw,setSoundVolume:Mw,setMusicVolume:Vw,setMuteAll:qw,setSaveLoadPagination:sa,incrementSaveLoadPagination:ia,decrementSaveLoadPagination:oa,setMenuPage:aa,setMenuEntryPoint:la,showConfirmDialog:Aw,hideConfirmDialog:Pw,resetStoryAtSection:zw,clearPendingEffects:Fw,appendPendingEffect:Bw,completeAchievement:Uw,setAchievementProgress:Yw,beginRollbackActionBatch:U0,endRollbackActionBatch:Y0,ensureRandomReplayOccurrence:z0,recordRandomOutcome:X0,markRollbackCheckpointTransient:F0,markSavedRollbackCheckpointTransient:B0,recordCurrentDialogueHistory:ew,addViewedLine:Gw,addViewedResource:Hw,showImageGalleryVariant:Kw,moveToPreviousImageGalleryVariant:Ww,moveToNextImageGalleryVariant:Jw,clearImageGallerySelection:Qw,moveToImageGalleryPage:Zw,moveToNextImageGalleryPage:eI,moveToPreviousImageGalleryPage:rI,playMusicRoomTrack:nI,playMusicRoom:sI,pauseMusicRoom:iI,stopMusicRoom:oI,seekMusicRoom:aI,playPreviousMusicRoomTrack:lI,playNextMusicRoomTrack:cI,clearMusicRoomSelection:uI,moveToMusicRoomPage:pI,moveToNextMusicRoomPage:fI,moveToPreviousMusicRoomPage:mI,musicRoomSoundReady:wI,musicRoomSoundProgress:II,musicRoomSoundComplete:vI,musicRoomSoundError:kI,startSceneReplay:dI,finishSceneReplay:Jp,exitSceneReplay:yI,moveToSceneReplayPage:hI,moveToNextSceneReplayPage:gI,moveToPreviousSceneReplayPage:bI,setNextLineConfig:rf,saveSlot:AI,loadSlot:PI,updateProjectData:EI,updateLocalizationPackage:xI,sectionTransition:$I,jumpToLine:SI,nextLine:OI,markLineCompleted:RI,rollbackToLine:WI,rollbackByOffset:KI,pushOverlay:Ew,popOverlay:xw,replaceLastOverlay:Sw,clearOverlays:Ow,updateFormField:DI,submitForm:TI,cancelForm:LI,updateVariable:MI,nextLineFromSystem:CI},{createTransactionalMetadata:a,updateTransactionalMetadata:ev,finalizeTransactionalMetadata:rv,transformActionFirstArgument:(n,i)=>({state:n,rollbackActionBatchStack:o,playbackOwnership:i}),transformSelectorFirstArgument:(n,i)=>({state:n,playbackOwnership:i})})};var sv="route-engine",iv="projectPersistence";var uf=()=>({saveSlots:{},globalDeviceVariables:{},globalAccountVariables:{},globalRuntime:{},accountViewedRegistry:{},accountReplayRegistry:{}}),be=e=>Object.prototype.toString.call(e)==="[object Object]",cf="variables.",ov=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(s=>typeof s=="string"||typeof s=="number"?{sectionId:String(s)}:!be(s)||typeof s.sectionId!="string"||s.sectionId.length===0?null:{sectionId:s.sectionId,...typeof s.lineId=="string"?{lineId:s.lineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(s=>typeof s=="string"||typeof s=="number"?{resourceId:String(s)}:!be(s)||typeof s.resourceId!="string"||s.resourceId.length===0?null:{resourceId:s.resourceId}).filter(Boolean)}},av=(e={})=>{let t=be(e)?e:{};return{sections:(Array.isArray(t.sections)?t.sections:[]).map(s=>typeof s=="string"||typeof s=="number"?{sectionId:String(s)}:!be(s)||typeof s.sectionId!="string"||s.sectionId.length===0?null:{sectionId:s.sectionId,...typeof s.lastLineId=="string"?{lastLineId:s.lastLineId}:{}}).filter(Boolean),resources:(Array.isArray(t.resources)?t.resources:[]).map(s=>typeof s=="string"||typeof s=="number"?{resourceId:String(s)}:!be(s)||typeof s.resourceId!="string"||s.resourceId.length===0?null:{resourceId:s.resourceId}).filter(Boolean)}},lv=(e,t)=>{let s=av(e),o=ov(t),a=s.sections.map(n=>({...n})),r=s.resources.map(n=>({...n}));return o.sections.forEach(n=>{let i=a.find(l=>l.sectionId===n.sectionId);if(!i){a.push({sectionId:n.sectionId,...n.lineId===void 0?{}:{lastLineId:n.lineId}});return}if(i.lastLineId!==void 0){if(n.lineId===void 0){delete i.lastLineId;return}i.lastLineId=n.lineId}}),o.resources.forEach(n=>{r.find(l=>l.resourceId===n.resourceId)||r.push({...n})}),{sections:a,resources:r}},cv=(e={})=>{let t=be(e)?e:{},s=Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set(s.filter(o=>typeof o=="string"&&o.length>0))]}},uv=(e,t)=>{let s=cv(e),o=be(t)&&Array.isArray(t.sceneIds)?t.sceneIds:[];return{sceneIds:[...new Set([...s.sceneIds,...o.filter(a=>typeof a=="string"&&a.length>0)])]}},pf=(e={})=>{let t=be(e)?e:{};return{saveSlots:be(t.saveSlots)?t.saveSlots:{},globalDeviceVariables:be(t.globalDeviceVariables)?t.globalDeviceVariables:{},globalAccountVariables:be(t.globalAccountVariables)?t.globalAccountVariables:{},globalRuntime:be(t.globalRuntime)?t.globalRuntime:{},accountViewedRegistry:be(t.accountViewedRegistry)?t.accountViewedRegistry:{},accountReplayRegistry:be(t.accountReplayRegistry)?t.accountReplayRegistry:{}}},pv=(e=[])=>{if(e===void 0)return[];if(!Array.isArray(e))throw new Error("applyScopedDataUpdates requires an updates array.");return e.map((t,s)=>{if(!be(t))throw new Error(`Malformed applyScopedDataUpdates.updates[${s}] entry.`);let o=t.path?.startsWith(cf)?t.path.slice(cf.length):null;if(o!==null){if(!["device","account"].includes(t.scope))throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(o.length===0)throw new Error(`Malformed applyScopedDataUpdates path "${t.path}" at updates[${s}].`);if(t.op!=="set")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);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[${s}].`);if(t.op!=="markViewed")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);return t}if(t.path==="replayRegistry"){if(t.scope!=="account")throw new Error(`Unsupported applyScopedDataUpdates scope "${t.scope}" at updates[${s}].`);if(t.op!=="unlock")throw new Error(`Unsupported applyScopedDataUpdates operation "${t.op}" at updates[${s}].`);if(!be(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[${s}].`);return{...t,value:{sceneIds:[...new Set(t.value.sceneIds)]}}}throw typeof t.path!="string"?new Error(`Malformed applyScopedDataUpdates path at updates[${s}].`):new Error(`Unsupported applyScopedDataUpdates path "${t.path}" at updates[${s}].`)})},fv=(e,t)=>{let s={};return pv(t).forEach(o=>{if(o.path==="viewedRegistry"){s.accountViewedRegistry=lv(s.accountViewedRegistry??e.accountViewedRegistry,o.value);return}if(o.path==="replayRegistry"){s.accountReplayRegistry=uv(s.accountReplayRegistry??e.accountReplayRegistry,o.value);return}let a=o.scope==="device"?"globalDeviceVariables":"globalAccountVariables";s[a]={...e[a],...s[a],[o.variableId]:o.value}}),s},Nt=e=>{if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null},mv=e=>{let t=Nt(e);if(!t)throw new Error("createIndexedDbPersistence requires a non-empty namespace.");return t},dv=e=>{let t=e??globalThis.indexedDB;if(!t)throw new Error("IndexedDB is not available in this environment.");return t},yv=({indexedDB:e,databaseName:t,objectStoreName:s})=>new Promise((o,a)=>{let r=e.open(t,1);r.onupgradeneeded=()=>{let n=r.result;n.objectStoreNames.contains(s)||n.createObjectStore(s,{keyPath:"namespace"})},r.onsuccess=()=>{o(r.result)},r.onerror=()=>{a(r.error??new Error(`Failed to open IndexedDB database "${t}".`))}}),hv=async({databasePromise:e,objectStoreName:t,namespace:s})=>{let o=await e;return new Promise((a,r)=>{let l=o.transaction(t,"readonly").objectStore(t).get(s);l.onsuccess=()=>{a(l.result??null)},l.onerror=()=>{r(l.error??new Error(`Failed to read persisted namespace "${s}" from IndexedDB.`))}})},hn=async({databasePromise:e,objectStoreName:t,namespace:s,patch:o})=>{let a=await e;return new Promise((r,n)=>{let i=a.transaction(t,"readwrite"),l=i.objectStore(t),c=l.get(s),u=!1,p=f=>{u||(u=!0,n(f))},d=()=>{u||(u=!0,r())};c.onerror=()=>{p(c.error??new Error(`Failed to read persisted namespace "${s}" before updating IndexedDB.`))},c.onsuccess=()=>{let f=pf(c.result),m=typeof o=="function"?o(f):o,g={namespace:s,version:1,...uf(),...f,...m},b=l.put(g);b.onerror=()=>{p(b.error??new Error(`Failed to persist namespace "${s}" to IndexedDB.`))}},i.oncomplete=()=>{d()},i.onerror=()=>{p(i.error??new Error(`IndexedDB transaction failed while updating namespace "${s}".`))},i.onabort=()=>{p(i.error??new Error(`IndexedDB transaction aborted while updating namespace "${s}".`))}})},gv=async({databasePromise:e,objectStoreName:t,namespace:s})=>{let o=await e;return new Promise((a,r)=>{let n=o.transaction(t,"readwrite"),l=n.objectStore(t).delete(s),c=!1,u=d=>{c||(c=!0,r(d))},p=()=>{c||(c=!0,a())};l.onerror=()=>{u(l.error??new Error(`Failed to clear persisted namespace "${s}" from IndexedDB.`))},n.oncomplete=()=>{p()},n.onerror=()=>{u(n.error??new Error(`IndexedDB transaction failed while clearing namespace "${s}".`))},n.onabort=()=>{u(n.error??new Error(`IndexedDB transaction aborted while clearing namespace "${s}".`))}})},qa=(e={})=>{let{indexedDB:t,databaseName:s=sv,objectStoreName:o=iv,namespace:a}=e,r=dv(t),n=mv(a),i=yv({indexedDB:r,databaseName:s,objectStoreName:o});return{namespace:n,load:async()=>{let l=await hv({databasePromise:i,objectStoreName:o,namespace:n});return{...uf(),...pf(l)}},clear:async()=>gv({databasePromise:i,objectStoreName:o,namespace:n}),saveSlots:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{saveSlots:be(l)?l:{}}}),saveGlobalDeviceVariables:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{globalDeviceVariables:be(l)?l:{}}}),saveGlobalAccountVariables:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{globalAccountVariables:be(l)?l:{}}}),saveGlobalRuntime:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:{globalRuntime:be(l)?l:{}}}),applyScopedDataUpdates:async l=>hn({databasePromise:i,objectStoreName:o,namespace:n,patch:c=>fv(c,l)})}},bv=qa;var Af=Pf;var wv={type:"object",properties:{resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"},colorId:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},additionalProperties:!1},Ke=Object.prototype.hasOwnProperty,Iv={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 Fe(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;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),n++}var u=c===n;if(l=l||u,!l){let p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.x===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"x"},message:"must have required property 'x'"};r===null?r=[f]:r.push(f),n++}if(e.y===void 0){let f={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"y"},message:"must have required property 'y'"};r===null?r=[f]:r.push(f),n++}for(let f in e)if(!(f==="x"||f==="y"||f==="quality"||f==="kernelSize"||f==="repeatEdgePixels")){let m={instancePath:t,schemaPath:"#/anyOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(e.x!==void 0){let f=e.x;if(typeof f=="number"){if(f<0||isNaN(f)){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),n++}}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),n++}}if(e.y!==void 0){let f=e.y;if(typeof f=="number"){if(f<0||isNaN(f)){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),n++}}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),n++}}if(e.quality!==void 0){let f=e.quality;if(typeof f=="number"){if(f<1||isNaN(f)){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),n++}}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),n++}}if(e.kernelSize!==void 0){let f=e.kernelSize;if(!(typeof f=="number"&&!(f%1)&&!isNaN(f))){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),n++}if(!(f===5||f===7||f===9||f===11||f===13||f===15)){let m={instancePath:t+"/kernelSize",schemaPath:"#/anyOf/1/properties/kernelSize/enum",keyword:"enum",params:{allowedValues:Iv.anyOf[1].properties.kernelSize.enum},message:"must be equal to one of the allowed values"};r===null?r=[m]:r.push(m),n++}}if(e.repeatEdgePixels!==void 0&&typeof e.repeatEdgePixels!="boolean"){let f={instancePath:t+"/repeatEdgePixels",schemaPath:"#/anyOf/1/properties/repeatEdgePixels/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[f]:r.push(f),n++}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}var u=p===n;l=l||u}if(l)n=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),n++}return Fe.errors=r,n===0}var Oe=mf().default;function $s(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return $s.errors=r,n===0}function lr(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)$s(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?$s.errors:r.concat($s.errors),n=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),n++}return lr.errors=r,n===0}var vv={type:"object",properties:{continuity:{type:"string",enum:["render","persistent"]},speed:{type:"number",exclusiveMinimum:0},loop:{type:"boolean"}},additionalProperties:!1};function Cs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(!(i==="render"||i==="persistent")){let l={instancePath:t+"/continuity",schemaPath:"#/properties/continuity/enum",keyword:"enum",params:{allowedValues:vv.properties.continuity.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}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),n++}}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Cs.errors=r,n===0}function pe(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}e.playback!==void 0&&(Cs(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Cs.errors:r.concat(Cs.errors),n=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),n++}return pe.errors=r,n===0}function _s(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(wv.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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}}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),n++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),e.filters!==void 0&&(lr(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),n=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return _s.errors=r,n===0}function Pf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return _s(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?_s.errors:r.concat(_s.errors),n=r.length),Pf.errors=r,n===0}var Ef=xf;var df={type:"object",properties:{sounds:{type:"array",items:{$ref:"#/definitions/bgmSound"}},resourceId:{type:"string"},loop:{type:"boolean"},interruption:{type:"string",enum:["immediate","loopEnd"]},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},audioEffects:{$ref:"#/definitions/audioEffectSelection"}},allOf:[{not:{required:["resourceId","sounds"]}},{not:{required:["startDelayMs","sounds"]}},{if:{required:["audioEffects"]},then:{required:["sounds"]}}],additionalProperties:!1},yf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function Ns(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ns.errors=r,n===0}function Ne(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}e.playback!==void 0&&(Ns(e.playback,{instancePath:t+"/playback",parentData:e,parentDataProperty:"playback",rootData:a})||(r=r===null?Ns.errors:r.concat(Ns.errors),n=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),n++}return Ne.errors=r,n===0}function js(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}for(let i in e)if(!Ke.call(yf.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),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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:yf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}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),n++}}e.beginEffect!==void 0&&(Ne(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),n=r.length)),e.endEffect!==void 0&&(Ne(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),n=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),n++}return js.errors=r,n===0}function Ds(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=n;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),n++}}var c=l===n;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),n++}else n=i,r!==null&&(i?r.length=i:r=null);let u=n,p=n;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),n++}}var d=p===n;if(d){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=u,r!==null&&(u?r.length=u:r=null);let f=n,m=!0,g=n;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),n++}}var b=g===n;if(n=f,r!==null&&(f?r.length=f:r=null),b){let y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let h={instancePath:t,schemaPath:"#/allOf/2/then/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[h]:r.push(h),n++}var b=y===n;m=b}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),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){for(let y in e)if(!Ke.call(df.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),n++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let h=0;h<w;h++)js(y[h],{instancePath:t+"/sounds/"+h,parentData:y,parentDataProperty:h,rootData:a})||(r=r===null?js.errors:r.concat(js.errors),n=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),n++}}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),n++}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),n++}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),n++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:df.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),n++}}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}e.audioEffects!==void 0&&(Ne(e.audioEffects,{instancePath:t+"/audioEffects",parentData:e,parentDataProperty:"audioEffects",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),n=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),n++}return Ds.errors=r,n===0}function xf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ds(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ds.errors:r.concat(Ds.errors),n=r.length),xf.errors=r,n===0}var Sf=Of;var kv={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},transformId:{type:"string"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},sprites:{type:"array",items:{type:"object",properties:{id:{type:"string"},resourceId:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},loop:{type:"boolean"}},additionalProperties:!1}},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{if:{required:["sprites"]},then:{required:["transformId"]}}],additionalProperties:!1}}},additionalProperties:!1};function Ts(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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],d=n,f=!0,m=n;if(p&&typeof p=="object"&&!Array.isArray(p)){let g;if(p.sprites===void 0&&(g="sprites")){let b={};r===null?r=[b]:r.push(b),n++}}var i=m===n;if(n=d,r!==null&&(d?r.length=d:r=null),i){let g=n;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),n++}var i=g===n;f=i}if(!f){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[g]:r.push(g),n++}if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.id===void 0){let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[g]:r.push(g),n++}for(let g in p)if(!Ke.call(kv.properties.items.items.properties,g)){let b={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:g},message:"must NOT have additional properties"};r===null?r=[b]:r.push(b),n++}if(p.id!==void 0&&typeof p.id!="string"){let g={instancePath:t+"/items/"+u+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(p.transformId!==void 0&&typeof p.transformId!="string"){let g={instancePath:t+"/items/"+u+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(p.x!==void 0&&typeof p.x!="number"){let g={instancePath:t+"/items/"+u+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.y!==void 0&&typeof p.y!="number"){let g={instancePath:t+"/items/"+u+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.anchorX!==void 0&&typeof p.anchorX!="number"){let g={instancePath:t+"/items/"+u+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.anchorY!==void 0&&typeof p.anchorY!="number"){let g={instancePath:t+"/items/"+u+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.scaleX!==void 0&&typeof p.scaleX!="number"){let g={instancePath:t+"/items/"+u+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.scaleY!==void 0&&typeof p.scaleY!="number"){let g={instancePath:t+"/items/"+u+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.flipX!==void 0&&typeof p.flipX!="boolean"){let g={instancePath:t+"/items/"+u+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),n++}if(p.flipY!==void 0&&typeof p.flipY!="boolean"){let g={instancePath:t+"/items/"+u+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[g]:r.push(g),n++}if(p.rotation!==void 0&&typeof p.rotation!="number"){let g={instancePath:t+"/items/"+u+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.originX!==void 0&&typeof p.originX!="number"){let g={instancePath:t+"/items/"+u+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.originY!==void 0&&typeof p.originY!="number"){let g={instancePath:t+"/items/"+u+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}if(p.alpha!==void 0){let g=p.alpha;if(typeof g=="number"){if(g>1||isNaN(g)){let b={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=[b]:r.push(b),n++}if(g<0||isNaN(g)){let b={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=[b]:r.push(b),n++}}else{let b={instancePath:t+"/items/"+u+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(p.opacity!==void 0){let g=p.opacity;if(typeof g=="number"){if(g>1||isNaN(g)){let b={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=[b]:r.push(b),n++}if(g<0||isNaN(g)){let b={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=[b]:r.push(b),n++}}else{let b={instancePath:t+"/items/"+u+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[b]:r.push(b),n++}}if(p.blur!==void 0&&(Fe(p.blur,{instancePath:t+"/items/"+u+"/blur",parentData:p,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),p.filters!==void 0&&(lr(p.filters,{instancePath:t+"/items/"+u+"/filters",parentData:p,parentDataProperty:"filters",rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),n=r.length)),p.sprites!==void 0){let g=p.sprites;if(Array.isArray(g)){let b=g.length;for(let y=0;y<b;y++){let w=g[y];if(w&&typeof w=="object"&&!Array.isArray(w)){for(let h in w)if(!(h==="id"||h==="resourceId"||h==="animationName"||h==="animationSpeed"||h==="loop")){let P={instancePath:t+"/items/"+u+"/sprites/"+y,schemaPath:"#/properties/items/items/properties/sprites/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(w.id!==void 0&&typeof w.id!="string"){let h={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=[h]:r.push(h),n++}if(w.resourceId!==void 0&&typeof w.resourceId!="string"){let h={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=[h]:r.push(h),n++}if(w.animationName!==void 0&&typeof w.animationName!="string"){let h={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=[h]:r.push(h),n++}if(w.animationSpeed!==void 0&&typeof w.animationSpeed!="number"){let h={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=[h]:r.push(h),n++}if(w.loop!==void 0&&typeof w.loop!="boolean"){let h={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=[h]:r.push(h),n++}}else{let h={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=[h]:r.push(h),n++}}}else{let b={instancePath:t+"/items/"+u+"/sprites",schemaPath:"#/properties/items/items/properties/sprites/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[b]:r.push(b),n++}}p.animations!==void 0&&(pe(p.animations,{instancePath:t+"/items/"+u+"/animations",parentData:p,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=r.length))}else{let g={instancePath:t+"/items/"+u,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[g]:r.push(g),n++}}}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),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return Ts.errors=r,n===0}function Of(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ts(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ts.errors:r.concat(Ts.errors),n=r.length),Of.errors=r,n===0}var Rf=$f;function Ls(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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 d={instancePath:t+"/items/"+c,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),n++}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),n++}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),n++}if(u.events!==void 0){let p=u.events;if(p&&typeof p=="object"&&!Array.isArray(p)){if(p.click!==void 0){let d=p.click;if(!(d&&typeof d=="object"&&!Array.isArray(d))){let f={instancePath: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=[f]:r.push(f),n++}}}else{let d={instancePath:t+"/items/"+c+"/events",schemaPath:"#/properties/items/items/properties/events/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[d]:r.push(d),n++}}}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),n++}}}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),n++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Ls.errors=r,n===0}function $f(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ls(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ls.errors:r.concat(Ls.errors),n=r.length),$f.errors=r,n===0}var Cf=_f;function Ms(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ms.errors=r,n===0}function _f(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ms(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ms.errors:r.concat(Ms.errors),n=r.length),_f.errors=r,n===0}var Nf=jf;function Vs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Vs.errors=r,n===0}function jf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Vs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Vs.errors:r.concat(Vs.errors),n=r.length),jf.errors=r,n===0}var Df=Tf;var hf={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 qs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(hf.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),n++}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),n++}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),n++}i.animations!==void 0&&(pe(i.animations,{instancePath:t+"/ui/animations",parentData:i,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}}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),n++}if(!(i==="adv"||i==="nvl")){let l={instancePath:t+"/mode",schemaPath:"#/properties/mode/enum",keyword:"enum",params:{allowedValues:hf.properties.mode.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}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),n++}}}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),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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 d=c[p];if(d&&typeof d=="object"&&!Array.isArray(d)){if(d.id===void 0){let f={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=[f]:r.push(f),n++}if(d.resourceId===void 0){let f={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=[f]:r.push(f),n++}for(let f in d)if(!(f==="id"||f==="resourceId"||f==="animationName"||f==="animationSpeed"||f==="loop")){let m={instancePath:t+"/character/sprite/items/"+p,schemaPath:"#/properties/character/properties/sprite/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(d.id!==void 0&&typeof d.id!="string"){let f={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=[f]:r.push(f),n++}if(d.resourceId!==void 0&&typeof d.resourceId!="string"){let f={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=[f]:r.push(f),n++}if(d.animationName!==void 0&&typeof d.animationName!="string"){let f={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=[f]:r.push(f),n++}if(d.animationSpeed!==void 0&&typeof d.animationSpeed!="number"){let f={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=[f]:r.push(f),n++}if(d.loop!==void 0&&typeof d.loop!="boolean"){let f={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=[f]:r.push(f),n++}}else{let f={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=[f]:r.push(f),n++}}}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),n++}}l.animations!==void 0&&(pe(l.animations,{instancePath:t+"/character/sprite/animations",parentData:l,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}}}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),n++}}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return qs.errors=r,n===0}function Tf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return qs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?qs.errors:r.concat(qs.errors),n=r.length),Tf.errors=r,n===0}var Lf=Mf;function Fs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}}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),n++}}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),n++}}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),n++}}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),n++}}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Fs.errors=r,n===0}function Mf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Fs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Fs.errors:r.concat(Fs.errors),n=r.length),Mf.errors=r,n===0}var Vf=qf;function Bs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Bs.errors=r,n===0}function qf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Bs(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Bs.errors:r.concat(Bs.errors),n=r.length),qf.errors=r,n===0}var Ff=Bf;function Us(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}}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),n++}}e.blur!==void 0&&(Fe(e.blur,{instancePath:t+"/blur",parentData:e,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),e.animations!==void 0&&(pe(e.animations,{instancePath:t+"/animations",parentData:e,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=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),n++}return Us.errors=r,n===0}function Bf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Us(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Us.errors:r.concat(Us.errors),n=r.length),Bf.errors=r,n===0}var Uf=Yf;var gf={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},bf={type:"object",properties:{id:{type:"string",minLength:1},resourceId:{type:"string",minLength:1},loop:{type:"boolean"},volume:{type:"number",minimum:0,maximum:100},muted:{type:"boolean"},pan:{type:"number",minimum:-1,maximum:1},startDelayMs:{type:"number",minimum:0},playbackRate:{type:"number",minimum:0},startAt:{type:"number",minimum:0},endAt:{type:["number","null"],minimum:0},beginEffect:{$ref:"#/definitions/audioEffectSelection"},endEffect:{$ref:"#/definitions/audioEffectSelection"}},required:["id","resourceId"],additionalProperties:!1};function ar(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}for(let i in e)if(!Ke.call(bf.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),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.resourceId!==void 0){let i=e.resourceId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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:bf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}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),n++}}e.beginEffect!==void 0&&(Ne(e.beginEffect,{instancePath:t+"/beginEffect",parentData:e,parentDataProperty:"beginEffect",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),n=r.length)),e.endEffect!==void 0&&(Ne(e.endEffect,{instancePath:t+"/endEffect",parentData:e,parentDataProperty:"endEffect",rootData:a})||(r=r===null?Ne.errors:r.concat(Ne.errors),n=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),n++}return ar.errors=r,n===0}function Ys(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=n;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),n++}}var c=l===n;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),n++}else n=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),n++}if(e.items!==void 0){let u=e.items;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++)ar(u[d],{instancePath:t+"/items/"+d,parentData:u,parentDataProperty:d,rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),n=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),n++}}if(e.channels!==void 0){let u=e.channels;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++){let f=u[d];if(f&&typeof f=="object"&&!Array.isArray(f)){if(f.id===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[m]:r.push(m),n++}if(f.sounds===void 0){let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[m]:r.push(m),n++}for(let m in f)if(!(m==="id"||m==="volume"||m==="muted"||m==="pan"||m==="loop"||m==="interruption"||m==="applyMode"||m==="sounds")){let g={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:m},message:"must NOT have additional properties"};r===null?r=[g]:r.push(g),n++}if(f.id!==void 0){let m=f.id;if(typeof m=="string"){if(Oe(m)<1){let g={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/minLength",keyword:"minLength",params:{limit:1},message:"must NOT have fewer than 1 characters"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/channels/"+d+"/id",schemaPath:"#/properties/channels/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}}if(f.volume!==void 0){let m=f.volume;if(typeof m=="number"){if(m>100||isNaN(m)){let g={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[g]:r.push(g),n++}if(m<0||isNaN(m)){let g={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/channels/"+d+"/volume",schemaPath:"#/properties/channels/items/properties/volume/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}}if(f.muted!==void 0&&typeof f.muted!="boolean"){let m={instancePath:t+"/channels/"+d+"/muted",schemaPath:"#/properties/channels/items/properties/muted/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),n++}if(f.pan!==void 0){let m=f.pan;if(typeof m=="number"){if(m>1||isNaN(m)){let g={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[g]:r.push(g),n++}if(m<-1||isNaN(m)){let g={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[g]:r.push(g),n++}}else{let g={instancePath:t+"/channels/"+d+"/pan",schemaPath:"#/properties/channels/items/properties/pan/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[g]:r.push(g),n++}}if(f.loop!==void 0&&typeof f.loop!="boolean"){let m={instancePath:t+"/channels/"+d+"/loop",schemaPath:"#/properties/channels/items/properties/loop/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[m]:r.push(m),n++}if(f.interruption!==void 0){let m=f.interruption;if(typeof m!="string"){let g={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(!(m==="immediate"||m==="loopEnd")){let g={instancePath:t+"/channels/"+d+"/interruption",schemaPath:"#/properties/channels/items/properties/interruption/enum",keyword:"enum",params:{allowedValues:gf.properties.channels.items.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[g]:r.push(g),n++}}if(f.applyMode!==void 0){let m=f.applyMode;if(typeof m!="string"){let g={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[g]:r.push(g),n++}if(!(m==="singleLine"||m==="persistent")){let g={instancePath:t+"/channels/"+d+"/applyMode",schemaPath:"#/properties/channels/items/properties/applyMode/enum",keyword:"enum",params:{allowedValues:gf.properties.channels.items.properties.applyMode.enum},message:"must be equal to one of the allowed values"};r===null?r=[g]:r.push(g),n++}}if(f.sounds!==void 0){let m=f.sounds;if(Array.isArray(m)){let g=m.length;for(let b=0;b<g;b++)ar(m[b],{instancePath:t+"/channels/"+d+"/sounds/"+b,parentData:m,parentDataProperty:b,rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),n=r.length)}else{let g={instancePath:t+"/channels/"+d+"/sounds",schemaPath:"#/properties/channels/items/properties/sounds/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[g]:r.push(g),n++}}}else{let m={instancePath:t+"/channels/"+d,schemaPath:"#/properties/channels/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[m]:r.push(m),n++}}}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),n++}}}else{let u={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[u]:r.push(u),n++}return Ys.errors=r,n===0}function Yf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ys(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ys.errors:r.concat(Ys.errors),n=r.length),Yf.errors=r,n===0}var zf=Xf;var wf={type:"object",properties:{items:{type:"array",items:{type:"object",properties:{id:{type:"string"},animationName:{type:"string"},animationSpeed:{type:"number"},resourceId:{type:"string"},text:{$ref:"#/definitions/visualText"},layout:{$ref:"#/definitions/visualInlineLayout"},transformId:{type:"string"},transform:{$ref:"#/definitions/visualInlineTransform"},x:{type:"number"},y:{type:"number"},anchorX:{type:"number"},anchorY:{type:"number"},scaleX:{type:"number"},scaleY:{type:"number"},flipX:{type:"boolean"},flipY:{type:"boolean"},rotation:{type:"number"},originX:{type:"number"},originY:{type:"number"},layer:{type:"number",enum:[10,30,50,70,90]},alpha:{type:"number",minimum:0,maximum:1},opacity:{type:"number",minimum:0,maximum:1},blur:{$ref:"#/definitions/backgroundBlur"},filters:{$ref:"#/definitions/shaderFilters"},animations:{$ref:"#/definitions/animationSelection"}},required:["id"],allOf:[{not:{required:["resourceId","text"]}},{not:{required:["resourceId","layout"]}},{not:{required:["text","layout"]}},{not:{required:["transformId","transform"]}}],additionalProperties:!1}}},additionalProperties:!1};function zs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;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),n++}var u=c===n;if(l=l||u,!l){let p=n;if(Array.isArray(e)){let f=e.length;for(let m=0;m<f;m++){let g=e[m];if(g&&typeof g=="object"&&!Array.isArray(g)){if(g.text!==void 0&&typeof g.text!="string"){let b={instancePath:t+"/"+m+"/text",schemaPath:"#/anyOf/1/items/properties/text/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(g.textStyleId!==void 0&&typeof g.textStyleId!="string"){let b={instancePath:t+"/"+m+"/textStyleId",schemaPath:"#/anyOf/1/items/properties/textStyleId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[b]:r.push(b),n++}if(g.furigana!==void 0){let b=g.furigana;if(b&&typeof b=="object"&&!Array.isArray(b)){if(b.text!==void 0&&typeof b.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),n++}if(b.textStyleId!==void 0&&typeof b.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),n++}}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),n++}}}else{let b={instancePath:t+"/"+m,schemaPath:"#/anyOf/1/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),n++}}}else{let f={instancePath:t,schemaPath:"#/anyOf/1/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[f]:r.push(f),n++}var u=p===n;l=l||u}if(l)n=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),n++}return zs.errors=r,n===0}function Xs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=n,c=n,u=!1,p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let w;if(e.id===void 0&&(w="id")){let h={};r===null?r=[h]:r.push(h),n++}}var d=p===n;if(u=u||d,!u){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.type===void 0&&(P="type")){let k={};r===null?r=[k]:r.push(k),n++}}var d=w===n;if(u=u||d,!u){let P=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let E;if(e.resourceId===void 0&&(E="resourceId")){let v={};r===null?r=[v]:r.push(v),n++}}var d=P===n;if(u=u||d,!u){let E=n;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),n++}}var d=E===n;if(u=u||d,!u){let O=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.transformId===void 0&&($="transformId")){let D={};r===null?r=[D]:r.push(D),n++}}var d=O===n;if(u=u||d,!u){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.transform===void 0&&(B="transform")){let _={};r===null?r=[_]:r.push(_),n++}}var d=$===n;if(u=u||d,!u){let B=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.x===void 0&&(G="x")){let fe={};r===null?r=[fe]:r.push(fe),n++}}var d=B===n;if(u=u||d,!u){let G=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let M;if(e.y===void 0&&(M="y")){let K={};r===null?r=[K]:r.push(K),n++}}var d=G===n;if(u=u||d,!u){let M=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let le;if(e.anchorX===void 0&&(le="anchorX")){let z={};r===null?r=[z]:r.push(z),n++}}var d=M===n;if(u=u||d,!u){let le=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let te;if(e.anchorY===void 0&&(te="anchorY")){let oe={};r===null?r=[oe]:r.push(oe),n++}}var d=le===n;if(u=u||d,!u){let te=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let ne;if(e.scaleX===void 0&&(ne="scaleX")){let ue={};r===null?r=[ue]:r.push(ue),n++}}var d=te===n;if(u=u||d,!u){let ne=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Z;if(e.scaleY===void 0&&(Z="scaleY")){let C={};r===null?r=[C]:r.push(C),n++}}var d=ne===n;if(u=u||d,!u){let Z=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let N;if(e.flipX===void 0&&(N="flipX")){let F={};r===null?r=[F]:r.push(F),n++}}var d=Z===n;if(u=u||d,!u){let N=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let J;if(e.flipY===void 0&&(J="flipY")){let me={};r===null?r=[me]:r.push(me),n++}}var d=N===n;if(u=u||d,!u){let J=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ie;if(e.rotation===void 0&&(Ie="rotation")){let we={};r===null?r=[we]:r.push(we),n++}}var d=J===n;if(u=u||d,!u){let Ie=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let de;if(e.originX===void 0&&(de="originX")){let mr={};r===null?r=[mr]:r.push(mr),n++}}var d=Ie===n;if(u=u||d,!u){let de=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let We;if(e.originY===void 0&&(We="originY")){let Sn={};r===null?r=[Sn]:r.push(Sn),n++}}var d=de===n;if(u=u||d,!u){let We=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Fr;if(e.layer===void 0&&(Fr="layer")){let Br={};r===null?r=[Br]:r.push(Br),n++}}var d=We===n;if(u=u||d,!u){let Fr=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ar;if(e.alpha===void 0&&(Ar="alpha")){let On={};r===null?r=[On]:r.push(On),n++}}var d=Fr===n;if(u=u||d,!u){let Ar=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let ut;if(e.opacity===void 0&&(ut="opacity")){let pt={};r===null?r=[pt]:r.push(pt),n++}}var d=Ar===n;if(u=u||d,!u){let ut=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Ur;if(e.blur===void 0&&(Ur="blur")){let ft={};r===null?r=[ft]:r.push(ft),n++}}var d=ut===n;if(u=u||d,!u){let Ur=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let Tt;if(e.filters===void 0&&(Tt="filters")){let Rn={};r===null?r=[Rn]:r.push(Rn),n++}}var d=Ur===n;if(u=u||d,!u){let Tt=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $n;if(e.animations===void 0&&($n="animations")){let Cn={};r===null?r=[Cn]:r.push(Cn),n++}}var d=Tt===n;u=u||d}}}}}}}}}}}}}}}}}}}}}}if(u)n=c,r!==null&&(c?r.length=c:r=null);else{let w={};r===null?r=[w]:r.push(w),n++}var f=l===n;if(f){let w={instancePath:t,schemaPath:"#/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[w]:r.push(w),n++}else n=i,r!==null&&(i?r.length=i:r=null);let m=n,g=!1,b=n;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),n++}var y=b===n;if(g=g||y,!g){let w=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.textStyleId===void 0){let P={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"textStyleId"},message:"must have required property 'textStyleId'"};r===null?r=[P]:r.push(P),n++}var y=w===n;g=g||y}if(g)n=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),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.content!==void 0&&(zs(e.content,{instancePath:t+"/content",parentData:e,parentDataProperty:"content",rootData:a})||(r=r===null?zs.errors:r.concat(zs.errors),n=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),n++}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),n++}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),n++}}else{let w={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[w]:r.push(w),n++}return Xs.errors=r,n===0}function Gs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Gs.errors=r,n===0}var Av={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 Hs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}for(let i in e)if(!Ke.call(Av.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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Hs.errors=r,n===0}function Ks(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let p in e)if(p!=="items"){let d={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:p},message:"must NOT have additional properties"};r===null?r=[d]:r.push(d),n++}if(e.items!==void 0){let p=e.items;if(Array.isArray(p)){let d=p.length;for(let f=0;f<d;f++){let m=p[f],g=n,b=n;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),n++}}var i=b===n;if(i){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=g,r!==null&&(g?r.length=g:r=null);let y=n,w=n;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),n++}}var l=w===n;if(l){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=y,r!==null&&(y?r.length=y:r=null);let h=n,P=n;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),n++}}var c=P===n;if(c){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/2/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=h,r!==null&&(h?r.length=h:r=null);let k=n,E=n;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),n++}}var u=E===n;if(u){let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/allOf/3/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[v]:r.push(v),n++}else n=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/"+f,schemaPath:"#/properties/items/items/required",keyword:"required",params:{missingProperty:"id"},message:"must have required property 'id'"};r===null?r=[v]:r.push(v),n++}for(let v in m)if(!Ke.call(wf.properties.items.items.properties,v)){let O={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:v},message:"must NOT have additional properties"};r===null?r=[O]:r.push(O),n++}if(m.id!==void 0&&typeof m.id!="string"){let v={instancePath:t+"/items/"+f+"/id",schemaPath:"#/properties/items/items/properties/id/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(m.animationName!==void 0&&typeof m.animationName!="string"){let v={instancePath:t+"/items/"+f+"/animationName",schemaPath:"#/properties/items/items/properties/animationName/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(m.animationSpeed!==void 0&&typeof m.animationSpeed!="number"){let v={instancePath:t+"/items/"+f+"/animationSpeed",schemaPath:"#/properties/items/items/properties/animationSpeed/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.resourceId!==void 0&&typeof m.resourceId!="string"){let v={instancePath:t+"/items/"+f+"/resourceId",schemaPath:"#/properties/items/items/properties/resourceId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(m.text!==void 0&&(Xs(m.text,{instancePath:t+"/items/"+f+"/text",parentData:m,parentDataProperty:"text",rootData:a})||(r=r===null?Xs.errors:r.concat(Xs.errors),n=r.length)),m.layout!==void 0&&(Gs(m.layout,{instancePath:t+"/items/"+f+"/layout",parentData:m,parentDataProperty:"layout",rootData:a})||(r=r===null?Gs.errors:r.concat(Gs.errors),n=r.length)),m.transformId!==void 0&&typeof m.transformId!="string"){let v={instancePath:t+"/items/"+f+"/transformId",schemaPath:"#/properties/items/items/properties/transformId/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[v]:r.push(v),n++}if(m.transform!==void 0&&(Hs(m.transform,{instancePath:t+"/items/"+f+"/transform",parentData:m,parentDataProperty:"transform",rootData:a})||(r=r===null?Hs.errors:r.concat(Hs.errors),n=r.length)),m.x!==void 0&&typeof m.x!="number"){let v={instancePath:t+"/items/"+f+"/x",schemaPath:"#/properties/items/items/properties/x/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.y!==void 0&&typeof m.y!="number"){let v={instancePath:t+"/items/"+f+"/y",schemaPath:"#/properties/items/items/properties/y/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.anchorX!==void 0&&typeof m.anchorX!="number"){let v={instancePath:t+"/items/"+f+"/anchorX",schemaPath:"#/properties/items/items/properties/anchorX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.anchorY!==void 0&&typeof m.anchorY!="number"){let v={instancePath:t+"/items/"+f+"/anchorY",schemaPath:"#/properties/items/items/properties/anchorY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.scaleX!==void 0&&typeof m.scaleX!="number"){let v={instancePath:t+"/items/"+f+"/scaleX",schemaPath:"#/properties/items/items/properties/scaleX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.scaleY!==void 0&&typeof m.scaleY!="number"){let v={instancePath:t+"/items/"+f+"/scaleY",schemaPath:"#/properties/items/items/properties/scaleY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.flipX!==void 0&&typeof m.flipX!="boolean"){let v={instancePath:t+"/items/"+f+"/flipX",schemaPath:"#/properties/items/items/properties/flipX/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),n++}if(m.flipY!==void 0&&typeof m.flipY!="boolean"){let v={instancePath:t+"/items/"+f+"/flipY",schemaPath:"#/properties/items/items/properties/flipY/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[v]:r.push(v),n++}if(m.rotation!==void 0&&typeof m.rotation!="number"){let v={instancePath:t+"/items/"+f+"/rotation",schemaPath:"#/properties/items/items/properties/rotation/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.originX!==void 0&&typeof m.originX!="number"){let v={instancePath:t+"/items/"+f+"/originX",schemaPath:"#/properties/items/items/properties/originX/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.originY!==void 0&&typeof m.originY!="number"){let v={instancePath:t+"/items/"+f+"/originY",schemaPath:"#/properties/items/items/properties/originY/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[v]:r.push(v),n++}if(m.layer!==void 0){let v=m.layer;if(typeof v!="number"){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),n++}if(!(v===10||v===30||v===50||v===70||v===90)){let O={instancePath:t+"/items/"+f+"/layer",schemaPath:"#/properties/items/items/properties/layer/enum",keyword:"enum",params:{allowedValues:wf.properties.items.items.properties.layer.enum},message:"must be equal to one of the allowed values"};r===null?r=[O]:r.push(O),n++}}if(m.alpha!==void 0){let v=m.alpha;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}}else{let O={instancePath:t+"/items/"+f+"/alpha",schemaPath:"#/properties/items/items/properties/alpha/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),n++}}if(m.opacity!==void 0){let v=m.opacity;if(typeof v=="number"){if(v>1||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}if(v<0||isNaN(v)){let O={instancePath:t+"/items/"+f+"/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),n++}}else{let O={instancePath:t+"/items/"+f+"/opacity",schemaPath:"#/properties/items/items/properties/opacity/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[O]:r.push(O),n++}}m.blur!==void 0&&(Fe(m.blur,{instancePath:t+"/items/"+f+"/blur",parentData:m,parentDataProperty:"blur",rootData:a})||(r=r===null?Fe.errors:r.concat(Fe.errors),n=r.length)),m.filters!==void 0&&(lr(m.filters,{instancePath:t+"/items/"+f+"/filters",parentData:m,parentDataProperty:"filters",rootData:a})||(r=r===null?lr.errors:r.concat(lr.errors),n=r.length)),m.animations!==void 0&&(pe(m.animations,{instancePath:t+"/items/"+f+"/animations",parentData:m,parentDataProperty:"animations",rootData:a})||(r=r===null?pe.errors:r.concat(pe.errors),n=r.length))}else{let v={instancePath:t+"/items/"+f,schemaPath:"#/properties/items/items/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}}else{let d={instancePath:t+"/items",schemaPath:"#/properties/items/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[d]:r.push(d),n++}}}else{let p={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[p]:r.push(p),n++}return Ks.errors=r,n===0}function Xf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ks(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ks.errors:r.concat(Ks.errors),n=r.length),Xf.errors=r,n===0}var Gf=Hf;var Pv={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 Ws(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;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),n++}var u=c===n;if(l=l||u,!l){let y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.sounds===void 0){let h={instancePath:t,schemaPath:"#/anyOf/1/required",keyword:"required",params:{missingProperty:"sounds"},message:"must have required property 'sounds'"};r===null?r=[h]:r.push(h),n++}var u=y===n;l=l||u}if(l)n=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),n++}let p=n,d=n;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),n++}}var f=d===n;if(f){let y={instancePath:t,schemaPath:"#/allOf/0/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=p,r!==null&&(p?r.length=p:r=null);let m=n,g=n;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),n++}}var b=g===n;if(b){let y={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[y]:r.push(y),n++}else n=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),n++}if(e.sounds!==void 0){let y=e.sounds;if(Array.isArray(y)){let w=y.length;for(let h=0;h<w;h++)ar(y[h],{instancePath:t+"/sounds/"+h,parentData:y,parentDataProperty:h,rootData:a})||(r=r===null?ar.errors:r.concat(ar.errors),n=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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}if(!(y==="immediate"||y==="loopEnd")){let w={instancePath:t+"/interruption",schemaPath:"#/properties/interruption/enum",keyword:"enum",params:{allowedValues:Pv.properties.interruption.enum},message:"must be equal to one of the allowed values"};r===null?r=[w]:r.push(w),n++}}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),n++}}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),n++}}}else{let y={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[y]:r.push(y),n++}return Ws.errors=r,n===0}function Hf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ws(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ws.errors:r.concat(Ws.errors),n=r.length),Hf.errors=r,n===0}var Kf=Wf;var Ev={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 Js(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="number"){let b={};r===null?r=[b]:r.push(b),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let b=n;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),n++}var u=b===n;l=u}if(!l){let b={instancePath:t,schemaPath:"#/allOf/0/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let p=n,d=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="boolean"){let b={};r===null?r=[b]:r.push(b),n++}var m=f===n;if(n=p,r!==null&&(p?r.length=p:r=null),m){let b=n,y=n,w=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let P;if(e.target===void 0&&(P="target")){let k={};r===null?r=[k]:r.push(k),n++}}var g=w===n;if(g){let P={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[P]:r.push(P),n++}else n=y,r!==null&&(y?r.length=y:r=null);var m=b===n;d=m}if(!d){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.type===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[b]:r.push(b),n++}if(e.name===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"name"},message:"must have required property 'name'"};r===null?r=[b]:r.push(b),n++}if(e.description===void 0){let b={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"description"},message:"must have required property 'description'"};r===null?r=[b]:r.push(b),n++}for(let b in e)if(!(b==="type"||b==="target"||b==="name"||b==="description"||b==="lockedName"||b==="lockedDescription"||b==="hidden")){let y={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:b},message:"must NOT have additional properties"};r===null?r=[y]:r.push(y),n++}if(e.type!==void 0){let b=e.type;if(typeof b!="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),n++}if(!(b==="boolean"||b==="number")){let y={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Ev.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[y]:r.push(y),n++}}if(e.target!==void 0){let b=e.target;if(!(typeof b=="number"&&!(b%1)&&!isNaN(b))){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),n++}if(typeof b=="number"&&(b<1||isNaN(b))){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),n++}}if(e.name!==void 0){let b=e.name;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.description!==void 0){let b=e.description;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.lockedName!==void 0){let b=e.lockedName;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.lockedDescription!==void 0){let b=e.lockedDescription;if(typeof b=="string"){if(Oe(b)<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),n++}}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),n++}}if(e.hidden!==void 0&&typeof e.hidden!="boolean"){let b={instancePath:t+"/hidden",schemaPath:"#/properties/hidden/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[b]:r.push(b),n++}}else{let b={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[b]:r.push(b),n++}return Js.errors=r,n===0}function Wf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Js(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Js.errors:r.concat(Js.errors),n=r.length),Wf.errors=r,n===0}var Jf=Qf;var xv={type:"object",required:["type"],$defs:{keyframe:{type:"object",required:["value","duration"],properties:{value:{type:"number"},duration:{type:"number"},easing:{type:"string",enum:["linear","easeInQuad","easeOutQuad","easeInOutQuad","easeInCubic","easeOutCubic","easeInOutCubic","easeInQuart","easeOutQuart","easeInOutQuart","easeInQuint","easeOutQuint","easeInOutQuint","easeInSine","easeOutSine","easeInOutSine","easeInExpo","easeOutExpo","easeInOutExpo","easeInCirc","easeOutCirc","easeInOutCirc","easeInBack","easeOutBack","easeInOutBack","easeInBounce","easeOutBounce","easeInOutBounce","easeInElastic","easeOutElastic","easeInOutElastic"]},relative:{type:"boolean"}},additionalProperties:!1},tweenProperty:{type:"object",properties:{initialValue:{type:"number"},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/keyframe"}}},required:["keyframes"],additionalProperties:!1},updateTween:{type:"object",properties:{alpha:{$ref:"#/$defs/tweenProperty"},x:{$ref:"#/$defs/tweenProperty"},y:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionTween:{type:"object",properties:{translateX:{$ref:"#/$defs/tweenProperty"},translateY:{$ref:"#/$defs/tweenProperty"},alpha:{$ref:"#/$defs/tweenProperty"},scaleX:{$ref:"#/$defs/tweenProperty"},scaleY:{$ref:"#/$defs/tweenProperty"},rotation:{$ref:"#/$defs/tweenProperty"}},additionalProperties:!1,minProperties:1},transitionSide:{type:"object",required:["tween"],properties:{tween:{$ref:"#/$defs/transitionTween"}},additionalProperties:!1},maskProgress:{$ref:"#/$defs/tweenProperty"},compositeMaskItem:{type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1},mask:{type:"object",required:["kind"],properties:{kind:{type:"string",enum:["single","sequence","composite"]},texture:{type:"string"},textures:{type:"array",minItems:1,items:{type:"string"}},items:{type:"array",minItems:1,items:{$ref:"#/$defs/compositeMaskItem"}},combine:{type:"string",enum:["max","min","multiply","add"]},channel:{type:"string",enum:["red","green","blue","alpha"]},softness:{type:"number"},invert:{type:"boolean"},sample:{type:"string"},progress:{$ref:"#/$defs/maskProgress"}},additionalProperties:!1,allOf:[{if:{properties:{kind:{const:"single"}}},then:{required:["texture"]}},{if:{properties:{kind:{const:"sequence"}}},then:{required:["textures"]}},{if:{properties:{kind:{const:"composite"}}},then:{required:["items"]}}]}},properties:{name:{type:"string"},type:{type:"string",enum:["update","transition"]},complete:{type:"object",properties:{payload:{type:"object"}},additionalProperties:!0},tween:{$ref:"#/$defs/updateTween"},prev:{$ref:"#/$defs/transitionSide"},next:{$ref:"#/$defs/transitionSide"},mask:{$ref:"#/$defs/mask"}},allOf:[{if:{properties:{type:{const:"update"}}},then:{required:["tween"],not:{anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}},{if:{properties:{type:{const:"transition"}}},then:{not:{required:["tween"]},anyOf:[{required:["prev"]},{required:["next"]},{required:["mask"]}]}}],additionalProperties:!1,$id:"https://route-engine.runtime/schemas/projectData/animationResource.yaml"};var Sv={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 ot(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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:Sv.properties.easing.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ot.errors=r,n===0}function re(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)ot(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return re.errors=r,n===0}function Qs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.x!==void 0&&(re(e.x,{instancePath:t+"/x",parentData:e,parentDataProperty:"x",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.y!==void 0&&(re(e.y,{instancePath:t+"/y",parentData:e,parentDataProperty:"y",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=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),n++}return Qs.errors=r,n===0}function Zs(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.translateX!==void 0&&(re(e.translateX,{instancePath:t+"/translateX",parentData:e,parentDataProperty:"translateX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.translateY!==void 0&&(re(e.translateY,{instancePath:t+"/translateY",parentData:e,parentDataProperty:"translateY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.alpha!==void 0&&(re(e.alpha,{instancePath:t+"/alpha",parentData:e,parentDataProperty:"alpha",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleX!==void 0&&(re(e.scaleX,{instancePath:t+"/scaleX",parentData:e,parentDataProperty:"scaleX",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.scaleY!==void 0&&(re(e.scaleY,{instancePath:t+"/scaleY",parentData:e,parentDataProperty:"scaleY",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=r.length)),e.rotation!==void 0&&(re(e.rotation,{instancePath:t+"/rotation",parentData:e,parentDataProperty:"rotation",rootData:a})||(r=r===null?re.errors:r.concat(re.errors),n=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),n++}return Zs.errors=r,n===0}function st(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n=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),n++}return st.errors=r,n===0}var Rs={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"]}}]},Ov={type:"object",required:["texture"],properties:{texture:{type:"string"},channel:{type:"string",enum:["red","green","blue","alpha"]},invert:{type:"boolean"}},additionalProperties:!1};function ei(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}if(!(i==="red"||i==="green"||i==="blue"||i==="alpha")){let l={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Ov.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[l]:r.push(l),n++}}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ei.errors=r,n===0}function ri(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}let l=i.length;for(let c=0;c<l;c++)ot(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?ot.errors:r.concat(ot.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ri.errors=r,n===0}function ti(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="single"){let h={};r===null?r=[h]:r.push(h),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let h=n;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),n++}var u=h===n;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),n++}let p=n,d=!0,f=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="sequence"){let h={};r===null?r=[h]:r.push(h),n++}var m=f===n;if(n=p,r!==null&&(p?r.length=p:r=null),m){let h=n;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),n++}var m=h===n;d=m}if(!d){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),n++}let g=n,b=!0,y=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.kind!==void 0&&e.kind!=="composite"){let h={};r===null?r=[h]:r.push(h),n++}var w=y===n;if(n=g,r!==null&&(g?r.length=g:r=null),w){let h=n;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),n++}var w=h===n;b=w}if(!b){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),n++}if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.kind===void 0){let h={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"kind"},message:"must have required property 'kind'"};r===null?r=[h]:r.push(h),n++}for(let h in e)if(!Ke.call(Rs.properties,h)){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.kind!==void 0){let h=e.kind;if(typeof h!="string"){let P={instancePath:t+"/kind",schemaPath:"#/properties/kind/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="single"||h==="sequence"||h==="composite")){let P={instancePath:t+"/kind",schemaPath:"#/properties/kind/enum",keyword:"enum",params:{allowedValues:Rs.properties.kind.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.texture!==void 0&&typeof e.texture!="string"){let h={instancePath:t+"/texture",schemaPath:"#/properties/texture/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(e.textures!==void 0){let h=e.textures;if(Array.isArray(h)){if(h.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),n++}let P=h.length;for(let k=0;k<P;k++)if(typeof h[k]!="string"){let E={instancePath:t+"/textures/"+k,schemaPath:"#/properties/textures/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[E]:r.push(E),n++}}else{let P={instancePath:t+"/textures",schemaPath:"#/properties/textures/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[P]:r.push(P),n++}}if(e.items!==void 0){let h=e.items;if(Array.isArray(h)){if(h.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),n++}let P=h.length;for(let k=0;k<P;k++)ei(h[k],{instancePath:t+"/items/"+k,parentData:h,parentDataProperty:k,rootData:a})||(r=r===null?ei.errors:r.concat(ei.errors),n=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),n++}}if(e.combine!==void 0){let h=e.combine;if(typeof h!="string"){let P={instancePath:t+"/combine",schemaPath:"#/properties/combine/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="max"||h==="min"||h==="multiply"||h==="add")){let P={instancePath:t+"/combine",schemaPath:"#/properties/combine/enum",keyword:"enum",params:{allowedValues:Rs.properties.combine.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.channel!==void 0){let h=e.channel;if(typeof h!="string"){let P={instancePath:t+"/channel",schemaPath:"#/properties/channel/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="red"||h==="green"||h==="blue"||h==="alpha")){let P={instancePath:t+"/channel",schemaPath:"#/properties/channel/enum",keyword:"enum",params:{allowedValues:Rs.properties.channel.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.softness!==void 0&&typeof e.softness!="number"){let h={instancePath:t+"/softness",schemaPath:"#/properties/softness/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[h]:r.push(h),n++}if(e.invert!==void 0&&typeof e.invert!="boolean"){let h={instancePath:t+"/invert",schemaPath:"#/properties/invert/type",keyword:"type",params:{type:"boolean"},message:"must be boolean"};r===null?r=[h]:r.push(h),n++}if(e.sample!==void 0&&typeof e.sample!="string"){let h={instancePath:t+"/sample",schemaPath:"#/properties/sample/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}e.progress!==void 0&&(ri(e.progress,{instancePath:t+"/progress",parentData:e,parentDataProperty:"progress",rootData:a})||(r=r===null?ri.errors:r.concat(ri.errors),n=r.length))}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}return ti.errors=r,n===0}function ni(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let h={};r===null?r=[h]:r.push(h),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let h=n,P=n,k=n,E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),n++}}var p=O===n;if(v=v||p,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),n++}}var p=$===n;if(v=v||p,!v){let B=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let G;if(e.mask===void 0&&(G="mask")){let fe={};r===null?r=[fe]:r.push(fe),n++}}var p=B===n;v=v||p}}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={};r===null?r=[$]:r.push($),n++}var d=k===n;if(d){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let $={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[$]:r.push($),n++}var u=h===n;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),n++}let f=n,m=!0,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let h={};r===null?r=[h]:r.push(h),n++}var b=g===n;if(n=f,r!==null&&(f?r.length=f:r=null),b){let h=n,P=n,k=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),n++}}var y=k===n;if(y){let $={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);let E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[$]:r.push($),n++}var w=O===n;if(v=v||w,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),n++}var w=$===n;if(v=v||w,!v){let B=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.mask===void 0){let G={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/2/required",keyword:"required",params:{missingProperty:"mask"},message:"must have required property 'mask'"};r===null?r=[G]:r.push(G),n++}var w=B===n;v=v||w}}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[$]:r.push($),n++}var b=h===n;m=b}if(!m){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),n++}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),n++}for(let h in e)if(!(h==="name"||h==="type"||h==="complete"||h==="tween"||h==="prev"||h==="next"||h==="mask")){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.name!==void 0&&typeof e.name!="string"){let h={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(e.type!==void 0){let h=e.type;if(typeof h!="string"){let P={instancePath:t+"/type",schemaPath:"#/properties/type/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[P]:r.push(P),n++}if(!(h==="update"||h==="transition")){let P={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:xv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}if(e.complete!==void 0){let h=e.complete;if(h&&typeof h=="object"&&!Array.isArray(h)){if(h.payload!==void 0){let P=h.payload;if(!(P&&typeof P=="object"&&!Array.isArray(P))){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),n++}}}else{let P={instancePath:t+"/complete",schemaPath:"#/properties/complete/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[P]:r.push(P),n++}}e.tween!==void 0&&(Qs(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?Qs.errors:r.concat(Qs.errors),n=r.length)),e.prev!==void 0&&(st(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?st.errors:r.concat(st.errors),n=r.length)),e.next!==void 0&&(st(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?st.errors:r.concat(st.errors),n=r.length)),e.mask!==void 0&&(ti(e.mask,{instancePath:t+"/mask",parentData:e,parentDataProperty:"mask",rootData:a})||(r=r===null?ti.errors:r.concat(ti.errors),n=r.length))}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}return ni.errors=r,n===0}function Qf(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return ni(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?ni.errors:r.concat(ni.errors),n=r.length),Qf.errors=r,n===0}var Zf=em;var Rv={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:{oneOf:[{type:"object",required:["duration"],properties:{initialValue:{type:"number",minimum:0,maximum:100},delay:{type:"number",minimum:0},duration:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"}},additionalProperties:!1},{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/fadeKeyframe"}}},additionalProperties:!1}]},transitionSide:{type:"object",minProperties:1,properties:{fade:{$ref:"#/$defs/fade"}},additionalProperties:!1},keyframeValue:{type:"number"},keyframe:{type:"object",required:["value","duration"],properties:{startValue:{type:"number"},value:{$ref:"#/$defs/keyframeValue"},duration:{type:"number",minimum:0},delay:{type:"number",minimum:0},easing:{$ref:"#/$defs/easing"},relative:{type:"boolean"}},additionalProperties:!1},boundedKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0,maximum:100}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0,maximum:100}}}}]},fadeKeyframe:{allOf:[{$ref:"#/$defs/boundedKeyframe"},{not:{properties:{relative:{const:!0}},required:["relative"]}}]},panKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:-1,maximum:1}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:-1,maximum:1}}}}]},playbackRateKeyframe:{allOf:[{$ref:"#/$defs/keyframe"},{if:{properties:{value:{type:"number"},relative:{const:!1}},required:["value"]},then:{properties:{value:{minimum:0}}}},{if:{properties:{relative:{const:!1}}},then:{properties:{startValue:{minimum:0}}}}]},volumeTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0,maximum:100},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/boundedKeyframe"}}},additionalProperties:!1},panTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:-1,maximum:1},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/panKeyframe"}}},additionalProperties:!1},playbackRateTweenProperty:{type:"object",required:["keyframes"],properties:{initialValue:{type:"number",minimum:0},keyframes:{type:"array",minItems:1,items:{$ref:"#/$defs/playbackRateKeyframe"}}},additionalProperties:!1},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 si(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(typeof e!="number"){let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[i]:r.push(i),n++}return si.errors=r,n===0}var $v={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 at(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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:$v.enum},message:"must be equal to one of the allowed values"};r===null?r=[i]:r.push(i),n++}return at.errors=r,n===0}function cr(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}if(e.value!==void 0&&(si(e.value,{instancePath:t+"/value",parentData:e,parentDataProperty:"value",rootData:a})||(r=r===null?si.errors:r.concat(si.errors),n=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),n++}}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),n++}}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),n++}}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),n++}}if(e.easing!==void 0&&(at(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?at.errors:r.concat(at.errors),n=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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return cr.errors=r,n===0}function lt(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;cr(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),n=r.length);let i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let h={};r===null?r=[h]:r.push(h),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),p){let b=n;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 h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),n++}if(w<0||isNaN(w)){let h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}}var p=b===n;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let d=n,f=!0,m=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),n++}var g=m===n;if(n=d,r!==null&&(d?r.length=d:r=null),g){let b=n;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 h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[h]:r.push(h),n++}if(w<0||isNaN(w)){let h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}}var g=b===n;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}return lt.errors=r,n===0}function ii(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>100||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[l]:r.push(l),n++}if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}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),n++}let l=i.length;for(let c=0;c<l;c++)lt(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?lt.errors:r.concat(lt.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ii.errors=r,n===0}function oi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;cr(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),n=r.length);let i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let h={};r===null?r=[h]:r.push(h),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),p){let b=n;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 h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),n++}if(w<-1||isNaN(w)){let h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),n++}}}var p=b===n;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let d=n,f=!0,m=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),n++}var g=m===n;if(n=d,r!==null&&(d?r.length=d:r=null),g){let b=n;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 h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[h]:r.push(h),n++}if(w<-1||isNaN(w)){let h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[h]:r.push(h),n++}}}var g=b===n;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}return oi.errors=r,n===0}function ai(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i>1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:1},message:"must be <= 1"};r===null?r=[l]:r.push(l),n++}if(i<-1||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:-1},message:"must be >= -1"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}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),n++}let l=i.length;for(let c=0;c<l;c++)oi(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?oi.errors:r.concat(oi.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ai.errors=r,n===0}function li(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;cr(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?cr.errors:r.concat(cr.errors),n=r.length);let i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let b;if(e.value===void 0&&(b="value")){let y={};r===null?r=[y]:r.push(y),n++}else{if(e.value!==void 0){let y=n;if(typeof e.value!="number"){let w={};r===null?r=[w]:r.push(w),n++}var u=y===n}else var u=!0;if(u)if(e.relative!==void 0){let y=n;if(e.relative!==!1){let h={};r===null?r=[h]:r.push(h),n++}var u=y===n}else var u=!0}}var p=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),p){let b=n;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 h={instancePath:t+"/value",schemaPath:"#/allOf/1/then/properties/value/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}var p=b===n;l=p}if(!l){let b={instancePath:t,schemaPath:"#/allOf/1/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}let d=n,f=!0,m=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.relative!==void 0&&e.relative!==!1){let b={};r===null?r=[b]:r.push(b),n++}var g=m===n;if(n=d,r!==null&&(d?r.length=d:r=null),g){let b=n;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 h={instancePath:t+"/startValue",schemaPath:"#/allOf/2/then/properties/startValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[h]:r.push(h),n++}}var g=b===n;f=g}if(!f){let b={instancePath:t,schemaPath:"#/allOf/2/if",keyword:"if",params:{failingKeyword:"then"},message:'must match "then" schema'};r===null?r=[b]:r.push(b),n++}return li.errors=r,n===0}function ci(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.initialValue!==void 0){let i=e.initialValue;if(typeof i=="number"){if(i<0||isNaN(i)){let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[l]:r.push(l),n++}}else{let l={instancePath:t+"/initialValue",schemaPath:"#/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[l]:r.push(l),n++}}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),n++}let l=i.length;for(let c=0;c<l;c++)li(i[c],{instancePath:t+"/keyframes/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?li.errors:r.concat(li.errors),n=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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ci.errors=r,n===0}function ui(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.volume!==void 0&&(ii(e.volume,{instancePath:t+"/volume",parentData:e,parentDataProperty:"volume",rootData:a})||(r=r===null?ii.errors:r.concat(ii.errors),n=r.length)),e.pan!==void 0&&(ai(e.pan,{instancePath:t+"/pan",parentData:e,parentDataProperty:"pan",rootData:a})||(r=r===null?ai.errors:r.concat(ai.errors),n=r.length)),e.playbackRate!==void 0&&(ci(e.playbackRate,{instancePath:t+"/playbackRate",parentData:e,parentDataProperty:"playbackRate",rootData:a})||(r=r===null?ci.errors:r.concat(ci.errors),n=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),n++}return ui.errors=r,n===0}function pi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;lt(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?lt.errors:r.concat(lt.errors),n=r.length);let i=n,l=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let u;if(e.relative===void 0&&(u="relative")){let p={};r===null?r=[p]:r.push(p),n++}else if(e.relative!==void 0&&e.relative!==!0){let p={};r===null?r=[p]:r.push(p),n++}}var c=l===n;if(c){let u={instancePath:t,schemaPath:"#/allOf/1/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[u]:r.push(u),n++}else n=i,r!==null&&(i?r.length=i:r=null);return pi.errors=r,n===0}function fi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=null,u=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.duration===void 0){let f={instancePath:t,schemaPath:"#/oneOf/0/required",keyword:"required",params:{missingProperty:"duration"},message:"must have required property 'duration'"};r===null?r=[f]:r.push(f),n++}for(let f in e)if(!(f==="initialValue"||f==="delay"||f==="duration"||f==="easing")){let m={instancePath:t,schemaPath:"#/oneOf/0/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(e.initialValue!==void 0){let f=e.initialValue;if(typeof f=="number"){if(f>100||isNaN(f)){let m={instancePath:t+"/initialValue",schemaPath:"#/oneOf/0/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[m]:r.push(m),n++}if(f<0||isNaN(f)){let m={instancePath:t+"/initialValue",schemaPath:"#/oneOf/0/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),n++}}else{let m={instancePath:t+"/initialValue",schemaPath:"#/oneOf/0/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),n++}}if(e.delay!==void 0){let f=e.delay;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/delay",schemaPath:"#/oneOf/0/properties/delay/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),n++}}else{let m={instancePath:t+"/delay",schemaPath:"#/oneOf/0/properties/delay/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),n++}}if(e.duration!==void 0){let f=e.duration;if(typeof f=="number"){if(f<0||isNaN(f)){let m={instancePath:t+"/duration",schemaPath:"#/oneOf/0/properties/duration/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),n++}}else{let m={instancePath:t+"/duration",schemaPath:"#/oneOf/0/properties/duration/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),n++}}e.easing!==void 0&&(at(e.easing,{instancePath:t+"/easing",parentData:e,parentDataProperty:"easing",rootData:a})||(r=r===null?at.errors:r.concat(at.errors),n=r.length))}else{let f={instancePath:t,schemaPath:"#/oneOf/0/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}var d=u===n;d&&(l=!0,c=0);let p=n;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.keyframes===void 0){let f={instancePath:t,schemaPath:"#/oneOf/1/required",keyword:"required",params:{missingProperty:"keyframes"},message:"must have required property 'keyframes'"};r===null?r=[f]:r.push(f),n++}for(let f in e)if(!(f==="initialValue"||f==="keyframes")){let m={instancePath:t,schemaPath:"#/oneOf/1/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:f},message:"must NOT have additional properties"};r===null?r=[m]:r.push(m),n++}if(e.initialValue!==void 0){let f=e.initialValue;if(typeof f=="number"){if(f>100||isNaN(f)){let m={instancePath:t+"/initialValue",schemaPath:"#/oneOf/1/properties/initialValue/maximum",keyword:"maximum",params:{comparison:"<=",limit:100},message:"must be <= 100"};r===null?r=[m]:r.push(m),n++}if(f<0||isNaN(f)){let m={instancePath:t+"/initialValue",schemaPath:"#/oneOf/1/properties/initialValue/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[m]:r.push(m),n++}}else{let m={instancePath:t+"/initialValue",schemaPath:"#/oneOf/1/properties/initialValue/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[m]:r.push(m),n++}}if(e.keyframes!==void 0){let f=e.keyframes;if(Array.isArray(f)){if(f.length<1){let g={instancePath:t+"/keyframes",schemaPath:"#/oneOf/1/properties/keyframes/minItems",keyword:"minItems",params:{limit:1},message:"must NOT have fewer than 1 items"};r===null?r=[g]:r.push(g),n++}let m=f.length;for(let g=0;g<m;g++)pi(f[g],{instancePath:t+"/keyframes/"+g,parentData:f,parentDataProperty:g,rootData:a})||(r=r===null?pi.errors:r.concat(pi.errors),n=r.length)}else{let m={instancePath:t+"/keyframes",schemaPath:"#/oneOf/1/properties/keyframes/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[m]:r.push(m),n++}}}else{let f={instancePath:t,schemaPath:"#/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[f]:r.push(f),n++}var d=p===n;if(d&&l?(l=!1,c=[c,1]):d&&(l=!0,c=1),l)n=i,r!==null&&(i?r.length=i:r=null);else{let f={instancePath:t,schemaPath:"#/oneOf",keyword:"oneOf",params:{passingSchemas:c},message:"must match exactly one schema in oneOf"};r===null?r=[f]:r.push(f),n++}return fi.errors=r,n===0}function it(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}e.fade!==void 0&&(fi(e.fade,{instancePath:t+"/fade",parentData:e,parentDataProperty:"fade",rootData:a})||(r=r===null?fi.errors:r.concat(fi.errors),n=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),n++}return it.errors=r,n===0}function mi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!0,c=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="update"){let h={};r===null?r=[h]:r.push(h),n++}var u=c===n;if(n=i,r!==null&&(i?r.length=i:r=null),u){let h=n,P=n,k=n,E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.prev===void 0&&($="prev")){let D={};r===null?r=[D]:r.push(D),n++}}var p=O===n;if(v=v||p,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let B;if(e.next===void 0&&(B="next")){let _={};r===null?r=[_]:r.push(_),n++}}var p=$===n;v=v||p}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={};r===null?r=[$]:r.push($),n++}var d=k===n;if(d){let $={instancePath:t,schemaPath:"#/allOf/0/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);if(e&&typeof e=="object"&&!Array.isArray(e)&&e.tween===void 0){let $={instancePath:t,schemaPath:"#/allOf/0/then/required",keyword:"required",params:{missingProperty:"tween"},message:"must have required property 'tween'"};r===null?r=[$]:r.push($),n++}var u=h===n;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),n++}let f=n,m=!0,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.type!==void 0&&e.type!=="transition"){let h={};r===null?r=[h]:r.push(h),n++}var b=g===n;if(n=f,r!==null&&(f?r.length=f:r=null),b){let h=n,P=n,k=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let $;if(e.tween===void 0&&($="tween")){let D={};r===null?r=[D]:r.push(D),n++}}var y=k===n;if(y){let $={instancePath:t,schemaPath:"#/allOf/1/then/not",keyword:"not",params:{},message:"must NOT be valid"};r===null?r=[$]:r.push($),n++}else n=P,r!==null&&(P?r.length=P:r=null);let E=n,v=!1,O=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.prev===void 0){let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/0/required",keyword:"required",params:{missingProperty:"prev"},message:"must have required property 'prev'"};r===null?r=[$]:r.push($),n++}var w=O===n;if(v=v||w,!v){let $=n;if(e&&typeof e=="object"&&!Array.isArray(e)&&e.next===void 0){let B={instancePath:t,schemaPath:"#/allOf/1/then/anyOf/1/required",keyword:"required",params:{missingProperty:"next"},message:"must have required property 'next'"};r===null?r=[B]:r.push(B),n++}var w=$===n;v=v||w}if(v)n=E,r!==null&&(E?r.length=E:r=null);else{let $={instancePath:t,schemaPath:"#/allOf/1/then/anyOf",keyword:"anyOf",params:{},message:"must match a schema in anyOf"};r===null?r=[$]:r.push($),n++}var b=h===n;m=b}if(!m){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),n++}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),n++}for(let h in e)if(!(h==="name"||h==="type"||h==="tween"||h==="prev"||h==="next")){let P={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:h},message:"must NOT have additional properties"};r===null?r=[P]:r.push(P),n++}if(e.name!==void 0&&typeof e.name!="string"){let h={instancePath:t+"/name",schemaPath:"#/properties/name/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}if(e.type!==void 0){let h=e.type;if(!(h==="update"||h==="transition")){let P={instancePath:t+"/type",schemaPath:"#/properties/type/enum",keyword:"enum",params:{allowedValues:Rv.properties.type.enum},message:"must be equal to one of the allowed values"};r===null?r=[P]:r.push(P),n++}}e.tween!==void 0&&(ui(e.tween,{instancePath:t+"/tween",parentData:e,parentDataProperty:"tween",rootData:a})||(r=r===null?ui.errors:r.concat(ui.errors),n=r.length)),e.prev!==void 0&&(it(e.prev,{instancePath:t+"/prev",parentData:e,parentDataProperty:"prev",rootData:a})||(r=r===null?it.errors:r.concat(it.errors),n=r.length)),e.next!==void 0&&(it(e.next,{instancePath:t+"/next",parentData:e,parentDataProperty:"next",rootData:a})||(r=r===null?it.errors:r.concat(it.errors),n=r.length))}else{let h={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[h]:r.push(h),n++}return mi.errors=r,n===0}function em(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return mi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?mi.errors:r.concat(mi.errors),n=r.length),em.errors=r,n===0}var rm=tm;function di(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.nameVariableId!==void 0){let i=e.nameVariableId;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return di.errors=r,n===0}function tm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return di(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?di.errors:r.concat(di.errors),n=r.length),tm.errors=r,n===0}var nm=sm;var Cv=new RegExp("^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$","u");function yi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}if(e.hex!==void 0){let i=e.hex;if(typeof i=="string"){if(!Cv.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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return yi.errors=r,n===0}function sm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return yi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?yi.errors:r.concat(yi.errors),n=r.length),sm.errors=r,n===0}var im=om;function hi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}}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),n++}}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 d={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=[d]:r.push(d),n++}}}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),n++}}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 d={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=[d]:r.push(d),n++}}}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),n++}}}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),n++}}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),n++}}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),n++}}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),n++}}}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),n++}}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),n++}}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),n++}}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return hi.errors=r,n===0}function om(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return hi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?hi.errors:r.concat(hi.errors),n=r.length),om.errors=r,n===0}var am=lm;function gi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return gi.errors=r,n===0}function lm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return gi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?gi.errors:r.concat(gi.errors),n=r.length),lm.errors=r,n===0}var cm=um;function bi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return bi.errors=r,n===0}function um(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return bi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?bi.errors:r.concat(bi.errors),n=r.length),um.errors=r,n===0}var pm=fm;function wi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}if(e.type===void 0){let i={instancePath:t,schemaPath:"#/required",keyword:"required",params:{missingProperty:"type"},message:"must have required property 'type'"};r===null?r=[i]:r.push(i),n++}if(e.id!==void 0){let i=e.id;if(typeof i=="string"){if(Oe(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),n++}}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),n++}}if(e.type!==void 0&&e.type!=="shader"){let i={instancePath:t+"/type",schemaPath:"#/properties/type/const",keyword:"const",params:{allowedValue:"shader"},message:"must be equal to constant"};r===null?r=[i]:r.push(i),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return wi.errors=r,n===0}var If=new RegExp("^\\$(if .+|for .+|else)$","u"),Ba={validate:gn};function Ii(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}for(let i in e)if(!If.test(i)){let l={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:i},message:"must NOT have additional properties"};r===null?r=[l]:r.push(l),n++}for(let i in e)if(If.test(i)){let l=e[i];if(Array.isArray(l)){let c=l.length;for(let u=0;u<c;u++)Ba.validate(l[u],{instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1")+"/"+u,parentData:l,parentDataProperty:u,rootData:a})||(r=r===null?Ba.validate.errors:r.concat(Ba.validate.errors),n=r.length)}else{let c={instancePath:t+"/"+i.replace(/~/g,"~0").replace(/\//g,"~1"),schemaPath:"#/patternProperties/%5E%5C%24(if%20.%2B%7Cfor%20.%2B%7Celse)%24/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[c]:r.push(c),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ii.errors=r,n===0}function gn(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=n;wi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?wi.errors:r.concat(wi.errors),n=r.length);var u=c===n;if(l=l||u,!l){let p=n;Ii(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ii.errors:r.concat(Ii.errors),n=r.length);var u=p===n;l=l||u}if(l)n=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),n++}return gn.errors=r,n===0}function vi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(Array.isArray(e)){let i=e.length;for(let l=0;l<i;l++)gn(e[l],{instancePath:t+"/"+l,parentData:e,parentDataProperty:l,rootData:a})||(r=r===null?gn.errors:r.concat(gn.errors),n=r.length)}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[i]:r.push(i),n++}return vi.errors=r,n===0}var Ua={validate:bn};function bn(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){if(e.filters!==void 0&&(vi(e.filters,{instancePath:t+"/filters",parentData:e,parentDataProperty:"filters",rootData:a})||(r=r===null?vi.errors:r.concat(vi.errors),n=r.length)),e.children!==void 0){let i=e.children;if(Array.isArray(i)){let l=i.length;for(let c=0;c<l;c++)Ua.validate(i[c],{instancePath:t+"/children/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?Ua.validate.errors:r.concat(Ua.validate.errors),n=r.length)}else{let l={instancePath:t+"/children",schemaPath:"#/properties/children/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return bn.errors=r,n===0}function ki(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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++)bn(i[c],{instancePath:t+"/elements/"+c,parentData:i,parentDataProperty:c,rootData:a})||(r=r===null?bn.errors:r.concat(bn.errors),n=r.length)}else{let l={instancePath:t+"/elements",schemaPath:"#/properties/elements/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[l]:r.push(l),n++}}if(e.transitions!==void 0){let i={instancePath:t+"/transitions",schemaPath:"#/properties/transitions/false schema",keyword:"false schema",params:{},message:"boolean schema is false"};r===null?r=[i]:r.push(i),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return ki.errors=r,n===0}function fm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return ki(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?ki.errors:r.concat(ki.errors),n=r.length),fm.errors=r,n===0}var mm=dm;function Ai(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0,i=n,l=!1,c=null,u=n,p=n,d=n,f=n,m=!1,g=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let k;if(e.count===void 0&&(k="count")){let E={};r===null?r=[E]:r.push(E),n++}}var b=g===n;if(m=m||b,!m){let k=n;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),n++}}var b=k===n;if(m=m||b,!m){let v=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let T;if(e.behaviors===void 0&&(T="behaviors")){let $={};r===null?r=[$]:r.push($),n++}}var b=v===n;if(m=m||b,!m){let T=n;if(e&&typeof e=="object"&&!Array.isArray(e)){let D;if(e.emitter===void 0&&(D="emitter")){let B={};r===null?r=[B]:r.push(B),n++}}var b=T===n;m=m||b}}}if(m)n=f,r!==null&&(f?r.length=f:r=null);else{let k={};r===null?r=[k]:r.push(k),n++}var y=d===n;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),n++}else n=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),n++}var h=u===n;h&&(l=!0,c=0);let w=n;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),n++}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),n++}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),n++}}var h=w===n;if(h&&l?(l=!1,c=[c,1]):h&&(l=!0,c=1),l)n=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),n++}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),n++}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),n++}for(let k in e)if(!(k==="width"||k==="height"||k==="seed"||k==="modules"||k==="count"||k==="texture"||k==="behaviors"||k==="emitter")){let E={instancePath:t,schemaPath:"#/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:k},message:"must NOT have additional properties"};r===null?r=[E]:r.push(E),n++}if(e.width!==void 0){let k=e.width;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/width",schemaPath:"#/properties/width/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),n++}}else{let E={instancePath:t+"/width",schemaPath:"#/properties/width/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),n++}}if(e.height!==void 0){let k=e.height;if(typeof k=="number"){if(k<=0||isNaN(k)){let E={instancePath:t+"/height",schemaPath:"#/properties/height/exclusiveMinimum",keyword:"exclusiveMinimum",params:{comparison:">",limit:0},message:"must be > 0"};r===null?r=[E]:r.push(E),n++}}else{let E={instancePath:t+"/height",schemaPath:"#/properties/height/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[E]:r.push(E),n++}}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),n++}if(e.modules!==void 0){let k=e.modules;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.emission===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"emission"},message:"must have required property 'emission'"};r===null?r=[E]:r.push(E),n++}if(k.appearance===void 0){let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/required",keyword:"required",params:{missingProperty:"appearance"},message:"must have required property 'appearance'"};r===null?r=[E]:r.push(E),n++}for(let E in k)if(!(E==="emission"||E==="movement"||E==="appearance"||E==="bounds")){let v={instancePath:t+"/modules",schemaPath:"#/properties/modules/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:E},message:"must NOT have additional properties"};r===null?r=[v]:r.push(v),n++}if(k.emission!==void 0){let E=k.emission;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/emission",schemaPath:"#/properties/modules/properties/emission/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}if(k.movement!==void 0){let E=k.movement;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/movement",schemaPath:"#/properties/modules/properties/movement/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}if(k.appearance!==void 0){let E=k.appearance;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/appearance",schemaPath:"#/properties/modules/properties/appearance/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}if(k.bounds!==void 0){let E=k.bounds;if(!(E&&typeof E=="object"&&!Array.isArray(E))){let v={instancePath:t+"/modules/bounds",schemaPath:"#/properties/modules/properties/bounds/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[v]:r.push(v),n++}}}else{let E={instancePath:t+"/modules",schemaPath:"#/properties/modules/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),n++}}if(e.count!==void 0){let k=e.count;if(!(typeof k=="number"&&!(k%1)&&!isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/type",keyword:"type",params:{type:"integer"},message:"must be integer"};r===null?r=[E]:r.push(E),n++}if(typeof k=="number"&&(k<1||isNaN(k))){let E={instancePath:t+"/count",schemaPath:"#/properties/count/minimum",keyword:"minimum",params:{comparison:">=",limit:1},message:"must be >= 1"};r===null?r=[E]:r.push(E),n++}}if(e.texture!==void 0){let k=e.texture,E=n,v=!1,O=null,T=n;if(typeof k=="string"){if(Oe(k)<1){let D={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=[D]:r.push(D),n++}}else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/0/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[D]:r.push(D),n++}var P=T===n;P&&(v=!0,O=0);let $=n;if(!(k&&typeof k=="object"&&!Array.isArray(k))){let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf/1/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[D]:r.push(D),n++}var P=$===n;if(P&&v?(v=!1,O=[O,1]):P&&(v=!0,O=1),v)n=E,r!==null&&(E?r.length=E:r=null);else{let D={instancePath:t+"/texture",schemaPath:"#/properties/texture/oneOf",keyword:"oneOf",params:{passingSchemas:O},message:"must match exactly one schema in oneOf"};r===null?r=[D]:r.push(D),n++}}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),n++}let E=k.length;for(let v=0;v<E;v++){let O=k[v];if(O&&typeof O=="object"&&!Array.isArray(O)){if(O.type===void 0){let 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),n++}for(let T in O)if(!(T==="type"||T==="config")){let $={instancePath:t+"/behaviors/"+v,schemaPath:"#/properties/behaviors/items/additionalProperties",keyword:"additionalProperties",params:{additionalProperty:T},message:"must NOT have additional properties"};r===null?r=[$]:r.push($),n++}if(O.type!==void 0){let T=O.type;if(typeof T=="string"){if(Oe(T)<1){let $={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.push($),n++}}else{let $={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.push($),n++}}if(O.config!==void 0){let T=O.config;if(!(T&&typeof T=="object"&&!Array.isArray(T))){let $={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.push($),n++}}}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),n++}}}else{let E={instancePath:t+"/behaviors",schemaPath:"#/properties/behaviors/type",keyword:"type",params:{type:"array"},message:"must be array"};r===null?r=[E]:r.push(E),n++}}if(e.emitter!==void 0){let k=e.emitter;if(k&&typeof k=="object"&&!Array.isArray(k)){if(k.lifetime===void 0){let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/required",keyword:"required",params:{missingProperty:"lifetime"},message:"must have required property 'lifetime'"};r===null?r=[E]:r.push(E),n++}if(k.lifetime!==void 0){let E=k.lifetime;if(E&&typeof E=="object"&&!Array.isArray(E)){if(E.min===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"min"},message:"must have required property 'min'"};r===null?r=[v]:r.push(v),n++}if(E.max===void 0){let v={instancePath:t+"/emitter/lifetime",schemaPath:"#/properties/emitter/properties/lifetime/required",keyword:"required",params:{missingProperty:"max"},message:"must have required property 'max'"};r===null?r=[v]:r.push(v),n++}if(E.min!==void 0){let v=E.min;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/min",schemaPath:"#/properties/emitter/properties/lifetime/properties/min/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),n++}}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),n++}}if(E.max!==void 0){let v=E.max;if(typeof v=="number"){if(v<0||isNaN(v)){let O={instancePath:t+"/emitter/lifetime/max",schemaPath:"#/properties/emitter/properties/lifetime/properties/max/minimum",keyword:"minimum",params:{comparison:">=",limit:0},message:"must be >= 0"};r===null?r=[O]:r.push(O),n++}}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),n++}}}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),n++}}}else{let E={instancePath:t+"/emitter",schemaPath:"#/properties/emitter/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[E]:r.push(E),n++}}}else{let k={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[k]:r.push(k),n++}return Ai.errors=r,n===0}function dm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ai(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ai.errors:r.concat(Ai.errors),n=r.length),dm.errors=r,n===0}var ym=hm;var vf={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 Pi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}for(let i in e)if(!Ke.call(vf.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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}}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:vf.properties.endAt.type},message:"must be number,null"};r===null?r=[l]:r.push(l),n++}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Pi.errors=r,n===0}function hm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Pi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Pi.errors:r.concat(Pi.errors),n=r.length),hm.errors=r,n===0}var gm=bm;var _v=new RegExp("^.+$","u");function Ei(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}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),n++}}if(e.animations!==void 0){let i=e.animations;if(i&&typeof i=="object"&&!Array.isArray(i)){for(let l in i)if(_v.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),n++}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),n++}if(c.frames!==void 0){let u=c.frames;if(Array.isArray(u)){let p=u.length;for(let d=0;d<p;d++)if(typeof u[d]!="number"){let f={instancePath:t+"/animations/"+l.replace(/~/g,"~0").replace(/\//g,"~1")+"/frames/"+d,schemaPath:"#/properties/animations/patternProperties/%5E.%2B%24/properties/frames/items/type",keyword:"type",params:{type:"number"},message:"must be number"};r===null?r=[f]:r.push(f),n++}}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),n++}}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),n++}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),n++}}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),n++}}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Ei.errors=r,n===0}function bm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Ei(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Ei.errors:r.concat(Ei.errors),n=r.length),bm.errors=r,n===0}var wm=Im;var kf={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 xi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}for(let l in e)if(!Ke.call(kf.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),n++}if(e.fontId!==void 0){let l=e.fontId,c=n,u=!1,p=null,d=n;if(typeof l=="string"){if(Oe(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),n++}}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),n++}var i=d===n;i&&(u=!0,p=0);let f=n;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),n++}let m=l.length;for(let y=0;y<m;y++){let w=l[y];if(typeof w=="string"){if(Oe(w)<1){let h={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=[h]:r.push(h),n++}}else{let h={instancePath:t+"/fontId/"+y,schemaPath:"#/properties/fontId/oneOf/1/items/type",keyword:"type",params:{type:"string"},message:"must be string"};r===null?r=[h]:r.push(h),n++}}let g=l.length,b;if(g>1){let y={};for(;g--;){let w=l[g];if(typeof w=="string"){if(typeof y[w]=="number"){b=y[w];let h={instancePath:t+"/fontId",schemaPath:"#/properties/fontId/oneOf/1/uniqueItems",keyword:"uniqueItems",params:{i:g,j:b},message:"must NOT have duplicate items (items ## "+b+" and "+g+" are identical)"};r===null?r=[h]:r.push(h),n++;break}y[w]=g}}}}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),n++}var i=f===n;if(i&&u?(u=!1,p=[p,1]):i&&(u=!0,p=1),u)n=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),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}if(!(l==="normal"||l==="italic"||l==="oblique")){let c={instancePath:t+"/fontStyle",schemaPath:"#/properties/fontStyle/enum",keyword:"enum",params:{allowedValues:kf.properties.fontStyle.enum},message:"must be equal to one of the allowed values"};r===null?r=[c]:r.push(c),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}if(l.colorId!==void 0){let c=l.colorId;if(typeof c=="string"){if(Oe(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),n++}}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),n++}}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),n++}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),n++}}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),n++}}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),n++}}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),n++}}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),n++}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),n++}}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),n++}}}else{let l={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[l]:r.push(l),n++}return xi.errors=r,n===0}function Im(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return xi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?xi.errors:r.concat(xi.errors),n=r.length),Im.errors=r,n===0}var vm=km;var Nv={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 Si(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;if(e&&typeof e=="object"&&!Array.isArray(e)){for(let i in e)if(!Ke.call(Nv.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),n++}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),n++}}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),n++}}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Si.errors=r,n===0}function km(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Si(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Si.errors:r.concat(Si.errors),n=r.length),km.errors=r,n===0}var Am=Pm;function Oi(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}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),n++}}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),n++}}}else{let i={instancePath:t,schemaPath:"#/type",keyword:"type",params:{type:"object"},message:"must be object"};r===null?r=[i]:r.push(i),n++}return Oi.errors=r,n===0}function Pm(e,{instancePath:t="",parentData:s,parentDataProperty:o,rootData:a=e}={}){let r=null,n=0;return Oi(e,{instancePath:t,parentData:s,parentDataProperty:o,rootData:a})||(r=r===null?Oi.errors:r.concat(Oi.errors),n=r.length),Pm.errors=r,n===0}var vn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),In=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),kr=e=>e===void 0?void 0:structuredClone(e),jv=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"}),Dv=new Set(["background","bgm","character","choice","cleanAll","control","dialogue","form","layout","screen","sfx","visual","voice"]),Tv=Object.freeze({background:Af,bgm:Ef,character:Sf,choice:Rf,cleanAll:Cf,control:Nf,dialogue:Df,form:Lf,layout:Vf,screen:Ff,sfx:Uf,visual:zf,voice:Gf}),Lv=Object.freeze({achievement:Kf,animation:Jf,audioEffect:Zf,character:rm,color:nm,control:im,font:am,image:cm,layout:pm,particle:mm,sound:ym,spritesheet:gm,textStyle:wm,transform:vm,video:Am}),Mv=new Set(["files","language","patches"]),Vv=new Set(["actionType","ignoreFields","lineId","mode","payload","type"]),qv=new Set(["lineId","mode","payload","type"]),Fv=new Set(["mode","payload","sceneId","type"]),Bv=new Set(["mode","operation","payload","resourceId","type"]),Uv=new Set(["fileId","mimeType"]),H=(e,t)=>{throw new Error(`Invalid l10nData at ${e}: ${t}`)},rr=(e,t)=>{In(e)||H(t,"expected an object")},Ya=(e,t)=>{Array.isArray(e)||H(t,"expected an array")},jt=(e,t)=>{(typeof e!="string"||e.length===0)&&H(t,"expected a non-empty string")},Om=(e,t)=>{typeof e!="string"&&H(t,"expected a string")},pr=(e,t,s)=>{for(let o of Object.keys(e))t.has(o)||H(`${s}.${o}`,"unknown field")},fr=(e,t,s)=>{for(let o of t)vn(e,o)||H(s,`missing required field "${o}"`)},Yv=e=>e.replaceAll("~1","/").replaceAll("~0","~"),zv=(e,t)=>{let s=(t?.instancePath??"").split("/").slice(1).map(Yv);return t?.keyword==="required"?s.push(t.params.missingProperty):t?.keyword==="additionalProperties"&&s.push(t.params.additionalProperty),s.reduce((o,a)=>/^\d+$/.test(a)?`${o}[${a}]`:`${o}.${a}`,e)},Xv=(e=[])=>e.filter(t=>!["anyOf","if","not","oneOf"].includes(t.keyword)).reduce((t,s)=>{if(t===void 0)return s;let o=s.instancePath.split("/").length,a=t.instancePath.split("/").length;return o>a?s:t},void 0)??e[0],Rm=({value:e,validator:t,path:s,contract:o})=>{if(t(e))return;let a=Xv(t.errors);H(zv(s,a),`does not match ${o}: ${a?.message??"schema validation failed"}`)},Ri=(e,t,s=new WeakSet)=>{if(typeof e=="number"){Number.isFinite(e)||H(t,"expected a finite number");return}if(!(e===null||typeof e!="object"||s.has(e))){if(s.add(e),Array.isArray(e)){e.forEach((o,a)=>Ri(o,`${t}[${a}]`,s));return}Object.entries(e).forEach(([o,a])=>Ri(a,`${t}.${o}`,s))}},ur=(e,t)=>{e===""&&H(t,"expected a non-empty resourceId")},Gv=(e,t,s)=>{let o=(n,i)=>ur(n?.resourceId,`${i}.resourceId`),a=(n,i)=>(n??[]).forEach((l,c)=>ur(l?.resourceId,`${i}[${c}].resourceId`)),r=(n,i)=>{ur(n?.resourceId,`${i}.resourceId`),a(n?.sounds,`${i}.sounds`)};switch(e){case"background":ur(t.resourceId,`${s}.resourceId`),o(t.animations,`${s}.animations`);break;case"bgm":o(t.audioEffects,`${s}.audioEffects`),r(t,s);break;case"voice":r(t,s);break;case"sfx":a(t.items,`${s}.items`),(t.channels??[]).forEach((n,i)=>a(n?.sounds,`${s}.channels[${i}].sounds`));break;case"character":(t.items??[]).forEach((n,i)=>{(n.sprites??[]).forEach((l,c)=>ur(l?.resourceId,`${s}.items[${i}].sprites[${c}].resourceId`)),o(n.animations,`${s}.items[${i}].animations`)});break;case"choice":case"form":case"layout":ur(t.resourceId,`${s}.resourceId`),o(t.animations,`${s}.animations`);break;case"control":ur(t.resourceId,`${s}.resourceId`);break;case"dialogue":ur(t.ui?.resourceId,`${s}.ui.resourceId`),o(t.ui?.animations,`${s}.ui.animations`),(t.character?.sprite?.items??[]).forEach((n,i)=>ur(n?.resourceId,`${s}.character.sprite.items[${i}].resourceId`)),o(t.character?.sprite?.animations,`${s}.character.sprite.animations`);break;case"screen":o(t.animations,`${s}.animations`);break;case"visual":(t.items??[]).forEach((n,i)=>{ur(n?.resourceId,`${s}.items[${i}].resourceId`),o(n?.animations,`${s}.items[${i}].animations`)});break;default:break}},Dt=(e,t)=>{jt(e,t),(e==="__proto__"||e==="constructor"||e==="prototype")&&H(t,`"${e}" is not a safe ID`)},Hv=(e,t)=>{jt(e,t),(e==="."||e===".."||e.includes("/")||e.includes("\\")||e.includes("\0"))&&H(t,"must be a safe single filename")},wn=(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)=>wn(a,t[r]));if(!In(e)||!In(t))return!1;let s=Object.keys(e).sort(),o=Object.keys(t).sort();return wn(s,o)&&s.every(a=>wn(e[a],t[a]))},$i=(e,t=new Set,s=new WeakSet)=>{if(Array.isArray(e))return e.forEach(o=>$i(o,t,s)),t;if(!In(e)||s.has(e))return t;s.add(e);for(let[o,a]of Object.entries(e))o==="fileId"&&typeof a=="string"&&t.add(a),$i(a,t,s);return t},Kv=e=>{let t=new Map;for(let[s,o]of Object.entries(e?.story?.scenes??{}))for(let[a,r]of Object.entries(o?.sections??{}))for(let[n,i]of(r?.lines??[]).entries()){if(typeof i?.id!="string")continue;let l=t.get(i.id)??[];l.push({sceneId:s,sectionId:a,lineIndex:n,line:i}),t.set(i.id,l)}return t},$m=(e,t,s)=>{let o=e.get(t)??[];return o.length===0&&H(s,`lineId "${t}" does not exist in projectData`),o.length>1&&H(s,`lineId "${t}" is not globally unique in projectData`),o[0]},Cm=(e,t)=>e.story.scenes[t.sceneId].sections[t.sectionId].lines[t.lineIndex],Em=e=>({items:(e?.items??[]).map(t=>({id:t?.id,events:t?.events}))}),xm=e=>{let t=kr(e??{});delete t.resourceId,delete t.animations;for(let s of Object.values(t.fields??{}))In(s)&&delete s.placeholder;return t},Wv=(e,t,s,o)=>{e==="choice"&&!wn(Em(t),Em(s))&&H(o,"choice item IDs and events must remain identical to the source action"),e==="form"&&!wn(xm(t),xm(s))&&H(o,"form behavior must remain identical; only presentation fields and placeholders may change")},Jv=({patch:e,path:t,lineIndex:s})=>{pr(e,Vv,t),fr(e,["type","lineId","actionType","payload"],t),Dt(e.lineId,`${t}.lineId`),jt(e.actionType,`${t}.actionType`),rr(e.payload,`${t}.payload`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.action supports only "replace"'),Dv.has(e.actionType)||H(`${t}.actionType`,`"${e.actionType}" is not a localizable presentation action`);let o=$m(s,e.lineId,`${t}.lineId`),a=o.line?.actions?.[e.actionType];return a===void 0&&H(`${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")&&H(`${t}.ignoreFields`,'dialogue action replacement requires exactly ["content"]'),vn(e.payload,"content")&&H(`${t}.payload.content`,"dialogue content must use a separate line.dialogue patch")):e.ignoreFields!==void 0&&H(`${t}.ignoreFields`,"ignoreFields is supported only for dialogue actions"),Wv(e.actionType,a,e.payload,`${t}.payload`),Rm({value:e.payload,validator:Tv[e.actionType],path:`${t}.payload`,contract:`the ${e.actionType} presentation-action schema`}),Ri(e.payload,`${t}.payload`),Gv(e.actionType,e.payload,`${t}.payload`),{kind:"line.action",key:`line.action:${e.lineId}:${e.actionType}`,location:o,patch:e}},Qv=(e,t)=>{Ya(e,t),e.forEach((s,o)=>{rr(s,`${t}[${o}]`),pr(s,new Set(["text"]),`${t}[${o}]`),fr(s,["text"],`${t}[${o}]`),Om(s.text,`${t}[${o}].text`)})},Zv=({patch:e,path:t,lineIndex:s})=>{pr(e,qv,t),fr(e,["type","lineId","payload"],t),Dt(e.lineId,`${t}.lineId`),rr(e.payload,`${t}.payload`),pr(e.payload,new Set(["content"]),`${t}.payload`),fr(e.payload,["content"],`${t}.payload`),Qv(e.payload.content,`${t}.payload.content`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'line.dialogue supports only "replace"');let o=$m(s,e.lineId,`${t}.lineId`);return o.line?.actions?.dialogue===void 0&&H(`${t}.lineId`,`source line "${e.lineId}" does not contain a dialogue action`),{kind:"line.dialogue",key:`line.dialogue:${e.lineId}`,location:o,patch:e}},ek=({patch:e,path:t,projectData:s})=>(pr(e,Fv,t),fr(e,["type","mode","sceneId","payload"],t),Dt(e.sceneId,`${t}.sceneId`),rr(e.payload,`${t}.payload`),pr(e.payload,new Set(["name"]),`${t}.payload`),fr(e.payload,["name"],`${t}.payload`),Om(e.payload.name,`${t}.payload.name`),e.mode!=="patch"&&H(`${t}.mode`,'story.scene requires "patch"'),vn(s?.story?.scenes??{},e.sceneId)||H(`${t}.sceneId`,`sceneId "${e.sceneId}" does not exist`),{kind:"story.scene",key:`story.scene:${e.sceneId}`,patch:e}),rk=(e,t,s)=>{rr(t,s),["font","image","sound","spritesheet","video"].includes(e)&&jt(t.fileId,`${s}.fileId`),["image","video"].includes(e)&&(Number.isInteger(t.width)||H(`${s}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${s}.height`,"expected an integer")),e==="spritesheet"&&(rr(t.jsonData,`${s}.jsonData`),Number.isInteger(t.width)||H(`${s}.width`,"expected an integer"),Number.isInteger(t.height)||H(`${s}.height`,"expected an integer")),e==="color"&&(typeof t.hex!="string"||!/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t.hex))&&H(`${s}.hex`,"expected an opaque #RGB or #RRGGBB color"),Rm({value:t,validator:Lv[e],path:s,contract:`the resource.${e} schema`}),Ri(t,s)},tk=({patch:e,path:t,projectData:s,packageFileIds:o,canonicalFileIds:a})=>{pr(e,Bv,t),fr(e,["type","resourceId","payload"],t),Dt(e.resourceId,`${t}.resourceId`);let r=e.type.slice(9),n=jv[r];n||H(`${t}.type`,`unsupported resource patch type "${e.type}"`),e.mode!==void 0&&e.mode!=="replace"&&H(`${t}.mode`,'resource patches support only "replace"'),e.operation!==void 0&&e.operation!=="add"&&H(`${t}.operation`,'the only resource operation is "add"'),rk(r,e.payload,`${t}.payload`);let i=s?.resources?.[n]??{},l=vn(i,e.resourceId);e.operation==="add"&&l&&H(`${t}.resourceId`,`cannot add existing ${r} resource "${e.resourceId}"`),e.operation!=="add"&&!l&&H(`${t}.resourceId`,`cannot replace missing ${r} resource "${e.resourceId}"`);for(let c of $i(e.payload))!o.has(c)&&!a.has(c)&&H(`${t}.payload`,`fileId "${c}" is not declared by this package or the canonical project`);return{kind:"resource",key:`${e.type}:${e.resourceId}`,collectionName:n,path:t,patch:e}},Sm=({resources:e,collectionName:t,resourceId:s,path:o,label:a})=>{s!==void 0&&(typeof s!="string"||s.length===0||!vn(e?.[t]??{},s))&&H(o,`${a} resource "${s}" was not found`)},nk=(e,t)=>{let s=kr(e);for(let a of t.patches)a.kind==="resource"&&(s.resources[a.collectionName]??={},s.resources[a.collectionName][a.patch.resourceId]=kr(a.patch.payload));let o=s.resources??{};for(let a of t.patches){if(a.patch.type!=="resource.textStyle")continue;let r=a.patch.payload,n=Array.isArray(r.fontId)?r.fontId:[r.fontId];n.forEach((i,l)=>Sm({resources:o,collectionName:"fonts",resourceId:i,path:`${a.path}.payload.fontId${n.length>1?`[${l}]`:""}`,label:"font"}));for(let[i,l]of[["colorId",r.colorId],["strokeColorId",r.strokeColorId],["shadow.colorId",r.shadow?.colorId]])Sm({resources:o,collectionName:"colors",resourceId:l,path:`${a.path}.payload.${i}`,label:"color"})}},sk=({patch:e,path:t,projectData:s,lineIndex:o,packageFileIds:a,canonicalFileIds:r})=>{if(rr(e,t),jt(e.type,`${t}.type`),e.type==="line.action")return Jv({patch:e,path:t,lineIndex:o});if(e.type==="line.dialogue")return Zv({patch:e,path:t,lineIndex:o});if(e.type==="story.scene")return ek({patch:e,path:t,projectData:s});if(e.type.startsWith("resource."))return tk({patch:e,path:t,projectData:s,packageFileIds:a,canonicalFileIds:r});H(`${t}.type`,`unsupported patch type "${e.type}"`)},ik=(e,t)=>{Ya(e,t);let s=new Set;return e.forEach((o,a)=>{let r=`${t}[${a}]`;rr(o,r),pr(o,Uv,r),fr(o,["fileId"],r),Hv(o.fileId,`${r}.fileId`),o.mimeType!==void 0&&(typeof o.mimeType!="string"||o.mimeType.length===0)&&H(`${r}.mimeType`,"expected a non-empty string"),s.has(o.fileId)&&H(`${r}.fileId`,`duplicate fileId "${o.fileId}"`),s.add(o.fileId)}),s},ok=({packageId:e,packageData:t,path:s,projectData:o,lineIndex:a,canonicalFileIds:r})=>{rr(t,s),pr(t,Mv,s),fr(t,["language","files","patches"],s),jt(t.language,`${s}.language`);let n=ik(t.files,`${s}.files`);Ya(t.patches,`${s}.patches`);let i=new Set,l=t.patches.map((c,u)=>{let p=sk({patch:c,path:`${s}.patches[${u}]`,projectData:o,lineIndex:a,packageFileIds:n,canonicalFileIds:r});return i.has(p.key)&&H(`${s}.patches[${u}]`,`duplicate patch target "${p.key}"`),i.add(p.key),p});return{id:e,data:t,fileIds:n,patches:l}},_m=({projectData:e,l10nData:t})=>{if(t===void 0)return{packages:new Map};rr(t,"l10nData"),pr(t,new Set(["packages"]),"l10nData"),fr(t,["packages"],"l10nData"),rr(t.packages,"l10nData.packages");let s=Kv(e),o=$i(e?.resources??{}),a=new Map,r=new Map;for(let[n,i]of Object.entries(t.packages)){Dt(n,`l10nData.packages.${n}`);let l=ok({packageId:n,packageData:i,path:`l10nData.packages.${n}`,projectData:e,lineIndex:s,canonicalFileIds:o});for(let c of l.fileIds){o.has(c)&&H(`l10nData.packages.${n}.files`,`fileId "${c}" conflicts with a canonical project file`);let u=r.get(c);u!==void 0&&H(`l10nData.packages.${n}.files`,`fileId "${c}" is already declared by package "${u}"`),r.set(c,n)}nk(e,l),a.set(n,l)}return{packages:a}},ak=(e,t)=>{let{collectionName:s,patch:o}=t;e.resources[s]??={},e.resources[s][o.resourceId]=kr(o.payload)},lk=(e,t)=>{let{patch:s}=t,o=e.story.scenes[s.sceneId];o.name=s.payload.name},ck=(e,t)=>{let{location:s,patch:o}=t,a=Cm(e,s);if(o.actionType!=="dialogue"){a.actions[o.actionType]=kr(o.payload);return}let r=kr(s.line.actions.dialogue.content);a.actions.dialogue=kr(o.payload),r!==void 0&&(a.actions.dialogue.content=r)},uk=(e,t)=>{let{location:s,patch:o}=t,a=Cm(e,s);a.actions.dialogue.content=kr(o.payload.content)},Nm=({projectData:e,l10nData:t})=>{let s=_m({projectData:e,l10nData:t});return[{l10nId:null,language:null},...Array.from(s.packages.values(),o=>({l10nId:o.id,language:o.data.language}))]},Ci=({projectData:e,l10nData:t,l10nId:s=null})=>{let o=_m({projectData:e,l10nData:t});if(s!==null&&(Dt(s,"l10nId"),o.packages.has(s)||H("l10nId",`package "${s}" was not imported`)),s===null)return e;let a=kr(e),r=o.packages.get(s).patches;return r.filter(n=>n.kind==="resource").forEach(n=>ak(a,n)),r.filter(n=>n.kind==="story.scene").forEach(n=>lk(a,n)),r.filter(n=>n.kind==="line.action").forEach(n=>ck(a,n)),r.filter(n=>n.kind==="line.dialogue").forEach(n=>uk(a,n)),a};var za=Object.freeze({auto:1e3,skip:80,authored:1e3}),Pn=new Set(["startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),jm=new WeakMap,pk=new ArrayBuffer(8),Xa=new DataView(pk),fk=e=>{let t=jm.get(e);if(t)return t;let s={dispatchDepth:0};return jm.set(e,s),s},mk=e=>{if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},dk=(e,t)=>Object.keys(e).length===t.length&&t.every(o=>Object.prototype.hasOwnProperty.call(e,o)),qr=(e,t,s)=>{if(!mk(e)||!dk(e,t))throw new TypeError(`${s} has an invalid shape`)},kn=(e,t)=>{if(!Number.isSafeInteger(e)||e<0)throw new TypeError(`${t} must be a non-negative safe integer`)},An=(e,t)=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)throw new TypeError(`${t} must be a finite non-negative number`)},Dm=e=>{if(An(e,"duration"),e===0)return 0n;Xa.setFloat64(0,e,!1);let t=Xa.getUint32(0,!1),s=Xa.getUint32(4,!1),o=t>>>20&2047,a=BigInt(t&1048575)<<32n|BigInt(s);if(o===0)return a;let r=1n<<52n|a,n=o-1;return r<<BigInt(n)},yk=e=>structuredClone(e),Ga=(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,Ha=(e,t,s)=>{if(t===null)return null;if(e==="auto"){if(qr(t,["owner","delayMs","contentKey"],"auto timer"),qr(t.owner,["sessionId","lineEntryId"],"auto timer owner"),kn(t.owner.sessionId,"auto owner sessionId"),kn(t.owner.lineEntryId,"auto owner lineEntryId"),t.owner.lineEntryId!==s)throw new TypeError("auto owner lineEntryId must match schedule lineEntryId");if(An(t.delayMs,"auto delayMs"),typeof t.contentKey!="string")throw new TypeError("auto contentKey must be a string")}else if(e==="skip")qr(t,["owner","delayMs"],"skip timer"),qr(t.owner,["sessionId"],"skip timer owner"),kn(t.owner.sessionId,"skip owner sessionId"),An(t.delayMs,"skip delayMs");else{if(qr(t,["owner","delayMs","trigger"],"authored timer"),qr(t.owner,["lineEntryId"],"authored timer owner"),kn(t.owner.lineEntryId,"authored owner lineEntryId"),t.owner.lineEntryId!==s)throw new TypeError("authored owner lineEntryId must match schedule lineEntryId");if(An(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,...yk(t)}},hk=e=>{if(qr(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(kn(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}}qr(e.timers,["auto","skip","authored"],"playback schedule timers");let t={auto:Ha("auto",e.timers.auto,e.lineEntryId),skip:Ha("skip",e.timers.skip,e.lineEntryId),authored:Ha("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}},Ka=e=>({descriptor:e,remainingQuanta:Dm(e.delayMs)}),_i=["auto","skip","authored"],Tm=({ticker:e,dispatchAutomaticAttempt:t,classifyAutomaticAttemptError:s=()=>"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=fk(e),a=!0,r={},n={},i=null,l=null,c=null,u=null,p=!1,d=!1,f="legacy",m={auto:null,skip:null,authored:null},g={auto:null,skip:null,authored:null},b={auto:0,skip:0,authored:0},y=()=>_i.some(M=>m[M]),w=()=>{l=null,c=null},h=()=>{p||(p=!0,queueMicrotask(()=>{p=!1;let M=c;if(M){if(o.dispatchDepth>0||d){h();return}a&&r===M.lifecycleToken&&n===M.generationToken&&i===M.callback&&y()&&!u&&(l=M.registrationToken),c===M&&(c=null)}}))},P=()=>{if(!u)return;let M=u;e.remove(M),u===M&&(u=null)},k=()=>{let M=i;M&&(w(),i=null,u=M,e.remove(M),u===M&&(u=null))},E=()=>{m={auto:null,skip:null,authored:null}},v=()=>{E(),n={},d||k()},O=M=>{if(o.dispatchDepth>0||d){c=M,h();return}a&&r===M.lifecycleToken&&n===M.generationToken&&i===M.callback&&y()&&(l=M.registrationToken),c===M&&(c=null)},T=()=>{if(!a||!y()||i)return;P();let M=r,K=n,le={},z=oe=>{if(!a||M!==r||K!==n||le!==l||z!==i||d)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 ne=Dm(oe.deltaMS);d=!0,o.dispatchDepth+=1;let ue=n,Z=null;try{let C=[];for(let N of _i){let F=m[N];F&&(F.remainingQuanta<=ne?(C.push({kind:N,descriptor:F.descriptor,revision:b[N]}),m[N]=null):F.remainingQuanta-=ne)}if(C.length>0){try{t({dueKinds:C.map(({kind:N})=>N)})}catch(N){let F=s(N);if(f==="reconciled"&&F==="preCommit")for(let{kind:J,descriptor:me}of C)g[J]=me;else f==="legacy"&&E();throw N}if(f==="legacy")for(let N of C)N.kind==="skip"&&b.skip===N.revision&&m.skip===null&&(m.skip=Ka(N.descriptor))}}catch(C){Z=C}finally{o.dispatchDepth-=1,d=!1;try{ue===n?y()?T():k():i===z&&!y()&&k()}catch(C){throw Z?new AggregateError([Z,C],"Playback attempt and ticker cleanup both failed"):C}}if(Z)throw Z},te={callback:z,lifecycleToken:M,generationToken:K,registrationToken:le};i=z,c=te;try{e.add(z)}catch(oe){throw i=null,w(),E(),n={},u=z,oe}O(te)},$=M=>{b[M]+=1,m[M]=null,g[M]=null,!y()&&!d&&k()},D=(M,K)=>{An(K,`${M} delay`),f="legacy",b[M]+=1,g[M]=null,m[M]=Ka({mode:"legacy",kind:M,instanceToken:{},delayMs:K}),T()};return{handleLegacyEffect:M=>{switch(M.name){case"startAutoNextTimer":return D("auto",M.payload?.delay??za.auto),!0;case"clearAutoNextTimer":return $("auto"),!0;case"startSkipNextTimer":return D("skip",M.payload?.delay??za.skip),!0;case"clearSkipNextTimer":return $("skip"),!0;case"nextLineConfigTimer":return D("authored",M.payload?.delay??za.authored),!0;case"clearNextLineConfigTimer":return $("authored"),!0;default:return!1}},reconcilePlaybackScheduleV1:M=>{let K;try{K=hk(M)}catch(z){try{v()}catch(te){throw new AggregateError([z,te],"Playback schedule validation and cleanup both failed")}throw z}if(f="reconciled",K.status==="unsettled"){E(),d||k();return}let le={};for(let z of _i){let te=K.timers[z],oe=g[z];if(oe&&(!te||!Ga(oe,te))&&(g[z]=null),te&&g[z]&&Ga(g[z],te)){le[z]=null;continue}let ne=m[z];le[z]=te&&ne&&Ga(ne.descriptor,te)?ne:te?Ka(te):null}m=le,y()?T():d||k()},reset:()=>{let M=[i,u].filter((z,te,oe)=>z&&oe.indexOf(z)===te);r={},n={},w(),i=null,u=null,E(),g={auto:null,skip:null,authored:null};for(let z of _i)b[z]+=1;f="legacy",a=!0;let K=null,le=null;for(let z of M)try{e.remove(z)}catch(te){K??=te,le??=z}if(u=le,K)throw K},dispose:()=>{a=!1,r={},n={},w(),E(),g={auto:null,skip:null,authored:null};let M=[i,u].filter((z,te,oe)=>z&&oe.indexOf(z)===te);i=null,u=null;let K=null,le=null;for(let z of M)try{e.remove(z)}catch(te){K??=te,le??=z}if(u=le,K)throw K}}};var gk=new Set(["loadSlot","resetStoryAtSection","rollbackByOffset","rollbackToLine","updateLocalizationPackage","updateProjectData"]),bk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Wa="conditional",En="random",Qa=Symbol("conditionalAutoContinue"),wk=new Set(["sectionTransition","resetStoryAtSection"]),Ik=new Set(["nextLine","nextLineFromSystem","resetStoryAtSection","sectionTransition"]),vk=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),kk=new Set(["nextLine","nextLineFromSystem"]),Ak=new Set(["loadSlot","rollbackByOffset","rollbackToLine"]),Ja="form",Pk=new Set(["submitForm","cancelForm"]),Ek="showImageGalleryVariant",xk="playMusicRoomTrack",Sk="startSceneReplay",Ok="channel:bgm",Rk=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"]),Be=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),$k=()=>typeof globalThis.crypto?.randomUUID=="function"?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,xn=e=>e?.type===Qa,ct=(e,t)=>e?.sectionId===t?.sectionId&&e?.lineId===t?.lineId,Ck=(e,t)=>[...new Set([...Object.keys(e??{}),...Object.keys(t??{})])].some(o=>!Object.is(e?.[o],t?.[o]));function Za(e){let t=$k(),s,o=0,a=!1,r=0,n=null,i=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,g=new Map,b=0,y=[],w=[],h=!1,P=null,k=null,E=null,v=null,O=new Map,T,$,D=null,B=!1,_=!1,G=0,fe=new Map,M=cc(e.randomSource),{handlePendingEffects:K}=e;if(typeof K!="function")throw new TypeError("RouteEngine requires handlePendingEffects");let le=K.bind(K),z=typeof K.reconcilePlaybackScheduleV1=="function"?K.reconcilePlaybackScheduleV1.bind(K):null,te=typeof K.reset=="function"?K.reset.bind(K):null,oe=typeof K.dispose=="function"?K.dispose.bind(K):null;if(z&&(!te||!oe))throw new TypeError("reconcilePlaybackScheduleV1 requires reset and dispose capabilities");let ne=I=>{if(_)throw new Error(`RouteEngine cannot ${I} during playback reconciliation`)},ue=I=>{if(ne(I),!a||!s)throw new Error(`RouteEngine ${I} requires an active engine`)},Z=(I,A)=>{if(G===0)return;let S={preCommit:0,postCommitUnsettled:1,reconcileFailed:2},R=fe.get(I);(R===void 0||S[A]>S[R])&&fe.set(I,A)},C=I=>{let A=fe.get(I)??"preCommit";return fe.delete(I),A},N=I=>{if(z){_=!0;try{let A=z(structuredClone(I));if(A!==null&&(typeof A=="object"||typeof A=="function")&&typeof A.then=="function")throw new TypeError("reconcilePlaybackScheduleV1 must complete synchronously")}finally{_=!1}}},F=()=>({contractVersion:1,status:"unsettled",lineEntryId:s?.selectPlaybackLineEntryId?.()??0,timers:null}),J=I=>{if(!(!z||!a||!s)){B=!0;try{N(F())}catch(A){if(I){let S=new AggregateError([I,A],"Playback work and schedule invalidation both failed");throw fe.delete(I),Z(S,"reconcileFailed"),S}throw Z(A,"reconcileFailed"),A}}},me=()=>{if(!z||!B||!a||!s||i>0||l)return;let I;try{I=s.selectDesiredPlaybackTimers()}catch(A){throw Z(A,"reconcileFailed"),J(A),A}try{N({contractVersion:1,status:"settled",lineEntryId:s.selectPlaybackLineEntryId(),timers:I})}catch(A){throw Z(A,"reconcileFailed"),J(A),A}B=!1},Ie=(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}])),we=(I=new Map)=>Array.from(I.values()).map(A=>structuredClone(A.animation)),de=(I=Date.now())=>{f=new Map(Array.from(f.entries()).filter(([,A])=>I<A.expiresAt))},mr=()=>{if(a&&!(i>0||l)){l=!0;try{for(;s.selectPendingEffects().length>0;){let I=s.selectCurrentPointer()?.pointer??null,A=[...s.selectPendingEffects()],S=A.map(R=>R.name!=="handleLineActions"?R:{...R,payload:{...R.payload,pointer:structuredClone(I)}});s.clearPendingEffects();try{let R=z?S.filter(j=>!Pn.has(j.name)):S;R.length>0&&le(R)}catch(R){throw s.clearPendingEffects(),A.forEach(j=>{s.appendPendingEffect(j)}),Z(R,"postCommitUnsettled"),J(R),R}}}finally{l=!1}me()}},We=I=>{i+=1;let A=!1;try{let S=I();return A=!0,S}finally{i-=1,A&&mr()}},Sn=()=>{let I=s.selectSystemState();return s.selectRuntime()?.skipTransitionsAndAnimations===!0||Da(I)},Fr=()=>{let I=s.selectSystemState();return I.projectData?Wo({presentationState:s.selectPresentationState(),resources:I.projectData?.resources,runtime:s.selectRuntime(),musicRoomPlayer:I.global?.musicRoomPlayer,skipTransitionsAndAnimations:Sn()}):null},Br=()=>s.selectSystemState().projectData?structuredClone(s.selectPresentationState()?.bgm??null):null,Ar=()=>({audioEffects:structuredClone(s.selectSystemState().projectData?.resources?.audioEffects??{})}),On=()=>structuredClone(s.selectSystemState().projectData?.resources?.sounds??{}),ut=I=>!!I?.audioEffects,pt=()=>structuredClone(h?P:Fr()),Ur=()=>h?structuredClone(k):Br(),ft=()=>h?structuredClone(E):Ar(),Tt=I=>{let A=s.selectSystemState().projectData?.story?.scenes??{};return Object.entries(A).find(([,S])=>S?.sections?.[I])?.[0]},Rn=()=>{if(w.length===0)return;let I=s.selectRuntime()?.skipTransitionsAndAnimations===!0,A=new Set(I?[]:y.map(S=>S.id));w.forEach(S=>{S.status=S.effects?.some(R=>A.has(R.id))?"active":"settled"}),I&&(y=[]),w=[]},$n=(I,A,S,R,j,U,Y)=>{let W=s.selectPlaybackLineEntryId?.()??0,ce=(A.actionPath??["bgm"]).join("."),he=s.selectCurrentPointer()?.pointer,ge=he?.sceneId??Tt(he?.sectionId),ve=A.rollbackSource==="line"&&he?`story.scenes[${JSON.stringify(ge)}].sections[${JSON.stringify(he.sectionId)}].lines[${JSON.stringify(he.lineId)}].actions.${ce}`:ce,Re=A.rollbackSource==="line"?`${o}:${W}:${ve}`:null,Ue=Re?O.get(Re):null;if(Ue)return Ue;b+=1;let De={occurrenceId:`${t}:g${o}:l${W}:audio${b}`,actionPath:ve,selection:I?.audioEffects?structuredClone(I.audioEffects):null},Te={...Ar(),sounds:On()},$e=Ec({occurrence:De,resources:Te,previousResources:Y??Te,nextResources:Te,previousChannel:S,nextChannel:R,previousBgm:j,nextBgm:U});if(De.effects=structuredClone($e),De.status=$e.length>0?"pending":"settled",y=structuredClone($e),w.push(De),Re)for(O.set(Re,De);O.size>512;){let dt=O.keys().next().value;O.delete(dt)}return De},Cn=({initialState:I,namespace:A})=>{ne("initialize");let S=s?.selectSystemState?.()?.global?.audioCommandId??0,{l10nData:R,...j}=I,U=R===void 0?void 0:structuredClone(R),Y=structuredClone(I.projectData),W=Nm({projectData:Y,l10nData:U}),ce=j.global??{};if(!Be(ce))throw new Error("Malformed global state.");let he=ce.runtime??{};if(!Be(he))throw new Error("Malformed global.runtime.");let ge=he.localizationPackageId;if(ge!=null&&typeof ge!="string")throw new Error("localizationPackageId requires a string or null value");let ve=new Set(W.map(({l10nId:Te})=>Te).filter(Te=>Te!==null)),Re=typeof ge=="string"&&ve.has(ge)?ge:null,Ue=Ci({projectData:Y,l10nData:U,l10nId:Re}),De=lf({...j,global:{...ce,localizationPackages:W,runtime:{...he,localizationPackageId:Re}},projectData:Ue,initialAudioCommandId:S});te?.(),s=De,o+=1,a=!0,r=0,n=Nt(A),i=0,l=!1,c=0,u=[],p=null,d=null,f=new Map,m=new Map,g=new Map,b=0,y=[],w=[],h=!1,P=null,k=null,E=null,v={lineEntryId:s.selectPlaybackLineEntryId?.()??0,channel:null,presentation:null,resources:Ar()},O=new Map,T=Y,$=U,D=Re,B=!0,_=!1,G=0,fe.clear(),s.appendPendingEffect({name:"handleLineActions"}),mr()},Fm=()=>{ne("dispose"),a&&(a=!1,o+=1,s?.clearPendingEffects?.(),i=0,l=!1,u=[],p=null,d=null,f=new Map,m=new Map,g=new Map,y=[],w=[],h=!1,P=null,k=null,E=null,v=null,O=new Map,B=!1,fe.clear(),oe?.())},Bm=()=>n,Um=()=>s.selectPresentationState(),Ym=()=>s.selectPresentationChanges(),zm=I=>s.selectSectionLineChanges(I),rl=(I={})=>{ue("rendering"),r+=1;let A=Date.now();de(A);let S=m.size>0,R=Ie(f,A),j=S?Ie(m,A):new Map,U=s.selectRenderState({activePersistentAnimations:we(R),restoredPersistentAnimations:we(j),activeAudioEffects:structuredClone(y)}),Y={...U,id:`render-${t}-${o}-${r}`};return g.set(Y.id,{builtAt:A,persistentAnimationSessions:new Map([...j.entries(),...R.entries()]),usedRestoredPersistentAnimationSessions:S,activeAudioEffectIds:y.map(W=>W.id),bgmPresentation:Br(),bgmResources:Ar(),retainsActiveAudioEffects:y.length>0&&y.every(W=>(U.audioEffects??[]).some(ce=>ce.id===W.id))}),Y},Xm=(I={})=>rl(I),Gm=(I={})=>rl(I),Hm=I=>{if(!a||!s)return;let A=typeof I?.id=="string"&&I.id.length>0?I.id:null,S=A?g.get(A):null;A&&g.delete(A);let R=I?.audio?.find(U=>U?.id===Ok);h=!0,P=R?structuredClone(R):null,k=structuredClone(S?.bgmPresentation??null),E=structuredClone(S?.bgmResources??null);let j=new Map;ou(I?.animations).forEach(U=>{let Y=us(U);if(!Y)return;let W=S?.persistentAnimationSessions?.get(Y)??f.get(Y),ce=Math.max(0,cu(U)),he=W?.startedAt??S?.builtAt??Date.now();j.set(Y,{animation:structuredClone(U),startedAt:he,expiresAt:he+ce})}),f=j,S?.usedRestoredPersistentAnimationSessions&&(m=new Map),S?.activeAudioEffectIds?.length>0&&!S.retainsActiveAudioEffects&&y.length===S.activeAudioEffectIds.length&&S.activeAudioEffectIds.every(U=>y.some(Y=>Y.id===U))&&(y=[])},Km=()=>s.selectSystemState(),Wm=()=>s.selectAchievements(),Jm=I=>s.selectAchievement(I),tl=()=>s.selectSaveSlotMap(),Qm=I=>s.selectSaveSlot(I),Zm=I=>s.selectSaveSlotPage(I),ed=()=>s.selectImageGallery(),rd=()=>s.selectMusicRoom(),td=()=>s.selectSceneReplay(),nd=()=>s.selectIsSceneReplayActive(),Yk=()=>s.selectSkipMode(),zk=()=>s.selectAutoMode(),sd=()=>s.selectRuntime(),id=()=>s.selectIsChoiceVisible(),od=()=>s.selectIsFormVisible(),ad=()=>s.selectActiveInteraction(),ld=()=>s.selectPendingEffects().some(I=>I?.name==="handleLineActions"||I?.name==="render"),nl=(I,A,S={})=>!Be(A)||I!=="nextLine"?A:S.bypassChoice===!0?{...A,bypassChoice:!0}:S.interactionSource===Ja?{...A,_interactionSource:Ja}:A,sl=(I={})=>({type:Qa,payload:nl("nextLine",{_conditionalContinuation:!0},I)}),Ni=(I,A)=>xn(I)?{type:Qa,payload:{...I.payload,...A.payload}}:A,cd=I=>{I.savedCheckpointOccurrences.forEach(A=>{s.markSavedRollbackCheckpointTransient(A)}),I.savedCheckpointOccurrences=[]},ud=(I,A)=>{let S=p;return p=null,!S||!ct(S.pointer,I)||S.checkpointIndex!==A?.checkpointIndex||S.checkpointIdentity!==A?.checkpoint?[]:S.savedCheckpointOccurrences},pd=I=>{let A=d;return!A||!ct(A.pointer,I)?null:(d=null,A)},fd=({actionType:I,pointerBeforeAction:A,pointerAfterAction:S,cursorBeforeAction:R,cursorAfterAction:j,wasSceneReplayActive:U,isSceneReplayActive:Y})=>{!S||!(!ct(A,S)||R?.checkpoint!==j?.checkpoint||R?.checkpointIndex!==j?.checkpointIndex||I==="jumpToLine")||(d={pointer:S,appendToPrevious:kk.has(I)&&U===Y&&A?.sectionId===S.sectionId&&A?.lineId!==S.lineId,reuseExistingOccurrence:Ak.has(I),forceNewOccurrence:I==="jumpToLine"})},il=I=>{I.markCurrentCheckpointTransient&&(s.markRollbackCheckpointTransient({checkpointIndex:I.rollbackCursor?.checkpointIndex,checkpointIdentity:I.rollbackCursor?.checkpoint,sectionId:I.pointer?.sectionId,lineId:I.pointer?.lineId}),cd(I))},md=(I,A,S)=>Ik.has(I)?I==="resetStoryAtSection"?S?.checkpoint!==A?.checkpoint:S?.checkpoint!==A?.checkpoint&&S?.checkpointIndex>A?.checkpointIndex:!1,dd=I=>{let A=u.at(-1);if(!A?.markCurrentCheckpointTransient)return;let S=s.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})},yd=()=>{u.at(-1)?.savedCheckpointOccurrences.forEach(A=>{let S=s.selectSaveSlot({slotId:A.slotId});S&&(A.saveSlotIdentity=S)})},hd=()=>{let I=u.at(-1);I&&(I.rollbackCursor=s.selectRollbackCursor?.()??null)},gd=(I,A,S)=>{let R=u.at(-1);if(!R)return;let j=s.selectCurrentPointer()?.pointer,U=md(I,A,S);if(ct(R.pointer,j)){let Y=S?.checkpoint!==A?.checkpoint||S?.checkpointIndex!==A?.checkpointIndex;U||Y&&vk.has(I)?(il(R),R.pointer=j,R.rollbackCursor=S,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]):Y&&I==="updateProjectData"&&(R.rollbackCursor=S);return}il(R),R.pointer=j,R.rollbackCursor=s.selectRollbackCursor?.()??null,R.markCurrentCheckpointTransient=U,R.savedCheckpointOccurrences=[]},mt=(I,A)=>{if(ue(`action "${I}"`),!s[I])return;let S=A,R,j;if(I==="updateProjectData")ol(A),R=structuredClone(A.projectData),S={...A,projectData:Ci({projectData:R,l10nData:$,l10nId:D})},ol(S);else if(I==="updateLocalizationPackage"){if(j=bd(A),j===D)return;S={l10nId:j,projectData:Ci({projectData:T,l10nData:$,l10nId:j})}}wk.has(I)&&(c+=1);let U=s.selectAutoMode(),Y=U?s.selectRuntime():null,W=s.selectIsSceneReplayActive?.()===!0,ce=bk.has(I)?Ie(f):null,he=s.selectCurrentPointer()?.pointer??null,ge=s.selectRollbackCursor?.()??null,ve=ns(I),Re=ve?s.selectPlaybackLineEntryId?.()??0:null,Ue=ve?pt():null,De=ve?Ur():null,Te=ve?ft():null,$e=!1,dt;try{dt=s[I](S),$e=!0}catch(Lt){throw Z(Lt,"preCommit"),Lt}R!==void 0&&(T=R),j!==void 0&&(D=j),gk.has(I)&&(m=ce??new Map,f=new Map,y=[]),I==="setSkipTransitionsAndAnimations"&&S?.value===!0&&(y=[]);let fl=s.selectIsSceneReplayActive?.()===!0;W!==fl&&(f=new Map,m=new Map);let _d=s.selectCurrentPointer()?.pointer??null,ml=s.selectRollbackCursor?.()??null,dl=ve?s.selectPlaybackLineEntryId?.()??0:null;ve&&dl!==Re&&(v={lineEntryId:dl,channel:Ue,presentation:De,resources:Te}),I==="saveSlot"?dd(A):I==="updateProjectData"&&yd(),gd(I,ge,ml),fd({actionType:I,pointerBeforeAction:he,pointerAfterAction:_d,cursorBeforeAction:ge,cursorAfterAction:ml,wasSceneReplayActive:W,isSceneReplayActive:fl});let Nd=s.selectAutoMode()&&(I==="updateVariable"||U&&Ck(Y,s.selectRuntime()));(Rk.has(I)||Nd)&&(B=!0);try{mr()}catch(Lt){throw $e&&Z(Lt,"postCommitUnsettled"),Lt}return dt},ol=I=>{if(!Object.prototype.hasOwnProperty.call(I??{},"projectData"))throw new Error("updateProjectData requires projectData");Wr(I?.projectData?.resources?.variables??{}),Yt(I.projectData),zt(I.projectData),Xt(I.projectData)},bd=I=>{if(!Be(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},wd=(I,A,S)=>{let R=s.selectCurrentPointer()?.pointer;A!==R||S!==c||(s.appendPendingEffect({name:"clearAutoNextTimer"}),s.appendPendingEffect({name:"clearNextLineConfigTimer"}),mt("nextLineFromSystem",I.payload))},Id=()=>({renderSequence:r,conditionalRoutingSequence:c,rollbackNavigationContexts:u.slice(),pendingRollbackLineEntrySaveHandoff:p,pendingDialogueHistoryLineEntry:d,persistentAnimationSessions:new Map(f),restoredPersistentAnimationSessions:new Map(m),renderPersistentAnimationMetadata:new Map(g),audioEffectOccurrenceSequence:b,activeAudioEffects:y,pendingAudioEffectOccurrences:w.slice(),pendingEnteredLineBgmHandoff:v?structuredClone(v):null,acceptedLineBgmActionOccurrences:new Map(O),canonicalProjectData:T,localizationPackageId:D,playbackScheduleDirty:B}),vd=I=>{r=I.renderSequence,c=I.conditionalRoutingSequence,u=I.rollbackNavigationContexts.slice(),p=I.pendingRollbackLineEntrySaveHandoff,d=I.pendingDialogueHistoryLineEntry,f=new Map(I.persistentAnimationSessions),m=new Map(I.restoredPersistentAnimationSessions),g=new Map(I.renderPersistentAnimationMetadata),b=I.audioEffectOccurrenceSequence,y=I.activeAudioEffects,w=I.pendingAudioEffectOccurrences.slice(),v=I.pendingEnteredLineBgmHandoff?structuredClone(I.pendingEnteredLineBgmHandoff):null,O=new Map(I.acceptedLineBgmActionOccurrences),T=I.canonicalProjectData,D=I.localizationPackageId,B=I.playbackScheduleDirty},ji=(I,A={})=>(ue("action batch"),We(()=>{let S=Id();try{return s[lo](()=>{let R,j=s.selectCurrentPointer()?.pointer??null,U=s.selectRollbackCursor?.()??null,Y=c,W={pointer:j,rollbackCursor:U,markCurrentCheckpointTransient:A.rollbackSource==="line",savedCheckpointOccurrences:A.savedCheckpointOccurrences?.slice()??[]};u.push(W);try{s.beginRollbackActionBatch({source:A.rollbackSource});try{R=I()}finally{s.endRollbackActionBatch({})}xn(R)&&wd(R,j,Y),Rn();let ce=s.selectCurrentPointer()?.pointer??null;A.rollbackSource==="line"&&ct(j,ce)&&s.recordCurrentDialogueHistory({savedCheckpointOccurrences:W.savedCheckpointOccurrences,appendToPrevious:A.dialogueHistoryAppendToPrevious===!0,reuseExistingOccurrence:A.dialogueHistoryReuseExistingOccurrence===!0,forceNewOccurrence:A.dialogueHistoryForceNewOccurrence===!0})}finally{u.pop(),(!ct(j,W.pointer)||U?.checkpoint!==W.rollbackCursor?.checkpoint)&&W.markCurrentCheckpointTransient&&W.savedCheckpointOccurrences.length>0&&(p={pointer:W.pointer,checkpointIndex:W.rollbackCursor?.checkpointIndex,checkpointIdentity:W.rollbackCursor?.checkpoint,savedCheckpointOccurrences:W.savedCheckpointOccurrences})}})}catch(R){throw vd(S),R}})),Di=(I,A,S,R={})=>{if(I===Wa||I===En)return ji(()=>{let j={...R,executionContext:R.executionContext??{depth:0,pendingNavigation:null},actionPath:R.actionPath??[I],randomOutcomeOrdinals:R.randomOutcomeOrdinals??new Map};if(I===En)return cl(A,S,j);let U=Ti(S),Y=Wt({[I]:A},U);return ll(Y[I],S,j)},R);if(I==="bgm")return ji(()=>{let j=Ur(),U=ut(A),Y=U?pt():null,W=U?ft():null;mt(I,A);let ce=Br();$n(A,{...R,actionPath:R.actionPath??[I]},Y,U?Fr():null,j,ce,W)},R);mt(I,A)},kd=(I,A)=>{if(I!=="nextLineFromSystem")return Di(I,A);G+=1;try{return Di(I,A)}finally{G=Math.max(0,G-1)}},al=I=>{if(I&&Object.prototype.hasOwnProperty.call(I,"event"))throw new Error('eventContext key "event" is no longer supported. Use "_event".')},Ti=I=>{if(al(I),!I)return{variables:s.selectAllVariables?s.selectAllVariables():void 0,runtime:s.selectRuntime?s.selectRuntime():{}};let{_event:A,...S}=I,R=s.selectAllVariables?s.selectAllVariables():void 0;return{...S,_event:A,variables:R,runtime:s.selectRuntime?s.selectRuntime():{}}},Ad=I=>{if(!Be(I))return{templatePayload:I,literalTargetIds:null};let A=s.selectImageGalleryConfig();if(!Array.isArray(A?.groups))return{templatePayload:I,literalTargetIds:null};let S=typeof I.groupId=="string"?A.groups.find(j=>j.id===I.groupId):void 0;if(!S)return{templatePayload:I,literalTargetIds:null};let R=typeof I.variantId=="string"&&S.variants.some(j=>j.id===I.variantId);return{templatePayload:{...I,groupId:null,...R?{variantId:null}:{}},literalTargetIds:{groupId:I.groupId,...R?{variantId:I.variantId}:{}}}},Pd=I=>!Be(I)||typeof I.trackId!="string"?{templatePayload:I,literalTargetIds:null}:s.selectMusicRoomConfig()?.tracks?.some(R=>R.id===I.trackId)?{templatePayload:{...I,trackId:null},literalTargetIds:{trackId:I.trackId}}:{templatePayload:I,literalTargetIds:null},Ed=I=>!Be(I)||typeof I.sceneId!="string"?{templatePayload:I,literalTargetIds:null}:s.selectSceneReplayConfig()?.replays?.some(R=>R.sceneId===I.sceneId)?{templatePayload:{...I,sceneId:null},literalTargetIds:{sceneId:I.sceneId}}:{templatePayload:I,literalTargetIds:null},xd=I=>{if(!Be(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")},Sd=(I,A,S)=>{if(!Be(I))throw new Error(`conditional branch at index ${A} must be an object`);if(!Be(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")},ll=(I,A,S)=>{xd(I);let R=sl(S);for(let j=0;j<I.branches.length;j+=1){let U=I.branches[j];Sd(U,j,I.branches.length);let Y=Ti(A);if(Object.prototype.hasOwnProperty.call(U,"when")&&!Ut(U.when,Y))continue;let ce=_n(U.actions,A,{...S,actionPath:[...S.actionPath??[Wa],"branches",String(j),"actions"]});return xn(ce)?Ni(R,ce):R}return R},Od=I=>{if(!Be(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(!Be(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=T?.resources?.variables?.[I.variableId];if(!S||S.type!=="number"||S.scope!=="context"||S.readonly===!0||_e(S))throw new Error(`integer random action variableId must reference a writable context number variable: ${I.variableId}`)}},cl=(I,A,S)=>{Od(I),al(A);let R=uc(I.distribution,{randomSource:M});if(S.rollbackSource==="line"){s.ensureRandomReplayOccurrence({});let Y=(S.actionPath??[En]).join("."),W=S.randomOutcomeOrdinals??new Map,ce=W.get(Y)??0;W.set(Y,ce+1),s.recordRandomOutcome({path:Y,ordinal:ce,type:R.type,result:R}),hd()}let j;R.type==="integer"?mt("updateVariable",{id:"randomResult",operations:[{variableId:I.variableId,op:"set",value:R.value}]}):j=_n(I.distribution.outcomes[R.outcomeIndex].actions,A,{...S,actionPath:[...S.actionPath??[En],"distribution","outcomes",String(R.outcomeIndex),"actions"]});let U=sl(S);return xn(j)?Ni(U,j):U},Rd=(I,A)=>({...I??{},_form:A}),$d=(I,A,S,R)=>{let j=mt(I,A),U=j?.submitted===!0&&j.valid===!0,Y=j?.cancelled===!0;if(!(!U&&!Y)&&Be(A.actions))return _n(A.actions,Rd(S,j.form),{...R,interactionSource:Ja})},ul=(I,A,S,R)=>{if(I===En)return cl(A,S,R);let j=Ti(S),U={templatePayload:A,literalTargetIds:null};I===Ek?U=Ad(A):I===xk?U=Pd(A):I===Sk&&(U=Ed(A));let{templatePayload:Y,literalTargetIds:W}=U,he=Wt({[I]:Y},j)[I],ge=W?{...he,...W}:he;if(I===Wa)return ll(ge,S,R);let ve=nl(I,ge,R);if(Pk.has(I))return $d(I,ve,S,R);let Re=null,Ue=null,De=null,Te=!1;if(I==="bgm"){let $e=R.audioEffectHandoff,dt=$e?.available?$e.presentation:Ur();Te=ut(ve),Te&&$e?.available?($e.available=!1,Re=structuredClone($e.channel),Ue=structuredClone($e.presentation),De=structuredClone($e.resources)):Te&&(Re=pt(),Ue=dt,De=ft())}if(mt(I,ve),I==="bgm"){let $e=Br();$n(ve,R,Re,Te?Fr():null,Ue,$e,De)}},_n=(I,A,S)=>{let R,j=S?.executionContext??{depth:0,pendingNavigation:null},U=ts(I);ss(U),j.depth+=1;try{for(let[Y,W]of U){let ce={...S,executionContext:j,actionPath:[...S?.actionPath??[],Y]};if(ns(Y)){let ge=j.pendingNavigation;if(ge)throw new Error(`action batch cannot execute multiple navigation actions: ${ge.actionType}, ${Y}`);j.pendingNavigation={actionType:Y,payload:W,eventContext:A,options:ce};continue}let he=ul(Y,W,A,ce);xn(he)&&(R=Ni(R,he))}}finally{j.depth-=1}if(j.depth===0&&j.pendingNavigation){let Y=j.pendingNavigation;j.pendingNavigation=null,ul(Y.actionType,Y.payload,Y.eventContext,Y.options)}return R},pl=(I,A,S={})=>{let R={...S,executionContext:{depth:0,pendingNavigation:null},randomOutcomeOrdinals:new Map};return ji(()=>_n(I,A,R),R)},Cd=I=>{let A=s.selectCurrentPointer()?.pointer;if(I!==A||s.selectActiveInteraction())return;let S=s.selectNextLineConfig();S?.auto?.enabled&&S.auto.trigger==="fromStart"&&s.appendPendingEffect({name:"nextLineConfigTimer",payload:{delay:S.auto.delay}})};return{init:Cn,dispose:Fm,handleAction:Di,handleInternalAction:kd,handleActions:pl,selectRenderState:Xm,prepareRenderState:Gm,commitRenderState:Hm,selectPresentationState:Um,selectPresentationChanges:Ym,selectSectionLineChanges:zm,selectSystemState:Km,selectAchievements:Wm,selectAchievement:Jm,selectSaveSlotMap:tl,selectSaveSlot:Qm,selectSaveSlotPage:Zm,selectSaveSlots:tl,selectImageGallery:ed,selectMusicRoom:rd,selectSceneReplay:td,selectIsSceneReplayActive:nd,selectRuntime:sd,selectIsChoiceVisible:id,selectIsFormVisible:od,selectActiveInteraction:ad,selectHasPendingRenderWork:ld,handleLineActions:I=>{ue("line action handling");let A=s.selectCurrentPointer()?.pointer;if(I?.pointer&&!ct(I.pointer,A))return!1;if(typeof I?.sceneReplaySceneId=="string"){let S=s.selectActiveSceneReplayEntry?.();if(S?.sceneId!==I.sceneReplaySceneId||S?.entryId!==I.entryId)return!1}return We(()=>{let S=s.selectCurrentPointer()?.pointer,R=s.selectPlaybackLineEntryId?.()??0,j=v?.lineEntryId===R?v:null,U=j?{available:!0,channel:structuredClone(j.channel),presentation:structuredClone(j.presentation),resources:structuredClone(j.resources)}:null,Y=s.selectRollbackCursor?.()??null,W=p,ce=d,he=ud(S,Y),ge=pd(S),ve=s.selectCurrentLine(),Re=!1;if(ve?.actions){try{pl(ve.actions,void 0,{rollbackSource:"line",savedCheckpointOccurrences:he,dialogueHistoryAppendToPrevious:ge?.appendToPrevious===!0,dialogueHistoryReuseExistingOccurrence:ge?.reuseExistingOccurrence===!0,dialogueHistoryForceNewOccurrence:ge?.forceNewOccurrence===!0,audioEffectHandoff:U})}catch(Ue){throw p=W,d=ce,Ue}Re=!0}return v?.lineEntryId===R&&(v=null),Cd(S),Re})},getNamespace:Bm,classifyAutomaticAttemptError:C}}var _k="music-room:player",Vm=new Map([["soundReady","musicRoomSoundReady"],["soundProgress","musicRoomSoundProgress"],["soundComplete","musicRoomSoundComplete"],["soundError","musicRoomSoundError"]]),Lm=(e,t)=>Vm.has(e)&&t?._event?.id===_k,qm=({engine:e,routeGraphics:t,trackRenderDispatch:s,lifecycleGeneration:o,isCurrentLifecycle:a},r)=>{if(e.selectHasPendingRenderWork?.())return;let n=e.prepareRenderState?.(r)??e.selectRenderState(r);s?.(n),t.render(n),a(o)&&e.commitRenderState?.(n)},Nk=({engine:e,routeGraphics:t,trackRenderDispatch:s,getRenderDispatchCount:o,lifecycleGeneration:a,isCurrentLifecycle:r},n)=>{let i=o?.()??0,l=e.handleLineActions(n);(o?.()??0)===i&&qm({engine:e,routeGraphics:t,trackRenderDispatch:s,lifecycleGeneration:a,isCurrentLifecycle:r},n)},jk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveSlots(t?.saveSlots))},Dk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalDeviceVariables(t?.globalDeviceVariables))},Tk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalAccountVariables(t?.globalAccountVariables))},Lk=({enqueuePersistenceWrite:e},t)=>{e(s=>s.saveGlobalRuntime(t?.globalRuntime))},Mk=({enqueuePersistenceWrite:e},t)=>{e(s=>{if(typeof s.applyScopedDataUpdates!="function")throw new Error("RouteEngine persistence adapter must implement applyScopedDataUpdates.");return s.applyScopedDataUpdates(t?.updates)})},Mm={render:qm,saveSlots:jk,saveGlobalDeviceVariables:Dk,saveGlobalAccountVariables:Tk,saveGlobalRuntime:Lk,applyScopedDataUpdates:Mk,handleLineActions:Nk},Vk=new Set(["render","handleLineActions","saveSlots","saveGlobalDeviceVariables","saveGlobalAccountVariables","saveGlobalRuntime","startAutoNextTimer","clearAutoNextTimer","startSkipNextTimer","clearSkipNextTimer","nextLineConfigTimer","clearNextLineConfigTimer"]),el=(e,t,s)=>{(e.handleInternalAction??e.handleAction?.bind(e))?.(t,s)},qk=(e=[])=>{let t=new Set,s=[];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(!Vk.has(a.name)){s.unshift(a);continue}t.has(a.name)||(t.add(a.name),s.unshift(a))}return s},Fk=({getEngine:e,routeGraphics:t,ticker:s,handleUnhandledEffect:o,handlePersistenceError:a,indexedDB:r,persistence:n,namespace:i})=>{let l=new Map,c=Promise.resolve(),u=null,p=null,d=!1,f=0,m=0,g=!0,b=Tm({ticker:s,dispatchAutomaticAttempt:()=>el(e(),"nextLineFromSystem",{}),classifyAutomaticAttemptError:C=>e()?.classifyAutomaticAttemptError?.(C)??"preCommit"}),y=()=>{u=null,p=null,d=!1,f=0},w=()=>{b.reset(),m+=1,y(),g=!0},h=()=>{m+=1,g=!1,y(),b.dispose()},P=C=>g&&C===m,k=C=>{if(a){a(C);return}console.error("RouteEngine persistence write failed.",C)},E=C=>{if(n)return n;let N=Nt(C),F=l.get(N);if(F)return F;let J=qa({indexedDB:r,namespace:N});return l.set(N,J),J},v=C=>{let N=n?null:Nt(i??e()?.getNamespace?.()),F;c=c.catch(()=>{}).then(()=>(F=E(N),C(F))).catch(J=>{!n&&l.get(N)===F&&l.delete(N),k(J)})},O=C=>{if(!g)return;let N=typeof C?.id=="string"&&C.id.length>0?C.id:null;f+=1,u=N,d=!1},T=()=>f,$=(C={})=>{if(!g||C?.aborted===!0)return!1;let N=typeof C?.id=="string"&&C.id.length>0?C.id:null;return N?N!==u||N===p?!1:(p=N,!0):u!==null||d?!1:(d=!0,!0)},D=(C,N={})=>{if(!g)return!1;if(Lm(C,N)){let J=Vm.get(C),me=e();return el(me,J,N?._event),!0}if(C!=="renderComplete"||!$(N))return!1;let F=e();return el(F,"markLineCompleted",{}),!0},B=new Set(["updateFormField","submitForm","cancelForm"]),_=new Set(["updateVariable"]),G=C=>typeof C?.selectActiveInteraction=="function"?C.selectActiveInteraction():typeof C?.selectIsChoiceVisible=="function"&&C.selectIsChoiceVisible()?{source:"choice"}:null,fe=C=>C?._formKey??C?.formKey,M=(C,N)=>fe(C)===N?.formKey,K=(C,N)=>!C||typeof C!="object"||Array.isArray(C)?!1:C._interactionSource===N?.source,le=(C,N)=>K(C,N)?N.source==="form"?M(C,N):!0:!1,z=(C,N)=>!C||typeof C!="object"||Array.isArray(C)||N?.source!=="form"?!1:M(C,N),te=(C={},N)=>Object.keys(C).length>0&&Object.entries(C).every(([F,J])=>B.has(F)?z(J,N):_.has(F)),oe=(C={},N)=>{let F=C?.actions;return N?.source==="form"?!F||typeof F!="object"||Array.isArray(F)?!1:te(F,N):le(C,N)?!0:!F||typeof F!="object"||Array.isArray(F)?!1:Object.values(F).some(J=>le(J,N))},ne=(C,N={})=>{if(!N?.actions)return!1;let F=G(C);return!F||F.source==="choice"?!1:!oe(N,F)},ue=({preprocessPayload:C,onEvent:N}={})=>async(F,J={})=>{if(!g)return!1;if(Lm(F,J))return D(F,J),N?.(F,J);let me=e(),Ie=m,we=f;if(ne(me,J))return N?.(F,J);let de=await C?.(F,J)??J;if(!P(Ie)||e()!==me||f!==we)return!1;if(ne(me,de))return N?.(F,de);if(D(F,de),de?.actions){let mr=de?._event?{_event:de._event}:de?.event?{_event:de.event}:void 0,We;de?.bypassChoice===!0?We={bypassChoice:!0}:de?._interactionSource&&(We={interactionSource:de._interactionSource}),We?me.handleActions(de.actions,mr,We):me.handleActions(de.actions,mr)}return N?.(F,de)},Z=C=>{if(!g)return;let N=m,F=e(),J=qk(C),me=J.some(we=>we.name==="handleLineActions");J.forEach(we=>{if(!Mm[we.name]&&!Pn.has(we.name)&&!o)throw new Error(`Unhandled pending effect "${we.name}".`)});let Ie={engine:F,routeGraphics:t,ticker:s,trackRenderDispatch:O,getRenderDispatchCount:T,enqueuePersistenceWrite:v,lifecycleGeneration:m,isCurrentLifecycle:P};for(let we of J){if(!P(N))break;if(me&&we.name==="render")continue;if(Pn.has(we.name)){b.handleLegacyEffect(we);continue}let de=Mm[we.name];if(de){de(Ie,we.payload);continue}o(we,Ie)}};return Z.handleRouteGraphicsEvent=D,Z.createRouteGraphicsEventHandler=ue,Z.reset=w,Z.dispose=h,Z.reconcilePlaybackScheduleV1=C=>b.reconcilePlaybackScheduleV1(C),Z},Bk=Fk;var Uk=(e,t={})=>{let{resources:s={}}=t;return Uo(e,s)};var zP=Za;export{Ao as DEFAULT_VISUAL_LAYER,kt as RENDER_LAYER,dr as VISUAL_LAYER,Bk as createEffectsHandler,bv as createIndexedDbPersistence,zP as default,uo as formatDate,sh as resolveComputedVariables,Uk as resolveLayoutReferences};
|