@m2c2kit/core 0.3.19 → 0.3.20

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/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
- var at=(g=>(g.Node="Node",g.Scene="Scene",g.Sprite="Sprite",g.Label="Label",g.TextLine="TextLine",g.Shape="Shape",g.Composite="Composite",g.SoundPlayer="SoundPlayer",g.SoundRecorder="SoundRecorder",g))(at||{});const zt={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var pt=(g=>(g.Sequence="Sequence",g.Group="Group",g.Wait="Wait",g.Custom="Custom",g.Move="Move",g.Scale="Scale",g.FadeAlpha="FadeAlpha",g.Rotate="Rotate",g.Play="Play",g.Repeat="Repeat",g.RepeatForever="RepeatForever",g))(pt||{});const Ct=class tt{static toTypeAsString(t){switch(t){case tt.none:return"None";case tt.linear:return"Linear";case tt.quadraticIn:return"QuadraticIn";case tt.quadraticOut:return"QuadraticOut";case tt.quadraticInOut:return"QuadraticInOut";case tt.cubicIn:return"CubicIn";case tt.cubicOut:return"CubicOut";case tt.cubicInOut:return"CubicInOut";case tt.quarticIn:return"QuarticIn";case tt.quarticOut:return"QuarticOut";case tt.quarticInOut:return"QuarticInOut";case tt.quinticIn:return"QuinticIn";case tt.quinticOut:return"QuinticOut";case tt.quinticInOut:return"QuinticInOut";case tt.sinusoidalIn:return"SinusoidalIn";case tt.sinusoidalOut:return"SinusoidalOut";case tt.sinusoidalInOut:return"SinusoidalInOut";case tt.exponentialIn:return"ExponentialIn";case tt.exponentialOut:return"ExponentialOut";case tt.exponentialInOut:return"ExponentialInOut";case tt.circularIn:return"CircularIn";case tt.circularOut:return"CircularOut";case tt.circularInOut:return"CircularInOut";default:throw new Error("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(t){switch(t){case"None":return tt.none;case"Linear":return tt.linear;case"QuadraticIn":return tt.quadraticIn;case"QuadraticOut":return tt.quadraticOut;case"QuadraticInOut":return tt.quadraticInOut;case"CubicIn":return tt.cubicIn;case"CubicOut":return tt.cubicOut;case"CubicInOut":return tt.cubicInOut;case"QuarticIn":return tt.quarticIn;case"QuarticOut":return tt.quarticOut;case"QuarticInOut":return tt.quarticInOut;case"QuinticIn":return tt.quinticIn;case"QuinticOut":return tt.quinticOut;case"QuinticInOut":return tt.quinticInOut;case"SinusoidalIn":return tt.sinusoidalIn;case"SinusoidalOut":return tt.sinusoidalOut;case"SinusoidalInOut":return tt.sinusoidalInOut;case"ExponentialIn":return tt.exponentialIn;case"ExponentialOut":return tt.exponentialOut;case"ExponentialInOut":return tt.exponentialInOut;case"CircularIn":return tt.circularIn;case"CircularOut":return tt.circularOut;case"CircularInOut":return tt.circularInOut;default:throw new Error(`Easings.fromTypeAsString(): Unknown easing function type ${t}`)}}};Ct.none=(g,t,i,n)=>i+t,Ct.linear=(g,t,i,n)=>i*g/n+t,Ct.quadraticIn=(g,t,i,n)=>(g/=n,i*g*g+t),Ct.quadraticOut=(g,t,i,n)=>(g/=n,-i*g*(g-2)+t),Ct.quadraticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g+t:(g--,-i/2*(g*(g-2)-1)+t)),Ct.cubicIn=(g,t,i,n)=>(g/=n,i*g*g*g+t),Ct.cubicOut=(g,t,i,n)=>(g/=n,g--,i*(g*g*g+1)+t),Ct.cubicInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g+t:(g-=2,i/2*(g*g*g+2)+t)),Ct.quarticIn=(g,t,i,n)=>(g/=n,i*g*g*g*g+t),Ct.quarticOut=(g,t,i,n)=>(g/=n,g--,-i*(g*g*g*g-1)+t),Ct.quarticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g*g+t:(g-=2,-i/2*(g*g*g*g-2)+t)),Ct.quinticIn=(g,t,i,n)=>(g/=n,i*g*g*g*g*g+t),Ct.quinticOut=(g,t,i,n)=>(g/=n,g--,i*(g*g*g*g*g+1)+t),Ct.quinticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g*g*g+t:(g-=2,i/2*(g*g*g*g*g+2)+t)),Ct.sinusoidalIn=(g,t,i,n)=>-i*Math.cos(g/n*(Math.PI/2))+i+t,Ct.sinusoidalOut=(g,t,i,n)=>i*Math.sin(g/n*(Math.PI/2))+t,Ct.sinusoidalInOut=(g,t,i,n)=>-i/2*(Math.cos(Math.PI*g/n)-1)+t,Ct.exponentialIn=(g,t,i,n)=>i*Math.pow(2,10*(g/n-1))+t,Ct.exponentialOut=(g,t,i,n)=>i*(-Math.pow(2,-10*g/n)+1)+t,Ct.exponentialInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*Math.pow(2,10*(g-1))+t:(g--,i/2*(-Math.pow(2,-10*g)+2)+t)),Ct.circularIn=(g,t,i,n)=>(g/=n,-i*(Math.sqrt(1-g*g)-1)+t),Ct.circularOut=(g,t,i,n)=>(g/=n,g--,i*Math.sqrt(1-g*g)+t),Ct.circularInOut=(g,t,i,n)=>(g/=n/2,g<1?-i/2*(Math.sqrt(1-g*g)-1)+t:(g-=2,i/2*(Math.sqrt(1-g*g)+1)+t));let Te=Ct;var Ut=(g=>(g.Undefined="Undefined",g.Rectangle="Rectangle",g.Circle="Circle",g.Path="Path",g))(Ut||{});const cn=class $n{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static new(t){this._timers=this._timers.filter(n=>n.name!==t);const i=new $n(t);i.cumulativeElapsed=0,this._timers.push(i)}static startNew(t){this.new(t),this.start(t)}static start(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't start timer. timer with name ${t} does not exist.`);if(i.stopped===!1)throw new Error(`can't start timer. timer with name ${t} is already started.`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't stop timer. timer with name ${t} does not exist.`);if(i.stopped===!0)throw new Error(`can't stop timer. timer with name ${t} is already stopped.`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static elapsed(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't get elapsed time. timer with name ${t} does not exist.`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(n=>n.name===t).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${t} does not exist.`);this._timers=this._timers.filter(n=>n.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};cn._timers=new Array;let Wt=cn;class q{static getUrlFromManifest(t,i){const n=t.manifest;return n&&n[i]?n[i]:i}static urlHasScheme(t){return/^[a-z]+:\/\//i.test(t)}static registerM2NodeClass(...t){m2c2Globals.m2NodeClassRegistry||(m2c2Globals.m2NodeClassRegistry={}),t.forEach(i=>{m2c2Globals.m2NodeClassRegistry={...m2c2Globals.m2NodeClassRegistry,[i.name]:i}})}static createFrameUpdateTimestamps(){return{timestamp:Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Wt.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Wt.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(t){const i=t.ancestors;i.reverse(),i.push(t);const n=i.map(u=>{const h=q.calculateNodeAbsoluteBoundingBox(u);return q.boundingBoxToPoints(h)});for(let u=0;u<n.length;u++){if(!nr(i[u]))continue;const h=n[u],C=i[u].zRotation,F=q.findCentroid(h);for(let B=u;B<i.length;B++)n[B]=Ks(n[B],C,F)}return n[n.length-1]}static rotateCanvasForDrawableNode(t,i){const n=q.calculateRotationTransforms(i);if(n.length===0)return;const u=m2c2Globals.canvasScale/i.absoluteScale;Hs(n,u,t)}static calculateNodeAbsoluteBoundingBox(t){const i=t.anchorPoint,n=t.absoluteScale;let u=t.size.width,h=t.size.height;if(t.type===at.Shape&&t.shapeType===Ut.Circle){const et=t.circleOfRadius;if(!et)throw"circleOfRadius is undefined";u=et*2,h=et*2}const C=t.absolutePosition.x-u*i.x*n,F=t.absolutePosition.x+u*(1-i.x)*n,B=t.absolutePosition.y-h*i.y*n,U=t.absolutePosition.y+h*(1-i.y)*n;return{xMin:C,xMax:F,yMin:B,yMax:U}}static radiansToDegrees(t){return-q.normalizeAngleRadians(t)*(180/Math.PI)}static normalizeAngleRadians(t){const i=Math.floor(t/(2*Math.PI));let n=t-i*(2*Math.PI);return n<0&&(n+=2*Math.PI),n}static arePointsOnSameSideOfLine(t,i,n,u){const h=(u.x-n.x)*(t.y-n.y)-(u.y-n.y)*(t.x-n.x),C=(u.x-n.x)*(i.y-n.y)-(u.y-n.y)*(i.x-n.x);return h*C>=0}static isPointInsideRectangle(t,i){if(i.length!==4)throw new Error("Invalid input: expected an array of four points");return q.arePointsOnSameSideOfLine(t,i[2],i[0],i[1])&&q.arePointsOnSameSideOfLine(t,i[3],i[1],i[2])&&q.arePointsOnSameSideOfLine(t,i[0],i[2],i[3])&&q.arePointsOnSameSideOfLine(t,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(t){const i=t.ancestors;return i.push(t),i.some(n=>nr(n))}static boundingBoxToPoints(t){const{xMin:i,xMax:n,yMin:u,yMax:h}=t;return[{x:i,y:u},{x:n,y:u},{x:n,y:h},{x:i,y:h}]}static findCentroid(t){if(t.length!==4)throw new Error("Invalid input: expected an array of four points");let i=0,n=0;for(const C of t)i+=C.x,n+=C.y;const u=i/4,h=n/4;return{x:u,y:h}}static rotatePoint(t,i,n){const u=t.x-n.x,h=t.y-n.y,C=u*Math.cos(-i)-h*Math.sin(-i),F=u*Math.sin(-i)+h*Math.cos(-i);return{x:C+n.x,y:F+n.y}}static calculateRotationTransforms(t){const i=[],n=t.ancestors;return n.reverse(),n.push(t),n.forEach(u=>{if(nr(u)){const h=u;if(h.type===at.Scene){const U={x:h.absolutePosition.x+h.size.width*.5,y:h.absolutePosition.y+h.size.height*.5};i.push({radians:h.zRotation,center:U});return}const C=q.calculateNodeAbsoluteBoundingBox(h),F=q.boundingBoxToPoints(C),B=q.findCentroid(F);i.push({radians:h.zRotation,center:B})}}),i}}function Hs(g,t,i){g.forEach(n=>{i.rotate(q.radiansToDegrees(n.radians),n.center.x*t,n.center.y*t)})}function nr(g){return q.normalizeAngleRadians(g.zRotation)!==0&&g.isDrawable}function Ks(g,t,i){if(g.length!==4)throw new Error("Invalid input: expected an array of four points");const n=[];for(const u of g)n.push(q.rotatePoint(u,t,i));return n}class xt{constructor(t){if(this.expression=new Array,this.WARNING_EXPRESSION_LENGTH=32,typeof t=="number"){this.pushToExpression(t);return}if(t===void 0){this.pushToExpression(1/0);return}this.pushToExpression(t)}pushToExpression(t){if(t===this)throw new Error("Cannot add, subtract, or assign a Futurable with itself.");this.expression.push(t),this.expression.length===this.WARNING_EXPRESSION_LENGTH&&console.warn(`Expression length is ${this.WARNING_EXPRESSION_LENGTH} elements. Something may be wrong.`)}assign(t){for(;this.expression.length>0;)this.expression.pop();this.pushToExpression(t)}add(...t){return this.appendOperation(Mi.Add,...t),this}subtract(...t){return this.appendOperation(Mi.Subtract,...t),this}appendOperation(t,...i){i.forEach(n=>{this.pushToExpression(t),this.pushToExpression(n)})}get value(){let t=0;const i=this.expression.flat(1/0);let n=1;for(let u=0;u<i.length;u++){if(typeof i[u]=="number"){t=t+n*i[u];continue}if(i[u]instanceof xt){t=t+n*i[u].value;continue}if(i[u]===Mi.Add){n=1;continue}if(i[u]===Mi.Subtract){n=-1;continue}}return t}}const Mi={Add:"Add",Subtract:"Subtract"};class V{constructor(t=!1){this.startOffset=new xt(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new xt,this.runDuringTransition=t}initialize(t){const i=this.clone();return this.assignParents(i,i,t),this.propagateRunDuringTransition(i),this.assignDurations(i),this.assignStartOffsets(i),i}assignParents(t,i,n){if(n!==void 0&&(t.key=n),this.isParent(t)){const u=t.children;u.forEach(h=>{h.parent=t}),u.filter(h=>this.isParent(h)).forEach(h=>this.assignParents(h,i,n))}}propagateRunDuringTransition(t){this.isParent(t)&&(t.descendants.some(i=>i.runDuringTransition)&&(t.runDuringTransition=!0),t.children.forEach(i=>this.propagateRunDuringTransition(i)))}assignDurations(t){t.duration=this.calculateDuration(t),this.isParent(t)&&t.children.forEach(i=>this.assignDurations(i))}calculateDuration(t){if(t.type===pt.Group){const n=t.children.map(u=>this.calculateDuration(u)).reduce((u,h)=>Math.max(u,h.value),0);return new xt(n)}if(t.type===pt.Sequence){const n=t.children.map(u=>this.calculateDuration(u)).reduce((u,h)=>u+h.value,0);return new xt(n)}return this.isRepeating(t)?new xt:t.duration}assignStartOffsets(t){t.startOffset=this.calculateStartOffset(t),this.isParent(t)&&t.children.forEach(i=>this.assignStartOffsets(i))}calculateStartOffset(t){if(t.parent===void 0)return new xt(0);if(t.parent.type!==pt.Sequence)return t.parent.startOffset;const i=new xt(0);i.add(t.parent.startOffset);for(const n of t.parent.children){if(n===t)break;i.add(n.duration)}return i}static evaluateAction(t,i,n,u){if(i.involvedInSceneTransition()&&!t.runDuringTransition||(t.runStartTime===-1&&t.assignRunStartTimes(t,n),n<t.runStartTime+t.startOffset.value))return;if(t.shouldBeRunning(n)&&(t.running=!0),t.isParent(t)){if(t.children.forEach(C=>{V.evaluateAction(C,i,n,u)}),!t.isRepeating(t)){t.started||(t.started=!0),t.running&&t.completed&&(t.running=!1);return}V.evaluateRepeatingActions(t,n);return}if(t.shouldBeRunning(n)||(t.running=!1),t.running===!1&&t.completed===!0)return;const h=n-(t.runStartTime+t.startOffset.value);switch(t.type){case pt.Custom:V.evaluateCustomAction(t);break;case pt.Play:V.evaluatePlayAction(i,t);break;case pt.Wait:V.evaluateWaitAction(t,n);break;case pt.Move:V.evaluateMoveAction(t,i,h);break;case pt.Scale:V.evaluateScaleAction(t,i,h,u);break;case pt.FadeAlpha:V.evaluateFadeAlphaAction(t,i,h,u);break;case pt.Rotate:V.evaluateRotateAction(t,i,h,u);break;default:throw new Error(`Action type not recognized: ${t.type}`)}}static evaluateRepeatingActions(t,i){if(t.started||(t.started=!0),t.repetitionHasCompleted){t.completedRepetitions++;const n=t.children[0].duration.value;if(t.cumulativeDuration=t.cumulativeDuration+n,!isFinite(n))throw"repetitionDuration is not finite";if(!t.completed)t.restartAction(t,i);else{if(t.type===pt.RepeatForever)throw new Error("RepeatForever action should never complete");t.duration.assign(t.cumulativeDuration),t.running=!1}}}static evaluateRotateAction(t,i,n,u){const h=t;h.started||(h.byAngle!==void 0&&(h.delta=h.byAngle),h.toAngle!==void 0&&(h.toAngle=q.normalizeAngleRadians(h.toAngle),i.zRotation=q.normalizeAngleRadians(i.zRotation),h.delta=h.toAngle-i.zRotation,h.shortestUnitArc===!0&&Math.abs(h.delta)>Math.PI&&(h.delta=2*Math.PI-Math.abs(h.delta))),h.started=!0,h.finalValue=i.zRotation+h.delta),n<h.duration.value?(i.zRotation=i.zRotation+h.delta*(u/h.duration.value),h.delta<=0&&i.zRotation<h.finalValue&&(i.zRotation=h.finalValue),h.delta>0&&i.zRotation>h.finalValue&&(i.zRotation=h.finalValue)):(i.zRotation=h.finalValue,h.running=!1,h.completed=!0)}static evaluateFadeAlphaAction(t,i,n,u){const h=t;h.started||(h.delta=h.alpha-i.alpha,h.started=!0),n<h.duration.value?i.alpha=i.alpha+h.delta*(u/h.duration.value):(i.alpha=h.alpha,h.running=!1,h.completed=!0)}static evaluateScaleAction(t,i,n,u){const h=t;h.started||(h.delta=h.scale-i.scale,h.started=!0),n<h.duration.value?i.scale=i.scale+h.delta*(u/h.duration.value):(i.scale=h.scale,h.running=!1,h.completed=!0)}static evaluateMoveAction(t,i,n){const u=t;u.started||(u.dx=u.point.x-i.position.x,u.dy=u.point.y-i.position.y,u.startPoint.x=i.position.x,u.startPoint.y=i.position.y,u.started=!0),n<u.duration.value?(i.position.x=u.easing(n,u.startPoint.x,u.dx,u.duration.value),i.position.y=u.easing(n,u.startPoint.y,u.dy,u.duration.value)):(i.position.x=u.point.x,i.position.y=u.point.y,u.running=!1,u.completed=!0)}static evaluateWaitAction(t,i){const n=t;i>t.runStartTime+t.startOffset.value+t.duration.value&&(n.running=!1,n.completed=!0)}static evaluatePlayAction(t,i){if(t.type!==at.SoundPlayer)throw new Error("Play action can only be used with a SoundPlayer");const n=i,u=t,h=u.game.soundManager;if(!n.started){const C=h.getSound(u.soundName);if(C.audioBuffer){const F=h.audioContext.createBufferSource();F.buffer=C.audioBuffer,F.onended=()=>{n.running=!1,n.completed=!0;const B=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(B)},F.connect(h.audioContext.destination),F.start(),n.started=!0}else{if(C.status===zt.Error)throw new Error(`error loading sound ${C.soundName} (url ${C.url})`);console.warn(`Play action: audio buffer not ready for sound ${u.soundName} (url: ${C.url}); will try next frame`),C.status===zt.Deferred&&h.fetchDeferredSound(C)}}}static evaluateCustomAction(t){const i=t;i.callback(),i.running=!1,i.completed=!0}assignRunStartTimes(t,i){t.runStartTime=i,t.isParent(t)&&t.children.forEach(n=>{t.assignRunStartTimes(n,i)})}restartAction(t,i){if(t.runStartTime=i,t.running=!0,t.started=!0,t.type===pt.Play&&(t.duration=new xt),t.isParent(t)){t.children.forEach(n=>{t.restartAction(n,i)});return}t.completed=!1}shouldBeRunning(t){return t>=this.runStartTime+this.startOffset.value&&t<=this.runStartTime+this.startOffset.value+this.duration.value}static move(t){return new vn(t.point,new xt(t.duration),t.easing??Te.linear,t.runDuringTransition??!1)}static wait(t){return new gn(new xt(t.duration),t.runDuringTransition??!1)}static custom(t){return new pn(t.callback,t.runDuringTransition??!1)}static play(t){return new mn(t?.runDuringTransition??!1)}static scale(t){return new yn(t.scale,new xt(t.duration),t.runDuringTransition)}static fadeAlpha(t){return new wn(t.alpha,new xt(t.duration),t.runDuringTransition)}static rotate(t){if(t.byAngle!==void 0&&t.toAngle!==void 0)throw new Error("rotate Action: cannot specify both byAngle and toAngle");if(t.byAngle===void 0&&t.toAngle===void 0)throw new Error("rotate Action: must specify either byAngle or toAngle");if(t.toAngle===void 0&&t.shortestUnitArc!==void 0)throw new Error("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return t.toAngle!==void 0&&t.shortestUnitArc===void 0&&(t.shortestUnitArc=!0),new Sn(t.byAngle,t.toAngle,t.shortestUnitArc,new xt(t.duration),t.runDuringTransition)}static sequence(t){const i=new un(t);return i.children=t,i}static group(t){const i=new dn(t);return i.children=t,i}static repeat(t){return new sr(t.action,t.count,t.runDuringTransition)}static repeatForever(t){return new fn(t.action,t.runDuringTransition)}isParent(t){return t.type===pt.Group||t.type===pt.Sequence||t.type===pt.Repeat||t.type===pt.RepeatForever}isRepeating(t){return t.type===pt.Repeat||t.type===pt.RepeatForever}get completed(){return this._completed}set completed(t){this._completed=t}}class un extends V{constructor(t){super(),this.type=pt.Sequence,this.children=t}clone(){const t=this.children.map(n=>n.clone()),i=V.sequence(t);return i.children.forEach(n=>n.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return ar(this)}}class dn extends V{constructor(t){super(),this.type=pt.Group,this.children=new Array,this.children=t}clone(){const t=this.children.map(n=>n.clone()),i=V.group(t);return i.children.forEach(n=>n.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return ar(this)}}class sr extends V{constructor(t,i,n=!1){super(n),this.type=pt.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[t],this.count=i,this.duration=new xt}clone(){if(this.children.length!==1)throw new Error("Repeat action must have exactly one child");const t=V.repeat({action:this.children[0].clone(),count:this.count,runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}get completed(){return this.children.every(t=>t.completed)&&this.completedRepetitions===this.count}get descendantsAreCompleted(){return this.children.every(t=>t.completed)}get repetitionHasCompleted(){return this.running&&this.descendantsAreCompleted&&!this.completed}get descendants(){return ar(this)}}class fn extends sr{constructor(t,i=!1){super(t,1/0,i),this.type=pt.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new Error("RepeatForever action must have exactly one child");const t=V.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}}function ar(g){const t=[];function i(n){if(n.isParent(n))for(const u of n.children)t.push(u),i(u)}return i(g),t}class pn extends V{constructor(t,i=!1){super(i),this.type=pt.Custom,this.callback=t,this.duration=new xt(0)}clone(){const t=V.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class mn extends V{constructor(t=!1){super(t),this.type=pt.Play,this.duration=new xt}clone(){const t=V.play({runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class gn extends V{constructor(t,i){super(i),this.type=pt.Wait,this.duration=t}clone(){const t=V.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class vn extends V{constructor(t,i,n,u){super(u),this.type=pt.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=t,this.easing=n}clone(){const t=V.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class yn extends V{constructor(t,i,n=!1){super(n),this.type=pt.Scale,this.delta=0,this.duration=i,this.scale=t}clone(){const t=V.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class wn extends V{constructor(t,i,n=!1){super(n),this.type=pt.FadeAlpha,this.delta=0,this.duration=i,this.alpha=t}clone(){const t=V.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Sn extends V{constructor(t,i,n,u,h=!1){super(h),this.type=pt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=u,this.byAngle=t,this.toAngle=i,this.shortestUnitArc=n}clone(){const t=V.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}var si=(g=>(g.Game="Game",g.Survey="Survey",g))(si||{});class Ft{static Dispose(t){t.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(t,i,n,u){const h=new t.Paint;return h.setColor(t.Color(i[0],i[1],i[2],i[3])),h.setStyle(n),h.setAntiAlias(u),h}}class Ni{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(t){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(t)}addLine(t){this.currentPath.push(t)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const t=new Ni;return t._subpaths=JSON.parse(JSON.stringify(this._subpaths)),t.currentPath=JSON.parse(JSON.stringify(this.currentPath)),t}}class x{}x.Transparent=[0,0,0,0],x.MediumVioletRed=[199,21,133,1],x.DeepPink=[255,20,147,1],x.PaleVioletRed=[219,112,147,1],x.HotPink=[255,105,180,1],x.LightPink=[255,182,193,1],x.Pink=[255,192,203,1],x.DarkRed=[139,0,0,1],x.Red=[255,0,0,1],x.Firebrick=[178,34,34,1],x.Crimson=[220,20,60,1],x.IndianRed=[205,92,92,1],x.LightCoral=[240,128,128,1],x.Salmon=[250,128,114,1],x.DarkSalmon=[233,150,122,1],x.LightSalmon=[255,160,122,1],x.OrangeRed=[255,69,0,1],x.Tomato=[255,99,71,1],x.DarkOrange=[255,140,0,1],x.Coral=[255,127,80,1],x.Orange=[255,165,0,1],x.DarkKhaki=[189,183,107,1],x.Gold=[255,215,0,1],x.Khaki=[240,230,140,1],x.PeachPuff=[255,218,185,1],x.Yellow=[255,255,0,1],x.PaleGoldenrod=[238,232,170,1],x.Moccasin=[255,228,181,1],x.PapayaWhip=[255,239,213,1],x.LightGoldenrodYellow=[250,250,210,1],x.LemonChiffon=[255,250,205,1],x.LightYellow=[255,255,224,1],x.Maroon=[128,0,0,1],x.Brown=[165,42,42,1],x.SaddleBrown=[139,69,19,1],x.Sienna=[160,82,45,1],x.Chocolate=[210,105,30,1],x.DarkGoldenrod=[184,134,11,1],x.Peru=[205,133,63,1],x.RosyBrown=[188,143,143,1],x.Goldenrod=[218,165,32,1],x.SandyBrown=[244,164,96,1],x.Tan=[210,180,140,1],x.Burlywood=[222,184,135,1],x.Wheat=[245,222,179,1],x.NavajoWhite=[255,222,173,1],x.Bisque=[255,228,196,1],x.BlanchedAlmond=[255,235,205,1],x.Cornsilk=[255,248,220,1],x.DarkGreen=[0,100,0,1],x.Green=[0,128,0,1],x.DarkOliveGreen=[85,107,47,1],x.ForestGreen=[34,139,34,1],x.SeaGreen=[46,139,87,1],x.Olive=[128,128,0,1],x.OliveDrab=[107,142,35,1],x.MediumSeaGreen=[60,179,113,1],x.LimeGreen=[50,205,50,1],x.Lime=[0,255,0,1],x.SpringGreen=[0,255,127,1],x.MediumSpringGreen=[0,250,154,1],x.DarkSeaGreen=[143,188,143,1],x.MediumAquamarine=[102,205,170,1],x.YellowGreen=[154,205,50,1],x.LawnGreen=[124,252,0,1],x.Chartreuse=[127,255,0,1],x.LightGreen=[144,238,144,1],x.GreenYellow=[173,255,47,1],x.PaleGreen=[152,251,152,1],x.Teal=[0,128,128,1],x.DarkCyan=[0,139,139,1],x.LightSeaGreen=[32,178,170,1],x.CadetBlue=[95,158,160,1],x.DarkTurquoise=[0,206,209,1],x.MediumTurquoise=[72,209,204,1],x.Turquoise=[64,224,208,1],x.Aqua=[0,255,255,1],x.Cyan=[0,255,255,1],x.Aquamarine=[127,255,212,1],x.PaleTurquoise=[175,238,238,1],x.LightCyan=[224,255,255,1],x.Navy=[0,0,128,1],x.DarkBlue=[0,0,139,1],x.MediumBlue=[0,0,205,1],x.Blue=[0,0,255,1],x.MidnightBlue=[25,25,112,1],x.RoyalBlue=[65,105,225,1],x.SteelBlue=[70,130,180,1],x.DodgerBlue=[30,144,255,1],x.DeepSkyBlue=[0,191,255,1],x.CornflowerBlue=[100,149,237,1],x.SkyBlue=[135,206,235,1],x.LightSkyBlue=[135,206,250,1],x.LightSteelBlue=[176,196,222,1],x.LightBlue=[173,216,230,1],x.PowderBlue=[176,224,230,1],x.Indigo=[75,0,130,1],x.Purple=[128,0,128,1],x.DarkMagenta=[139,0,139,1],x.DarkViolet=[148,0,211,1],x.DarkSlateBlue=[72,61,139,1],x.BlueViolet=[138,43,226,1],x.DarkOrchid=[153,50,204,1],x.Fuchsia=[255,0,255,1],x.Magenta=[255,0,255,1],x.SlateBlue=[106,90,205,1],x.MediumSlateBlue=[123,104,238,1],x.MediumOrchid=[186,85,211,1],x.MediumPurple=[147,112,219,1],x.Orchid=[218,112,214,1],x.Violet=[238,130,238,1],x.Plum=[221,160,221,1],x.Thistle=[216,191,216,1],x.Lavender=[230,230,250,1],x.MistyRose=[255,228,225,1],x.AntiqueWhite=[250,235,215,1],x.Linen=[250,240,230,1],x.Beige=[245,245,220,1],x.WhiteSmoke=[245,245,245,1],x.LavenderBlush=[255,240,245,1],x.OldLace=[253,245,230,1],x.AliceBlue=[240,248,255,1],x.Seashell=[255,245,238,1],x.GhostWhite=[248,248,255,1],x.Honeydew=[240,255,240,1],x.FloralWhite=[255,250,240,1],x.Azure=[240,255,255,1],x.MintCream=[245,255,250,1],x.Snow=[255,250,250,1],x.Ivory=[255,255,240,1],x.White=[255,255,255,1],x.Black=[0,0,0,1],x.DarkSlateGray=[47,79,79,1],x.DimGray=[105,105,105,1],x.SlateGray=[112,128,144,1],x.Gray=[128,128,128,1],x.LightSlateGray=[119,136,153,1],x.DarkGray=[169,169,169,1],x.Silver=[192,192,192,1],x.LightGray=[211,211,211,1],x.Gainsboro=[220,220,220,1],x.RebeccaPurple=[102,51,153,1];class X{}X.FPS_DISPLAY_TEXT_FONT_SIZE=12,X.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],X.FPS_DISPLAY_UPDATE_INTERVAL=1e3,X.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,X.FPS_METRIC_REPORT_THRESHOLD=59,X.DEFAULT_SCENE_BACKGROUND_COLOR=x.White,X.DEFAULT_SHAPE_FILL_COLOR=x.Red,X.DEFAULT_PATH_STROKE_COLOR=x.Red,X.DEFAULT_PATH_LINE_WIDTH=2,X.DEFAULT_FONT_COLOR=x.Black,X.DEFAULT_FONT_SIZE=16,X.LIMITED_FPS_RATE=5,X.FREE_NODES_SCENE_NAME="__freeNodesScene",X.OUTGOING_SCENE_NAME="__outgoingScene",X.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",X.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",X.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,X.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},X.DEFAULT_ROOT_ELEMENT_ID="m2c2kit";class Vs extends Ni{constructor(){super(...arguments),this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(t){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(t)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const t=this.linePresentations[this.linePresentations.length-1];return t.strokeColor!==this.strokeColor||t.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH}duplicate(){const t=super.duplicate();return t.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),t.lineWidth=this.lineWidth,t.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),t}}var Dt=(g=>(g.topToTopOf="topToTopOf",g.topToBottomOf="topToBottomOf",g.bottomToTopOf="bottomToTopOf",g.bottomToBottomOf="bottomToBottomOf",g.startToStartOf="startToStartOf",g.startToEndOf="startToEndOf",g.endToEndOf="endToEndOf",g.endToStartOf="endToStartOf",g))(Dt||{});class Pn{constructor(t,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Dt.topToTopOf,Dt.topToBottomOf,Dt.bottomToTopOf,Dt.bottomToBottomOf],this.focalNodeMinimumTypes=[Dt.topToTopOf,Dt.topToBottomOf,Dt.startToStartOf,Dt.startToEndOf],this.alterNodeMinimumTypes=[Dt.topToTopOf,Dt.bottomToTopOf,Dt.startToStartOf,Dt.endToStartOf],this.type=t,this.alterNode=i,this.verticalTypes.includes(t)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class De{static generate(){try{return crypto.randomUUID()}catch{let t;try{t=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{t=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(Number(i)^t()&15>>Number(i)/4).toString(16))}}static isValid(t){return t?t==="00000000-0000-0000-0000-000000000000"?!0:/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t):!1}}const G={ActivityStart:"ActivityStart",ActivityEnd:"ActivityEnd",ActivityCancel:"ActivityCancel",ActivityData:"ActivityData",GameWarmupStart:"GameWarmupStart",GameWarmupEnd:"GameWarmupEnd",TapDown:"TapDown",TapUp:"TapUp",TapUpAny:"TapUpAny",TapLeave:"TapLeave",PointerDown:"PointerDown",PointerUp:"PointerUp",PointerMove:"PointerMove",PointerLeave:"PointerLeave",Drag:"Drag",DragStart:"DragStart",DragEnd:"DragEnd",Composite:"Composite",FrameDidSimulatePhysics:"FrameDidSimulatePhysics",SceneSetup:"SceneSetup",SceneAppear:"SceneAppear",ScenePresent:"ScenePresent",NodeNew:"NodeNew",NodeAddChild:"NodeAddChild",NodeRemoveChild:"NodeRemoveChild",NodePropertyChange:"NodePropertyChange",DomPointerDown:"DomPointerDown",BrowserImageDataReady:"BrowserImageDataReady",I18nDataReadyEvent:"I18nDataReadyEvent"};class j{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}static value(t,i){return typeof t!=typeof i?!1:t&&typeof t=="object"&&i&&typeof i=="object"?j.objectsDeepEqual(t,i):t===i}static objectsDeepEqual(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return!1;for(let n=0;n<t.length;n++)if(!j.objectsDeepEqual(t[n],i[n]))return!1;return!0}if(typeof t=="object"&&!Array.isArray(t)&&t!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const n=Object.keys(t),u=Object.keys(i);if(n.length!==u.length)return!1;for(const h of n)if(!(h in i)||!j.objectsDeepEqual(t[h],i[h]))return!1;return!0}return!1}}function Ys(g,t){t.anchorPoint&&(g.anchorPoint=t.anchorPoint),t.zPosition!==void 0&&(g.zPosition=t.zPosition)}function qs(g,t){t.text!==void 0&&(g.text=t.text),t.fontName!==void 0&&(g.fontName=t.fontName),t.fontColor&&(g.fontColor=t.fontColor),t.fontSize!==void 0&&(g.fontSize=t.fontSize),t.interpolation&&(g.interpolation=t.interpolation),t.localize!==void 0&&(g.localize=t.localize)}function Fe(g,t){g.isDrawable&&Ys(g,t),g.isText&&qs(g,t)}class re{constructor(t={}){this.type=at.Node,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this._suppressEvents=!1,this._position={x:0,y:0},this._scale=1,this._alpha=1,this._zRotation=0,this._isUserInteractionEnabled=!1,this._draggable=!1,this._hidden=!1,this.layout={},this.children=new Array,this.absolutePosition={x:0,y:0},this._size={width:0,height:0},this.absoluteScale=1,this.absoluteAlpha=1,this.absoluteAlphaChange=0,this.actions=new Array,this.eventListeners=new Array,this.uuid=De.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.nodeEvents=new Array,this.pressed=!1,this.withinHitArea=!1,this.pressedAndWithinHitArea=!1,this.pressedInitialPointerOffset={x:NaN,y:NaN},this.draggingLastPointerOffset={x:NaN,y:NaN},this.dragging=!1,this.toString=()=>{let i=this.type.toString();return this.type==at.Composite&&(i=this.compositeType),this.name!==this.uuid?`${this.name} (${i}, ${this.uuid})`:`${i} (${this.uuid})`},t.suppressEvents!==void 0&&(this.suppressEvents=t.suppressEvents),this.constructionTimeStamp=Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Wt.now():m2c2Globals.now,this.constructionIso8601TimeStamp=new Date().toISOString(),this.constructionSequence=m2c2Globals.eventSequence,this.options=t,t.uuid!==void 0&&(this.uuid=t.uuid),t.name===void 0?this.name=this.uuid:this.name=t.name,t.position!==void 0&&(this.position=t.position),t.scale!==void 0&&(this.scale=t.scale),t.alpha!==void 0&&(this.alpha=t.alpha),t.zRotation!==void 0&&(this.zRotation=t.zRotation),t.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=t.isUserInteractionEnabled),t.draggable!==void 0&&(this.draggable=t.draggable),t.hidden!==void 0&&(this.hidden=t.hidden),t.layout!==void 0&&(this.layout=t.layout)}initialize(){throw new Error("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new Error("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const t={type:G.NodeNew,target:this,nodeType:this.type,compositeType:this.type===at.Composite?this.compositeType:void 0,timestamp:this.constructionTimeStamp,iso8601Timestamp:this.constructionIso8601TimeStamp,nodeOptions:this.completeNodeOptions,sequence:this.constructionSequence};this.saveEvent(t)}savePropertyChangeEvent(t,i){if(this.suppressEvents)return;const n={type:G.NodePropertyChange,target:this,uuid:this.uuid,property:t,value:i,...q.createFrameUpdateTimestamps()};this.saveEvent(n)}saveEvent(t){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);try{this.game.eventStore.addEvent(t)}catch{this.nodeEvents.push(t)}}get game(){const t=i=>{if(i.parent)return i.parent.type===at.Scene?i.parent:t(i.parent);throw new Error(`Node ${this} has not been added to a scene.`)};return t(this).game}isPartOfGame(){if(this.type===at.Scene&&this._game===void 0)return!1;if(this.type===at.Scene&&this._game!==void 0)return!0;const t=i=>{if(i.parent)return i.parent.type===at.Scene?i.parent:t(i.parent)};return t(this)?._game!==void 0}addChild(t){const i=this.suppressEvents||t.suppressEvents;if(t===this)throw new Error(`Cannot add node ${t.toString()} as a child to itself.`);if(t.type==at.Scene)throw new Error(`Cannot add scene ${t.toString()} as a child to node ${this.toString()}. A scene cannot be the child of a node. A scene can only be added to a game object.`);if(this.children.filter(h=>h!==t).map(h=>h.name).includes(t.name))throw new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. A child with name "${t.name}" already exists on this parent.`);let n=new Array;if(this.isPartOfGame())n=this.game.nodes.filter(h=>h.children.includes(t));else{const h=this.descendants;h.includes(t)&&(n=h.filter(C=>C.children.includes(t)).map(C=>C.parent??void 0))}if(n.length===0){t.parent=this,this.children.push(t);const h={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(h),this.saveChildEvents(t);return}const u=n.find(Boolean);throw u===this?new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${u?.toString()}}. Remove the child from the other parent first.`)}saveChildEvents(t){t.nodeEvents.forEach(i=>{this.saveEvent(i)}),t.nodeEvents.length=0;for(const i of t.children)this.saveChildEvents(i)}removeAllChildren(){this.children.forEach(t=>this.removeChild(t))}removeChild(t){const i=this.suppressEvents||t.suppressEvents;if(this.children.includes(t))t.parent=void 0,this.children=this.children.filter(u=>u!==t);else throw new Error(`cannot remove node ${t} from parent ${this} because the node is not currently a child of the parent`);const n={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(n)}removeChildren(t){t.forEach(i=>{if(!this.children.includes(i))throw new Error(`cannot remove node ${i} from parent ${this} because the node is not currently a child of the parent`);this.removeChild(i)})}descendant(t){const i=this.descendants.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`descendant with name ${t} not found on parent ${this.toString()}`);return i}get descendants(){function t(n,u){u.push(n),n.children.forEach(h=>t(h,u))}const i=new Array;return this.children.forEach(n=>t(n,i)),i}get ancestors(){function t(n,u){return n.type==at.Scene||!n.parent?u:(u.push(n.parent),t(n.parent,u))}const i=new Array;return t(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(n=>n.actions).some(n=>n.running&&(n.type===pt.Move||n.type===pt.Scale))}involvedInSceneTransition(){let t;return this.type===at.Scene?t=this:t=this.parentSceneAsNode,t._transitioning}onTapDown(t,i){this.addEventListener(G.TapDown,t,i)}onTapUp(t,i){this.addEventListener(G.TapUp,t,i)}onTapUpAny(t,i){this.addEventListener(G.TapUpAny,t,i)}onTapLeave(t,i){this.addEventListener(G.TapLeave,t,i)}onPointerDown(t,i){this.addEventListener(G.PointerDown,t,i)}onPointerUp(t,i){this.addEventListener(G.PointerUp,t,i)}onPointerMove(t,i){this.addEventListener(G.PointerMove,t,i)}onPointerLeave(t,i){this.addEventListener(G.PointerLeave,t,i)}onDragStart(t,i){this.addEventListener(G.DragStart,t,i)}onDrag(t,i){this.addEventListener(G.Drag,t,i)}onDragEnd(t,i){this.addEventListener(G.DragEnd,t,i)}addEventListener(t,i,n){const u={type:t,nodeUuid:this.uuid,callback:i};n?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(h=>!(h.nodeUuid===u.nodeUuid&&h.type===u.type))),this.eventListeners.push(u)}parseLayoutConstraints(t,i){const n=new Array;return Object.values(Dt).forEach(h=>{if(t[h]!==void 0){let C,F="";if(typeof t[h]=="object")C=t[h];else{const U=t[h];C=i.filter(et=>et.name===U||et.uuid===U).find(Boolean),C||(C=this.game.materializedNodes.filter(et=>et.name===U||et.uuid===U).find(Boolean)),F=`. sibling node named "${U}" has not been added to the game object`}if(C===void 0)throw new Error("could not find sibling node for constraint"+F);const B=new Pn(h,C);n.push(B)}}),n}calculateYFromConstraint(t,i,n,u){let h=t.alterNode.absolutePosition.y;return t.alterNodeMinimum?t.alterNode.type!==at.Scene&&(h=h-t.alterNode.size.height*.5*u):t.alterNode.type!==at.Scene?h=h+t.alterNode.size.height*.5*u:h=h+t.alterNode.size.height*u,t.focalNodeMinimum?(h=h+this.size.height*.5*u,h=h+i*u):(h=h-this.size.height*.5*u,h=h-n*u),h}calculateXFromConstraint(t,i,n,u){let h=t.alterNode.absolutePosition.x;return t.alterNodeMinimum?t.alterNode.type!==at.Scene&&(h=h-t.alterNode.size.width*.5*u):t.alterNode.type!==at.Scene?h=h+t.alterNode.size.width*.5*u:h=h+t.alterNode.size.width*u,t.focalNodeMinimum?(h=h+this.size.width*.5*u,h=h+i*u):(h=h-this.size.width*.5*u,h=h-n*u),h}calculateAbsoluteAlpha(t,i){const n=i.reduce((u,h)=>u*h.alpha,1);return t*n}update(){if(this.needsInitialization&&this.initialize(),this.absoluteAlphaChange=this.calculateAbsoluteAlpha(this.alpha,this.ancestors)-this.absoluteAlpha,this.absoluteAlpha+=this.absoluteAlphaChange,this.parent===void 0)this.absolutePosition.x=this.position.x*this.scale,this.absolutePosition.y=this.position.y*this.scale,this.absoluteScale=this.scale;else if(this.absoluteScale=this.parent.absoluteScale*this.scale,this.layout?.constraints===void 0)this.absolutePosition.x=this.parent.absolutePosition.x+this.position.x*this.parent.absoluteScale,this.absolutePosition.y=this.parent.absolutePosition.y+this.position.y*this.parent.absoluteScale;else{const u=this.layout?.constraints?.horizontalBias??.5,h=this.layout?.constraints?.verticalBias??.5,C=this.layout?.marginTop??0,F=this.layout?.marginBottom??0,B=this.layout?.marginStart??0,U=this.layout?.marginEnd??0,et=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),ct=this.parent.absoluteScale,ut=et.filter(yt=>yt.verticalConstraint).map(yt=>this.calculateYFromConstraint(yt,C,F,ct));ut.length===0||(ut.length===1?this.absolutePosition.y=ut[0]:ut.length===2&&(this.absolutePosition.y=Math.min(ut[0],ut[1])+h*Math.abs(ut[0]-ut[1])));const At=et.filter(yt=>!yt.verticalConstraint).map(yt=>this.calculateXFromConstraint(yt,B,U,ct));At.length===0||(At.length===1?this.absolutePosition.x=At[0]:At.length===2&&(this.absolutePosition.x=Math.min(At[0],At[1])+u*Math.abs(At[0]-At[1])))}this.actions.forEach(u=>V.evaluateAction(u,this,m2c2Globals.now,m2c2Globals.deltaTime));function t(u,h){const C=new Array;return h===void 0||Object.values(Dt).forEach(B=>{if(h[B]!==void 0){let U,et="";if(typeof h[B]=="object")U=h[B];else{const ct=h[B];let ut;u.type===at.Scene?ut=u.descendants:ut=u.parentSceneAsNode.descendants,U=ut.filter(At=>At.name===ct||At.uuid===ct).find(Boolean),U===void 0&&(U=u.game.materializedNodes.filter(At=>At.name===ct||At.uuid===ct).find(Boolean)),U===void 0&&(et=`. sibling node named "${ct}" has not been added to the game object`)}if(U===void 0)throw new Error("error getting uuid of sibling constraint"+et);U!==u&&C.push(U.uuid)}}),C}const i=new Map;this.children.forEach(u=>{i.set(u.uuid,t(this,u.layout?.constraints))});const n=this.findTopologicalSort(i);if(n.length>0){const u=n.reverse(),h=new Array;u.forEach(C=>{const F=this.children.filter(B=>B.uuid===C).find(Boolean);if(F===void 0)throw new Error("error in dag topological sort");h.push(F)}),h.forEach(C=>C.update())}else this.children.forEach(u=>u.update())}drawChildren(t){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,n)=>i.zPosition-n.zPosition).forEach(i=>i.draw(t))}run(t,i){this.actions.push(t.initialize(i))}removeAction(t){this.actions=this.actions.filter(i=>i.key!==t)}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getNodeOptions(){return{name:this.name,position:this.position,scale:this.scale,alpha:this.alpha,zRotation:this.zRotation,isUserInteractionEnabled:this.isUserInteractionEnabled,draggable:this.draggable,hidden:this.hidden,layout:this.layout,uuid:this.uuid}}getDrawableOptions(){if(!this.isDrawable)throw new Error("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new Error("getTextOptions() called object that is not IText");return{text:this.text,fontName:this.fontName,fontColor:this.fontColor,fontSize:this.fontSize}}get canvasKit(){return this.game.canvasKit}get parentSceneAsNode(){if(this.type===at.Scene)throw new Error(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===at.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new Error(`Node ${this} has not been added to a scene`)}get size(){const t=this;return{get height(){return t._size.height},set height(i){j.value(t._size.height,i)||(t._size.height=i,t.savePropertyChangeEvent("size",t.size))},get width(){return t._size.width},set width(i){j.value(t._size.width,i)||(t._size.width=i,t.savePropertyChangeEvent("size",t.size))}}}set size(t){j.value(this._size.width,t.width)||(this._size=t,this.savePropertyChangeEvent("size",this.size))}get position(){const t=this;return{get x(){return t._position.x},set x(i){j.value(t._position.x,i)||(t._position.x=i,t.savePropertyChangeEvent("position",t.position))},get y(){return t._position.y},set y(i){j.value(t._position.y,i)||(t._position.y=i,t.savePropertyChangeEvent("position",t.position))}}}set position(t){j.value(this._position,t)||(this._position=t,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(t){j.value(this._zRotation,t)||(this._zRotation=t,this.savePropertyChangeEvent("zRotation",t))}get scale(){return this._scale}set scale(t){j.value(this._scale,t)||(this._scale=t,this.savePropertyChangeEvent("scale",t))}get alpha(){return this._alpha}set alpha(t){j.value(this._alpha,t)||(this._alpha=t,this.savePropertyChangeEvent("alpha",t))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(t){j.value(this._isUserInteractionEnabled,t)||(this._isUserInteractionEnabled=t,this.savePropertyChangeEvent("isUserInteractionEnabled",t))}get hidden(){return this._hidden}set hidden(t){j.value(this._hidden,t)||(this._hidden=t,this.savePropertyChangeEvent("hidden",t))}get draggable(){return this._draggable}set draggable(t){j.value(this._draggable,t)||(this._draggable=t,this.savePropertyChangeEvent("draggable",t))}get suppressEvents(){return this._suppressEvents}set suppressEvents(t){this._suppressEvents=t}findTopologicalSort(t){const i=[],n=new Map;t.forEach((h,C)=>{n.has(C)||n.set(C,0),h.forEach(F=>{if(n.has(F)){const B=n.get(F);if(B===void 0)throw new Error(`Could not find inDegree for edge ${F}`);n.set(F,B+1)}else n.set(F,1)})});const u=[];for(n.forEach((h,C)=>{h==0&&u.push(C)});u.length>0;){const h=u.shift();if(h===void 0)throw"current vertex is undefined";i.push(h),t.has(h)&&t.get(h)?.forEach(C=>{const F=n.get(C);if(F===void 0)throw new Error(`Could not find inDegree for edge ${C}`);if(n.has(C)&&F>0){const B=F-1;n.set(C,B),B==0&&u.push(C)}})}return i}}class Xs extends re{constructor(t={}){super(t),this.type=at.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,Fe(this,t)}initialize(){}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){}update(){super.update()}draw(t){super.drawChildren(t)}handleCompositeEvent(t){}}var bn=(g=>(g[g.MatchConstraint=0]="MatchConstraint",g))(bn||{});const qt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class or{constructor(t,i){this.images={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit}initializeImages(t){return this.loadImages(t??[])}async loadImages(t){if(t.length===0)return;this.checkImageNamesForDuplicates(t);const i=t.map(n=>{let u=n.url;n.url&&!q.urlHasScheme(n.url)&&(u=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${n.url}`)),n.dataUrl&&(u=n.dataUrl);const h={imageName:n.imageName,url:u,originalUrl:u,isFallback:!1,localize:n.localize??!1,svgString:n.svgString,canvaskitImage:void 0,width:n.width,height:n.height,status:n.lazy?qt.Deferred:qt.Loading};return h.localize&&this.configureImageLocalization(h),this.images[n.imageName]=h,h.status===qt.Loading?this.renderM2Image(h):Promise.resolve()});await Promise.all(i)}configureImageLocalization(t){t.fallbackLocalizationUrls=new Array,t.originalUrl&&this.game.i18n?.locale&&(t.status="Deferred",this.game.i18n?.fallbackLocale&&this.game.i18n?.fallbackLocale!==this.game.i18n?.baseLocale&&t.fallbackLocalizationUrls.push(this.localizeImageUrl(t.originalUrl,this.game.i18n.fallbackLocale)),this.game.i18n?.locale===this.game.i18n?.baseLocale?t.url=t.originalUrl:t.url=this.localizeImageUrl(t.originalUrl,this.game.i18n.locale),t.url!==t.originalUrl&&t.fallbackLocalizationUrls.push(t.originalUrl),this.game.i18n.missingLocalizationColor&&!this.missingLocalizationImagePaint&&(this.missingLocalizationImagePaint=Ft.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(t,i){const n=t.lastIndexOf(".");if(n===-1)throw new Error("URL does not have an extension");return t.slice(0,n)+`.${i}`+t.slice(n)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const n=this.game.imageManager.images[i];n.localize&&this.game.imageManager.configureImageLocalization(n)}),this.game.nodes.filter(i=>i.type===at.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(t){const n=(u=>u.filter((h,C)=>u.indexOf(h)!=C))(t.map(u=>u.imageName));if(n.length>0)throw new Error(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+n.join(", "))}prepareDeferredImage(t){return t.status=qt.Loading,t.isFallback=!1,this.renderM2Image(t).catch(async()=>{for(t.isFallback=!0;t.fallbackLocalizationUrls?.length;){t.url=t.fallbackLocalizationUrls.shift();try{await this.renderM2Image(t)}catch(i){if(t.fallbackLocalizationUrls.length===0)throw i instanceof Error?i:new Error(`prepareDeferredImage(): unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`)}}})}renderM2Image(t){const i=document.createElement("img"),n=u=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new Error("image manager not set up");this.scratchCanvas.width=t.width*this.scale,this.scratchCanvas.height=t.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,t.width,t.height),this.ctx.drawImage(i,0,0,t.width,t.height),this.scratchCanvas.toBlob(h=>{if(!h)throw new Error(`renderM2Image(): blob is undefined for ${t.imageName}`);h.arrayBuffer().then(C=>{const F=this.canvasKit.MakeImageFromEncoded(C);if(!F)throw new Error(`could not create image with name "${t.imageName}."`);console.log(`image loaded. name: ${t.imageName}, w: ${t.width}, h: ${t.height}`),this.images[t.imageName].canvaskitImage=F,this.images[t.imageName].status=qt.Ready,this.game.nodes.filter(U=>U.type==="Sprite").forEach(U=>{U.imageName===t.imageName&&(U.needsInitialization=!0)}),u()})})};return new Promise((u,h)=>{if(i.width=t.width,i.height=t.height,i.crossOrigin="Anonymous",i.onerror=()=>{h(new Error(`unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`))},i.onload=()=>{n(u)},!t.svgString&&!t.url)throw new Error(`no svgString or url provided for image named ${t.imageName}`);if(t.svgString&&t.url)throw new Error(`provide svgString or url. both were provided for image named ${t.imageName}`);if(t.svgString){i.src="data:image/svg+xml,"+encodeURIComponent(t.svgString);const C={type:G.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,svgString:t.svgString,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(C)}else t.url&&fetch(t.url).then(C=>C.arrayBuffer()).then(C=>{this.arrayBufferToBase64Async(C).then(F=>{const B=this.inferImageSubtypeFromUrl(t.url);i.src="data:image/"+B+";base64,"+F;const U={type:G.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,dataUrl:i.src,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(U)})})})}arrayBufferToBase64Async(t){return new Promise((i,n)=>{const u=new FileReader;u.onload=()=>{i(u.result?.toString().split(",")[1]??"")},u.onerror=n,u.readAsDataURL(new Blob([t]))})}inferImageSubtypeFromUrl(t){if(t?.startsWith("data:image/"))return t.split(";")[0].split("/")[1];let i="jpeg";return t?.includes(".")&&(i=t.split(".").pop()?.toLowerCase()??"jpeg",i===""&&(i="jpeg")),i==="svg"&&(i="svg+xml"),i}getImage(t){return this.images[t]}addImage(t){this.images[t.imageName]=t}get scratchCanvas(){if(!this._scratchCanvas){this._scratchCanvas=document.createElement("canvas"),this._scratchCanvas.id=`m2c2kit-scratch-canvas-${this.game.id}-${Math.floor(Math.random()*1e6)}`,this._scratchCanvas.hidden=!0,document.body.appendChild(this._scratchCanvas);const t=this._scratchCanvas.getContext("2d");if(t===null)throw new Error("could not get 2d canvas context from scratch canvas");this.ctx=t,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}class xi{constructor(t,i){this.locale="",this.fallbackLocale="en-US",this.baseLocale="en-US",this.game=t,this._translation=this.mergeAdditionalTranslation(i.translation,i.additionalTranslation)??{},this.translation.configuration?.baseLocale&&(this.baseLocale=this.translation.configuration.baseLocale),i.missingLocalizationColor&&(this.missingLocalizationColor=i.missingLocalizationColor),i.locale&&(this.locale=i.locale),i.fallbackLocale&&(this.fallbackLocale=i.fallbackLocale)}async initialize(){await this.configureInitialLocale()}async configureInitialLocale(){if(this.game.hasDataStores()){const t=await this.game.storeGetItem("locale"),i=await this.game.storeGetItem("fallbackLocale");if(typeof t=="string"&&typeof i=="string"){this.locale=t,this.fallbackLocale=i;return}}if(this.locale?.toLowerCase()==="auto"){const t=this.getEnvironmentLocale();t?this.localeTranslationAvailable(t)?(this.locale=t,this.localeTranslationAvailable(this.fallbackLocale)||(this.fallbackLocale=this.baseLocale)):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but detected locale ${t} does not have translation. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but detected locale ${t} does not have translation, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but environment cannot detect locale. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but environment cannot detect locale, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale)}else this.locale=this.locale??"",this.fallbackLocale||(this.fallbackLocale=this.baseLocale)}localeTranslationAvailable(t){return this.translation[t]!==void 0||t===this.baseLocale}switchToLocale(t){this.locale=t,this.game.nodes.filter(i=>i.isText).forEach(i=>i.needsInitialization=!0),this.game.imageManager.reinitializeLocalizedImages(),this.game&&this.game.hasDataStores()&&(this.game.storeSetItem("locale",this.locale),this.game.storeSetItem("fallbackLocale",this.fallbackLocale))}getTextLocalization(t,i){let n="",u=!1,h=this.tf(t,i);return h?.text!==void 0?n=h.text:(h=this.tf(t,{useFallbackLocale:!0,...i}),h===void 0||h.text===void 0?n=t:n=h.text,u=!0),{text:n,fontName:h?.fontName,fontNames:h?.fontNames,isFallbackOrMissingTranslation:u}}t(t,i){const{useFallbackLocale:n,...u}=i??{};if(n!==!0){const C=this.translation[this.locale]?.[t];return this.isStringOrTextWithFontCustomization(C)?this.insertInterpolations(this.getKeyText(C),u):void 0}const h=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(h))return this.insertInterpolations(this.getKeyText(h),u)}tf(t,i){const{useFallbackLocale:n,...u}=i??{};if(n!==!0){const C=this.translation[this.locale]?.[t];if(this.isStringOrTextWithFontCustomization(C)){const F=this.getKeyTextAndFont(C,this.locale);return F.text&&(F.text=this.insertInterpolations(F.text,u)),F}return}const h=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(h)){const C=this.getKeyTextAndFont(h,this.fallbackLocale);return C.text&&(C.text=this.insertInterpolations(C.text,u)),C}}getKeyText(t){return this.isTextWithFontCustomization(t)?t.text:t}getKeyTextAndFont(t,i){let n=new Array;this.isString(this.translation[i]?.fontName)?n.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?n.push(...this.translation[i].fontName):n.push("default");let u;switch(this.isTextWithFontCustomization(t)?(u=t.text,this.isString(t.additionalFontName)&&n.push(t.additionalFontName),this.isStringArray(t.additionalFontName)&&n.push(...t.additionalFontName),t.overrideFontName&&(n.length=0,this.isString(t.overrideFontName)&&n.push(t.overrideFontName),this.isStringArray(t.overrideFontName)&&n.push(...t.overrideFontName))):u=t,n=n.filter(h=>h!=="default"),n.length){case 0:return{text:u};case 1:return{text:u,fontName:n[0]};default:return{text:u,fontNames:n}}}insertInterpolations(t,i){return i?t.replace(/\{\{(.*?)\}\}/g,(n,u)=>{if(Object.prototype.hasOwnProperty.call(i,u))return i[u];throw new Error(`insertInterpolations(): placeholder "${u}" not found. Text was ${t}, provided interpolation was ${JSON.stringify(i)}`)}):t}get translation(){return this._translation}set translation(t){this._translation=t}getEnvironmentLocale(){return(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language)??""}mergeAdditionalTranslation(t,i){if(!t&&!i)return;if(!i)return t;if(!t)return i;const n={},u=new Array;for(const h in t)u.push(h),n[h]={...t[h],...i[h]};for(const h in i)u.includes(h)||(n[h]=i[h]);return n}static makeLocalizationParameters(){return JSON.parse(JSON.stringify({locale:{type:["string","null"],default:null,description:'Locale to use for localization, or "auto" to request from the environment.'},fallback_locale:{type:["string","null"],default:null,description:'Locale to use if requested locale translation is not available, or if "auto" locale was requested and environment cannot provide a locale.'},missing_localization_color:{type:["array","null"],default:null,description:"Font color for strings that are missing translation and outline color for images that are missing localization, [r,g,b,a].",items:{type:"number"}},translation:{type:["object","null"],default:null,description:"Additional translation for localization."}}))}isTextWithFontCustomization(t){return t?.text!==void 0}isStringOrTextWithFontCustomization(t){return typeof t=="string"||this.isTextWithFontCustomization(t)}isStringArray(t){return Array.isArray(t)&&t.every(i=>typeof i=="string")}isString(t){return typeof t=="string"}}const ce={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class An{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=ce.Disabled}serializeEvent(t){const i=t.target;if(t.type===G.NodeNew&&t.nodeOptions?.layout?.constraints!==void 0){const u=t.nodeOptions?.layout?.constraints,h={};for(const F in u){if(F==="horizontalBias"||F==="verticalBias"){h[F]=u[F];continue}const B=u[F];B instanceof re&&(h[F]=B.uuid)}t.target=i.uuid,t.nodeOptions.layout.constraints=h;const C=JSON.stringify(t);return t.target=i,t.nodeOptions.layout.constraints=u,C}if(i instanceof re){t.target=i.uuid;const u=JSON.stringify(t);return t.target=i,u}if(i instanceof Element){t.target=i.nodeName;const u=JSON.stringify(t);return t.target=i,u}if(i instanceof or){t.target="ImageManager";const u=JSON.stringify(t);return t.target=i,u}if(i instanceof xi){t.target="I18n";const u=JSON.stringify(t);return t.target=i,u}t.target="object";const n=JSON.stringify(t);return t.target=i,n}addEvent(t){if(this.mode===ce.Record){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);const i=this.serializeEvent(t);this.events.push(JSON.parse(i))}}addEvents(t){t.forEach(i=>{this.addEvent(i)})}clearEvents(){this.events=[]}record(){this.mode=ce.Record}replay(t){if(t&&(this.events=t),this.events.length===0)if(this.serializedEventsBeforeReplay!=="")this.events=JSON.parse(this.serializedEventsBeforeReplay);else{console.log("Event store has no events to replay.");return}this.mode=ce.Replay,this.replayBeginTimestamp=Wt.now(),this.sortEventStore(this.events),this.serializedEventsBeforeReplay===""&&(this.serializedEventsBeforeReplay=JSON.stringify(this.events)),this.firstTimestamp=this.events[0].timestamp,console.log(`Event store has ${this.events.length} events. Replay beginning.`);const i=document.getElementById("sequence-number");i&&(this.replayThoughSequence=parseInt(i.value))}getEvents(){return this.sortEventStore(this.events),this.events}dequeueEvents(t){const i=new Array,n=t-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=n;){const u=this.events.shift();if(!u)throw new Error("EventStore.dequeueEvents(): undefined event");u.sequence!==void 0&&u.sequence>this.replayThoughSequence||i.push(u)}return i}get eventQueueLength(){return this.events.length}sortEventStore(t){t.sort((i,n)=>{if(i.sequence===void 0||n.sequence===void 0)throw new Error("EventStore.sortEventStore(): undefined sequence");return i.sequence!==n.sequence?i.sequence-n.sequence:0})}}var ze=(g=>(g[g.Center=0]="Center",g[g.Left=1]="Left",g[g.Right=2]="Right",g))(ze||{});const Xt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class ki extends re{constructor(t={}){super(t),this.type=at.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=X.DEFAULT_FONT_COLOR,this._fontSize=X.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=ze.Center,this._localize=!0,this.localizedFontNames=[],Fe(this,t),t.horizontalAlignmentMode&&(this.horizontalAlignmentMode=t.horizontalAlignmentMode),t.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=t.preferredMaxLayoutWidth),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),t.fontNames&&(this.fontNames=t.fontNames),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,fontNames:this.fontNames}}initialize(){let t=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case ze.Center:t=this.canvasKit.TextAlign.Center;break;case ze.Left:t=this.canvasKit.TextAlign.Left;break;case ze.Right:t=this.canvasKit.TextAlign.Right;break;default:throw new Error("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]),n;const u=this.game.i18n;if(u&&this.localize!==!1){const U=u.getTextLocalization(this.text,this.interpolation);n=U.text,this.localizedFontName=U.fontName,this.localizedFontNames=U.fontNames??[],U.isFallbackOrMissingTranslation&&u.missingLocalizationColor&&(i=this.canvasKit.Color(u.missingLocalizationColor[0],u.missingLocalizationColor[1],u.missingLocalizationColor[2],u.missingLocalizationColor[3]))}else n=this.text;if(this.fontName&&this.fontNames)throw new Error("cannot specify both fontName and fontNames");const h=this.game.fontManager,C=this.getRequiredLabelFonts(h);if(C.forEach(U=>{if(U.status===Xt.Deferred){h.prepareDeferredFont(U);return}}),!C.every(U=>U.status===Xt.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:t}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,h.provider),this._backgroundPaint||(this._backgroundPaint=new this.canvasKit.Paint),this._fontPaint||(this._fontPaint=new this.canvasKit.Paint),this.fontPaint.setColor(i),this.fontPaint.setAlphaf(this.absoluteAlpha),this.backgroundColor?(this.backgroundPaint.setColor(this.backgroundColor),this.backgroundPaint.setAlphaf(this.absoluteAlpha)):this.backgroundPaint.setColor(this.canvasKit.Color(0,0,0,0)),this.builder.pushPaintStyle({fontFamilies:C.map(U=>U.fontName),fontSize:this.fontSize*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Oblique},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0},this.fontPaint,this.backgroundPaint),this.builder.addText(n),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const F=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let B=F;if(F===0||this.layout.width===0){if(this.parent===void 0)throw new Error("width is set to match parent, but node has no parent");const U=this.layout.marginStart??0,et=this.layout.marginEnd??0;B=this.parent.size.width-(U+et)}this.paragraph.layout(B*m2c2Globals.canvasScale),F===0||this.layout.width===0?this.size.width=B:(this.paragraph.layout(Math.ceil(this.paragraph.getLongestLine())),this.size.width=this.paragraph.getMaxWidth()/m2c2Globals.canvasScale),this.size.height=this.paragraph.getHeight()/m2c2Globals.canvasScale,this.needsInitialization=!1}getRequiredLabelFonts(t){let i;if(this.game.i18n&&this.localize!==!1){if(this.localizedFontName)return i=[t.fonts[this.localizedFontName]],i;if(this.localizedFontNames.length>0)return i=this.localizedFontNames.map(n=>t.fonts[n]),i}if(this.fontName===void 0&&this.fontNames===void 0)i=[t.getDefaultFont()];else if(this.fontName!==void 0)i=[t.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)i=this.fontNames.map(n=>t.fonts[n]);else throw new Error("cannot determine required fonts");return i}dispose(){Ft.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(t){j.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get interpolation(){return this._interpolation}set interpolation(t){j.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get fontName(){return this._fontName}set fontName(t){j.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontNames(){return this._fontNames}set fontNames(t){j.value(this._fontNames,t)||(this._fontNames=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",t))}get fontColor(){return this._fontColor}set fontColor(t){j.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){j.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){j.value(this._horizontalAlignmentMode,t)||(this._horizontalAlignmentMode=t,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",t))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){j.value(this._preferredMaxLayoutWidth,t)||(this._preferredMaxLayoutWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",t))}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){j.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get localize(){return this._localize}set localize(t){j.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}get backgroundPaint(){if(!this._backgroundPaint)throw new Error("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(t){this._backgroundPaint=t}get fontPaint(){if(!this._fontPaint)throw new Error("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(t){this._fontPaint=t}duplicate(t){const i=new ki({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(t){if(this.parent&&this.text!==""&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,u=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new Error("no paragraph");t.drawParagraph(this.paragraph,n,u),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const u=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=u.fontName,this.localizedFontNames=u.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(u=>u.status===Xt.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new Error(`warmup Label node ${this.toString()}: paragraph is undefined`);t.drawParagraph(this.paragraph,0,0)}}}class Ue extends re{constructor(t={}){super(t),this.type=at.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=X.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,Fe(this,t),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor}}initialize(){this.scale=m2c2Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint&&this.backgroundPaint.delete(),this.backgroundPaint=Ft.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Ft.Dispose([this.backgroundPaint])}set game(t){this._game=t}get game(){if(this._game===void 0)throw new Error(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){j.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}duplicate(t){const i=new Ue({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:t});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}onSetup(t,i){this.addEventListener("SceneSetup",t,i)}onAppear(t,i){this.addEventListener("SceneAppear",t,i)}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),super.drawChildren(t)}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),this.children.forEach(n=>{n.isDrawable&&n.warmup(t)})}}class ai extends re{constructor(t={}){if(super(t),this.type=at.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Ut.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=X.DEFAULT_SHAPE_FILL_COLOR,this._isAntialiased=!0,this.svgPathScaleForResizing=1,this.svgPathWidth=0,this.svgPathHeight=0,this.svgPreviousAbsoluteX=NaN,this.svgPreviousAbsoluteY=NaN,this.svgFirstPathDraw=!0,this.colorfulPathPaints=new Map,Fe(this,t),t.path!==void 0){if(this.path=t.path,this.shapeType=Ut.Path,this.shapeIsM2Path()&&t.size!==void 0&&(this.size=t.size),this.shapeIsSvgStringPath()&&t.size!==void 0)throw new Error("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=t.path.width,this.svgPathRequestedHeight=t.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new Error("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH),t.circleOfRadius||t.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect")}if(t.circleOfRadius!==void 0){if(this.circleOfRadius=t.circleOfRadius,this.shapeType=Ut.Circle,t.size!==void 0)throw new Error("Size cannot be specified for circle shape");if(t.path||t.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(t.rect&&(this.rect=t.rect,t.rect.size?(this.size.width=t.rect.size.width,this.size.height=t.rect.size.height):t.rect.width!==void 0&&t.rect.height!==void 0&&(this.size.width=t.rect.width,this.size.height=t.rect.height),t.rect.origin?this.position=t.rect.origin:t.rect.x!==void 0&&t.rect.y!==void 0&&(this.position={x:t.rect.x,y:t.rect.y}),this.shapeType=Ut.Rectangle,t.size!==void 0))throw new Error("Size cannot be specified for rectangle shape");t.cornerRadius!==void 0&&(this.cornerRadius=t.cornerRadius),t.fillColor&&(this.fillColor=t.fillColor),t.strokeColor&&(this.strokeColor=t.strokeColor),t.lineWidth!==void 0&&(this.lineWidth=t.lineWidth),t.isAntialiased!==void 0&&(this.isAntialiased=t.isAntialiased),t.strokeColor&&!t.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${t.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),t.strokeColor===void 0&&t.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${t.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`),this.saveNodeNewEvent()}get completeNodeOptions(){let t;return this.shapeIsM2Path()&&(t=this.size),{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,path:this.path,size:t,isAntialiased:this.isAntialiased}}initialize(){if(this.shapeType===Ut.Path&&this.shapeIsSvgStringPath()){const t=this.path.pathString??this.path.svgPathString;if(!t)throw new Error("SVG Path string is null/undefined");if(this.path.svgPathString!==void 0&&console.warn("warning: svgPathString is deprecated. Use pathString instead."),this.ckPath=this.canvasKit.Path.MakeFromSVGString(t),!this.ckPath)throw new Error("could not make CanvasKit Path from SVG string");const i=this.ckPath.getBounds();this.svgPathWidth=i[2]+(i[0]<0?Math.abs(i[0]):0),this.svgPathHeight=i[3]+(i[1]<0?Math.abs(i[1]):0),this.svgPathRequestedHeight!==void 0?this.svgPathScaleForResizing=this.svgPathRequestedHeight/this.svgPathHeight:this.svgPathRequestedWidth!==void 0&&(this.svgPathScaleForResizing=this.svgPathRequestedWidth/this.svgPathWidth),this.size.width=this.svgPathWidth*this.svgPathScaleForResizing,this.size.height=this.svgPathHeight*this.svgPathScaleForResizing,this.svgPreviousAbsoluteX=0,this.svgPreviousAbsoluteY=0}if(this.shapeIsM2Path()&&(this.size.width===0||this.size.height===0||this.size.width===void 0||this.size.height===void 0))throw new Error("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Ft.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Ft.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Ft.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Ft.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Ft.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(t){const i=new ai({...this.getNodeOptions(),...this.getDrawableOptions(),shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(t),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(t),this.shapeType===Ut.Circle&&this.drawCircle(t),this.shapeType===Ut.Rectangle&&this.drawRectangle(t),t.restore(),super.drawChildren(t)}applyAlphaToPaints(t,i){i.forEach(n=>{n&&n.setAlphaf(t)})}drawPathFromM2Path(t){const i=m2c2Globals.canvasScale/this.absoluteScale,n=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,u=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const h=this.path.linePresentations;let C=0;const F=this.path.subpaths;let B;for(let U=0;U<F.length;U++){const ct=F[U].flat();for(let ut=0;ut<ct.length-1;ut++){if(h[C].subpathIndex===U&&h[C].pointIndex===ut){const At=h[C].strokeColor,yt=h[C].lineWidth,ne=[...At,yt].toString();B=this.colorfulPathPaints.get(ne),B===void 0&&(B=Ft.makePaint(this.canvasKit,At,this.canvasKit.PaintStyle.Stroke,!0),B.setStrokeWidth(yt*m2c2Globals.canvasScale),this.colorfulPathPaints.set(ne,B)),C<h.length-1&&C++}if(B===void 0)throw new Error("paint is undefined");t.drawLine(n+ct[ut].x*m2c2Globals.canvasScale,u+ct[ut].y*m2c2Globals.canvasScale,n+ct[ut+1].x*m2c2Globals.canvasScale,u+ct[ut+1].y*m2c2Globals.canvasScale,B)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const h=this.path.subpaths;for(const C of h){const F=C.flat();for(let B=0;B<F.length-1;B++)t.drawLine(n+F[B].x*m2c2Globals.canvasScale,u+F[B].y*m2c2Globals.canvasScale,n+F[B+1].x*m2c2Globals.canvasScale,u+F[B+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(t){if(!this.ckPath)return;const i=this.calculateSvgPathX(),n=this.calculateSvgPathY();if(this.pathNeedsTransform(i,n)){const h=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,C=this.calculateTransformationMatrix(h,i,n);this.ckPath=this.ckPath.transform(C),this.saveSvgPathAbsolutePosition(i,n)}if(this.fillColor){const u=this.getFillPaint();t.drawPath(this.ckPath,u)}if(this.strokeColor&&this.lineWidth){const u=this.getStrokePaint(this.lineWidth);t.drawPath(this.ckPath,u)}}calculateSvgPathY(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*t}calculateSvgPathX(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*t}saveSvgPathAbsolutePosition(t,i){this.svgPreviousAbsoluteX=t,this.svgPreviousAbsoluteY=i}calculateTransformationMatrix(t,i,n){let u;this.svgFirstPathDraw?(u=t,this.svgFirstPathDraw=!1):u=1;const h=i-this.svgPreviousAbsoluteX,C=n-this.svgPreviousAbsoluteY;return[u,0,h,0,u,C,0,0,1]}pathNeedsTransform(t,i){return this.svgFirstPathDraw===!0||t!==this.svgPreviousAbsoluteX||i!==this.svgPreviousAbsoluteY}shapeIsSvgStringPath(){return this.path?.pathString!==void 0||this.path?.svgPathString!==void 0}shapeIsM2Path(){return this.path?.subpaths!==void 0}pathIsM2ColorfulPath(t){return t!==void 0&&"linePresentations"in t}drawCircle(t){if(this.circleOfRadius){if(this.fillColor){const i=this.getFillPaint();this.drawCircleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(t,i)}}}drawRectangle(t){if(this.fillColor){const i=this.getFillPaint();this.drawRectangleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(t,i)}}drawCircleWithCanvasKit(t,i){if(!this.circleOfRadius)return;const n=m2c2Globals.canvasScale/this.absoluteScale,u=this.absolutePosition.x*n,h=this.absolutePosition.y*n,C=this.circleOfRadius*this.absoluteScale*n;t.drawCircle(u,h,C,i)}drawRectangleWithCanvasKit(t,i){const n=this.calculateCKRoundedRectangle();t.drawRRect(n,i)}calculateCKRoundedRectangle(){const t=m2c2Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*t,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*t),this.cornerRadius*t,this.cornerRadius*t)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(t){let i;this.involvedInActionAffectingAppearance()?i=this.strokeColorPaintNotAntialiased:i=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const n=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(t*n),i}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),this.shapeType===Ut.Circle&&(this.fillColor&&this.warmupFilledCircle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(t)),this.shapeType===Ut.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(t)),t.restore(),this.children.forEach(n=>{n.isDrawable&&n.warmup(t)})}warmupFilledCircle(t){this.circleOfRadius&&(this.drawCircleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(t,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(t){this.drawRectangleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(t,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}get circleOfRadius(){return this._circleOfRadius}set circleOfRadius(t){j.value(t,this._circleOfRadius)||(this._circleOfRadius=t,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",t))}get rect(){return this._rect}set rect(t){j.value(t,this._rect)||(this._rect=t,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",t))}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){j.value(t,this._cornerRadius)||(this._cornerRadius=t??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",t??0))}get lineWidth(){return this._lineWidth}set lineWidth(t){j.value(t,this._lineWidth)||(this._lineWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",t))}get path(){return this._path}set path(t){j.value(t,this._path)||(this._path=t,this.needsInitialization=!0,this.savePropertyChangeEvent("path",t))}get fillColor(){return this._fillColor}set fillColor(t){j.value(t,this._fillColor)||(this._fillColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",t))}get strokeColor(){return this._strokeColor}set strokeColor(t){j.value(t,this._strokeColor)||(this._strokeColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",t))}get isAntialiased(){return this._isAntialiased}set isAntialiased(t){j.value(t,this._isAntialiased)||(this._isAntialiased=t,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",t))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new Error("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(t){this._fillColorPaintAntialiased=t}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new Error("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(t){this._strokeColorPaintAntialiased=t}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new Error("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(t){this._fillColorPaintNotAntialiased=t}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new Error("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(t){this._strokeColorPaintNotAntialiased=t}}class Oi extends re{constructor(t={}){super(t),this.type=at.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=X.DEFAULT_FONT_COLOR,this._fontSize=X.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],Fe(this,t),this.size.height=this.fontSize,this.size.width=t.width??NaN,this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width}}initialize(){const t=this.game.i18n;if(this.tryMissingTranslationPaint=!1,t&&this.localize!==!1){const n=t.getTextLocalization(this.text,this.interpolation);this.textForDraw=n.text,this.localizedFontName=n.fontName,this.localizedFontNames=n.fontNames??[],n.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===Xt.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==Xt.Loading&&(this.createFontPaint(t),this.createFont(i),this.needsInitialization=!1)}getRequiredTextLineFont(t){if(this.game.i18n){if(this.localizedFontName!==void 0&&this.localizedFontNames.length!==0||this.localizedFontNames.length>1)throw new Error("TextLine supports only one font, but multiple fonts are specified in translation.");if(this.localizedFontName!==void 0)return t.fonts[this.localizedFontName];if(this.localizedFontNames.length==1)return t.fonts[this.localizedFontNames[0]]}return this.fontName===void 0?t.getDefaultFont():t.getFont(this.fontName)}createFontPaint(t){this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.tryMissingTranslationPaint&&this.localize!==!1?t?.missingLocalizationColor&&this.paint.setColor(this.canvasKit.Color(t.missingLocalizationColor[0],t.missingLocalizationColor[1],t.missingLocalizationColor[2],t.missingLocalizationColor[3])):this.paint.setColor(this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0)}createFont(t){if(this.fontForDraw)this.typeface=t.getTypeface(this.fontForDraw.fontName);else{const i=t.getFontNames();i.length>0&&(this.typeface=t.getTypeface(i[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,this.fontSize*m2c2Globals.canvasScale)}get text(){return this._text}set text(t){j.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get fontName(){return this._fontName}set fontName(t){j.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontColor(){return this._fontColor}set fontColor(t){j.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){j.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get interpolation(){return this._interpolation}set interpolation(t){j.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get localize(){return this._localize}set localize(t){j.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Ft.Dispose([this.font,this.typeface,this.paint])}duplicate(t){const i=new Oi({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){if(this.parent&&this.text&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=this.absolutePosition.x*i,u=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new Error(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),t.drawText(this.textForDraw,n,u,this.paint,this.font),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const u=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=u.fontName,this.localizedFontNames=u.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==Xt.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new Error(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);t.drawText(this.text,0,0,this.paint,this.font)}}}class oi extends re{constructor(t={}){super(t),this.type=at.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Fe(this,t),t.imageName!==void 0&&(this.imageName=t.imageName),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName}}initialize(){if(this.m2Image=this.game.imageManager.getImage(this._imageName),!this.m2Image)throw new Error(`could not create sprite. the image named ${this._imageName} has not been loaded`);this.size.width=this.m2Image.width,this.size.height=this.m2Image.height,this._paint||(this.paint=new this.canvasKit.Paint),this.needsInitialization=!1}dispose(){Ft.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(t){j.value(this._imageName,t)||(this._imageName=t,this.needsInitialization=!0)}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}set paint(t){this._paint=t}get paint(){if(!this._paint)throw new Error(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(t){const i=new oi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){if(!this.hidden){if(this.m2Image){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,u=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===qt.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(t),t.drawImage(this.m2Image.canvaskitImage,n,u,this.paint);else if(this.m2Image.status===qt.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===qt.Error)throw new Error(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);t.restore()}super.drawChildren(t)}}warmup(t){if(this.m2Image?.status===qt.Ready){if(this.initialize(),!this.m2Image)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);t.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(i=>{i.isDrawable&&i.warmup(t)})}drawFallbackImageBorder(t){const i=this.game.imageManager.missingLocalizationImagePaint;if(!i)return;const n=m2c2Globals.canvasScale/this.absoluteScale,u=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*n,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*n,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*n,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*n),0,0);t.drawRRect(u,i)}}class Cn{constructor(){q.registerM2NodeClass(ki,ai,oi,Ue,Oi)}createNode(t,i,n){const u=i||t;if(!this.hasClassRegistration(u))throw new Error(`Unknown node type: ${u}`);if(!m2c2Globals.m2NodeClassRegistry)throw new Error("Node class registry is not initialized.");const h=m2c2Globals.m2NodeClassRegistry[u];return new h(n)}hasClassRegistration(t){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(t)}}class Js{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}}class _n{constructor(t,i){this.fonts={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(t){return this.loadFonts(t??[])}async loadFonts(t){if(t.length===0)return;const i=t.map((n,u)=>{let h=n.url;q.urlHasScheme(n.url)||(h=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${n.url}`));const C={fontName:n.fontName,typeface:void 0,data:n.sharedFont?.data,default:u===0,url:n.sharedFont?.url??h,status:n.lazy?Xt.Deferred:Xt.Loading};if(this.fonts[n.fontName]=C,C.status===Xt.Loading)return this.prepareFont(C)});await Promise.all(i)}async prepareFont(t){const i=t.data??await this.fetchFontAsArrayBuffer(t);this.registerFont(i,t),console.log(`\u26AA font ${t.fontName}${t.default?" (default)":""} loaded for game ${this.game.id} from ${t.url}`)}async prepareDeferredFont(t){return t.status=Xt.Loading,this.prepareFont(t)}async fetchFontAsArrayBuffer(t){const i=await fetch(t.url);if(!i.ok)throw new Error(`cannot fetch font ${t.fontName} at url ${t.url}: ${i.statusText}`);return await i.arrayBuffer()}registerFont(t,i){this.provider.registerFont(t,i.fontName);const n=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(t);if(!n)throw new Error(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=n,i.status=Xt.Ready}getFont(t){return this.fonts[t]}getDefaultFont(){const t=Object.values(this.fonts).find(i=>i.default);if(!t)throw new Error("no default font found; please make sure at least one font is loaded");return t}dispose(){const t=Object.entries(this.fonts).map(([,i])=>i.typeface);Ft.Dispose([...t,this.provider])}getTypeface(t){const i=this.fonts[t]?.typeface;if(!i)throw new Error(`font ${t} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var lr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qs(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function En(g){if(g.__esModule)return g;var t=g.default;if(typeof t=="function"){var i=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(g).forEach(function(n){var u=Object.getOwnPropertyDescriptor(g,n);Object.defineProperty(i,n,u.get?u:{enumerable:!0,get:function(){return g[n]}})}),i}var Tn={exports:{}},Zs={},ta=Object.freeze({__proto__:null,default:Zs}),ea=En(ta);function Fn(g,t){for(var i=0,n=g.length-1;n>=0;n--){var u=g[n];u==="."?g.splice(n,1):u===".."?(g.splice(n,1),i++):i&&(g.splice(n,1),i--)}if(t)for(;i--;i)g.unshift("..");return g}var ia=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,hr=function(g){return ia.exec(g).slice(1)};function Ri(){for(var g="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var n=i>=0?arguments[i]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;g=n+"/"+g,t=n.charAt(0)==="/"}return g=Fn(dr(g.split("/"),function(u){return!!u}),!t).join("/"),(t?"/":"")+g||"."}function cr(g){var t=ur(g),i=na(g,-1)==="/";return g=Fn(dr(g.split("/"),function(n){return!!n}),!t).join("/"),!g&&!t&&(g="."),g&&i&&(g+="/"),(t?"/":"")+g}function ur(g){return g.charAt(0)==="/"}function Mn(){var g=Array.prototype.slice.call(arguments,0);return cr(dr(g,function(t,i){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function xn(g,t){g=Ri(g).substr(1),t=Ri(t).substr(1);function i(U){for(var et=0;et<U.length&&U[et]==="";et++);for(var ct=U.length-1;ct>=0&&U[ct]==="";ct--);return et>ct?[]:U.slice(et,ct-et+1)}for(var n=i(g.split("/")),u=i(t.split("/")),h=Math.min(n.length,u.length),C=h,F=0;F<h;F++)if(n[F]!==u[F]){C=F;break}for(var B=[],F=C;F<n.length;F++)B.push("..");return B=B.concat(u.slice(C)),B.join("/")}var Rn="/",Nn=":";function kn(g){var t=hr(g),i=t[0],n=t[1];return!i&&!n?".":(n&&(n=n.substr(0,n.length-1)),i+n)}function On(g,t){var i=hr(g)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function In(g){return hr(g)[3]}var ra={extname:In,basename:On,dirname:kn,sep:Rn,delimiter:Nn,relative:xn,join:Mn,isAbsolute:ur,normalize:cr,resolve:Ri};function dr(g,t){if(g.filter)return g.filter(t);for(var i=[],n=0;n<g.length;n++)t(g[n],n,g)&&i.push(g[n]);return i}var na="ab".substr(-1)==="b"?function(g,t,i){return g.substr(t,i)}:function(g,t,i){return t<0&&(t=g.length+t),g.substr(t,i)},sa=Object.freeze({__proto__:null,basename:On,default:ra,delimiter:Nn,dirname:kn,extname:In,isAbsolute:ur,join:Mn,normalize:cr,relative:xn,resolve:Ri,sep:Rn}),aa=En(sa);(function(g,t){var i=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(u={}){var h=u,C,F;h.ready=new Promise((e,r)=>{C=e,F=r}),function(e){e.Td=e.Td||[],e.Td.push(function(){e.MakeSWCanvasSurface=function(r){var s=r,l=typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||l||(s=document.getElementById(r),s)))throw"Canvas with id "+r+" was not found";return(r=e.MakeSurface(s.width,s.height))&&(r.Ld=s),r},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(r,s){var l={width:r,height:s,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},d=r*s*4,m=e._malloc(d);return(l=e.Surface._makeRasterDirect(l,m,4*r))&&(l.Ld=null,l.Hf=r,l.Df=s,l.Ff=d,l.bf=m,l.getCanvas().clear(e.TRANSPARENT)),l},e.MakeRasterDirectSurface=function(r,s,l){return e.Surface._makeRasterDirect(r,s.byteOffset,l)},e.Surface.prototype.flush=function(r){if(e.Md(this.Kd),this._flush(),this.Ld){var s=new Uint8ClampedArray(e.HEAPU8.buffer,this.bf,this.Ff);s=new ImageData(s,this.Hf,this.Df),r?this.Ld.getContext("2d").putImageData(s,0,0,r[0],r[1],r[2]-r[0],r[3]-r[1]):this.Ld.getContext("2d").putImageData(s,0,0)}},e.Surface.prototype.dispose=function(){this.bf&&e._free(this.bf),this.delete()},e.Md=e.Md||function(){},e.Te=e.Te||function(){return null}})}(h),function(e){e.Td=e.Td||[],e.Td.push(function(){function r(v,y,A){return v&&v.hasOwnProperty(y)?v[y]:A}function s(v){var y=Oe(Kt);return Kt[y]=v,y}function l(v){return v.naturalHeight||v.videoHeight||v.displayHeight||v.height}function d(v){return v.naturalWidth||v.videoWidth||v.displayWidth||v.width}function m(v,y,A,O){return v.bindTexture(v.TEXTURE_2D,y),O||A.alphaType!==e.AlphaType.Premul||v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),y}function b(v,y,A){A||y.alphaType!==e.AlphaType.Premul||v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),v.bindTexture(v.TEXTURE_2D,null)}e.GetWebGLContext=function(v,y){if(!v)throw"null canvas passed into makeWebGLContext";var A={alpha:r(y,"alpha",1),depth:r(y,"depth",1),stencil:r(y,"stencil",8),antialias:r(y,"antialias",0),premultipliedAlpha:r(y,"premultipliedAlpha",1),preserveDrawingBuffer:r(y,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:r(y,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:r(y,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:r(y,"enableExtensionsByDefault",1),explicitSwapControl:r(y,"explicitSwapControl",0),renderViaOffscreenBackBuffer:r(y,"renderViaOffscreenBackBuffer",0)};if(A.majorVersion=y&&y.majorVersion?y.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,A.explicitSwapControl)throw"explicitSwapControl is not supported";return v=ws(v,A),v?(jr(v),it.fe.getExtension("WEBGL_debug_renderer_info"),v):0},e.deleteContext=function(v){it===le[v]&&(it=null),typeof JSEvents=="object"&&JSEvents.ug(le[v].fe.canvas),le[v]&&le[v].fe.canvas&&(le[v].fe.canvas.zf=void 0),le[v]=null},e._setTextureCleanup({deleteTexture:function(v,y){var A=Kt[y];A&&le[v].fe.deleteTexture(A),Kt[y]=null}}),e.MakeWebGLContext=function(v){if(!this.Md(v))return null;var y=this._MakeGrContext();if(!y)return null;y.Kd=v;var A=y.delete.bind(y);return y.delete=function(){e.Md(this.Kd),A()}.bind(y),it.ff=y},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.Md(this.Kd),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.Md(this.Kd),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.Md(this.Kd),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(v){e.Md(this.Kd),this._setResourceCacheLimitBytes(v)},e.MakeOnScreenGLSurface=function(v,y,A,O,D,H){return!this.Md(v.Kd)||(y=D===void 0||H===void 0?this._MakeOnScreenGLSurface(v,y,A,O):this._MakeOnScreenGLSurface(v,y,A,O,D,H),!y)?null:(y.Kd=v.Kd,y)},e.MakeRenderTarget=function(){var v=arguments[0];if(!this.Md(v.Kd))return null;if(arguments.length===3){var y=this._MakeRenderTargetWH(v,arguments[1],arguments[2]);if(!y)return null}else if(arguments.length===2){if(y=this._MakeRenderTargetII(v,arguments[1]),!y)return null}else return null;return y.Kd=v.Kd,y},e.MakeWebGLCanvasSurface=function(v,y,A){y=y||null;var O=v,D=typeof OffscreenCanvas<"u"&&O instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||D||(O=document.getElementById(v),O)))throw"Canvas with id "+v+" was not found";if(v=this.GetWebGLContext(O,A),!v||0>v)throw"failed to create webgl context: err "+v;return v=this.MakeWebGLContext(v),y=this.MakeOnScreenGLSurface(v,O.width,O.height,y),y||(y=O.cloneNode(!0),O.parentNode.replaceChild(y,O),y.classList.add("ck-replaced"),e.MakeSWCanvasSurface(y))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(v,y){return e.Md(this.Kd),v=s(v),(y=this._makeImageFromTexture(this.Kd,v,y))&&(y.Le=v),y},e.Surface.prototype.makeImageFromTextureSource=function(v,y,A){y||(y={height:l(v),width:d(v),colorType:e.ColorType.RGBA_8888,alphaType:A?e.AlphaType.Premul:e.AlphaType.Unpremul}),y.colorSpace||(y.colorSpace=e.ColorSpace.SRGB),e.Md(this.Kd);var O=it.fe;return A=m(O,O.createTexture(),y,A),it.version===2?O.texImage2D(O.TEXTURE_2D,0,O.RGBA,y.width,y.height,0,O.RGBA,O.UNSIGNED_BYTE,v):O.texImage2D(O.TEXTURE_2D,0,O.RGBA,O.RGBA,O.UNSIGNED_BYTE,v),b(O,y),this._resetContext(),this.makeImageFromTexture(A,y)},e.Surface.prototype.updateTextureFromSource=function(v,y,A){if(v.Le){e.Md(this.Kd);var O=v.getImageInfo(),D=it.fe,H=m(D,Kt[v.Le],O,A);it.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,d(y),l(y),0,D.RGBA,D.UNSIGNED_BYTE,y):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,y),b(D,O,A),this._resetContext(),Kt[v.Le]=null,v.Le=s(H),O.colorSpace=v.getColorSpace(),y=this._makeImageFromTexture(this.Kd,v.Le,O),A=v.Jd.Rd,D=v.Jd.Yd,v.Jd.Rd=y.Jd.Rd,v.Jd.Yd=y.Jd.Yd,y.Jd.Rd=A,y.Jd.Yd=D,y.delete(),O.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(v,y,A){y||(y={height:l(v),width:d(v),colorType:e.ColorType.RGBA_8888,alphaType:A?e.AlphaType.Premul:e.AlphaType.Unpremul}),y.colorSpace||(y.colorSpace=e.ColorSpace.SRGB);var O={makeTexture:function(){var D=it,H=D.fe,T=m(H,H.createTexture(),y,A);return D.version===2?H.texImage2D(H.TEXTURE_2D,0,H.RGBA,y.width,y.height,0,H.RGBA,H.UNSIGNED_BYTE,v):H.texImage2D(H.TEXTURE_2D,0,H.RGBA,H.RGBA,H.UNSIGNED_BYTE,v),b(H,y,A),s(T)},freeSrc:function(){}};return v.constructor.name==="VideoFrame"&&(O.freeSrc=function(){v.close()}),e.Image._makeFromGenerator(y,O)},e.Md=function(v){return v?jr(v):!1},e.Te=function(){return it&&it.ff&&!it.ff.isDeleted()?it.ff:null}})}(h),function(e){function r(o,a,c,p,P){for(var E=0;E<o.length;E++)a[E*c+(E*P+p+c)%c]=o[E];return a}function s(o){for(var a=o*o,c=Array(a);a--;)c[a]=a%(o+1)===0?1:0;return c}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(v(255*o[3])<<24|v(255*o[0])<<16|v(255*o[1])<<8|v(255*o[2])<<0)>>>0}function m(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var a=Math.floor(o.length/4),c=new Uint32Array(a),p=0;p<a;p++)c[p]=d(o.slice(4*p,4*(p+1)));return c}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function b(o){if(o===void 0)return 1;var a=parseFloat(o);return o&&o.indexOf("%")!==-1?a/100:a}function v(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function y(o,a){a&&a._ck||e._free(o)}function A(o,a,c){if(!o||!o.length)return ht;if(o&&o._ck)return o.byteOffset;var p=e[a].BYTES_PER_ELEMENT;return c||(c=e._malloc(o.length*p)),e[a].set(o,c/p),c}function O(o){var a={be:ht,count:o.length,colorType:e.ColorType.RGBA_F32};if(o instanceof Float32Array)a.be=A(o,"HEAPF32"),a.count=o.length/4;else if(o instanceof Uint32Array)a.be=A(o,"HEAPU32"),a.colorType=e.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var c=e._malloc(16*o.length),p=0,P=c/4,E=0;E<o.length;E++)for(var N=0;4>N;N++)e.HEAPF32[P+p]=o[E][N],p++;o=c}else o=ht;a.be=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return a}function D(o){if(!o)return ht;var a=Qi.toTypedArray();if(o.length){if(o.length===6||o.length===9)return A(o,"HEAPF32",ye),o.length===6&&e.HEAPF32.set(Gs,6+ye/4),ye;if(o.length===16)return a[0]=o[0],a[1]=o[1],a[2]=o[3],a[3]=o[4],a[4]=o[5],a[5]=o[7],a[6]=o[12],a[7]=o[13],a[8]=o[15],ye;throw"invalid matrix size"}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m41,a[3]=o.m12,a[4]=o.m22,a[5]=o.m42,a[6]=o.m14,a[7]=o.m24,a[8]=o.m44,ye}function H(o){if(!o)return ht;var a=Zi.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?A(o,"HEAPF32",Le):(a.fill(0),a[0]=o[0],a[1]=o[1],a[3]=o[2],a[4]=o[3],a[5]=o[4],a[7]=o[5],a[10]=1,a[12]=o[6],a[13]=o[7],a[15]=o[8],o.length===6&&(a[12]=0,a[13]=0,a[15]=1),Le)}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m31,a[3]=o.m41,a[4]=o.m12,a[5]=o.m22,a[6]=o.m32,a[7]=o.m42,a[8]=o.m13,a[9]=o.m23,a[10]=o.m33,a[11]=o.m43,a[12]=o.m14,a[13]=o.m24,a[14]=o.m34,a[15]=o.m44,Le}function T(o,a){return A(o,"HEAPF32",a||Ee)}function Y(o,a,c,p){var P=tr.toTypedArray();return P[0]=o,P[1]=a,P[2]=c,P[3]=p,Ee}function nt(o){for(var a=new Float32Array(4),c=0;4>c;c++)a[c]=e.HEAPF32[o/4+c];return a}function rt(o,a){return A(o,"HEAPF32",a||Et)}function Bt(o,a){return A(o,"HEAPF32",a||rr)}function Rt(){for(var o=0,a=0;a<arguments.length-1;a+=2)o+=arguments[a]*arguments[a+1];return o}function ti(o,a,c){for(var p=Array(o.length),P=0;P<c;P++)for(var E=0;E<c;E++){for(var N=0,W=0;W<c;W++)N+=o[c*P+W]*a[c*W+E];p[P*c+E]=N}return p}function ei(o,a){for(var c=ti(a[0],a[1],o),p=2;p<a.length;)c=ti(c,a[p],o),p++;return c}e.Color=function(o,a,c,p){return p===void 0&&(p=1),e.Color4f(v(o)/255,v(a)/255,v(c)/255,p)},e.ColorAsInt=function(o,a,c,p){return p===void 0&&(p=255),(v(p)<<24|v(o)<<16|v(a)<<8|v(c)<<0&268435455)>>>0},e.Color4f=function(o,a,c,p){return p===void 0&&(p=1),Float32Array.of(o,a,c,p)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(o){return[Math.floor(255*o[0]),Math.floor(255*o[1]),Math.floor(255*o[2]),o[3]]},e.parseColorString=function(o,a){if(o=o.toLowerCase(),o.startsWith("#")){switch(a=255,o.length){case 9:a=parseInt(o.slice(7,9),16);case 7:var c=parseInt(o.slice(1,3),16),p=parseInt(o.slice(3,5),16),P=parseInt(o.slice(5,7),16);break;case 5:a=17*parseInt(o.slice(4,5),16);case 4:c=17*parseInt(o.slice(1,2),16),p=17*parseInt(o.slice(2,3),16),P=17*parseInt(o.slice(3,4),16)}return e.Color(c,p,P,a/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],b(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],b(o[3]))):o.startsWith("gray(")||o.startsWith("hsl")||!a||(o=a[o],o===void 0)?e.BLACK:o},e.multiplyByAlpha=function(o,a){return o=o.slice(),o[3]=Math.max(0,Math.min(o[3]*a,1)),o},e.Malloc=function(o,a){var c=e._malloc(a*o.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:c,qe:null,subarray:function(p,P){return p=this.toTypedArray().subarray(p,P),p._ck=!0,p},toTypedArray:function(){return this.qe&&this.qe.length?this.qe:(this.qe=new o(e.HEAPU8.buffer,c,a),this.qe._ck=!0,this.qe)}}},e.Free=function(o){e._free(o.byteOffset),o.byteOffset=ht,o.toTypedArray=null,o.qe=null};var ye=ht,Qi,Le=ht,Zi,Ee=ht,tr,ie,Et=ht,nn,we=ht,sn,er=ht,an,ir=ht,Fi,ii=ht,on,rr=ht,ln,hn=ht,Gs=Float32Array.of(0,0,1),ht=0;e.onRuntimeInitialized=function(){function o(a,c,p,P,E,N,W){N||(N=4*P.width,P.colorType===e.ColorType.RGBA_F16?N*=2:P.colorType===e.ColorType.RGBA_F32&&(N*=4));var Q=N*P.height,J=E?E.byteOffset:e._malloc(Q);if(W?!a._readPixels(P,J,N,c,p,W):!a._readPixels(P,J,N,c,p))return E||e._free(J),null;if(E)return E.toTypedArray();switch(P.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:a=new Uint8Array(e.HEAPU8.buffer,J,Q).slice();break;case e.ColorType.RGBA_F32:a=new Float32Array(e.HEAPU8.buffer,J,Q).slice();break;default:return null}return e._free(J),a}tr=e.Malloc(Float32Array,4),Ee=tr.byteOffset,Zi=e.Malloc(Float32Array,16),Le=Zi.byteOffset,Qi=e.Malloc(Float32Array,9),ye=Qi.byteOffset,on=e.Malloc(Float32Array,12),rr=on.byteOffset,ln=e.Malloc(Float32Array,12),hn=ln.byteOffset,ie=e.Malloc(Float32Array,4),Et=ie.byteOffset,nn=e.Malloc(Float32Array,4),we=nn.byteOffset,sn=e.Malloc(Float32Array,3),er=sn.byteOffset,an=e.Malloc(Float32Array,3),ir=an.byteOffset,Fi=e.Malloc(Int32Array,4),ii=Fi.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(a){var c=A(a,"HEAPF32"),p=e.Path._MakeFromCmds(c,a.length);return y(c,a),p},e.Path.MakeFromVerbsPointsWeights=function(a,c,p){var P=A(a,"HEAPU8"),E=A(c,"HEAPF32"),N=A(p,"HEAPF32"),W=e.Path._MakeFromVerbsPointsWeights(P,a.length,E,c.length,N,p&&p.length||0);return y(P,a),y(E,c),y(N,p),W},e.Path.prototype.addArc=function(a,c,p){return a=rt(a),this._addArc(a,c,p),this},e.Path.prototype.addCircle=function(a,c,p,P){return this._addCircle(a,c,p,!!P),this},e.Path.prototype.addOval=function(a,c,p){return p===void 0&&(p=1),a=rt(a),this._addOval(a,!!c,p),this},e.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),c=a[0],p=!1;if(typeof a[a.length-1]=="boolean"&&(p=a.pop()),a.length===1)this._addPath(c,1,0,0,0,1,0,0,0,1,p);else if(a.length===2)a=a[1],this._addPath(c,a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1,p);else if(a.length===7||a.length===10)this._addPath(c,a[1],a[2],a[3],a[4],a[5],a[6],a[7]||0,a[8]||0,a[9]||1,p);else return null;return this},e.Path.prototype.addPoly=function(a,c){var p=A(a,"HEAPF32");return this._addPoly(p,a.length/2,c),y(p,a),this},e.Path.prototype.addRect=function(a,c){return a=rt(a),this._addRect(a,!!c),this},e.Path.prototype.addRRect=function(a,c){return a=Bt(a),this._addRRect(a,!!c),this},e.Path.prototype.addVerbsPointsWeights=function(a,c,p){var P=A(a,"HEAPU8"),E=A(c,"HEAPF32"),N=A(p,"HEAPF32");this._addVerbsPointsWeights(P,a.length,E,c.length,N,p&&p.length||0),y(P,a),y(E,c),y(N,p)},e.Path.prototype.arc=function(a,c,p,P,E,N){return a=e.LTRBRect(a-p,c-p,a+p,c+p),E=(E-P)/Math.PI*180-360*!!N,N=new e.Path,N.addArc(a,P/Math.PI*180,E),this.addPath(N,!0),N.delete(),this},e.Path.prototype.arcToOval=function(a,c,p,P){return a=rt(a),this._arcToOval(a,c,p,P),this},e.Path.prototype.arcToRotated=function(a,c,p,P,E,N,W){return this._arcToRotated(a,c,p,!!P,!!E,N,W),this},e.Path.prototype.arcToTangent=function(a,c,p,P,E){return this._arcToTangent(a,c,p,P,E),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(a,c,p,P,E){return this._conicTo(a,c,p,P,E),this},e.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Path.prototype.cubicTo=function(a,c,p,P,E,N){return this._cubicTo(a,c,p,P,E,N),this},e.Path.prototype.dash=function(a,c,p){return this._dash(a,c,p)?this:null},e.Path.prototype.getBounds=function(a){this._getBounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Path.prototype.lineTo=function(a,c){return this._lineTo(a,c),this},e.Path.prototype.moveTo=function(a,c){return this._moveTo(a,c),this},e.Path.prototype.offset=function(a,c){return this._transform(1,0,a,0,1,c,0,0,1),this},e.Path.prototype.quadTo=function(a,c,p,P){return this._quadTo(a,c,p,P),this},e.Path.prototype.rArcTo=function(a,c,p,P,E,N,W){return this._rArcTo(a,c,p,P,E,N,W),this},e.Path.prototype.rConicTo=function(a,c,p,P,E){return this._rConicTo(a,c,p,P,E),this},e.Path.prototype.rCubicTo=function(a,c,p,P,E,N){return this._rCubicTo(a,c,p,P,E,N),this},e.Path.prototype.rLineTo=function(a,c){return this._rLineTo(a,c),this},e.Path.prototype.rMoveTo=function(a,c){return this._rMoveTo(a,c),this},e.Path.prototype.rQuadTo=function(a,c,p,P){return this._rQuadTo(a,c,p,P),this},e.Path.prototype.stroke=function(a){return a=a||{},a.width=a.width||1,a.miter_limit=a.miter_limit||4,a.cap=a.cap||e.StrokeCap.Butt,a.join=a.join||e.StrokeJoin.Miter,a.precision=a.precision||1,this._stroke(a)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var a=arguments[0];this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1)}else if(arguments.length===6||arguments.length===9)a=arguments,this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(a,c,p){return this._trim(a,c,!!p)?this:null},e.Image.prototype.encodeToBytes=function(a,c){var p=e.Te();return a=a||e.ImageFormat.PNG,c=c||100,p?this._encodeToBytes(a,c,p):this._encodeToBytes(a,c)},e.Image.prototype.makeShaderCubic=function(a,c,p,P,E){return E=D(E),this._makeShaderCubic(a,c,p,P,E)},e.Image.prototype.makeShaderOptions=function(a,c,p,P,E){return E=D(E),this._makeShaderOptions(a,c,p,P,E)},e.Image.prototype.readPixels=function(a,c,p,P,E){var N=e.Te();return o(this,a,c,p,P,E,N)},e.Canvas.prototype.clear=function(a){e.Md(this.Kd),a=T(a),this._clear(a)},e.Canvas.prototype.clipRRect=function(a,c,p){e.Md(this.Kd),a=Bt(a),this._clipRRect(a,c,p)},e.Canvas.prototype.clipRect=function(a,c,p){e.Md(this.Kd),a=rt(a),this._clipRect(a,c,p)},e.Canvas.prototype.concat=function(a){e.Md(this.Kd),a=H(a),this._concat(a)},e.Canvas.prototype.drawArc=function(a,c,p,P,E){e.Md(this.Kd),a=rt(a),this._drawArc(a,c,p,P,E)},e.Canvas.prototype.drawAtlas=function(a,c,p,P,E,N,W){if(a&&P&&c&&p&&c.length===p.length){e.Md(this.Kd),E||(E=e.BlendMode.SrcOver);var Q=A(c,"HEAPF32"),J=A(p,"HEAPF32"),dt=p.length/4,mt=A(m(N),"HEAPU32");if(W&&"B"in W&&"C"in W)this._drawAtlasCubic(a,J,Q,mt,dt,E,W.B,W.C,P);else{let S=e.FilterMode.Linear,k=e.MipmapMode.None;W&&(S=W.filter,"mipmap"in W&&(k=W.mipmap)),this._drawAtlasOptions(a,J,Q,mt,dt,E,S,k,P)}y(Q,c),y(J,p),y(mt,N)}},e.Canvas.prototype.drawCircle=function(a,c,p,P){e.Md(this.Kd),this._drawCircle(a,c,p,P)},e.Canvas.prototype.drawColor=function(a,c){e.Md(this.Kd),a=T(a),c!==void 0?this._drawColor(a,c):this._drawColor(a)},e.Canvas.prototype.drawColorInt=function(a,c){e.Md(this.Kd),this._drawColorInt(a,c||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(a,c,p,P,E){e.Md(this.Kd),a=Y(a,c,p,P),E!==void 0?this._drawColor(a,E):this._drawColor(a)},e.Canvas.prototype.drawDRRect=function(a,c,p){e.Md(this.Kd),a=Bt(a,rr),c=Bt(c,hn),this._drawDRRect(a,c,p)},e.Canvas.prototype.drawImage=function(a,c,p,P){e.Md(this.Kd),this._drawImage(a,c,p,P||null)},e.Canvas.prototype.drawImageCubic=function(a,c,p,P,E,N){e.Md(this.Kd),this._drawImageCubic(a,c,p,P,E,N||null)},e.Canvas.prototype.drawImageOptions=function(a,c,p,P,E,N){e.Md(this.Kd),this._drawImageOptions(a,c,p,P,E,N||null)},e.Canvas.prototype.drawImageNine=function(a,c,p,P,E){e.Md(this.Kd),c=A(c,"HEAP32",ii),p=rt(p),this._drawImageNine(a,c,p,P,E||null)},e.Canvas.prototype.drawImageRect=function(a,c,p,P,E){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRect(a,Et,we,P,!!E)},e.Canvas.prototype.drawImageRectCubic=function(a,c,p,P,E,N){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRectCubic(a,Et,we,P,E,N||null)},e.Canvas.prototype.drawImageRectOptions=function(a,c,p,P,E,N){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRectOptions(a,Et,we,P,E,N||null)},e.Canvas.prototype.drawLine=function(a,c,p,P,E){e.Md(this.Kd),this._drawLine(a,c,p,P,E)},e.Canvas.prototype.drawOval=function(a,c){e.Md(this.Kd),a=rt(a),this._drawOval(a,c)},e.Canvas.prototype.drawPaint=function(a){e.Md(this.Kd),this._drawPaint(a)},e.Canvas.prototype.drawParagraph=function(a,c,p){e.Md(this.Kd),this._drawParagraph(a,c,p)},e.Canvas.prototype.drawPatch=function(a,c,p,P,E){if(24>a.length)throw"Need 12 cubic points";if(c&&4>c.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";e.Md(this.Kd);const N=A(a,"HEAPF32"),W=c?A(m(c),"HEAPU32"):ht,Q=p?A(p,"HEAPF32"):ht;P||(P=e.BlendMode.Modulate),this._drawPatch(N,W,Q,P,E),y(Q,p),y(W,c),y(N,a)},e.Canvas.prototype.drawPath=function(a,c){e.Md(this.Kd),this._drawPath(a,c)},e.Canvas.prototype.drawPicture=function(a){e.Md(this.Kd),this._drawPicture(a)},e.Canvas.prototype.drawPoints=function(a,c,p){e.Md(this.Kd);var P=A(c,"HEAPF32");this._drawPoints(a,P,c.length/2,p),y(P,c)},e.Canvas.prototype.drawRRect=function(a,c){e.Md(this.Kd),a=Bt(a),this._drawRRect(a,c)},e.Canvas.prototype.drawRect=function(a,c){e.Md(this.Kd),a=rt(a),this._drawRect(a,c)},e.Canvas.prototype.drawRect4f=function(a,c,p,P,E){e.Md(this.Kd),this._drawRect4f(a,c,p,P,E)},e.Canvas.prototype.drawShadow=function(a,c,p,P,E,N,W){e.Md(this.Kd);var Q=A(E,"HEAPF32"),J=A(N,"HEAPF32");c=A(c,"HEAPF32",er),p=A(p,"HEAPF32",ir),this._drawShadow(a,c,p,P,Q,J,W),y(Q,E),y(J,N)},e.getShadowLocalBounds=function(a,c,p,P,E,N,W){return a=D(a),p=A(p,"HEAPF32",er),P=A(P,"HEAPF32",ir),this._getShadowLocalBounds(a,c,p,P,E,N,Et)?(c=ie.toTypedArray(),W?(W.set(c),W):c.slice()):null},e.Canvas.prototype.drawTextBlob=function(a,c,p,P){e.Md(this.Kd),this._drawTextBlob(a,c,p,P)},e.Canvas.prototype.drawVertices=function(a,c,p){e.Md(this.Kd),this._drawVertices(a,c,p)},e.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(ii);var c=Fi.toTypedArray();return a?a.set(c):a=c.slice(),a},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Le);for(var a=Le,c=Array(16),p=0;16>p;p++)c[p]=e.HEAPF32[a/4+p];return c},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(ye);for(var a=Array(9),c=0;9>c;c++)a[c]=e.HEAPF32[ye/4+c];return a},e.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.Kd=this.Kd,a},e.Canvas.prototype.readPixels=function(a,c,p,P,E){return e.Md(this.Kd),o(this,a,c,p,P,E)},e.Canvas.prototype.saveLayer=function(a,c,p,P){return c=rt(c),this._saveLayer(a||null,c,p||null,P||0)},e.Canvas.prototype.writePixels=function(a,c,p,P,E,N,W,Q){if(a.byteLength%(c*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.Md(this.Kd);var J=a.byteLength/(c*p);N=N||e.AlphaType.Unpremul,W=W||e.ColorType.RGBA_8888,Q=Q||e.ColorSpace.SRGB;var dt=J*c;return J=A(a,"HEAPU8"),c=this._writePixels({width:c,height:p,colorType:W,alphaType:N,colorSpace:Q},J,dt,P,E),y(J,a),c},e.ColorFilter.MakeBlend=function(a,c,p){return a=T(a),p=p||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(a,c,p)},e.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var c=A(a,"HEAPF32"),p=e.ColorFilter._makeMatrix(c);return y(c,a),p},e.ContourMeasure.prototype.getPosTan=function(a,c){return this._getPosTan(a,Et),a=ie.toTypedArray(),c?(c.set(a),c):a.slice()},e.ImageFilter.prototype.getOutputBounds=function(a,c,p){return a=rt(a,Et),c=D(c),this._getOutputBounds(a,c,ii),c=Fi.toTypedArray(),p?(p.set(c),p):c.slice()},e.ImageFilter.MakeDropShadow=function(a,c,p,P,E,N){return E=T(E,Ee),e.ImageFilter._MakeDropShadow(a,c,p,P,E,N)},e.ImageFilter.MakeDropShadowOnly=function(a,c,p,P,E,N){return E=T(E,Ee),e.ImageFilter._MakeDropShadowOnly(a,c,p,P,E,N)},e.ImageFilter.MakeImage=function(a,c,p,P){if(p=rt(p,Et),P=rt(P,we),"B"in c&&"C"in c)return e.ImageFilter._MakeImageCubic(a,c.B,c.C,p,P);const E=c.filter;let N=e.MipmapMode.None;return"mipmap"in c&&(N=c.mipmap),e.ImageFilter._MakeImageOptions(a,E,N,p,P)},e.ImageFilter.MakeMatrixTransform=function(a,c,p){if(a=D(a),"B"in c&&"C"in c)return e.ImageFilter._MakeMatrixTransformCubic(a,c.B,c.C,p);const P=c.filter;let E=e.MipmapMode.None;return"mipmap"in c&&(E=c.mipmap),e.ImageFilter._MakeMatrixTransformOptions(a,P,E,p)},e.Paint.prototype.getColor=function(){return this._getColor(Ee),nt(Ee)},e.Paint.prototype.setColor=function(a,c){c=c||null,a=T(a),this._setColor(a,c)},e.Paint.prototype.setColorComponents=function(a,c,p,P,E){E=E||null,a=Y(a,c,p,P),this._setColor(a,E)},e.Path.prototype.getPoint=function(a,c){return this._getPoint(a,Et),a=ie.toTypedArray(),c?(c[0]=a[0],c[1]=a[1],c):a.slice(0,2)},e.Picture.prototype.makeShader=function(a,c,p,P,E){return P=D(P),E=rt(E),this._makeShader(a,c,p,P,E)},e.Picture.prototype.cullRect=function(a){this._cullRect(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.PictureRecorder.prototype.beginRecording=function(a,c){return a=rt(a),this._beginRecording(a,!!c)},e.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.Kd=this.Kd,a},e.Surface.prototype.makeImageSnapshot=function(a){return e.Md(this.Kd),a=A(a,"HEAP32",ii),this._makeImageSnapshot(a)},e.Surface.prototype.makeSurface=function(a){return e.Md(this.Kd),a=this._makeSurface(a),a.Kd=this.Kd,a},e.Surface.prototype.Gf=function(a,c){return this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){e.Md(this.Kd),a(this.He),this.flush(c)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Gf),e.Surface.prototype.Cf=function(a,c){this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){e.Md(this.Kd),a(this.He),this.flush(c),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Cf),e.PathEffect.MakeDash=function(a,c){if(c||(c=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var p=A(a,"HEAPF32");return c=e.PathEffect._MakeDash(p,a.length,c),y(p,a),c},e.PathEffect.MakeLine2D=function(a,c){return c=D(c),e.PathEffect._MakeLine2D(a,c)},e.PathEffect.MakePath2D=function(a,c){return a=D(a),e.PathEffect._MakePath2D(a,c)},e.Shader.MakeColor=function(a,c){return c=c||null,a=T(a),e.Shader._MakeColor(a,c)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(a,c,p,P,E,N,W,Q){Q=Q||null;var J=O(p),dt=A(P,"HEAPF32");W=W||0,N=D(N);var mt=ie.toTypedArray();return mt.set(a),mt.set(c,2),a=e.Shader._MakeLinearGradient(Et,J.be,J.colorType,dt,J.count,E,W,N,Q),y(J.be,p),P&&y(dt,P),a},e.Shader.MakeRadialGradient=function(a,c,p,P,E,N,W,Q){Q=Q||null;var J=O(p),dt=A(P,"HEAPF32");return W=W||0,N=D(N),a=e.Shader._MakeRadialGradient(a[0],a[1],c,J.be,J.colorType,dt,J.count,E,W,N,Q),y(J.be,p),P&&y(dt,P),a},e.Shader.MakeSweepGradient=function(a,c,p,P,E,N,W,Q,J,dt){dt=dt||null;var mt=O(p),S=A(P,"HEAPF32");return W=W||0,Q=Q||0,J=J||360,N=D(N),a=e.Shader._MakeSweepGradient(a,c,mt.be,mt.colorType,S,mt.count,E,Q,J,W,N,dt),y(mt.be,p),P&&y(S,P),a},e.Shader.MakeTwoPointConicalGradient=function(a,c,p,P,E,N,W,Q,J,dt){dt=dt||null;var mt=O(E),S=A(N,"HEAPF32");J=J||0,Q=D(Q);var k=ie.toTypedArray();return k.set(a),k.set(p,2),a=e.Shader._MakeTwoPointConicalGradient(Et,c,P,mt.be,mt.colorType,S,mt.count,W,J,Q,dt),y(mt.be,E),N&&y(S,N),a},e.Vertices.prototype.bounds=function(a){this._bounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Td&&e.Td.forEach(function(a){a()})},e.computeTonalColors=function(o){var a=A(o.ambient,"HEAPF32"),c=A(o.spot,"HEAPF32");this._computeTonalColors(a,c);var p={ambient:nt(a),spot:nt(c)};return y(a,o.ambient),y(c,o.spot),p},e.LTRBRect=function(o,a,c,p){return Float32Array.of(o,a,c,p)},e.XYWHRect=function(o,a,c,p){return Float32Array.of(o,a,o+c,a+p)},e.LTRBiRect=function(o,a,c,p){return Int32Array.of(o,a,c,p)},e.XYWHiRect=function(o,a,c,p){return Int32Array.of(o,a,o+c,a+p)},e.RRectXY=function(o,a,c){return Float32Array.of(o[0],o[1],o[2],o[3],a,c,a,c,a,c,a,c)},e.MakeAnimatedImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeAnimatedImage(a,o.byteLength))?o:null},e.MakeImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeImage(a,o.byteLength))?o:null};var ri=null;e.MakeImageFromCanvasImageSource=function(o){var a=o.width,c=o.height;ri||(ri=document.createElement("canvas")),ri.width=a,ri.height=c;var p=ri.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,a,c),e.MakeImage({width:a,height:c,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},o.data,4*a)},e.MakeImage=function(o,a,c){var p=e._malloc(a.length);return e.HEAPU8.set(a,p),e._MakeImage(o,p,a.length,c)},e.MakeVertices=function(o,a,c,p,P,E){var N=P&&P.length||0,W=0;return c&&c.length&&(W|=1),p&&p.length&&(W|=2),E===void 0||E||(W|=4),o=new e._VerticesBuilder(o,a.length/2,N,W),A(a,"HEAPF32",o.positions()),o.texCoords()&&A(c,"HEAPF32",o.texCoords()),o.colors()&&A(m(p),"HEAPU32",o.colors()),o.indices()&&A(P,"HEAPU16",o.indices()),o.detach()},e.Matrix={},e.Matrix.identity=function(){return s(3)},e.Matrix.invert=function(o){var a=o[0]*o[4]*o[8]+o[1]*o[5]*o[6]+o[2]*o[3]*o[7]-o[2]*o[4]*o[6]-o[1]*o[3]*o[8]-o[0]*o[5]*o[7];return a?[(o[4]*o[8]-o[5]*o[7])/a,(o[2]*o[7]-o[1]*o[8])/a,(o[1]*o[5]-o[2]*o[4])/a,(o[5]*o[6]-o[3]*o[8])/a,(o[0]*o[8]-o[2]*o[6])/a,(o[2]*o[3]-o[0]*o[5])/a,(o[3]*o[7]-o[4]*o[6])/a,(o[1]*o[6]-o[0]*o[7])/a,(o[0]*o[4]-o[1]*o[3])/a]:null},e.Matrix.mapPoints=function(o,a){for(var c=0;c<a.length;c+=2){var p=a[c],P=a[c+1],E=o[6]*p+o[7]*P+o[8],N=o[3]*p+o[4]*P+o[5];a[c]=(o[0]*p+o[1]*P+o[2])/E,a[c+1]=N/E}return a},e.Matrix.multiply=function(){return ei(3,arguments)},e.Matrix.rotated=function(o,a,c){a=a||0,c=c||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,Rt(p,c,1-o,a),p,o,Rt(-p,a,1-o,c),0,0,1]},e.Matrix.scaled=function(o,a,c,p){c=c||0,p=p||0;var P=r([o,a],s(3),3,0,1);return r([c-o*c,p-a*p],P,3,2,0)},e.Matrix.skewed=function(o,a,c,p){c=c||0,p=p||0;var P=r([o,a],s(3),3,1,-1);return r([-o*c,-a*p],P,3,2,0)},e.Matrix.translated=function(o,a){return r(arguments,s(3),3,2,0)},e.Vector={},e.Vector.dot=function(o,a){return o.map(function(c,p){return c*a[p]}).reduce(function(c,p){return c+p})},e.Vector.lengthSquared=function(o){return e.Vector.dot(o,o)},e.Vector.length=function(o){return Math.sqrt(e.Vector.lengthSquared(o))},e.Vector.mulScalar=function(o,a){return o.map(function(c){return c*a})},e.Vector.add=function(o,a){return o.map(function(c,p){return c+a[p]})},e.Vector.sub=function(o,a){return o.map(function(c,p){return c-a[p]})},e.Vector.dist=function(o,a){return e.Vector.length(e.Vector.sub(o,a))},e.Vector.normalize=function(o){return e.Vector.mulScalar(o,1/e.Vector.length(o))},e.Vector.cross=function(o,a){return[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]},e.M44={},e.M44.identity=function(){return s(4)},e.M44.translated=function(o){return r(o,s(4),4,3,0)},e.M44.scaled=function(o){return r(o,s(4),4,0,1)},e.M44.rotated=function(o,a){return e.M44.rotatedUnitSinCos(e.Vector.normalize(o),Math.sin(a),Math.cos(a))},e.M44.rotatedUnitSinCos=function(o,a,c){var p=o[0],P=o[1];o=o[2];var E=1-c;return[E*p*p+c,E*p*P-a*o,E*p*o+a*P,0,E*p*P+a*o,E*P*P+c,E*P*o-a*p,0,E*p*o-a*P,E*P*o+a*p,E*o*o+c,0,0,0,0,1]},e.M44.lookat=function(o,a,c){a=e.Vector.normalize(e.Vector.sub(a,o)),c=e.Vector.normalize(c),c=e.Vector.normalize(e.Vector.cross(a,c));var p=e.M44.identity();return r(c,p,4,0,0),r(e.Vector.cross(c,a),p,4,1,0),r(e.Vector.mulScalar(a,-1),p,4,2,0),r(o,p,4,3,0),o=e.M44.invert(p),o===null?e.M44.identity():o},e.M44.perspective=function(o,a,c){var p=1/(a-o);return c/=2,c=Math.cos(c)/Math.sin(c),[c,0,0,0,0,c,0,0,0,0,(a+o)*p,2*a*o*p,0,0,-1,1]},e.M44.rc=function(o,a,c){return o[4*a+c]},e.M44.multiply=function(){return ei(4,arguments)},e.M44.invert=function(o){var a=o[0],c=o[4],p=o[8],P=o[12],E=o[1],N=o[5],W=o[9],Q=o[13],J=o[2],dt=o[6],mt=o[10],S=o[14],k=o[3],st=o[7],vt=o[11];o=o[15];var Tt=a*N-c*E,Vt=a*W-p*E,Yt=a*Q-P*E,Lt=c*W-p*N,L=c*Q-P*N,f=p*Q-P*W,w=J*st-dt*k,M=J*vt-mt*k,R=J*o-S*k,I=dt*vt-mt*st,z=dt*o-S*st,K=mt*o-S*vt,Pt=Tt*K-Vt*z+Yt*I+Lt*R-L*M+f*w,bt=1/Pt;return Pt===0||bt===1/0?null:(Tt*=bt,Vt*=bt,Yt*=bt,Lt*=bt,L*=bt,f*=bt,w*=bt,M*=bt,R*=bt,I*=bt,z*=bt,K*=bt,a=[N*K-W*z+Q*I,W*R-E*K-Q*M,E*z-N*R+Q*w,N*M-E*I-W*w,p*z-c*K-P*I,a*K-p*R+P*M,c*R-a*z-P*w,a*I-c*M+p*w,st*f-vt*L+o*Lt,vt*Yt-k*f-o*Vt,k*L-st*Yt+o*Tt,st*Vt-k*Lt-vt*Tt,mt*L-dt*f-S*Lt,J*f-mt*Yt+S*Vt,dt*Yt-J*L-S*Tt,J*Lt-dt*Vt+mt*Tt],a.every(function(he){return!isNaN(he)&&he!==1/0&&he!==-1/0})?a:null)},e.M44.transpose=function(o){return[o[0],o[4],o[8],o[12],o[1],o[5],o[9],o[13],o[2],o[6],o[10],o[14],o[3],o[7],o[11],o[15]]},e.M44.mustInvert=function(o){if(o=e.M44.invert(o),o===null)throw"Matrix not invertible";return o},e.M44.setupCamera=function(o,a,c){var p=e.M44.lookat(c.eye,c.coa,c.up);return c=e.M44.perspective(c.near,c.far,c.angle),a=[(o[2]-o[0])/2,(o[3]-o[1])/2,a],o=e.M44.multiply(e.M44.translated([(o[0]+o[2])/2,(o[1]+o[3])/2,0]),e.M44.scaled(a)),e.M44.multiply(o,c,p,e.M44.mustInvert(o))},e.ColorMatrix={},e.ColorMatrix.identity=function(){var o=new Float32Array(20);return o[0]=1,o[6]=1,o[12]=1,o[18]=1,o},e.ColorMatrix.scaled=function(o,a,c,p){var P=new Float32Array(20);return P[0]=o,P[6]=a,P[12]=c,P[18]=p,P};var js=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];e.ColorMatrix.rotated=function(o,a,c){var p=e.ColorMatrix.identity();return o=js[o],p[o[0]]=c,p[o[1]]=a,p[o[2]]=-a,p[o[3]]=c,p},e.ColorMatrix.postTranslate=function(o,a,c,p,P){return o[4]+=a,o[9]+=c,o[14]+=p,o[19]+=P,o},e.ColorMatrix.concat=function(o,a){for(var c=new Float32Array(20),p=0,P=0;20>P;P+=5){for(var E=0;4>E;E++)c[p++]=o[P]*a[E]+o[P+1]*a[E+5]+o[P+2]*a[E+10]+o[P+3]*a[E+15];c[p++]=o[P]*a[4]+o[P+1]*a[9]+o[P+2]*a[14]+o[P+3]*a[19]+o[P+4]}return c},function(o){o.Td=o.Td||[],o.Td.push(function(){function a(S){return S&&(S.dir=S.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),S}function c(S){if(!S||!S.length)return[];for(var k=[],st=0;st<S.length;st+=5){var vt=o.LTRBRect(S[st],S[st+1],S[st+2],S[st+3]),Tt=o.TextDirection.LTR;S[st+4]===0&&(Tt=o.TextDirection.RTL),k.push({rect:vt,dir:Tt})}return o._free(S.byteOffset),k}function p(S){return S=S||{},S.weight===void 0&&(S.weight=o.FontWeight.Normal),S.width=S.width||o.FontWidth.Normal,S.slant=S.slant||o.FontSlant.Upright,S}function P(S){if(!S||!S.length)return ht;for(var k=[],st=0;st<S.length;st++){var vt=E(S[st]);k.push(vt)}return A(k,"HEAPU32")}function E(S){if(Q[S])return Q[S];var k=Zt(S)+1,st=o._malloc(k);return Qt(S,ot,st,k),Q[S]=st}function N(S){if(S._colorPtr=T(S.color),S._foregroundColorPtr=ht,S._backgroundColorPtr=ht,S._decorationColorPtr=ht,S.foregroundColor&&(S._foregroundColorPtr=T(S.foregroundColor,J)),S.backgroundColor&&(S._backgroundColorPtr=T(S.backgroundColor,dt)),S.decorationColor&&(S._decorationColorPtr=T(S.decorationColor,mt)),Array.isArray(S.fontFamilies)&&S.fontFamilies.length?(S._fontFamiliesPtr=P(S.fontFamilies),S._fontFamiliesLen=S.fontFamilies.length):(S._fontFamiliesPtr=ht,S._fontFamiliesLen=0),S.locale){var k=S.locale;S._localePtr=E(k),S._localeLen=Zt(k)+1}else S._localePtr=ht,S._localeLen=0;if(Array.isArray(S.shadows)&&S.shadows.length){k=S.shadows;var st=k.map(function(L){return L.color||o.BLACK}),vt=k.map(function(L){return L.blurRadius||0});S._shadowLen=k.length;for(var Tt=o._malloc(8*k.length),Vt=Tt/4,Yt=0;Yt<k.length;Yt++){var Lt=k[Yt].offset||[0,0];o.HEAPF32[Vt]=Lt[0],o.HEAPF32[Vt+1]=Lt[1],Vt+=2}S._shadowColorsPtr=O(st).be,S._shadowOffsetsPtr=Tt,S._shadowBlurRadiiPtr=A(vt,"HEAPF32")}else S._shadowLen=0,S._shadowColorsPtr=ht,S._shadowOffsetsPtr=ht,S._shadowBlurRadiiPtr=ht;Array.isArray(S.fontFeatures)&&S.fontFeatures.length?(k=S.fontFeatures,st=k.map(function(L){return L.name}),vt=k.map(function(L){return L.value}),S._fontFeatureLen=k.length,S._fontFeatureNamesPtr=P(st),S._fontFeatureValuesPtr=A(vt,"HEAPU32")):(S._fontFeatureLen=0,S._fontFeatureNamesPtr=ht,S._fontFeatureValuesPtr=ht),Array.isArray(S.fontVariations)&&S.fontVariations.length?(k=S.fontVariations,st=k.map(function(L){return L.axis}),vt=k.map(function(L){return L.value}),S._fontVariationLen=k.length,S._fontVariationAxesPtr=P(st),S._fontVariationValuesPtr=A(vt,"HEAPF32")):(S._fontVariationLen=0,S._fontVariationAxesPtr=ht,S._fontVariationValuesPtr=ht)}function W(S){o._free(S._fontFamiliesPtr),o._free(S._shadowColorsPtr),o._free(S._shadowOffsetsPtr),o._free(S._shadowBlurRadiiPtr),o._free(S._fontFeatureNamesPtr),o._free(S._fontFeatureValuesPtr),o._free(S._fontVariationAxesPtr),o._free(S._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(S,k,st,vt){return S=this._getRectsForRange(S,k,st,vt),c(S)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var S=this._getRectsForPlaceholders();return c(S)},o.Paragraph.prototype.getGlyphInfoAt=function(S){return a(this._getGlyphInfoAt(S))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(S,k){return a(this._getClosestGlyphInfoAtCoordinate(S,k))},o.TypefaceFontProvider.prototype.registerFont=function(S,k){if(S=o.Typeface.MakeFreeTypeFaceFromData(S),!S)return null;k=E(k),this._registerFont(S,k)},o.ParagraphStyle=function(S){if(S.disableHinting=S.disableHinting||!1,S.ellipsis){var k=S.ellipsis;S._ellipsisPtr=E(k),S._ellipsisLen=Zt(k)+1}else S._ellipsisPtr=ht,S._ellipsisLen=0;return S.heightMultiplier==null&&(S.heightMultiplier=-1),S.maxLines=S.maxLines||0,S.replaceTabCharacters=S.replaceTabCharacters||!1,k=(k=S.strutStyle)||{},k.strutEnabled=k.strutEnabled||!1,k.strutEnabled&&Array.isArray(k.fontFamilies)&&k.fontFamilies.length?(k._fontFamiliesPtr=P(k.fontFamilies),k._fontFamiliesLen=k.fontFamilies.length):(k._fontFamiliesPtr=ht,k._fontFamiliesLen=0),k.fontStyle=p(k.fontStyle),k.fontSize==null&&(k.fontSize=-1),k.heightMultiplier==null&&(k.heightMultiplier=-1),k.halfLeading=k.halfLeading||!1,k.leading=k.leading||0,k.forceStrutHeight=k.forceStrutHeight||!1,S.strutStyle=k,S.textAlign=S.textAlign||o.TextAlign.Start,S.textDirection=S.textDirection||o.TextDirection.LTR,S.textHeightBehavior=S.textHeightBehavior||o.TextHeightBehavior.All,S.textStyle=o.TextStyle(S.textStyle),S.applyRoundingHack=S.applyRoundingHack!==!1,S},o.TextStyle=function(S){return S.color||(S.color=o.BLACK),S.decoration=S.decoration||0,S.decorationThickness=S.decorationThickness||0,S.decorationStyle=S.decorationStyle||o.DecorationStyle.Solid,S.textBaseline=S.textBaseline||o.TextBaseline.Alphabetic,S.fontSize==null&&(S.fontSize=-1),S.letterSpacing=S.letterSpacing||0,S.wordSpacing=S.wordSpacing||0,S.heightMultiplier==null&&(S.heightMultiplier=-1),S.halfLeading=S.halfLeading||!1,S.fontStyle=p(S.fontStyle),S};var Q={},J=o._malloc(16),dt=o._malloc(16),mt=o._malloc(16);o.ParagraphBuilder.Make=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._Make(S,k),W(S.textStyle),k},o.ParagraphBuilder.MakeFromFontProvider=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._MakeFromFontProvider(S,k),W(S.textStyle),k},o.ParagraphBuilder.MakeFromFontCollection=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._MakeFromFontCollection(S,k),W(S.textStyle),k},o.ParagraphBuilder.ShapeText=function(S,k,st){let vt=0;for(const Tt of k)vt+=Tt.length;if(vt!==S.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(S,k,st)},o.ParagraphBuilder.prototype.pushStyle=function(S){N(S),this._pushStyle(S),W(S)},o.ParagraphBuilder.prototype.pushPaintStyle=function(S,k,st){N(S),this._pushPaintStyle(S,k,st),W(S)},o.ParagraphBuilder.prototype.addPlaceholder=function(S,k,st,vt,Tt){st=st||o.PlaceholderAlignment.Baseline,vt=vt||o.TextBaseline.Alphabetic,this._addPlaceholder(S||0,k||0,st,vt,Tt||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(S){var k=A(S,"HEAPU32");this._setWordsUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setWordsUtf16=function(S){var k=A(S,"HEAPU32");this._setWordsUtf16(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(S){var k=A(S,"HEAPU32");this._setGraphemeBreaksUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(S){var k=A(S,"HEAPU32");this._setGraphemeBreaksUtf16(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(S){var k=A(S,"HEAPU32");this._setLineBreaksUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(S){var k=A(S,"HEAPU32");this._setLineBreaksUtf16(k,S&&S.length||0),y(k,S)}})}(h),e.Td=e.Td||[],e.Td.push(function(){e.Path.prototype.op=function(o,a){return this._op(o,a)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.Td=e.Td||[],e.Td.push(function(){e.Canvas.prototype.drawText=function(o,a,c,p,P){var E=Zt(o),N=e._malloc(E+1);Qt(o,ot,N,E+1),this._drawSimpleText(N,E,a,c,P,p),e._free(N)},e.Canvas.prototype.drawGlyphs=function(o,a,c,p,P,E){if(!(2*o.length<=a.length))throw"Not enough positions for the array of gyphs";e.Md(this.Kd);const N=A(o,"HEAPU16"),W=A(a,"HEAPF32");this._drawGlyphs(o.length,N,W,c,p,P,E),y(W,a),y(N,o)},e.Font.prototype.getGlyphBounds=function(o,a,c){var p=A(o,"HEAPU16"),P=e._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,ht,P,a||null),a=new Float32Array(e.HEAPU8.buffer,P,4*o.length),y(p,o),c?(c.set(a),e._free(P),c):(o=Float32Array.from(a),e._free(P),o)},e.Font.prototype.getGlyphIDs=function(o,a,c){a||(a=o.length);var p=Zt(o)+1,P=e._malloc(p);return Qt(o,ot,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),c?(c.set(P),e._free(o),c):(c=Uint16Array.from(P),e._free(o),c))},e.Font.prototype.getGlyphIntercepts=function(o,a,c,p){var P=A(o,"HEAPU16"),E=A(a,"HEAPF32");return this._getGlyphIntercepts(P,o.length,!(o&&o._ck),E,a.length,!(a&&a._ck),c,p)},e.Font.prototype.getGlyphWidths=function(o,a,c){var p=A(o,"HEAPU16"),P=e._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,P,ht,a||null),a=new Float32Array(e.HEAPU8.buffer,P,o.length),y(p,o),c?(c.set(a),e._free(P),c):(o=Float32Array.from(a),e._free(P),o)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var o=arguments;if(o.length===1&&Array.isArray(o[0])&&(o=arguments[0]),!o.length)return null;for(var a=[],c=[],p=0;p<o.length;p++){var P=new Uint8Array(o[p]),E=A(P,"HEAPU8");a.push(E),c.push(P.byteLength)}return a=A(a,"HEAPU32"),c=A(c,"HEAPU32"),o=e.FontMgr._fromData(a,c,o.length),e._free(a),e._free(c),o},e.Typeface.MakeFreeTypeFaceFromData=function(o){o=new Uint8Array(o);var a=A(o,"HEAPU8");return(o=e.Typeface._MakeFreeTypeFaceFromData(a,o.byteLength))?o:null},e.Typeface.prototype.getGlyphIDs=function(o,a,c){a||(a=o.length);var p=Zt(o)+1,P=e._malloc(p);return Qt(o,ot,P,p),o=e._malloc(2*a),a=this._getGlyphIDs(P,p-1,a,o),e._free(P),0>a?(e._free(o),null):(P=new Uint16Array(e.HEAPU8.buffer,o,a),c?(c.set(P),e._free(o),c):(c=Uint16Array.from(P),e._free(o),c))},e.TextBlob.MakeOnPath=function(o,a,c,p){if(o&&o.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(o,c);p||(p=0);var P=c.getGlyphIDs(o);P=c.getGlyphWidths(P);var E=[];a=new e.ContourMeasureIter(a,!1,1);for(var N=a.next(),W=new Float32Array(4),Q=0;Q<o.length&&N;Q++){var J=P[Q];if(p+=J/2,p>N.length()){if(N.delete(),N=a.next(),!N){o=o.substring(0,Q);break}p=J/2}N.getPosTan(p,W);var dt=W[2],mt=W[3];E.push(dt,mt,W[0]-J/2*dt,W[1]-J/2*mt),p+=J/2}return o=this.MakeFromRSXform(o,E,c),N&&N.delete(),a.delete(),o}},e.TextBlob.MakeFromRSXform=function(o,a,c){var p=Zt(o)+1,P=e._malloc(p);return Qt(o,ot,P,p),o=A(a,"HEAPF32"),c=e.TextBlob._MakeFromRSXform(P,p-1,o,c),e._free(P),c||null},e.TextBlob.MakeFromRSXformGlyphs=function(o,a,c){var p=A(o,"HEAPU16");return a=A(a,"HEAPF32"),c=e.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,a,c),y(p,o),c||null},e.TextBlob.MakeFromGlyphs=function(o,a){var c=A(o,"HEAPU16");return a=e.TextBlob._MakeFromGlyphs(c,2*o.length,a),y(c,o),a||null},e.TextBlob.MakeFromText=function(o,a){var c=Zt(o)+1,p=e._malloc(c);return Qt(o,ot,p,c),o=e.TextBlob._MakeFromText(p,c-1,a),e._free(p),o||null},e.MallocGlyphIDs=function(o){return e.Malloc(Uint16Array,o)}}),e.Td=e.Td||[],e.Td.push(function(){e.MakePicture=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._MakePicture(a,o.byteLength))?o:null}}),e.Td=e.Td||[],e.Td.push(function(){e.RuntimeEffect.Make=function(o,a){return e.RuntimeEffect._Make(o,{onError:a||function(c){console.log("RuntimeEffect error",c)}})},e.RuntimeEffect.MakeForBlender=function(o,a){return e.RuntimeEffect._MakeForBlender(o,{onError:a||function(c){console.log("RuntimeEffect error",c)}})},e.RuntimeEffect.prototype.makeShader=function(o,a){var c=!o._ck,p=A(o,"HEAPF32");return a=D(a),this._makeShader(p,4*o.length,c,a)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(o,a,c){var p=!o._ck,P=A(o,"HEAPF32");c=D(c);for(var E=[],N=0;N<a.length;N++)E.push(a[N].Jd.Rd);return a=A(E,"HEAPU32"),this._makeShaderWithChildren(P,4*o.length,p,a,E.length,c)},e.RuntimeEffect.prototype.makeBlender=function(o){var a=!o._ck,c=A(o,"HEAPF32");return this._makeBlender(c,4*o.length,a)}}),function(){function o(L){for(var f=0;f<L.length;f++)if(L[f]!==void 0&&!Number.isFinite(L[f]))return!1;return!0}function a(L){var f=e.getColorComponents(L);L=f[0];var w=f[1],M=f[2];return f=f[3],f===1?(L=L.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),L=L.length===1?"0"+L:L,w=w.length===1?"0"+w:w,M=M.length===1?"0"+M:M,"#"+L+w+M):(f=f===0||f===1?f:f.toFixed(8),"rgba("+L+", "+w+", "+M+", "+f+")")}function c(L){return e.parseColorString(L,Vt)}function p(L){if(L=Yt.exec(L),!L)return null;var f=parseFloat(L[4]),w=16;switch(L[5]){case"em":case"rem":w=16*f;break;case"pt":w=4*f/3;break;case"px":w=f;break;case"pc":w=16*f;break;case"in":w=96*f;break;case"cm":w=96*f/2.54;break;case"mm":w=3.7795275590551185*f;break;case"q":w=.9448818897637796*f;break;case"%":w=.21333333333333335*f}return{style:L[1],variant:L[2],weight:L[3],sizePx:w,family:L[6].trim()}}function P(L){this.Ld=L,this.Od=new e.Paint,this.Od.setAntiAlias(!0),this.Od.setStrokeMiter(10),this.Od.setStrokeCap(e.StrokeCap.Butt),this.Od.setStrokeJoin(e.StrokeJoin.Miter),this.Re="10px monospace",this.me=new e.Font(null,10),this.me.setSubpixel(!0),this.ae=this.ge=e.BLACK,this.ve=0,this.Je=e.TRANSPARENT,this.xe=this.we=0,this.Ke=this.ie=1,this.Ie=0,this.ue=[],this.Nd=e.BlendMode.SrcOver,this.Od.setStrokeWidth(this.Ke),this.Od.setBlendMode(this.Nd),this.Qd=new e.Path,this.Sd=e.Matrix.identity(),this.lf=[],this.Be=[],this.le=function(){this.Qd.delete(),this.Od.delete(),this.me.delete(),this.Be.forEach(function(f){f.le()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Sd[0],c:this.Sd[1],e:this.Sd[2],b:this.Sd[3],d:this.Sd[4],f:this.Sd[5]}},set:function(f){f.a&&this.setTransform(f.a,f.b,f.c,f.d,f.e,f.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return l(this.ae)?a(this.ae):this.ae},set:function(f){typeof f=="string"?this.ae=c(f):f.te&&(this.ae=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(f){var w=p(f),M=w.family;w.typeface=Lt[M]?Lt[M][(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal")]||Lt[M]["*"]:null,w&&(this.me.setSize(w.sizePx),this.me.setTypeface(w.typeface),this.Re=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.ie},set:function(f){!isFinite(f)||0>f||1<f||(this.ie=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Nd){case e.BlendMode.SrcOver:return"source-over";case e.BlendMode.DstOver:return"destination-over";case e.BlendMode.Src:return"copy";case e.BlendMode.Dst:return"destination";case e.BlendMode.Clear:return"clear";case e.BlendMode.SrcIn:return"source-in";case e.BlendMode.DstIn:return"destination-in";case e.BlendMode.SrcOut:return"source-out";case e.BlendMode.DstOut:return"destination-out";case e.BlendMode.SrcATop:return"source-atop";case e.BlendMode.DstATop:return"destination-atop";case e.BlendMode.Xor:return"xor";case e.BlendMode.Plus:return"lighter";case e.BlendMode.Multiply:return"multiply";case e.BlendMode.Screen:return"screen";case e.BlendMode.Overlay:return"overlay";case e.BlendMode.Darken:return"darken";case e.BlendMode.Lighten:return"lighten";case e.BlendMode.ColorDodge:return"color-dodge";case e.BlendMode.ColorBurn:return"color-burn";case e.BlendMode.HardLight:return"hard-light";case e.BlendMode.SoftLight:return"soft-light";case e.BlendMode.Difference:return"difference";case e.BlendMode.Exclusion:return"exclusion";case e.BlendMode.Hue:return"hue";case e.BlendMode.Saturation:return"saturation";case e.BlendMode.Color:return"color";case e.BlendMode.Luminosity:return"luminosity"}},set:function(f){switch(f){case"source-over":this.Nd=e.BlendMode.SrcOver;break;case"destination-over":this.Nd=e.BlendMode.DstOver;break;case"copy":this.Nd=e.BlendMode.Src;break;case"destination":this.Nd=e.BlendMode.Dst;break;case"clear":this.Nd=e.BlendMode.Clear;break;case"source-in":this.Nd=e.BlendMode.SrcIn;break;case"destination-in":this.Nd=e.BlendMode.DstIn;break;case"source-out":this.Nd=e.BlendMode.SrcOut;break;case"destination-out":this.Nd=e.BlendMode.DstOut;break;case"source-atop":this.Nd=e.BlendMode.SrcATop;break;case"destination-atop":this.Nd=e.BlendMode.DstATop;break;case"xor":this.Nd=e.BlendMode.Xor;break;case"lighter":this.Nd=e.BlendMode.Plus;break;case"plus-lighter":this.Nd=e.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.Nd=e.BlendMode.Multiply;break;case"screen":this.Nd=e.BlendMode.Screen;break;case"overlay":this.Nd=e.BlendMode.Overlay;break;case"darken":this.Nd=e.BlendMode.Darken;break;case"lighten":this.Nd=e.BlendMode.Lighten;break;case"color-dodge":this.Nd=e.BlendMode.ColorDodge;break;case"color-burn":this.Nd=e.BlendMode.ColorBurn;break;case"hard-light":this.Nd=e.BlendMode.HardLight;break;case"soft-light":this.Nd=e.BlendMode.SoftLight;break;case"difference":this.Nd=e.BlendMode.Difference;break;case"exclusion":this.Nd=e.BlendMode.Exclusion;break;case"hue":this.Nd=e.BlendMode.Hue;break;case"saturation":this.Nd=e.BlendMode.Saturation;break;case"color":this.Nd=e.BlendMode.Color;break;case"luminosity":this.Nd=e.BlendMode.Luminosity;break;default:return}this.Od.setBlendMode(this.Nd)}}),Object.defineProperty(this,"imageSmoothingEnabled",{enumerable:!0,get:function(){return!0},set:function(){}}),Object.defineProperty(this,"imageSmoothingQuality",{enumerable:!0,get:function(){return"high"},set:function(){}}),Object.defineProperty(this,"lineCap",{enumerable:!0,get:function(){switch(this.Od.getStrokeCap()){case e.StrokeCap.Butt:return"butt";case e.StrokeCap.Round:return"round";case e.StrokeCap.Square:return"square"}},set:function(f){switch(f){case"butt":this.Od.setStrokeCap(e.StrokeCap.Butt);break;case"round":this.Od.setStrokeCap(e.StrokeCap.Round);break;case"square":this.Od.setStrokeCap(e.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.Ie},set:function(f){isFinite(f)&&(this.Ie=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Od.getStrokeJoin()){case e.StrokeJoin.Miter:return"miter";case e.StrokeJoin.Round:return"round";case e.StrokeJoin.Bevel:return"bevel"}},set:function(f){switch(f){case"miter":this.Od.setStrokeJoin(e.StrokeJoin.Miter);break;case"round":this.Od.setStrokeJoin(e.StrokeJoin.Round);break;case"bevel":this.Od.setStrokeJoin(e.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Od.getStrokeWidth()},set:function(f){0>=f||!f||(this.Ke=f,this.Od.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.Od.getStrokeMiter()},set:function(f){0>=f||!f||this.Od.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.ve},set:function(f){0>f||!isFinite(f)||(this.ve=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.Je)},set:function(f){this.Je=c(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.we},set:function(f){isFinite(f)&&(this.we=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.xe},set:function(f){isFinite(f)&&(this.xe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ge)},set:function(f){typeof f=="string"?this.ge=c(f):f.te&&(this.ge=f)}}),this.arc=function(f,w,M,R,I,z){S(this.Qd,f,w,M,M,0,R,I,z)},this.arcTo=function(f,w,M,R,I){J(this.Qd,f,w,M,R,I)},this.beginPath=function(){this.Qd.delete(),this.Qd=new e.Path},this.bezierCurveTo=function(f,w,M,R,I,z){var K=this.Qd;o([f,w,M,R,I,z])&&(K.isEmpty()&&K.moveTo(f,w),K.cubicTo(f,w,M,R,I,z))},this.clearRect=function(f,w,M,R){this.Od.setStyle(e.PaintStyle.Fill),this.Od.setBlendMode(e.BlendMode.Clear),this.Ld.drawRect(e.XYWHRect(f,w,M,R),this.Od),this.Od.setBlendMode(this.Nd)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.Qd):f&&f.af&&(f=f.Ud),f||(f=this.Qd),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(e.FillType.EvenOdd):f.setFillType(e.FillType.Winding),this.Ld.clipPath(f,e.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){dt(this.Qd)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new W(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new W(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,M,R){if(o(arguments)){var I=new Q(f,w,M,R);return this.Be.push(I),I}},this.createPattern=function(f,w){return f=new vt(f,w),this.Be.push(f),f},this.createRadialGradient=function(f,w,M,R,I,z){if(o(arguments)){var K=new Tt(f,w,M,R,I,z);return this.Be.push(K),K}},this.drawImage=function(f){f instanceof N&&(f=f.tf());var w=this.Qe();if(arguments.length===3||arguments.length===5)var M=e.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),R=e.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)M=e.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),R=e.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.Ld.drawImageRect(f,R,M,w,!1),w.dispose()},this.ellipse=function(f,w,M,R,I,z,K,Pt){S(this.Qd,f,w,M,R,I,z,K,Pt)},this.Qe=function(){var f=this.Od.copy();if(f.setStyle(e.PaintStyle.Fill),l(this.ae)){var w=e.multiplyByAlpha(this.ae,this.ie);f.setColor(w)}else w=this.ae.te(this.Sd),f.setColor(e.Color(0,0,0,this.ie)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.Qd):f&&f.af&&(f=f.Ud),w==="evenodd")this.Qd.setFillType(e.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.Qd.setFillType(e.FillType.Winding)}f||(f=this.Qd),w=this.Qe();var M=this.ye(w);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(f,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,M,R){var I=this.Qe(),z=this.ye(I);z&&(this.Ld.save(),this.re(),this.Ld.drawRect(e.XYWHRect(f,w,M,R),z),this.Ld.restore(),z.dispose()),this.Ld.drawRect(e.XYWHRect(f,w,M,R),I),I.dispose()},this.fillText=function(f,w,M){var R=this.Qe();f=e.TextBlob.MakeFromText(f,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(f,w,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(f,w,M,R),f.delete(),R.dispose()},this.getImageData=function(f,w,M,R){return(f=this.Ld.readPixels(f,w,{width:M,height:R,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB}))?new W(new Uint8ClampedArray(f.buffer),M,R):null},this.getLineDash=function(){return this.ue.slice()},this.mf=function(f){var w=e.Matrix.invert(this.Sd);return e.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,M){var R=arguments;if(R.length===3)var I=this.Qd;else if(R.length===4)I=R[0],f=R[1],w=R[2],M=R[3];else throw"invalid arg count, need 3 or 4, got "+R.length;return!isFinite(f)||!isFinite(w)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(R=this.mf([f,w]),f=R[0],w=R[1],I.setFillType(M==="nonzero"?e.FillType.Winding:e.FillType.EvenOdd),I.contains(f,w))},this.isPointInStroke=function(f,w){var M=arguments;if(M.length===2)var R=this.Qd;else if(M.length===3)R=M[0],f=M[1],w=M[2];else throw"invalid arg count, need 2 or 3, got "+M.length;return!isFinite(f)||!isFinite(w)?!1:(M=this.mf([f,w]),f=M[0],w=M[1],R=R.copy(),R.setFillType(e.FillType.Winding),R.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Od.getStrokeCap(),join:this.Od.getStrokeJoin(),precision:.3}),M=R.contains(f,w),R.delete(),M)},this.lineTo=function(f,w){k(this.Qd,f,w)},this.measureText=function(f){f=this.me.getGlyphIDs(f),f=this.me.getGlyphWidths(f);let w=0;for(const M of f)w+=M;return{width:w}},this.moveTo=function(f,w){var M=this.Qd;o([f,w])&&M.moveTo(f,w)},this.putImageData=function(f,w,M,R,I,z,K){if(o([w,M,R,I,z,K])){if(R===void 0)this.Ld.writePixels(f.data,f.width,f.height,w,M);else if(R=R||0,I=I||0,z=z||f.width,K=K||f.height,0>z&&(R+=z,z=Math.abs(z)),0>K&&(I+=K,K=Math.abs(K)),0>R&&(z+=R,R=0),0>I&&(K+=I,I=0),!(0>=z||0>=K)){f=e.MakeImage({width:f.width,height:f.height,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},f.data,4*f.width);var Pt=e.XYWHRect(R,I,z,K);w=e.XYWHRect(w+R,M+I,z,K),M=e.Matrix.invert(this.Sd),this.Ld.save(),this.Ld.concat(M),this.Ld.drawImageRect(f,Pt,w,null,!1),this.Ld.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,M,R){var I=this.Qd;o([f,w,M,R])&&(I.isEmpty()&&I.moveTo(f,w),I.quadTo(f,w,M,R))},this.rect=function(f,w,M,R){var I=this.Qd;f=e.XYWHRect(f,w,M,R),o(f)&&I.addRect(f)},this.resetTransform=function(){this.Qd.transform(this.Sd);var f=e.Matrix.invert(this.Sd);this.Ld.concat(f),this.Sd=this.Ld.getTotalMatrix()},this.restore=function(){var f=this.lf.pop();if(f){var w=e.Matrix.multiply(this.Sd,e.Matrix.invert(f.Jf));this.Qd.transform(w),this.Od.delete(),this.Od=f.ag,this.ue=f.Zf,this.Ke=f.mg,this.ge=f.lg,this.ae=f.fs,this.we=f.jg,this.xe=f.kg,this.ve=f.sb,this.Je=f.ig,this.ie=f.ga,this.Nd=f.Qf,this.Ie=f.$f,this.Re=f.Pf,this.Ld.restore(),this.Sd=this.Ld.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=e.Matrix.rotated(-f);this.Qd.transform(w),this.Ld.rotate(f/Math.PI*180,0,0),this.Sd=this.Ld.getTotalMatrix()}},this.save=function(){if(this.ae.se){var f=this.ae.se();this.Be.push(f)}else f=this.ae;if(this.ge.se){var w=this.ge.se();this.Be.push(w)}else w=this.ge;this.lf.push({Jf:this.Sd.slice(),Zf:this.ue.slice(),mg:this.Ke,lg:w,fs:f,jg:this.we,kg:this.xe,sb:this.ve,ig:this.Je,ga:this.ie,$f:this.Ie,Qf:this.Nd,ag:this.Od.copy(),Pf:this.Re}),this.Ld.save()},this.scale=function(f,w){if(o(arguments)){var M=e.Matrix.scaled(1/f,1/w);this.Qd.transform(M),this.Ld.scale(f,w),this.Sd=this.Ld.getTotalMatrix()}},this.setLineDash=function(f){for(var w=0;w<f.length;w++)if(!isFinite(f[w])||0>f[w])return;f.length%2===1&&Array.prototype.push.apply(f,f),this.ue=f},this.setTransform=function(f,w,M,R,I,z){o(arguments)&&(this.resetTransform(),this.transform(f,w,M,R,I,z))},this.re=function(){var f=e.Matrix.invert(this.Sd);this.Ld.concat(f),this.Ld.concat(e.Matrix.translated(this.we,this.xe)),this.Ld.concat(this.Sd)},this.ye=function(f){var w=e.multiplyByAlpha(this.Je,this.ie);if(!e.getColorComponents(w)[3]||!(this.ve||this.xe||this.we))return null;f=f.copy(),f.setColor(w);var M=e.MaskFilter.MakeBlur(e.BlurStyle.Normal,this.ve/2,!1);return f.setMaskFilter(M),f.dispose=function(){M.delete(),this.delete()},f},this.cf=function(){var f=this.Od.copy();if(f.setStyle(e.PaintStyle.Stroke),l(this.ge)){var w=e.multiplyByAlpha(this.ge,this.ie);f.setColor(w)}else w=this.ge.te(this.Sd),f.setColor(e.Color(0,0,0,this.ie)),f.setShader(w);if(f.setStrokeWidth(this.Ke),this.ue.length){var M=e.PathEffect.MakeDash(this.ue,this.Ie);f.setPathEffect(M)}return f.dispose=function(){M&&M.delete(),this.delete()},f},this.stroke=function(f){f=f?f.Ud:this.Qd;var w=this.cf(),M=this.ye(w);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(f,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,M,R){var I=this.cf(),z=this.ye(I);z&&(this.Ld.save(),this.re(),this.Ld.drawRect(e.XYWHRect(f,w,M,R),z),this.Ld.restore(),z.dispose()),this.Ld.drawRect(e.XYWHRect(f,w,M,R),I),I.dispose()},this.strokeText=function(f,w,M){var R=this.cf();f=e.TextBlob.MakeFromText(f,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(f,w,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(f,w,M,R),f.delete(),R.dispose()},this.translate=function(f,w){if(o(arguments)){var M=e.Matrix.translated(-f,-w);this.Qd.transform(M),this.Ld.translate(f,w),this.Sd=this.Ld.getTotalMatrix()}},this.transform=function(f,w,M,R,I,z){f=[f,M,I,w,R,z,0,0,1],w=e.Matrix.invert(f),this.Qd.transform(w),this.Ld.concat(f),this.Sd=this.Ld.getTotalMatrix()},this.addHitRegion=function(){},this.clearHitRegions=function(){},this.drawFocusIfNeeded=function(){},this.removeHitRegion=function(){},this.scrollPathIntoView=function(){},Object.defineProperty(this,"canvas",{value:null,writable:!1})}function E(L){this.df=L,this.Kd=new P(L.getCanvas()),this.Se=[],this.decodeImage=function(f){if(f=e.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.Se.push(f),new N(f)},this.loadFont=function(f,w){if(f=e.Typeface.MakeFreeTypeFaceFromData(f),!f)return null;this.Se.push(f);var M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,Lt[w]||(Lt[w]={"*":f}),Lt[w][M]=f},this.makePath2D=function(f){return f=new st(f),this.Se.push(f.Ud),f},this.getContext=function(f){return f==="2d"?this.Kd:null},this.toDataURL=function(f,w){this.df.flush();var M=this.df.makeImageSnapshot();if(M){f=f||"image/png";var R=e.ImageFormat.PNG;if(f==="image/jpeg"&&(R=e.ImageFormat.JPEG),w=M.encodeToBytes(R,w||.92)){if(M.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{M=0,R=w.length;for(var I="",z;M<R;)z=w.slice(M,Math.min(M+32768,R)),I+=String.fromCharCode.apply(null,z),M+=32768;w=btoa(I)}return f+w}}},this.dispose=function(){this.Kd.le(),this.Se.forEach(function(f){f.delete()}),this.df.dispose()}}function N(L){this.width=L.width(),this.height=L.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.tf=function(){return L}}function W(L,f,w){if(!f||w===0)throw"invalid dimensions, width and height must be non-zero";if(L.length%4)throw"arr must be a multiple of 4";w=w||L.length/(4*f),Object.defineProperty(this,"data",{value:L,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function Q(L,f,w,M){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(R,I){if(0>R||1<R||!isFinite(R))throw"offset must be between 0 and 1 inclusively";I=c(I);var z=this.Zd.indexOf(R);if(z!==-1)this.ce[z]=I;else{for(z=0;z<this.Zd.length&&!(this.Zd[z]>R);z++);this.Zd.splice(z,0,R),this.ce.splice(z,0,I)}},this.se=function(){var R=new Q(L,f,w,M);return R.ce=this.ce.slice(),R.Zd=this.Zd.slice(),R},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(R){var I=[L,f,w,M];e.Matrix.mapPoints(R,I),R=I[0];var z=I[1],K=I[2];return I=I[3],this.le(),this.Wd=e.Shader.MakeLinearGradient([R,z],[K,I],this.ce,this.Zd,e.TileMode.Clamp)}}function J(L,f,w,M,R,I){if(o([f,w,M,R,I])){if(0>I)throw"radii cannot be negative";L.isEmpty()&&L.moveTo(f,w),L.arcToTangent(f,w,M,R,I)}}function dt(L){if(!L.isEmpty()){var f=L.getBounds();(f[3]-f[1]||f[2]-f[0])&&L.close()}}function mt(L,f,w,M,R,I,z){z=(z-I)/Math.PI*180,I=I/Math.PI*180,f=e.LTRBRect(f-M,w-R,f+M,w+R),1e-5>Math.abs(Math.abs(z)-360)?(w=z/2,L.arcToOval(f,I,w,!1),L.arcToOval(f,I+w,w,!1)):L.arcToOval(f,I,z,!1)}function S(L,f,w,M,R,I,z,K,Pt){if(o([f,w,M,R,I,z,K])){if(0>M||0>R)throw"radii cannot be negative";var bt=2*Math.PI,he=z%bt;0>he&&(he+=bt);var ni=he-z;z=he,K+=ni,!Pt&&K-z>=bt?K=z+bt:Pt&&z-K>=bt?K=z-bt:!Pt&&z>K?K=z+(bt-(z-K)%bt):Pt&&z<K&&(K=z-(bt-(K-z)%bt)),I?(Pt=e.Matrix.rotated(I,f,w),I=e.Matrix.rotated(-I,f,w),L.transform(I),mt(L,f,w,M,R,z,K),L.transform(Pt)):mt(L,f,w,M,R,z,K)}}function k(L,f,w){o([f,w])&&(L.isEmpty()&&L.moveTo(f,w),L.lineTo(f,w))}function st(L){this.Ud=null,this.Ud=typeof L=="string"?e.Path.MakeFromSVGString(L):L&&L.af?L.Ud.copy():new e.Path,this.af=function(){return this.Ud},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.Ud.addPath(f.Ud,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,M,R,I,z){S(this.Ud,f,w,M,M,0,R,I,z)},this.arcTo=function(f,w,M,R,I){J(this.Ud,f,w,M,R,I)},this.bezierCurveTo=function(f,w,M,R,I,z){var K=this.Ud;o([f,w,M,R,I,z])&&(K.isEmpty()&&K.moveTo(f,w),K.cubicTo(f,w,M,R,I,z))},this.closePath=function(){dt(this.Ud)},this.ellipse=function(f,w,M,R,I,z,K,Pt){S(this.Ud,f,w,M,R,I,z,K,Pt)},this.lineTo=function(f,w){k(this.Ud,f,w)},this.moveTo=function(f,w){var M=this.Ud;o([f,w])&&M.moveTo(f,w)},this.quadraticCurveTo=function(f,w,M,R){var I=this.Ud;o([f,w,M,R])&&(I.isEmpty()&&I.moveTo(f,w),I.quadTo(f,w,M,R))},this.rect=function(f,w,M,R){var I=this.Ud;f=e.XYWHRect(f,w,M,R),o(f)&&I.addRect(f)}}function vt(L,f){switch(this.Wd=null,L instanceof N&&(L=L.tf()),this.Ef=L,this._transform=e.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.ze=e.TileMode.Repeat,this.Ae=e.TileMode.Decal;break;case"repeat-y":this.ze=e.TileMode.Decal,this.Ae=e.TileMode.Repeat;break;case"repeat":this.Ae=this.ze=e.TileMode.Repeat;break;case"no-repeat":this.Ae=this.ze=e.TileMode.Decal;break;default:throw"invalid repetition mode "+f}this.setTransform=function(w){w=[w.a,w.c,w.e,w.b,w.d,w.f,0,0,1],o(w)&&(this._transform=w)},this.se=function(){var w=new vt;return w.ze=this.ze,w.Ae=this.Ae,w},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(){return this.le(),this.Wd=this.Ef.makeShaderCubic(this.ze,this.Ae,.3333333333333333,.3333333333333333,this._transform)}}function Tt(L,f,w,M,R,I){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(z,K){if(0>z||1<z||!isFinite(z))throw"offset must be between 0 and 1 inclusively";K=c(K);var Pt=this.Zd.indexOf(z);if(Pt!==-1)this.ce[Pt]=K;else{for(Pt=0;Pt<this.Zd.length&&!(this.Zd[Pt]>z);Pt++);this.Zd.splice(Pt,0,z),this.ce.splice(Pt,0,K)}},this.se=function(){var z=new Tt(L,f,w,M,R,I);return z.ce=this.ce.slice(),z.Zd=this.Zd.slice(),z},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(z){var K=[L,f,M,R];e.Matrix.mapPoints(z,K);var Pt=K[0],bt=K[1],he=K[2];K=K[3];var ni=(Math.abs(z[0])+Math.abs(z[4]))/2;return z=w*ni,ni*=I,this.le(),this.Wd=e.Shader.MakeTwoPointConicalGradient([Pt,bt],z,[he,K],ni,this.ce,this.Zd,e.TileMode.Clamp)}}e._testing={};var Vt={aliceblue:Float32Array.of(.941,.973,1,1),antiquewhite:Float32Array.of(.98,.922,.843,1),aqua:Float32Array.of(0,1,1,1),aquamarine:Float32Array.of(.498,1,.831,1),azure:Float32Array.of(.941,1,1,1),beige:Float32Array.of(.961,.961,.863,1),bisque:Float32Array.of(1,.894,.769,1),black:Float32Array.of(0,0,0,1),blanchedalmond:Float32Array.of(1,.922,.804,1),blue:Float32Array.of(0,0,1,1),blueviolet:Float32Array.of(.541,.169,.886,1),brown:Float32Array.of(.647,.165,.165,1),burlywood:Float32Array.of(.871,.722,.529,1),cadetblue:Float32Array.of(.373,.62,.627,1),chartreuse:Float32Array.of(.498,1,0,1),chocolate:Float32Array.of(.824,.412,.118,1),coral:Float32Array.of(1,.498,.314,1),cornflowerblue:Float32Array.of(.392,.584,.929,1),cornsilk:Float32Array.of(1,.973,.863,1),crimson:Float32Array.of(.863,.078,.235,1),cyan:Float32Array.of(0,1,1,1),darkblue:Float32Array.of(0,0,.545,1),darkcyan:Float32Array.of(0,.545,.545,1),darkgoldenrod:Float32Array.of(.722,.525,.043,1),darkgray:Float32Array.of(.663,.663,.663,1),darkgreen:Float32Array.of(0,.392,0,1),darkgrey:Float32Array.of(.663,.663,.663,1),darkkhaki:Float32Array.of(.741,.718,.42,1),darkmagenta:Float32Array.of(.545,0,.545,1),darkolivegreen:Float32Array.of(.333,.42,.184,1),darkorange:Float32Array.of(1,.549,0,1),darkorchid:Float32Array.of(.6,.196,.8,1),darkred:Float32Array.of(.545,0,0,1),darksalmon:Float32Array.of(.914,.588,.478,1),darkseagreen:Float32Array.of(.561,.737,.561,1),darkslateblue:Float32Array.of(.282,.239,.545,1),darkslategray:Float32Array.of(.184,.31,.31,1),darkslategrey:Float32Array.of(.184,.31,.31,1),darkturquoise:Float32Array.of(0,.808,.82,1),darkviolet:Float32Array.of(.58,0,.827,1),deeppink:Float32Array.of(1,.078,.576,1),deepskyblue:Float32Array.of(0,.749,1,1),dimgray:Float32Array.of(.412,.412,.412,1),dimgrey:Float32Array.of(.412,.412,.412,1),dodgerblue:Float32Array.of(.118,.565,1,1),firebrick:Float32Array.of(.698,.133,.133,1),floralwhite:Float32Array.of(1,.98,.941,1),forestgreen:Float32Array.of(.133,.545,.133,1),fuchsia:Float32Array.of(1,0,1,1),gainsboro:Float32Array.of(.863,.863,.863,1),ghostwhite:Float32Array.of(.973,.973,1,1),gold:Float32Array.of(1,.843,0,1),goldenrod:Float32Array.of(.855,.647,.125,1),gray:Float32Array.of(.502,.502,.502,1),green:Float32Array.of(0,.502,0,1),greenyellow:Float32Array.of(.678,1,.184,1),grey:Float32Array.of(.502,.502,.502,1),honeydew:Float32Array.of(.941,1,.941,1),hotpink:Float32Array.of(1,.412,.706,1),indianred:Float32Array.of(.804,.361,.361,1),indigo:Float32Array.of(.294,0,.51,1),ivory:Float32Array.of(1,1,.941,1),khaki:Float32Array.of(.941,.902,.549,1),lavender:Float32Array.of(.902,.902,.98,1),lavenderblush:Float32Array.of(1,.941,.961,1),lawngreen:Float32Array.of(.486,.988,0,1),lemonchiffon:Float32Array.of(1,.98,.804,1),lightblue:Float32Array.of(.678,.847,.902,1),lightcoral:Float32Array.of(.941,.502,.502,1),lightcyan:Float32Array.of(.878,1,1,1),lightgoldenrodyellow:Float32Array.of(.98,.98,.824,1),lightgray:Float32Array.of(.827,.827,.827,1),lightgreen:Float32Array.of(.565,.933,.565,1),lightgrey:Float32Array.of(.827,.827,.827,1),lightpink:Float32Array.of(1,.714,.757,1),lightsalmon:Float32Array.of(1,.627,.478,1),lightseagreen:Float32Array.of(.125,.698,.667,1),lightskyblue:Float32Array.of(.529,.808,.98,1),lightslategray:Float32Array.of(.467,.533,.6,1),lightslategrey:Float32Array.of(.467,.533,.6,1),lightsteelblue:Float32Array.of(.69,.769,.871,1),lightyellow:Float32Array.of(1,1,.878,1),lime:Float32Array.of(0,1,0,1),limegreen:Float32Array.of(.196,.804,.196,1),linen:Float32Array.of(.98,.941,.902,1),magenta:Float32Array.of(1,0,1,1),maroon:Float32Array.of(.502,0,0,1),mediumaquamarine:Float32Array.of(.4,.804,.667,1),mediumblue:Float32Array.of(0,0,.804,1),mediumorchid:Float32Array.of(.729,.333,.827,1),mediumpurple:Float32Array.of(.576,.439,.859,1),mediumseagreen:Float32Array.of(.235,.702,.443,1),mediumslateblue:Float32Array.of(.482,.408,.933,1),mediumspringgreen:Float32Array.of(0,.98,.604,1),mediumturquoise:Float32Array.of(.282,.82,.8,1),mediumvioletred:Float32Array.of(.78,.082,.522,1),midnightblue:Float32Array.of(.098,.098,.439,1),mintcream:Float32Array.of(.961,1,.98,1),mistyrose:Float32Array.of(1,.894,.882,1),moccasin:Float32Array.of(1,.894,.71,1),navajowhite:Float32Array.of(1,.871,.678,1),navy:Float32Array.of(0,0,.502,1),oldlace:Float32Array.of(.992,.961,.902,1),olive:Float32Array.of(.502,.502,0,1),olivedrab:Float32Array.of(.42,.557,.137,1),orange:Float32Array.of(1,.647,0,1),orangered:Float32Array.of(1,.271,0,1),orchid:Float32Array.of(.855,.439,.839,1),palegoldenrod:Float32Array.of(.933,.91,.667,1),palegreen:Float32Array.of(.596,.984,.596,1),paleturquoise:Float32Array.of(.686,.933,.933,1),palevioletred:Float32Array.of(.859,.439,.576,1),papayawhip:Float32Array.of(1,.937,.835,1),peachpuff:Float32Array.of(1,.855,.725,1),peru:Float32Array.of(.804,.522,.247,1),pink:Float32Array.of(1,.753,.796,1),plum:Float32Array.of(.867,.627,.867,1),powderblue:Float32Array.of(.69,.878,.902,1),purple:Float32Array.of(.502,0,.502,1),rebeccapurple:Float32Array.of(.4,.2,.6,1),red:Float32Array.of(1,0,0,1),rosybrown:Float32Array.of(.737,.561,.561,1),royalblue:Float32Array.of(.255,.412,.882,1),saddlebrown:Float32Array.of(.545,.271,.075,1),salmon:Float32Array.of(.98,.502,.447,1),sandybrown:Float32Array.of(.957,.643,.376,1),seagreen:Float32Array.of(.18,.545,.341,1),seashell:Float32Array.of(1,.961,.933,1),sienna:Float32Array.of(.627,.322,.176,1),silver:Float32Array.of(.753,.753,.753,1),skyblue:Float32Array.of(.529,.808,.922,1),slateblue:Float32Array.of(.416,.353,.804,1),slategray:Float32Array.of(.439,.502,.565,1),slategrey:Float32Array.of(.439,.502,.565,1),snow:Float32Array.of(1,.98,.98,1),springgreen:Float32Array.of(0,1,.498,1),steelblue:Float32Array.of(.275,.51,.706,1),tan:Float32Array.of(.824,.706,.549,1),teal:Float32Array.of(0,.502,.502,1),thistle:Float32Array.of(.847,.749,.847,1),tomato:Float32Array.of(1,.388,.278,1),transparent:Float32Array.of(0,0,0,0),turquoise:Float32Array.of(.251,.878,.816,1),violet:Float32Array.of(.933,.51,.933,1),wheat:Float32Array.of(.961,.871,.702,1),white:Float32Array.of(1,1,1,1),whitesmoke:Float32Array.of(.961,.961,.961,1),yellow:Float32Array.of(1,1,0,1),yellowgreen:Float32Array.of(.604,.804,.196,1)};e._testing.parseColor=c,e._testing.colorToString=a;var Yt=RegExp("(italic|oblique|normal|)\\s*(small-caps|normal|)\\s*(bold|bolder|lighter|[1-9]00|normal|)\\s*([\\d\\.]+)(px|pt|pc|in|cm|mm|%|em|ex|ch|rem|q)(.+)"),Lt={"Noto Mono":{"*":null},monospace:{"*":null}};e._testing.parseFontString=p,e.MakeCanvas=function(L,f){return(L=e.MakeSurface(L,f))?new E(L):null},e.ImageData=function(){if(arguments.length===2){var L=arguments[0],f=arguments[1];return new W(new Uint8ClampedArray(4*L*f),L,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw"bytes must be given as a Uint8ClampedArray";if(L=arguments[1],f=arguments[2],w%4)throw"bytes must be given in a multiple of 4";if(w%L)throw"bytes must divide evenly by width";if(f&&f!==w/(4*L))throw"invalid height given";return new W(w,L,w/(4*L))}throw"invalid number of arguments - takes 2 or 3, saw "+arguments.length}}()}(h);var B=Object.assign({},h),U="./this.program",et=(e,r)=>{throw r},ct=typeof window=="object",ut=typeof importScripts=="function",At=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",yt="",ne,Se,Me;if(At){var We=ea,Ii=aa;yt=ut?Ii.dirname(yt)+"/":__dirname+"/",ne=(e,r)=>(e=e.startsWith("file://")?new URL(e):Ii.normalize(e),We.readFileSync(e,r?void 0:"utf8")),Me=e=>(e=ne(e,!0),e.buffer||(e=new Uint8Array(e)),e),Se=(e,r,s,l=!0)=>{e=e.startsWith("file://")?new URL(e):Ii.normalize(e),We.readFile(e,l?void 0:"utf8",(d,m)=>{d?s(d):r(l?m.buffer:m)})},!h.thisProgram&&1<process.argv.length&&(U=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),et=(e,r)=>{throw process.exitCode=e,r},h.inspect=()=>"[Emscripten Module object]"}else(ct||ut)&&(ut?yt=self.location.href:typeof document<"u"&&document.currentScript&&(yt=document.currentScript.src),n&&(yt=n),yt.indexOf("blob:")!==0?yt=yt.substr(0,yt.replace(/[?#].*/,"").lastIndexOf("/")+1):yt="",ne=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},ut&&(Me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Se=(e,r,s)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?r(l.response):s()},l.onerror=s,l.send(null)});var jn=h.print||console.log.bind(console),pe=h.printErr||console.error.bind(console);Object.assign(h,B),B=null,h.thisProgram&&(U=h.thisProgram),h.quit&&(et=h.quit);var $e;h.wasmBinary&&($e=h.wasmBinary);var Hn=h.noExitRuntime||!0;typeof WebAssembly!="object"&&Di("no native wasm support detected");var li,lt,Li=!1,se,ot,me,xe,$,wt,Z,mr;function gr(){var e=li.buffer;h.HEAP8=se=new Int8Array(e),h.HEAP16=me=new Int16Array(e),h.HEAP32=$=new Int32Array(e),h.HEAPU8=ot=new Uint8Array(e),h.HEAPU16=xe=new Uint16Array(e),h.HEAPU32=wt=new Uint32Array(e),h.HEAPF32=Z=new Float32Array(e),h.HEAPF64=mr=new Float64Array(e)}var Mt,vr=[],yr=[],wr=[];function Kn(){var e=h.preRun.shift();vr.unshift(e)}var Pe=0,Ge=null;function Di(e){throw h.onAbort&&h.onAbort(e),e="Aborted("+e+")",pe(e),Li=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),F(e),e}function Sr(e){return e.startsWith("data:application/octet-stream;base64,")}var Re;if(Re="canvaskit.wasm",!Sr(Re)){var Pr=Re;Re=h.locateFile?h.locateFile(Pr,yt):yt+Pr}function br(e){if(e==Re&&$e)return new Uint8Array($e);if(Me)return Me(e);throw"both async and sync fetching of the wasm failed"}function Vn(e){if(!$e&&(ct||ut)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>br(e));if(Se)return new Promise((r,s)=>{Se(e,l=>r(new Uint8Array(l)),s)})}return Promise.resolve().then(()=>br(e))}function Ar(e,r,s){return Vn(e).then(l=>WebAssembly.instantiate(l,r)).then(l=>l).then(s,l=>{pe("failed to asynchronously prepare wasm: "+l),Di(l)})}function Yn(e,r){var s=Re;return $e||typeof WebAssembly.instantiateStreaming!="function"||Sr(s)||s.startsWith("file://")||At||typeof fetch!="function"?Ar(s,e,r):fetch(s,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(r,function(d){return pe("wasm streaming compile failed: "+d),pe("falling back to ArrayBuffer instantiation"),Ar(s,e,r)}))}function qn(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var zi=e=>{for(;0<e.length;)e.shift()(h)},Cr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,be=(e,r,s)=>{var l=r+s;for(s=r;e[s]&&!(s>=l);)++s;if(16<s-r&&e.buffer&&Cr)return Cr.decode(e.subarray(r,s));for(l="";r<s;){var d=e[r++];if(d&128){var m=e[r++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|m);else{var b=e[r++]&63;d=(d&240)==224?(d&15)<<12|m<<6|b:(d&7)<<18|m<<12|b<<6|e[r++]&63,65536>d?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else l+=String.fromCharCode(d)}return l},hi={};function Bi(e){for(;e.length;){var r=e.pop();e.pop()(r)}}function je(e){return this.fromWireType($[e>>2])}var Ne={},Ae={},ci={},_r=void 0;function ui(e){throw new _r(e)}function Jt(e,r,s){function l(v){v=s(v),v.length!==e.length&&ui("Mismatched type converter count");for(var y=0;y<e.length;++y)ae(e[y],v[y])}e.forEach(function(v){ci[v]=r});var d=Array(r.length),m=[],b=0;r.forEach((v,y)=>{Ae.hasOwnProperty(v)?d[y]=Ae[v]:(m.push(v),Ne.hasOwnProperty(v)||(Ne[v]=[]),Ne[v].push(()=>{d[y]=Ae[v],++b,b===m.length&&l(d)}))}),m.length===0&&l(d)}function di(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var Er=void 0;function _t(e){for(var r="";ot[e];)r+=Er[ot[e++]];return r}var ke=void 0;function ft(e){throw new ke(e)}function Xn(e,r,s={}){var l=r.name;if(e||ft(`type "${l}" must have a positive integer typeid pointer`),Ae.hasOwnProperty(e)){if(s.Wf)return;ft(`Cannot register type '${l}' twice`)}Ae[e]=r,delete ci[e],Ne.hasOwnProperty(e)&&(r=Ne[e],delete Ne[e],r.forEach(d=>d()))}function ae(e,r,s={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");Xn(e,r,s)}function Ui(e){ft(e.Jd.Vd.Pd.name+" instance already deleted")}var Wi=!1;function Tr(){}function Fr(e){--e.count.value,e.count.value===0&&(e.Yd?e.ee.ke(e.Yd):e.Vd.Pd.ke(e.Rd))}function Mr(e,r,s){return r===s?e:s.$d===void 0?null:(e=Mr(e,r,s.$d),e===null?null:s.Mf(e))}var xr={},He=[];function $i(){for(;He.length;){var e=He.pop();e.Jd.Ee=!1,e.delete()}}var Ke=void 0,Ve={};function Jn(e,r){for(r===void 0&&ft("ptr should not be undefined");e.$d;)r=e.Oe(r),e=e.$d;return Ve[r]}function fi(e,r){return r.Vd&&r.Rd||ui("makeClassHandle requires ptr and ptrType"),!!r.ee!=!!r.Yd&&ui("Both smartPtrType and smartPtr must be specified"),r.count={value:1},Ye(Object.create(e,{Jd:{value:r}}))}function Ye(e){return typeof FinalizationRegistry>"u"?(Ye=r=>r,e):(Wi=new FinalizationRegistry(r=>{Fr(r.Jd)}),Ye=r=>{var s=r.Jd;return s.Yd&&Wi.register(r,{Jd:s},r),r},Tr=r=>{Wi.unregister(r)},Ye(e))}function ge(){}function Rr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return 48<=r&&57>=r?`_${e}`:e}function Gi(e,r){return e=Rr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function ji(e,r,s){if(e[r].Xd===void 0){var l=e[r];e[r]=function(){return e[r].Xd.hasOwnProperty(arguments.length)||ft(`Function '${s}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].Xd})!`),e[r].Xd[arguments.length].apply(this,arguments)},e[r].Xd=[],e[r].Xd[l.Ce]=l}}function Hi(e,r,s){h.hasOwnProperty(e)?((s===void 0||h[e].Xd!==void 0&&h[e].Xd[s]!==void 0)&&ft(`Cannot register public name '${e}' twice`),ji(h,e,e),h.hasOwnProperty(s)&&ft(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`),h[e].Xd[s]=r):(h[e]=r,s!==void 0&&(h[e].tg=s))}function Qn(e,r,s,l,d,m,b,v){this.name=e,this.constructor=r,this.Fe=s,this.ke=l,this.$d=d,this.Rf=m,this.Oe=b,this.Mf=v,this.cg=[]}function Ki(e,r,s){for(;r!==s;)r.Oe||ft(`Expected null or instance of ${s.name}, got an instance of ${r.name}`),e=r.Oe(e),r=r.$d;return e}function Zn(e,r){return r===null?(this.gf&&ft(`null is not a valid ${this.name}`),0):(r.Jd||ft(`Cannot pass "${Yi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd))}function ts(e,r){if(r===null){if(this.gf&&ft(`null is not a valid ${this.name}`),this.Ve){var s=this.hf();return e!==null&&e.push(this.ke,s),s}return 0}if(r.Jd||ft(`Cannot pass "${Yi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.Ue&&r.Jd.Vd.Ue&&ft(`Cannot convert argument of type ${r.Jd.ee?r.Jd.ee.name:r.Jd.Vd.name} to parameter type ${this.name}`),s=Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd),this.Ve)switch(r.Jd.Yd===void 0&&ft("Passing raw pointer to smart pointer is illegal"),this.hg){case 0:r.Jd.ee===this?s=r.Jd.Yd:ft(`Cannot convert argument of type ${r.Jd.ee?r.Jd.ee.name:r.Jd.Vd.name} to parameter type ${this.name}`);break;case 1:s=r.Jd.Yd;break;case 2:if(r.Jd.ee===this)s=r.Jd.Yd;else{var l=r.clone();s=this.dg(s,Ht(function(){l.delete()})),e!==null&&e.push(this.ke,s)}break;default:ft("Unsupporting sharing policy")}return s}function es(e,r){return r===null?(this.gf&&ft(`null is not a valid ${this.name}`),0):(r.Jd||ft(`Cannot pass "${Yi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),r.Jd.Vd.Ue&&ft(`Cannot convert argument of type ${r.Jd.Vd.name} to parameter type ${this.name}`),Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd))}function oe(e,r,s,l,d,m,b,v,y,A,O){this.name=e,this.Pd=r,this.gf=s,this.Ue=l,this.Ve=d,this.bg=m,this.hg=b,this.vf=v,this.hf=y,this.dg=A,this.ke=O,d||r.$d!==void 0?this.toWireType=ts:(this.toWireType=l?Zn:es,this.de=null)}function Nr(e,r,s){h.hasOwnProperty(e)||ui("Replacing nonexistant public symbol"),h[e].Xd!==void 0&&s!==void 0?h[e].Xd[s]=r:(h[e]=r,h[e].Ce=s)}var is=(e,r)=>{var s=[];return function(){if(s.length=0,Object.assign(s,arguments),e.includes("j")){var l=h["dynCall_"+e];l=s&&s.length?l.apply(null,[r].concat(s)):l.call(null,r)}else l=Mt.get(r).apply(null,s);return l}};function Nt(e,r){e=_t(e);var s=e.includes("j")?is(e,r):Mt.get(r);return typeof s!="function"&&ft(`unknown function pointer with signature ${e}: ${r}`),s}var kr=void 0;function Or(e){e=en(e);var r=_t(e);return ue(e),r}function qe(e,r){function s(m){d[m]||Ae[m]||(ci[m]?ci[m].forEach(s):(l.push(m),d[m]=!0))}var l=[],d={};throw r.forEach(s),new kr(`${e}: `+l.map(Or).join([", "]))}function pi(e,r,s,l,d){var m=r.length;2>m&&ft("argTypes array size mismatch! Must at least get return value and 'this' types!");var b=r[1]!==null&&s!==null,v=!1;for(s=1;s<r.length;++s)if(r[s]!==null&&r[s].de===void 0){v=!0;break}var y=r[0].name!=="void",A=m-2,O=Array(A),D=[],H=[];return function(){if(arguments.length!==A&&ft(`function ${e} called with ${arguments.length} arguments, expected ${A} args!`),H.length=0,D.length=b?2:1,D[0]=d,b){var T=r[1].toWireType(H,this);D[1]=T}for(var Y=0;Y<A;++Y)O[Y]=r[Y+2].toWireType(H,arguments[Y]),D.push(O[Y]);if(Y=l.apply(null,D),v)Bi(H);else for(var nt=b?1:2;nt<r.length;nt++){var rt=nt===1?T:O[nt-2];r[nt].de!==null&&r[nt].de(rt)}return T=y?r[0].fromWireType(Y):void 0,T}}function mi(e,r){for(var s=[],l=0;l<e;l++)s.push(wt[r+4*l>>2]);return s}function Ir(){this.je=[void 0],this.sf=[]}var Gt=new Ir;function Vi(e){e>=Gt.Ge&&--Gt.get(e).wf===0&&Gt.Bf(e)}var jt=e=>(e||ft("Cannot use deleted val. handle = "+e),Gt.get(e).value),Ht=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Gt.Af({wf:1,value:e})}};function rs(e,r,s){switch(r){case 0:return function(l){return this.fromWireType((s?se:ot)[l])};case 1:return function(l){return this.fromWireType((s?me:xe)[l>>1])};case 2:return function(l){return this.fromWireType((s?$:wt)[l>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Xe(e,r){var s=Ae[e];return s===void 0&&ft(r+" has unknown type "+Or(e)),s}function Yi(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function ns(e,r){switch(r){case 2:return function(s){return this.fromWireType(Z[s>>2])};case 3:return function(s){return this.fromWireType(mr[s>>3])};default:throw new TypeError("Unknown float type: "+e)}}function ss(e,r,s){switch(r){case 0:return s?function(l){return se[l]}:function(l){return ot[l]};case 1:return s?function(l){return me[l>>1]}:function(l){return xe[l>>1]};case 2:return s?function(l){return $[l>>2]}:function(l){return wt[l>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Qt=(e,r,s,l)=>{if(!(0<l))return 0;var d=s;l=s+l-1;for(var m=0;m<e.length;++m){var b=e.charCodeAt(m);if(55296<=b&&57343>=b){var v=e.charCodeAt(++m);b=65536+((b&1023)<<10)|v&1023}if(127>=b){if(s>=l)break;r[s++]=b}else{if(2047>=b){if(s+1>=l)break;r[s++]=192|b>>6}else{if(65535>=b){if(s+2>=l)break;r[s++]=224|b>>12}else{if(s+3>=l)break;r[s++]=240|b>>18,r[s++]=128|b>>12&63}r[s++]=128|b>>6&63}r[s++]=128|b&63}}return r[s]=0,s-d},Zt=e=>{for(var r=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);127>=l?r++:2047>=l?r+=2:55296<=l&&57343>=l?(r+=4,++s):r+=3}return r},Lr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,as=(e,r)=>{for(var s=e>>1,l=s+r/2;!(s>=l)&&xe[s];)++s;if(s<<=1,32<s-e&&Lr)return Lr.decode(ot.subarray(e,s));for(s="",l=0;!(l>=r/2);++l){var d=me[e+2*l>>1];if(d==0)break;s+=String.fromCharCode(d)}return s},os=(e,r,s)=>{if(s===void 0&&(s=2147483647),2>s)return 0;s-=2;var l=r;s=s<2*e.length?s/2:e.length;for(var d=0;d<s;++d)me[r>>1]=e.charCodeAt(d),r+=2;return me[r>>1]=0,r-l},ls=e=>2*e.length,hs=(e,r)=>{for(var s=0,l="";!(s>=r/4);){var d=$[e+4*s>>2];if(d==0)break;++s,65536<=d?(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023)):l+=String.fromCharCode(d)}return l},cs=(e,r,s)=>{if(s===void 0&&(s=2147483647),4>s)return 0;var l=r;s=l+s-4;for(var d=0;d<e.length;++d){var m=e.charCodeAt(d);if(55296<=m&&57343>=m){var b=e.charCodeAt(++d);m=65536+((m&1023)<<10)|b&1023}if($[r>>2]=m,r+=4,r+4>s)break}return $[r>>2]=0,r-l},us=e=>{for(var r=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);55296<=l&&57343>=l&&++s,r+=4}return r},ds={};function gi(e){var r=ds[e];return r===void 0?_t(e):r}var vi=[];function Dr(){function e(r){r.$$$embind_global$$$=r;var s=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return s||delete r.$$$embind_global$$$,s}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof lr=="object"&&e(lr)?$$$embind_global$$$=lr:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function fs(e){var r=vi.length;return vi.push(e),r}function ps(e,r){for(var s=Array(e),l=0;l<e;++l)s[l]=Xe(wt[r+4*l>>2],"parameter "+l);return s}var zr=[];function ms(e){var r=Array(e+1);return function(s,l,d){r[0]=s;for(var m=0;m<e;++m){var b=Xe(wt[l+4*m>>2],"parameter "+m);r[m+1]=b.readValueFromPointer(d),d+=b.argPackAdvance}return s=new(s.bind.apply(s,r)),Ht(s)}}var Br={};function gs(e){var r=e.getExtension("ANGLE_instanced_arrays");r&&(e.vertexAttribDivisor=function(s,l){r.vertexAttribDivisorANGLE(s,l)},e.drawArraysInstanced=function(s,l,d,m){r.drawArraysInstancedANGLE(s,l,d,m)},e.drawElementsInstanced=function(s,l,d,m,b){r.drawElementsInstancedANGLE(s,l,d,m,b)})}function vs(e){var r=e.getExtension("OES_vertex_array_object");r&&(e.createVertexArray=function(){return r.createVertexArrayOES()},e.deleteVertexArray=function(s){r.deleteVertexArrayOES(s)},e.bindVertexArray=function(s){r.bindVertexArrayOES(s)},e.isVertexArray=function(s){return r.isVertexArrayOES(s)})}function ys(e){var r=e.getExtension("WEBGL_draw_buffers");r&&(e.drawBuffers=function(s,l){r.drawBuffersWEBGL(s,l)})}var Ur=1,yi=[],te=[],wi=[],Je=[],Kt=[],ee=[],Si=[],le=[],Ce=[],_e=[],Wr={},$r={},Gr=4;function St(e){Pi||(Pi=e)}function Oe(e){for(var r=Ur++,s=e.length;s<r;s++)e[s]=null;return r}function ws(e,r){e.Ge||(e.Ge=e.getContext,e.getContext=function(l,d){return d=e.Ge(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var s=1<r.majorVersion?e.getContext("webgl2",r):e.getContext("webgl",r);return s?Ss(s,r):0}function Ss(e,r){var s=Oe(le),l={handle:s,attributes:r,version:r.majorVersion,fe:e};return e.canvas&&(e.canvas.zf=l),le[s]=l,(typeof r.Nf>"u"||r.Nf)&&Ps(l),s}function jr(e){return it=le[e],h.rg=_=it&&it.fe,!(e&&!_)}function Ps(e){if(e||(e=it),!e.Xf){e.Xf=!0;var r=e.fe;gs(r),vs(r),ys(r),r.pf=r.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),r.uf=r.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(r.qf=r.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!r.qf)&&(r.qf=r.getExtension("EXT_disjoint_timer_query")),r.sg=r.getExtension("WEBGL_multi_draw"),(r.getSupportedExtensions()||[]).forEach(function(s){s.includes("lose_context")||s.includes("debug")||r.getExtension(s)})}}var it,Pi,qi={},Hr=()=>{if(!Xi){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:U||"./this.program"},r;for(r in qi)qi[r]===void 0?delete e[r]:e[r]=qi[r];var s=[];for(r in e)s.push(`${r}=${e[r]}`);Xi=s}return Xi},Xi,bs=[null,[],[]];function Kr(e){_.bindVertexArray(Si[e])}function Vr(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2];_.deleteVertexArray(Si[l]),Si[l]=null}}var bi=[];function Yr(e,r,s,l){_.drawElements(e,r,s,l)}function Ie(e,r,s,l){for(var d=0;d<e;d++){var m=_[s](),b=m&&Oe(l);m?(m.name=b,l[b]=m):St(1282),$[r+4*d>>2]=b}}function qr(e,r){Ie(e,r,"createVertexArray",Si)}function Xr(e,r,s){if(r){var l=void 0;switch(e){case 36346:l=1;break;case 36344:s!=0&&s!=1&&St(1280);return;case 34814:case 36345:l=0;break;case 34466:var d=_.getParameter(34467);l=d?d.length:0;break;case 33309:if(2>it.version){St(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>it.version){St(1280);return}l=e==33307?3:0}if(l===void 0)switch(d=_.getParameter(e),typeof d){case"number":l=d;break;case"boolean":l=d?1:0;break;case"string":St(1280);return;case"object":if(d===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:l=0;break;default:St(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(e=0;e<d.length;++e)switch(s){case 0:$[r+4*e>>2]=d[e];break;case 2:Z[r+4*e>>2]=d[e];break;case 4:se[r+e>>0]=d[e]?1:0}return}try{l=d.name|0}catch(m){St(1280),pe("GL_INVALID_ENUM in glGet"+s+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+m+")");return}}break;default:St(1280),pe("GL_INVALID_ENUM in glGet"+s+"v: Native code calling glGet"+s+"v("+e+") and it returns "+d+" of type "+typeof d+"!");return}switch(s){case 1:s=l,wt[r>>2]=s,wt[r+4>>2]=(s-wt[r>>2])/4294967296;break;case 0:$[r>>2]=l;break;case 2:Z[r>>2]=l;break;case 4:se[r>>0]=l?1:0}}else St(1281)}var Qe=e=>{var r=Zt(e)+1,s=Ei(r);return s&&Qt(e,ot,s,r),s};function Jr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function Ai(e){return e-=5120,e==0?se:e==1?ot:e==2?me:e==4?$:e==6?Z:e==5||e==28922||e==28520||e==30779||e==30782?wt:xe}function Ji(e,r,s,l,d){e=Ai(e);var m=31-Math.clz32(e.BYTES_PER_ELEMENT),b=Gr;return e.subarray(d>>m,d+l*(s*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[r-6402]||1)*(1<<m)+b-1&-b)>>m)}function gt(e){var r=_.Kf;if(r){var s=r.Ne[e];return typeof s=="number"&&(r.Ne[e]=s=_.getUniformLocation(r,r.xf[e]+(0<s?"["+s+"]":""))),s}St(1282)}var ve=[],Ze=[],Ci=e=>e%4===0&&(e%100!==0||e%400===0),Qr=[31,29,31,30,31,30,31,31,30,31,30,31],Zr=[31,28,31,30,31,30,31,31,30,31,30,31];function As(e){var r=Array(Zt(e)+1);return Qt(e,r,0,r.length),r}var Cs=(e,r,s,l)=>{function d(T,Y,nt){for(T=typeof T=="number"?T.toString():T||"";T.length<Y;)T=nt[0]+T;return T}function m(T,Y){return d(T,Y,"0")}function b(T,Y){function nt(Bt){return 0>Bt?-1:0<Bt?1:0}var rt;return(rt=nt(T.getFullYear()-Y.getFullYear()))===0&&(rt=nt(T.getMonth()-Y.getMonth()))===0&&(rt=nt(T.getDate()-Y.getDate())),rt}function v(T){switch(T.getDay()){case 0:return new Date(T.getFullYear()-1,11,29);case 1:return T;case 2:return new Date(T.getFullYear(),0,3);case 3:return new Date(T.getFullYear(),0,2);case 4:return new Date(T.getFullYear(),0,1);case 5:return new Date(T.getFullYear()-1,11,31);case 6:return new Date(T.getFullYear()-1,11,30)}}function y(T){var Y=T.oe;for(T=new Date(new Date(T.pe+1900,0,1).getTime());0<Y;){var nt=T.getMonth(),rt=(Ci(T.getFullYear())?Qr:Zr)[nt];if(Y>rt-T.getDate())Y-=rt-T.getDate()+1,T.setDate(1),11>nt?T.setMonth(nt+1):(T.setMonth(0),T.setFullYear(T.getFullYear()+1));else{T.setDate(T.getDate()+Y);break}}return nt=new Date(T.getFullYear()+1,0,4),Y=v(new Date(T.getFullYear(),0,4)),nt=v(nt),0>=b(Y,T)?0>=b(nt,T)?T.getFullYear()+1:T.getFullYear():T.getFullYear()-1}var A=$[l+40>>2];l={pg:$[l>>2],og:$[l+4>>2],Ze:$[l+8>>2],jf:$[l+12>>2],$e:$[l+16>>2],pe:$[l+20>>2],he:$[l+24>>2],oe:$[l+28>>2],vg:$[l+32>>2],ng:$[l+36>>2],qg:A&&A?be(ot,A):""},s=s?be(ot,s):"",A={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var O in A)s=s.replace(new RegExp(O,"g"),A[O]);var D="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),H="January February March April May June July August September October November December".split(" ");A={"%a":T=>D[T.he].substring(0,3),"%A":T=>D[T.he],"%b":T=>H[T.$e].substring(0,3),"%B":T=>H[T.$e],"%C":T=>m((T.pe+1900)/100|0,2),"%d":T=>m(T.jf,2),"%e":T=>d(T.jf,2," "),"%g":T=>y(T).toString().substring(2),"%G":T=>y(T),"%H":T=>m(T.Ze,2),"%I":T=>(T=T.Ze,T==0?T=12:12<T&&(T-=12),m(T,2)),"%j":T=>{for(var Y=0,nt=0;nt<=T.$e-1;Y+=(Ci(T.pe+1900)?Qr:Zr)[nt++]);return m(T.jf+Y,3)},"%m":T=>m(T.$e+1,2),"%M":T=>m(T.og,2),"%n":()=>`
2
- `,"%p":T=>0<=T.Ze&&12>T.Ze?"AM":"PM","%S":T=>m(T.pg,2),"%t":()=>" ","%u":T=>T.he||7,"%U":T=>m(Math.floor((T.oe+7-T.he)/7),2),"%V":T=>{var Y=Math.floor((T.oe+7-(T.he+6)%7)/7);if(2>=(T.he+371-T.oe-2)%7&&Y++,Y)Y==53&&(nt=(T.he+371-T.oe)%7,nt==4||nt==3&&Ci(T.pe)||(Y=1));else{Y=52;var nt=(T.he+7-T.oe-1)%7;(nt==4||nt==5&&Ci(T.pe%400-1))&&Y++}return m(Y,2)},"%w":T=>T.he,"%W":T=>m(Math.floor((T.oe+7-(T.he+6)%7)/7),2),"%y":T=>(T.pe+1900).toString().substring(2),"%Y":T=>T.pe+1900,"%z":T=>{T=T.ng;var Y=0<=T;return T=Math.abs(T)/60,(Y?"+":"-")+("0000"+(T/60*100+T%60)).slice(-4)},"%Z":T=>T.qg,"%%":()=>"%"},s=s.replace(/%%/g,"\0\0");for(O in A)s.includes(O)&&(s=s.replace(new RegExp(O,"g"),A[O](l)));return s=s.replace(/\0\0/g,"%"),O=As(s),O.length>r?0:(se.set(O,e),O.length-1)};_r=h.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var tn=Array(256),_i=0;256>_i;++_i)tn[_i]=String.fromCharCode(_i);Er=tn,ke=h.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},ge.prototype.isAliasOf=function(e){if(!(this instanceof ge&&e instanceof ge))return!1;var r=this.Jd.Vd.Pd,s=this.Jd.Rd,l=e.Jd.Vd.Pd;for(e=e.Jd.Rd;r.$d;)s=r.Oe(s),r=r.$d;for(;l.$d;)e=l.Oe(e),l=l.$d;return r===l&&s===e},ge.prototype.clone=function(){if(this.Jd.Rd||Ui(this),this.Jd.Me)return this.Jd.count.value+=1,this;var e=Ye,r=Object,s=r.create,l=Object.getPrototypeOf(this),d=this.Jd;return e=e(s.call(r,l,{Jd:{value:{count:d.count,Ee:d.Ee,Me:d.Me,Rd:d.Rd,Vd:d.Vd,Yd:d.Yd,ee:d.ee}}})),e.Jd.count.value+=1,e.Jd.Ee=!1,e},ge.prototype.delete=function(){this.Jd.Rd||Ui(this),this.Jd.Ee&&!this.Jd.Me&&ft("Object already scheduled for deletion"),Tr(this),Fr(this.Jd),this.Jd.Me||(this.Jd.Yd=void 0,this.Jd.Rd=void 0)},ge.prototype.isDeleted=function(){return!this.Jd.Rd},ge.prototype.deleteLater=function(){return this.Jd.Rd||Ui(this),this.Jd.Ee&&!this.Jd.Me&&ft("Object already scheduled for deletion"),He.push(this),He.length===1&&Ke&&Ke($i),this.Jd.Ee=!0,this},h.getInheritedInstanceCount=function(){return Object.keys(Ve).length},h.getLiveInheritedInstances=function(){var e=[],r;for(r in Ve)Ve.hasOwnProperty(r)&&e.push(Ve[r]);return e},h.flushPendingDeletes=$i,h.setDelayFunction=function(e){Ke=e,He.length&&Ke&&Ke($i)},oe.prototype.Sf=function(e){return this.vf&&(e=this.vf(e)),e},oe.prototype.nf=function(e){this.ke&&this.ke(e)},oe.prototype.argPackAdvance=8,oe.prototype.readValueFromPointer=je,oe.prototype.deleteObject=function(e){e!==null&&e.delete()},oe.prototype.fromWireType=function(e){function r(){return this.Ve?fi(this.Pd.Fe,{Vd:this.bg,Rd:s,ee:this,Yd:e}):fi(this.Pd.Fe,{Vd:this,Rd:e})}var s=this.Sf(e);if(!s)return this.nf(e),null;var l=Jn(this.Pd,s);if(l!==void 0)return l.Jd.count.value===0?(l.Jd.Rd=s,l.Jd.Yd=e,l.clone()):(l=l.clone(),this.nf(e),l);if(l=this.Pd.Rf(s),l=xr[l],!l)return r.call(this);l=this.Ue?l.If:l.pointerType;var d=Mr(s,this.Pd,l.Pd);return d===null?r.call(this):this.Ve?fi(l.Pd.Fe,{Vd:l,Rd:d,ee:this,Yd:e}):fi(l.Pd.Fe,{Vd:l,Rd:d})},kr=h.UnboundTypeError=function(e,r){var s=Gi(r,function(l){this.name=r,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
3
- `+l.replace(/^Error(:[^\n]*)?\n/,""))});return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},s}(Error,"UnboundTypeError"),Object.assign(Ir.prototype,{get(e){return this.je[e]},has(e){return this.je[e]!==void 0},Af(e){var r=this.sf.pop()||this.je.length;return this.je[r]=e,r},Bf(e){this.je[e]=void 0,this.sf.push(e)}}),Gt.je.push({value:void 0},{value:null},{value:!0},{value:!1}),Gt.Ge=Gt.je.length,h.count_emval_handles=function(){for(var e=0,r=Gt.Ge;r<Gt.je.length;++r)Gt.je[r]!==void 0&&++e;return e};for(var _,$t=0;32>$t;++$t)bi.push(Array($t));var _s=new Float32Array(288);for($t=0;288>$t;++$t)ve[$t]=_s.subarray(0,$t+1);var Es=new Int32Array(288);for($t=0;288>$t;++$t)Ze[$t]=Es.subarray(0,$t+1);var Ts={T:function(){return 0},Bb:()=>{},Db:function(){return 0},yb:()=>{},zb:()=>{},U:function(){},Ab:()=>{},C:function(e){var r=hi[e];delete hi[e];var s=r.hf,l=r.ke,d=r.rf,m=d.map(b=>b.Vf).concat(d.map(b=>b.fg));Jt([e],m,b=>{var v={};return d.forEach((y,A)=>{var O=b[A],D=y.Tf,H=y.Uf,T=b[A+d.length],Y=y.eg,nt=y.gg;v[y.Of]={read:rt=>O.fromWireType(D(H,rt)),write:(rt,Bt)=>{var Rt=[];Y(nt,rt,T.toWireType(Rt,Bt)),Bi(Rt)}}}),[{name:r.name,fromWireType:function(y){var A={},O;for(O in v)A[O]=v[O].read(y);return l(y),A},toWireType:function(y,A){for(var O in v)if(!(O in A))throw new TypeError(`Missing field: "${O}"`);var D=s();for(O in v)v[O].write(D,A[O]);return y!==null&&y.push(l,D),D},argPackAdvance:8,readValueFromPointer:je,de:l}]})},qb:function(){},Hb:function(e,r,s,l,d){var m=di(s);r=_t(r),ae(e,{name:r,fromWireType:function(b){return!!b},toWireType:function(b,v){return v?l:d},argPackAdvance:8,readValueFromPointer:function(b){if(s===1)var v=se;else if(s===2)v=me;else if(s===4)v=$;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(v[b>>m])},de:null})},m:function(e,r,s,l,d,m,b,v,y,A,O,D,H){O=_t(O),m=Nt(d,m),v&&(v=Nt(b,v)),A&&(A=Nt(y,A)),H=Nt(D,H);var T=Rr(O);Hi(T,function(){qe(`Cannot construct ${O} due to unbound types`,[l])}),Jt([e,r,s],l?[l]:[],function(Y){if(Y=Y[0],l)var nt=Y.Pd,rt=nt.Fe;else rt=ge.prototype;Y=Gi(T,function(){if(Object.getPrototypeOf(this)!==Bt)throw new ke("Use 'new' to construct "+O);if(Rt.ne===void 0)throw new ke(O+" has no accessible constructor");var ei=Rt.ne[arguments.length];if(ei===void 0)throw new ke(`Tried to invoke ctor of ${O} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Rt.ne).toString()}) parameters instead!`);return ei.apply(this,arguments)});var Bt=Object.create(rt,{constructor:{value:Y}});Y.prototype=Bt;var Rt=new Qn(O,Y,Bt,H,nt,m,v,A);Rt.$d&&(Rt.$d.Pe===void 0&&(Rt.$d.Pe=[]),Rt.$d.Pe.push(Rt)),nt=new oe(O,Rt,!0,!1,!1),rt=new oe(O+"*",Rt,!1,!1,!1);var ti=new oe(O+" const*",Rt,!1,!0,!1);return xr[e]={pointerType:rt,If:ti},Nr(T,Y),[nt,rt,ti]})},f:function(e,r,s,l,d,m,b){var v=mi(s,l);r=_t(r),m=Nt(d,m),Jt([],[e],function(y){function A(){qe(`Cannot call ${O} due to unbound types`,v)}y=y[0];var O=`${y.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var D=y.Pd.constructor;return D[r]===void 0?(A.Ce=s-1,D[r]=A):(ji(D,r,O),D[r].Xd[s-1]=A),Jt([],v,function(H){if(H=[H[0],null].concat(H.slice(1)),H=pi(O,H,null,m,b),D[r].Xd===void 0?(H.Ce=s-1,D[r]=H):D[r].Xd[s-1]=H,y.Pd.Pe)for(const T of y.Pd.Pe)T.constructor.hasOwnProperty(r)||(T.constructor[r]=H);return[]}),[]})},A:function(e,r,s,l,d,m){var b=mi(r,s);d=Nt(l,d),Jt([],[e],function(v){v=v[0];var y=`constructor ${v.name}`;if(v.Pd.ne===void 0&&(v.Pd.ne=[]),v.Pd.ne[r-1]!==void 0)throw new ke(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${v.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return v.Pd.ne[r-1]=()=>{qe(`Cannot construct ${v.name} due to unbound types`,b)},Jt([],b,function(A){return A.splice(1,0,null),v.Pd.ne[r-1]=pi(y,A,null,d,m),[]}),[]})},b:function(e,r,s,l,d,m,b,v){var y=mi(s,l);r=_t(r),m=Nt(d,m),Jt([],[e],function(A){function O(){qe(`Cannot call ${D} due to unbound types`,y)}A=A[0];var D=`${A.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),v&&A.Pd.cg.push(r);var H=A.Pd.Fe,T=H[r];return T===void 0||T.Xd===void 0&&T.className!==A.name&&T.Ce===s-2?(O.Ce=s-2,O.className=A.name,H[r]=O):(ji(H,r,D),H[r].Xd[s-2]=O),Jt([],y,function(Y){return Y=pi(D,Y,A,m,b),H[r].Xd===void 0?(Y.Ce=s-2,H[r]=Y):H[r].Xd[s-2]=Y,[]}),[]})},t:function(e,r,s){e=_t(e),Jt([],[r],function(l){return l=l[0],h[e]=l.fromWireType(s),[]})},Gb:function(e,r){r=_t(r),ae(e,{name:r,fromWireType:function(s){var l=jt(s);return Vi(s),l},toWireType:function(s,l){return Ht(l)},argPackAdvance:8,readValueFromPointer:je,de:null})},l:function(e,r,s,l){function d(){}s=di(s),r=_t(r),d.values={},ae(e,{name:r,constructor:d,fromWireType:function(m){return this.constructor.values[m]},toWireType:function(m,b){return b.value},argPackAdvance:8,readValueFromPointer:rs(r,s,l),de:null}),Hi(r,d)},c:function(e,r,s){var l=Xe(e,"enum");r=_t(r),e=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:s},constructor:{value:Gi(`${l.name}_${r}`,function(){})}}),e.values[s]=l,e[r]=l},W:function(e,r,s){s=di(s),r=_t(r),ae(e,{name:r,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:ns(r,s),de:null})},y:function(e,r,s,l,d,m){var b=mi(r,s);e=_t(e),d=Nt(l,d),Hi(e,function(){qe(`Cannot call ${e} due to unbound types`,b)},r-1),Jt([],b,function(v){return v=[v[0],null].concat(v.slice(1)),Nr(e,pi(e,v,null,d,m),r-1),[]})},E:function(e,r,s,l,d){r=_t(r),d===-1&&(d=4294967295),d=di(s);var m=v=>v;if(l===0){var b=32-8*s;m=v=>v<<b>>>b}s=r.includes("unsigned")?function(v,y){return y>>>0}:function(v,y){return y},ae(e,{name:r,fromWireType:m,toWireType:s,argPackAdvance:8,readValueFromPointer:ss(r,d,l!==0),de:null})},s:function(e,r,s){function l(m){m>>=2;var b=wt;return new d(b.buffer,b[m+1],b[m])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][r];s=_t(s),ae(e,{name:s,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{Wf:!0})},q:function(e,r,s,l,d,m,b,v,y,A,O,D){s=_t(s),m=Nt(d,m),v=Nt(b,v),A=Nt(y,A),D=Nt(O,D),Jt([e],[r],function(H){return H=H[0],[new oe(s,H.Pd,!1,!1,!0,H,l,m,v,A,D)]})},V:function(e,r){r=_t(r);var s=r==="std::string";ae(e,{name:r,fromWireType:function(l){var d=wt[l>>2],m=l+4;if(s)for(var b=m,v=0;v<=d;++v){var y=m+v;if(v==d||ot[y]==0){if(b=b?be(ot,b,y-b):"",A===void 0)var A=b;else A+="\0",A+=b;b=y+1}}else{for(A=Array(d),v=0;v<d;++v)A[v]=String.fromCharCode(ot[m+v]);A=A.join("")}return ue(l),A},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var m=typeof d=="string";m||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||ft("Cannot pass non-string to std::string");var b=s&&m?Zt(d):d.length,v=Ei(4+b+1),y=v+4;if(wt[v>>2]=b,s&&m)Qt(d,ot,y,b+1);else if(m)for(m=0;m<b;++m){var A=d.charCodeAt(m);255<A&&(ue(y),ft("String has UTF-16 code units that do not fit in 8 bits")),ot[y+m]=A}else for(m=0;m<b;++m)ot[y+m]=d[m];return l!==null&&l.push(ue,v),v},argPackAdvance:8,readValueFromPointer:je,de:function(l){ue(l)}})},N:function(e,r,s){if(s=_t(s),r===2)var l=as,d=os,m=ls,b=()=>xe,v=1;else r===4&&(l=hs,d=cs,m=us,b=()=>wt,v=2);ae(e,{name:s,fromWireType:function(y){for(var A=wt[y>>2],O=b(),D,H=y+4,T=0;T<=A;++T){var Y=y+4+T*r;(T==A||O[Y>>v]==0)&&(H=l(H,Y-H),D===void 0?D=H:(D+="\0",D+=H),H=Y+r)}return ue(y),D},toWireType:function(y,A){typeof A!="string"&&ft(`Cannot pass non-string to C++ string type ${s}`);var O=m(A),D=Ei(4+O+r);return wt[D>>2]=O>>v,d(A,D+4,O+r),y!==null&&y.push(ue,D),D},argPackAdvance:8,readValueFromPointer:je,de:function(y){ue(y)}})},D:function(e,r,s,l,d,m){hi[e]={name:_t(r),hf:Nt(s,l),ke:Nt(d,m),rf:[]}},e:function(e,r,s,l,d,m,b,v,y,A){hi[e].rf.push({Of:_t(r),Vf:s,Tf:Nt(l,d),Uf:m,fg:b,eg:Nt(v,y),gg:A})},Ib:function(e,r){r=_t(r),ae(e,{Yf:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Fb:()=>!0,ub:()=>{throw 1/0},F:function(e,r,s){e=jt(e),r=Xe(r,"emval::as");var l=[],d=Ht(l);return wt[s>>2]=d,r.toWireType(l,e)},Z:function(e,r,s,l,d){e=vi[e],r=jt(r),s=gi(s);var m=[];return wt[l>>2]=Ht(m),e(r,s,m,d)},w:function(e,r,s,l){e=vi[e],r=jt(r),s=gi(s),e(r,s,null,l)},d:Vi,K:function(e){return e===0?Ht(Dr()):(e=gi(e),Ht(Dr()[e]))},u:function(e,r){var s=ps(e,r),l=s[0];r=l.name+"_$"+s.slice(1).map(function(b){return b.name}).join("_")+"$";var d=zr[r];if(d!==void 0)return d;var m=Array(e-1);return d=fs((b,v,y,A)=>{for(var O=0,D=0;D<e-1;++D)m[D]=s[D+1].readValueFromPointer(A+O),O+=s[D+1].argPackAdvance;for(b=b[v].apply(b,m),D=0;D<e-1;++D)s[D+1].Lf&&s[D+1].Lf(m[D]);if(!l.Yf)return l.toWireType(y,b)}),zr[r]=d},z:function(e,r){return e=jt(e),r=jt(r),Ht(e[r])},p:function(e){4<e&&(Gt.get(e).wf+=1)},J:function(e,r,s,l){e=jt(e);var d=Br[r];return d||(d=ms(r),Br[r]=d),d(e,s,l)},H:function(){return Ht([])},g:function(e){return Ht(gi(e))},G:function(){return Ht({})},kb:function(e){return e=jt(e),!e},B:function(e){var r=jt(e);Bi(r),Vi(e)},i:function(e,r,s){e=jt(e),r=jt(r),s=jt(s),e[r]=s},h:function(e,r){return e=Xe(e,"_emval_take_value"),e=e.readValueFromPointer(r),Ht(e)},nb:function(){return-52},ob:function(){},a:()=>{Di("")},Eb:()=>performance.now(),vb:e=>{var r=ot.length;if(e>>>=0,2147483648<e)return!1;for(var s=1;4>=s;s*=2){var l=r*(1+.2/s);l=Math.min(l,e+100663296);var d=Math;l=Math.max(e,l);t:{d=d.min.call(d,2147483648,l+(65536-l%65536)%65536)-li.buffer.byteLength+65535>>>16;try{li.grow(d),gr();var m=1;break t}catch{}m=void 0}if(m)return!0}return!1},lb:function(){return it?it.handle:0},wb:(e,r)=>{var s=0;return Hr().forEach(function(l,d){var m=r+s;for(d=wt[e+4*d>>2]=m,m=0;m<l.length;++m)se[d++>>0]=l.charCodeAt(m);se[d>>0]=0,s+=l.length+1}),0},xb:(e,r)=>{var s=Hr();wt[e>>2]=s.length;var l=0;return s.forEach(function(d){l+=d.length+1}),wt[r>>2]=l,0},Jb:e=>{Hn||(h.onExit&&h.onExit(e),Li=!0),et(e,new qn(e))},M:()=>52,mb:function(){return 52},Cb:()=>52,pb:function(){return 70},S:(e,r,s,l)=>{for(var d=0,m=0;m<s;m++){var b=wt[r>>2],v=wt[r+4>>2];r+=8;for(var y=0;y<v;y++){var A=ot[b+y],O=bs[e];A===0||A===10?((e===1?jn:pe)(be(O,0)),O.length=0):O.push(A)}d+=v}return wt[l>>2]=d,0},aa:function(e){_.activeTexture(e)},ba:function(e,r){_.attachShader(te[e],ee[r])},ca:function(e,r,s){_.bindAttribLocation(te[e],r,s?be(ot,s):"")},da:function(e,r){e==35051?_.ef=r:e==35052&&(_.De=r),_.bindBuffer(e,yi[r])},$:function(e,r){_.bindFramebuffer(e,wi[r])},fc:function(e,r){_.bindRenderbuffer(e,Je[r])},Rb:function(e,r){_.bindSampler(e,Ce[r])},ea:function(e,r){_.bindTexture(e,Kt[r])},zc:Kr,Cc:Kr,fa:function(e,r,s,l){_.blendColor(e,r,s,l)},ga:function(e){_.blendEquation(e)},ha:function(e,r){_.blendFunc(e,r)},$b:function(e,r,s,l,d,m,b,v,y,A){_.blitFramebuffer(e,r,s,l,d,m,b,v,y,A)},ia:function(e,r,s,l){2<=it.version?s&&r?_.bufferData(e,ot,l,s,r):_.bufferData(e,r,l):_.bufferData(e,s?ot.subarray(s,s+r):r,l)},ja:function(e,r,s,l){2<=it.version?s&&_.bufferSubData(e,r,ot,l,s):_.bufferSubData(e,r,ot.subarray(l,l+s))},gc:function(e){return _.checkFramebufferStatus(e)},Q:function(e){_.clear(e)},_:function(e,r,s,l){_.clearColor(e,r,s,l)},R:function(e){_.clearStencil(e)},sb:function(e,r,s,l){return _.clientWaitSync(_e[e],r,(s>>>0)+4294967296*l)},ka:function(e,r,s,l){_.colorMask(!!e,!!r,!!s,!!l)},la:function(e){_.compileShader(ee[e])},ma:function(e,r,s,l,d,m,b,v){2<=it.version?_.De||!b?_.compressedTexImage2D(e,r,s,l,d,m,b,v):_.compressedTexImage2D(e,r,s,l,d,m,ot,v,b):_.compressedTexImage2D(e,r,s,l,d,m,v?ot.subarray(v,v+b):null)},na:function(e,r,s,l,d,m,b,v,y){2<=it.version?_.De||!v?_.compressedTexSubImage2D(e,r,s,l,d,m,b,v,y):_.compressedTexSubImage2D(e,r,s,l,d,m,b,ot,y,v):_.compressedTexSubImage2D(e,r,s,l,d,m,b,y?ot.subarray(y,y+v):null)},Zb:function(e,r,s,l,d){_.copyBufferSubData(e,r,s,l,d)},oa:function(e,r,s,l,d,m,b,v){_.copyTexSubImage2D(e,r,s,l,d,m,b,v)},pa:function(){var e=Oe(te),r=_.createProgram();return r.name=e,r.Ye=r.We=r.Xe=0,r.kf=1,te[e]=r,e},qa:function(e){var r=Oe(ee);return ee[r]=_.createShader(e),r},ra:function(e){_.cullFace(e)},sa:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=yi[l];d&&(_.deleteBuffer(d),d.name=0,yi[l]=null,l==_.ef&&(_.ef=0),l==_.De&&(_.De=0))}},hc:function(e,r){for(var s=0;s<e;++s){var l=$[r+4*s>>2],d=wi[l];d&&(_.deleteFramebuffer(d),d.name=0,wi[l]=null)}},ta:function(e){if(e){var r=te[e];r?(_.deleteProgram(r),r.name=0,te[e]=null):St(1281)}},ic:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Je[l];d&&(_.deleteRenderbuffer(d),d.name=0,Je[l]=null)}},Sb:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Ce[l];d&&(_.deleteSampler(d),d.name=0,Ce[l]=null)}},ua:function(e){if(e){var r=ee[e];r?(_.deleteShader(r),ee[e]=null):St(1281)}},_b:function(e){if(e){var r=_e[e];r?(_.deleteSync(r),r.name=0,_e[e]=null):St(1281)}},va:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Kt[l];d&&(_.deleteTexture(d),d.name=0,Kt[l]=null)}},Ac:Vr,Dc:Vr,wa:function(e){_.depthMask(!!e)},xa:function(e){_.disable(e)},ya:function(e){_.disableVertexAttribArray(e)},za:function(e,r,s){_.drawArrays(e,r,s)},xc:function(e,r,s,l){_.drawArraysInstanced(e,r,s,l)},vc:function(e,r,s,l,d){_.pf.drawArraysInstancedBaseInstanceWEBGL(e,r,s,l,d)},tc:function(e,r){for(var s=bi[e],l=0;l<e;l++)s[l]=$[r+4*l>>2];_.drawBuffers(s)},Aa:Yr,yc:function(e,r,s,l,d){_.drawElementsInstanced(e,r,s,l,d)},wc:function(e,r,s,l,d,m,b){_.pf.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,r,s,l,d,m,b)},nc:function(e,r,s,l,d,m){Yr(e,l,d,m)},Ba:function(e){_.enable(e)},Ca:function(e){_.enableVertexAttribArray(e)},Xb:function(e,r){return(e=_.fenceSync(e,r))?(r=Oe(_e),e.name=r,_e[r]=e,r):0},Da:function(){_.finish()},Ea:function(){_.flush()},jc:function(e,r,s,l){_.framebufferRenderbuffer(e,r,s,Je[l])},kc:function(e,r,s,l,d){_.framebufferTexture2D(e,r,s,Kt[l],d)},Fa:function(e){_.frontFace(e)},Ga:function(e,r){Ie(e,r,"createBuffer",yi)},lc:function(e,r){Ie(e,r,"createFramebuffer",wi)},mc:function(e,r){Ie(e,r,"createRenderbuffer",Je)},Tb:function(e,r){Ie(e,r,"createSampler",Ce)},Ha:function(e,r){Ie(e,r,"createTexture",Kt)},Bc:qr,Ec:qr,bc:function(e){_.generateMipmap(e)},Ia:function(e,r,s){s?$[s>>2]=_.getBufferParameter(e,r):St(1281)},Ja:function(){var e=_.getError()||Pi;return Pi=0,e},Ka:function(e,r){Xr(e,r,2)},cc:function(e,r,s,l){e=_.getFramebufferAttachmentParameter(e,r,s),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),$[l>>2]=e},L:function(e,r){Xr(e,r,0)},La:function(e,r,s,l){e=_.getProgramInfoLog(te[e]),e===null&&(e="(unknown error)"),r=0<r&&l?Qt(e,ot,l,r):0,s&&($[s>>2]=r)},Ma:function(e,r,s){if(s)if(e>=Ur)St(1281);else if(e=te[e],r==35716)e=_.getProgramInfoLog(e),e===null&&(e="(unknown error)"),$[s>>2]=e.length+1;else if(r==35719){if(!e.Ye)for(r=0;r<_.getProgramParameter(e,35718);++r)e.Ye=Math.max(e.Ye,_.getActiveUniform(e,r).name.length+1);$[s>>2]=e.Ye}else if(r==35722){if(!e.We)for(r=0;r<_.getProgramParameter(e,35721);++r)e.We=Math.max(e.We,_.getActiveAttrib(e,r).name.length+1);$[s>>2]=e.We}else if(r==35381){if(!e.Xe)for(r=0;r<_.getProgramParameter(e,35382);++r)e.Xe=Math.max(e.Xe,_.getActiveUniformBlockName(e,r).length+1);$[s>>2]=e.Xe}else $[s>>2]=_.getProgramParameter(e,r);else St(1281)},dc:function(e,r,s){s?$[s>>2]=_.getRenderbufferParameter(e,r):St(1281)},Na:function(e,r,s,l){e=_.getShaderInfoLog(ee[e]),e===null&&(e="(unknown error)"),r=0<r&&l?Qt(e,ot,l,r):0,s&&($[s>>2]=r)},Ob:function(e,r,s,l){e=_.getShaderPrecisionFormat(e,r),$[s>>2]=e.rangeMin,$[s+4>>2]=e.rangeMax,$[l>>2]=e.precision},Oa:function(e,r,s){s?r==35716?(e=_.getShaderInfoLog(ee[e]),e===null&&(e="(unknown error)"),$[s>>2]=e?e.length+1:0):r==35720?(e=_.getShaderSource(ee[e]),$[s>>2]=e?e.length+1:0):$[s>>2]=_.getShaderParameter(ee[e],r):St(1281)},P:function(e){var r=Wr[e];if(!r){switch(e){case 7939:r=_.getSupportedExtensions()||[],r=r.concat(r.map(function(l){return"GL_"+l})),r=Qe(r.join(" "));break;case 7936:case 7937:case 37445:case 37446:(r=_.getParameter(e))||St(1280),r=r&&Qe(r);break;case 7938:r=_.getParameter(7938),r=2<=it.version?"OpenGL ES 3.0 ("+r+")":"OpenGL ES 2.0 ("+r+")",r=Qe(r);break;case 35724:r=_.getParameter(35724);var s=r.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);s!==null&&(s[1].length==3&&(s[1]+="0"),r="OpenGL ES GLSL ES "+s[1]+" ("+r+")"),r=Qe(r);break;default:St(1280)}Wr[e]=r}return r},jb:function(e,r){if(2>it.version)return St(1282),0;var s=$r[e];if(s)return 0>r||r>=s.length?(St(1281),0):s[r];switch(e){case 7939:return s=_.getSupportedExtensions()||[],s=s.concat(s.map(function(l){return"GL_"+l})),s=s.map(function(l){return Qe(l)}),s=$r[e]=s,0>r||r>=s.length?(St(1281),0):s[r];default:return St(1280),0}},Pa:function(e,r){if(r=r?be(ot,r):"",e=te[e]){var s=e,l=s.Ne,d=s.yf,m;if(!l)for(s.Ne=l={},s.xf={},m=0;m<_.getProgramParameter(s,35718);++m){var b=_.getActiveUniform(s,m),v=b.name;b=b.size;var y=Jr(v);y=0<y?v.slice(0,y):v;var A=s.kf;for(s.kf+=b,d[y]=[b,A],v=0;v<b;++v)l[A]=v,s.xf[A++]=y}if(s=e.Ne,l=0,d=r,m=Jr(r),0<m&&(l=parseInt(r.slice(m+1))>>>0,d=r.slice(0,m)),(d=e.yf[d])&&l<d[0]&&(l+=d[1],s[l]=s[l]||_.getUniformLocation(e,r)))return l}else St(1281);return-1},Pb:function(e,r,s){for(var l=bi[r],d=0;d<r;d++)l[d]=$[s+4*d>>2];_.invalidateFramebuffer(e,l)},Qb:function(e,r,s,l,d,m,b){for(var v=bi[r],y=0;y<r;y++)v[y]=$[s+4*y>>2];_.invalidateSubFramebuffer(e,v,l,d,m,b)},Yb:function(e){return _.isSync(_e[e])},Qa:function(e){return(e=Kt[e])?_.isTexture(e):0},Ra:function(e){_.lineWidth(e)},Sa:function(e){e=te[e],_.linkProgram(e),e.Ne=0,e.yf={}},rc:function(e,r,s,l,d,m){_.uf.multiDrawArraysInstancedBaseInstanceWEBGL(e,$,r>>2,$,s>>2,$,l>>2,wt,d>>2,m)},sc:function(e,r,s,l,d,m,b,v){_.uf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,$,r>>2,s,$,l>>2,$,d>>2,$,m>>2,wt,b>>2,v)},Ta:function(e,r){e==3317&&(Gr=r),_.pixelStorei(e,r)},uc:function(e){_.readBuffer(e)},Ua:function(e,r,s,l,d,m,b){if(2<=it.version)if(_.ef)_.readPixels(e,r,s,l,d,m,b);else{var v=Ai(m);_.readPixels(e,r,s,l,d,m,v,b>>31-Math.clz32(v.BYTES_PER_ELEMENT))}else(b=Ji(m,d,s,l,b))?_.readPixels(e,r,s,l,d,m,b):St(1280)},ec:function(e,r,s,l){_.renderbufferStorage(e,r,s,l)},ac:function(e,r,s,l,d){_.renderbufferStorageMultisample(e,r,s,l,d)},Ub:function(e,r,s){_.samplerParameterf(Ce[e],r,s)},Vb:function(e,r,s){_.samplerParameteri(Ce[e],r,s)},Wb:function(e,r,s){_.samplerParameteri(Ce[e],r,$[s>>2])},Va:function(e,r,s,l){_.scissor(e,r,s,l)},Wa:function(e,r,s,l){for(var d="",m=0;m<r;++m){var b=l?$[l+4*m>>2]:-1,v=$[s+4*m>>2];b=v?be(ot,v,0>b?void 0:b):"",d+=b}_.shaderSource(ee[e],d)},Xa:function(e,r,s){_.stencilFunc(e,r,s)},Ya:function(e,r,s,l){_.stencilFuncSeparate(e,r,s,l)},Za:function(e){_.stencilMask(e)},_a:function(e,r){_.stencilMaskSeparate(e,r)},$a:function(e,r,s){_.stencilOp(e,r,s)},ab:function(e,r,s,l){_.stencilOpSeparate(e,r,s,l)},bb:function(e,r,s,l,d,m,b,v,y){if(2<=it.version)if(_.De)_.texImage2D(e,r,s,l,d,m,b,v,y);else if(y){var A=Ai(v);_.texImage2D(e,r,s,l,d,m,b,v,A,y>>31-Math.clz32(A.BYTES_PER_ELEMENT))}else _.texImage2D(e,r,s,l,d,m,b,v,null);else _.texImage2D(e,r,s,l,d,m,b,v,y?Ji(v,b,l,d,y):null)},cb:function(e,r,s){_.texParameterf(e,r,s)},db:function(e,r,s){_.texParameterf(e,r,Z[s>>2])},eb:function(e,r,s){_.texParameteri(e,r,s)},fb:function(e,r,s){_.texParameteri(e,r,$[s>>2])},oc:function(e,r,s,l,d){_.texStorage2D(e,r,s,l,d)},gb:function(e,r,s,l,d,m,b,v,y){if(2<=it.version)if(_.De)_.texSubImage2D(e,r,s,l,d,m,b,v,y);else if(y){var A=Ai(v);_.texSubImage2D(e,r,s,l,d,m,b,v,A,y>>31-Math.clz32(A.BYTES_PER_ELEMENT))}else _.texSubImage2D(e,r,s,l,d,m,b,v,null);else A=null,y&&(A=Ji(v,b,d,m,y)),_.texSubImage2D(e,r,s,l,d,m,b,v,A)},hb:function(e,r){_.uniform1f(gt(e),r)},ib:function(e,r,s){if(2<=it.version)r&&_.uniform1fv(gt(e),Z,s>>2,r);else{if(288>=r)for(var l=ve[r-1],d=0;d<r;++d)l[d]=Z[s+4*d>>2];else l=Z.subarray(s>>2,s+4*r>>2);_.uniform1fv(gt(e),l)}},Zc:function(e,r){_.uniform1i(gt(e),r)},_c:function(e,r,s){if(2<=it.version)r&&_.uniform1iv(gt(e),$,s>>2,r);else{if(288>=r)for(var l=Ze[r-1],d=0;d<r;++d)l[d]=$[s+4*d>>2];else l=$.subarray(s>>2,s+4*r>>2);_.uniform1iv(gt(e),l)}},$c:function(e,r,s){_.uniform2f(gt(e),r,s)},ad:function(e,r,s){if(2<=it.version)r&&_.uniform2fv(gt(e),Z,s>>2,2*r);else{if(144>=r)for(var l=ve[2*r-1],d=0;d<2*r;d+=2)l[d]=Z[s+4*d>>2],l[d+1]=Z[s+(4*d+4)>>2];else l=Z.subarray(s>>2,s+8*r>>2);_.uniform2fv(gt(e),l)}},Yc:function(e,r,s){_.uniform2i(gt(e),r,s)},Xc:function(e,r,s){if(2<=it.version)r&&_.uniform2iv(gt(e),$,s>>2,2*r);else{if(144>=r)for(var l=Ze[2*r-1],d=0;d<2*r;d+=2)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2];else l=$.subarray(s>>2,s+8*r>>2);_.uniform2iv(gt(e),l)}},Wc:function(e,r,s,l){_.uniform3f(gt(e),r,s,l)},Vc:function(e,r,s){if(2<=it.version)r&&_.uniform3fv(gt(e),Z,s>>2,3*r);else{if(96>=r)for(var l=ve[3*r-1],d=0;d<3*r;d+=3)l[d]=Z[s+4*d>>2],l[d+1]=Z[s+(4*d+4)>>2],l[d+2]=Z[s+(4*d+8)>>2];else l=Z.subarray(s>>2,s+12*r>>2);_.uniform3fv(gt(e),l)}},Uc:function(e,r,s,l){_.uniform3i(gt(e),r,s,l)},Tc:function(e,r,s){if(2<=it.version)r&&_.uniform3iv(gt(e),$,s>>2,3*r);else{if(96>=r)for(var l=Ze[3*r-1],d=0;d<3*r;d+=3)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2],l[d+2]=$[s+(4*d+8)>>2];else l=$.subarray(s>>2,s+12*r>>2);_.uniform3iv(gt(e),l)}},Sc:function(e,r,s,l,d){_.uniform4f(gt(e),r,s,l,d)},Rc:function(e,r,s){if(2<=it.version)r&&_.uniform4fv(gt(e),Z,s>>2,4*r);else{if(72>=r){var l=ve[4*r-1],d=Z;s>>=2;for(var m=0;m<4*r;m+=4){var b=s+m;l[m]=d[b],l[m+1]=d[b+1],l[m+2]=d[b+2],l[m+3]=d[b+3]}}else l=Z.subarray(s>>2,s+16*r>>2);_.uniform4fv(gt(e),l)}},Fc:function(e,r,s,l,d){_.uniform4i(gt(e),r,s,l,d)},Gc:function(e,r,s){if(2<=it.version)r&&_.uniform4iv(gt(e),$,s>>2,4*r);else{if(72>=r)for(var l=Ze[4*r-1],d=0;d<4*r;d+=4)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2],l[d+2]=$[s+(4*d+8)>>2],l[d+3]=$[s+(4*d+12)>>2];else l=$.subarray(s>>2,s+16*r>>2);_.uniform4iv(gt(e),l)}},Hc:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix2fv(gt(e),!!s,Z,l>>2,4*r);else{if(72>=r)for(var d=ve[4*r-1],m=0;m<4*r;m+=4)d[m]=Z[l+4*m>>2],d[m+1]=Z[l+(4*m+4)>>2],d[m+2]=Z[l+(4*m+8)>>2],d[m+3]=Z[l+(4*m+12)>>2];else d=Z.subarray(l>>2,l+16*r>>2);_.uniformMatrix2fv(gt(e),!!s,d)}},Ic:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix3fv(gt(e),!!s,Z,l>>2,9*r);else{if(32>=r)for(var d=ve[9*r-1],m=0;m<9*r;m+=9)d[m]=Z[l+4*m>>2],d[m+1]=Z[l+(4*m+4)>>2],d[m+2]=Z[l+(4*m+8)>>2],d[m+3]=Z[l+(4*m+12)>>2],d[m+4]=Z[l+(4*m+16)>>2],d[m+5]=Z[l+(4*m+20)>>2],d[m+6]=Z[l+(4*m+24)>>2],d[m+7]=Z[l+(4*m+28)>>2],d[m+8]=Z[l+(4*m+32)>>2];else d=Z.subarray(l>>2,l+36*r>>2);_.uniformMatrix3fv(gt(e),!!s,d)}},Jc:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix4fv(gt(e),!!s,Z,l>>2,16*r);else{if(18>=r){var d=ve[16*r-1],m=Z;l>>=2;for(var b=0;b<16*r;b+=16){var v=l+b;d[b]=m[v],d[b+1]=m[v+1],d[b+2]=m[v+2],d[b+3]=m[v+3],d[b+4]=m[v+4],d[b+5]=m[v+5],d[b+6]=m[v+6],d[b+7]=m[v+7],d[b+8]=m[v+8],d[b+9]=m[v+9],d[b+10]=m[v+10],d[b+11]=m[v+11],d[b+12]=m[v+12],d[b+13]=m[v+13],d[b+14]=m[v+14],d[b+15]=m[v+15]}}else d=Z.subarray(l>>2,l+64*r>>2);_.uniformMatrix4fv(gt(e),!!s,d)}},Kc:function(e){e=te[e],_.useProgram(e),_.Kf=e},Lc:function(e,r){_.vertexAttrib1f(e,r)},Mc:function(e,r){_.vertexAttrib2f(e,Z[r>>2],Z[r+4>>2])},Nc:function(e,r){_.vertexAttrib3f(e,Z[r>>2],Z[r+4>>2],Z[r+8>>2])},Oc:function(e,r){_.vertexAttrib4f(e,Z[r>>2],Z[r+4>>2],Z[r+8>>2],Z[r+12>>2])},pc:function(e,r){_.vertexAttribDivisor(e,r)},qc:function(e,r,s,l,d){_.vertexAttribIPointer(e,r,s,l,d)},Pc:function(e,r,s,l,d,m){_.vertexAttribPointer(e,r,s,!!l,d,m)},Qc:function(e,r,s,l){_.viewport(e,r,s,l)},rb:function(e,r,s,l){_.waitSync(_e[e],r,(s>>>0)+4294967296*l)},j:Ms,n:Ls,k:Fs,I:zs,Lb:Bs,Y:Us,X:$s,O:ks,o:Is,x:Ns,r:Rs,v:Os,Kb:Ws,Mb:Ds,Nb:xs,tb:(e,r,s,l)=>Cs(e,r,s,l)};(function(){function e(s){if(lt=s=s.exports,li=lt.bd,gr(),Mt=lt.dd,yr.unshift(lt.cd),Pe--,h.monitorRunDependencies&&h.monitorRunDependencies(Pe),Pe==0&&Ge){var l=Ge;Ge=null,l()}return s}var r={a:Ts};if(Pe++,h.monitorRunDependencies&&h.monitorRunDependencies(Pe),h.instantiateWasm)try{return h.instantiateWasm(r,e)}catch(s){pe("Module.instantiateWasm callback failed with error: "+s),F(s)}return Yn(r,function(s){e(s.instance)}).catch(F),{}})();var ue=h._free=e=>(ue=h._free=lt.ed)(e),Ei=h._malloc=e=>(Ei=h._malloc=lt.fd)(e),en=e=>(en=lt.gd)(e);h.__embind_initialize_bindings=()=>(h.__embind_initialize_bindings=lt.hd)();var kt=(e,r)=>(kt=lt.id)(e,r),Ot=()=>(Ot=lt.jd)(),It=e=>(It=lt.kd)(e);h.dynCall_viji=(e,r,s,l,d)=>(h.dynCall_viji=lt.ld)(e,r,s,l,d),h.dynCall_vijiii=(e,r,s,l,d,m,b)=>(h.dynCall_vijiii=lt.md)(e,r,s,l,d,m,b),h.dynCall_viiiiij=(e,r,s,l,d,m,b,v)=>(h.dynCall_viiiiij=lt.nd)(e,r,s,l,d,m,b,v),h.dynCall_jiiiijiiiii=(e,r,s,l,d,m,b,v,y,A,O,D)=>(h.dynCall_jiiiijiiiii=lt.od)(e,r,s,l,d,m,b,v,y,A,O,D),h.dynCall_viiij=(e,r,s,l,d,m)=>(h.dynCall_viiij=lt.pd)(e,r,s,l,d,m),h.dynCall_jii=(e,r,s)=>(h.dynCall_jii=lt.qd)(e,r,s),h.dynCall_vij=(e,r,s,l)=>(h.dynCall_vij=lt.rd)(e,r,s,l),h.dynCall_iiij=(e,r,s,l,d)=>(h.dynCall_iiij=lt.sd)(e,r,s,l,d),h.dynCall_iiiij=(e,r,s,l,d,m)=>(h.dynCall_iiiij=lt.td)(e,r,s,l,d,m),h.dynCall_viij=(e,r,s,l,d)=>(h.dynCall_viij=lt.ud)(e,r,s,l,d),h.dynCall_ji=(e,r)=>(h.dynCall_ji=lt.vd)(e,r),h.dynCall_iij=(e,r,s,l)=>(h.dynCall_iij=lt.wd)(e,r,s,l),h.dynCall_jiiiiii=(e,r,s,l,d,m,b)=>(h.dynCall_jiiiiii=lt.xd)(e,r,s,l,d,m,b),h.dynCall_jiiiiji=(e,r,s,l,d,m,b,v)=>(h.dynCall_jiiiiji=lt.yd)(e,r,s,l,d,m,b,v),h.dynCall_iijj=(e,r,s,l,d,m)=>(h.dynCall_iijj=lt.zd)(e,r,s,l,d,m),h.dynCall_iiiji=(e,r,s,l,d,m)=>(h.dynCall_iiiji=lt.Ad)(e,r,s,l,d,m),h.dynCall_iiji=(e,r,s,l,d)=>(h.dynCall_iiji=lt.Bd)(e,r,s,l,d),h.dynCall_iijjiii=(e,r,s,l,d,m,b,v,y)=>(h.dynCall_iijjiii=lt.Cd)(e,r,s,l,d,m,b,v,y),h.dynCall_vijjjii=(e,r,s,l,d,m,b,v,y,A)=>(h.dynCall_vijjjii=lt.Dd)(e,r,s,l,d,m,b,v,y,A),h.dynCall_jiji=(e,r,s,l,d)=>(h.dynCall_jiji=lt.Ed)(e,r,s,l,d),h.dynCall_viijii=(e,r,s,l,d,m,b)=>(h.dynCall_viijii=lt.Fd)(e,r,s,l,d,m,b),h.dynCall_iiiiij=(e,r,s,l,d,m,b)=>(h.dynCall_iiiiij=lt.Gd)(e,r,s,l,d,m,b),h.dynCall_iiiiijj=(e,r,s,l,d,m,b,v,y)=>(h.dynCall_iiiiijj=lt.Hd)(e,r,s,l,d,m,b,v,y),h.dynCall_iiiiiijj=(e,r,s,l,d,m,b,v,y,A)=>(h.dynCall_iiiiiijj=lt.Id)(e,r,s,l,d,m,b,v,y,A);function Fs(e,r,s,l){var d=Ot();try{return Mt.get(e)(r,s,l)}catch(m){if(It(d),m!==m+0)throw m;kt(1,0)}}function Ms(e,r){var s=Ot();try{return Mt.get(e)(r)}catch(l){if(It(s),l!==l+0)throw l;kt(1,0)}}function xs(e,r,s,l,d,m,b,v,y,A){var O=Ot();try{Mt.get(e)(r,s,l,d,m,b,v,y,A)}catch(D){if(It(O),D!==D+0)throw D;kt(1,0)}}function Rs(e,r,s,l){var d=Ot();try{Mt.get(e)(r,s,l)}catch(m){if(It(d),m!==m+0)throw m;kt(1,0)}}function Ns(e,r,s){var l=Ot();try{Mt.get(e)(r,s)}catch(d){if(It(l),d!==d+0)throw d;kt(1,0)}}function ks(e){var r=Ot();try{Mt.get(e)()}catch(s){if(It(r),s!==s+0)throw s;kt(1,0)}}function Os(e,r,s,l,d){var m=Ot();try{Mt.get(e)(r,s,l,d)}catch(b){if(It(m),b!==b+0)throw b;kt(1,0)}}function Is(e,r){var s=Ot();try{Mt.get(e)(r)}catch(l){if(It(s),l!==l+0)throw l;kt(1,0)}}function Ls(e,r,s){var l=Ot();try{return Mt.get(e)(r,s)}catch(d){if(It(l),d!==d+0)throw d;kt(1,0)}}function Ds(e,r,s,l,d,m,b){var v=Ot();try{Mt.get(e)(r,s,l,d,m,b)}catch(y){if(It(v),y!==y+0)throw y;kt(1,0)}}function zs(e,r,s,l,d){var m=Ot();try{return Mt.get(e)(r,s,l,d)}catch(b){if(It(m),b!==b+0)throw b;kt(1,0)}}function Bs(e,r,s,l,d,m){var b=Ot();try{return Mt.get(e)(r,s,l,d,m)}catch(v){if(It(b),v!==v+0)throw v;kt(1,0)}}function Us(e,r,s,l,d,m,b){var v=Ot();try{return Mt.get(e)(r,s,l,d,m,b)}catch(y){if(It(v),y!==y+0)throw y;kt(1,0)}}function Ws(e,r,s,l,d,m){var b=Ot();try{Mt.get(e)(r,s,l,d,m)}catch(v){if(It(b),v!==v+0)throw v;kt(1,0)}}function $s(e,r,s,l,d,m,b,v,y,A){var O=Ot();try{return Mt.get(e)(r,s,l,d,m,b,v,y,A)}catch(D){if(It(O),D!==D+0)throw D;kt(1,0)}}var Ti;Ge=function e(){Ti||rn(),Ti||(Ge=e)};function rn(){function e(){if(!Ti&&(Ti=!0,h.calledRun=!0,!Li)){if(zi(yr),C(h),h.onRuntimeInitialized&&h.onRuntimeInitialized(),h.postRun)for(typeof h.postRun=="function"&&(h.postRun=[h.postRun]);h.postRun.length;){var r=h.postRun.shift();wr.unshift(r)}zi(wr)}}if(!(0<Pe)){if(h.preRun)for(typeof h.preRun=="function"&&(h.preRun=[h.preRun]);h.preRun.length;)Kn();zi(vr),0<Pe||(h.setStatus?(h.setStatus("Running..."),setTimeout(function(){setTimeout(function(){h.setStatus("")},1),e()},1)):e())}}if(h.preInit)for(typeof h.preInit=="function"&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.pop()();return rn(),u.ready}})();g.exports=i})(Tn);var oa=Tn.exports,la=Qs(oa);class Be{static slide(t){let i=Te.linear;return typeof t.easing=="string"?i=Te.fromTypeAsString(t.easing):t.easing!==void 0&&(i=t.easing),new Dn(t.direction,t.duration,i)}static none(){return new Ln}}class Ln extends Be{constructor(){super(),this.type=de.None,this.duration=NaN,this.easing=Te.none}}class Dn extends Be{constructor(t,i,n){super(),this.type=de.Slide,this.direction=t,this.duration=i,this.easing=n}}const de={Slide:"Slide",None:"None"},fe={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class zn{constructor(t,i){this.scene=t,this.transition=i}}const Bn={type:"object",description:"Information about the user's device.",properties:{userAgent:{type:"string",description:"The user agent string returned by navigator.userAgent."},devicePixelRatio:{type:"number",description:"Ratio of physical pixels to CSS pixels."},screen:{type:"object",description:"Screen information returned by window.screen.",properties:{availHeight:{type:"number",description:"Height of screen, in pixels, excluding UI features."},availWidth:{type:"number",description:"Width of screen, in pixels, excluding UI features."},colorDepth:{type:"number",description:"Color depth of screen."},height:{type:"number",description:"Height of screen, in pixels"},width:{type:"number",description:"Width of screen, in pixels."},orientation:{type:"object",description:"Information about the device's orientation.",properties:{type:{type:"string",description:"The orientation type (ScreenOrientation.type)."},angle:{type:"number",description:"The orientation angle (ScreenOrientation.angle)."}}},pixelDepth:{type:"number",description:"Pixel depth of screen."}}},webGlRenderer:{type:"string",description:"WebGL driver vendor and renderer. Taken from WEBGL_debug_renderer_info."}}};class fr{static getRendererString(){const t=document.createElement("canvas");t.id="webgl-renderer-info-canvas",t.height=0,t.width=0,t.hidden=!0,document.body.appendChild(t);const i=t.getContext("webgl");let n="no webgl context";if(!i)return n;const u=i.getExtension("WEBGL_debug_renderer_info");return u!=null?n=String(i.getParameter(u.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(u.UNMASKED_RENDERER_WEBGL)):n="no debug renderer info",t.remove(),n}static dispose(){const t=document.getElementById("webgl-renderer-info-canvas");t&&t.remove()}}class Un{constructor(t,i){this.sounds={},this.game=t,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new Error("AudioContext cannot be created until user has interacted with the page");this._audioContext=new AudioContext}return this._audioContext}initializeSounds(t){return t?this.loadSounds(t):Promise.resolve()}loadSounds(t){return t.length===0?Promise.resolve():(t.forEach(i=>{let n=i.url;q.urlHasScheme(i.url)||(n=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const u={soundName:i.soundName,data:void 0,audioBuffer:void 0,url:n,status:i.lazy?zt.Deferred:zt.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=u}),this.fetchSounds())}async fetchSounds(){const t=Object.values(this.sounds).map(i=>i.status===zt.WillFetch?(i.status=zt.Fetching,fetch(i.url).then(n=>{if(!n.ok)throw i.status=zt.Error,new Error(`cannot fetch sound ${i.soundName} at url ${i.url}: ${n.statusText}`);return n.arrayBuffer().then(u=>{i.data=u,i.status=zt.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${u.byteLength}`)})})):Promise.resolve());await Promise.all(t)}fetchDeferredSound(t){return t.status=zt.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(t=>t.status===zt.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(n=>n.status===zt.Fetched).map(n=>this.decodeSound(n));return Promise.all(i)}async decodeSound(t){if(!t.data)throw new Error(`data is undefined for sound ${t.soundName} (url ${t.url})`);try{t.status=zt.Decoding;const i=await this.audioContext.decodeAudioData(t.data);t.audioBuffer=i,t.status=zt.Ready,console.log(`\u26AA sound decoded. name: ${t.soundName}, duration (seconds): ${i.duration}`)}catch{throw t.status=zt.Error,new Error(`error decoding sound ${t.soundName} (url: ${t.url})`)}}getSound(t){const i=this.sounds[t];if(!i)throw new Error(`getSound(): sound ${t} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class ha{constructor(t){this.game=t.game,this.nodeFactory=t.nodeFactory,this.freeNodesScene=t.freeNodesScene,this.configureI18n=t.configureI18n,this.eventMaterializers=new Map([[G.NodeNew,this.materializeNodeNewEvent.bind(this)],[G.Composite,this.materializeCompositeEvent.bind(this)],[G.ScenePresent,this.materializeScenePresentEvent.bind(this)],[G.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[G.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[G.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[G.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[G.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[G.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(t){t.length>0&&(console.log(`Replaying ${t.length} events`),t.forEach(i=>{const n=this.eventMaterializers.get(i.type);n?n(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(t){const i=this.game.materializedNodes.find(n=>n.uuid===t.target);if(!i)console.log(`EventMaterializer: composite node of type ${t.compositeType} with uuid ${t.target} not found when handling CompositeEvent ${t.compositeEventType}`);else if(console.log("calling handleCompositeEvent on composite node"),i.type===at.Composite)i.handleCompositeEvent(t);else throw new Error(`EventMaterializer: node was expected to be composite, but was of type ${i.type}`)}materializeNodeNewEvent(t){const i=this.nodeFactory.createNode(t.nodeType,t.compositeType,t.nodeOptions);i.type===at.Scene&&(i.name===X.FREE_NODES_SCENE_NAME?(this.freeNodesScene=i,this.freeNodesScene.game=this.game,this.freeNodesScene.needsInitialization=!0,this.game.freeNodesScene=this.freeNodesScene):this.game.addScene(i)),this.game.materializedNodes.push(i)}materializeNodePropertyChangeEvent(t){const i=this.game.materializedNodes.find(n=>n.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: node with uuid ${t.uuid} not found`);if(t.property in i)i[t.property]=t.value;else throw new Error(`EventMaterializer: on node ${i.name}, type ${i.type}, nodePropertyChangeEvent tried to set unknown property ${t.property} to value ${JSON.stringify(t.value)}`)}materializeNodeAddChildEvent(t){const i=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const n=this.game.materializedNodes.find(u=>u.uuid===t.childUuid);if(!n)throw new Error(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.addChild(n)}materializeNodeRemoveChildEvent(t){const i=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const n=this.game.materializedNodes.find(u=>u.uuid===t.childUuid);if(!n)throw new Error(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.removeChild(n)}materializeDomPointerDownEvent(t){this.game.currentScene?.run(V.custom({callback:()=>{const i=new ai({circleOfRadius:16,fillColor:x.LightGray,strokeColor:x.Black,lineWidth:2,alpha:.75,position:{x:t.x,y:t.y}});this.game.currentScene?.addChild(i),i.run(V.sequence([V.group([V.fadeAlpha({duration:750,alpha:0}),V.scale({duration:750,scale:0})]),V.custom({callback:()=>{this.game.currentScene?.removeChild(i)}})]))}}))}materializeBrowserImageDataReadyEvent(t){this.game.imageManager.loadImages([{imageName:t.imageName,width:t.width,height:t.height,dataUrl:t.dataUrl,svgString:t.svgString}])}materializeI18nDataReadyEvent(t){this.configureI18n(t.localizationOptions)}materializeScenePresentEvent(t){let i=Be.none();if(t.transitionType===de.Slide){if(t.direction===void 0)throw new Error("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(t.duration===void 0)throw new Error("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(t.easingType===void 0)throw new Error("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const n=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!n)throw new Error(`EventMaterializer: Scene with uuid ${t.uuid} not found`);switch(t.direction){case fe.Left:{n.position.x=n.size.width;break}case fe.Right:{n.position.x=-n.size.width;break}case fe.Up:{n.position.y=n.size.height;break}case fe.Down:{n.position.y=-n.size.height;break}}i=Be.slide({direction:t.direction,duration:t.duration,easing:Te.fromTypeAsString(t.easingType)})}this.game.presentScene(t.uuid,i)}}class ca{constructor(t){if(this.type=si.Game,this.sessionUuid="",this.uuid=De.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.39.1",this.beginTimestamp=NaN,this.beginIso8601Timestamp="",this.eventListeners=new Array,this.gameMetrics=new Array,this.stepCount=0,this.steppingNow=0,this.warmupFunctionQueue=new Array,this.warmupFinished=!1,this.plugins=[],this.staticTrialSchema={},this.eventStore=new An,this.nodeFactory=new Cn,this.materializedNodes=new Array,this.data={trials:new Array},this.trialIndex=0,this.drawnFrames=0,this.lastFpsUpdate=0,this.nextFpsUpdate=0,this.fpsRate=0,this.animationFramesRequested=0,this.limitFps=!1,this.gameStopRequested=!1,this.webGlRendererInfo="",this.canvasCssWidth=0,this.canvasCssHeight=0,this.scenes=new Array,this.freeNodesScene=new Ue({name:X.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.replayEventsButtonEnabled=!0,this.automaticTrialSchema={study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.snapshots=new Array,!t.id||t.id.trim()==="")throw new Error("id is required in GameOptions");if(!De.isValid(t.publishUuid)){const i=t.publishUuid?`Provided publishUuid was ${t.publishUuid}. `:"";console.warn(`Missing or invalid publishUuid in GameOptions. ${i}To generate a valid UUID, visit a site such as https://www.uuidgenerator.net/version4`)}this.options=t,this.name=t.name,this.id=t.id,this.publishUuid=t.publishUuid,this.fpsMetricReportThreshold=t.fpsMetricReportThreshold??X.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=t.maximumRecordedActivityMetrics??X.MAXIMUM_RECORDED_ACTIVITY_METRICS,this.addLocalizationParametersToGameParameters(),this.options.locale!==void 0&&this.setParameters({locale:this.options.locale}),this.options.fallbackLocale!==void 0&&this.setParameters({fallback_locale:this.options.fallbackLocale}),this.options.missingLocalizationColor&&this.setParameters({missing_localization_color:this.options.missingLocalizationColor}),this.options.translation&&this.setParameters({translation:this.options.translation}),this.options.additionalTranslation&&this.setParameters({translation:this.options.additionalTranslation}),this.options.trialSchema||(this.options.trialSchema={}),t.moduleMetadata?this.moduleMetadata=t.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}}}createFreeNodesScene(){this.freeNodesScene.game=this,this.freeNodesScene.needsInitialization=!0;const t={name:X.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:this.freeNodesScene.uuid},i={type:G.NodeNew,target:this.freeNodesScene,nodeType:at.Scene,...q.createFrameUpdateTimestamps(),nodeOptions:t,sequence:m2c2Globals.eventSequence};this.eventStore.addEvent(i)}getImportedModuleBaseUrl(t,i){const n=new RegExp(`^.*${t}[^\\/]*`),u=i.match(n);if(!u||u.length===0)throw new Error(`Could not calculate imported assessment package base URL. Package name: ${t}, module URL: ${i}`);return u[0]}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...xi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(t){return la({locateFile:()=>t})}async resolveGameBaseUrls(t){let i,n=!1,u=`assets/${t.id}`;if(t.moduleMetadata.name)try{i=await import.meta.resolve(t.moduleMetadata.name),u=t.getImportedModuleBaseUrl(t.moduleMetadata.name,i)+"/assets",n=!0}catch{}let h=`assets/${t.id}`;try{const C=await import.meta.resolve("@m2c2kit/core");h=t.getImportedModuleBaseUrl("@m2c2kit/core",C)+"/assets"}catch{if(n)throw new Error(`the package ${t.moduleMetadata.name} has been imported from a module URL (${i}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:u,canvasKitWasm:h}}async configureI18n(t){if(this.i18n=new xi(this,t),!this.i18n)throw new Error("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:t,...q.createFrameUpdateTimestamps()})}async initialize(){this.options.recordEvents===!0&&(this.eventStore.mode=ce.Record),this.createFreeNodesScene();const t=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const i=q.getUrlFromManifest(this,t.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch{throw new Error(`game ${this.id} could not load canvaskit wasm file from ${i}`)}}if(this.isLocalizationRequested()){const i=this.getLocalizationOptionsFromGameParameters();await this.configureI18n(i)}return this.fontManager=new _n(this,t),this.imageManager=new or(this,t),this.soundManager=new Un(this,t),this.eventMaterializer=new ha({game:this,nodeFactory:this.nodeFactory,freeNodesScene:this.freeNodesScene,configureI18n:this.configureI18n.bind(this)}),Promise.all([this.fontManager.initializeFonts(this.options.fonts),this.imageManager.initializeImages(this.options.images),this.soundManager.initializeSounds(this.options.sounds)])}async loadManifest(t="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(t.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let i;try{if(i=await fetch(t),!i.ok)throw new Error(`Error ${i.status} on GET manifest.json from ${t}.`)}catch{throw new Error(`Network error on GET manifest.json from ${t}.`)}try{return await i.json()}catch{throw new Error(`Error parsing manifest.json from ${t}.`)}}get fontManager(){if(!this._fontManager)throw new Error("fontManager is undefined");return this._fontManager}set fontManager(t){this._fontManager=t}get imageManager(){if(!this._imageManager)throw new Error("imageManager is undefined");return this._imageManager}set imageManager(t){this._imageManager=t}get soundManager(){if(!this._soundManager)throw new Error("soundManager is undefined");return this._soundManager}set soundManager(t){this._soundManager=t}get eventMaterializer(){if(!this._eventMaterializer)throw new Error("eventMaterializer is undefined");return this._eventMaterializer}set eventMaterializer(t){this._eventMaterializer=t}addPrefixesToKey(t){let i="";if(this.studyId&&this.studyUuid)i=this.studyId.concat(":",this.studyUuid,":");else if(this.studyId||this.studyUuid)throw new Error(`study_id and study_uuid must both be set or unset. Values are study_id: ${this.studyId}, study_uuid: ${this.studyUuid}`);return i.concat(this.id.concat(this.id,":",this.publishUuid,":",t))}storeSetItem(t,i,n=!1){const u=n?t:this.addPrefixesToKey(t);return this.dataStores[0].setItem(u,i,n?"":this.publishUuid)}storeGetItem(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].getItem(n)}storeDeleteItem(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].deleteItem(n)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(t=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(t?"":this.publishUuid)}storeItemExists(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].itemExists(n)}get dataStores(){if(!this._dataStores)throw new Error("dataStores is undefined");return this._dataStores}set dataStores(t){this._dataStores=t}hasDataStores(){return this._dataStores&&this._dataStores.length>0||!1}getLocalizationOptionsFromGameParameters(){const t=this.getParameter("locale"),i=this.getParameterOrFallback("fallback_locale",void 0),n=this.getParameterOrFallback("missing_localization_color",void 0),u=this.getParameterOrFallback("translation",void 0),h=this.options.translation;return{locale:t,fallbackLocale:i,missingLocalizationColor:n,additionalTranslation:u,translation:h}}isLocalizationRequested(){const t=this.getParameterOrFallback("locale",void 0);if(t==="")throw new Error("Empty string in locale. Leave locale undefined or null to prevent localization.");return t==null&&this.options.translation?(this.setParameters({locale:this.options.translation.baseLocale}),!0):!(t==null&&this.options.translation===void 0)}setParameters(t){const{parameters:i}=this.options;Object.keys(t).forEach(n=>{!i||!(n in i)?console.warn(`game ${this.options.name} does not have a parameter named ${n}. attempt to set parameter ${n} to value ${t[n]} will be ignored`):this.options.parameters&&this.options.parameters[n]&&(this.options.parameters[n].default=t[n])}),this.additionalParameters=t}get canvasKit(){if(!this._canvasKit)throw new Error("canvaskit is undefined");return this._canvasKit}set canvasKit(t){this._canvasKit=t}addFreeNode(t){this.freeNodesScene.addChild(t)}addFreeEntity(t){this.addFreeNode(t)}removeFreeNode(t){if(typeof t=="string"){const i=this.freeNodesScene.children.filter(n=>n.name===t).find(Boolean);if(!i)throw new Error(`cannot remove free node named "${t}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.removeChild(i)}else this.freeNodesScene.removeChild(t)}removeFreeEntity(t){this.removeFreeNode(t)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}removeAllFreeEntities(){this.removeAllFreeNodes()}get freeNodes(){return this.freeNodesScene.children}get freeEntities(){return this.freeNodes}addScene(t){t.game=this,t.needsInitialization=!0,this.scenes.push(t),this.addNodeEvents(t)}addNodeEvents(t){this.eventStore.addEvents(t.nodeEvents),t.nodeEvents.length=0;for(const i of t.children)this.addNodeEvents(i)}addScenes(t){t.forEach(i=>{this.addScene(i)})}removeScene(t){if(typeof t=="object")if(this.scenes.includes(t))this.scenes=this.scenes.filter(i=>i!==t);else throw new Error(`cannot remove scene ${t} from game because the scene is not currently added to the game`);else if(this.scenes.map(i=>i.name).includes(t))this.scenes=this.scenes.filter(i=>i.name!==t);else throw new Error(`cannot remove scene named "${t}" from game because the scene is not currently added to the game`)}presentScene(t,i){let n;if(typeof t=="string"){if(n=this.scenes.filter(F=>F.name===t).find(Boolean),n===void 0&&(n=this.scenes.filter(F=>F.uuid===t).find(Boolean)),n===void 0)throw new Error(`scene ${t} not found`)}else{if(!this.scenes.some(F=>F===t))throw new Error(`scene ${t} exists, but it has not been added to the game object`);n=t}n.initialize(),n.needsInitialization=!1;const u=new zn(n,i??Be.none());this.incomingSceneTransitions.push(u),n.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${n.game.bodyBackgroundColor[0]},${n.game.bodyBackgroundColor[1]},${n.game.bodyBackgroundColor[2]},${n.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${n.backgroundColor[0]},${n.backgroundColor[1]},${n.backgroundColor[2]},${n.backgroundColor[3]})`;let h;i?.type===de.Slide&&(h=i.direction);const C={type:"ScenePresent",target:n,uuid:n.uuid,...q.createFrameUpdateTimestamps(),transitionType:i?.type??de.None,duration:i?.duration,direction:h,easingType:i?.easing?Te.toTypeAsString(i.easing):void 0};this.eventStore.addEvent(C)}getParameter(t){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))return this.options.parameters[t].default;throw new Error(`game parameter ${t} not found`)}getParameterOrFallback(t,i){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t)?this.options.parameters[t].default:i}hasParameter(t){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))}async start(t){const i=this.options;this.setupHtmlCanvases(i.canvasId,i.width,i.height,i.stretch),this.showFps=i.showFps??!1,this.bodyBackgroundColor=i.bodyBackgroundColor,this.initData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupCanvasDomEventHandlers(),this.beginTimestamp=Wt.now(),this.beginIso8601Timestamp=new Date().toISOString();let n;if(t!==void 0?typeof t=="object"?n=t:n=this.scenes.filter(C=>C.name===t).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?n=this.entryScene:n=this.scenes.filter(C=>C.name===this.entryScene).find(Boolean):n=this.scenes.find(Boolean),n===void 0)throw new Error("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(n),this.surface===void 0)throw new Error("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const u={target:this,type:G.GameWarmupStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(u),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives,positionOffset:.10012117}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithScenes}),this.surface.requestAnimationFrame(this.loop.bind(this));const h={target:this,type:G.ActivityStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h)}playEventsHandler(t){if(t?.target?.id==="replay-events"&&(this.eventStore.mode=ce.Disabled,this.scenes.forEach(i=>{this.removeScene(i)}),this.currentScene=void 0,this.eventListeners=new Array,this.freeNodesScene.removeAllChildren(),this.materializedNodes=[],this.eventStore.replay(),this.setReplayEventsButtonEnabled(!1),this.setStopReplayButtonEnabled(!0)),t?.target?.id==="stop-replay"&&(this.eventStore.clearEvents(),this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1)),t?.target?.id==="log-events"){if(this.eventStore.mode===ce.Replay){console.log(this.eventStore.serializedEventsBeforeReplay),console.log(`Total events: ${JSON.parse(this.eventStore.serializedEventsBeforeReplay).length}`);return}console.log(JSON.stringify(this.eventStore.getEvents())),console.log(`Total events: ${this.eventStore.getEvents().length}`)}}setReplayEventsButtonEnabled(t){const i=document.getElementById("replay-events");if(i){if(t){i.removeAttribute("disabled"),this.replayEventsButtonEnabled=!0;return}i.setAttribute("disabled","true"),this.replayEventsButtonEnabled=!1}}setStopReplayButtonEnabled(t){const i=document.getElementById("stop-replay");if(i){if(t){i.removeAttribute("disabled");return}i.setAttribute("disabled","true")}}addEventControlsToDom(){const t=document.getElementById("m2c2kit-event-controls-div");t&&t.remove();const i=document.getElementsByTagName("body")[0];if(i){const n=document.createElement("div");n.id="m2c2kit-event-controls-div",n.style.position="fixed",n.style.top="4px",n.style.left="4px",i.prepend(n);const u=document.createElement("button");u.id="replay-events",u.title="replay event recording",u.innerText="\u25B6\uFE0F",u.style.marginRight="4px",n.appendChild(u),u.addEventListener("click",this.playEventsHandler.bind(this));const h=document.createElement("button");h.id="stop-replay",h.title="stop event replay",h.innerText="\u23F9\uFE0F",h.style.marginRight="4px",h.disabled=!0,n.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const C=document.createElement("button");C.id="log-events",C.title="log events to console",C.innerText="\u{1F4C4}",C.style.marginRight="4px",n.appendChild(C),C.addEventListener("click",this.playEventsHandler.bind(this));const F=document.createElement("span");F.title="optional: replay events only through a given sequence number. Default is to replay all events.",F.innerText="Replay through sequence: ",n.appendChild(F);const B=document.createElement("input");B.id="sequence-number",B.title="optional: replay events only through a given sequence number. Default is to replay all events.",B.style.marginRight="4px",n.appendChild(B)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const n=document.createElement("div");n.id="m2c2kit-time-stepping-div",i.prepend(n);const u=document.createElement("button");u.id="1-step-advance",u.title="advance 1 step (16.667 ms)",u.innerText=">",u.style.marginRight="4px",n.appendChild(u),u.addEventListener("click",this.advanceStepsHandler.bind(this));const h=document.createElement("button");h.id="55-step-advance",h.title="advance 55 steps (916.667 ms)",h.innerText=">>",h.style.marginRight="4px",n.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const C=document.createElement("input");C.id="time-stepping-steps-input",C.title="steps",C.style.width="40px",C.style.marginRight="4px",C.setAttribute("readonly","true"),n.appendChild(C);const F=document.createElement("input");F.id="time-stepping-now-input",F.title="milliseconds",F.style.width="80px",F.style.marginRight="4px",F.setAttribute("readonly","true"),n.appendChild(F)}}updateTimeSteppingOutput(){const t=document.getElementById("time-stepping-steps-input");t&&(t.value=this.stepCount.toString());const i=document.getElementById("time-stepping-now-input");i&&(i.value=this.steppingNow.toFixed(2))}advanceStepsHandler(t){t?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):t?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const t=document.getElementById("m2c2kit-time-stepping-div");t&&t.remove()}warmupShadersWithPrimitives(t,i=0){if(t.save(),i==0?t.scale(1/m2c2Globals.canvasScale,1/m2c2Globals.canvasScale):t.scale(1/m2c2Globals.canvasScale*1.13,1/m2c2Globals.canvasScale*1.13),!this.surface)throw new Error("surface is undefined");const n=this.surface.width(),u=this.surface.height(),h=Math.round(n/2)+i,C=Math.round(u/2)+i,F=i,B=i,U=Ft.makePaint(this.canvasKit,x.White,this.canvasKit.PaintStyle.Fill,!0);t.drawRect([0,0,this.surface.width(),this.surface.height()],U);const et=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Fill,!1),ct=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Fill,!0),ut=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Stroke,!1);ut.setStrokeWidth(2);const At=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Stroke,!0);At.setStrokeWidth(2),t.drawCircle(h,C,32,et),t.drawCircle(h,C,32,ct),t.drawCircle(h,C,32,ut),t.drawCircle(h,C,32,At);const yt=this.fontManager,ne=this.fontManager.getFontNames();if(ne.length>0&&yt.fonts[ne[0]].status===Xt.Ready){const Me=yt.getTypeface(ne[0]),We=new this.canvasKit.Font(Me,16*m2c2Globals.canvasScale);t.drawText("abc",h,C,et,We),t.drawText("abc",h,C,ct,We)}const Se=this.takeCurrentSceneSnapshot();t.drawImage(Se,F,B),Se.delete(),t.drawRect([F,B,16,16],et),t.drawRect([F,B,16,16],ct),t.drawRect([F,B,16,16],ut),t.drawRect([F,B,16,16],At),t.restore()}warmupShadersWithScenes(t){[...this.scenes,this.freeNodesScene].forEach(h=>{h.warmup(t)});const i=this.nodes.filter(h=>h.type===at.Sprite).map(h=>h.imageName),n=this.imageManager.images;n&&Object.keys(n).filter(C=>C!=="__outgoingSceneSnapshot").forEach(C=>{if(!i.includes(C)&&n[C].status===qt.Ready){const F=n[C].canvaskitImage;if(!F)throw new Error(`image ${C} is undefined`);t.drawImage(F,0,0)}});const u=new this.canvasKit.Paint;if(u.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new Error("surface is undefined");t.drawRect([0,0,this.surface.width(),this.surface.height()],u)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Wt.removeAll(),this.dispose()}dispose(){this.nodes.filter(t=>t.isDrawable).forEach(t=>t.dispose()),this.fontManager.dispose()}initData(){this.trialIndex=0,this.data={trials:new Array};const t=this.options.trialSchema??{},i=Object.entries(t);for(const[n,u]of i)if(u.type!==void 0&&!this.propertySchemaDataTypeIsValid(u.type))throw new Error(`invalid schema. variable ${n} is type ${u.type}. type must be number, string, boolean, object, or array`)}propertySchemaDataTypeIsValid(t){const i=["string","number","integer","object","array","boolean","null"];if(typeof t=="string")return i.includes(t);let n=!0;if(Array.isArray(t))t.forEach(u=>{i.includes(u)||(n=!1)});else throw new Error(`Invalid data type: ${t}`);return n}getDeviceMetadata(){const t=window.screen;return t.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,orientation:{type:t.orientation.type,angle:t.orientation.angle},pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}}addTrialData(t,i){if(!this.options.trialSchema)throw new Error("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const h={},C=Object.entries(this.options.trialSchema);for(const[F]of C)h[F]=null;this.data.trials.push({document_uuid:De.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,...h,device_metadata:this.getDeviceMetadata()})}if(!(t in this.options.trialSchema))throw new Error(`trial variable ${t} not defined in schema`);let n;Array.isArray(this.options.trialSchema[t].type)?n=this.options.trialSchema[t].type:n=[this.options.trialSchema[t].type];let u=typeof i;if(u==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(u="array"),i==null&&(u="null"),!n.includes(u)&&!(u==="number"&&Number.isInteger(i)&&n.includes("integer")))throw new Error(`type for variable ${t} (value: ${i}) is "${u}". Based on schema for this variable, expected type was "${n}"`);this.data.trials[this.trialIndex][t]=i}addTrialSchema(t){Object.keys(t).forEach(n=>{if(!this.options.trialSchema)throw new Error("trial schema is undefined");this.options.trialSchema[n]=t[n]})}addStaticTrialData(t,i){if(!this.options.trialSchema)throw new Error("trial schema is undefined");if(this.options.trialSchema[t]===void 0)throw new Error(`trial variable ${t} not defined in schema`);this.staticTrialSchema[t]=i}trialComplete(){this.data.trials[this.trialIndex]?.locale&&(this.data.trials[this.trialIndex].locale=this.i18n?.locale??null),this.data.trials[this.trialIndex]?.device_metadata&&(this.data.trials[this.trialIndex].device_metadata=this.getDeviceMetadata()),Object.keys(this.staticTrialSchema).length>0&&(this.data.trials[this.trialIndex]={...this.data.trials[this.trialIndex],...this.staticTrialSchema}),this.trialIndex++;const t={type:G.ActivityData,...q.createFrameUpdateTimestamps(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Bn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",required:["trials"],properties:{trials:{type:"array",items:{$ref:"#/$defs/trial"},description:"All trials from the assessment."}},$defs:{trial:{type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Bn}}}}}makeGameActivityConfiguration(t){const i=JSON.parse(JSON.stringify(t)),{locale:n,fallback_locale:u,missing_localization_color:h,translation:C,...F}=i;for(const B in F)for(const U in F[B])U=="default"&&(F[B]=F[B][U]);return F}makeGameActivityConfigurationSchema(t){const i=JSON.parse(JSON.stringify(t)),{locale:n,fallback_locale:u,missing_localization_color:h,translation:C,...F}=i;for(const B in F){if(!("type"in F[B])&&"value"in F[B]){const U=typeof F[B].default;U!=="bigint"&&U!=="function"&&U!=="symbol"&&U!=="undefined"&&(F[B].type=U)}for(const U in F[B])U=="default"&&delete F[B][U]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:F}}end(){const t={target:this,type:G.ActivityEnd,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}cancel(){const t={target:this,type:G.ActivityCancel,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}setupHtmlCanvases(t,i,n,u){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let h;if(t===void 0){const C=document.getElementsByTagName("canvas");let F=new Array;for(let U=0;U<C.length;U++)F.push(C[U]);if(F=F.filter(U=>!U.id.startsWith("m2c2kit-scratch-canvas")),F.length===0)throw new Error("no html canvas tag was found in the html");const B=F.filter(U=>U.id==="m2c2kit-canvas")[0];B?(h=B,F.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(h=C[0],F.length>1&&console.log("using first canvas"))}else if(h=document.getElementById(t),h===void 0)throw new Error(`could not find canvas HTML element with id "${t}"`);if(u||window.innerWidth<i||window.innerHeight<n){const C=n/i;window.innerHeight/window.innerWidth<C?m2c2Globals.rootScale=window.innerHeight/n:m2c2Globals.rootScale=window.innerWidth/i}h.style.width=m2c2Globals.rootScale*i+"px",h.style.height=m2c2Globals.rootScale*n+"px",h.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,h.height=m2c2Globals.rootScale*n*m2c2Globals.canvasScale,this.htmlCanvas=h,this.canvasCssWidth=i,this.canvasCssHeight=n,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=n}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=fr.getRendererString()}catch{this.webGlRendererInfo="err",fr.dispose()}const t=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(t===null)throw new Error("could not make CanvasKit surface from canvas HTML element");this.surface=t,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(m2c2Globals.canvasScale,m2c2Globals.canvasScale)}interceptWebGlCalls(){if(!this.htmlCanvas.__proto__.m2c2ModifiedGetContext){this.htmlCanvas.__proto__.m2c2ModifiedGetContext=!0;const t=this.htmlCanvas.__proto__.getContext;this.htmlCanvas.__proto__.getContext=function(...i){window.logWebGl&&console.log(`\u{1F53C} getContext(${i.map(u=>u.toString()).join(", ")})`);const n=t.apply(this,[...i]);if(n.__proto__.compileShader&&!n.__proto__.m2c2ModifiedCompileShader){n.__proto__.m2c2ModifiedCompileShader=!0;const u=n.__proto__.compileShader;n.__proto__.compileShader=function(...h){if(window.logWebGl){const C=h[0],F=n.getShaderSource(C);console.log("\u{1F53C} compileShader():"),console.log(F)}return u.apply(this,[...h])}}return n}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,X.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(X.FPS_DISPLAY_TEXT_COLOR[0],X.FPS_DISPLAY_TEXT_COLOR[1],X.FPS_DISPLAY_TEXT_COLOR[2],X.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");this.htmlCanvas.addEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.addEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.addEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.addEventListener("touchstart",t=>{t.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this))}loop(t){if(!this.surface)throw new Error("surface is undefined");if(this.warmupFunctionQueue.length>0){const i=this.warmupFunctionQueue.shift();i?.warmupFunction.call(this,t,i.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const i={target:this,type:G.GameWarmupEnd,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(i),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(this.soundManager.hasSoundsToDecode()&&navigator.userActivation.hasBeenActive&&this.soundManager.decodeFetchedSounds(),this.gameStopRequested){this.surface.deleteLater();return}if(this.animationFramesRequested++,!this.limitFps||this.animationFramesRequested%Math.round(60/X.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0&&this.eventStore.mode!==ce.Replay)throw new Error("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===ce.Replay){const i=this.eventStore.dequeueEvents(Wt.now());this.eventMaterializer.materialize(i),this.eventStore.eventQueueLength===0&&!this.replayEventsButtonEnabled&&(this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1))}for(this.handleIncomingSceneTransitions(this.incomingSceneTransitions),this.update(),this.draw(t);this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.freeNodesScene.draw(t),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}this.priorUpdateTime=m2c2Globals.now,this.surface.requestAnimationFrame(this.loop.bind(this))}updateGameTime(){this.options.timeStepping?m2c2Globals.now=this.steppingNow:m2c2Globals.now=performance.now(),this.priorUpdateTime?m2c2Globals.deltaTime=m2c2Globals.now-this.priorUpdateTime:m2c2Globals.deltaTime=0}handleIncomingSceneTransitions(t){if(t.length!==0&&(this.snapshots.length>0||t[0].transition.type===de.None)){const i=t.shift();if(i===void 0)throw new Error("no incoming scene transition");const n=i.scene,u=i.transition;if(u.type===de.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=n,this.currentScene._active=!0,this.raiseSceneEvent(n,"SceneSetup"),this.raiseSceneEvent(n,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new Error("No snapshot available for outgoing scene");const h=this.createOutgoingScene(this.currentSceneSnapshot);h._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=n,this.currentScene._active=!0,this.raiseSceneEvent(n,"SceneSetup"),this.animateSceneTransition(n,u,h)}}createOutgoingScene(t){const i=new Ue({name:X.OUTGOING_SCENE_NAME});i.size.width=this.canvasCssWidth,i.size.height=this.canvasCssHeight,this.addScene(i);const n={imageName:X.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:t,width:this.canvasCssWidth,height:this.canvasCssHeight,status:qt.Ready,localize:!1,isFallback:!1};this.imageManager.addImage(n);const u=new oi({name:X.OUTGOING_SCENE_SPRITE_NAME,imageName:X.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/m2c2Globals.rootScale/2,y:this.canvasCssHeight/m2c2Globals.rootScale/2}});return u.scale=1/m2c2Globals.rootScale,i.addChild(u),i}async registerPlugin(t){if(t.type!==si.Game)throw new Error(`registerPlugin(): plugin ${t.id} is not a game plugin. It is a ${t.type} plugin.`);if(this.plugins.includes(t)||this.plugins.map(i=>i.id).includes(t.id))throw new Error(`registerPlugin(): plugin ${t.id} already registered.`);this.plugins.push(t),t.initialize&&await t.initialize(this)}update(){this.executeBeforeUpdatePlugins(),this.updateScenes(),this.executeAfterUpdatePlugins()}updateScenes(){this.scenes.filter(t=>t._active).forEach(t=>t.update()),this.freeNodesScene.update()}executeBeforeUpdatePlugins(){this.plugins.filter(t=>typeof t.beforeUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.beforeUpdate&&t.beforeUpdate(this,m2c2Globals.deltaTime)})}executeAfterUpdatePlugins(){this.plugins.filter(t=>typeof t.afterUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.afterUpdate&&t.afterUpdate(this,m2c2Globals.deltaTime)})}draw(t){this.scenes.filter(i=>i._active).forEach(i=>i.draw(t)),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(t)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+X.FPS_DISPLAY_UPDATE_INTERVAL):m2c2Globals.now>=this.nextFpsUpdate&&(this.fpsRate=this.drawnFrames/((m2c2Globals.now-this.lastFpsUpdate)/1e3),this.drawnFrames=0,this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+X.FPS_DISPLAY_UPDATE_INTERVAL,this.gameMetrics.length<this.maximumRecordedActivityMetrics&&this.fpsRate<this.fpsMetricReportThreshold&&this.gameMetrics.push({fps:Number.parseFloat(this.fpsRate.toFixed(2)),fps_interval_ms:X.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:si.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new Error("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(t){if(!this.surface)throw new Error("no surface");let i;if(t.rect.length==4){const u=t.rect[0]*m2c2Globals.canvasScale,h=t.rect[1]*m2c2Globals.canvasScale,C=t.rect[2]*m2c2Globals.canvasScale,F=t.rect[3]*m2c2Globals.canvasScale,B=[u,h,u+C,h+F];i=this.surface.makeImageSnapshot(B)}else i=this.surface.makeImageSnapshot();const n=i.encodeToBytes();t.promiseResolve(n)}takeScreenshot(t,i,n,u){if(!this.surface)throw new Error("no canvaskit surface. unable to take screenshot.");const h=[t,i,n,u].map(C=>C?0:1).reduce((C,F)=>C+F);return new Promise((C,F)=>{switch(h){case 0:{if(!t||!i||!n||!u){F("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[t,i,n,u],promiseResolve:C};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:C};break}default:F("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(t,i,n){const u=i.duration;switch(t._transitioning=!0,n._transitioning=!0,i.type){case de.Slide:{switch(i.direction){case fe.Left:t.position.x=t.size.width,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:-n.size.width,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Right:t.position.x=-t.size.width,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:n.size.width,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Up:t.position.y=t.size.height,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:0,y:-n.size.height},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Down:t.position.y=-t.size.height,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:0,y:n.size.height},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new Error("unknown transition direction")}break}default:throw new Error("unknown transition type")}}drawFps(t){t.save();const i=m2c2Globals.canvasScale;if(t.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new Error("fps font or paint is undefined");t.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+X.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),t.restore()}createEventListener(t,i,n,u){const h=this.nodes.filter(F=>F.name===i);h.length>1&&console.warn(`warning: createEventListener() found more than one node with name ${i}. Event listener will be attached to first node found. All nodes that receive tap events should be uniquely named`);const C=h.filter(F=>F.name===i).find(Boolean);if(C===void 0)throw new Error(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(G).includes(t))throw new Error(`game ${this.id}: could not create event listener. event type ${t} is not known`);C.addEventListener(t,n,u)}get nodes(){function t(n,u){u.push(n),n.children.forEach(h=>t(h,u))}const i=new Array;return[...this.scenes,this.freeNodesScene].forEach(n=>t(n,i)),i}get entities(){return this.nodes}htmlCanvasPointerDownHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;if(!this.htmlCanvas)throw new Error("main html canvas is undefined");const n={type:"DomPointerDown",target:this.htmlCanvas,x:t.offsetX/m2c2Globals.rootScale,y:t.offsetY/m2c2Globals.rootScale,...q.createTimestamps()};this.eventStore.addEvent(n);const u={target:i,type:G.PointerDown,handled:!1,...q.createTimestamps()};this.processDomPointerDown(i,u,t),this.processDomPointerDown(this.freeNodesScene,u,t)}htmlCanvasPointerUpHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerUp,handled:!1,...q.createTimestamps()};this.processDomPointerUp(i,n,t),this.processDomPointerUp(this.freeNodesScene,n,t)}htmlCanvasPointerMoveHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerMove,handled:!1,...q.createTimestamps()};this.processDomPointerMove(i,n,t),this.processDomPointerMove(this.freeNodesScene,n,t)}htmlCanvasPointerLeaveHandler(t){if(!this.currentScene)return;t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerLeave,handled:!1,...q.createTimestamps()};this.processDomPointerLeave(i,n,t),this.processDomPointerLeave(this.freeNodesScene,n,t)}processDomPointerDown(t,i,n){i.handled||(t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressed=!0,t.pressedAndWithinHitArea=!0,t.pressedInitialPointerOffset={x:n.offsetX,y:n.offsetY},this.raiseM2PointerDownEvent(t,i,n),this.raiseTapDownEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerDown(u,i,n)))}processDomPointerUp(t,i,n){if(!i.handled){if(t.dragging){t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,i,n),i.handled=!0;return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(t,i,n),this.raiseTapUpAny(t,i,n),this.raiseM2PointerUpEvent(t,i,n)):t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea==!1?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpAny(t,i,n)):t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerUp(u,i,n))}}processDomPointerMove(t,i,n){if(!i.handled){if(t.isUserInteractionEnabled&&t.draggable&&t.pressed){let u=!1,h,C;t.dragging===!1?(t.dragging=!0,u=!0,h=n.offsetX-t.pressedInitialPointerOffset.x,C=n.offsetY-t.pressedInitialPointerOffset.y):(h=n.offsetX-t.draggingLastPointerOffset.x,C=n.offsetY-t.draggingLastPointerOffset.y),t.position.x+=h,t.position.y+=C,t.draggingLastPointerOffset={x:n.offsetX,y:n.offsetY},i.handled=!0,u?this.raiseM2DragStartEvent(t,i,n):this.raiseM2DragEvent(t,i,n);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,n)),t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(this.raiseM2PointerMoveEvent(t,i,n),t.withinHitArea=!0),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerMove(u,i,n))}}processDomPointerLeave(t,i,n){if(!i.handled){if(t.dragging){const u={target:t,type:G.DragEnd,handled:!1,...q.createTimestamps()};t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,u,n);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,n)),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerLeave(u,i,n))}}raiseM2PointerDownEvent(t,i,n){i.target=t,i.type=G.PointerDown,this.raiseEventOnListeningNodes(t,i,n)}raiseTapDownEvent(t,i,n){i.target=t,i.type=G.TapDown,this.raiseEventOnListeningNodes(t,i,n)}raiseTapLeaveEvent(t,i,n){i.target=t,i.type=G.TapLeave,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerUpEvent(t,i,n){i.target=t,i.type=G.PointerUp,this.raiseEventOnListeningNodes(t,i,n)}raiseTapUpEvent(t,i,n){i.target=t,i.type=G.TapUp,this.raiseEventOnListeningNodes(t,i,n)}raiseTapUpAny(t,i,n){i.target=t,i.type=G.TapUpAny,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerMoveEvent(t,i,n){i.target=t,i.type=G.PointerMove,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerLeaveEvent(t,i,n){i.target=t,i.type=G.PointerLeave,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragStartEvent(t,i,n){i.target=t,i.type=G.DragStart,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragEvent(t,i,n){i.target=t,i.type=G.Drag,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragEndEvent(t,i,n){i.target=t,i.type=G.DragEnd,this.raiseEventOnListeningNodes(t,i,n)}raiseSceneEvent(t,i){const n={target:t,type:i,...q.createFrameUpdateTimestamps()};t.eventListeners.filter(u=>u.type===i).forEach(u=>u.callback(n))}calculatePointWithinNodeFromDomPointerEvent(t,i){let n=t.size.width,u=t.size.height;if(t.type===at.Shape&&t.shapeType===Ut.Circle){const et=t.circleOfRadius;if(!et)throw"circleOfRadius is undefined";n=et*2,u=et*2}let h=i.offsetX,C=i.offsetY;const F=q.calculateNodeAbsoluteBoundingBox(t);q.nodeOrAncestorHasBeenRotated(t)&&q.calculateRotationTransforms(t).forEach(ct=>{const ut=q.rotatePoint({x:h,y:C},-ct.radians,ct.center);h=ut.x,C=ut.y});const B=(h-F.xMin)/(F.xMax-F.xMin)*n,U=(C-F.yMin)/(F.yMax-F.yMin)*u;return{x:B,y:U}}onStart(t,i){this.addEventListener(G.ActivityStart,t,i)}onCancel(t,i){this.addEventListener(G.ActivityCancel,t,i)}onEnd(t,i){this.addEventListener(G.ActivityEnd,t,i)}onData(t,i){this.addEventListener(G.ActivityData,t,i)}onWarmupStart(t,i){this.addEventListener(G.GameWarmupStart,t,i)}onWarmupEnd(t,i){this.addEventListener(G.GameWarmupEnd,t,i)}addEventListener(t,i,n){const u={type:t,activityUuid:this.uuid,callback:i};n?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(h=>!(h.activityUuid===u.activityUuid&&h.type===u.type))),this.eventListeners.push(u)}raiseActivityEventOnListeners(t,i){i&&(t={...t,...i}),this.eventListeners.filter(n=>n.type===t.type).forEach(n=>{n.callback(t)})}raiseEventOnListeningNodes(t,i,n){t.eventListeners.filter(u=>u.type===i.type).forEach(u=>{if(u.nodeUuid===t.uuid){switch(i.target=t,i.type){case G.PointerDown:case G.PointerMove:case G.PointerUp:case G.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,n),i.buttons=n.buttons,u.callback(i);break;case G.TapDown:case G.TapUp:case G.TapUpAny:case G.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,n),i.buttons=n.buttons,u.callback(i);break;case G.DragStart:case G.Drag:case G.DragEnd:i.position={x:t.position.x,y:t.position.y},i.buttons=n.buttons,u.callback(i);break}t.suppressEvents||this.eventStore.addEvent(i)}})}sceneCanReceiveUserInteraction(t){return!!(t._active&&t._transitioning===!1)}IsCanvasPointWithinNodeBounds(t,i,n){if(!t.isDrawable)throw"only drawable nodes can receive pointer events";if(t.type===at.Shape&&t.shapeType===Ut.Circle){const h=q.calculateNodeAbsoluteBoundingBox(t),C=t.circleOfRadius;if(!C)throw"circleOfRadius is undefined";const F={x:h.xMin+C*t.absoluteScale,y:h.yMin+C*t.absoluteScale};return Math.sqrt(Math.pow(i-F.x,2)+Math.pow(n-F.y,2))<=C*t.absoluteScale}if(t.size.width===0||t.size.height===0||t.type===at.TextLine&&isNaN(t.size.width))return!1;const u=q.calculateRotatedPoints(t);return t.isUserInteractionEnabled&&q.isPointInsideRectangle({x:i,y:n},u)}}function ua(){globalThis.m2c2Globals={now:performance.now(),iso8601Now:"",deltaTime:NaN,canvasScale:NaN,rootScale:1,canvasCssWidth:NaN,canvasCssHeight:NaN,m2NodeClassRegistry:{},__sequence:0,get eventSequence(){return m2c2Globals.__sequence++,m2c2Globals.__sequence-1}}}ua();const Wn=class Gn{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static start(t){let i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)i=new Gn(t),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new Error(`can't start timer. timer with name ${t} is already started`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't stop timer. timer with name ${t} does not exist`);if(i.stopped===!0)throw new Error(`can't stop timer. timer with name ${t} is already stopped`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static restart(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't restart timer. timer with name ${t} does not exist`);i.startTime=window.performance.now(),i.cumulativeElapsed=0,i.stopped=!1}static elapsed(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't get elapsed time. timer with name ${t} does not exist`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(n=>n.name===t).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${t} does not exist`);this._timers=this._timers.filter(n=>n.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};Wn._timers=new Array;let da=Wn;class pr{static SingleFromRange(t,i){return Math.floor(Math.random()*(i-t+1))+t}static FromRangeWithoutReplacement(t,i,n){if(t>n-i+1)throw new Error(`number of requested draws (n = ${t}) is greater than number of integers in range [ ${i}, ${n}]`);const u=new Array;for(let h=0;h<t;h++){const C=pr.SingleFromRange(i,n);u.includes(C)?t++:u.push(C)}return u}static FromGridWithoutReplacement(t,i,n,u){const h=new Array,C=i*n-1,F=this.FromRangeWithoutReplacement(t,0,C);let B=0,U=NaN;for(;B<t;){const et=F[B]%n,ct=(F[B]-et)/n;if(u===void 0||u(ct,et))h.push({row:ct,column:et}),B++;else{do U=this.FromRangeWithoutReplacement(1,0,C)[0];while(F.includes(U));F[B]=U}}return h}}class fa extends re{constructor(t){super(t),this.type=at.SoundPlayer,this.isDrawable=!1,this.soundName=t.soundName}initialize(){}dispose(){}duplicate(t){throw new Error("Method not implemented.")}}class pa extends re{constructor(t){if(super(t),this.type=at.SoundRecorder,this.isDrawable=!1,this._isRecording=!1,this._isPaused=!1,this.audioChunks=[],this.timerUuid="",t?.mimeType){const i=this.getMediaRecorderSupportedAudioMimeTypes();if(i.includes(t.mimeType))this.mimeType=t.mimeType;else if(console.warn(`Unsupported MIME type in SoundRecorderOptions: ${t.mimeType}. Supported types are: ${i}.`),t.backupMimeTypes){const n=this.getSupportedBackupMimeType(t.backupMimeTypes);n&&(this.mimeType=n,console.log(`Using backup MIME type: ${n}.`))}}t?.audioTrackConstraints&&(this.audioTrackConstraints=t.audioTrackConstraints),t?.maximumDuration&&(this.maximumDuration=t.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new Error("cannot start SoundRecorder because it is already started.");const t=this.getMediaRecorderSupportedAudioMimeTypes();if(t.length===0)throw new Error("SoundRecorder found no supported MIME types for MediaRecorder.");this.mimeType||(this.mimeType=t[0],console.log(`Using MIME type: ${this.mimeType}.`));let i;try{i=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})}catch{throw new Error("Error getting user media.")}if(!i)throw new Error("no stream.");const n=i.getAudioTracks();this.mediaTrackSettings=n?.map(u=>u.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=u=>{this.audioChunks.push(u.data)},this.mediaRecorder.onerror=u=>{throw new Error(`MediaRecorder error: ${u?.error?.message} ${u?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=De.generate(),Wt.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new Error("cannot stop SoundRecorder because it has not started.");return new Promise(t=>{if(!this.mediaRecorder)throw new Error("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new Error("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),n=await this.blobToBase64(i);t({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Wt.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:n,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Wt.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new Error("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new Error("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Wt.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new Error("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new Error("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Wt.start(this.timerUuid)}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Wt.elapsed(this.timerUuid)>this.maximumDuration){this.pause();return}}getMediaRecorderSupportedAudioMimeTypes(){const t=["audio"],i=["webm","ogg","mp3","mp4","x-matroska","3gpp","3gpp2","3gp2","quicktime","mpeg","aac","flac","x-flac","wave","wav","x-wav","x-pn-wav","not-supported"],n=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","vorbis","pcm","aac","mpeg","mp4a","rtx","red","ulpfec","g722","pcmu","pcma","cn","telephone-event","not-supported"];return[...new Set(i.flatMap(u=>t.flatMap(h=>[`${h}/${u}`]))),...new Set(i.flatMap(u=>n.flatMap(h=>t.flatMap(C=>[`${C}/${u};codecs=${h}`])))),...new Set(i.flatMap(u=>n.flatMap(h=>n.flatMap(C=>t.flatMap(F=>[`${F}/${u};codecs="${h}, ${C}"`])))))].filter(u=>MediaRecorder.isTypeSupported(u))}blobToBase64(t){return new Promise((i,n)=>{const u=new FileReader;u.onloadend=()=>{const h=u.result?.toString().split(",").pop();if(h===void 0)throw new Error("base64WithoutPrefix is undefined.");i(h)},u.onerror=n,u.readAsDataURL(t)})}getMimeTypeWithoutCodecs(t){const i=t.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(t){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const n of t)if(i.includes(n))return n}dispose(){}duplicate(t){throw new Error(`Method not implemented. ${t}`)}}class ma{static create(t){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.19 (0679492d)");export{V as Action,si as ActivityType,Ft as CanvasKitHelpers,Vs as ColorfulMutablePath,Xs as Composite,X as Constants,Dt as ConstraintType,pn as CustomAction,bn as Dimensions,Te as Easings,j as Equal,Js as Equals,An as EventStore,ce as EventStoreMode,wn as FadeAlphaAction,_n as FontManager,ca as Game,dn as GroupAction,xi as I18n,or as ImageManager,ki as Label,ze as LabelHorizontalAlignmentMode,Pn as LayoutConstraint,da as LegacyTimer,G as M2EventType,qt as M2ImageStatus,re as M2Node,Cn as M2NodeFactory,at as M2NodeType,zt as M2SoundStatus,q as M2c2KitHelpers,vn as MoveAction,Ni as MutablePath,Ln as NoneTransition,mn as PlayAction,pr as RandomDraws,sr as RepeatAction,fn as RepeatForeverAction,Sn as RotateAction,yn as ScaleAction,Ue as Scene,zn as SceneTransition,un as SequenceAction,ai as Shape,Ut as ShapeType,Dn as SlideTransition,Un as SoundManager,fa as SoundPlayer,pa as SoundRecorder,oi as Sprite,ma as Story,Oi as TextLine,Wt as Timer,Be as Transition,fe as TransitionDirection,de as TransitionType,De as Uuid,gn as WaitAction,x as WebColors,fr as WebGlInfo,Fe as handleInterfaceOptions};
1
+ var at=(g=>(g.Node="Node",g.Scene="Scene",g.Sprite="Sprite",g.Label="Label",g.TextLine="TextLine",g.Shape="Shape",g.Composite="Composite",g.SoundPlayer="SoundPlayer",g.SoundRecorder="SoundRecorder",g))(at||{});const zt={Deferred:"Deferred",WillFetch:"WillFetch",Fetching:"Fetching",Fetched:"Fetched",Decoding:"Decoding",Ready:"Ready",Error:"Error"};var pt=(g=>(g.Sequence="Sequence",g.Group="Group",g.Wait="Wait",g.Custom="Custom",g.Move="Move",g.Scale="Scale",g.FadeAlpha="FadeAlpha",g.Rotate="Rotate",g.Play="Play",g.Repeat="Repeat",g.RepeatForever="RepeatForever",g))(pt||{});const Ct=class tt{static toTypeAsString(t){switch(t){case tt.none:return"None";case tt.linear:return"Linear";case tt.quadraticIn:return"QuadraticIn";case tt.quadraticOut:return"QuadraticOut";case tt.quadraticInOut:return"QuadraticInOut";case tt.cubicIn:return"CubicIn";case tt.cubicOut:return"CubicOut";case tt.cubicInOut:return"CubicInOut";case tt.quarticIn:return"QuarticIn";case tt.quarticOut:return"QuarticOut";case tt.quarticInOut:return"QuarticInOut";case tt.quinticIn:return"QuinticIn";case tt.quinticOut:return"QuinticOut";case tt.quinticInOut:return"QuinticInOut";case tt.sinusoidalIn:return"SinusoidalIn";case tt.sinusoidalOut:return"SinusoidalOut";case tt.sinusoidalInOut:return"SinusoidalInOut";case tt.exponentialIn:return"ExponentialIn";case tt.exponentialOut:return"ExponentialOut";case tt.exponentialInOut:return"ExponentialInOut";case tt.circularIn:return"CircularIn";case tt.circularOut:return"CircularOut";case tt.circularInOut:return"CircularInOut";default:throw new Error("Easings.toTypeAsString(): Unknown easing function")}}static fromTypeAsString(t){switch(t){case"None":return tt.none;case"Linear":return tt.linear;case"QuadraticIn":return tt.quadraticIn;case"QuadraticOut":return tt.quadraticOut;case"QuadraticInOut":return tt.quadraticInOut;case"CubicIn":return tt.cubicIn;case"CubicOut":return tt.cubicOut;case"CubicInOut":return tt.cubicInOut;case"QuarticIn":return tt.quarticIn;case"QuarticOut":return tt.quarticOut;case"QuarticInOut":return tt.quarticInOut;case"QuinticIn":return tt.quinticIn;case"QuinticOut":return tt.quinticOut;case"QuinticInOut":return tt.quinticInOut;case"SinusoidalIn":return tt.sinusoidalIn;case"SinusoidalOut":return tt.sinusoidalOut;case"SinusoidalInOut":return tt.sinusoidalInOut;case"ExponentialIn":return tt.exponentialIn;case"ExponentialOut":return tt.exponentialOut;case"ExponentialInOut":return tt.exponentialInOut;case"CircularIn":return tt.circularIn;case"CircularOut":return tt.circularOut;case"CircularInOut":return tt.circularInOut;default:throw new Error(`Easings.fromTypeAsString(): Unknown easing function type ${t}`)}}};Ct.none=(g,t,i,n)=>i+t,Ct.linear=(g,t,i,n)=>i*g/n+t,Ct.quadraticIn=(g,t,i,n)=>(g/=n,i*g*g+t),Ct.quadraticOut=(g,t,i,n)=>(g/=n,-i*g*(g-2)+t),Ct.quadraticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g+t:(g--,-i/2*(g*(g-2)-1)+t)),Ct.cubicIn=(g,t,i,n)=>(g/=n,i*g*g*g+t),Ct.cubicOut=(g,t,i,n)=>(g/=n,g--,i*(g*g*g+1)+t),Ct.cubicInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g+t:(g-=2,i/2*(g*g*g+2)+t)),Ct.quarticIn=(g,t,i,n)=>(g/=n,i*g*g*g*g+t),Ct.quarticOut=(g,t,i,n)=>(g/=n,g--,-i*(g*g*g*g-1)+t),Ct.quarticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g*g+t:(g-=2,-i/2*(g*g*g*g-2)+t)),Ct.quinticIn=(g,t,i,n)=>(g/=n,i*g*g*g*g*g+t),Ct.quinticOut=(g,t,i,n)=>(g/=n,g--,i*(g*g*g*g*g+1)+t),Ct.quinticInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*g*g*g*g*g+t:(g-=2,i/2*(g*g*g*g*g+2)+t)),Ct.sinusoidalIn=(g,t,i,n)=>-i*Math.cos(g/n*(Math.PI/2))+i+t,Ct.sinusoidalOut=(g,t,i,n)=>i*Math.sin(g/n*(Math.PI/2))+t,Ct.sinusoidalInOut=(g,t,i,n)=>-i/2*(Math.cos(Math.PI*g/n)-1)+t,Ct.exponentialIn=(g,t,i,n)=>i*Math.pow(2,10*(g/n-1))+t,Ct.exponentialOut=(g,t,i,n)=>i*(-Math.pow(2,-10*g/n)+1)+t,Ct.exponentialInOut=(g,t,i,n)=>(g/=n/2,g<1?i/2*Math.pow(2,10*(g-1))+t:(g--,i/2*(-Math.pow(2,-10*g)+2)+t)),Ct.circularIn=(g,t,i,n)=>(g/=n,-i*(Math.sqrt(1-g*g)-1)+t),Ct.circularOut=(g,t,i,n)=>(g/=n,g--,i*Math.sqrt(1-g*g)+t),Ct.circularInOut=(g,t,i,n)=>(g/=n/2,g<1?-i/2*(Math.sqrt(1-g*g)-1)+t:(g-=2,i/2*(Math.sqrt(1-g*g)+1)+t));let Te=Ct;var Ut=(g=>(g.Undefined="Undefined",g.Rectangle="Rectangle",g.Circle="Circle",g.Path="Path",g))(Ut||{});const cn=class $n{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static new(t){this._timers=this._timers.filter(n=>n.name!==t);const i=new $n(t);i.cumulativeElapsed=0,this._timers.push(i)}static startNew(t){this.new(t),this.start(t)}static start(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't start timer. timer with name ${t} does not exist.`);if(i.stopped===!1)throw new Error(`can't start timer. timer with name ${t} is already started.`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't stop timer. timer with name ${t} does not exist.`);if(i.stopped===!0)throw new Error(`can't stop timer. timer with name ${t} is already stopped.`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static elapsed(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't get elapsed time. timer with name ${t} does not exist.`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(n=>n.name===t).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${t} does not exist.`);this._timers=this._timers.filter(n=>n.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};cn._timers=new Array;let Wt=cn;class x{}x.Transparent=[0,0,0,0],x.MediumVioletRed=[199,21,133,1],x.DeepPink=[255,20,147,1],x.PaleVioletRed=[219,112,147,1],x.HotPink=[255,105,180,1],x.LightPink=[255,182,193,1],x.Pink=[255,192,203,1],x.DarkRed=[139,0,0,1],x.Red=[255,0,0,1],x.Firebrick=[178,34,34,1],x.Crimson=[220,20,60,1],x.IndianRed=[205,92,92,1],x.LightCoral=[240,128,128,1],x.Salmon=[250,128,114,1],x.DarkSalmon=[233,150,122,1],x.LightSalmon=[255,160,122,1],x.OrangeRed=[255,69,0,1],x.Tomato=[255,99,71,1],x.DarkOrange=[255,140,0,1],x.Coral=[255,127,80,1],x.Orange=[255,165,0,1],x.DarkKhaki=[189,183,107,1],x.Gold=[255,215,0,1],x.Khaki=[240,230,140,1],x.PeachPuff=[255,218,185,1],x.Yellow=[255,255,0,1],x.PaleGoldenrod=[238,232,170,1],x.Moccasin=[255,228,181,1],x.PapayaWhip=[255,239,213,1],x.LightGoldenrodYellow=[250,250,210,1],x.LemonChiffon=[255,250,205,1],x.LightYellow=[255,255,224,1],x.Maroon=[128,0,0,1],x.Brown=[165,42,42,1],x.SaddleBrown=[139,69,19,1],x.Sienna=[160,82,45,1],x.Chocolate=[210,105,30,1],x.DarkGoldenrod=[184,134,11,1],x.Peru=[205,133,63,1],x.RosyBrown=[188,143,143,1],x.Goldenrod=[218,165,32,1],x.SandyBrown=[244,164,96,1],x.Tan=[210,180,140,1],x.Burlywood=[222,184,135,1],x.Wheat=[245,222,179,1],x.NavajoWhite=[255,222,173,1],x.Bisque=[255,228,196,1],x.BlanchedAlmond=[255,235,205,1],x.Cornsilk=[255,248,220,1],x.DarkGreen=[0,100,0,1],x.Green=[0,128,0,1],x.DarkOliveGreen=[85,107,47,1],x.ForestGreen=[34,139,34,1],x.SeaGreen=[46,139,87,1],x.Olive=[128,128,0,1],x.OliveDrab=[107,142,35,1],x.MediumSeaGreen=[60,179,113,1],x.LimeGreen=[50,205,50,1],x.Lime=[0,255,0,1],x.SpringGreen=[0,255,127,1],x.MediumSpringGreen=[0,250,154,1],x.DarkSeaGreen=[143,188,143,1],x.MediumAquamarine=[102,205,170,1],x.YellowGreen=[154,205,50,1],x.LawnGreen=[124,252,0,1],x.Chartreuse=[127,255,0,1],x.LightGreen=[144,238,144,1],x.GreenYellow=[173,255,47,1],x.PaleGreen=[152,251,152,1],x.Teal=[0,128,128,1],x.DarkCyan=[0,139,139,1],x.LightSeaGreen=[32,178,170,1],x.CadetBlue=[95,158,160,1],x.DarkTurquoise=[0,206,209,1],x.MediumTurquoise=[72,209,204,1],x.Turquoise=[64,224,208,1],x.Aqua=[0,255,255,1],x.Cyan=[0,255,255,1],x.Aquamarine=[127,255,212,1],x.PaleTurquoise=[175,238,238,1],x.LightCyan=[224,255,255,1],x.Navy=[0,0,128,1],x.DarkBlue=[0,0,139,1],x.MediumBlue=[0,0,205,1],x.Blue=[0,0,255,1],x.MidnightBlue=[25,25,112,1],x.RoyalBlue=[65,105,225,1],x.SteelBlue=[70,130,180,1],x.DodgerBlue=[30,144,255,1],x.DeepSkyBlue=[0,191,255,1],x.CornflowerBlue=[100,149,237,1],x.SkyBlue=[135,206,235,1],x.LightSkyBlue=[135,206,250,1],x.LightSteelBlue=[176,196,222,1],x.LightBlue=[173,216,230,1],x.PowderBlue=[176,224,230,1],x.Indigo=[75,0,130,1],x.Purple=[128,0,128,1],x.DarkMagenta=[139,0,139,1],x.DarkViolet=[148,0,211,1],x.DarkSlateBlue=[72,61,139,1],x.BlueViolet=[138,43,226,1],x.DarkOrchid=[153,50,204,1],x.Fuchsia=[255,0,255,1],x.Magenta=[255,0,255,1],x.SlateBlue=[106,90,205,1],x.MediumSlateBlue=[123,104,238,1],x.MediumOrchid=[186,85,211,1],x.MediumPurple=[147,112,219,1],x.Orchid=[218,112,214,1],x.Violet=[238,130,238,1],x.Plum=[221,160,221,1],x.Thistle=[216,191,216,1],x.Lavender=[230,230,250,1],x.MistyRose=[255,228,225,1],x.AntiqueWhite=[250,235,215,1],x.Linen=[250,240,230,1],x.Beige=[245,245,220,1],x.WhiteSmoke=[245,245,245,1],x.LavenderBlush=[255,240,245,1],x.OldLace=[253,245,230,1],x.AliceBlue=[240,248,255,1],x.Seashell=[255,245,238,1],x.GhostWhite=[248,248,255,1],x.Honeydew=[240,255,240,1],x.FloralWhite=[255,250,240,1],x.Azure=[240,255,255,1],x.MintCream=[245,255,250,1],x.Snow=[255,250,250,1],x.Ivory=[255,255,240,1],x.White=[255,255,255,1],x.Black=[0,0,0,1],x.DarkSlateGray=[47,79,79,1],x.DimGray=[105,105,105,1],x.SlateGray=[112,128,144,1],x.Gray=[128,128,128,1],x.LightSlateGray=[119,136,153,1],x.DarkGray=[169,169,169,1],x.Silver=[192,192,192,1],x.LightGray=[211,211,211,1],x.Gainsboro=[220,220,220,1],x.RebeccaPurple=[102,51,153,1];class X{}X.FPS_DISPLAY_TEXT_FONT_SIZE=12,X.FPS_DISPLAY_TEXT_COLOR=[0,0,0,.5],X.FPS_DISPLAY_UPDATE_INTERVAL=1e3,X.MAXIMUM_RECORDED_ACTIVITY_METRICS=32,X.FPS_METRIC_REPORT_THRESHOLD=59,X.DEFAULT_SCENE_BACKGROUND_COLOR=x.White,X.DEFAULT_SHAPE_FILL_COLOR=x.Red,X.DEFAULT_PATH_STROKE_COLOR=x.Red,X.DEFAULT_PATH_LINE_WIDTH=2,X.DEFAULT_FONT_COLOR=x.Black,X.DEFAULT_FONT_SIZE=16,X.LIMITED_FPS_RATE=5,X.FREE_NODES_SCENE_NAME="__freeNodesScene",X.OUTGOING_SCENE_NAME="__outgoingScene",X.OUTGOING_SCENE_SPRITE_NAME="__outgoingSceneSprite",X.OUTGOING_SCENE_IMAGE_NAME="__outgoingSceneSnapshot",X.SESSION_INITIALIZATION_POLLING_INTERVAL_MS=50,X.MODULE_METADATA_PLACEHOLDER={name:"",version:"",dependencies:{}},X.DEFAULT_ROOT_ELEMENT_ID="m2c2kit",X.ERUDA_URL="https://cdn.jsdelivr.net/npm/eruda@3.2.1/eruda.js";class q{static getUrlFromManifest(t,i){const n=t.manifest;return n&&n[i]?n[i]:i}static urlHasScheme(t){return/^[a-z]+:\/\//i.test(t)}static loadScriptUrls(t){if(!Array.isArray(t)||!t.every(i=>typeof i=="string")){console.warn('Error parsing "scripts" parameter. "scripts" must be an array of URL strings, and it is recommended to be URI encoded.');return}t.forEach(i=>{if(!m2c2Globals.addedScriptUrls.includes(i)){const n=document.createElement("script");n.src=i,n.async=!0,document.head.appendChild(n),console.log(`\u26AA added script: ${i}`),m2c2Globals.addedScriptUrls.push(i)}})}static loadEruda(t=100,i=50){if(m2c2Globals.erudaRequested===!0)return;console.log(`\u26AA added eruda script: ${X.ERUDA_URL}`);const n=document.createElement("script");n.src=X.ERUDA_URL,n.async=!0,document.head.appendChild(n),m2c2Globals.erudaRequested=!0;let u=0;const h=()=>{const C=window?.eruda;typeof C<"u"?(console.log("\u26AA eruda ready"),C.init(),m2c2Globals.erudaInitialized=!0):u<i?(u++,setTimeout(h,t)):console.log(`eruda was requested, but could not be loaded after ${t*i} milliseconds.`)};h()}static registerM2NodeClass(...t){m2c2Globals.m2NodeClassRegistry||(m2c2Globals.m2NodeClassRegistry={}),t.forEach(i=>{m2c2Globals.m2NodeClassRegistry={...m2c2Globals.m2NodeClassRegistry,[i.name]:i}})}static createFrameUpdateTimestamps(){return{timestamp:Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Wt.now():m2c2Globals.now,iso8601Timestamp:m2c2Globals.iso8601Now?m2c2Globals.iso8601Now:new Date().toISOString()}}static createTimestamps(){return{timestamp:Wt.now(),iso8601Timestamp:new Date().toISOString()}}static calculateRotatedPoints(t){const i=t.ancestors;i.reverse(),i.push(t);const n=i.map(u=>{const h=q.calculateNodeAbsoluteBoundingBox(u);return q.boundingBoxToPoints(h)});for(let u=0;u<n.length;u++){if(!nr(i[u]))continue;const h=n[u],C=i[u].zRotation,F=q.findCentroid(h);for(let B=u;B<i.length;B++)n[B]=Ks(n[B],C,F)}return n[n.length-1]}static rotateCanvasForDrawableNode(t,i){const n=q.calculateRotationTransforms(i);if(n.length===0)return;const u=m2c2Globals.canvasScale/i.absoluteScale;Hs(n,u,t)}static calculateNodeAbsoluteBoundingBox(t){const i=t.anchorPoint,n=t.absoluteScale;let u=t.size.width,h=t.size.height;if(t.type===at.Shape&&t.shapeType===Ut.Circle){const et=t.circleOfRadius;if(!et)throw"circleOfRadius is undefined";u=et*2,h=et*2}const C=t.absolutePosition.x-u*i.x*n,F=t.absolutePosition.x+u*(1-i.x)*n,B=t.absolutePosition.y-h*i.y*n,U=t.absolutePosition.y+h*(1-i.y)*n;return{xMin:C,xMax:F,yMin:B,yMax:U}}static radiansToDegrees(t){return-q.normalizeAngleRadians(t)*(180/Math.PI)}static normalizeAngleRadians(t){const i=Math.floor(t/(2*Math.PI));let n=t-i*(2*Math.PI);return n<0&&(n+=2*Math.PI),n}static arePointsOnSameSideOfLine(t,i,n,u){const h=(u.x-n.x)*(t.y-n.y)-(u.y-n.y)*(t.x-n.x),C=(u.x-n.x)*(i.y-n.y)-(u.y-n.y)*(i.x-n.x);return h*C>=0}static isPointInsideRectangle(t,i){if(i.length!==4)throw new Error("Invalid input: expected an array of four points");return q.arePointsOnSameSideOfLine(t,i[2],i[0],i[1])&&q.arePointsOnSameSideOfLine(t,i[3],i[1],i[2])&&q.arePointsOnSameSideOfLine(t,i[0],i[2],i[3])&&q.arePointsOnSameSideOfLine(t,i[1],i[3],i[0])}static nodeOrAncestorHasBeenRotated(t){const i=t.ancestors;return i.push(t),i.some(n=>nr(n))}static boundingBoxToPoints(t){const{xMin:i,xMax:n,yMin:u,yMax:h}=t;return[{x:i,y:u},{x:n,y:u},{x:n,y:h},{x:i,y:h}]}static findCentroid(t){if(t.length!==4)throw new Error("Invalid input: expected an array of four points");let i=0,n=0;for(const C of t)i+=C.x,n+=C.y;const u=i/4,h=n/4;return{x:u,y:h}}static rotatePoint(t,i,n){const u=t.x-n.x,h=t.y-n.y,C=u*Math.cos(-i)-h*Math.sin(-i),F=u*Math.sin(-i)+h*Math.cos(-i);return{x:C+n.x,y:F+n.y}}static calculateRotationTransforms(t){const i=[],n=t.ancestors;return n.reverse(),n.push(t),n.forEach(u=>{if(nr(u)){const h=u;if(h.type===at.Scene){const U={x:h.absolutePosition.x+h.size.width*.5,y:h.absolutePosition.y+h.size.height*.5};i.push({radians:h.zRotation,center:U});return}const C=q.calculateNodeAbsoluteBoundingBox(h),F=q.boundingBoxToPoints(C),B=q.findCentroid(F);i.push({radians:h.zRotation,center:B})}}),i}}function Hs(g,t,i){g.forEach(n=>{i.rotate(q.radiansToDegrees(n.radians),n.center.x*t,n.center.y*t)})}function nr(g){return q.normalizeAngleRadians(g.zRotation)!==0&&g.isDrawable}function Ks(g,t,i){if(g.length!==4)throw new Error("Invalid input: expected an array of four points");const n=[];for(const u of g)n.push(q.rotatePoint(u,t,i));return n}class xt{constructor(t){if(this.expression=new Array,this.WARNING_EXPRESSION_LENGTH=32,typeof t=="number"){this.pushToExpression(t);return}if(t===void 0){this.pushToExpression(1/0);return}this.pushToExpression(t)}pushToExpression(t){if(t===this)throw new Error("Cannot add, subtract, or assign a Futurable with itself.");this.expression.push(t),this.expression.length===this.WARNING_EXPRESSION_LENGTH&&console.warn(`Expression length is ${this.WARNING_EXPRESSION_LENGTH} elements. Something may be wrong.`)}assign(t){for(;this.expression.length>0;)this.expression.pop();this.pushToExpression(t)}add(...t){return this.appendOperation(Mi.Add,...t),this}subtract(...t){return this.appendOperation(Mi.Subtract,...t),this}appendOperation(t,...i){i.forEach(n=>{this.pushToExpression(t),this.pushToExpression(n)})}get value(){let t=0;const i=this.expression.flat(1/0);let n=1;for(let u=0;u<i.length;u++){if(typeof i[u]=="number"){t=t+n*i[u];continue}if(i[u]instanceof xt){t=t+n*i[u].value;continue}if(i[u]===Mi.Add){n=1;continue}if(i[u]===Mi.Subtract){n=-1;continue}}return t}}const Mi={Add:"Add",Subtract:"Subtract"};class V{constructor(t=!1){this.startOffset=new xt(0),this.started=!1,this.running=!1,this._completed=!1,this.runStartTime=-1,this.duration=new xt,this.runDuringTransition=t}initialize(t){const i=this.clone();return this.assignParents(i,i,t),this.propagateRunDuringTransition(i),this.assignDurations(i),this.assignStartOffsets(i),i}assignParents(t,i,n){if(n!==void 0&&(t.key=n),this.isParent(t)){const u=t.children;u.forEach(h=>{h.parent=t}),u.filter(h=>this.isParent(h)).forEach(h=>this.assignParents(h,i,n))}}propagateRunDuringTransition(t){this.isParent(t)&&(t.descendants.some(i=>i.runDuringTransition)&&(t.runDuringTransition=!0),t.children.forEach(i=>this.propagateRunDuringTransition(i)))}assignDurations(t){t.duration=this.calculateDuration(t),this.isParent(t)&&t.children.forEach(i=>this.assignDurations(i))}calculateDuration(t){if(t.type===pt.Group){const n=t.children.map(u=>this.calculateDuration(u)).reduce((u,h)=>Math.max(u,h.value),0);return new xt(n)}if(t.type===pt.Sequence){const n=t.children.map(u=>this.calculateDuration(u)).reduce((u,h)=>u+h.value,0);return new xt(n)}return this.isRepeating(t)?new xt:t.duration}assignStartOffsets(t){t.startOffset=this.calculateStartOffset(t),this.isParent(t)&&t.children.forEach(i=>this.assignStartOffsets(i))}calculateStartOffset(t){if(t.parent===void 0)return new xt(0);if(t.parent.type!==pt.Sequence)return t.parent.startOffset;const i=new xt(0);i.add(t.parent.startOffset);for(const n of t.parent.children){if(n===t)break;i.add(n.duration)}return i}static evaluateAction(t,i,n,u){if(i.involvedInSceneTransition()&&!t.runDuringTransition||(t.runStartTime===-1&&t.assignRunStartTimes(t,n),n<t.runStartTime+t.startOffset.value))return;if(t.shouldBeRunning(n)&&(t.running=!0),t.isParent(t)){if(t.children.forEach(C=>{V.evaluateAction(C,i,n,u)}),!t.isRepeating(t)){t.started||(t.started=!0),t.running&&t.completed&&(t.running=!1);return}V.evaluateRepeatingActions(t,n);return}if(t.shouldBeRunning(n)||(t.running=!1),t.running===!1&&t.completed===!0)return;const h=n-(t.runStartTime+t.startOffset.value);switch(t.type){case pt.Custom:V.evaluateCustomAction(t);break;case pt.Play:V.evaluatePlayAction(i,t);break;case pt.Wait:V.evaluateWaitAction(t,n);break;case pt.Move:V.evaluateMoveAction(t,i,h);break;case pt.Scale:V.evaluateScaleAction(t,i,h,u);break;case pt.FadeAlpha:V.evaluateFadeAlphaAction(t,i,h,u);break;case pt.Rotate:V.evaluateRotateAction(t,i,h,u);break;default:throw new Error(`Action type not recognized: ${t.type}`)}}static evaluateRepeatingActions(t,i){if(t.started||(t.started=!0),t.repetitionHasCompleted){t.completedRepetitions++;const n=t.children[0].duration.value;if(t.cumulativeDuration=t.cumulativeDuration+n,!isFinite(n))throw"repetitionDuration is not finite";if(!t.completed)t.restartAction(t,i);else{if(t.type===pt.RepeatForever)throw new Error("RepeatForever action should never complete");t.duration.assign(t.cumulativeDuration),t.running=!1}}}static evaluateRotateAction(t,i,n,u){const h=t;h.started||(h.byAngle!==void 0&&(h.delta=h.byAngle),h.toAngle!==void 0&&(h.toAngle=q.normalizeAngleRadians(h.toAngle),i.zRotation=q.normalizeAngleRadians(i.zRotation),h.delta=h.toAngle-i.zRotation,h.shortestUnitArc===!0&&Math.abs(h.delta)>Math.PI&&(h.delta=2*Math.PI-Math.abs(h.delta))),h.started=!0,h.finalValue=i.zRotation+h.delta),n<h.duration.value?(i.zRotation=i.zRotation+h.delta*(u/h.duration.value),h.delta<=0&&i.zRotation<h.finalValue&&(i.zRotation=h.finalValue),h.delta>0&&i.zRotation>h.finalValue&&(i.zRotation=h.finalValue)):(i.zRotation=h.finalValue,h.running=!1,h.completed=!0)}static evaluateFadeAlphaAction(t,i,n,u){const h=t;h.started||(h.delta=h.alpha-i.alpha,h.started=!0),n<h.duration.value?i.alpha=i.alpha+h.delta*(u/h.duration.value):(i.alpha=h.alpha,h.running=!1,h.completed=!0)}static evaluateScaleAction(t,i,n,u){const h=t;h.started||(h.delta=h.scale-i.scale,h.started=!0),n<h.duration.value?i.scale=i.scale+h.delta*(u/h.duration.value):(i.scale=h.scale,h.running=!1,h.completed=!0)}static evaluateMoveAction(t,i,n){const u=t;u.started||(u.dx=u.point.x-i.position.x,u.dy=u.point.y-i.position.y,u.startPoint.x=i.position.x,u.startPoint.y=i.position.y,u.started=!0),n<u.duration.value?(i.position.x=u.easing(n,u.startPoint.x,u.dx,u.duration.value),i.position.y=u.easing(n,u.startPoint.y,u.dy,u.duration.value)):(i.position.x=u.point.x,i.position.y=u.point.y,u.running=!1,u.completed=!0)}static evaluateWaitAction(t,i){const n=t;i>t.runStartTime+t.startOffset.value+t.duration.value&&(n.running=!1,n.completed=!0)}static evaluatePlayAction(t,i){if(t.type!==at.SoundPlayer)throw new Error("Play action can only be used with a SoundPlayer");const n=i,u=t,h=u.game.soundManager;if(!n.started){const C=h.getSound(u.soundName);if(C.audioBuffer){const F=h.audioContext.createBufferSource();F.buffer=C.audioBuffer,F.onended=()=>{n.running=!1,n.completed=!0;const B=performance.now()-(i.runStartTime+i.startOffset.value);i.duration.assign(B)},F.connect(h.audioContext.destination),F.start(),n.started=!0}else{if(C.status===zt.Error)throw new Error(`error loading sound ${C.soundName} (url ${C.url})`);console.warn(`Play action: audio buffer not ready for sound ${u.soundName} (url: ${C.url}); will try next frame`),C.status===zt.Deferred&&h.fetchDeferredSound(C)}}}static evaluateCustomAction(t){const i=t;i.callback(),i.running=!1,i.completed=!0}assignRunStartTimes(t,i){t.runStartTime=i,t.isParent(t)&&t.children.forEach(n=>{t.assignRunStartTimes(n,i)})}restartAction(t,i){if(t.runStartTime=i,t.running=!0,t.started=!0,t.type===pt.Play&&(t.duration=new xt),t.isParent(t)){t.children.forEach(n=>{t.restartAction(n,i)});return}t.completed=!1}shouldBeRunning(t){return t>=this.runStartTime+this.startOffset.value&&t<=this.runStartTime+this.startOffset.value+this.duration.value}static move(t){return new vn(t.point,new xt(t.duration),t.easing??Te.linear,t.runDuringTransition??!1)}static wait(t){return new gn(new xt(t.duration),t.runDuringTransition??!1)}static custom(t){return new pn(t.callback,t.runDuringTransition??!1)}static play(t){return new mn(t?.runDuringTransition??!1)}static scale(t){return new yn(t.scale,new xt(t.duration),t.runDuringTransition)}static fadeAlpha(t){return new wn(t.alpha,new xt(t.duration),t.runDuringTransition)}static rotate(t){if(t.byAngle!==void 0&&t.toAngle!==void 0)throw new Error("rotate Action: cannot specify both byAngle and toAngle");if(t.byAngle===void 0&&t.toAngle===void 0)throw new Error("rotate Action: must specify either byAngle or toAngle");if(t.toAngle===void 0&&t.shortestUnitArc!==void 0)throw new Error("rotate Action: shortestUnitArc can only be specified when toAngle is provided");return t.toAngle!==void 0&&t.shortestUnitArc===void 0&&(t.shortestUnitArc=!0),new Sn(t.byAngle,t.toAngle,t.shortestUnitArc,new xt(t.duration),t.runDuringTransition)}static sequence(t){const i=new un(t);return i.children=t,i}static group(t){const i=new dn(t);return i.children=t,i}static repeat(t){return new sr(t.action,t.count,t.runDuringTransition)}static repeatForever(t){return new fn(t.action,t.runDuringTransition)}isParent(t){return t.type===pt.Group||t.type===pt.Sequence||t.type===pt.Repeat||t.type===pt.RepeatForever}isRepeating(t){return t.type===pt.Repeat||t.type===pt.RepeatForever}get completed(){return this._completed}set completed(t){this._completed=t}}class un extends V{constructor(t){super(),this.type=pt.Sequence,this.children=t}clone(){const t=this.children.map(n=>n.clone()),i=V.sequence(t);return i.children.forEach(n=>n.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return ar(this)}}class dn extends V{constructor(t){super(),this.type=pt.Group,this.children=new Array,this.children=t}clone(){const t=this.children.map(n=>n.clone()),i=V.group(t);return i.children.forEach(n=>n.key=this.key),i.key=this.key,i}get completed(){return this.children.every(t=>t.completed)}get descendants(){return ar(this)}}class sr extends V{constructor(t,i,n=!1){super(n),this.type=pt.Repeat,this.completedRepetitions=0,this.cumulativeDuration=0,this.children=[t],this.count=i,this.duration=new xt}clone(){if(this.children.length!==1)throw new Error("Repeat action must have exactly one child");const t=V.repeat({action:this.children[0].clone(),count:this.count,runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}get completed(){return this.children.every(t=>t.completed)&&this.completedRepetitions===this.count}get descendantsAreCompleted(){return this.children.every(t=>t.completed)}get repetitionHasCompleted(){return this.running&&this.descendantsAreCompleted&&!this.completed}get descendants(){return ar(this)}}class fn extends sr{constructor(t,i=!1){super(t,1/0,i),this.type=pt.RepeatForever,this.count=1/0}clone(){if(this.children.length!==1)throw new Error("RepeatForever action must have exactly one child");const t=V.repeatForever({action:this.children[0].clone(),runDuringTransition:this.runDuringTransition});return t.children[0].key=this.key,t.key=this.key,t}}function ar(g){const t=[];function i(n){if(n.isParent(n))for(const u of n.children)t.push(u),i(u)}return i(g),t}class pn extends V{constructor(t,i=!1){super(i),this.type=pt.Custom,this.callback=t,this.duration=new xt(0)}clone(){const t=V.custom({callback:this.callback,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class mn extends V{constructor(t=!1){super(t),this.type=pt.Play,this.duration=new xt}clone(){const t=V.play({runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class gn extends V{constructor(t,i){super(i),this.type=pt.Wait,this.duration=t}clone(){const t=V.wait({duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class vn extends V{constructor(t,i,n,u){super(u),this.type=pt.Move,this.startPoint={x:NaN,y:NaN},this.dx=0,this.dy=0,this.duration=i,this.point=t,this.easing=n}clone(){const t=V.move({point:this.point,duration:this.duration.value,easing:this.easing,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class yn extends V{constructor(t,i,n=!1){super(n),this.type=pt.Scale,this.delta=0,this.duration=i,this.scale=t}clone(){const t=V.scale({scale:this.scale,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class wn extends V{constructor(t,i,n=!1){super(n),this.type=pt.FadeAlpha,this.delta=0,this.duration=i,this.alpha=t}clone(){const t=V.fadeAlpha({alpha:this.alpha,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}class Sn extends V{constructor(t,i,n,u,h=!1){super(h),this.type=pt.Rotate,this.delta=0,this.finalValue=NaN,this.duration=u,this.byAngle=t,this.toAngle=i,this.shortestUnitArc=n}clone(){const t=V.rotate({byAngle:this.byAngle,toAngle:this.toAngle,shortestUnitArc:this.shortestUnitArc,duration:this.duration.value,runDuringTransition:this.runDuringTransition});return t.key=this.key,t}}var si=(g=>(g.Game="Game",g.Survey="Survey",g))(si||{});class Ft{static Dispose(t){t.filter(i=>!i?.isDeleted()).forEach(i=>i?.delete())}static makePaint(t,i,n,u){const h=new t.Paint;return h.setColor(t.Color(i[0],i[1],i[2],i[3])),h.setStyle(n),h.setAntiAlias(u),h}}class Ni{constructor(){this._subpaths=new Array,this.currentPath=new Array}get subpaths(){return this.currentPath.length>0?[...this._subpaths,this.currentPath]:this._subpaths}move(t){this.currentPath.length>0&&this._subpaths.push(this.currentPath),this.currentPath=new Array,this.currentPath.push(t)}addLine(t){this.currentPath.push(t)}clear(){this._subpaths=new Array,this.currentPath=new Array}duplicate(){const t=new Ni;return t._subpaths=JSON.parse(JSON.stringify(this._subpaths)),t.currentPath=JSON.parse(JSON.stringify(this.currentPath)),t}}class Vs extends Ni{constructor(){super(...arguments),this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH,this.linePresentations=[]}addLine(t){this.isNewLinePresentation()&&this.linePresentations.push({strokeColor:this.strokeColor,lineWidth:this.lineWidth,subpathIndex:this._subpaths.length,pointIndex:this.currentPath.length-1}),this.currentPath.push(t)}isNewLinePresentation(){if(this.linePresentations.length===0)return!0;const t=this.linePresentations[this.linePresentations.length-1];return t.strokeColor!==this.strokeColor||t.lineWidth!==this.lineWidth}clear(){super.clear(),this.linePresentations=[],this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR,this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH}duplicate(){const t=super.duplicate();return t.strokeColor=JSON.parse(JSON.stringify(this.strokeColor)),t.lineWidth=this.lineWidth,t.linePresentations=JSON.parse(JSON.stringify(this.linePresentations)),t}}var Dt=(g=>(g.topToTopOf="topToTopOf",g.topToBottomOf="topToBottomOf",g.bottomToTopOf="bottomToTopOf",g.bottomToBottomOf="bottomToBottomOf",g.startToStartOf="startToStartOf",g.startToEndOf="startToEndOf",g.endToEndOf="endToEndOf",g.endToStartOf="endToStartOf",g))(Dt||{});class bn{constructor(t,i){this.verticalConstraint=!1,this.focalNodeMinimum=!1,this.alterNodeMinimum=!1,this.verticalTypes=[Dt.topToTopOf,Dt.topToBottomOf,Dt.bottomToTopOf,Dt.bottomToBottomOf],this.focalNodeMinimumTypes=[Dt.topToTopOf,Dt.topToBottomOf,Dt.startToStartOf,Dt.startToEndOf],this.alterNodeMinimumTypes=[Dt.topToTopOf,Dt.bottomToTopOf,Dt.startToStartOf,Dt.endToStartOf],this.type=t,this.alterNode=i,this.verticalTypes.includes(t)?(this.verticalConstraint=!0,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1):(this.verticalConstraint=!1,this.focalNodeMinimumTypes.includes(t)?this.focalNodeMinimum=!0:this.focalNodeMinimum=!1,this.alterNodeMinimumTypes.includes(t)?this.alterNodeMinimum=!0:this.alterNodeMinimum=!1)}}class De{static generate(){try{return crypto.randomUUID()}catch{let t;try{t=()=>crypto.getRandomValues(new Uint8Array(1))[0]}catch{t=()=>Math.floor(Math.random()*256)}return("10000000-1000-4000-8000"+-1e11).replace(/[018]/g,i=>(Number(i)^t()&15>>Number(i)/4).toString(16))}}static isValid(t){return t?t==="00000000-0000-0000-0000-000000000000"?!0:/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(t):!1}}const G={ActivityStart:"ActivityStart",ActivityEnd:"ActivityEnd",ActivityCancel:"ActivityCancel",ActivityData:"ActivityData",GameWarmupStart:"GameWarmupStart",GameWarmupEnd:"GameWarmupEnd",TapDown:"TapDown",TapUp:"TapUp",TapUpAny:"TapUpAny",TapLeave:"TapLeave",PointerDown:"PointerDown",PointerUp:"PointerUp",PointerMove:"PointerMove",PointerLeave:"PointerLeave",Drag:"Drag",DragStart:"DragStart",DragEnd:"DragEnd",Composite:"Composite",FrameDidSimulatePhysics:"FrameDidSimulatePhysics",SceneSetup:"SceneSetup",SceneAppear:"SceneAppear",ScenePresent:"ScenePresent",NodeNew:"NodeNew",NodeAddChild:"NodeAddChild",NodeRemoveChild:"NodeRemoveChild",NodePropertyChange:"NodePropertyChange",DomPointerDown:"DomPointerDown",BrowserImageDataReady:"BrowserImageDataReady",I18nDataReadyEvent:"I18nDataReadyEvent"};class j{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}static value(t,i){return typeof t!=typeof i?!1:t&&typeof t=="object"&&i&&typeof i=="object"?j.objectsDeepEqual(t,i):t===i}static objectsDeepEqual(t,i){if(t===i)return!0;if(Array.isArray(t)&&Array.isArray(i)){if(t.length!==i.length)return!1;for(let n=0;n<t.length;n++)if(!j.objectsDeepEqual(t[n],i[n]))return!1;return!0}if(typeof t=="object"&&!Array.isArray(t)&&t!==null&&typeof i=="object"&&!Array.isArray(i)&&i!==null){const n=Object.keys(t),u=Object.keys(i);if(n.length!==u.length)return!1;for(const h of n)if(!(h in i)||!j.objectsDeepEqual(t[h],i[h]))return!1;return!0}return!1}}function qs(g,t){t.anchorPoint&&(g.anchorPoint=t.anchorPoint),t.zPosition!==void 0&&(g.zPosition=t.zPosition)}function Ys(g,t){t.text!==void 0&&(g.text=t.text),t.fontName!==void 0&&(g.fontName=t.fontName),t.fontColor&&(g.fontColor=t.fontColor),t.fontSize!==void 0&&(g.fontSize=t.fontSize),t.interpolation&&(g.interpolation=t.interpolation),t.localize!==void 0&&(g.localize=t.localize)}function Fe(g,t){g.isDrawable&&qs(g,t),g.isText&&Ys(g,t)}class re{constructor(t={}){this.type=at.Node,this.isDrawable=!1,this.isShape=!1,this.isText=!1,this._suppressEvents=!1,this._position={x:0,y:0},this._scale=1,this._alpha=1,this._zRotation=0,this._isUserInteractionEnabled=!1,this._draggable=!1,this._hidden=!1,this.layout={},this.children=new Array,this.absolutePosition={x:0,y:0},this._size={width:0,height:0},this.absoluteScale=1,this.absoluteAlpha=1,this.absoluteAlphaChange=0,this.actions=new Array,this.eventListeners=new Array,this.uuid=De.generate(),this.needsInitialization=!0,this.userData={},this.loopMessages=new Set,this.nodeEvents=new Array,this.pressed=!1,this.withinHitArea=!1,this.pressedAndWithinHitArea=!1,this.pressedInitialPointerOffset={x:NaN,y:NaN},this.draggingLastPointerOffset={x:NaN,y:NaN},this.dragging=!1,this.toString=()=>{let i=this.type.toString();return this.type==at.Composite&&(i=this.compositeType),this.name!==this.uuid?`${this.name} (${i}, ${this.uuid})`:`${i} (${this.uuid})`},t.suppressEvents!==void 0&&(this.suppressEvents=t.suppressEvents),this.constructionTimeStamp=Number.isNaN(m2c2Globals?.now)||m2c2Globals?.now===void 0?Wt.now():m2c2Globals.now,this.constructionIso8601TimeStamp=new Date().toISOString(),this.constructionSequence=m2c2Globals.eventSequence,this.options=t,t.uuid!==void 0&&(this.uuid=t.uuid),t.name===void 0?this.name=this.uuid:this.name=t.name,t.position!==void 0&&(this.position=t.position),t.scale!==void 0&&(this.scale=t.scale),t.alpha!==void 0&&(this.alpha=t.alpha),t.zRotation!==void 0&&(this.zRotation=t.zRotation),t.isUserInteractionEnabled!==void 0&&(this.isUserInteractionEnabled=t.isUserInteractionEnabled),t.draggable!==void 0&&(this.draggable=t.draggable),t.hidden!==void 0&&(this.hidden=t.hidden),t.layout!==void 0&&(this.layout=t.layout)}initialize(){throw new Error("initialize() called in abstract base class Node.")}get completeNodeOptions(){throw new Error("get completeNodeOptions() called in abstract base class Node.")}saveNodeNewEvent(){if(this.suppressEvents)return;const t={type:G.NodeNew,target:this,nodeType:this.type,compositeType:this.type===at.Composite?this.compositeType:void 0,timestamp:this.constructionTimeStamp,iso8601Timestamp:this.constructionIso8601TimeStamp,nodeOptions:this.completeNodeOptions,sequence:this.constructionSequence};this.saveEvent(t)}savePropertyChangeEvent(t,i){if(this.suppressEvents)return;const n={type:G.NodePropertyChange,target:this,uuid:this.uuid,property:t,value:i,...q.createFrameUpdateTimestamps()};this.saveEvent(n)}saveEvent(t){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);try{this.game.eventStore.addEvent(t)}catch{this.nodeEvents.push(t)}}get game(){const t=i=>{if(i.parent)return i.parent.type===at.Scene?i.parent:t(i.parent);throw new Error(`Node ${this} has not been added to a scene.`)};return t(this).game}isPartOfGame(){if(this.type===at.Scene&&this._game===void 0)return!1;if(this.type===at.Scene&&this._game!==void 0)return!0;const t=i=>{if(i.parent)return i.parent.type===at.Scene?i.parent:t(i.parent)};return t(this)?._game!==void 0}addChild(t){const i=this.suppressEvents||t.suppressEvents;if(t===this)throw new Error(`Cannot add node ${t.toString()} as a child to itself.`);if(t.type==at.Scene)throw new Error(`Cannot add scene ${t.toString()} as a child to node ${this.toString()}. A scene cannot be the child of a node. A scene can only be added to a game object.`);if(this.children.filter(h=>h!==t).map(h=>h.name).includes(t.name))throw new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. A child with name "${t.name}" already exists on this parent.`);let n=new Array;if(this.isPartOfGame())n=this.game.nodes.filter(h=>h.children.includes(t));else{const h=this.descendants;h.includes(t)&&(n=h.filter(C=>C.children.includes(t)).map(C=>C.parent??void 0))}if(n.length===0){t.parent=this,this.children.push(t);const h={type:"NodeAddChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(h),this.saveChildEvents(t);return}const u=n.find(Boolean);throw u===this?new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on this parent. The child cannot be added again.`):new Error(`Cannot add child node ${t.toString()} to parent node ${this.toString()}. This child already exists on other parent node: ${u?.toString()}}. Remove the child from the other parent first.`)}saveChildEvents(t){t.nodeEvents.forEach(i=>{this.saveEvent(i)}),t.nodeEvents.length=0;for(const i of t.children)this.saveChildEvents(i)}removeAllChildren(){this.children.forEach(t=>this.removeChild(t))}removeChild(t){const i=this.suppressEvents||t.suppressEvents;if(this.children.includes(t))t.parent=void 0,this.children=this.children.filter(u=>u!==t);else throw new Error(`cannot remove node ${t} from parent ${this} because the node is not currently a child of the parent`);const n={type:"NodeRemoveChild",target:this,uuid:this.uuid,childUuid:t.uuid,...q.createFrameUpdateTimestamps()};i||this.saveEvent(n)}removeChildren(t){t.forEach(i=>{if(!this.children.includes(i))throw new Error(`cannot remove node ${i} from parent ${this} because the node is not currently a child of the parent`);this.removeChild(i)})}descendant(t){const i=this.descendants.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`descendant with name ${t} not found on parent ${this.toString()}`);return i}get descendants(){function t(n,u){u.push(n),n.children.forEach(h=>t(h,u))}const i=new Array;return this.children.forEach(n=>t(n,i)),i}get ancestors(){function t(n,u){return n.type==at.Scene||!n.parent?u:(u.push(n.parent),t(n.parent,u))}const i=new Array;return t(this,i)}involvedInActionAffectingAppearance(){return this.ancestors.concat(this).flatMap(n=>n.actions).some(n=>n.running&&(n.type===pt.Move||n.type===pt.Scale))}involvedInSceneTransition(){let t;return this.type===at.Scene?t=this:t=this.parentSceneAsNode,t._transitioning}onTapDown(t,i){this.addEventListener(G.TapDown,t,i)}onTapUp(t,i){this.addEventListener(G.TapUp,t,i)}onTapUpAny(t,i){this.addEventListener(G.TapUpAny,t,i)}onTapLeave(t,i){this.addEventListener(G.TapLeave,t,i)}onPointerDown(t,i){this.addEventListener(G.PointerDown,t,i)}onPointerUp(t,i){this.addEventListener(G.PointerUp,t,i)}onPointerMove(t,i){this.addEventListener(G.PointerMove,t,i)}onPointerLeave(t,i){this.addEventListener(G.PointerLeave,t,i)}onDragStart(t,i){this.addEventListener(G.DragStart,t,i)}onDrag(t,i){this.addEventListener(G.Drag,t,i)}onDragEnd(t,i){this.addEventListener(G.DragEnd,t,i)}addEventListener(t,i,n){const u={type:t,nodeUuid:this.uuid,callback:i};n?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(h=>!(h.nodeUuid===u.nodeUuid&&h.type===u.type))),this.eventListeners.push(u)}parseLayoutConstraints(t,i){const n=new Array;return Object.values(Dt).forEach(h=>{if(t[h]!==void 0){let C,F="";if(typeof t[h]=="object")C=t[h];else{const U=t[h];C=i.filter(et=>et.name===U||et.uuid===U).find(Boolean),C||(C=this.game.materializedNodes.filter(et=>et.name===U||et.uuid===U).find(Boolean)),F=`. sibling node named "${U}" has not been added to the game object`}if(C===void 0)throw new Error("could not find sibling node for constraint"+F);const B=new bn(h,C);n.push(B)}}),n}calculateYFromConstraint(t,i,n,u){let h=t.alterNode.absolutePosition.y;return t.alterNodeMinimum?t.alterNode.type!==at.Scene&&(h=h-t.alterNode.size.height*.5*u):t.alterNode.type!==at.Scene?h=h+t.alterNode.size.height*.5*u:h=h+t.alterNode.size.height*u,t.focalNodeMinimum?(h=h+this.size.height*.5*u,h=h+i*u):(h=h-this.size.height*.5*u,h=h-n*u),h}calculateXFromConstraint(t,i,n,u){let h=t.alterNode.absolutePosition.x;return t.alterNodeMinimum?t.alterNode.type!==at.Scene&&(h=h-t.alterNode.size.width*.5*u):t.alterNode.type!==at.Scene?h=h+t.alterNode.size.width*.5*u:h=h+t.alterNode.size.width*u,t.focalNodeMinimum?(h=h+this.size.width*.5*u,h=h+i*u):(h=h-this.size.width*.5*u,h=h-n*u),h}calculateAbsoluteAlpha(t,i){const n=i.reduce((u,h)=>u*h.alpha,1);return t*n}update(){if(this.needsInitialization&&this.initialize(),this.absoluteAlphaChange=this.calculateAbsoluteAlpha(this.alpha,this.ancestors)-this.absoluteAlpha,this.absoluteAlpha+=this.absoluteAlphaChange,this.parent===void 0)this.absolutePosition.x=this.position.x*this.scale,this.absolutePosition.y=this.position.y*this.scale,this.absoluteScale=this.scale;else if(this.absoluteScale=this.parent.absoluteScale*this.scale,this.layout?.constraints===void 0)this.absolutePosition.x=this.parent.absolutePosition.x+this.position.x*this.parent.absoluteScale,this.absolutePosition.y=this.parent.absolutePosition.y+this.position.y*this.parent.absoluteScale;else{const u=this.layout?.constraints?.horizontalBias??.5,h=this.layout?.constraints?.verticalBias??.5,C=this.layout?.marginTop??0,F=this.layout?.marginBottom??0,B=this.layout?.marginStart??0,U=this.layout?.marginEnd??0,et=this.parseLayoutConstraints(this.layout?.constraints,this.parentSceneAsNode.descendants),ct=this.parent.absoluteScale,ut=et.filter(yt=>yt.verticalConstraint).map(yt=>this.calculateYFromConstraint(yt,C,F,ct));ut.length===0||(ut.length===1?this.absolutePosition.y=ut[0]:ut.length===2&&(this.absolutePosition.y=Math.min(ut[0],ut[1])+h*Math.abs(ut[0]-ut[1])));const At=et.filter(yt=>!yt.verticalConstraint).map(yt=>this.calculateXFromConstraint(yt,B,U,ct));At.length===0||(At.length===1?this.absolutePosition.x=At[0]:At.length===2&&(this.absolutePosition.x=Math.min(At[0],At[1])+u*Math.abs(At[0]-At[1])))}this.actions.forEach(u=>V.evaluateAction(u,this,m2c2Globals.now,m2c2Globals.deltaTime));function t(u,h){const C=new Array;return h===void 0||Object.values(Dt).forEach(B=>{if(h[B]!==void 0){let U,et="";if(typeof h[B]=="object")U=h[B];else{const ct=h[B];let ut;u.type===at.Scene?ut=u.descendants:ut=u.parentSceneAsNode.descendants,U=ut.filter(At=>At.name===ct||At.uuid===ct).find(Boolean),U===void 0&&(U=u.game.materializedNodes.filter(At=>At.name===ct||At.uuid===ct).find(Boolean)),U===void 0&&(et=`. sibling node named "${ct}" has not been added to the game object`)}if(U===void 0)throw new Error("error getting uuid of sibling constraint"+et);U!==u&&C.push(U.uuid)}}),C}const i=new Map;this.children.forEach(u=>{i.set(u.uuid,t(this,u.layout?.constraints))});const n=this.findTopologicalSort(i);if(n.length>0){const u=n.reverse(),h=new Array;u.forEach(C=>{const F=this.children.filter(B=>B.uuid===C).find(Boolean);if(F===void 0)throw new Error("error in dag topological sort");h.push(F)}),h.forEach(C=>C.update())}else this.children.forEach(u=>u.update())}drawChildren(t){this.children.filter(i=>!i.hidden&&i.isDrawable).map(i=>i).sort((i,n)=>i.zPosition-n.zPosition).forEach(i=>i.draw(t))}run(t,i){this.actions.push(t.initialize(i))}removeAction(t){this.actions=this.actions.filter(i=>i.key!==t)}removeAllActions(){for(;this.actions.length;)this.actions.pop()}getNodeOptions(){return{name:this.name,position:this.position,scale:this.scale,alpha:this.alpha,zRotation:this.zRotation,isUserInteractionEnabled:this.isUserInteractionEnabled,draggable:this.draggable,hidden:this.hidden,layout:this.layout,uuid:this.uuid}}getDrawableOptions(){if(!this.isDrawable)throw new Error("getDrawableOptions() called object that is not IDrawable");return{anchorPoint:this.anchorPoint,zPosition:this.zPosition}}getTextOptions(){if(!this.isText)throw new Error("getTextOptions() called object that is not IText");return{text:this.text,fontName:this.fontName,fontColor:this.fontColor,fontSize:this.fontSize}}get canvasKit(){return this.game.canvasKit}get parentSceneAsNode(){if(this.type===at.Scene)throw new Error(`Node ${this} is a scene and cannot have a parent scene`);if(this.parent&&this.parent.type===at.Scene)return this.parent;if(this.parent)return this.parent.parentSceneAsNode;throw new Error(`Node ${this} has not been added to a scene`)}get size(){const t=this;return{get height(){return t._size.height},set height(i){j.value(t._size.height,i)||(t._size.height=i,t.savePropertyChangeEvent("size",t.size))},get width(){return t._size.width},set width(i){j.value(t._size.width,i)||(t._size.width=i,t.savePropertyChangeEvent("size",t.size))}}}set size(t){j.value(this._size.width,t.width)||(this._size=t,this.savePropertyChangeEvent("size",this.size))}get position(){const t=this;return{get x(){return t._position.x},set x(i){j.value(t._position.x,i)||(t._position.x=i,t.savePropertyChangeEvent("position",t.position))},get y(){return t._position.y},set y(i){j.value(t._position.y,i)||(t._position.y=i,t.savePropertyChangeEvent("position",t.position))}}}set position(t){j.value(this._position,t)||(this._position=t,this.savePropertyChangeEvent("position",this.position))}get zRotation(){return this._zRotation}set zRotation(t){j.value(this._zRotation,t)||(this._zRotation=t,this.savePropertyChangeEvent("zRotation",t))}get scale(){return this._scale}set scale(t){j.value(this._scale,t)||(this._scale=t,this.savePropertyChangeEvent("scale",t))}get alpha(){return this._alpha}set alpha(t){j.value(this._alpha,t)||(this._alpha=t,this.savePropertyChangeEvent("alpha",t))}get isUserInteractionEnabled(){return this._isUserInteractionEnabled}set isUserInteractionEnabled(t){j.value(this._isUserInteractionEnabled,t)||(this._isUserInteractionEnabled=t,this.savePropertyChangeEvent("isUserInteractionEnabled",t))}get hidden(){return this._hidden}set hidden(t){j.value(this._hidden,t)||(this._hidden=t,this.savePropertyChangeEvent("hidden",t))}get draggable(){return this._draggable}set draggable(t){j.value(this._draggable,t)||(this._draggable=t,this.savePropertyChangeEvent("draggable",t))}get suppressEvents(){return this._suppressEvents}set suppressEvents(t){this._suppressEvents=t}findTopologicalSort(t){const i=[],n=new Map;t.forEach((h,C)=>{n.has(C)||n.set(C,0),h.forEach(F=>{if(n.has(F)){const B=n.get(F);if(B===void 0)throw new Error(`Could not find inDegree for edge ${F}`);n.set(F,B+1)}else n.set(F,1)})});const u=[];for(n.forEach((h,C)=>{h==0&&u.push(C)});u.length>0;){const h=u.shift();if(h===void 0)throw"current vertex is undefined";i.push(h),t.has(h)&&t.get(h)?.forEach(C=>{const F=n.get(C);if(F===void 0)throw new Error(`Could not find inDegree for edge ${C}`);if(n.has(C)&&F>0){const B=F-1;n.set(C,B),B==0&&u.push(C)}})}return i}}class Xs extends re{constructor(t={}){super(t),this.type=at.Composite,this.compositeType="<compositeType>",this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,Fe(this,t)}initialize(){}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){}update(){super.update()}draw(t){super.drawChildren(t)}handleCompositeEvent(t){}}var Pn=(g=>(g[g.MatchConstraint=0]="MatchConstraint",g))(Pn||{});const Yt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class or{constructor(t,i){this.images={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit}initializeImages(t){return this.loadImages(t??[])}async loadImages(t){if(t.length===0)return;this.checkImageNamesForDuplicates(t);const i=t.map(n=>{let u=n.url;n.url&&!q.urlHasScheme(n.url)&&(u=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${n.url}`)),n.dataUrl&&(u=n.dataUrl);const h={imageName:n.imageName,url:u,originalUrl:u,isFallback:!1,localize:n.localize??!1,svgString:n.svgString,canvaskitImage:void 0,width:n.width,height:n.height,status:n.lazy?Yt.Deferred:Yt.Loading};return h.localize&&this.configureImageLocalization(h),this.images[n.imageName]=h,h.status===Yt.Loading?this.renderM2Image(h):Promise.resolve()});await Promise.all(i)}configureImageLocalization(t){t.fallbackLocalizationUrls=new Array,t.originalUrl&&this.game.i18n?.locale&&(t.status="Deferred",this.game.i18n?.fallbackLocale&&this.game.i18n?.fallbackLocale!==this.game.i18n?.baseLocale&&t.fallbackLocalizationUrls.push(this.localizeImageUrl(t.originalUrl,this.game.i18n.fallbackLocale)),this.game.i18n?.locale===this.game.i18n?.baseLocale?t.url=t.originalUrl:t.url=this.localizeImageUrl(t.originalUrl,this.game.i18n.locale),t.url!==t.originalUrl&&t.fallbackLocalizationUrls.push(t.originalUrl),this.game.i18n.missingLocalizationColor&&!this.missingLocalizationImagePaint&&(this.missingLocalizationImagePaint=Ft.makePaint(this.canvasKit,this.game.i18n.missingLocalizationColor,this.canvasKit.PaintStyle.Stroke,!0),this.missingLocalizationImagePaint.setStrokeWidth(4)))}localizeImageUrl(t,i){const n=t.lastIndexOf(".");if(n===-1)throw new Error("URL does not have an extension");return t.slice(0,n)+`.${i}`+t.slice(n)}reinitializeLocalizedImages(){Object.keys(this.game.imageManager.images).forEach(i=>{const n=this.game.imageManager.images[i];n.localize&&this.game.imageManager.configureImageLocalization(n)}),this.game.nodes.filter(i=>i.type===at.Sprite).forEach(i=>{i.needsInitialization=!0})}checkImageNamesForDuplicates(t){const n=(u=>u.filter((h,C)=>u.indexOf(h)!=C))(t.map(u=>u.imageName));if(n.length>0)throw new Error(`image names must be unique. these image names are duplicated within a game ${this.game.id}: `+n.join(", "))}prepareDeferredImage(t){return t.status=Yt.Loading,t.isFallback=!1,this.renderM2Image(t).catch(async()=>{for(t.isFallback=!0;t.fallbackLocalizationUrls?.length;){t.url=t.fallbackLocalizationUrls.shift();try{await this.renderM2Image(t)}catch(i){if(t.fallbackLocalizationUrls.length===0)throw i instanceof Error?i:new Error(`prepareDeferredImage(): unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`)}}})}renderM2Image(t){const i=document.createElement("img"),n=u=>{if(!this.scratchCanvas||!this.ctx||!this.scale)throw new Error("image manager not set up");this.scratchCanvas.width=t.width*this.scale,this.scratchCanvas.height=t.height*this.scale,this.ctx.scale(this.scale,this.scale),this.ctx.clearRect(0,0,t.width,t.height),this.ctx.drawImage(i,0,0,t.width,t.height),this.scratchCanvas.toBlob(h=>{if(!h)throw new Error(`renderM2Image(): blob is undefined for ${t.imageName}`);h.arrayBuffer().then(C=>{const F=this.canvasKit.MakeImageFromEncoded(C);if(!F)throw new Error(`could not create image with name "${t.imageName}."`);console.log(`image loaded. name: ${t.imageName}, w: ${t.width}, h: ${t.height}`),this.images[t.imageName].canvaskitImage=F,this.images[t.imageName].status=Yt.Ready,this.game.nodes.filter(U=>U.type==="Sprite").forEach(U=>{U.imageName===t.imageName&&(U.needsInitialization=!0)}),u()})})};return new Promise((u,h)=>{if(i.width=t.width,i.height=t.height,i.crossOrigin="Anonymous",i.onerror=()=>{h(new Error(`unable to render image named ${t.imageName}. image source was ${t.svgString?"svgString":`url: ${t.url}`}`))},i.onload=()=>{n(u)},!t.svgString&&!t.url)throw new Error(`no svgString or url provided for image named ${t.imageName}`);if(t.svgString&&t.url)throw new Error(`provide svgString or url. both were provided for image named ${t.imageName}`);if(t.svgString){i.src="data:image/svg+xml,"+encodeURIComponent(t.svgString);const C={type:G.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,svgString:t.svgString,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(C)}else t.url&&fetch(t.url).then(C=>C.arrayBuffer()).then(C=>{this.arrayBufferToBase64Async(C).then(F=>{const B=this.inferImageSubtypeFromUrl(t.url);i.src="data:image/"+B+";base64,"+F;const U={type:G.BrowserImageDataReady,target:this,imageName:t.imageName,width:t.width,height:t.height,dataUrl:i.src,...q.createFrameUpdateTimestamps()};this.game.eventStore.addEvent(U)})})})}arrayBufferToBase64Async(t){return new Promise((i,n)=>{const u=new FileReader;u.onload=()=>{i(u.result?.toString().split(",")[1]??"")},u.onerror=n,u.readAsDataURL(new Blob([t]))})}inferImageSubtypeFromUrl(t){if(t?.startsWith("data:image/"))return t.split(";")[0].split("/")[1];let i="jpeg";return t?.includes(".")&&(i=t.split(".").pop()?.toLowerCase()??"jpeg",i===""&&(i="jpeg")),i==="svg"&&(i="svg+xml"),i}getImage(t){return this.images[t]}addImage(t){this.images[t.imageName]=t}get scratchCanvas(){if(!this._scratchCanvas){this._scratchCanvas=document.createElement("canvas"),this._scratchCanvas.id=`m2c2kit-scratch-canvas-${this.game.id}-${Math.floor(Math.random()*1e6)}`,this._scratchCanvas.hidden=!0,document.body.appendChild(this._scratchCanvas);const t=this._scratchCanvas.getContext("2d");if(t===null)throw new Error("could not get 2d canvas context from scratch canvas");this.ctx=t,this.scale=window.devicePixelRatio}return this._scratchCanvas}removeScratchCanvas(){this.ctx=void 0,this._scratchCanvas?.remove()}}class xi{constructor(t,i){this.locale="",this.fallbackLocale="en-US",this.baseLocale="en-US",this.game=t,this._translation=this.mergeAdditionalTranslation(i.translation,i.additionalTranslation)??{},this.translation.configuration?.baseLocale&&(this.baseLocale=this.translation.configuration.baseLocale),i.missingLocalizationColor&&(this.missingLocalizationColor=i.missingLocalizationColor),i.locale&&(this.locale=i.locale),i.fallbackLocale&&(this.fallbackLocale=i.fallbackLocale)}async initialize(){await this.configureInitialLocale()}async configureInitialLocale(){if(this.game.hasDataStores()){const t=await this.game.storeGetItem("locale"),i=await this.game.storeGetItem("fallbackLocale");if(typeof t=="string"&&typeof i=="string"){this.locale=t,this.fallbackLocale=i;return}}if(this.locale?.toLowerCase()==="auto"){const t=this.getEnvironmentLocale();t?this.localeTranslationAvailable(t)?(this.locale=t,this.localeTranslationAvailable(this.fallbackLocale)||(this.fallbackLocale=this.baseLocale)):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but detected locale ${t} does not have translation. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but detected locale ${t} does not have translation, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale):this.fallbackLocale&&this.localeTranslationAvailable(this.fallbackLocale)?(console.warn(`auto locale requested, but environment cannot detect locale. Setting locale to fallback locale ${this.fallbackLocale}`),this.locale=this.fallbackLocale,this.fallbackLocale=this.baseLocale):(console.warn(`auto locale requested, but environment cannot detect locale, and fallback locale does not have translation or was not specified (fallback locale is ${this.fallbackLocale}). Setting locale to base locale ${this.baseLocale}.`),this.locale=this.baseLocale,this.fallbackLocale=this.baseLocale)}else this.locale=this.locale??"",this.fallbackLocale||(this.fallbackLocale=this.baseLocale)}localeTranslationAvailable(t){return this.translation[t]!==void 0||t===this.baseLocale}switchToLocale(t){this.locale=t,this.game.nodes.filter(i=>i.isText).forEach(i=>i.needsInitialization=!0),this.game.imageManager.reinitializeLocalizedImages(),this.game&&this.game.hasDataStores()&&(this.game.storeSetItem("locale",this.locale),this.game.storeSetItem("fallbackLocale",this.fallbackLocale))}getTextLocalization(t,i){let n="",u=!1,h=this.tf(t,i);return h?.text!==void 0?n=h.text:(h=this.tf(t,{useFallbackLocale:!0,...i}),h===void 0||h.text===void 0?n=t:n=h.text,u=!0),{text:n,fontName:h?.fontName,fontNames:h?.fontNames,isFallbackOrMissingTranslation:u}}t(t,i){const{useFallbackLocale:n,...u}=i??{};if(n!==!0){const C=this.translation[this.locale]?.[t];return this.isStringOrTextWithFontCustomization(C)?this.insertInterpolations(this.getKeyText(C),u):void 0}const h=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(h))return this.insertInterpolations(this.getKeyText(h),u)}tf(t,i){const{useFallbackLocale:n,...u}=i??{};if(n!==!0){const C=this.translation[this.locale]?.[t];if(this.isStringOrTextWithFontCustomization(C)){const F=this.getKeyTextAndFont(C,this.locale);return F.text&&(F.text=this.insertInterpolations(F.text,u)),F}return}const h=this.translation[this.fallbackLocale]?.[t];if(this.isStringOrTextWithFontCustomization(h)){const C=this.getKeyTextAndFont(h,this.fallbackLocale);return C.text&&(C.text=this.insertInterpolations(C.text,u)),C}}getKeyText(t){return this.isTextWithFontCustomization(t)?t.text:t}getKeyTextAndFont(t,i){let n=new Array;this.isString(this.translation[i]?.fontName)?n.push(this.translation[i].fontName):this.isStringArray(this.translation[i]?.fontName)?n.push(...this.translation[i].fontName):n.push("default");let u;switch(this.isTextWithFontCustomization(t)?(u=t.text,this.isString(t.additionalFontName)&&n.push(t.additionalFontName),this.isStringArray(t.additionalFontName)&&n.push(...t.additionalFontName),t.overrideFontName&&(n.length=0,this.isString(t.overrideFontName)&&n.push(t.overrideFontName),this.isStringArray(t.overrideFontName)&&n.push(...t.overrideFontName))):u=t,n=n.filter(h=>h!=="default"),n.length){case 0:return{text:u};case 1:return{text:u,fontName:n[0]};default:return{text:u,fontNames:n}}}insertInterpolations(t,i){return i?t.replace(/\{\{(.*?)\}\}/g,(n,u)=>{if(Object.prototype.hasOwnProperty.call(i,u))return i[u];throw new Error(`insertInterpolations(): placeholder "${u}" not found. Text was ${t}, provided interpolation was ${JSON.stringify(i)}`)}):t}get translation(){return this._translation}set translation(t){this._translation=t}getEnvironmentLocale(){return(navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language)??""}mergeAdditionalTranslation(t,i){if(!t&&!i)return;if(!i)return t;if(!t)return i;const n={},u=new Array;for(const h in t)u.push(h),n[h]={...t[h],...i[h]};for(const h in i)u.includes(h)||(n[h]=i[h]);return n}static makeLocalizationParameters(){return JSON.parse(JSON.stringify({locale:{type:["string","null"],default:null,description:'Locale to use for localization, or "auto" to request from the environment.'},fallback_locale:{type:["string","null"],default:null,description:'Locale to use if requested locale translation is not available, or if "auto" locale was requested and environment cannot provide a locale.'},missing_localization_color:{type:["array","null"],default:null,description:"Font color for strings that are missing translation and outline color for images that are missing localization, [r,g,b,a].",items:{type:"number"}},translation:{type:["object","null"],default:null,description:"Additional translation for localization."}}))}isTextWithFontCustomization(t){return t?.text!==void 0}isStringOrTextWithFontCustomization(t){return typeof t=="string"||this.isTextWithFontCustomization(t)}isStringArray(t){return Array.isArray(t)&&t.every(i=>typeof i=="string")}isString(t){return typeof t=="string"}}const ce={Disabled:"Disabled",Record:"Record",Replay:"Replay"};class An{constructor(){this.events=new Array,this.replayBeginTimestamp=NaN,this.firstTimestamp=NaN,this.replayThoughSequence=Number.MAX_VALUE,this.serializedEventsBeforeReplay="",this.mode=ce.Disabled}serializeEvent(t){const i=t.target;if(t.type===G.NodeNew&&t.nodeOptions?.layout?.constraints!==void 0){const u=t.nodeOptions?.layout?.constraints,h={};for(const F in u){if(F==="horizontalBias"||F==="verticalBias"){h[F]=u[F];continue}const B=u[F];B instanceof re&&(h[F]=B.uuid)}t.target=i.uuid,t.nodeOptions.layout.constraints=h;const C=JSON.stringify(t);return t.target=i,t.nodeOptions.layout.constraints=u,C}if(i instanceof re){t.target=i.uuid;const u=JSON.stringify(t);return t.target=i,u}if(i instanceof Element){t.target=i.nodeName;const u=JSON.stringify(t);return t.target=i,u}if(i instanceof or){t.target="ImageManager";const u=JSON.stringify(t);return t.target=i,u}if(i instanceof xi){t.target="I18n";const u=JSON.stringify(t);return t.target=i,u}t.target="object";const n=JSON.stringify(t);return t.target=i,n}addEvent(t){if(this.mode===ce.Record){t.sequence===void 0&&(t.sequence=m2c2Globals.eventSequence);const i=this.serializeEvent(t);this.events.push(JSON.parse(i))}}addEvents(t){t.forEach(i=>{this.addEvent(i)})}clearEvents(){this.events=[]}record(){this.mode=ce.Record}replay(t){if(t&&(this.events=t),this.events.length===0)if(this.serializedEventsBeforeReplay!=="")this.events=JSON.parse(this.serializedEventsBeforeReplay);else{console.log("Event store has no events to replay.");return}this.mode=ce.Replay,this.replayBeginTimestamp=Wt.now(),this.sortEventStore(this.events),this.serializedEventsBeforeReplay===""&&(this.serializedEventsBeforeReplay=JSON.stringify(this.events)),this.firstTimestamp=this.events[0].timestamp,console.log(`Event store has ${this.events.length} events. Replay beginning.`);const i=document.getElementById("sequence-number");i&&(this.replayThoughSequence=parseInt(i.value))}getEvents(){return this.sortEventStore(this.events),this.events}dequeueEvents(t){const i=new Array,n=t-this.replayBeginTimestamp+this.firstTimestamp;for(;this.events.length>0&&this.events[0].timestamp<=n;){const u=this.events.shift();if(!u)throw new Error("EventStore.dequeueEvents(): undefined event");u.sequence!==void 0&&u.sequence>this.replayThoughSequence||i.push(u)}return i}get eventQueueLength(){return this.events.length}sortEventStore(t){t.sort((i,n)=>{if(i.sequence===void 0||n.sequence===void 0)throw new Error("EventStore.sortEventStore(): undefined sequence");return i.sequence!==n.sequence?i.sequence-n.sequence:0})}}var ze=(g=>(g[g.Center=0]="Center",g[g.Left=1]="Left",g[g.Right=2]="Right",g))(ze||{});const Xt={Deferred:"Deferred",Loading:"Loading",Ready:"Ready",Error:"Error"};class ki extends re{constructor(t={}){super(t),this.type=at.Label,this.isDrawable=!0,this.isText=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._text="",this._fontColor=X.DEFAULT_FONT_COLOR,this._fontSize=X.DEFAULT_FONT_SIZE,this._interpolation={},this._horizontalAlignmentMode=ze.Center,this._localize=!0,this.localizedFontNames=[],Fe(this,t),t.horizontalAlignmentMode&&(this.horizontalAlignmentMode=t.horizontalAlignmentMode),t.preferredMaxLayoutWidth!==void 0&&(this.preferredMaxLayoutWidth=t.preferredMaxLayoutWidth),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),t.fontNames&&(this.fontNames=t.fontNames),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,fontNames:this.fontNames}}initialize(){let t=this.canvasKit.TextAlign.Center;switch(this.horizontalAlignmentMode){case ze.Center:t=this.canvasKit.TextAlign.Center;break;case ze.Left:t=this.canvasKit.TextAlign.Left;break;case ze.Right:t=this.canvasKit.TextAlign.Right;break;default:throw new Error("unknown horizontalAlignmentMode")}this.text||(this.text="");let i=this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3]),n;const u=this.game.i18n;if(u&&this.localize!==!1){const U=u.getTextLocalization(this.text,this.interpolation);n=U.text,this.localizedFontName=U.fontName,this.localizedFontNames=U.fontNames??[],U.isFallbackOrMissingTranslation&&u.missingLocalizationColor&&(i=this.canvasKit.Color(u.missingLocalizationColor[0],u.missingLocalizationColor[1],u.missingLocalizationColor[2],u.missingLocalizationColor[3]))}else n=this.text;if(this.fontName&&this.fontNames)throw new Error("cannot specify both fontName and fontNames");const h=this.game.fontManager,C=this.getRequiredLabelFonts(h);if(C.forEach(U=>{if(U.status===Xt.Deferred){h.prepareDeferredFont(U);return}}),!C.every(U=>U.status===Xt.Ready))return;this.paraStyle=new this.canvasKit.ParagraphStyle({textStyle:{},textAlign:t}),this.builder&&this.builder.delete(),this.builder=this.canvasKit.ParagraphBuilder.MakeFromFontProvider(this.paraStyle,h.provider),this._backgroundPaint||(this._backgroundPaint=new this.canvasKit.Paint),this._fontPaint||(this._fontPaint=new this.canvasKit.Paint),this.fontPaint.setColor(i),this.fontPaint.setAlphaf(this.absoluteAlpha),this.backgroundColor?(this.backgroundPaint.setColor(this.backgroundColor),this.backgroundPaint.setAlphaf(this.absoluteAlpha)):this.backgroundPaint.setColor(this.canvasKit.Color(0,0,0,0)),this.builder.pushPaintStyle({fontFamilies:C.map(U=>U.fontName),fontSize:this.fontSize*m2c2Globals.canvasScale,fontStyle:{weight:this.canvasKit.FontWeight.Normal,width:this.canvasKit.FontWidth.Normal,slant:this.canvasKit.FontSlant.Oblique},decoration:0,decorationThickness:1,decorationStyle:this.canvasKit.DecorationStyle.Solid,heightMultiplier:-1,halfLeading:!1,letterSpacing:0,wordSpacing:0},this.fontPaint,this.backgroundPaint),this.builder.addText(n),this.paragraph&&this.paragraph.delete(),this.paragraph=this.builder.build();const F=this.preferredMaxLayoutWidth??m2c2Globals.canvasCssWidth;let B=F;if(F===0||this.layout.width===0){if(this.parent===void 0)throw new Error("width is set to match parent, but node has no parent");const U=this.layout.marginStart??0,et=this.layout.marginEnd??0;B=this.parent.size.width-(U+et)}this.paragraph.layout(B*m2c2Globals.canvasScale),F===0||this.layout.width===0?this.size.width=B:(this.paragraph.layout(Math.ceil(this.paragraph.getLongestLine())),this.size.width=this.paragraph.getMaxWidth()/m2c2Globals.canvasScale),this.size.height=this.paragraph.getHeight()/m2c2Globals.canvasScale,this.needsInitialization=!1}getRequiredLabelFonts(t){let i;if(this.game.i18n&&this.localize!==!1){if(this.localizedFontName)return i=[t.fonts[this.localizedFontName]],i;if(this.localizedFontNames.length>0)return i=this.localizedFontNames.map(n=>t.fonts[n]),i}if(this.fontName===void 0&&this.fontNames===void 0)i=[t.getDefaultFont()];else if(this.fontName!==void 0)i=[t.fonts[this.fontName]];else if(this.fontNames!==void 0&&this.fontNames.length>0)i=this.fontNames.map(n=>t.fonts[n]);else throw new Error("cannot determine required fonts");return i}dispose(){Ft.Dispose([this.paragraph,this.builder,this._fontPaint,this._backgroundPaint])}get text(){return this._text}set text(t){j.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get interpolation(){return this._interpolation}set interpolation(t){j.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get fontName(){return this._fontName}set fontName(t){j.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontNames(){return this._fontNames}set fontNames(t){j.value(this._fontNames,t)||(this._fontNames=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontNames",t))}get fontColor(){return this._fontColor}set fontColor(t){j.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){j.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get horizontalAlignmentMode(){return this._horizontalAlignmentMode}set horizontalAlignmentMode(t){j.value(this._horizontalAlignmentMode,t)||(this._horizontalAlignmentMode=t,this.needsInitialization=!0,this.savePropertyChangeEvent("horizontalAlignmentMode",t))}get preferredMaxLayoutWidth(){return this._preferredMaxLayoutWidth}set preferredMaxLayoutWidth(t){j.value(this._preferredMaxLayoutWidth,t)||(this._preferredMaxLayoutWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("preferredMaxLayoutWidth",t))}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){j.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get localize(){return this._localize}set localize(t){j.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}get backgroundPaint(){if(!this._backgroundPaint)throw new Error("backgroundPaint cannot be undefined");return this._backgroundPaint}set backgroundPaint(t){this._backgroundPaint=t}get fontPaint(){if(!this._fontPaint)throw new Error("fontPaint cannot be undefined");return this._fontPaint}set fontPaint(t){this._fontPaint=t}duplicate(t){const i=new ki({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),horizontalAlignmentMode:this.horizontalAlignmentMode,preferredMaxLayoutWidth:this.preferredMaxLayoutWidth,backgroundColor:this.backgroundColor,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update(),this.absoluteAlphaChange!==0&&this.initialize()}draw(t){if(this.parent&&this.text!==""&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,u=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paragraph===void 0)throw new Error("no paragraph");t.drawParagraph(this.paragraph,n,u),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const u=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=u.fontName,this.localizedFontNames=u.fontNames??[]}if(!this.getRequiredLabelFonts(this.game.fontManager).some(u=>u.status===Xt.Deferred)&&Object.keys(this.layout).length===0){if(this.initialize(),!this.paragraph)throw new Error(`warmup Label node ${this.toString()}: paragraph is undefined`);t.drawParagraph(this.paragraph,0,0)}}}class Ue extends re{constructor(t={}){super(t),this.type=at.Scene,this.isDrawable=!0,this._anchorPoint={x:0,y:0},this._zPosition=0,this._backgroundColor=X.DEFAULT_SCENE_BACKGROUND_COLOR,this._active=!1,this._transitioning=!1,Fe(this,t),t.backgroundColor&&(this.backgroundColor=t.backgroundColor),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor}}initialize(){this.scale=m2c2Globals.rootScale,this.size.width=this.game.canvasCssWidth,this.size.height=this.game.canvasCssHeight,this.backgroundPaint&&this.backgroundPaint.delete(),this.backgroundPaint=Ft.makePaint(this.canvasKit,this.backgroundColor,this.canvasKit.PaintStyle.Fill,!1),this.needsInitialization=!1}dispose(){Ft.Dispose([this.backgroundPaint])}set game(t){this._game=t}get game(){if(this._game===void 0)throw new Error(`Scene ${this} has not been added to a game.`);return this._game}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){j.value(this._backgroundColor,t)||(this._backgroundColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("backgroundColor",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}duplicate(t){const i=new Ue({...this.getNodeOptions(),...this.getDrawableOptions(),backgroundColor:this.backgroundColor,name:t});return i.game=this.game,this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}onSetup(t,i){this.addEventListener("SceneSetup",t,i)}onAppear(t,i){this.addEventListener("SceneAppear",t,i)}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);this.absoluteAlphaChange!==0&&this.backgroundPaint.setAlphaf(this.absoluteAlpha),t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),super.drawChildren(t)}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;if(t.scale(1/i,1/i),!this.backgroundPaint)throw new Error(`in Scene ${this}, background paint is undefined.`);t.drawRect([this.position.x*i*m2c2Globals.rootScale,this.position.y*i*m2c2Globals.rootScale,(this.position.x+this.size.width)*i*m2c2Globals.rootScale,(this.position.y+this.size.height)*i*m2c2Globals.rootScale],this.backgroundPaint),t.restore(),this.children.forEach(n=>{n.isDrawable&&n.warmup(t)})}}class ai extends re{constructor(t={}){if(super(t),this.type=at.Shape,this.isDrawable=!0,this.isShape=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this.shapeType=Ut.Undefined,this.ckPath=null,this._cornerRadius=0,this._fillColor=X.DEFAULT_SHAPE_FILL_COLOR,this._isAntialiased=!0,this.svgPathScaleForResizing=1,this.svgPathWidth=0,this.svgPathHeight=0,this.svgPreviousAbsoluteX=NaN,this.svgPreviousAbsoluteY=NaN,this.svgFirstPathDraw=!0,this.colorfulPathPaints=new Map,Fe(this,t),t.path!==void 0){if(this.path=t.path,this.shapeType=Ut.Path,this.shapeIsM2Path()&&t.size!==void 0&&(this.size=t.size),this.shapeIsSvgStringPath()&&t.size!==void 0)throw new Error("Size cannot be specified when path is SVG string path");if(this.svgPathRequestedWidth=t.path.width,this.svgPathRequestedHeight=t.path.height,this.svgPathRequestedHeight!==void 0&&this.svgPathRequestedWidth!==void 0)throw new Error("Cannot specify both width and height for SVG string path.");if(this.strokeColor||(this.strokeColor=X.DEFAULT_PATH_STROKE_COLOR),this.lineWidth===void 0&&(this.lineWidth=X.DEFAULT_PATH_LINE_WIDTH),t.circleOfRadius||t.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect")}if(t.circleOfRadius!==void 0){if(this.circleOfRadius=t.circleOfRadius,this.shapeType=Ut.Circle,t.size!==void 0)throw new Error("Size cannot be specified for circle shape");if(t.path||t.rect)throw new Error("Shape must specify only one of: path, circleOfRadius, or rect");this.size.width=this.circleOfRadius*2,this.size.height=this.circleOfRadius*2}if(t.rect&&(this.rect=t.rect,t.rect.size?(this.size.width=t.rect.size.width,this.size.height=t.rect.size.height):t.rect.width!==void 0&&t.rect.height!==void 0&&(this.size.width=t.rect.width,this.size.height=t.rect.height),t.rect.origin?this.position=t.rect.origin:t.rect.x!==void 0&&t.rect.y!==void 0&&(this.position={x:t.rect.x,y:t.rect.y}),this.shapeType=Ut.Rectangle,t.size!==void 0))throw new Error("Size cannot be specified for rectangle shape");t.cornerRadius!==void 0&&(this.cornerRadius=t.cornerRadius),t.fillColor&&(this.fillColor=t.fillColor),t.strokeColor&&(this.strokeColor=t.strokeColor),t.lineWidth!==void 0&&(this.lineWidth=t.lineWidth),t.isAntialiased!==void 0&&(this.isAntialiased=t.isAntialiased),t.strokeColor&&!t.lineWidth&&console.warn(`warning: for node ${this}, strokeColor = ${t.strokeColor} but lineWidth is non-zero. In normal usage, both would be set or both would be undefined.`),t.strokeColor===void 0&&t.lineWidth&&console.warn(`warning: for node ${this}, lineWidth = ${t.lineWidth} but strokeColor is undefined. In normal usage, both would be set or both would be undefined.`),this.saveNodeNewEvent()}get completeNodeOptions(){let t;return this.shapeIsM2Path()&&(t=this.size),{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,path:this.path,size:t,isAntialiased:this.isAntialiased}}initialize(){if(this.shapeType===Ut.Path&&this.shapeIsSvgStringPath()){const t=this.path.pathString??this.path.svgPathString;if(!t)throw new Error("SVG Path string is null/undefined");if(this.path.svgPathString!==void 0&&console.warn("warning: svgPathString is deprecated. Use pathString instead."),this.ckPath=this.canvasKit.Path.MakeFromSVGString(t),!this.ckPath)throw new Error("could not make CanvasKit Path from SVG string");const i=this.ckPath.getBounds();this.svgPathWidth=i[2]+(i[0]<0?Math.abs(i[0]):0),this.svgPathHeight=i[3]+(i[1]<0?Math.abs(i[1]):0),this.svgPathRequestedHeight!==void 0?this.svgPathScaleForResizing=this.svgPathRequestedHeight/this.svgPathHeight:this.svgPathRequestedWidth!==void 0&&(this.svgPathScaleForResizing=this.svgPathRequestedWidth/this.svgPathWidth),this.size.width=this.svgPathWidth*this.svgPathScaleForResizing,this.size.height=this.svgPathHeight*this.svgPathScaleForResizing,this.svgPreviousAbsoluteX=0,this.svgPreviousAbsoluteY=0}if(this.shapeIsM2Path()&&(this.size.width===0||this.size.height===0||this.size.width===void 0||this.size.height===void 0))throw new Error("Size of shape must have non-zero height and width when path is M2Path");this.fillColor&&(this.fillColorPaintAntialiased=Ft.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!0),this.fillColorPaintNotAntialiased=Ft.makePaint(this.canvasKit,this.fillColor,this.canvasKit.PaintStyle.Fill,!1)),this.strokeColor&&(this.strokeColorPaintAntialiased=Ft.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!0),this.strokeColorPaintNotAntialiased=Ft.makePaint(this.canvasKit,this.strokeColor,this.canvasKit.PaintStyle.Stroke,!1)),this.svgFirstPathDraw=!0,this.needsInitialization=!1}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Ft.Dispose([this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased,this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this.ckPath,...Array.from(this.colorfulPathPaints.values())])}duplicate(t){const i=new ai({...this.getNodeOptions(),...this.getDrawableOptions(),shapeType:this.shapeType,circleOfRadius:this.circleOfRadius,rect:this.rect,cornerRadius:this.cornerRadius,fillColor:this.fillColor,strokeColor:this.strokeColor,lineWidth:this.lineWidth,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this),this.absoluteAlphaChange!==0&&this.applyAlphaToPaints(this.absoluteAlpha,[this._fillColorPaintAntialiased,this._fillColorPaintNotAntialiased,this._strokeColorPaintAntialiased,this._strokeColorPaintNotAntialiased]),this.shapeIsM2Path()&&this.drawPathFromM2Path(t),this.shapeIsSvgStringPath()&&this.drawPathFromSvgString(t),this.shapeType===Ut.Circle&&this.drawCircle(t),this.shapeType===Ut.Rectangle&&this.drawRectangle(t),t.restore(),super.drawChildren(t)}applyAlphaToPaints(t,i){i.forEach(n=>{n&&n.setAlphaf(t)})}drawPathFromM2Path(t){const i=m2c2Globals.canvasScale/this.absoluteScale,n=(this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*i,u=(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*i;if(this.pathIsM2ColorfulPath(this.path)){const h=this.path.linePresentations;let C=0;const F=this.path.subpaths;let B;for(let U=0;U<F.length;U++){const ct=F[U].flat();for(let ut=0;ut<ct.length-1;ut++){if(h[C].subpathIndex===U&&h[C].pointIndex===ut){const At=h[C].strokeColor,yt=h[C].lineWidth,ne=[...At,yt].toString();B=this.colorfulPathPaints.get(ne),B===void 0&&(B=Ft.makePaint(this.canvasKit,At,this.canvasKit.PaintStyle.Stroke,!0),B.setStrokeWidth(yt*m2c2Globals.canvasScale),this.colorfulPathPaints.set(ne,B)),C<h.length-1&&C++}if(B===void 0)throw new Error("paint is undefined");t.drawLine(n+ct[ut].x*m2c2Globals.canvasScale,u+ct[ut].y*m2c2Globals.canvasScale,n+ct[ut+1].x*m2c2Globals.canvasScale,u+ct[ut+1].y*m2c2Globals.canvasScale,B)}}return}if(this.strokeColor&&this.strokeColorPaintAntialiased&&this.lineWidth){this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*m2c2Globals.canvasScale);const h=this.path.subpaths;for(const C of h){const F=C.flat();for(let B=0;B<F.length-1;B++)t.drawLine(n+F[B].x*m2c2Globals.canvasScale,u+F[B].y*m2c2Globals.canvasScale,n+F[B+1].x*m2c2Globals.canvasScale,u+F[B+1].y*m2c2Globals.canvasScale,this.strokeColorPaintAntialiased)}}}drawPathFromSvgString(t){if(!this.ckPath)return;const i=this.calculateSvgPathX(),n=this.calculateSvgPathY();if(this.pathNeedsTransform(i,n)){const h=m2c2Globals.canvasScale/this.absoluteScale*this.svgPathScaleForResizing*m2c2Globals.rootScale,C=this.calculateTransformationMatrix(h,i,n);this.ckPath=this.ckPath.transform(C),this.saveSvgPathAbsolutePosition(i,n)}if(this.fillColor){const u=this.getFillPaint();t.drawPath(this.ckPath,u)}if(this.strokeColor&&this.lineWidth){const u=this.getStrokePaint(this.lineWidth);t.drawPath(this.ckPath,u)}}calculateSvgPathY(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.y-this.size.height*this.absoluteScale/2)*t}calculateSvgPathX(){const t=m2c2Globals.canvasScale/this.absoluteScale;return(this.absolutePosition.x-this.size.width*this.absoluteScale/2)*t}saveSvgPathAbsolutePosition(t,i){this.svgPreviousAbsoluteX=t,this.svgPreviousAbsoluteY=i}calculateTransformationMatrix(t,i,n){let u;this.svgFirstPathDraw?(u=t,this.svgFirstPathDraw=!1):u=1;const h=i-this.svgPreviousAbsoluteX,C=n-this.svgPreviousAbsoluteY;return[u,0,h,0,u,C,0,0,1]}pathNeedsTransform(t,i){return this.svgFirstPathDraw===!0||t!==this.svgPreviousAbsoluteX||i!==this.svgPreviousAbsoluteY}shapeIsSvgStringPath(){return this.path?.pathString!==void 0||this.path?.svgPathString!==void 0}shapeIsM2Path(){return this.path?.subpaths!==void 0}pathIsM2ColorfulPath(t){return t!==void 0&&"linePresentations"in t}drawCircle(t){if(this.circleOfRadius){if(this.fillColor){const i=this.getFillPaint();this.drawCircleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawCircleWithCanvasKit(t,i)}}}drawRectangle(t){if(this.fillColor){const i=this.getFillPaint();this.drawRectangleWithCanvasKit(t,i)}if(this.strokeColor&&this.lineWidth){const i=this.getStrokePaint(this.lineWidth);this.drawRectangleWithCanvasKit(t,i)}}drawCircleWithCanvasKit(t,i){if(!this.circleOfRadius)return;const n=m2c2Globals.canvasScale/this.absoluteScale,u=this.absolutePosition.x*n,h=this.absolutePosition.y*n,C=this.circleOfRadius*this.absoluteScale*n;t.drawCircle(u,h,C,i)}drawRectangleWithCanvasKit(t,i){const n=this.calculateCKRoundedRectangle();t.drawRRect(n,i)}calculateCKRoundedRectangle(){const t=m2c2Globals.canvasScale/this.absoluteScale;return this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*t,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*t,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*t),this.cornerRadius*t,this.cornerRadius*t)}getFillPaint(){return this.involvedInActionAffectingAppearance()?this.fillColorPaintNotAntialiased:this.isAntialiased?this.fillColorPaintAntialiased:this.fillColorPaintNotAntialiased}getStrokePaint(t){let i;this.involvedInActionAffectingAppearance()?i=this.strokeColorPaintNotAntialiased:i=this.isAntialiased?this.strokeColorPaintAntialiased:this.strokeColorPaintNotAntialiased;const n=m2c2Globals.canvasScale/this.absoluteScale;return i.setStrokeWidth(t*n),i}warmup(t){this.initialize(),t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),this.shapeType===Ut.Circle&&(this.fillColor&&this.warmupFilledCircle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedCircle(t)),this.shapeType===Ut.Rectangle&&(this.fillColor&&this.warmupFilledRectangle(t),this.strokeColor&&this.lineWidth&&this.warmupStrokedRectangle(t)),t.restore(),this.children.forEach(n=>{n.isDrawable&&n.warmup(t)})}warmupFilledCircle(t){this.circleOfRadius&&(this.drawCircleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawCircleWithCanvasKit(t,this.fillColorPaintNotAntialiased))}warmupStrokedCircle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawCircleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}warmupFilledRectangle(t){this.drawRectangleWithCanvasKit(t,this.fillColorPaintAntialiased),this.drawRectangleWithCanvasKit(t,this.fillColorPaintNotAntialiased)}warmupStrokedRectangle(t){if(!this.lineWidth||!this.circleOfRadius)return;const i=m2c2Globals.canvasScale/this.absoluteScale;this.strokeColorPaintAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintAntialiased),this.strokeColorPaintNotAntialiased.setStrokeWidth(this.lineWidth*i),this.drawRectangleWithCanvasKit(t,this.strokeColorPaintNotAntialiased)}get circleOfRadius(){return this._circleOfRadius}set circleOfRadius(t){j.value(t,this._circleOfRadius)||(this._circleOfRadius=t,this.needsInitialization=!0,this.savePropertyChangeEvent("circleOfRadius",t))}get rect(){return this._rect}set rect(t){j.value(t,this._rect)||(this._rect=t,this.needsInitialization=!0,this.savePropertyChangeEvent("rect",t))}get cornerRadius(){return this._cornerRadius}set cornerRadius(t){j.value(t,this._cornerRadius)||(this._cornerRadius=t??0,this.needsInitialization=!0,this.savePropertyChangeEvent("cornerRadius",t??0))}get lineWidth(){return this._lineWidth}set lineWidth(t){j.value(t,this._lineWidth)||(this._lineWidth=t,this.needsInitialization=!0,this.savePropertyChangeEvent("lineWidth",t))}get path(){return this._path}set path(t){j.value(t,this._path)||(this._path=t,this.needsInitialization=!0,this.savePropertyChangeEvent("path",t))}get fillColor(){return this._fillColor}set fillColor(t){j.value(t,this._fillColor)||(this._fillColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fillColor",t))}get strokeColor(){return this._strokeColor}set strokeColor(t){j.value(t,this._strokeColor)||(this._strokeColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("strokeColor",t))}get isAntialiased(){return this._isAntialiased}set isAntialiased(t){j.value(t,this._isAntialiased)||(this._isAntialiased=t,this.needsInitialization=!0,this.savePropertyChangeEvent("isAntialiased",t))}get fillColorPaintAntialiased(){if(!this._fillColorPaintAntialiased)throw new Error("fillColorPaintAntiAliased is undefined");return this._fillColorPaintAntialiased}set fillColorPaintAntialiased(t){this._fillColorPaintAntialiased=t}get strokeColorPaintAntialiased(){if(!this._strokeColorPaintAntialiased)throw new Error("strokeColorPaintAntiAliased is undefined");return this._strokeColorPaintAntialiased}set strokeColorPaintAntialiased(t){this._strokeColorPaintAntialiased=t}get fillColorPaintNotAntialiased(){if(!this._fillColorPaintNotAntialiased)throw new Error("fillColorPaintNotAntiAliased is undefined");return this._fillColorPaintNotAntialiased}set fillColorPaintNotAntialiased(t){this._fillColorPaintNotAntialiased=t}get strokeColorPaintNotAntialiased(){if(!this._strokeColorPaintNotAntialiased)throw new Error("strokeColorPaintNotAntiAliased is undefined");return this._strokeColorPaintNotAntialiased}set strokeColorPaintNotAntialiased(t){this._strokeColorPaintNotAntialiased=t}}class Oi extends re{constructor(t={}){super(t),this.type=at.TextLine,this.isDrawable=!0,this.isText=!0,this._zPosition=0,this._anchorPoint={x:0,y:.5},this._text="",this._fontColor=X.DEFAULT_FONT_COLOR,this._fontSize=X.DEFAULT_FONT_SIZE,this._interpolation={},this._localize=!0,this.typeface=null,this.tryMissingTranslationPaint=!1,this.textForDraw="",this.localizedFontNames=[],Fe(this,t),this.size.height=this.fontSize,this.size.width=t.width??NaN,this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width}}initialize(){const t=this.game.i18n;if(this.tryMissingTranslationPaint=!1,t&&this.localize!==!1){const n=t.getTextLocalization(this.text,this.interpolation);this.textForDraw=n.text,this.localizedFontName=n.fontName,this.localizedFontNames=n.fontNames??[],n.isFallbackOrMissingTranslation&&(this.tryMissingTranslationPaint=!0)}else this.textForDraw=this.text;const i=this.game.fontManager;if(this.fontForDraw=this.getRequiredTextLineFont(i),this.fontForDraw.status===Xt.Deferred){i.prepareDeferredFont(this.fontForDraw);return}this.fontForDraw.status!==Xt.Loading&&(this.createFontPaint(t),this.createFont(i),this.needsInitialization=!1)}getRequiredTextLineFont(t){if(this.game.i18n){if(this.localizedFontName!==void 0&&this.localizedFontNames.length!==0||this.localizedFontNames.length>1)throw new Error("TextLine supports only one font, but multiple fonts are specified in translation.");if(this.localizedFontName!==void 0)return t.fonts[this.localizedFontName];if(this.localizedFontNames.length==1)return t.fonts[this.localizedFontNames[0]]}return this.fontName===void 0?t.getDefaultFont():t.getFont(this.fontName)}createFontPaint(t){this.paint&&this.paint.delete(),this.paint=new this.canvasKit.Paint,this.tryMissingTranslationPaint&&this.localize!==!1?t?.missingLocalizationColor&&this.paint.setColor(this.canvasKit.Color(t.missingLocalizationColor[0],t.missingLocalizationColor[1],t.missingLocalizationColor[2],t.missingLocalizationColor[3])):this.paint.setColor(this.canvasKit.Color(this.fontColor[0],this.fontColor[1],this.fontColor[2],this.fontColor[3])),this.paint.setStyle(this.canvasKit.PaintStyle.Fill),this.paint.setAntiAlias(!0)}createFont(t){if(this.fontForDraw)this.typeface=t.getTypeface(this.fontForDraw.fontName);else{const i=t.getFontNames();i.length>0&&(this.typeface=t.getTypeface(i[0]))}this.font&&this.font.delete(),this.font=new this.canvasKit.Font(this.typeface,this.fontSize*m2c2Globals.canvasScale)}get text(){return this._text}set text(t){j.value(this._text,t)||(this._text=t,this.needsInitialization=!0,this.savePropertyChangeEvent("text",t))}get fontName(){return this._fontName}set fontName(t){j.value(this._fontName,t)||(this._fontName=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontName",t))}get fontColor(){return this._fontColor}set fontColor(t){j.value(this._fontColor,t)||(this._fontColor=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontColor",t))}get fontSize(){return this._fontSize}set fontSize(t){j.value(this._fontSize,t)||(this._fontSize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("fontSize",t))}get interpolation(){return this._interpolation}set interpolation(t){j.value(this._interpolation,t)||(this._interpolation=t,Object.freeze(this._interpolation),this.needsInitialization=!0,this.savePropertyChangeEvent("interpolation",t))}get localize(){return this._localize}set localize(t){j.value(this._localize,t)||(this._localize=t,this.needsInitialization=!0,this.savePropertyChangeEvent("localize",t))}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}dispose(){Ft.Dispose([this.font,this.typeface,this.paint])}duplicate(t){const i=new Oi({...this.getNodeOptions(),...this.getDrawableOptions(),...this.getTextOptions(),width:this.size.width,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){if(this.parent&&this.text&&!this.needsInitialization){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=this.absolutePosition.x*i,u=(this.absolutePosition.y+this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.paint===void 0||this.font===void 0)throw new Error(`in TextLine node ${this}, Paint or Font is undefined.`);this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),t.drawText(this.textForDraw,n,u,this.paint,this.font),t.restore()}super.drawChildren(t)}warmup(t){const i=this.game.i18n;if(i&&this.localize!==!1){const u=i.getTextLocalization(this.text,this.interpolation);this.localizedFontName=u.fontName,this.localizedFontNames=u.fontNames??[]}if(this.getRequiredTextLineFont(this.game.fontManager).status!==Xt.Deferred){if(this.initialize(),this.paint===void 0||this.font===void 0)throw new Error(`warmup TextLine node ${this.toString()}: Paint or Font is undefined.`);t.drawText(this.text,0,0,this.paint,this.font)}}}class oi extends re{constructor(t={}){super(t),this.type=at.Sprite,this.isDrawable=!0,this._anchorPoint={x:.5,y:.5},this._zPosition=0,this._imageName="",Fe(this,t),t.imageName!==void 0&&(this.imageName=t.imageName),this.saveNodeNewEvent()}get completeNodeOptions(){return{...this.options,...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName}}initialize(){if(this.m2Image=this.game.imageManager.getImage(this._imageName),!this.m2Image)throw new Error(`could not create sprite. the image named ${this._imageName} has not been loaded`);this.size.width=this.m2Image.width,this.size.height=this.m2Image.height,this._paint||(this.paint=new this.canvasKit.Paint),this.needsInitialization=!1}dispose(){Ft.Dispose([this.m2Image?.canvaskitImage,this._paint])}get imageName(){return this._imageName}set imageName(t){j.value(this._imageName,t)||(this._imageName=t,this.needsInitialization=!0)}get anchorPoint(){const t=this;return{get x(){return t._anchorPoint.x},set x(i){j.value(t._anchorPoint.x,i)||(t._anchorPoint.x=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))},get y(){return t._anchorPoint.y},set y(i){j.value(t._anchorPoint.y,i)||(t._anchorPoint.y=i,t.savePropertyChangeEvent("anchorPoint",t.anchorPoint))}}}set anchorPoint(t){j.value(this._anchorPoint,t)||(this._anchorPoint=t,this.savePropertyChangeEvent("anchorPoint",this.anchorPoint))}get zPosition(){return this._zPosition}set zPosition(t){j.value(this._zPosition,t)||(this._zPosition=t,this.savePropertyChangeEvent("zPosition",t))}set paint(t){this._paint=t}get paint(){if(!this._paint)throw new Error(`in paint getter: Sprite node ${this.toString()} paint is undefined.`);return this._paint}duplicate(t){const i=new oi({...this.getNodeOptions(),...this.getDrawableOptions(),imageName:this.imageName,name:t});return this.children.length>0&&(i.children=this.children.map(n=>{const u=n.duplicate();return u.parent=i,u})),i}update(){super.update()}draw(t){if(!this.hidden){if(this.m2Image){t.save();const i=m2c2Globals.canvasScale/this.absoluteScale;t.scale(1/i,1/i),q.rotateCanvasForDrawableNode(t,this);const n=(this.absolutePosition.x-this.size.width*this.anchorPoint.x*this.absoluteScale)*i,u=(this.absolutePosition.y-this.size.height*this.anchorPoint.y*this.absoluteScale)*i;if(this.absoluteAlphaChange!==0&&this.paint.setAlphaf(this.absoluteAlpha),this.m2Image.status===Yt.Ready&&this.m2Image.canvaskitImage)this.m2Image.isFallback&&this.drawFallbackImageBorder(t),t.drawImage(this.m2Image.canvaskitImage,n,u,this.paint);else if(this.m2Image.status===Yt.Deferred&&(console.log(`begin loading lazy image ${this.m2Image.imageName} for Sprite node ${this.toString()}`),this.game.imageManager.prepareDeferredImage(this.m2Image)),this.m2Image.status===Yt.Error)throw new Error(`error status on image ${this.m2Image.imageName} for Sprite node ${this.toString()}`);t.restore()}super.drawChildren(t)}}warmup(t){if(this.m2Image?.status===Yt.Ready){if(this.initialize(),!this.m2Image)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()}: image not loaded.`);if(!this.m2Image.canvaskitImage)throw new Error(`in Sprite.warmup(): Sprite node ${this.toString()} image ${this.m2Image.imageName} is undefined.`);t.drawImage(this.m2Image.canvaskitImage,0,0)}this.children.forEach(i=>{i.isDrawable&&i.warmup(t)})}drawFallbackImageBorder(t){const i=this.game.imageManager.missingLocalizationImagePaint;if(!i)return;const n=m2c2Globals.canvasScale/this.absoluteScale,u=this.canvasKit.RRectXY(this.canvasKit.LTRBRect((this.absolutePosition.x-this.anchorPoint.x*this.size.width*this.absoluteScale)*n,(this.absolutePosition.y-this.anchorPoint.y*this.size.height*this.absoluteScale)*n,(this.absolutePosition.x+this.size.width*this.absoluteScale-this.anchorPoint.x*this.size.width*this.absoluteScale)*n,(this.absolutePosition.y+this.size.height*this.absoluteScale-this.anchorPoint.y*this.size.height*this.absoluteScale)*n),0,0);t.drawRRect(u,i)}}class Cn{constructor(){q.registerM2NodeClass(ki,ai,oi,Ue,Oi)}createNode(t,i,n){const u=i||t;if(!this.hasClassRegistration(u))throw new Error(`Unknown node type: ${u}`);if(!m2c2Globals.m2NodeClassRegistry)throw new Error("Node class registry is not initialized.");const h=m2c2Globals.m2NodeClassRegistry[u];return new h(n)}hasClassRegistration(t){return Object.keys(m2c2Globals.m2NodeClassRegistry??{}).includes(t)}}class Js{static rgbaColor(t,i){return!t||!i?!1:t[0]===i[0]&&t[1]===i[1]&&t[2]===i[2]&&t[3]===i[3]}}class _n{constructor(t,i){this.fonts={},this.game=t,this.baseUrls=i,this.canvasKit=t.canvasKit,this.provider=this.canvasKit.TypefaceFontProvider.Make()}initializeFonts(t){return this.loadFonts(t??[])}async loadFonts(t){if(t.length===0)return;const i=t.map((n,u)=>{let h=n.url;q.urlHasScheme(n.url)||(h=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${n.url}`));const C={fontName:n.fontName,typeface:void 0,data:n.sharedFont?.data,default:u===0,url:n.sharedFont?.url??h,status:n.lazy?Xt.Deferred:Xt.Loading};if(this.fonts[n.fontName]=C,C.status===Xt.Loading)return this.prepareFont(C)});await Promise.all(i)}async prepareFont(t){const i=t.data??await this.fetchFontAsArrayBuffer(t);this.registerFont(i,t),console.log(`\u26AA font ${t.fontName}${t.default?" (default)":""} loaded for game ${this.game.id} from ${t.url}`)}async prepareDeferredFont(t){return t.status=Xt.Loading,this.prepareFont(t)}async fetchFontAsArrayBuffer(t){const i=await fetch(t.url);if(!i.ok)throw new Error(`cannot fetch font ${t.fontName} at url ${t.url}: ${i.statusText}`);return await i.arrayBuffer()}registerFont(t,i){this.provider.registerFont(t,i.fontName);const n=this.canvasKit.Typeface.MakeFreeTypeFaceFromData(t);if(!n)throw new Error(`cannot make typeface for font ${i.fontName} at url ${i.url}`);i.typeface=n,i.status=Xt.Ready}getFont(t){return this.fonts[t]}getDefaultFont(){const t=Object.values(this.fonts).find(i=>i.default);if(!t)throw new Error("no default font found; please make sure at least one font is loaded");return t}dispose(){const t=Object.entries(this.fonts).map(([,i])=>i.typeface);Ft.Dispose([...t,this.provider])}getTypeface(t){const i=this.fonts[t]?.typeface;if(!i)throw new Error(`font ${t} not found`);return i}getFontNames(){return Object.keys(this.fonts)}}var lr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Qs(g){return g&&g.__esModule&&Object.prototype.hasOwnProperty.call(g,"default")?g.default:g}function En(g){if(g.__esModule)return g;var t=g.default;if(typeof t=="function"){var i=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};i.prototype=t.prototype}else i={};return Object.defineProperty(i,"__esModule",{value:!0}),Object.keys(g).forEach(function(n){var u=Object.getOwnPropertyDescriptor(g,n);Object.defineProperty(i,n,u.get?u:{enumerable:!0,get:function(){return g[n]}})}),i}var Tn={exports:{}},Zs={},ta=Object.freeze({__proto__:null,default:Zs}),ea=En(ta);function Fn(g,t){for(var i=0,n=g.length-1;n>=0;n--){var u=g[n];u==="."?g.splice(n,1):u===".."?(g.splice(n,1),i++):i&&(g.splice(n,1),i--)}if(t)for(;i--;i)g.unshift("..");return g}var ia=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,hr=function(g){return ia.exec(g).slice(1)};function Ri(){for(var g="",t=!1,i=arguments.length-1;i>=-1&&!t;i--){var n=i>=0?arguments[i]:"/";if(typeof n!="string")throw new TypeError("Arguments to path.resolve must be strings");if(!n)continue;g=n+"/"+g,t=n.charAt(0)==="/"}return g=Fn(dr(g.split("/"),function(u){return!!u}),!t).join("/"),(t?"/":"")+g||"."}function cr(g){var t=ur(g),i=na(g,-1)==="/";return g=Fn(dr(g.split("/"),function(n){return!!n}),!t).join("/"),!g&&!t&&(g="."),g&&i&&(g+="/"),(t?"/":"")+g}function ur(g){return g.charAt(0)==="/"}function Mn(){var g=Array.prototype.slice.call(arguments,0);return cr(dr(g,function(t,i){if(typeof t!="string")throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))}function xn(g,t){g=Ri(g).substr(1),t=Ri(t).substr(1);function i(U){for(var et=0;et<U.length&&U[et]==="";et++);for(var ct=U.length-1;ct>=0&&U[ct]==="";ct--);return et>ct?[]:U.slice(et,ct-et+1)}for(var n=i(g.split("/")),u=i(t.split("/")),h=Math.min(n.length,u.length),C=h,F=0;F<h;F++)if(n[F]!==u[F]){C=F;break}for(var B=[],F=C;F<n.length;F++)B.push("..");return B=B.concat(u.slice(C)),B.join("/")}var Rn="/",Nn=":";function kn(g){var t=hr(g),i=t[0],n=t[1];return!i&&!n?".":(n&&(n=n.substr(0,n.length-1)),i+n)}function On(g,t){var i=hr(g)[2];return t&&i.substr(-1*t.length)===t&&(i=i.substr(0,i.length-t.length)),i}function In(g){return hr(g)[3]}var ra={extname:In,basename:On,dirname:kn,sep:Rn,delimiter:Nn,relative:xn,join:Mn,isAbsolute:ur,normalize:cr,resolve:Ri};function dr(g,t){if(g.filter)return g.filter(t);for(var i=[],n=0;n<g.length;n++)t(g[n],n,g)&&i.push(g[n]);return i}var na="ab".substr(-1)==="b"?function(g,t,i){return g.substr(t,i)}:function(g,t,i){return t<0&&(t=g.length+t),g.substr(t,i)},sa=Object.freeze({__proto__:null,basename:On,default:ra,delimiter:Nn,dirname:kn,extname:In,isAbsolute:ur,join:Mn,normalize:cr,relative:xn,resolve:Ri,sep:Rn}),aa=En(sa);(function(g,t){var i=(()=>{var n=typeof document<"u"&&document.currentScript?document.currentScript.src:void 0;return typeof __filename<"u"&&(n=n||__filename),function(u={}){var h=u,C,F;h.ready=new Promise((e,r)=>{C=e,F=r}),function(e){e.Td=e.Td||[],e.Td.push(function(){e.MakeSWCanvasSurface=function(r){var s=r,l=typeof OffscreenCanvas<"u"&&s instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||l||(s=document.getElementById(r),s)))throw"Canvas with id "+r+" was not found";return(r=e.MakeSurface(s.width,s.height))&&(r.Ld=s),r},e.MakeCanvasSurface||(e.MakeCanvasSurface=e.MakeSWCanvasSurface),e.MakeSurface=function(r,s){var l={width:r,height:s,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB},d=r*s*4,m=e._malloc(d);return(l=e.Surface._makeRasterDirect(l,m,4*r))&&(l.Ld=null,l.Hf=r,l.Df=s,l.Ff=d,l.bf=m,l.getCanvas().clear(e.TRANSPARENT)),l},e.MakeRasterDirectSurface=function(r,s,l){return e.Surface._makeRasterDirect(r,s.byteOffset,l)},e.Surface.prototype.flush=function(r){if(e.Md(this.Kd),this._flush(),this.Ld){var s=new Uint8ClampedArray(e.HEAPU8.buffer,this.bf,this.Ff);s=new ImageData(s,this.Hf,this.Df),r?this.Ld.getContext("2d").putImageData(s,0,0,r[0],r[1],r[2]-r[0],r[3]-r[1]):this.Ld.getContext("2d").putImageData(s,0,0)}},e.Surface.prototype.dispose=function(){this.bf&&e._free(this.bf),this.delete()},e.Md=e.Md||function(){},e.Te=e.Te||function(){return null}})}(h),function(e){e.Td=e.Td||[],e.Td.push(function(){function r(v,y,A){return v&&v.hasOwnProperty(y)?v[y]:A}function s(v){var y=Oe(Kt);return Kt[y]=v,y}function l(v){return v.naturalHeight||v.videoHeight||v.displayHeight||v.height}function d(v){return v.naturalWidth||v.videoWidth||v.displayWidth||v.width}function m(v,y,A,O){return v.bindTexture(v.TEXTURE_2D,y),O||A.alphaType!==e.AlphaType.Premul||v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),y}function P(v,y,A){A||y.alphaType!==e.AlphaType.Premul||v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),v.bindTexture(v.TEXTURE_2D,null)}e.GetWebGLContext=function(v,y){if(!v)throw"null canvas passed into makeWebGLContext";var A={alpha:r(y,"alpha",1),depth:r(y,"depth",1),stencil:r(y,"stencil",8),antialias:r(y,"antialias",0),premultipliedAlpha:r(y,"premultipliedAlpha",1),preserveDrawingBuffer:r(y,"preserveDrawingBuffer",0),preferLowPowerToHighPerformance:r(y,"preferLowPowerToHighPerformance",0),failIfMajorPerformanceCaveat:r(y,"failIfMajorPerformanceCaveat",0),enableExtensionsByDefault:r(y,"enableExtensionsByDefault",1),explicitSwapControl:r(y,"explicitSwapControl",0),renderViaOffscreenBackBuffer:r(y,"renderViaOffscreenBackBuffer",0)};if(A.majorVersion=y&&y.majorVersion?y.majorVersion:typeof WebGL2RenderingContext<"u"?2:1,A.explicitSwapControl)throw"explicitSwapControl is not supported";return v=ws(v,A),v?(jr(v),it.fe.getExtension("WEBGL_debug_renderer_info"),v):0},e.deleteContext=function(v){it===le[v]&&(it=null),typeof JSEvents=="object"&&JSEvents.ug(le[v].fe.canvas),le[v]&&le[v].fe.canvas&&(le[v].fe.canvas.zf=void 0),le[v]=null},e._setTextureCleanup({deleteTexture:function(v,y){var A=Kt[y];A&&le[v].fe.deleteTexture(A),Kt[y]=null}}),e.MakeWebGLContext=function(v){if(!this.Md(v))return null;var y=this._MakeGrContext();if(!y)return null;y.Kd=v;var A=y.delete.bind(y);return y.delete=function(){e.Md(this.Kd),A()}.bind(y),it.ff=y},e.MakeGrContext=e.MakeWebGLContext,e.GrDirectContext.prototype.getResourceCacheLimitBytes=function(){e.Md(this.Kd),this._getResourceCacheLimitBytes()},e.GrDirectContext.prototype.getResourceCacheUsageBytes=function(){e.Md(this.Kd),this._getResourceCacheUsageBytes()},e.GrDirectContext.prototype.releaseResourcesAndAbandonContext=function(){e.Md(this.Kd),this._releaseResourcesAndAbandonContext()},e.GrDirectContext.prototype.setResourceCacheLimitBytes=function(v){e.Md(this.Kd),this._setResourceCacheLimitBytes(v)},e.MakeOnScreenGLSurface=function(v,y,A,O,D,H){return!this.Md(v.Kd)||(y=D===void 0||H===void 0?this._MakeOnScreenGLSurface(v,y,A,O):this._MakeOnScreenGLSurface(v,y,A,O,D,H),!y)?null:(y.Kd=v.Kd,y)},e.MakeRenderTarget=function(){var v=arguments[0];if(!this.Md(v.Kd))return null;if(arguments.length===3){var y=this._MakeRenderTargetWH(v,arguments[1],arguments[2]);if(!y)return null}else if(arguments.length===2){if(y=this._MakeRenderTargetII(v,arguments[1]),!y)return null}else return null;return y.Kd=v.Kd,y},e.MakeWebGLCanvasSurface=function(v,y,A){y=y||null;var O=v,D=typeof OffscreenCanvas<"u"&&O instanceof OffscreenCanvas;if(!(typeof HTMLCanvasElement<"u"&&O instanceof HTMLCanvasElement||D||(O=document.getElementById(v),O)))throw"Canvas with id "+v+" was not found";if(v=this.GetWebGLContext(O,A),!v||0>v)throw"failed to create webgl context: err "+v;return v=this.MakeWebGLContext(v),y=this.MakeOnScreenGLSurface(v,O.width,O.height,y),y||(y=O.cloneNode(!0),O.parentNode.replaceChild(y,O),y.classList.add("ck-replaced"),e.MakeSWCanvasSurface(y))},e.MakeCanvasSurface=e.MakeWebGLCanvasSurface,e.Surface.prototype.makeImageFromTexture=function(v,y){return e.Md(this.Kd),v=s(v),(y=this._makeImageFromTexture(this.Kd,v,y))&&(y.Le=v),y},e.Surface.prototype.makeImageFromTextureSource=function(v,y,A){y||(y={height:l(v),width:d(v),colorType:e.ColorType.RGBA_8888,alphaType:A?e.AlphaType.Premul:e.AlphaType.Unpremul}),y.colorSpace||(y.colorSpace=e.ColorSpace.SRGB),e.Md(this.Kd);var O=it.fe;return A=m(O,O.createTexture(),y,A),it.version===2?O.texImage2D(O.TEXTURE_2D,0,O.RGBA,y.width,y.height,0,O.RGBA,O.UNSIGNED_BYTE,v):O.texImage2D(O.TEXTURE_2D,0,O.RGBA,O.RGBA,O.UNSIGNED_BYTE,v),P(O,y),this._resetContext(),this.makeImageFromTexture(A,y)},e.Surface.prototype.updateTextureFromSource=function(v,y,A){if(v.Le){e.Md(this.Kd);var O=v.getImageInfo(),D=it.fe,H=m(D,Kt[v.Le],O,A);it.version===2?D.texImage2D(D.TEXTURE_2D,0,D.RGBA,d(y),l(y),0,D.RGBA,D.UNSIGNED_BYTE,y):D.texImage2D(D.TEXTURE_2D,0,D.RGBA,D.RGBA,D.UNSIGNED_BYTE,y),P(D,O,A),this._resetContext(),Kt[v.Le]=null,v.Le=s(H),O.colorSpace=v.getColorSpace(),y=this._makeImageFromTexture(this.Kd,v.Le,O),A=v.Jd.Rd,D=v.Jd.Yd,v.Jd.Rd=y.Jd.Rd,v.Jd.Yd=y.Jd.Yd,y.Jd.Rd=A,y.Jd.Yd=D,y.delete(),O.colorSpace.delete()}},e.MakeLazyImageFromTextureSource=function(v,y,A){y||(y={height:l(v),width:d(v),colorType:e.ColorType.RGBA_8888,alphaType:A?e.AlphaType.Premul:e.AlphaType.Unpremul}),y.colorSpace||(y.colorSpace=e.ColorSpace.SRGB);var O={makeTexture:function(){var D=it,H=D.fe,T=m(H,H.createTexture(),y,A);return D.version===2?H.texImage2D(H.TEXTURE_2D,0,H.RGBA,y.width,y.height,0,H.RGBA,H.UNSIGNED_BYTE,v):H.texImage2D(H.TEXTURE_2D,0,H.RGBA,H.RGBA,H.UNSIGNED_BYTE,v),P(H,y,A),s(T)},freeSrc:function(){}};return v.constructor.name==="VideoFrame"&&(O.freeSrc=function(){v.close()}),e.Image._makeFromGenerator(y,O)},e.Md=function(v){return v?jr(v):!1},e.Te=function(){return it&&it.ff&&!it.ff.isDeleted()?it.ff:null}})}(h),function(e){function r(o,a,c,p,b){for(var E=0;E<o.length;E++)a[E*c+(E*b+p+c)%c]=o[E];return a}function s(o){for(var a=o*o,c=Array(a);a--;)c[a]=a%(o+1)===0?1:0;return c}function l(o){return o?o.constructor===Float32Array&&o.length===4:!1}function d(o){return(v(255*o[3])<<24|v(255*o[0])<<16|v(255*o[1])<<8|v(255*o[2])<<0)>>>0}function m(o){if(o&&o._ck)return o;if(o instanceof Float32Array){for(var a=Math.floor(o.length/4),c=new Uint32Array(a),p=0;p<a;p++)c[p]=d(o.slice(4*p,4*(p+1)));return c}if(o instanceof Uint32Array)return o;if(o instanceof Array&&o[0]instanceof Float32Array)return o.map(d)}function P(o){if(o===void 0)return 1;var a=parseFloat(o);return o&&o.indexOf("%")!==-1?a/100:a}function v(o){return Math.round(Math.max(0,Math.min(o||0,255)))}function y(o,a){a&&a._ck||e._free(o)}function A(o,a,c){if(!o||!o.length)return ht;if(o&&o._ck)return o.byteOffset;var p=e[a].BYTES_PER_ELEMENT;return c||(c=e._malloc(o.length*p)),e[a].set(o,c/p),c}function O(o){var a={be:ht,count:o.length,colorType:e.ColorType.RGBA_F32};if(o instanceof Float32Array)a.be=A(o,"HEAPF32"),a.count=o.length/4;else if(o instanceof Uint32Array)a.be=A(o,"HEAPU32"),a.colorType=e.ColorType.RGBA_8888;else if(o instanceof Array){if(o&&o.length){for(var c=e._malloc(16*o.length),p=0,b=c/4,E=0;E<o.length;E++)for(var N=0;4>N;N++)e.HEAPF32[b+p]=o[E][N],p++;o=c}else o=ht;a.be=o}else throw"Invalid argument to copyFlexibleColorArray, Not a color array "+typeof o;return a}function D(o){if(!o)return ht;var a=Qi.toTypedArray();if(o.length){if(o.length===6||o.length===9)return A(o,"HEAPF32",ye),o.length===6&&e.HEAPF32.set(Gs,6+ye/4),ye;if(o.length===16)return a[0]=o[0],a[1]=o[1],a[2]=o[3],a[3]=o[4],a[4]=o[5],a[5]=o[7],a[6]=o[12],a[7]=o[13],a[8]=o[15],ye;throw"invalid matrix size"}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m41,a[3]=o.m12,a[4]=o.m22,a[5]=o.m42,a[6]=o.m14,a[7]=o.m24,a[8]=o.m44,ye}function H(o){if(!o)return ht;var a=Zi.toTypedArray();if(o.length){if(o.length!==16&&o.length!==6&&o.length!==9)throw"invalid matrix size";return o.length===16?A(o,"HEAPF32",Le):(a.fill(0),a[0]=o[0],a[1]=o[1],a[3]=o[2],a[4]=o[3],a[5]=o[4],a[7]=o[5],a[10]=1,a[12]=o[6],a[13]=o[7],a[15]=o[8],o.length===6&&(a[12]=0,a[13]=0,a[15]=1),Le)}if(o.m11===void 0)throw"invalid matrix argument";return a[0]=o.m11,a[1]=o.m21,a[2]=o.m31,a[3]=o.m41,a[4]=o.m12,a[5]=o.m22,a[6]=o.m32,a[7]=o.m42,a[8]=o.m13,a[9]=o.m23,a[10]=o.m33,a[11]=o.m43,a[12]=o.m14,a[13]=o.m24,a[14]=o.m34,a[15]=o.m44,Le}function T(o,a){return A(o,"HEAPF32",a||Ee)}function Y(o,a,c,p){var b=tr.toTypedArray();return b[0]=o,b[1]=a,b[2]=c,b[3]=p,Ee}function nt(o){for(var a=new Float32Array(4),c=0;4>c;c++)a[c]=e.HEAPF32[o/4+c];return a}function rt(o,a){return A(o,"HEAPF32",a||Et)}function Bt(o,a){return A(o,"HEAPF32",a||rr)}function Rt(){for(var o=0,a=0;a<arguments.length-1;a+=2)o+=arguments[a]*arguments[a+1];return o}function ti(o,a,c){for(var p=Array(o.length),b=0;b<c;b++)for(var E=0;E<c;E++){for(var N=0,W=0;W<c;W++)N+=o[c*b+W]*a[c*W+E];p[b*c+E]=N}return p}function ei(o,a){for(var c=ti(a[0],a[1],o),p=2;p<a.length;)c=ti(c,a[p],o),p++;return c}e.Color=function(o,a,c,p){return p===void 0&&(p=1),e.Color4f(v(o)/255,v(a)/255,v(c)/255,p)},e.ColorAsInt=function(o,a,c,p){return p===void 0&&(p=255),(v(p)<<24|v(o)<<16|v(a)<<8|v(c)<<0&268435455)>>>0},e.Color4f=function(o,a,c,p){return p===void 0&&(p=1),Float32Array.of(o,a,c,p)},Object.defineProperty(e,"TRANSPARENT",{get:function(){return e.Color4f(0,0,0,0)}}),Object.defineProperty(e,"BLACK",{get:function(){return e.Color4f(0,0,0,1)}}),Object.defineProperty(e,"WHITE",{get:function(){return e.Color4f(1,1,1,1)}}),Object.defineProperty(e,"RED",{get:function(){return e.Color4f(1,0,0,1)}}),Object.defineProperty(e,"GREEN",{get:function(){return e.Color4f(0,1,0,1)}}),Object.defineProperty(e,"BLUE",{get:function(){return e.Color4f(0,0,1,1)}}),Object.defineProperty(e,"YELLOW",{get:function(){return e.Color4f(1,1,0,1)}}),Object.defineProperty(e,"CYAN",{get:function(){return e.Color4f(0,1,1,1)}}),Object.defineProperty(e,"MAGENTA",{get:function(){return e.Color4f(1,0,1,1)}}),e.getColorComponents=function(o){return[Math.floor(255*o[0]),Math.floor(255*o[1]),Math.floor(255*o[2]),o[3]]},e.parseColorString=function(o,a){if(o=o.toLowerCase(),o.startsWith("#")){switch(a=255,o.length){case 9:a=parseInt(o.slice(7,9),16);case 7:var c=parseInt(o.slice(1,3),16),p=parseInt(o.slice(3,5),16),b=parseInt(o.slice(5,7),16);break;case 5:a=17*parseInt(o.slice(4,5),16);case 4:c=17*parseInt(o.slice(1,2),16),p=17*parseInt(o.slice(2,3),16),b=17*parseInt(o.slice(3,4),16)}return e.Color(c,p,b,a/255)}return o.startsWith("rgba")?(o=o.slice(5,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],P(o[3]))):o.startsWith("rgb")?(o=o.slice(4,-1),o=o.split(","),e.Color(+o[0],+o[1],+o[2],P(o[3]))):o.startsWith("gray(")||o.startsWith("hsl")||!a||(o=a[o],o===void 0)?e.BLACK:o},e.multiplyByAlpha=function(o,a){return o=o.slice(),o[3]=Math.max(0,Math.min(o[3]*a,1)),o},e.Malloc=function(o,a){var c=e._malloc(a*o.BYTES_PER_ELEMENT);return{_ck:!0,length:a,byteOffset:c,qe:null,subarray:function(p,b){return p=this.toTypedArray().subarray(p,b),p._ck=!0,p},toTypedArray:function(){return this.qe&&this.qe.length?this.qe:(this.qe=new o(e.HEAPU8.buffer,c,a),this.qe._ck=!0,this.qe)}}},e.Free=function(o){e._free(o.byteOffset),o.byteOffset=ht,o.toTypedArray=null,o.qe=null};var ye=ht,Qi,Le=ht,Zi,Ee=ht,tr,ie,Et=ht,nn,we=ht,sn,er=ht,an,ir=ht,Fi,ii=ht,on,rr=ht,ln,hn=ht,Gs=Float32Array.of(0,0,1),ht=0;e.onRuntimeInitialized=function(){function o(a,c,p,b,E,N,W){N||(N=4*b.width,b.colorType===e.ColorType.RGBA_F16?N*=2:b.colorType===e.ColorType.RGBA_F32&&(N*=4));var Q=N*b.height,J=E?E.byteOffset:e._malloc(Q);if(W?!a._readPixels(b,J,N,c,p,W):!a._readPixels(b,J,N,c,p))return E||e._free(J),null;if(E)return E.toTypedArray();switch(b.colorType){case e.ColorType.RGBA_8888:case e.ColorType.RGBA_F16:a=new Uint8Array(e.HEAPU8.buffer,J,Q).slice();break;case e.ColorType.RGBA_F32:a=new Float32Array(e.HEAPU8.buffer,J,Q).slice();break;default:return null}return e._free(J),a}tr=e.Malloc(Float32Array,4),Ee=tr.byteOffset,Zi=e.Malloc(Float32Array,16),Le=Zi.byteOffset,Qi=e.Malloc(Float32Array,9),ye=Qi.byteOffset,on=e.Malloc(Float32Array,12),rr=on.byteOffset,ln=e.Malloc(Float32Array,12),hn=ln.byteOffset,ie=e.Malloc(Float32Array,4),Et=ie.byteOffset,nn=e.Malloc(Float32Array,4),we=nn.byteOffset,sn=e.Malloc(Float32Array,3),er=sn.byteOffset,an=e.Malloc(Float32Array,3),ir=an.byteOffset,Fi=e.Malloc(Int32Array,4),ii=Fi.byteOffset,e.ColorSpace.SRGB=e.ColorSpace._MakeSRGB(),e.ColorSpace.DISPLAY_P3=e.ColorSpace._MakeDisplayP3(),e.ColorSpace.ADOBE_RGB=e.ColorSpace._MakeAdobeRGB(),e.GlyphRunFlags={IsWhiteSpace:e._GlyphRunFlags_isWhiteSpace},e.Path.MakeFromCmds=function(a){var c=A(a,"HEAPF32"),p=e.Path._MakeFromCmds(c,a.length);return y(c,a),p},e.Path.MakeFromVerbsPointsWeights=function(a,c,p){var b=A(a,"HEAPU8"),E=A(c,"HEAPF32"),N=A(p,"HEAPF32"),W=e.Path._MakeFromVerbsPointsWeights(b,a.length,E,c.length,N,p&&p.length||0);return y(b,a),y(E,c),y(N,p),W},e.Path.prototype.addArc=function(a,c,p){return a=rt(a),this._addArc(a,c,p),this},e.Path.prototype.addCircle=function(a,c,p,b){return this._addCircle(a,c,p,!!b),this},e.Path.prototype.addOval=function(a,c,p){return p===void 0&&(p=1),a=rt(a),this._addOval(a,!!c,p),this},e.Path.prototype.addPath=function(){var a=Array.prototype.slice.call(arguments),c=a[0],p=!1;if(typeof a[a.length-1]=="boolean"&&(p=a.pop()),a.length===1)this._addPath(c,1,0,0,0,1,0,0,0,1,p);else if(a.length===2)a=a[1],this._addPath(c,a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1,p);else if(a.length===7||a.length===10)this._addPath(c,a[1],a[2],a[3],a[4],a[5],a[6],a[7]||0,a[8]||0,a[9]||1,p);else return null;return this},e.Path.prototype.addPoly=function(a,c){var p=A(a,"HEAPF32");return this._addPoly(p,a.length/2,c),y(p,a),this},e.Path.prototype.addRect=function(a,c){return a=rt(a),this._addRect(a,!!c),this},e.Path.prototype.addRRect=function(a,c){return a=Bt(a),this._addRRect(a,!!c),this},e.Path.prototype.addVerbsPointsWeights=function(a,c,p){var b=A(a,"HEAPU8"),E=A(c,"HEAPF32"),N=A(p,"HEAPF32");this._addVerbsPointsWeights(b,a.length,E,c.length,N,p&&p.length||0),y(b,a),y(E,c),y(N,p)},e.Path.prototype.arc=function(a,c,p,b,E,N){return a=e.LTRBRect(a-p,c-p,a+p,c+p),E=(E-b)/Math.PI*180-360*!!N,N=new e.Path,N.addArc(a,b/Math.PI*180,E),this.addPath(N,!0),N.delete(),this},e.Path.prototype.arcToOval=function(a,c,p,b){return a=rt(a),this._arcToOval(a,c,p,b),this},e.Path.prototype.arcToRotated=function(a,c,p,b,E,N,W){return this._arcToRotated(a,c,p,!!b,!!E,N,W),this},e.Path.prototype.arcToTangent=function(a,c,p,b,E){return this._arcToTangent(a,c,p,b,E),this},e.Path.prototype.close=function(){return this._close(),this},e.Path.prototype.conicTo=function(a,c,p,b,E){return this._conicTo(a,c,p,b,E),this},e.Path.prototype.computeTightBounds=function(a){this._computeTightBounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Path.prototype.cubicTo=function(a,c,p,b,E,N){return this._cubicTo(a,c,p,b,E,N),this},e.Path.prototype.dash=function(a,c,p){return this._dash(a,c,p)?this:null},e.Path.prototype.getBounds=function(a){this._getBounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Path.prototype.lineTo=function(a,c){return this._lineTo(a,c),this},e.Path.prototype.moveTo=function(a,c){return this._moveTo(a,c),this},e.Path.prototype.offset=function(a,c){return this._transform(1,0,a,0,1,c,0,0,1),this},e.Path.prototype.quadTo=function(a,c,p,b){return this._quadTo(a,c,p,b),this},e.Path.prototype.rArcTo=function(a,c,p,b,E,N,W){return this._rArcTo(a,c,p,b,E,N,W),this},e.Path.prototype.rConicTo=function(a,c,p,b,E){return this._rConicTo(a,c,p,b,E),this},e.Path.prototype.rCubicTo=function(a,c,p,b,E,N){return this._rCubicTo(a,c,p,b,E,N),this},e.Path.prototype.rLineTo=function(a,c){return this._rLineTo(a,c),this},e.Path.prototype.rMoveTo=function(a,c){return this._rMoveTo(a,c),this},e.Path.prototype.rQuadTo=function(a,c,p,b){return this._rQuadTo(a,c,p,b),this},e.Path.prototype.stroke=function(a){return a=a||{},a.width=a.width||1,a.miter_limit=a.miter_limit||4,a.cap=a.cap||e.StrokeCap.Butt,a.join=a.join||e.StrokeJoin.Miter,a.precision=a.precision||1,this._stroke(a)?this:null},e.Path.prototype.transform=function(){if(arguments.length===1){var a=arguments[0];this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1)}else if(arguments.length===6||arguments.length===9)a=arguments,this._transform(a[0],a[1],a[2],a[3],a[4],a[5],a[6]||0,a[7]||0,a[8]||1);else throw"transform expected to take 1 or 9 arguments. Got "+arguments.length;return this},e.Path.prototype.trim=function(a,c,p){return this._trim(a,c,!!p)?this:null},e.Image.prototype.encodeToBytes=function(a,c){var p=e.Te();return a=a||e.ImageFormat.PNG,c=c||100,p?this._encodeToBytes(a,c,p):this._encodeToBytes(a,c)},e.Image.prototype.makeShaderCubic=function(a,c,p,b,E){return E=D(E),this._makeShaderCubic(a,c,p,b,E)},e.Image.prototype.makeShaderOptions=function(a,c,p,b,E){return E=D(E),this._makeShaderOptions(a,c,p,b,E)},e.Image.prototype.readPixels=function(a,c,p,b,E){var N=e.Te();return o(this,a,c,p,b,E,N)},e.Canvas.prototype.clear=function(a){e.Md(this.Kd),a=T(a),this._clear(a)},e.Canvas.prototype.clipRRect=function(a,c,p){e.Md(this.Kd),a=Bt(a),this._clipRRect(a,c,p)},e.Canvas.prototype.clipRect=function(a,c,p){e.Md(this.Kd),a=rt(a),this._clipRect(a,c,p)},e.Canvas.prototype.concat=function(a){e.Md(this.Kd),a=H(a),this._concat(a)},e.Canvas.prototype.drawArc=function(a,c,p,b,E){e.Md(this.Kd),a=rt(a),this._drawArc(a,c,p,b,E)},e.Canvas.prototype.drawAtlas=function(a,c,p,b,E,N,W){if(a&&b&&c&&p&&c.length===p.length){e.Md(this.Kd),E||(E=e.BlendMode.SrcOver);var Q=A(c,"HEAPF32"),J=A(p,"HEAPF32"),dt=p.length/4,mt=A(m(N),"HEAPU32");if(W&&"B"in W&&"C"in W)this._drawAtlasCubic(a,J,Q,mt,dt,E,W.B,W.C,b);else{let S=e.FilterMode.Linear,k=e.MipmapMode.None;W&&(S=W.filter,"mipmap"in W&&(k=W.mipmap)),this._drawAtlasOptions(a,J,Q,mt,dt,E,S,k,b)}y(Q,c),y(J,p),y(mt,N)}},e.Canvas.prototype.drawCircle=function(a,c,p,b){e.Md(this.Kd),this._drawCircle(a,c,p,b)},e.Canvas.prototype.drawColor=function(a,c){e.Md(this.Kd),a=T(a),c!==void 0?this._drawColor(a,c):this._drawColor(a)},e.Canvas.prototype.drawColorInt=function(a,c){e.Md(this.Kd),this._drawColorInt(a,c||e.BlendMode.SrcOver)},e.Canvas.prototype.drawColorComponents=function(a,c,p,b,E){e.Md(this.Kd),a=Y(a,c,p,b),E!==void 0?this._drawColor(a,E):this._drawColor(a)},e.Canvas.prototype.drawDRRect=function(a,c,p){e.Md(this.Kd),a=Bt(a,rr),c=Bt(c,hn),this._drawDRRect(a,c,p)},e.Canvas.prototype.drawImage=function(a,c,p,b){e.Md(this.Kd),this._drawImage(a,c,p,b||null)},e.Canvas.prototype.drawImageCubic=function(a,c,p,b,E,N){e.Md(this.Kd),this._drawImageCubic(a,c,p,b,E,N||null)},e.Canvas.prototype.drawImageOptions=function(a,c,p,b,E,N){e.Md(this.Kd),this._drawImageOptions(a,c,p,b,E,N||null)},e.Canvas.prototype.drawImageNine=function(a,c,p,b,E){e.Md(this.Kd),c=A(c,"HEAP32",ii),p=rt(p),this._drawImageNine(a,c,p,b,E||null)},e.Canvas.prototype.drawImageRect=function(a,c,p,b,E){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRect(a,Et,we,b,!!E)},e.Canvas.prototype.drawImageRectCubic=function(a,c,p,b,E,N){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRectCubic(a,Et,we,b,E,N||null)},e.Canvas.prototype.drawImageRectOptions=function(a,c,p,b,E,N){e.Md(this.Kd),rt(c,Et),rt(p,we),this._drawImageRectOptions(a,Et,we,b,E,N||null)},e.Canvas.prototype.drawLine=function(a,c,p,b,E){e.Md(this.Kd),this._drawLine(a,c,p,b,E)},e.Canvas.prototype.drawOval=function(a,c){e.Md(this.Kd),a=rt(a),this._drawOval(a,c)},e.Canvas.prototype.drawPaint=function(a){e.Md(this.Kd),this._drawPaint(a)},e.Canvas.prototype.drawParagraph=function(a,c,p){e.Md(this.Kd),this._drawParagraph(a,c,p)},e.Canvas.prototype.drawPatch=function(a,c,p,b,E){if(24>a.length)throw"Need 12 cubic points";if(c&&4>c.length)throw"Need 4 colors";if(p&&8>p.length)throw"Need 4 shader coordinates";e.Md(this.Kd);const N=A(a,"HEAPF32"),W=c?A(m(c),"HEAPU32"):ht,Q=p?A(p,"HEAPF32"):ht;b||(b=e.BlendMode.Modulate),this._drawPatch(N,W,Q,b,E),y(Q,p),y(W,c),y(N,a)},e.Canvas.prototype.drawPath=function(a,c){e.Md(this.Kd),this._drawPath(a,c)},e.Canvas.prototype.drawPicture=function(a){e.Md(this.Kd),this._drawPicture(a)},e.Canvas.prototype.drawPoints=function(a,c,p){e.Md(this.Kd);var b=A(c,"HEAPF32");this._drawPoints(a,b,c.length/2,p),y(b,c)},e.Canvas.prototype.drawRRect=function(a,c){e.Md(this.Kd),a=Bt(a),this._drawRRect(a,c)},e.Canvas.prototype.drawRect=function(a,c){e.Md(this.Kd),a=rt(a),this._drawRect(a,c)},e.Canvas.prototype.drawRect4f=function(a,c,p,b,E){e.Md(this.Kd),this._drawRect4f(a,c,p,b,E)},e.Canvas.prototype.drawShadow=function(a,c,p,b,E,N,W){e.Md(this.Kd);var Q=A(E,"HEAPF32"),J=A(N,"HEAPF32");c=A(c,"HEAPF32",er),p=A(p,"HEAPF32",ir),this._drawShadow(a,c,p,b,Q,J,W),y(Q,E),y(J,N)},e.getShadowLocalBounds=function(a,c,p,b,E,N,W){return a=D(a),p=A(p,"HEAPF32",er),b=A(b,"HEAPF32",ir),this._getShadowLocalBounds(a,c,p,b,E,N,Et)?(c=ie.toTypedArray(),W?(W.set(c),W):c.slice()):null},e.Canvas.prototype.drawTextBlob=function(a,c,p,b){e.Md(this.Kd),this._drawTextBlob(a,c,p,b)},e.Canvas.prototype.drawVertices=function(a,c,p){e.Md(this.Kd),this._drawVertices(a,c,p)},e.Canvas.prototype.getDeviceClipBounds=function(a){this._getDeviceClipBounds(ii);var c=Fi.toTypedArray();return a?a.set(c):a=c.slice(),a},e.Canvas.prototype.getLocalToDevice=function(){this._getLocalToDevice(Le);for(var a=Le,c=Array(16),p=0;16>p;p++)c[p]=e.HEAPF32[a/4+p];return c},e.Canvas.prototype.getTotalMatrix=function(){this._getTotalMatrix(ye);for(var a=Array(9),c=0;9>c;c++)a[c]=e.HEAPF32[ye/4+c];return a},e.Canvas.prototype.makeSurface=function(a){return a=this._makeSurface(a),a.Kd=this.Kd,a},e.Canvas.prototype.readPixels=function(a,c,p,b,E){return e.Md(this.Kd),o(this,a,c,p,b,E)},e.Canvas.prototype.saveLayer=function(a,c,p,b){return c=rt(c),this._saveLayer(a||null,c,p||null,b||0)},e.Canvas.prototype.writePixels=function(a,c,p,b,E,N,W,Q){if(a.byteLength%(c*p))throw"pixels length must be a multiple of the srcWidth * srcHeight";e.Md(this.Kd);var J=a.byteLength/(c*p);N=N||e.AlphaType.Unpremul,W=W||e.ColorType.RGBA_8888,Q=Q||e.ColorSpace.SRGB;var dt=J*c;return J=A(a,"HEAPU8"),c=this._writePixels({width:c,height:p,colorType:W,alphaType:N,colorSpace:Q},J,dt,b,E),y(J,a),c},e.ColorFilter.MakeBlend=function(a,c,p){return a=T(a),p=p||e.ColorSpace.SRGB,e.ColorFilter._MakeBlend(a,c,p)},e.ColorFilter.MakeMatrix=function(a){if(!a||a.length!==20)throw"invalid color matrix";var c=A(a,"HEAPF32"),p=e.ColorFilter._makeMatrix(c);return y(c,a),p},e.ContourMeasure.prototype.getPosTan=function(a,c){return this._getPosTan(a,Et),a=ie.toTypedArray(),c?(c.set(a),c):a.slice()},e.ImageFilter.prototype.getOutputBounds=function(a,c,p){return a=rt(a,Et),c=D(c),this._getOutputBounds(a,c,ii),c=Fi.toTypedArray(),p?(p.set(c),p):c.slice()},e.ImageFilter.MakeDropShadow=function(a,c,p,b,E,N){return E=T(E,Ee),e.ImageFilter._MakeDropShadow(a,c,p,b,E,N)},e.ImageFilter.MakeDropShadowOnly=function(a,c,p,b,E,N){return E=T(E,Ee),e.ImageFilter._MakeDropShadowOnly(a,c,p,b,E,N)},e.ImageFilter.MakeImage=function(a,c,p,b){if(p=rt(p,Et),b=rt(b,we),"B"in c&&"C"in c)return e.ImageFilter._MakeImageCubic(a,c.B,c.C,p,b);const E=c.filter;let N=e.MipmapMode.None;return"mipmap"in c&&(N=c.mipmap),e.ImageFilter._MakeImageOptions(a,E,N,p,b)},e.ImageFilter.MakeMatrixTransform=function(a,c,p){if(a=D(a),"B"in c&&"C"in c)return e.ImageFilter._MakeMatrixTransformCubic(a,c.B,c.C,p);const b=c.filter;let E=e.MipmapMode.None;return"mipmap"in c&&(E=c.mipmap),e.ImageFilter._MakeMatrixTransformOptions(a,b,E,p)},e.Paint.prototype.getColor=function(){return this._getColor(Ee),nt(Ee)},e.Paint.prototype.setColor=function(a,c){c=c||null,a=T(a),this._setColor(a,c)},e.Paint.prototype.setColorComponents=function(a,c,p,b,E){E=E||null,a=Y(a,c,p,b),this._setColor(a,E)},e.Path.prototype.getPoint=function(a,c){return this._getPoint(a,Et),a=ie.toTypedArray(),c?(c[0]=a[0],c[1]=a[1],c):a.slice(0,2)},e.Picture.prototype.makeShader=function(a,c,p,b,E){return b=D(b),E=rt(E),this._makeShader(a,c,p,b,E)},e.Picture.prototype.cullRect=function(a){this._cullRect(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.PictureRecorder.prototype.beginRecording=function(a,c){return a=rt(a),this._beginRecording(a,!!c)},e.Surface.prototype.getCanvas=function(){var a=this._getCanvas();return a.Kd=this.Kd,a},e.Surface.prototype.makeImageSnapshot=function(a){return e.Md(this.Kd),a=A(a,"HEAP32",ii),this._makeImageSnapshot(a)},e.Surface.prototype.makeSurface=function(a){return e.Md(this.Kd),a=this._makeSurface(a),a.Kd=this.Kd,a},e.Surface.prototype.Gf=function(a,c){return this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){e.Md(this.Kd),a(this.He),this.flush(c)}.bind(this))},e.Surface.prototype.requestAnimationFrame||(e.Surface.prototype.requestAnimationFrame=e.Surface.prototype.Gf),e.Surface.prototype.Cf=function(a,c){this.He||(this.He=this.getCanvas()),requestAnimationFrame(function(){e.Md(this.Kd),a(this.He),this.flush(c),this.dispose()}.bind(this))},e.Surface.prototype.drawOnce||(e.Surface.prototype.drawOnce=e.Surface.prototype.Cf),e.PathEffect.MakeDash=function(a,c){if(c||(c=0),!a.length||a.length%2===1)throw"Intervals array must have even length";var p=A(a,"HEAPF32");return c=e.PathEffect._MakeDash(p,a.length,c),y(p,a),c},e.PathEffect.MakeLine2D=function(a,c){return c=D(c),e.PathEffect._MakeLine2D(a,c)},e.PathEffect.MakePath2D=function(a,c){return a=D(a),e.PathEffect._MakePath2D(a,c)},e.Shader.MakeColor=function(a,c){return c=c||null,a=T(a),e.Shader._MakeColor(a,c)},e.Shader.Blend=e.Shader.MakeBlend,e.Shader.Color=e.Shader.MakeColor,e.Shader.MakeLinearGradient=function(a,c,p,b,E,N,W,Q){Q=Q||null;var J=O(p),dt=A(b,"HEAPF32");W=W||0,N=D(N);var mt=ie.toTypedArray();return mt.set(a),mt.set(c,2),a=e.Shader._MakeLinearGradient(Et,J.be,J.colorType,dt,J.count,E,W,N,Q),y(J.be,p),b&&y(dt,b),a},e.Shader.MakeRadialGradient=function(a,c,p,b,E,N,W,Q){Q=Q||null;var J=O(p),dt=A(b,"HEAPF32");return W=W||0,N=D(N),a=e.Shader._MakeRadialGradient(a[0],a[1],c,J.be,J.colorType,dt,J.count,E,W,N,Q),y(J.be,p),b&&y(dt,b),a},e.Shader.MakeSweepGradient=function(a,c,p,b,E,N,W,Q,J,dt){dt=dt||null;var mt=O(p),S=A(b,"HEAPF32");return W=W||0,Q=Q||0,J=J||360,N=D(N),a=e.Shader._MakeSweepGradient(a,c,mt.be,mt.colorType,S,mt.count,E,Q,J,W,N,dt),y(mt.be,p),b&&y(S,b),a},e.Shader.MakeTwoPointConicalGradient=function(a,c,p,b,E,N,W,Q,J,dt){dt=dt||null;var mt=O(E),S=A(N,"HEAPF32");J=J||0,Q=D(Q);var k=ie.toTypedArray();return k.set(a),k.set(p,2),a=e.Shader._MakeTwoPointConicalGradient(Et,c,b,mt.be,mt.colorType,S,mt.count,W,J,Q,dt),y(mt.be,E),N&&y(S,N),a},e.Vertices.prototype.bounds=function(a){this._bounds(Et);var c=ie.toTypedArray();return a?(a.set(c),a):c.slice()},e.Td&&e.Td.forEach(function(a){a()})},e.computeTonalColors=function(o){var a=A(o.ambient,"HEAPF32"),c=A(o.spot,"HEAPF32");this._computeTonalColors(a,c);var p={ambient:nt(a),spot:nt(c)};return y(a,o.ambient),y(c,o.spot),p},e.LTRBRect=function(o,a,c,p){return Float32Array.of(o,a,c,p)},e.XYWHRect=function(o,a,c,p){return Float32Array.of(o,a,o+c,a+p)},e.LTRBiRect=function(o,a,c,p){return Int32Array.of(o,a,c,p)},e.XYWHiRect=function(o,a,c,p){return Int32Array.of(o,a,o+c,a+p)},e.RRectXY=function(o,a,c){return Float32Array.of(o[0],o[1],o[2],o[3],a,c,a,c,a,c,a,c)},e.MakeAnimatedImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeAnimatedImage(a,o.byteLength))?o:null},e.MakeImageFromEncoded=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._decodeImage(a,o.byteLength))?o:null};var ri=null;e.MakeImageFromCanvasImageSource=function(o){var a=o.width,c=o.height;ri||(ri=document.createElement("canvas")),ri.width=a,ri.height=c;var p=ri.getContext("2d",{willReadFrequently:!0});return p.drawImage(o,0,0),o=p.getImageData(0,0,a,c),e.MakeImage({width:a,height:c,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},o.data,4*a)},e.MakeImage=function(o,a,c){var p=e._malloc(a.length);return e.HEAPU8.set(a,p),e._MakeImage(o,p,a.length,c)},e.MakeVertices=function(o,a,c,p,b,E){var N=b&&b.length||0,W=0;return c&&c.length&&(W|=1),p&&p.length&&(W|=2),E===void 0||E||(W|=4),o=new e._VerticesBuilder(o,a.length/2,N,W),A(a,"HEAPF32",o.positions()),o.texCoords()&&A(c,"HEAPF32",o.texCoords()),o.colors()&&A(m(p),"HEAPU32",o.colors()),o.indices()&&A(b,"HEAPU16",o.indices()),o.detach()},e.Matrix={},e.Matrix.identity=function(){return s(3)},e.Matrix.invert=function(o){var a=o[0]*o[4]*o[8]+o[1]*o[5]*o[6]+o[2]*o[3]*o[7]-o[2]*o[4]*o[6]-o[1]*o[3]*o[8]-o[0]*o[5]*o[7];return a?[(o[4]*o[8]-o[5]*o[7])/a,(o[2]*o[7]-o[1]*o[8])/a,(o[1]*o[5]-o[2]*o[4])/a,(o[5]*o[6]-o[3]*o[8])/a,(o[0]*o[8]-o[2]*o[6])/a,(o[2]*o[3]-o[0]*o[5])/a,(o[3]*o[7]-o[4]*o[6])/a,(o[1]*o[6]-o[0]*o[7])/a,(o[0]*o[4]-o[1]*o[3])/a]:null},e.Matrix.mapPoints=function(o,a){for(var c=0;c<a.length;c+=2){var p=a[c],b=a[c+1],E=o[6]*p+o[7]*b+o[8],N=o[3]*p+o[4]*b+o[5];a[c]=(o[0]*p+o[1]*b+o[2])/E,a[c+1]=N/E}return a},e.Matrix.multiply=function(){return ei(3,arguments)},e.Matrix.rotated=function(o,a,c){a=a||0,c=c||0;var p=Math.sin(o);return o=Math.cos(o),[o,-p,Rt(p,c,1-o,a),p,o,Rt(-p,a,1-o,c),0,0,1]},e.Matrix.scaled=function(o,a,c,p){c=c||0,p=p||0;var b=r([o,a],s(3),3,0,1);return r([c-o*c,p-a*p],b,3,2,0)},e.Matrix.skewed=function(o,a,c,p){c=c||0,p=p||0;var b=r([o,a],s(3),3,1,-1);return r([-o*c,-a*p],b,3,2,0)},e.Matrix.translated=function(o,a){return r(arguments,s(3),3,2,0)},e.Vector={},e.Vector.dot=function(o,a){return o.map(function(c,p){return c*a[p]}).reduce(function(c,p){return c+p})},e.Vector.lengthSquared=function(o){return e.Vector.dot(o,o)},e.Vector.length=function(o){return Math.sqrt(e.Vector.lengthSquared(o))},e.Vector.mulScalar=function(o,a){return o.map(function(c){return c*a})},e.Vector.add=function(o,a){return o.map(function(c,p){return c+a[p]})},e.Vector.sub=function(o,a){return o.map(function(c,p){return c-a[p]})},e.Vector.dist=function(o,a){return e.Vector.length(e.Vector.sub(o,a))},e.Vector.normalize=function(o){return e.Vector.mulScalar(o,1/e.Vector.length(o))},e.Vector.cross=function(o,a){return[o[1]*a[2]-o[2]*a[1],o[2]*a[0]-o[0]*a[2],o[0]*a[1]-o[1]*a[0]]},e.M44={},e.M44.identity=function(){return s(4)},e.M44.translated=function(o){return r(o,s(4),4,3,0)},e.M44.scaled=function(o){return r(o,s(4),4,0,1)},e.M44.rotated=function(o,a){return e.M44.rotatedUnitSinCos(e.Vector.normalize(o),Math.sin(a),Math.cos(a))},e.M44.rotatedUnitSinCos=function(o,a,c){var p=o[0],b=o[1];o=o[2];var E=1-c;return[E*p*p+c,E*p*b-a*o,E*p*o+a*b,0,E*p*b+a*o,E*b*b+c,E*b*o-a*p,0,E*p*o-a*b,E*b*o+a*p,E*o*o+c,0,0,0,0,1]},e.M44.lookat=function(o,a,c){a=e.Vector.normalize(e.Vector.sub(a,o)),c=e.Vector.normalize(c),c=e.Vector.normalize(e.Vector.cross(a,c));var p=e.M44.identity();return r(c,p,4,0,0),r(e.Vector.cross(c,a),p,4,1,0),r(e.Vector.mulScalar(a,-1),p,4,2,0),r(o,p,4,3,0),o=e.M44.invert(p),o===null?e.M44.identity():o},e.M44.perspective=function(o,a,c){var p=1/(a-o);return c/=2,c=Math.cos(c)/Math.sin(c),[c,0,0,0,0,c,0,0,0,0,(a+o)*p,2*a*o*p,0,0,-1,1]},e.M44.rc=function(o,a,c){return o[4*a+c]},e.M44.multiply=function(){return ei(4,arguments)},e.M44.invert=function(o){var a=o[0],c=o[4],p=o[8],b=o[12],E=o[1],N=o[5],W=o[9],Q=o[13],J=o[2],dt=o[6],mt=o[10],S=o[14],k=o[3],st=o[7],vt=o[11];o=o[15];var Tt=a*N-c*E,Vt=a*W-p*E,qt=a*Q-b*E,Lt=c*W-p*N,L=c*Q-b*N,f=p*Q-b*W,w=J*st-dt*k,M=J*vt-mt*k,R=J*o-S*k,I=dt*vt-mt*st,z=dt*o-S*st,K=mt*o-S*vt,bt=Tt*K-Vt*z+qt*I+Lt*R-L*M+f*w,Pt=1/bt;return bt===0||Pt===1/0?null:(Tt*=Pt,Vt*=Pt,qt*=Pt,Lt*=Pt,L*=Pt,f*=Pt,w*=Pt,M*=Pt,R*=Pt,I*=Pt,z*=Pt,K*=Pt,a=[N*K-W*z+Q*I,W*R-E*K-Q*M,E*z-N*R+Q*w,N*M-E*I-W*w,p*z-c*K-b*I,a*K-p*R+b*M,c*R-a*z-b*w,a*I-c*M+p*w,st*f-vt*L+o*Lt,vt*qt-k*f-o*Vt,k*L-st*qt+o*Tt,st*Vt-k*Lt-vt*Tt,mt*L-dt*f-S*Lt,J*f-mt*qt+S*Vt,dt*qt-J*L-S*Tt,J*Lt-dt*Vt+mt*Tt],a.every(function(he){return!isNaN(he)&&he!==1/0&&he!==-1/0})?a:null)},e.M44.transpose=function(o){return[o[0],o[4],o[8],o[12],o[1],o[5],o[9],o[13],o[2],o[6],o[10],o[14],o[3],o[7],o[11],o[15]]},e.M44.mustInvert=function(o){if(o=e.M44.invert(o),o===null)throw"Matrix not invertible";return o},e.M44.setupCamera=function(o,a,c){var p=e.M44.lookat(c.eye,c.coa,c.up);return c=e.M44.perspective(c.near,c.far,c.angle),a=[(o[2]-o[0])/2,(o[3]-o[1])/2,a],o=e.M44.multiply(e.M44.translated([(o[0]+o[2])/2,(o[1]+o[3])/2,0]),e.M44.scaled(a)),e.M44.multiply(o,c,p,e.M44.mustInvert(o))},e.ColorMatrix={},e.ColorMatrix.identity=function(){var o=new Float32Array(20);return o[0]=1,o[6]=1,o[12]=1,o[18]=1,o},e.ColorMatrix.scaled=function(o,a,c,p){var b=new Float32Array(20);return b[0]=o,b[6]=a,b[12]=c,b[18]=p,b};var js=[[6,7,11,12],[0,10,2,12],[0,1,5,6]];e.ColorMatrix.rotated=function(o,a,c){var p=e.ColorMatrix.identity();return o=js[o],p[o[0]]=c,p[o[1]]=a,p[o[2]]=-a,p[o[3]]=c,p},e.ColorMatrix.postTranslate=function(o,a,c,p,b){return o[4]+=a,o[9]+=c,o[14]+=p,o[19]+=b,o},e.ColorMatrix.concat=function(o,a){for(var c=new Float32Array(20),p=0,b=0;20>b;b+=5){for(var E=0;4>E;E++)c[p++]=o[b]*a[E]+o[b+1]*a[E+5]+o[b+2]*a[E+10]+o[b+3]*a[E+15];c[p++]=o[b]*a[4]+o[b+1]*a[9]+o[b+2]*a[14]+o[b+3]*a[19]+o[b+4]}return c},function(o){o.Td=o.Td||[],o.Td.push(function(){function a(S){return S&&(S.dir=S.dir===0?o.TextDirection.RTL:o.TextDirection.LTR),S}function c(S){if(!S||!S.length)return[];for(var k=[],st=0;st<S.length;st+=5){var vt=o.LTRBRect(S[st],S[st+1],S[st+2],S[st+3]),Tt=o.TextDirection.LTR;S[st+4]===0&&(Tt=o.TextDirection.RTL),k.push({rect:vt,dir:Tt})}return o._free(S.byteOffset),k}function p(S){return S=S||{},S.weight===void 0&&(S.weight=o.FontWeight.Normal),S.width=S.width||o.FontWidth.Normal,S.slant=S.slant||o.FontSlant.Upright,S}function b(S){if(!S||!S.length)return ht;for(var k=[],st=0;st<S.length;st++){var vt=E(S[st]);k.push(vt)}return A(k,"HEAPU32")}function E(S){if(Q[S])return Q[S];var k=Zt(S)+1,st=o._malloc(k);return Qt(S,ot,st,k),Q[S]=st}function N(S){if(S._colorPtr=T(S.color),S._foregroundColorPtr=ht,S._backgroundColorPtr=ht,S._decorationColorPtr=ht,S.foregroundColor&&(S._foregroundColorPtr=T(S.foregroundColor,J)),S.backgroundColor&&(S._backgroundColorPtr=T(S.backgroundColor,dt)),S.decorationColor&&(S._decorationColorPtr=T(S.decorationColor,mt)),Array.isArray(S.fontFamilies)&&S.fontFamilies.length?(S._fontFamiliesPtr=b(S.fontFamilies),S._fontFamiliesLen=S.fontFamilies.length):(S._fontFamiliesPtr=ht,S._fontFamiliesLen=0),S.locale){var k=S.locale;S._localePtr=E(k),S._localeLen=Zt(k)+1}else S._localePtr=ht,S._localeLen=0;if(Array.isArray(S.shadows)&&S.shadows.length){k=S.shadows;var st=k.map(function(L){return L.color||o.BLACK}),vt=k.map(function(L){return L.blurRadius||0});S._shadowLen=k.length;for(var Tt=o._malloc(8*k.length),Vt=Tt/4,qt=0;qt<k.length;qt++){var Lt=k[qt].offset||[0,0];o.HEAPF32[Vt]=Lt[0],o.HEAPF32[Vt+1]=Lt[1],Vt+=2}S._shadowColorsPtr=O(st).be,S._shadowOffsetsPtr=Tt,S._shadowBlurRadiiPtr=A(vt,"HEAPF32")}else S._shadowLen=0,S._shadowColorsPtr=ht,S._shadowOffsetsPtr=ht,S._shadowBlurRadiiPtr=ht;Array.isArray(S.fontFeatures)&&S.fontFeatures.length?(k=S.fontFeatures,st=k.map(function(L){return L.name}),vt=k.map(function(L){return L.value}),S._fontFeatureLen=k.length,S._fontFeatureNamesPtr=b(st),S._fontFeatureValuesPtr=A(vt,"HEAPU32")):(S._fontFeatureLen=0,S._fontFeatureNamesPtr=ht,S._fontFeatureValuesPtr=ht),Array.isArray(S.fontVariations)&&S.fontVariations.length?(k=S.fontVariations,st=k.map(function(L){return L.axis}),vt=k.map(function(L){return L.value}),S._fontVariationLen=k.length,S._fontVariationAxesPtr=b(st),S._fontVariationValuesPtr=A(vt,"HEAPF32")):(S._fontVariationLen=0,S._fontVariationAxesPtr=ht,S._fontVariationValuesPtr=ht)}function W(S){o._free(S._fontFamiliesPtr),o._free(S._shadowColorsPtr),o._free(S._shadowOffsetsPtr),o._free(S._shadowBlurRadiiPtr),o._free(S._fontFeatureNamesPtr),o._free(S._fontFeatureValuesPtr),o._free(S._fontVariationAxesPtr),o._free(S._fontVariationValuesPtr)}o.Paragraph.prototype.getRectsForRange=function(S,k,st,vt){return S=this._getRectsForRange(S,k,st,vt),c(S)},o.Paragraph.prototype.getRectsForPlaceholders=function(){var S=this._getRectsForPlaceholders();return c(S)},o.Paragraph.prototype.getGlyphInfoAt=function(S){return a(this._getGlyphInfoAt(S))},o.Paragraph.prototype.getClosestGlyphInfoAtCoordinate=function(S,k){return a(this._getClosestGlyphInfoAtCoordinate(S,k))},o.TypefaceFontProvider.prototype.registerFont=function(S,k){if(S=o.Typeface.MakeFreeTypeFaceFromData(S),!S)return null;k=E(k),this._registerFont(S,k)},o.ParagraphStyle=function(S){if(S.disableHinting=S.disableHinting||!1,S.ellipsis){var k=S.ellipsis;S._ellipsisPtr=E(k),S._ellipsisLen=Zt(k)+1}else S._ellipsisPtr=ht,S._ellipsisLen=0;return S.heightMultiplier==null&&(S.heightMultiplier=-1),S.maxLines=S.maxLines||0,S.replaceTabCharacters=S.replaceTabCharacters||!1,k=(k=S.strutStyle)||{},k.strutEnabled=k.strutEnabled||!1,k.strutEnabled&&Array.isArray(k.fontFamilies)&&k.fontFamilies.length?(k._fontFamiliesPtr=b(k.fontFamilies),k._fontFamiliesLen=k.fontFamilies.length):(k._fontFamiliesPtr=ht,k._fontFamiliesLen=0),k.fontStyle=p(k.fontStyle),k.fontSize==null&&(k.fontSize=-1),k.heightMultiplier==null&&(k.heightMultiplier=-1),k.halfLeading=k.halfLeading||!1,k.leading=k.leading||0,k.forceStrutHeight=k.forceStrutHeight||!1,S.strutStyle=k,S.textAlign=S.textAlign||o.TextAlign.Start,S.textDirection=S.textDirection||o.TextDirection.LTR,S.textHeightBehavior=S.textHeightBehavior||o.TextHeightBehavior.All,S.textStyle=o.TextStyle(S.textStyle),S.applyRoundingHack=S.applyRoundingHack!==!1,S},o.TextStyle=function(S){return S.color||(S.color=o.BLACK),S.decoration=S.decoration||0,S.decorationThickness=S.decorationThickness||0,S.decorationStyle=S.decorationStyle||o.DecorationStyle.Solid,S.textBaseline=S.textBaseline||o.TextBaseline.Alphabetic,S.fontSize==null&&(S.fontSize=-1),S.letterSpacing=S.letterSpacing||0,S.wordSpacing=S.wordSpacing||0,S.heightMultiplier==null&&(S.heightMultiplier=-1),S.halfLeading=S.halfLeading||!1,S.fontStyle=p(S.fontStyle),S};var Q={},J=o._malloc(16),dt=o._malloc(16),mt=o._malloc(16);o.ParagraphBuilder.Make=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._Make(S,k),W(S.textStyle),k},o.ParagraphBuilder.MakeFromFontProvider=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._MakeFromFontProvider(S,k),W(S.textStyle),k},o.ParagraphBuilder.MakeFromFontCollection=function(S,k){return N(S.textStyle),k=o.ParagraphBuilder._MakeFromFontCollection(S,k),W(S.textStyle),k},o.ParagraphBuilder.ShapeText=function(S,k,st){let vt=0;for(const Tt of k)vt+=Tt.length;if(vt!==S.length)throw"Accumulated block lengths must equal text.length";return o.ParagraphBuilder._ShapeText(S,k,st)},o.ParagraphBuilder.prototype.pushStyle=function(S){N(S),this._pushStyle(S),W(S)},o.ParagraphBuilder.prototype.pushPaintStyle=function(S,k,st){N(S),this._pushPaintStyle(S,k,st),W(S)},o.ParagraphBuilder.prototype.addPlaceholder=function(S,k,st,vt,Tt){st=st||o.PlaceholderAlignment.Baseline,vt=vt||o.TextBaseline.Alphabetic,this._addPlaceholder(S||0,k||0,st,vt,Tt||0)},o.ParagraphBuilder.prototype.setWordsUtf8=function(S){var k=A(S,"HEAPU32");this._setWordsUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setWordsUtf16=function(S){var k=A(S,"HEAPU32");this._setWordsUtf16(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf8=function(S){var k=A(S,"HEAPU32");this._setGraphemeBreaksUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setGraphemeBreaksUtf16=function(S){var k=A(S,"HEAPU32");this._setGraphemeBreaksUtf16(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setLineBreaksUtf8=function(S){var k=A(S,"HEAPU32");this._setLineBreaksUtf8(k,S&&S.length||0),y(k,S)},o.ParagraphBuilder.prototype.setLineBreaksUtf16=function(S){var k=A(S,"HEAPU32");this._setLineBreaksUtf16(k,S&&S.length||0),y(k,S)}})}(h),e.Td=e.Td||[],e.Td.push(function(){e.Path.prototype.op=function(o,a){return this._op(o,a)?this:null},e.Path.prototype.simplify=function(){return this._simplify()?this:null}}),e.Td=e.Td||[],e.Td.push(function(){e.Canvas.prototype.drawText=function(o,a,c,p,b){var E=Zt(o),N=e._malloc(E+1);Qt(o,ot,N,E+1),this._drawSimpleText(N,E,a,c,b,p),e._free(N)},e.Canvas.prototype.drawGlyphs=function(o,a,c,p,b,E){if(!(2*o.length<=a.length))throw"Not enough positions for the array of gyphs";e.Md(this.Kd);const N=A(o,"HEAPU16"),W=A(a,"HEAPF32");this._drawGlyphs(o.length,N,W,c,p,b,E),y(W,a),y(N,o)},e.Font.prototype.getGlyphBounds=function(o,a,c){var p=A(o,"HEAPU16"),b=e._malloc(16*o.length);return this._getGlyphWidthBounds(p,o.length,ht,b,a||null),a=new Float32Array(e.HEAPU8.buffer,b,4*o.length),y(p,o),c?(c.set(a),e._free(b),c):(o=Float32Array.from(a),e._free(b),o)},e.Font.prototype.getGlyphIDs=function(o,a,c){a||(a=o.length);var p=Zt(o)+1,b=e._malloc(p);return Qt(o,ot,b,p),o=e._malloc(2*a),a=this._getGlyphIDs(b,p-1,a,o),e._free(b),0>a?(e._free(o),null):(b=new Uint16Array(e.HEAPU8.buffer,o,a),c?(c.set(b),e._free(o),c):(c=Uint16Array.from(b),e._free(o),c))},e.Font.prototype.getGlyphIntercepts=function(o,a,c,p){var b=A(o,"HEAPU16"),E=A(a,"HEAPF32");return this._getGlyphIntercepts(b,o.length,!(o&&o._ck),E,a.length,!(a&&a._ck),c,p)},e.Font.prototype.getGlyphWidths=function(o,a,c){var p=A(o,"HEAPU16"),b=e._malloc(4*o.length);return this._getGlyphWidthBounds(p,o.length,b,ht,a||null),a=new Float32Array(e.HEAPU8.buffer,b,o.length),y(p,o),c?(c.set(a),e._free(b),c):(o=Float32Array.from(a),e._free(b),o)},e.FontMgr.FromData=function(){if(!arguments.length)return null;var o=arguments;if(o.length===1&&Array.isArray(o[0])&&(o=arguments[0]),!o.length)return null;for(var a=[],c=[],p=0;p<o.length;p++){var b=new Uint8Array(o[p]),E=A(b,"HEAPU8");a.push(E),c.push(b.byteLength)}return a=A(a,"HEAPU32"),c=A(c,"HEAPU32"),o=e.FontMgr._fromData(a,c,o.length),e._free(a),e._free(c),o},e.Typeface.MakeFreeTypeFaceFromData=function(o){o=new Uint8Array(o);var a=A(o,"HEAPU8");return(o=e.Typeface._MakeFreeTypeFaceFromData(a,o.byteLength))?o:null},e.Typeface.prototype.getGlyphIDs=function(o,a,c){a||(a=o.length);var p=Zt(o)+1,b=e._malloc(p);return Qt(o,ot,b,p),o=e._malloc(2*a),a=this._getGlyphIDs(b,p-1,a,o),e._free(b),0>a?(e._free(o),null):(b=new Uint16Array(e.HEAPU8.buffer,o,a),c?(c.set(b),e._free(o),c):(c=Uint16Array.from(b),e._free(o),c))},e.TextBlob.MakeOnPath=function(o,a,c,p){if(o&&o.length&&a&&a.countPoints()){if(a.countPoints()===1)return this.MakeFromText(o,c);p||(p=0);var b=c.getGlyphIDs(o);b=c.getGlyphWidths(b);var E=[];a=new e.ContourMeasureIter(a,!1,1);for(var N=a.next(),W=new Float32Array(4),Q=0;Q<o.length&&N;Q++){var J=b[Q];if(p+=J/2,p>N.length()){if(N.delete(),N=a.next(),!N){o=o.substring(0,Q);break}p=J/2}N.getPosTan(p,W);var dt=W[2],mt=W[3];E.push(dt,mt,W[0]-J/2*dt,W[1]-J/2*mt),p+=J/2}return o=this.MakeFromRSXform(o,E,c),N&&N.delete(),a.delete(),o}},e.TextBlob.MakeFromRSXform=function(o,a,c){var p=Zt(o)+1,b=e._malloc(p);return Qt(o,ot,b,p),o=A(a,"HEAPF32"),c=e.TextBlob._MakeFromRSXform(b,p-1,o,c),e._free(b),c||null},e.TextBlob.MakeFromRSXformGlyphs=function(o,a,c){var p=A(o,"HEAPU16");return a=A(a,"HEAPF32"),c=e.TextBlob._MakeFromRSXformGlyphs(p,2*o.length,a,c),y(p,o),c||null},e.TextBlob.MakeFromGlyphs=function(o,a){var c=A(o,"HEAPU16");return a=e.TextBlob._MakeFromGlyphs(c,2*o.length,a),y(c,o),a||null},e.TextBlob.MakeFromText=function(o,a){var c=Zt(o)+1,p=e._malloc(c);return Qt(o,ot,p,c),o=e.TextBlob._MakeFromText(p,c-1,a),e._free(p),o||null},e.MallocGlyphIDs=function(o){return e.Malloc(Uint16Array,o)}}),e.Td=e.Td||[],e.Td.push(function(){e.MakePicture=function(o){o=new Uint8Array(o);var a=e._malloc(o.byteLength);return e.HEAPU8.set(o,a),(o=e._MakePicture(a,o.byteLength))?o:null}}),e.Td=e.Td||[],e.Td.push(function(){e.RuntimeEffect.Make=function(o,a){return e.RuntimeEffect._Make(o,{onError:a||function(c){console.log("RuntimeEffect error",c)}})},e.RuntimeEffect.MakeForBlender=function(o,a){return e.RuntimeEffect._MakeForBlender(o,{onError:a||function(c){console.log("RuntimeEffect error",c)}})},e.RuntimeEffect.prototype.makeShader=function(o,a){var c=!o._ck,p=A(o,"HEAPF32");return a=D(a),this._makeShader(p,4*o.length,c,a)},e.RuntimeEffect.prototype.makeShaderWithChildren=function(o,a,c){var p=!o._ck,b=A(o,"HEAPF32");c=D(c);for(var E=[],N=0;N<a.length;N++)E.push(a[N].Jd.Rd);return a=A(E,"HEAPU32"),this._makeShaderWithChildren(b,4*o.length,p,a,E.length,c)},e.RuntimeEffect.prototype.makeBlender=function(o){var a=!o._ck,c=A(o,"HEAPF32");return this._makeBlender(c,4*o.length,a)}}),function(){function o(L){for(var f=0;f<L.length;f++)if(L[f]!==void 0&&!Number.isFinite(L[f]))return!1;return!0}function a(L){var f=e.getColorComponents(L);L=f[0];var w=f[1],M=f[2];return f=f[3],f===1?(L=L.toString(16).toLowerCase(),w=w.toString(16).toLowerCase(),M=M.toString(16).toLowerCase(),L=L.length===1?"0"+L:L,w=w.length===1?"0"+w:w,M=M.length===1?"0"+M:M,"#"+L+w+M):(f=f===0||f===1?f:f.toFixed(8),"rgba("+L+", "+w+", "+M+", "+f+")")}function c(L){return e.parseColorString(L,Vt)}function p(L){if(L=qt.exec(L),!L)return null;var f=parseFloat(L[4]),w=16;switch(L[5]){case"em":case"rem":w=16*f;break;case"pt":w=4*f/3;break;case"px":w=f;break;case"pc":w=16*f;break;case"in":w=96*f;break;case"cm":w=96*f/2.54;break;case"mm":w=3.7795275590551185*f;break;case"q":w=.9448818897637796*f;break;case"%":w=.21333333333333335*f}return{style:L[1],variant:L[2],weight:L[3],sizePx:w,family:L[6].trim()}}function b(L){this.Ld=L,this.Od=new e.Paint,this.Od.setAntiAlias(!0),this.Od.setStrokeMiter(10),this.Od.setStrokeCap(e.StrokeCap.Butt),this.Od.setStrokeJoin(e.StrokeJoin.Miter),this.Re="10px monospace",this.me=new e.Font(null,10),this.me.setSubpixel(!0),this.ae=this.ge=e.BLACK,this.ve=0,this.Je=e.TRANSPARENT,this.xe=this.we=0,this.Ke=this.ie=1,this.Ie=0,this.ue=[],this.Nd=e.BlendMode.SrcOver,this.Od.setStrokeWidth(this.Ke),this.Od.setBlendMode(this.Nd),this.Qd=new e.Path,this.Sd=e.Matrix.identity(),this.lf=[],this.Be=[],this.le=function(){this.Qd.delete(),this.Od.delete(),this.me.delete(),this.Be.forEach(function(f){f.le()})},Object.defineProperty(this,"currentTransform",{enumerable:!0,get:function(){return{a:this.Sd[0],c:this.Sd[1],e:this.Sd[2],b:this.Sd[3],d:this.Sd[4],f:this.Sd[5]}},set:function(f){f.a&&this.setTransform(f.a,f.b,f.c,f.d,f.e,f.f)}}),Object.defineProperty(this,"fillStyle",{enumerable:!0,get:function(){return l(this.ae)?a(this.ae):this.ae},set:function(f){typeof f=="string"?this.ae=c(f):f.te&&(this.ae=f)}}),Object.defineProperty(this,"font",{enumerable:!0,get:function(){return this.Re},set:function(f){var w=p(f),M=w.family;w.typeface=Lt[M]?Lt[M][(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal")]||Lt[M]["*"]:null,w&&(this.me.setSize(w.sizePx),this.me.setTypeface(w.typeface),this.Re=f)}}),Object.defineProperty(this,"globalAlpha",{enumerable:!0,get:function(){return this.ie},set:function(f){!isFinite(f)||0>f||1<f||(this.ie=f)}}),Object.defineProperty(this,"globalCompositeOperation",{enumerable:!0,get:function(){switch(this.Nd){case e.BlendMode.SrcOver:return"source-over";case e.BlendMode.DstOver:return"destination-over";case e.BlendMode.Src:return"copy";case e.BlendMode.Dst:return"destination";case e.BlendMode.Clear:return"clear";case e.BlendMode.SrcIn:return"source-in";case e.BlendMode.DstIn:return"destination-in";case e.BlendMode.SrcOut:return"source-out";case e.BlendMode.DstOut:return"destination-out";case e.BlendMode.SrcATop:return"source-atop";case e.BlendMode.DstATop:return"destination-atop";case e.BlendMode.Xor:return"xor";case e.BlendMode.Plus:return"lighter";case e.BlendMode.Multiply:return"multiply";case e.BlendMode.Screen:return"screen";case e.BlendMode.Overlay:return"overlay";case e.BlendMode.Darken:return"darken";case e.BlendMode.Lighten:return"lighten";case e.BlendMode.ColorDodge:return"color-dodge";case e.BlendMode.ColorBurn:return"color-burn";case e.BlendMode.HardLight:return"hard-light";case e.BlendMode.SoftLight:return"soft-light";case e.BlendMode.Difference:return"difference";case e.BlendMode.Exclusion:return"exclusion";case e.BlendMode.Hue:return"hue";case e.BlendMode.Saturation:return"saturation";case e.BlendMode.Color:return"color";case e.BlendMode.Luminosity:return"luminosity"}},set:function(f){switch(f){case"source-over":this.Nd=e.BlendMode.SrcOver;break;case"destination-over":this.Nd=e.BlendMode.DstOver;break;case"copy":this.Nd=e.BlendMode.Src;break;case"destination":this.Nd=e.BlendMode.Dst;break;case"clear":this.Nd=e.BlendMode.Clear;break;case"source-in":this.Nd=e.BlendMode.SrcIn;break;case"destination-in":this.Nd=e.BlendMode.DstIn;break;case"source-out":this.Nd=e.BlendMode.SrcOut;break;case"destination-out":this.Nd=e.BlendMode.DstOut;break;case"source-atop":this.Nd=e.BlendMode.SrcATop;break;case"destination-atop":this.Nd=e.BlendMode.DstATop;break;case"xor":this.Nd=e.BlendMode.Xor;break;case"lighter":this.Nd=e.BlendMode.Plus;break;case"plus-lighter":this.Nd=e.BlendMode.Plus;break;case"plus-darker":throw"plus-darker is not supported";case"multiply":this.Nd=e.BlendMode.Multiply;break;case"screen":this.Nd=e.BlendMode.Screen;break;case"overlay":this.Nd=e.BlendMode.Overlay;break;case"darken":this.Nd=e.BlendMode.Darken;break;case"lighten":this.Nd=e.BlendMode.Lighten;break;case"color-dodge":this.Nd=e.BlendMode.ColorDodge;break;case"color-burn":this.Nd=e.BlendMode.ColorBurn;break;case"hard-light":this.Nd=e.BlendMode.HardLight;break;case"soft-light":this.Nd=e.BlendMode.SoftLight;break;case"difference":this.Nd=e.BlendMode.Difference;break;case"exclusion":this.Nd=e.BlendMode.Exclusion;break;case"hue":this.Nd=e.BlendMode.Hue;break;case"saturation":this.Nd=e.BlendMode.Saturation;break;case"color":this.Nd=e.BlendMode.Color;break;case"luminosity":this.Nd=e.BlendMode.Luminosity;break;default:return}this.Od.setBlendMode(this.Nd)}}),Object.defineProperty(this,"imageSmoothingEnabled",{enumerable:!0,get:function(){return!0},set:function(){}}),Object.defineProperty(this,"imageSmoothingQuality",{enumerable:!0,get:function(){return"high"},set:function(){}}),Object.defineProperty(this,"lineCap",{enumerable:!0,get:function(){switch(this.Od.getStrokeCap()){case e.StrokeCap.Butt:return"butt";case e.StrokeCap.Round:return"round";case e.StrokeCap.Square:return"square"}},set:function(f){switch(f){case"butt":this.Od.setStrokeCap(e.StrokeCap.Butt);break;case"round":this.Od.setStrokeCap(e.StrokeCap.Round);break;case"square":this.Od.setStrokeCap(e.StrokeCap.Square)}}}),Object.defineProperty(this,"lineDashOffset",{enumerable:!0,get:function(){return this.Ie},set:function(f){isFinite(f)&&(this.Ie=f)}}),Object.defineProperty(this,"lineJoin",{enumerable:!0,get:function(){switch(this.Od.getStrokeJoin()){case e.StrokeJoin.Miter:return"miter";case e.StrokeJoin.Round:return"round";case e.StrokeJoin.Bevel:return"bevel"}},set:function(f){switch(f){case"miter":this.Od.setStrokeJoin(e.StrokeJoin.Miter);break;case"round":this.Od.setStrokeJoin(e.StrokeJoin.Round);break;case"bevel":this.Od.setStrokeJoin(e.StrokeJoin.Bevel)}}}),Object.defineProperty(this,"lineWidth",{enumerable:!0,get:function(){return this.Od.getStrokeWidth()},set:function(f){0>=f||!f||(this.Ke=f,this.Od.setStrokeWidth(f))}}),Object.defineProperty(this,"miterLimit",{enumerable:!0,get:function(){return this.Od.getStrokeMiter()},set:function(f){0>=f||!f||this.Od.setStrokeMiter(f)}}),Object.defineProperty(this,"shadowBlur",{enumerable:!0,get:function(){return this.ve},set:function(f){0>f||!isFinite(f)||(this.ve=f)}}),Object.defineProperty(this,"shadowColor",{enumerable:!0,get:function(){return a(this.Je)},set:function(f){this.Je=c(f)}}),Object.defineProperty(this,"shadowOffsetX",{enumerable:!0,get:function(){return this.we},set:function(f){isFinite(f)&&(this.we=f)}}),Object.defineProperty(this,"shadowOffsetY",{enumerable:!0,get:function(){return this.xe},set:function(f){isFinite(f)&&(this.xe=f)}}),Object.defineProperty(this,"strokeStyle",{enumerable:!0,get:function(){return a(this.ge)},set:function(f){typeof f=="string"?this.ge=c(f):f.te&&(this.ge=f)}}),this.arc=function(f,w,M,R,I,z){S(this.Qd,f,w,M,M,0,R,I,z)},this.arcTo=function(f,w,M,R,I){J(this.Qd,f,w,M,R,I)},this.beginPath=function(){this.Qd.delete(),this.Qd=new e.Path},this.bezierCurveTo=function(f,w,M,R,I,z){var K=this.Qd;o([f,w,M,R,I,z])&&(K.isEmpty()&&K.moveTo(f,w),K.cubicTo(f,w,M,R,I,z))},this.clearRect=function(f,w,M,R){this.Od.setStyle(e.PaintStyle.Fill),this.Od.setBlendMode(e.BlendMode.Clear),this.Ld.drawRect(e.XYWHRect(f,w,M,R),this.Od),this.Od.setBlendMode(this.Nd)},this.clip=function(f,w){typeof f=="string"?(w=f,f=this.Qd):f&&f.af&&(f=f.Ud),f||(f=this.Qd),f=f.copy(),w&&w.toLowerCase()==="evenodd"?f.setFillType(e.FillType.EvenOdd):f.setFillType(e.FillType.Winding),this.Ld.clipPath(f,e.ClipOp.Intersect,!0),f.delete()},this.closePath=function(){dt(this.Qd)},this.createImageData=function(){if(arguments.length===1){var f=arguments[0];return new W(new Uint8ClampedArray(4*f.width*f.height),f.width,f.height)}if(arguments.length===2){f=arguments[0];var w=arguments[1];return new W(new Uint8ClampedArray(4*f*w),f,w)}throw"createImageData expects 1 or 2 arguments, got "+arguments.length},this.createLinearGradient=function(f,w,M,R){if(o(arguments)){var I=new Q(f,w,M,R);return this.Be.push(I),I}},this.createPattern=function(f,w){return f=new vt(f,w),this.Be.push(f),f},this.createRadialGradient=function(f,w,M,R,I,z){if(o(arguments)){var K=new Tt(f,w,M,R,I,z);return this.Be.push(K),K}},this.drawImage=function(f){f instanceof N&&(f=f.tf());var w=this.Qe();if(arguments.length===3||arguments.length===5)var M=e.XYWHRect(arguments[1],arguments[2],arguments[3]||f.width(),arguments[4]||f.height()),R=e.XYWHRect(0,0,f.width(),f.height());else if(arguments.length===9)M=e.XYWHRect(arguments[5],arguments[6],arguments[7],arguments[8]),R=e.XYWHRect(arguments[1],arguments[2],arguments[3],arguments[4]);else throw"invalid number of args for drawImage, need 3, 5, or 9; got "+arguments.length;this.Ld.drawImageRect(f,R,M,w,!1),w.dispose()},this.ellipse=function(f,w,M,R,I,z,K,bt){S(this.Qd,f,w,M,R,I,z,K,bt)},this.Qe=function(){var f=this.Od.copy();if(f.setStyle(e.PaintStyle.Fill),l(this.ae)){var w=e.multiplyByAlpha(this.ae,this.ie);f.setColor(w)}else w=this.ae.te(this.Sd),f.setColor(e.Color(0,0,0,this.ie)),f.setShader(w);return f.dispose=function(){this.delete()},f},this.fill=function(f,w){if(typeof f=="string"?(w=f,f=this.Qd):f&&f.af&&(f=f.Ud),w==="evenodd")this.Qd.setFillType(e.FillType.EvenOdd);else{if(w!=="nonzero"&&w)throw"invalid fill rule";this.Qd.setFillType(e.FillType.Winding)}f||(f=this.Qd),w=this.Qe();var M=this.ye(w);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(f,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(f,w),w.dispose()},this.fillRect=function(f,w,M,R){var I=this.Qe(),z=this.ye(I);z&&(this.Ld.save(),this.re(),this.Ld.drawRect(e.XYWHRect(f,w,M,R),z),this.Ld.restore(),z.dispose()),this.Ld.drawRect(e.XYWHRect(f,w,M,R),I),I.dispose()},this.fillText=function(f,w,M){var R=this.Qe();f=e.TextBlob.MakeFromText(f,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(f,w,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(f,w,M,R),f.delete(),R.dispose()},this.getImageData=function(f,w,M,R){return(f=this.Ld.readPixels(f,w,{width:M,height:R,colorType:e.ColorType.RGBA_8888,alphaType:e.AlphaType.Unpremul,colorSpace:e.ColorSpace.SRGB}))?new W(new Uint8ClampedArray(f.buffer),M,R):null},this.getLineDash=function(){return this.ue.slice()},this.mf=function(f){var w=e.Matrix.invert(this.Sd);return e.Matrix.mapPoints(w,f),f},this.isPointInPath=function(f,w,M){var R=arguments;if(R.length===3)var I=this.Qd;else if(R.length===4)I=R[0],f=R[1],w=R[2],M=R[3];else throw"invalid arg count, need 3 or 4, got "+R.length;return!isFinite(f)||!isFinite(w)||(M=M||"nonzero",M!=="nonzero"&&M!=="evenodd")?!1:(R=this.mf([f,w]),f=R[0],w=R[1],I.setFillType(M==="nonzero"?e.FillType.Winding:e.FillType.EvenOdd),I.contains(f,w))},this.isPointInStroke=function(f,w){var M=arguments;if(M.length===2)var R=this.Qd;else if(M.length===3)R=M[0],f=M[1],w=M[2];else throw"invalid arg count, need 2 or 3, got "+M.length;return!isFinite(f)||!isFinite(w)?!1:(M=this.mf([f,w]),f=M[0],w=M[1],R=R.copy(),R.setFillType(e.FillType.Winding),R.stroke({width:this.lineWidth,miter_limit:this.miterLimit,cap:this.Od.getStrokeCap(),join:this.Od.getStrokeJoin(),precision:.3}),M=R.contains(f,w),R.delete(),M)},this.lineTo=function(f,w){k(this.Qd,f,w)},this.measureText=function(f){f=this.me.getGlyphIDs(f),f=this.me.getGlyphWidths(f);let w=0;for(const M of f)w+=M;return{width:w}},this.moveTo=function(f,w){var M=this.Qd;o([f,w])&&M.moveTo(f,w)},this.putImageData=function(f,w,M,R,I,z,K){if(o([w,M,R,I,z,K])){if(R===void 0)this.Ld.writePixels(f.data,f.width,f.height,w,M);else if(R=R||0,I=I||0,z=z||f.width,K=K||f.height,0>z&&(R+=z,z=Math.abs(z)),0>K&&(I+=K,K=Math.abs(K)),0>R&&(z+=R,R=0),0>I&&(K+=I,I=0),!(0>=z||0>=K)){f=e.MakeImage({width:f.width,height:f.height,alphaType:e.AlphaType.Unpremul,colorType:e.ColorType.RGBA_8888,colorSpace:e.ColorSpace.SRGB},f.data,4*f.width);var bt=e.XYWHRect(R,I,z,K);w=e.XYWHRect(w+R,M+I,z,K),M=e.Matrix.invert(this.Sd),this.Ld.save(),this.Ld.concat(M),this.Ld.drawImageRect(f,bt,w,null,!1),this.Ld.restore(),f.delete()}}},this.quadraticCurveTo=function(f,w,M,R){var I=this.Qd;o([f,w,M,R])&&(I.isEmpty()&&I.moveTo(f,w),I.quadTo(f,w,M,R))},this.rect=function(f,w,M,R){var I=this.Qd;f=e.XYWHRect(f,w,M,R),o(f)&&I.addRect(f)},this.resetTransform=function(){this.Qd.transform(this.Sd);var f=e.Matrix.invert(this.Sd);this.Ld.concat(f),this.Sd=this.Ld.getTotalMatrix()},this.restore=function(){var f=this.lf.pop();if(f){var w=e.Matrix.multiply(this.Sd,e.Matrix.invert(f.Jf));this.Qd.transform(w),this.Od.delete(),this.Od=f.ag,this.ue=f.Zf,this.Ke=f.mg,this.ge=f.lg,this.ae=f.fs,this.we=f.jg,this.xe=f.kg,this.ve=f.sb,this.Je=f.ig,this.ie=f.ga,this.Nd=f.Qf,this.Ie=f.$f,this.Re=f.Pf,this.Ld.restore(),this.Sd=this.Ld.getTotalMatrix()}},this.rotate=function(f){if(isFinite(f)){var w=e.Matrix.rotated(-f);this.Qd.transform(w),this.Ld.rotate(f/Math.PI*180,0,0),this.Sd=this.Ld.getTotalMatrix()}},this.save=function(){if(this.ae.se){var f=this.ae.se();this.Be.push(f)}else f=this.ae;if(this.ge.se){var w=this.ge.se();this.Be.push(w)}else w=this.ge;this.lf.push({Jf:this.Sd.slice(),Zf:this.ue.slice(),mg:this.Ke,lg:w,fs:f,jg:this.we,kg:this.xe,sb:this.ve,ig:this.Je,ga:this.ie,$f:this.Ie,Qf:this.Nd,ag:this.Od.copy(),Pf:this.Re}),this.Ld.save()},this.scale=function(f,w){if(o(arguments)){var M=e.Matrix.scaled(1/f,1/w);this.Qd.transform(M),this.Ld.scale(f,w),this.Sd=this.Ld.getTotalMatrix()}},this.setLineDash=function(f){for(var w=0;w<f.length;w++)if(!isFinite(f[w])||0>f[w])return;f.length%2===1&&Array.prototype.push.apply(f,f),this.ue=f},this.setTransform=function(f,w,M,R,I,z){o(arguments)&&(this.resetTransform(),this.transform(f,w,M,R,I,z))},this.re=function(){var f=e.Matrix.invert(this.Sd);this.Ld.concat(f),this.Ld.concat(e.Matrix.translated(this.we,this.xe)),this.Ld.concat(this.Sd)},this.ye=function(f){var w=e.multiplyByAlpha(this.Je,this.ie);if(!e.getColorComponents(w)[3]||!(this.ve||this.xe||this.we))return null;f=f.copy(),f.setColor(w);var M=e.MaskFilter.MakeBlur(e.BlurStyle.Normal,this.ve/2,!1);return f.setMaskFilter(M),f.dispose=function(){M.delete(),this.delete()},f},this.cf=function(){var f=this.Od.copy();if(f.setStyle(e.PaintStyle.Stroke),l(this.ge)){var w=e.multiplyByAlpha(this.ge,this.ie);f.setColor(w)}else w=this.ge.te(this.Sd),f.setColor(e.Color(0,0,0,this.ie)),f.setShader(w);if(f.setStrokeWidth(this.Ke),this.ue.length){var M=e.PathEffect.MakeDash(this.ue,this.Ie);f.setPathEffect(M)}return f.dispose=function(){M&&M.delete(),this.delete()},f},this.stroke=function(f){f=f?f.Ud:this.Qd;var w=this.cf(),M=this.ye(w);M&&(this.Ld.save(),this.re(),this.Ld.drawPath(f,M),this.Ld.restore(),M.dispose()),this.Ld.drawPath(f,w),w.dispose()},this.strokeRect=function(f,w,M,R){var I=this.cf(),z=this.ye(I);z&&(this.Ld.save(),this.re(),this.Ld.drawRect(e.XYWHRect(f,w,M,R),z),this.Ld.restore(),z.dispose()),this.Ld.drawRect(e.XYWHRect(f,w,M,R),I),I.dispose()},this.strokeText=function(f,w,M){var R=this.cf();f=e.TextBlob.MakeFromText(f,this.me);var I=this.ye(R);I&&(this.Ld.save(),this.re(),this.Ld.drawTextBlob(f,w,M,I),this.Ld.restore(),I.dispose()),this.Ld.drawTextBlob(f,w,M,R),f.delete(),R.dispose()},this.translate=function(f,w){if(o(arguments)){var M=e.Matrix.translated(-f,-w);this.Qd.transform(M),this.Ld.translate(f,w),this.Sd=this.Ld.getTotalMatrix()}},this.transform=function(f,w,M,R,I,z){f=[f,M,I,w,R,z,0,0,1],w=e.Matrix.invert(f),this.Qd.transform(w),this.Ld.concat(f),this.Sd=this.Ld.getTotalMatrix()},this.addHitRegion=function(){},this.clearHitRegions=function(){},this.drawFocusIfNeeded=function(){},this.removeHitRegion=function(){},this.scrollPathIntoView=function(){},Object.defineProperty(this,"canvas",{value:null,writable:!1})}function E(L){this.df=L,this.Kd=new b(L.getCanvas()),this.Se=[],this.decodeImage=function(f){if(f=e.MakeImageFromEncoded(f),!f)throw"Invalid input";return this.Se.push(f),new N(f)},this.loadFont=function(f,w){if(f=e.Typeface.MakeFreeTypeFaceFromData(f),!f)return null;this.Se.push(f);var M=(w.style||"normal")+"|"+(w.variant||"normal")+"|"+(w.weight||"normal");w=w.family,Lt[w]||(Lt[w]={"*":f}),Lt[w][M]=f},this.makePath2D=function(f){return f=new st(f),this.Se.push(f.Ud),f},this.getContext=function(f){return f==="2d"?this.Kd:null},this.toDataURL=function(f,w){this.df.flush();var M=this.df.makeImageSnapshot();if(M){f=f||"image/png";var R=e.ImageFormat.PNG;if(f==="image/jpeg"&&(R=e.ImageFormat.JPEG),w=M.encodeToBytes(R,w||.92)){if(M.delete(),f="data:"+f+";base64,",typeof Buffer<"u")w=Buffer.from(w).toString("base64");else{M=0,R=w.length;for(var I="",z;M<R;)z=w.slice(M,Math.min(M+32768,R)),I+=String.fromCharCode.apply(null,z),M+=32768;w=btoa(I)}return f+w}}},this.dispose=function(){this.Kd.le(),this.Se.forEach(function(f){f.delete()}),this.df.dispose()}}function N(L){this.width=L.width(),this.height=L.height(),this.naturalWidth=this.width,this.naturalHeight=this.height,this.tf=function(){return L}}function W(L,f,w){if(!f||w===0)throw"invalid dimensions, width and height must be non-zero";if(L.length%4)throw"arr must be a multiple of 4";w=w||L.length/(4*f),Object.defineProperty(this,"data",{value:L,writable:!1}),Object.defineProperty(this,"height",{value:w,writable:!1}),Object.defineProperty(this,"width",{value:f,writable:!1})}function Q(L,f,w,M){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(R,I){if(0>R||1<R||!isFinite(R))throw"offset must be between 0 and 1 inclusively";I=c(I);var z=this.Zd.indexOf(R);if(z!==-1)this.ce[z]=I;else{for(z=0;z<this.Zd.length&&!(this.Zd[z]>R);z++);this.Zd.splice(z,0,R),this.ce.splice(z,0,I)}},this.se=function(){var R=new Q(L,f,w,M);return R.ce=this.ce.slice(),R.Zd=this.Zd.slice(),R},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(R){var I=[L,f,w,M];e.Matrix.mapPoints(R,I),R=I[0];var z=I[1],K=I[2];return I=I[3],this.le(),this.Wd=e.Shader.MakeLinearGradient([R,z],[K,I],this.ce,this.Zd,e.TileMode.Clamp)}}function J(L,f,w,M,R,I){if(o([f,w,M,R,I])){if(0>I)throw"radii cannot be negative";L.isEmpty()&&L.moveTo(f,w),L.arcToTangent(f,w,M,R,I)}}function dt(L){if(!L.isEmpty()){var f=L.getBounds();(f[3]-f[1]||f[2]-f[0])&&L.close()}}function mt(L,f,w,M,R,I,z){z=(z-I)/Math.PI*180,I=I/Math.PI*180,f=e.LTRBRect(f-M,w-R,f+M,w+R),1e-5>Math.abs(Math.abs(z)-360)?(w=z/2,L.arcToOval(f,I,w,!1),L.arcToOval(f,I+w,w,!1)):L.arcToOval(f,I,z,!1)}function S(L,f,w,M,R,I,z,K,bt){if(o([f,w,M,R,I,z,K])){if(0>M||0>R)throw"radii cannot be negative";var Pt=2*Math.PI,he=z%Pt;0>he&&(he+=Pt);var ni=he-z;z=he,K+=ni,!bt&&K-z>=Pt?K=z+Pt:bt&&z-K>=Pt?K=z-Pt:!bt&&z>K?K=z+(Pt-(z-K)%Pt):bt&&z<K&&(K=z-(Pt-(K-z)%Pt)),I?(bt=e.Matrix.rotated(I,f,w),I=e.Matrix.rotated(-I,f,w),L.transform(I),mt(L,f,w,M,R,z,K),L.transform(bt)):mt(L,f,w,M,R,z,K)}}function k(L,f,w){o([f,w])&&(L.isEmpty()&&L.moveTo(f,w),L.lineTo(f,w))}function st(L){this.Ud=null,this.Ud=typeof L=="string"?e.Path.MakeFromSVGString(L):L&&L.af?L.Ud.copy():new e.Path,this.af=function(){return this.Ud},this.addPath=function(f,w){w||(w={a:1,c:0,e:0,b:0,d:1,f:0}),this.Ud.addPath(f.Ud,[w.a,w.c,w.e,w.b,w.d,w.f])},this.arc=function(f,w,M,R,I,z){S(this.Ud,f,w,M,M,0,R,I,z)},this.arcTo=function(f,w,M,R,I){J(this.Ud,f,w,M,R,I)},this.bezierCurveTo=function(f,w,M,R,I,z){var K=this.Ud;o([f,w,M,R,I,z])&&(K.isEmpty()&&K.moveTo(f,w),K.cubicTo(f,w,M,R,I,z))},this.closePath=function(){dt(this.Ud)},this.ellipse=function(f,w,M,R,I,z,K,bt){S(this.Ud,f,w,M,R,I,z,K,bt)},this.lineTo=function(f,w){k(this.Ud,f,w)},this.moveTo=function(f,w){var M=this.Ud;o([f,w])&&M.moveTo(f,w)},this.quadraticCurveTo=function(f,w,M,R){var I=this.Ud;o([f,w,M,R])&&(I.isEmpty()&&I.moveTo(f,w),I.quadTo(f,w,M,R))},this.rect=function(f,w,M,R){var I=this.Ud;f=e.XYWHRect(f,w,M,R),o(f)&&I.addRect(f)}}function vt(L,f){switch(this.Wd=null,L instanceof N&&(L=L.tf()),this.Ef=L,this._transform=e.Matrix.identity(),f===""&&(f="repeat"),f){case"repeat-x":this.ze=e.TileMode.Repeat,this.Ae=e.TileMode.Decal;break;case"repeat-y":this.ze=e.TileMode.Decal,this.Ae=e.TileMode.Repeat;break;case"repeat":this.Ae=this.ze=e.TileMode.Repeat;break;case"no-repeat":this.Ae=this.ze=e.TileMode.Decal;break;default:throw"invalid repetition mode "+f}this.setTransform=function(w){w=[w.a,w.c,w.e,w.b,w.d,w.f,0,0,1],o(w)&&(this._transform=w)},this.se=function(){var w=new vt;return w.ze=this.ze,w.Ae=this.Ae,w},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(){return this.le(),this.Wd=this.Ef.makeShaderCubic(this.ze,this.Ae,.3333333333333333,.3333333333333333,this._transform)}}function Tt(L,f,w,M,R,I){this.Wd=null,this.ce=[],this.Zd=[],this.addColorStop=function(z,K){if(0>z||1<z||!isFinite(z))throw"offset must be between 0 and 1 inclusively";K=c(K);var bt=this.Zd.indexOf(z);if(bt!==-1)this.ce[bt]=K;else{for(bt=0;bt<this.Zd.length&&!(this.Zd[bt]>z);bt++);this.Zd.splice(bt,0,z),this.ce.splice(bt,0,K)}},this.se=function(){var z=new Tt(L,f,w,M,R,I);return z.ce=this.ce.slice(),z.Zd=this.Zd.slice(),z},this.le=function(){this.Wd&&(this.Wd.delete(),this.Wd=null)},this.te=function(z){var K=[L,f,M,R];e.Matrix.mapPoints(z,K);var bt=K[0],Pt=K[1],he=K[2];K=K[3];var ni=(Math.abs(z[0])+Math.abs(z[4]))/2;return z=w*ni,ni*=I,this.le(),this.Wd=e.Shader.MakeTwoPointConicalGradient([bt,Pt],z,[he,K],ni,this.ce,this.Zd,e.TileMode.Clamp)}}e._testing={};var Vt={aliceblue:Float32Array.of(.941,.973,1,1),antiquewhite:Float32Array.of(.98,.922,.843,1),aqua:Float32Array.of(0,1,1,1),aquamarine:Float32Array.of(.498,1,.831,1),azure:Float32Array.of(.941,1,1,1),beige:Float32Array.of(.961,.961,.863,1),bisque:Float32Array.of(1,.894,.769,1),black:Float32Array.of(0,0,0,1),blanchedalmond:Float32Array.of(1,.922,.804,1),blue:Float32Array.of(0,0,1,1),blueviolet:Float32Array.of(.541,.169,.886,1),brown:Float32Array.of(.647,.165,.165,1),burlywood:Float32Array.of(.871,.722,.529,1),cadetblue:Float32Array.of(.373,.62,.627,1),chartreuse:Float32Array.of(.498,1,0,1),chocolate:Float32Array.of(.824,.412,.118,1),coral:Float32Array.of(1,.498,.314,1),cornflowerblue:Float32Array.of(.392,.584,.929,1),cornsilk:Float32Array.of(1,.973,.863,1),crimson:Float32Array.of(.863,.078,.235,1),cyan:Float32Array.of(0,1,1,1),darkblue:Float32Array.of(0,0,.545,1),darkcyan:Float32Array.of(0,.545,.545,1),darkgoldenrod:Float32Array.of(.722,.525,.043,1),darkgray:Float32Array.of(.663,.663,.663,1),darkgreen:Float32Array.of(0,.392,0,1),darkgrey:Float32Array.of(.663,.663,.663,1),darkkhaki:Float32Array.of(.741,.718,.42,1),darkmagenta:Float32Array.of(.545,0,.545,1),darkolivegreen:Float32Array.of(.333,.42,.184,1),darkorange:Float32Array.of(1,.549,0,1),darkorchid:Float32Array.of(.6,.196,.8,1),darkred:Float32Array.of(.545,0,0,1),darksalmon:Float32Array.of(.914,.588,.478,1),darkseagreen:Float32Array.of(.561,.737,.561,1),darkslateblue:Float32Array.of(.282,.239,.545,1),darkslategray:Float32Array.of(.184,.31,.31,1),darkslategrey:Float32Array.of(.184,.31,.31,1),darkturquoise:Float32Array.of(0,.808,.82,1),darkviolet:Float32Array.of(.58,0,.827,1),deeppink:Float32Array.of(1,.078,.576,1),deepskyblue:Float32Array.of(0,.749,1,1),dimgray:Float32Array.of(.412,.412,.412,1),dimgrey:Float32Array.of(.412,.412,.412,1),dodgerblue:Float32Array.of(.118,.565,1,1),firebrick:Float32Array.of(.698,.133,.133,1),floralwhite:Float32Array.of(1,.98,.941,1),forestgreen:Float32Array.of(.133,.545,.133,1),fuchsia:Float32Array.of(1,0,1,1),gainsboro:Float32Array.of(.863,.863,.863,1),ghostwhite:Float32Array.of(.973,.973,1,1),gold:Float32Array.of(1,.843,0,1),goldenrod:Float32Array.of(.855,.647,.125,1),gray:Float32Array.of(.502,.502,.502,1),green:Float32Array.of(0,.502,0,1),greenyellow:Float32Array.of(.678,1,.184,1),grey:Float32Array.of(.502,.502,.502,1),honeydew:Float32Array.of(.941,1,.941,1),hotpink:Float32Array.of(1,.412,.706,1),indianred:Float32Array.of(.804,.361,.361,1),indigo:Float32Array.of(.294,0,.51,1),ivory:Float32Array.of(1,1,.941,1),khaki:Float32Array.of(.941,.902,.549,1),lavender:Float32Array.of(.902,.902,.98,1),lavenderblush:Float32Array.of(1,.941,.961,1),lawngreen:Float32Array.of(.486,.988,0,1),lemonchiffon:Float32Array.of(1,.98,.804,1),lightblue:Float32Array.of(.678,.847,.902,1),lightcoral:Float32Array.of(.941,.502,.502,1),lightcyan:Float32Array.of(.878,1,1,1),lightgoldenrodyellow:Float32Array.of(.98,.98,.824,1),lightgray:Float32Array.of(.827,.827,.827,1),lightgreen:Float32Array.of(.565,.933,.565,1),lightgrey:Float32Array.of(.827,.827,.827,1),lightpink:Float32Array.of(1,.714,.757,1),lightsalmon:Float32Array.of(1,.627,.478,1),lightseagreen:Float32Array.of(.125,.698,.667,1),lightskyblue:Float32Array.of(.529,.808,.98,1),lightslategray:Float32Array.of(.467,.533,.6,1),lightslategrey:Float32Array.of(.467,.533,.6,1),lightsteelblue:Float32Array.of(.69,.769,.871,1),lightyellow:Float32Array.of(1,1,.878,1),lime:Float32Array.of(0,1,0,1),limegreen:Float32Array.of(.196,.804,.196,1),linen:Float32Array.of(.98,.941,.902,1),magenta:Float32Array.of(1,0,1,1),maroon:Float32Array.of(.502,0,0,1),mediumaquamarine:Float32Array.of(.4,.804,.667,1),mediumblue:Float32Array.of(0,0,.804,1),mediumorchid:Float32Array.of(.729,.333,.827,1),mediumpurple:Float32Array.of(.576,.439,.859,1),mediumseagreen:Float32Array.of(.235,.702,.443,1),mediumslateblue:Float32Array.of(.482,.408,.933,1),mediumspringgreen:Float32Array.of(0,.98,.604,1),mediumturquoise:Float32Array.of(.282,.82,.8,1),mediumvioletred:Float32Array.of(.78,.082,.522,1),midnightblue:Float32Array.of(.098,.098,.439,1),mintcream:Float32Array.of(.961,1,.98,1),mistyrose:Float32Array.of(1,.894,.882,1),moccasin:Float32Array.of(1,.894,.71,1),navajowhite:Float32Array.of(1,.871,.678,1),navy:Float32Array.of(0,0,.502,1),oldlace:Float32Array.of(.992,.961,.902,1),olive:Float32Array.of(.502,.502,0,1),olivedrab:Float32Array.of(.42,.557,.137,1),orange:Float32Array.of(1,.647,0,1),orangered:Float32Array.of(1,.271,0,1),orchid:Float32Array.of(.855,.439,.839,1),palegoldenrod:Float32Array.of(.933,.91,.667,1),palegreen:Float32Array.of(.596,.984,.596,1),paleturquoise:Float32Array.of(.686,.933,.933,1),palevioletred:Float32Array.of(.859,.439,.576,1),papayawhip:Float32Array.of(1,.937,.835,1),peachpuff:Float32Array.of(1,.855,.725,1),peru:Float32Array.of(.804,.522,.247,1),pink:Float32Array.of(1,.753,.796,1),plum:Float32Array.of(.867,.627,.867,1),powderblue:Float32Array.of(.69,.878,.902,1),purple:Float32Array.of(.502,0,.502,1),rebeccapurple:Float32Array.of(.4,.2,.6,1),red:Float32Array.of(1,0,0,1),rosybrown:Float32Array.of(.737,.561,.561,1),royalblue:Float32Array.of(.255,.412,.882,1),saddlebrown:Float32Array.of(.545,.271,.075,1),salmon:Float32Array.of(.98,.502,.447,1),sandybrown:Float32Array.of(.957,.643,.376,1),seagreen:Float32Array.of(.18,.545,.341,1),seashell:Float32Array.of(1,.961,.933,1),sienna:Float32Array.of(.627,.322,.176,1),silver:Float32Array.of(.753,.753,.753,1),skyblue:Float32Array.of(.529,.808,.922,1),slateblue:Float32Array.of(.416,.353,.804,1),slategray:Float32Array.of(.439,.502,.565,1),slategrey:Float32Array.of(.439,.502,.565,1),snow:Float32Array.of(1,.98,.98,1),springgreen:Float32Array.of(0,1,.498,1),steelblue:Float32Array.of(.275,.51,.706,1),tan:Float32Array.of(.824,.706,.549,1),teal:Float32Array.of(0,.502,.502,1),thistle:Float32Array.of(.847,.749,.847,1),tomato:Float32Array.of(1,.388,.278,1),transparent:Float32Array.of(0,0,0,0),turquoise:Float32Array.of(.251,.878,.816,1),violet:Float32Array.of(.933,.51,.933,1),wheat:Float32Array.of(.961,.871,.702,1),white:Float32Array.of(1,1,1,1),whitesmoke:Float32Array.of(.961,.961,.961,1),yellow:Float32Array.of(1,1,0,1),yellowgreen:Float32Array.of(.604,.804,.196,1)};e._testing.parseColor=c,e._testing.colorToString=a;var qt=RegExp("(italic|oblique|normal|)\\s*(small-caps|normal|)\\s*(bold|bolder|lighter|[1-9]00|normal|)\\s*([\\d\\.]+)(px|pt|pc|in|cm|mm|%|em|ex|ch|rem|q)(.+)"),Lt={"Noto Mono":{"*":null},monospace:{"*":null}};e._testing.parseFontString=p,e.MakeCanvas=function(L,f){return(L=e.MakeSurface(L,f))?new E(L):null},e.ImageData=function(){if(arguments.length===2){var L=arguments[0],f=arguments[1];return new W(new Uint8ClampedArray(4*L*f),L,f)}if(arguments.length===3){var w=arguments[0];if(w.prototype.constructor!==Uint8ClampedArray)throw"bytes must be given as a Uint8ClampedArray";if(L=arguments[1],f=arguments[2],w%4)throw"bytes must be given in a multiple of 4";if(w%L)throw"bytes must divide evenly by width";if(f&&f!==w/(4*L))throw"invalid height given";return new W(w,L,w/(4*L))}throw"invalid number of arguments - takes 2 or 3, saw "+arguments.length}}()}(h);var B=Object.assign({},h),U="./this.program",et=(e,r)=>{throw r},ct=typeof window=="object",ut=typeof importScripts=="function",At=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string",yt="",ne,Se,Me;if(At){var We=ea,Ii=aa;yt=ut?Ii.dirname(yt)+"/":__dirname+"/",ne=(e,r)=>(e=e.startsWith("file://")?new URL(e):Ii.normalize(e),We.readFileSync(e,r?void 0:"utf8")),Me=e=>(e=ne(e,!0),e.buffer||(e=new Uint8Array(e)),e),Se=(e,r,s,l=!0)=>{e=e.startsWith("file://")?new URL(e):Ii.normalize(e),We.readFile(e,l?void 0:"utf8",(d,m)=>{d?s(d):r(l?m.buffer:m)})},!h.thisProgram&&1<process.argv.length&&(U=process.argv[1].replace(/\\/g,"/")),process.argv.slice(2),et=(e,r)=>{throw process.exitCode=e,r},h.inspect=()=>"[Emscripten Module object]"}else(ct||ut)&&(ut?yt=self.location.href:typeof document<"u"&&document.currentScript&&(yt=document.currentScript.src),n&&(yt=n),yt.indexOf("blob:")!==0?yt=yt.substr(0,yt.replace(/[?#].*/,"").lastIndexOf("/")+1):yt="",ne=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.send(null),r.responseText},ut&&(Me=e=>{var r=new XMLHttpRequest;return r.open("GET",e,!1),r.responseType="arraybuffer",r.send(null),new Uint8Array(r.response)}),Se=(e,r,s)=>{var l=new XMLHttpRequest;l.open("GET",e,!0),l.responseType="arraybuffer",l.onload=()=>{l.status==200||l.status==0&&l.response?r(l.response):s()},l.onerror=s,l.send(null)});var jn=h.print||console.log.bind(console),pe=h.printErr||console.error.bind(console);Object.assign(h,B),B=null,h.thisProgram&&(U=h.thisProgram),h.quit&&(et=h.quit);var $e;h.wasmBinary&&($e=h.wasmBinary);var Hn=h.noExitRuntime||!0;typeof WebAssembly!="object"&&Di("no native wasm support detected");var li,lt,Li=!1,se,ot,me,xe,$,wt,Z,mr;function gr(){var e=li.buffer;h.HEAP8=se=new Int8Array(e),h.HEAP16=me=new Int16Array(e),h.HEAP32=$=new Int32Array(e),h.HEAPU8=ot=new Uint8Array(e),h.HEAPU16=xe=new Uint16Array(e),h.HEAPU32=wt=new Uint32Array(e),h.HEAPF32=Z=new Float32Array(e),h.HEAPF64=mr=new Float64Array(e)}var Mt,vr=[],yr=[],wr=[];function Kn(){var e=h.preRun.shift();vr.unshift(e)}var be=0,Ge=null;function Di(e){throw h.onAbort&&h.onAbort(e),e="Aborted("+e+")",pe(e),Li=!0,e=new WebAssembly.RuntimeError(e+". Build with -sASSERTIONS for more info."),F(e),e}function Sr(e){return e.startsWith("data:application/octet-stream;base64,")}var Re;if(Re="canvaskit.wasm",!Sr(Re)){var br=Re;Re=h.locateFile?h.locateFile(br,yt):yt+br}function Pr(e){if(e==Re&&$e)return new Uint8Array($e);if(Me)return Me(e);throw"both async and sync fetching of the wasm failed"}function Vn(e){if(!$e&&(ct||ut)){if(typeof fetch=="function"&&!e.startsWith("file://"))return fetch(e,{credentials:"same-origin"}).then(r=>{if(!r.ok)throw"failed to load wasm binary file at '"+e+"'";return r.arrayBuffer()}).catch(()=>Pr(e));if(Se)return new Promise((r,s)=>{Se(e,l=>r(new Uint8Array(l)),s)})}return Promise.resolve().then(()=>Pr(e))}function Ar(e,r,s){return Vn(e).then(l=>WebAssembly.instantiate(l,r)).then(l=>l).then(s,l=>{pe("failed to asynchronously prepare wasm: "+l),Di(l)})}function qn(e,r){var s=Re;return $e||typeof WebAssembly.instantiateStreaming!="function"||Sr(s)||s.startsWith("file://")||At||typeof fetch!="function"?Ar(s,e,r):fetch(s,{credentials:"same-origin"}).then(l=>WebAssembly.instantiateStreaming(l,e).then(r,function(d){return pe("wasm streaming compile failed: "+d),pe("falling back to ArrayBuffer instantiation"),Ar(s,e,r)}))}function Yn(e){this.name="ExitStatus",this.message=`Program terminated with exit(${e})`,this.status=e}var zi=e=>{for(;0<e.length;)e.shift()(h)},Cr=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0,Pe=(e,r,s)=>{var l=r+s;for(s=r;e[s]&&!(s>=l);)++s;if(16<s-r&&e.buffer&&Cr)return Cr.decode(e.subarray(r,s));for(l="";r<s;){var d=e[r++];if(d&128){var m=e[r++]&63;if((d&224)==192)l+=String.fromCharCode((d&31)<<6|m);else{var P=e[r++]&63;d=(d&240)==224?(d&15)<<12|m<<6|P:(d&7)<<18|m<<12|P<<6|e[r++]&63,65536>d?l+=String.fromCharCode(d):(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023))}}else l+=String.fromCharCode(d)}return l},hi={};function Bi(e){for(;e.length;){var r=e.pop();e.pop()(r)}}function je(e){return this.fromWireType($[e>>2])}var Ne={},Ae={},ci={},_r=void 0;function ui(e){throw new _r(e)}function Jt(e,r,s){function l(v){v=s(v),v.length!==e.length&&ui("Mismatched type converter count");for(var y=0;y<e.length;++y)ae(e[y],v[y])}e.forEach(function(v){ci[v]=r});var d=Array(r.length),m=[],P=0;r.forEach((v,y)=>{Ae.hasOwnProperty(v)?d[y]=Ae[v]:(m.push(v),Ne.hasOwnProperty(v)||(Ne[v]=[]),Ne[v].push(()=>{d[y]=Ae[v],++P,P===m.length&&l(d)}))}),m.length===0&&l(d)}function di(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError(`Unknown type size: ${e}`)}}var Er=void 0;function _t(e){for(var r="";ot[e];)r+=Er[ot[e++]];return r}var ke=void 0;function ft(e){throw new ke(e)}function Xn(e,r,s={}){var l=r.name;if(e||ft(`type "${l}" must have a positive integer typeid pointer`),Ae.hasOwnProperty(e)){if(s.Wf)return;ft(`Cannot register type '${l}' twice`)}Ae[e]=r,delete ci[e],Ne.hasOwnProperty(e)&&(r=Ne[e],delete Ne[e],r.forEach(d=>d()))}function ae(e,r,s={}){if(!("argPackAdvance"in r))throw new TypeError("registerType registeredInstance requires argPackAdvance");Xn(e,r,s)}function Ui(e){ft(e.Jd.Vd.Pd.name+" instance already deleted")}var Wi=!1;function Tr(){}function Fr(e){--e.count.value,e.count.value===0&&(e.Yd?e.ee.ke(e.Yd):e.Vd.Pd.ke(e.Rd))}function Mr(e,r,s){return r===s?e:s.$d===void 0?null:(e=Mr(e,r,s.$d),e===null?null:s.Mf(e))}var xr={},He=[];function $i(){for(;He.length;){var e=He.pop();e.Jd.Ee=!1,e.delete()}}var Ke=void 0,Ve={};function Jn(e,r){for(r===void 0&&ft("ptr should not be undefined");e.$d;)r=e.Oe(r),e=e.$d;return Ve[r]}function fi(e,r){return r.Vd&&r.Rd||ui("makeClassHandle requires ptr and ptrType"),!!r.ee!=!!r.Yd&&ui("Both smartPtrType and smartPtr must be specified"),r.count={value:1},qe(Object.create(e,{Jd:{value:r}}))}function qe(e){return typeof FinalizationRegistry>"u"?(qe=r=>r,e):(Wi=new FinalizationRegistry(r=>{Fr(r.Jd)}),qe=r=>{var s=r.Jd;return s.Yd&&Wi.register(r,{Jd:s},r),r},Tr=r=>{Wi.unregister(r)},qe(e))}function ge(){}function Rr(e){if(e===void 0)return"_unknown";e=e.replace(/[^a-zA-Z0-9_]/g,"$");var r=e.charCodeAt(0);return 48<=r&&57>=r?`_${e}`:e}function Gi(e,r){return e=Rr(e),{[e]:function(){return r.apply(this,arguments)}}[e]}function ji(e,r,s){if(e[r].Xd===void 0){var l=e[r];e[r]=function(){return e[r].Xd.hasOwnProperty(arguments.length)||ft(`Function '${s}' called with an invalid number of arguments (${arguments.length}) - expects one of (${e[r].Xd})!`),e[r].Xd[arguments.length].apply(this,arguments)},e[r].Xd=[],e[r].Xd[l.Ce]=l}}function Hi(e,r,s){h.hasOwnProperty(e)?((s===void 0||h[e].Xd!==void 0&&h[e].Xd[s]!==void 0)&&ft(`Cannot register public name '${e}' twice`),ji(h,e,e),h.hasOwnProperty(s)&&ft(`Cannot register multiple overloads of a function with the same number of arguments (${s})!`),h[e].Xd[s]=r):(h[e]=r,s!==void 0&&(h[e].tg=s))}function Qn(e,r,s,l,d,m,P,v){this.name=e,this.constructor=r,this.Fe=s,this.ke=l,this.$d=d,this.Rf=m,this.Oe=P,this.Mf=v,this.cg=[]}function Ki(e,r,s){for(;r!==s;)r.Oe||ft(`Expected null or instance of ${s.name}, got an instance of ${r.name}`),e=r.Oe(e),r=r.$d;return e}function Zn(e,r){return r===null?(this.gf&&ft(`null is not a valid ${this.name}`),0):(r.Jd||ft(`Cannot pass "${qi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd))}function ts(e,r){if(r===null){if(this.gf&&ft(`null is not a valid ${this.name}`),this.Ve){var s=this.hf();return e!==null&&e.push(this.ke,s),s}return 0}if(r.Jd||ft(`Cannot pass "${qi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),!this.Ue&&r.Jd.Vd.Ue&&ft(`Cannot convert argument of type ${r.Jd.ee?r.Jd.ee.name:r.Jd.Vd.name} to parameter type ${this.name}`),s=Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd),this.Ve)switch(r.Jd.Yd===void 0&&ft("Passing raw pointer to smart pointer is illegal"),this.hg){case 0:r.Jd.ee===this?s=r.Jd.Yd:ft(`Cannot convert argument of type ${r.Jd.ee?r.Jd.ee.name:r.Jd.Vd.name} to parameter type ${this.name}`);break;case 1:s=r.Jd.Yd;break;case 2:if(r.Jd.ee===this)s=r.Jd.Yd;else{var l=r.clone();s=this.dg(s,Ht(function(){l.delete()})),e!==null&&e.push(this.ke,s)}break;default:ft("Unsupporting sharing policy")}return s}function es(e,r){return r===null?(this.gf&&ft(`null is not a valid ${this.name}`),0):(r.Jd||ft(`Cannot pass "${qi(r)}" as a ${this.name}`),r.Jd.Rd||ft(`Cannot pass deleted object as a pointer of type ${this.name}`),r.Jd.Vd.Ue&&ft(`Cannot convert argument of type ${r.Jd.Vd.name} to parameter type ${this.name}`),Ki(r.Jd.Rd,r.Jd.Vd.Pd,this.Pd))}function oe(e,r,s,l,d,m,P,v,y,A,O){this.name=e,this.Pd=r,this.gf=s,this.Ue=l,this.Ve=d,this.bg=m,this.hg=P,this.vf=v,this.hf=y,this.dg=A,this.ke=O,d||r.$d!==void 0?this.toWireType=ts:(this.toWireType=l?Zn:es,this.de=null)}function Nr(e,r,s){h.hasOwnProperty(e)||ui("Replacing nonexistant public symbol"),h[e].Xd!==void 0&&s!==void 0?h[e].Xd[s]=r:(h[e]=r,h[e].Ce=s)}var is=(e,r)=>{var s=[];return function(){if(s.length=0,Object.assign(s,arguments),e.includes("j")){var l=h["dynCall_"+e];l=s&&s.length?l.apply(null,[r].concat(s)):l.call(null,r)}else l=Mt.get(r).apply(null,s);return l}};function Nt(e,r){e=_t(e);var s=e.includes("j")?is(e,r):Mt.get(r);return typeof s!="function"&&ft(`unknown function pointer with signature ${e}: ${r}`),s}var kr=void 0;function Or(e){e=en(e);var r=_t(e);return ue(e),r}function Ye(e,r){function s(m){d[m]||Ae[m]||(ci[m]?ci[m].forEach(s):(l.push(m),d[m]=!0))}var l=[],d={};throw r.forEach(s),new kr(`${e}: `+l.map(Or).join([", "]))}function pi(e,r,s,l,d){var m=r.length;2>m&&ft("argTypes array size mismatch! Must at least get return value and 'this' types!");var P=r[1]!==null&&s!==null,v=!1;for(s=1;s<r.length;++s)if(r[s]!==null&&r[s].de===void 0){v=!0;break}var y=r[0].name!=="void",A=m-2,O=Array(A),D=[],H=[];return function(){if(arguments.length!==A&&ft(`function ${e} called with ${arguments.length} arguments, expected ${A} args!`),H.length=0,D.length=P?2:1,D[0]=d,P){var T=r[1].toWireType(H,this);D[1]=T}for(var Y=0;Y<A;++Y)O[Y]=r[Y+2].toWireType(H,arguments[Y]),D.push(O[Y]);if(Y=l.apply(null,D),v)Bi(H);else for(var nt=P?1:2;nt<r.length;nt++){var rt=nt===1?T:O[nt-2];r[nt].de!==null&&r[nt].de(rt)}return T=y?r[0].fromWireType(Y):void 0,T}}function mi(e,r){for(var s=[],l=0;l<e;l++)s.push(wt[r+4*l>>2]);return s}function Ir(){this.je=[void 0],this.sf=[]}var Gt=new Ir;function Vi(e){e>=Gt.Ge&&--Gt.get(e).wf===0&&Gt.Bf(e)}var jt=e=>(e||ft("Cannot use deleted val. handle = "+e),Gt.get(e).value),Ht=e=>{switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:return Gt.Af({wf:1,value:e})}};function rs(e,r,s){switch(r){case 0:return function(l){return this.fromWireType((s?se:ot)[l])};case 1:return function(l){return this.fromWireType((s?me:xe)[l>>1])};case 2:return function(l){return this.fromWireType((s?$:wt)[l>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Xe(e,r){var s=Ae[e];return s===void 0&&ft(r+" has unknown type "+Or(e)),s}function qi(e){if(e===null)return"null";var r=typeof e;return r==="object"||r==="array"||r==="function"?e.toString():""+e}function ns(e,r){switch(r){case 2:return function(s){return this.fromWireType(Z[s>>2])};case 3:return function(s){return this.fromWireType(mr[s>>3])};default:throw new TypeError("Unknown float type: "+e)}}function ss(e,r,s){switch(r){case 0:return s?function(l){return se[l]}:function(l){return ot[l]};case 1:return s?function(l){return me[l>>1]}:function(l){return xe[l>>1]};case 2:return s?function(l){return $[l>>2]}:function(l){return wt[l>>2]};default:throw new TypeError("Unknown integer type: "+e)}}var Qt=(e,r,s,l)=>{if(!(0<l))return 0;var d=s;l=s+l-1;for(var m=0;m<e.length;++m){var P=e.charCodeAt(m);if(55296<=P&&57343>=P){var v=e.charCodeAt(++m);P=65536+((P&1023)<<10)|v&1023}if(127>=P){if(s>=l)break;r[s++]=P}else{if(2047>=P){if(s+1>=l)break;r[s++]=192|P>>6}else{if(65535>=P){if(s+2>=l)break;r[s++]=224|P>>12}else{if(s+3>=l)break;r[s++]=240|P>>18,r[s++]=128|P>>12&63}r[s++]=128|P>>6&63}r[s++]=128|P&63}}return r[s]=0,s-d},Zt=e=>{for(var r=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);127>=l?r++:2047>=l?r+=2:55296<=l&&57343>=l?(r+=4,++s):r+=3}return r},Lr=typeof TextDecoder<"u"?new TextDecoder("utf-16le"):void 0,as=(e,r)=>{for(var s=e>>1,l=s+r/2;!(s>=l)&&xe[s];)++s;if(s<<=1,32<s-e&&Lr)return Lr.decode(ot.subarray(e,s));for(s="",l=0;!(l>=r/2);++l){var d=me[e+2*l>>1];if(d==0)break;s+=String.fromCharCode(d)}return s},os=(e,r,s)=>{if(s===void 0&&(s=2147483647),2>s)return 0;s-=2;var l=r;s=s<2*e.length?s/2:e.length;for(var d=0;d<s;++d)me[r>>1]=e.charCodeAt(d),r+=2;return me[r>>1]=0,r-l},ls=e=>2*e.length,hs=(e,r)=>{for(var s=0,l="";!(s>=r/4);){var d=$[e+4*s>>2];if(d==0)break;++s,65536<=d?(d-=65536,l+=String.fromCharCode(55296|d>>10,56320|d&1023)):l+=String.fromCharCode(d)}return l},cs=(e,r,s)=>{if(s===void 0&&(s=2147483647),4>s)return 0;var l=r;s=l+s-4;for(var d=0;d<e.length;++d){var m=e.charCodeAt(d);if(55296<=m&&57343>=m){var P=e.charCodeAt(++d);m=65536+((m&1023)<<10)|P&1023}if($[r>>2]=m,r+=4,r+4>s)break}return $[r>>2]=0,r-l},us=e=>{for(var r=0,s=0;s<e.length;++s){var l=e.charCodeAt(s);55296<=l&&57343>=l&&++s,r+=4}return r},ds={};function gi(e){var r=ds[e];return r===void 0?_t(e):r}var vi=[];function Dr(){function e(r){r.$$$embind_global$$$=r;var s=typeof $$$embind_global$$$=="object"&&r.$$$embind_global$$$==r;return s||delete r.$$$embind_global$$$,s}if(typeof globalThis=="object")return globalThis;if(typeof $$$embind_global$$$=="object"||(typeof lr=="object"&&e(lr)?$$$embind_global$$$=lr:typeof self=="object"&&e(self)&&($$$embind_global$$$=self),typeof $$$embind_global$$$=="object"))return $$$embind_global$$$;throw Error("unable to get global object.")}function fs(e){var r=vi.length;return vi.push(e),r}function ps(e,r){for(var s=Array(e),l=0;l<e;++l)s[l]=Xe(wt[r+4*l>>2],"parameter "+l);return s}var zr=[];function ms(e){var r=Array(e+1);return function(s,l,d){r[0]=s;for(var m=0;m<e;++m){var P=Xe(wt[l+4*m>>2],"parameter "+m);r[m+1]=P.readValueFromPointer(d),d+=P.argPackAdvance}return s=new(s.bind.apply(s,r)),Ht(s)}}var Br={};function gs(e){var r=e.getExtension("ANGLE_instanced_arrays");r&&(e.vertexAttribDivisor=function(s,l){r.vertexAttribDivisorANGLE(s,l)},e.drawArraysInstanced=function(s,l,d,m){r.drawArraysInstancedANGLE(s,l,d,m)},e.drawElementsInstanced=function(s,l,d,m,P){r.drawElementsInstancedANGLE(s,l,d,m,P)})}function vs(e){var r=e.getExtension("OES_vertex_array_object");r&&(e.createVertexArray=function(){return r.createVertexArrayOES()},e.deleteVertexArray=function(s){r.deleteVertexArrayOES(s)},e.bindVertexArray=function(s){r.bindVertexArrayOES(s)},e.isVertexArray=function(s){return r.isVertexArrayOES(s)})}function ys(e){var r=e.getExtension("WEBGL_draw_buffers");r&&(e.drawBuffers=function(s,l){r.drawBuffersWEBGL(s,l)})}var Ur=1,yi=[],te=[],wi=[],Je=[],Kt=[],ee=[],Si=[],le=[],Ce=[],_e=[],Wr={},$r={},Gr=4;function St(e){bi||(bi=e)}function Oe(e){for(var r=Ur++,s=e.length;s<r;s++)e[s]=null;return r}function ws(e,r){e.Ge||(e.Ge=e.getContext,e.getContext=function(l,d){return d=e.Ge(l,d),l=="webgl"==d instanceof WebGLRenderingContext?d:null});var s=1<r.majorVersion?e.getContext("webgl2",r):e.getContext("webgl",r);return s?Ss(s,r):0}function Ss(e,r){var s=Oe(le),l={handle:s,attributes:r,version:r.majorVersion,fe:e};return e.canvas&&(e.canvas.zf=l),le[s]=l,(typeof r.Nf>"u"||r.Nf)&&bs(l),s}function jr(e){return it=le[e],h.rg=_=it&&it.fe,!(e&&!_)}function bs(e){if(e||(e=it),!e.Xf){e.Xf=!0;var r=e.fe;gs(r),vs(r),ys(r),r.pf=r.getExtension("WEBGL_draw_instanced_base_vertex_base_instance"),r.uf=r.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance"),2<=e.version&&(r.qf=r.getExtension("EXT_disjoint_timer_query_webgl2")),(2>e.version||!r.qf)&&(r.qf=r.getExtension("EXT_disjoint_timer_query")),r.sg=r.getExtension("WEBGL_multi_draw"),(r.getSupportedExtensions()||[]).forEach(function(s){s.includes("lose_context")||s.includes("debug")||r.getExtension(s)})}}var it,bi,Yi={},Hr=()=>{if(!Xi){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:(typeof navigator=="object"&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:U||"./this.program"},r;for(r in Yi)Yi[r]===void 0?delete e[r]:e[r]=Yi[r];var s=[];for(r in e)s.push(`${r}=${e[r]}`);Xi=s}return Xi},Xi,Ps=[null,[],[]];function Kr(e){_.bindVertexArray(Si[e])}function Vr(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2];_.deleteVertexArray(Si[l]),Si[l]=null}}var Pi=[];function qr(e,r,s,l){_.drawElements(e,r,s,l)}function Ie(e,r,s,l){for(var d=0;d<e;d++){var m=_[s](),P=m&&Oe(l);m?(m.name=P,l[P]=m):St(1282),$[r+4*d>>2]=P}}function Yr(e,r){Ie(e,r,"createVertexArray",Si)}function Xr(e,r,s){if(r){var l=void 0;switch(e){case 36346:l=1;break;case 36344:s!=0&&s!=1&&St(1280);return;case 34814:case 36345:l=0;break;case 34466:var d=_.getParameter(34467);l=d?d.length:0;break;case 33309:if(2>it.version){St(1282);return}l=2*(_.getSupportedExtensions()||[]).length;break;case 33307:case 33308:if(2>it.version){St(1280);return}l=e==33307?3:0}if(l===void 0)switch(d=_.getParameter(e),typeof d){case"number":l=d;break;case"boolean":l=d?1:0;break;case"string":St(1280);return;case"object":if(d===null)switch(e){case 34964:case 35725:case 34965:case 36006:case 36007:case 32873:case 34229:case 36662:case 36663:case 35053:case 35055:case 36010:case 35097:case 35869:case 32874:case 36389:case 35983:case 35368:case 34068:l=0;break;default:St(1280);return}else{if(d instanceof Float32Array||d instanceof Uint32Array||d instanceof Int32Array||d instanceof Array){for(e=0;e<d.length;++e)switch(s){case 0:$[r+4*e>>2]=d[e];break;case 2:Z[r+4*e>>2]=d[e];break;case 4:se[r+e>>0]=d[e]?1:0}return}try{l=d.name|0}catch(m){St(1280),pe("GL_INVALID_ENUM in glGet"+s+"v: Unknown object returned from WebGL getParameter("+e+")! (error: "+m+")");return}}break;default:St(1280),pe("GL_INVALID_ENUM in glGet"+s+"v: Native code calling glGet"+s+"v("+e+") and it returns "+d+" of type "+typeof d+"!");return}switch(s){case 1:s=l,wt[r>>2]=s,wt[r+4>>2]=(s-wt[r>>2])/4294967296;break;case 0:$[r>>2]=l;break;case 2:Z[r>>2]=l;break;case 4:se[r>>0]=l?1:0}}else St(1281)}var Qe=e=>{var r=Zt(e)+1,s=Ei(r);return s&&Qt(e,ot,s,r),s};function Jr(e){return e.slice(-1)=="]"&&e.lastIndexOf("[")}function Ai(e){return e-=5120,e==0?se:e==1?ot:e==2?me:e==4?$:e==6?Z:e==5||e==28922||e==28520||e==30779||e==30782?wt:xe}function Ji(e,r,s,l,d){e=Ai(e);var m=31-Math.clz32(e.BYTES_PER_ELEMENT),P=Gr;return e.subarray(d>>m,d+l*(s*({5:3,6:4,8:2,29502:3,29504:4,26917:2,26918:2,29846:3,29847:4}[r-6402]||1)*(1<<m)+P-1&-P)>>m)}function gt(e){var r=_.Kf;if(r){var s=r.Ne[e];return typeof s=="number"&&(r.Ne[e]=s=_.getUniformLocation(r,r.xf[e]+(0<s?"["+s+"]":""))),s}St(1282)}var ve=[],Ze=[],Ci=e=>e%4===0&&(e%100!==0||e%400===0),Qr=[31,29,31,30,31,30,31,31,30,31,30,31],Zr=[31,28,31,30,31,30,31,31,30,31,30,31];function As(e){var r=Array(Zt(e)+1);return Qt(e,r,0,r.length),r}var Cs=(e,r,s,l)=>{function d(T,Y,nt){for(T=typeof T=="number"?T.toString():T||"";T.length<Y;)T=nt[0]+T;return T}function m(T,Y){return d(T,Y,"0")}function P(T,Y){function nt(Bt){return 0>Bt?-1:0<Bt?1:0}var rt;return(rt=nt(T.getFullYear()-Y.getFullYear()))===0&&(rt=nt(T.getMonth()-Y.getMonth()))===0&&(rt=nt(T.getDate()-Y.getDate())),rt}function v(T){switch(T.getDay()){case 0:return new Date(T.getFullYear()-1,11,29);case 1:return T;case 2:return new Date(T.getFullYear(),0,3);case 3:return new Date(T.getFullYear(),0,2);case 4:return new Date(T.getFullYear(),0,1);case 5:return new Date(T.getFullYear()-1,11,31);case 6:return new Date(T.getFullYear()-1,11,30)}}function y(T){var Y=T.oe;for(T=new Date(new Date(T.pe+1900,0,1).getTime());0<Y;){var nt=T.getMonth(),rt=(Ci(T.getFullYear())?Qr:Zr)[nt];if(Y>rt-T.getDate())Y-=rt-T.getDate()+1,T.setDate(1),11>nt?T.setMonth(nt+1):(T.setMonth(0),T.setFullYear(T.getFullYear()+1));else{T.setDate(T.getDate()+Y);break}}return nt=new Date(T.getFullYear()+1,0,4),Y=v(new Date(T.getFullYear(),0,4)),nt=v(nt),0>=P(Y,T)?0>=P(nt,T)?T.getFullYear()+1:T.getFullYear():T.getFullYear()-1}var A=$[l+40>>2];l={pg:$[l>>2],og:$[l+4>>2],Ze:$[l+8>>2],jf:$[l+12>>2],$e:$[l+16>>2],pe:$[l+20>>2],he:$[l+24>>2],oe:$[l+28>>2],vg:$[l+32>>2],ng:$[l+36>>2],qg:A&&A?Pe(ot,A):""},s=s?Pe(ot,s):"",A={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var O in A)s=s.replace(new RegExp(O,"g"),A[O]);var D="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),H="January February March April May June July August September October November December".split(" ");A={"%a":T=>D[T.he].substring(0,3),"%A":T=>D[T.he],"%b":T=>H[T.$e].substring(0,3),"%B":T=>H[T.$e],"%C":T=>m((T.pe+1900)/100|0,2),"%d":T=>m(T.jf,2),"%e":T=>d(T.jf,2," "),"%g":T=>y(T).toString().substring(2),"%G":T=>y(T),"%H":T=>m(T.Ze,2),"%I":T=>(T=T.Ze,T==0?T=12:12<T&&(T-=12),m(T,2)),"%j":T=>{for(var Y=0,nt=0;nt<=T.$e-1;Y+=(Ci(T.pe+1900)?Qr:Zr)[nt++]);return m(T.jf+Y,3)},"%m":T=>m(T.$e+1,2),"%M":T=>m(T.og,2),"%n":()=>`
2
+ `,"%p":T=>0<=T.Ze&&12>T.Ze?"AM":"PM","%S":T=>m(T.pg,2),"%t":()=>" ","%u":T=>T.he||7,"%U":T=>m(Math.floor((T.oe+7-T.he)/7),2),"%V":T=>{var Y=Math.floor((T.oe+7-(T.he+6)%7)/7);if(2>=(T.he+371-T.oe-2)%7&&Y++,Y)Y==53&&(nt=(T.he+371-T.oe)%7,nt==4||nt==3&&Ci(T.pe)||(Y=1));else{Y=52;var nt=(T.he+7-T.oe-1)%7;(nt==4||nt==5&&Ci(T.pe%400-1))&&Y++}return m(Y,2)},"%w":T=>T.he,"%W":T=>m(Math.floor((T.oe+7-(T.he+6)%7)/7),2),"%y":T=>(T.pe+1900).toString().substring(2),"%Y":T=>T.pe+1900,"%z":T=>{T=T.ng;var Y=0<=T;return T=Math.abs(T)/60,(Y?"+":"-")+("0000"+(T/60*100+T%60)).slice(-4)},"%Z":T=>T.qg,"%%":()=>"%"},s=s.replace(/%%/g,"\0\0");for(O in A)s.includes(O)&&(s=s.replace(new RegExp(O,"g"),A[O](l)));return s=s.replace(/\0\0/g,"%"),O=As(s),O.length>r?0:(se.set(O,e),O.length-1)};_r=h.InternalError=class extends Error{constructor(e){super(e),this.name="InternalError"}};for(var tn=Array(256),_i=0;256>_i;++_i)tn[_i]=String.fromCharCode(_i);Er=tn,ke=h.BindingError=class extends Error{constructor(e){super(e),this.name="BindingError"}},ge.prototype.isAliasOf=function(e){if(!(this instanceof ge&&e instanceof ge))return!1;var r=this.Jd.Vd.Pd,s=this.Jd.Rd,l=e.Jd.Vd.Pd;for(e=e.Jd.Rd;r.$d;)s=r.Oe(s),r=r.$d;for(;l.$d;)e=l.Oe(e),l=l.$d;return r===l&&s===e},ge.prototype.clone=function(){if(this.Jd.Rd||Ui(this),this.Jd.Me)return this.Jd.count.value+=1,this;var e=qe,r=Object,s=r.create,l=Object.getPrototypeOf(this),d=this.Jd;return e=e(s.call(r,l,{Jd:{value:{count:d.count,Ee:d.Ee,Me:d.Me,Rd:d.Rd,Vd:d.Vd,Yd:d.Yd,ee:d.ee}}})),e.Jd.count.value+=1,e.Jd.Ee=!1,e},ge.prototype.delete=function(){this.Jd.Rd||Ui(this),this.Jd.Ee&&!this.Jd.Me&&ft("Object already scheduled for deletion"),Tr(this),Fr(this.Jd),this.Jd.Me||(this.Jd.Yd=void 0,this.Jd.Rd=void 0)},ge.prototype.isDeleted=function(){return!this.Jd.Rd},ge.prototype.deleteLater=function(){return this.Jd.Rd||Ui(this),this.Jd.Ee&&!this.Jd.Me&&ft("Object already scheduled for deletion"),He.push(this),He.length===1&&Ke&&Ke($i),this.Jd.Ee=!0,this},h.getInheritedInstanceCount=function(){return Object.keys(Ve).length},h.getLiveInheritedInstances=function(){var e=[],r;for(r in Ve)Ve.hasOwnProperty(r)&&e.push(Ve[r]);return e},h.flushPendingDeletes=$i,h.setDelayFunction=function(e){Ke=e,He.length&&Ke&&Ke($i)},oe.prototype.Sf=function(e){return this.vf&&(e=this.vf(e)),e},oe.prototype.nf=function(e){this.ke&&this.ke(e)},oe.prototype.argPackAdvance=8,oe.prototype.readValueFromPointer=je,oe.prototype.deleteObject=function(e){e!==null&&e.delete()},oe.prototype.fromWireType=function(e){function r(){return this.Ve?fi(this.Pd.Fe,{Vd:this.bg,Rd:s,ee:this,Yd:e}):fi(this.Pd.Fe,{Vd:this,Rd:e})}var s=this.Sf(e);if(!s)return this.nf(e),null;var l=Jn(this.Pd,s);if(l!==void 0)return l.Jd.count.value===0?(l.Jd.Rd=s,l.Jd.Yd=e,l.clone()):(l=l.clone(),this.nf(e),l);if(l=this.Pd.Rf(s),l=xr[l],!l)return r.call(this);l=this.Ue?l.If:l.pointerType;var d=Mr(s,this.Pd,l.Pd);return d===null?r.call(this):this.Ve?fi(l.Pd.Fe,{Vd:l,Rd:d,ee:this,Yd:e}):fi(l.Pd.Fe,{Vd:l,Rd:d})},kr=h.UnboundTypeError=function(e,r){var s=Gi(r,function(l){this.name=r,this.message=l,l=Error(l).stack,l!==void 0&&(this.stack=this.toString()+`
3
+ `+l.replace(/^Error(:[^\n]*)?\n/,""))});return s.prototype=Object.create(e.prototype),s.prototype.constructor=s,s.prototype.toString=function(){return this.message===void 0?this.name:`${this.name}: ${this.message}`},s}(Error,"UnboundTypeError"),Object.assign(Ir.prototype,{get(e){return this.je[e]},has(e){return this.je[e]!==void 0},Af(e){var r=this.sf.pop()||this.je.length;return this.je[r]=e,r},Bf(e){this.je[e]=void 0,this.sf.push(e)}}),Gt.je.push({value:void 0},{value:null},{value:!0},{value:!1}),Gt.Ge=Gt.je.length,h.count_emval_handles=function(){for(var e=0,r=Gt.Ge;r<Gt.je.length;++r)Gt.je[r]!==void 0&&++e;return e};for(var _,$t=0;32>$t;++$t)Pi.push(Array($t));var _s=new Float32Array(288);for($t=0;288>$t;++$t)ve[$t]=_s.subarray(0,$t+1);var Es=new Int32Array(288);for($t=0;288>$t;++$t)Ze[$t]=Es.subarray(0,$t+1);var Ts={T:function(){return 0},Bb:()=>{},Db:function(){return 0},yb:()=>{},zb:()=>{},U:function(){},Ab:()=>{},C:function(e){var r=hi[e];delete hi[e];var s=r.hf,l=r.ke,d=r.rf,m=d.map(P=>P.Vf).concat(d.map(P=>P.fg));Jt([e],m,P=>{var v={};return d.forEach((y,A)=>{var O=P[A],D=y.Tf,H=y.Uf,T=P[A+d.length],Y=y.eg,nt=y.gg;v[y.Of]={read:rt=>O.fromWireType(D(H,rt)),write:(rt,Bt)=>{var Rt=[];Y(nt,rt,T.toWireType(Rt,Bt)),Bi(Rt)}}}),[{name:r.name,fromWireType:function(y){var A={},O;for(O in v)A[O]=v[O].read(y);return l(y),A},toWireType:function(y,A){for(var O in v)if(!(O in A))throw new TypeError(`Missing field: "${O}"`);var D=s();for(O in v)v[O].write(D,A[O]);return y!==null&&y.push(l,D),D},argPackAdvance:8,readValueFromPointer:je,de:l}]})},qb:function(){},Hb:function(e,r,s,l,d){var m=di(s);r=_t(r),ae(e,{name:r,fromWireType:function(P){return!!P},toWireType:function(P,v){return v?l:d},argPackAdvance:8,readValueFromPointer:function(P){if(s===1)var v=se;else if(s===2)v=me;else if(s===4)v=$;else throw new TypeError("Unknown boolean type size: "+r);return this.fromWireType(v[P>>m])},de:null})},m:function(e,r,s,l,d,m,P,v,y,A,O,D,H){O=_t(O),m=Nt(d,m),v&&(v=Nt(P,v)),A&&(A=Nt(y,A)),H=Nt(D,H);var T=Rr(O);Hi(T,function(){Ye(`Cannot construct ${O} due to unbound types`,[l])}),Jt([e,r,s],l?[l]:[],function(Y){if(Y=Y[0],l)var nt=Y.Pd,rt=nt.Fe;else rt=ge.prototype;Y=Gi(T,function(){if(Object.getPrototypeOf(this)!==Bt)throw new ke("Use 'new' to construct "+O);if(Rt.ne===void 0)throw new ke(O+" has no accessible constructor");var ei=Rt.ne[arguments.length];if(ei===void 0)throw new ke(`Tried to invoke ctor of ${O} with invalid number of parameters (${arguments.length}) - expected (${Object.keys(Rt.ne).toString()}) parameters instead!`);return ei.apply(this,arguments)});var Bt=Object.create(rt,{constructor:{value:Y}});Y.prototype=Bt;var Rt=new Qn(O,Y,Bt,H,nt,m,v,A);Rt.$d&&(Rt.$d.Pe===void 0&&(Rt.$d.Pe=[]),Rt.$d.Pe.push(Rt)),nt=new oe(O,Rt,!0,!1,!1),rt=new oe(O+"*",Rt,!1,!1,!1);var ti=new oe(O+" const*",Rt,!1,!0,!1);return xr[e]={pointerType:rt,If:ti},Nr(T,Y),[nt,rt,ti]})},f:function(e,r,s,l,d,m,P){var v=mi(s,l);r=_t(r),m=Nt(d,m),Jt([],[e],function(y){function A(){Ye(`Cannot call ${O} due to unbound types`,v)}y=y[0];var O=`${y.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]);var D=y.Pd.constructor;return D[r]===void 0?(A.Ce=s-1,D[r]=A):(ji(D,r,O),D[r].Xd[s-1]=A),Jt([],v,function(H){if(H=[H[0],null].concat(H.slice(1)),H=pi(O,H,null,m,P),D[r].Xd===void 0?(H.Ce=s-1,D[r]=H):D[r].Xd[s-1]=H,y.Pd.Pe)for(const T of y.Pd.Pe)T.constructor.hasOwnProperty(r)||(T.constructor[r]=H);return[]}),[]})},A:function(e,r,s,l,d,m){var P=mi(r,s);d=Nt(l,d),Jt([],[e],function(v){v=v[0];var y=`constructor ${v.name}`;if(v.Pd.ne===void 0&&(v.Pd.ne=[]),v.Pd.ne[r-1]!==void 0)throw new ke(`Cannot register multiple constructors with identical number of parameters (${r-1}) for class '${v.name}'! Overload resolution is currently only performed using the parameter count, not actual type info!`);return v.Pd.ne[r-1]=()=>{Ye(`Cannot construct ${v.name} due to unbound types`,P)},Jt([],P,function(A){return A.splice(1,0,null),v.Pd.ne[r-1]=pi(y,A,null,d,m),[]}),[]})},b:function(e,r,s,l,d,m,P,v){var y=mi(s,l);r=_t(r),m=Nt(d,m),Jt([],[e],function(A){function O(){Ye(`Cannot call ${D} due to unbound types`,y)}A=A[0];var D=`${A.name}.${r}`;r.startsWith("@@")&&(r=Symbol[r.substring(2)]),v&&A.Pd.cg.push(r);var H=A.Pd.Fe,T=H[r];return T===void 0||T.Xd===void 0&&T.className!==A.name&&T.Ce===s-2?(O.Ce=s-2,O.className=A.name,H[r]=O):(ji(H,r,D),H[r].Xd[s-2]=O),Jt([],y,function(Y){return Y=pi(D,Y,A,m,P),H[r].Xd===void 0?(Y.Ce=s-2,H[r]=Y):H[r].Xd[s-2]=Y,[]}),[]})},t:function(e,r,s){e=_t(e),Jt([],[r],function(l){return l=l[0],h[e]=l.fromWireType(s),[]})},Gb:function(e,r){r=_t(r),ae(e,{name:r,fromWireType:function(s){var l=jt(s);return Vi(s),l},toWireType:function(s,l){return Ht(l)},argPackAdvance:8,readValueFromPointer:je,de:null})},l:function(e,r,s,l){function d(){}s=di(s),r=_t(r),d.values={},ae(e,{name:r,constructor:d,fromWireType:function(m){return this.constructor.values[m]},toWireType:function(m,P){return P.value},argPackAdvance:8,readValueFromPointer:rs(r,s,l),de:null}),Hi(r,d)},c:function(e,r,s){var l=Xe(e,"enum");r=_t(r),e=l.constructor,l=Object.create(l.constructor.prototype,{value:{value:s},constructor:{value:Gi(`${l.name}_${r}`,function(){})}}),e.values[s]=l,e[r]=l},W:function(e,r,s){s=di(s),r=_t(r),ae(e,{name:r,fromWireType:function(l){return l},toWireType:function(l,d){return d},argPackAdvance:8,readValueFromPointer:ns(r,s),de:null})},y:function(e,r,s,l,d,m){var P=mi(r,s);e=_t(e),d=Nt(l,d),Hi(e,function(){Ye(`Cannot call ${e} due to unbound types`,P)},r-1),Jt([],P,function(v){return v=[v[0],null].concat(v.slice(1)),Nr(e,pi(e,v,null,d,m),r-1),[]})},E:function(e,r,s,l,d){r=_t(r),d===-1&&(d=4294967295),d=di(s);var m=v=>v;if(l===0){var P=32-8*s;m=v=>v<<P>>>P}s=r.includes("unsigned")?function(v,y){return y>>>0}:function(v,y){return y},ae(e,{name:r,fromWireType:m,toWireType:s,argPackAdvance:8,readValueFromPointer:ss(r,d,l!==0),de:null})},s:function(e,r,s){function l(m){m>>=2;var P=wt;return new d(P.buffer,P[m+1],P[m])}var d=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][r];s=_t(s),ae(e,{name:s,fromWireType:l,argPackAdvance:8,readValueFromPointer:l},{Wf:!0})},q:function(e,r,s,l,d,m,P,v,y,A,O,D){s=_t(s),m=Nt(d,m),v=Nt(P,v),A=Nt(y,A),D=Nt(O,D),Jt([e],[r],function(H){return H=H[0],[new oe(s,H.Pd,!1,!1,!0,H,l,m,v,A,D)]})},V:function(e,r){r=_t(r);var s=r==="std::string";ae(e,{name:r,fromWireType:function(l){var d=wt[l>>2],m=l+4;if(s)for(var P=m,v=0;v<=d;++v){var y=m+v;if(v==d||ot[y]==0){if(P=P?Pe(ot,P,y-P):"",A===void 0)var A=P;else A+="\0",A+=P;P=y+1}}else{for(A=Array(d),v=0;v<d;++v)A[v]=String.fromCharCode(ot[m+v]);A=A.join("")}return ue(l),A},toWireType:function(l,d){d instanceof ArrayBuffer&&(d=new Uint8Array(d));var m=typeof d=="string";m||d instanceof Uint8Array||d instanceof Uint8ClampedArray||d instanceof Int8Array||ft("Cannot pass non-string to std::string");var P=s&&m?Zt(d):d.length,v=Ei(4+P+1),y=v+4;if(wt[v>>2]=P,s&&m)Qt(d,ot,y,P+1);else if(m)for(m=0;m<P;++m){var A=d.charCodeAt(m);255<A&&(ue(y),ft("String has UTF-16 code units that do not fit in 8 bits")),ot[y+m]=A}else for(m=0;m<P;++m)ot[y+m]=d[m];return l!==null&&l.push(ue,v),v},argPackAdvance:8,readValueFromPointer:je,de:function(l){ue(l)}})},N:function(e,r,s){if(s=_t(s),r===2)var l=as,d=os,m=ls,P=()=>xe,v=1;else r===4&&(l=hs,d=cs,m=us,P=()=>wt,v=2);ae(e,{name:s,fromWireType:function(y){for(var A=wt[y>>2],O=P(),D,H=y+4,T=0;T<=A;++T){var Y=y+4+T*r;(T==A||O[Y>>v]==0)&&(H=l(H,Y-H),D===void 0?D=H:(D+="\0",D+=H),H=Y+r)}return ue(y),D},toWireType:function(y,A){typeof A!="string"&&ft(`Cannot pass non-string to C++ string type ${s}`);var O=m(A),D=Ei(4+O+r);return wt[D>>2]=O>>v,d(A,D+4,O+r),y!==null&&y.push(ue,D),D},argPackAdvance:8,readValueFromPointer:je,de:function(y){ue(y)}})},D:function(e,r,s,l,d,m){hi[e]={name:_t(r),hf:Nt(s,l),ke:Nt(d,m),rf:[]}},e:function(e,r,s,l,d,m,P,v,y,A){hi[e].rf.push({Of:_t(r),Vf:s,Tf:Nt(l,d),Uf:m,fg:P,eg:Nt(v,y),gg:A})},Ib:function(e,r){r=_t(r),ae(e,{Yf:!0,name:r,argPackAdvance:0,fromWireType:function(){},toWireType:function(){}})},Fb:()=>!0,ub:()=>{throw 1/0},F:function(e,r,s){e=jt(e),r=Xe(r,"emval::as");var l=[],d=Ht(l);return wt[s>>2]=d,r.toWireType(l,e)},Z:function(e,r,s,l,d){e=vi[e],r=jt(r),s=gi(s);var m=[];return wt[l>>2]=Ht(m),e(r,s,m,d)},w:function(e,r,s,l){e=vi[e],r=jt(r),s=gi(s),e(r,s,null,l)},d:Vi,K:function(e){return e===0?Ht(Dr()):(e=gi(e),Ht(Dr()[e]))},u:function(e,r){var s=ps(e,r),l=s[0];r=l.name+"_$"+s.slice(1).map(function(P){return P.name}).join("_")+"$";var d=zr[r];if(d!==void 0)return d;var m=Array(e-1);return d=fs((P,v,y,A)=>{for(var O=0,D=0;D<e-1;++D)m[D]=s[D+1].readValueFromPointer(A+O),O+=s[D+1].argPackAdvance;for(P=P[v].apply(P,m),D=0;D<e-1;++D)s[D+1].Lf&&s[D+1].Lf(m[D]);if(!l.Yf)return l.toWireType(y,P)}),zr[r]=d},z:function(e,r){return e=jt(e),r=jt(r),Ht(e[r])},p:function(e){4<e&&(Gt.get(e).wf+=1)},J:function(e,r,s,l){e=jt(e);var d=Br[r];return d||(d=ms(r),Br[r]=d),d(e,s,l)},H:function(){return Ht([])},g:function(e){return Ht(gi(e))},G:function(){return Ht({})},kb:function(e){return e=jt(e),!e},B:function(e){var r=jt(e);Bi(r),Vi(e)},i:function(e,r,s){e=jt(e),r=jt(r),s=jt(s),e[r]=s},h:function(e,r){return e=Xe(e,"_emval_take_value"),e=e.readValueFromPointer(r),Ht(e)},nb:function(){return-52},ob:function(){},a:()=>{Di("")},Eb:()=>performance.now(),vb:e=>{var r=ot.length;if(e>>>=0,2147483648<e)return!1;for(var s=1;4>=s;s*=2){var l=r*(1+.2/s);l=Math.min(l,e+100663296);var d=Math;l=Math.max(e,l);t:{d=d.min.call(d,2147483648,l+(65536-l%65536)%65536)-li.buffer.byteLength+65535>>>16;try{li.grow(d),gr();var m=1;break t}catch{}m=void 0}if(m)return!0}return!1},lb:function(){return it?it.handle:0},wb:(e,r)=>{var s=0;return Hr().forEach(function(l,d){var m=r+s;for(d=wt[e+4*d>>2]=m,m=0;m<l.length;++m)se[d++>>0]=l.charCodeAt(m);se[d>>0]=0,s+=l.length+1}),0},xb:(e,r)=>{var s=Hr();wt[e>>2]=s.length;var l=0;return s.forEach(function(d){l+=d.length+1}),wt[r>>2]=l,0},Jb:e=>{Hn||(h.onExit&&h.onExit(e),Li=!0),et(e,new Yn(e))},M:()=>52,mb:function(){return 52},Cb:()=>52,pb:function(){return 70},S:(e,r,s,l)=>{for(var d=0,m=0;m<s;m++){var P=wt[r>>2],v=wt[r+4>>2];r+=8;for(var y=0;y<v;y++){var A=ot[P+y],O=Ps[e];A===0||A===10?((e===1?jn:pe)(Pe(O,0)),O.length=0):O.push(A)}d+=v}return wt[l>>2]=d,0},aa:function(e){_.activeTexture(e)},ba:function(e,r){_.attachShader(te[e],ee[r])},ca:function(e,r,s){_.bindAttribLocation(te[e],r,s?Pe(ot,s):"")},da:function(e,r){e==35051?_.ef=r:e==35052&&(_.De=r),_.bindBuffer(e,yi[r])},$:function(e,r){_.bindFramebuffer(e,wi[r])},fc:function(e,r){_.bindRenderbuffer(e,Je[r])},Rb:function(e,r){_.bindSampler(e,Ce[r])},ea:function(e,r){_.bindTexture(e,Kt[r])},zc:Kr,Cc:Kr,fa:function(e,r,s,l){_.blendColor(e,r,s,l)},ga:function(e){_.blendEquation(e)},ha:function(e,r){_.blendFunc(e,r)},$b:function(e,r,s,l,d,m,P,v,y,A){_.blitFramebuffer(e,r,s,l,d,m,P,v,y,A)},ia:function(e,r,s,l){2<=it.version?s&&r?_.bufferData(e,ot,l,s,r):_.bufferData(e,r,l):_.bufferData(e,s?ot.subarray(s,s+r):r,l)},ja:function(e,r,s,l){2<=it.version?s&&_.bufferSubData(e,r,ot,l,s):_.bufferSubData(e,r,ot.subarray(l,l+s))},gc:function(e){return _.checkFramebufferStatus(e)},Q:function(e){_.clear(e)},_:function(e,r,s,l){_.clearColor(e,r,s,l)},R:function(e){_.clearStencil(e)},sb:function(e,r,s,l){return _.clientWaitSync(_e[e],r,(s>>>0)+4294967296*l)},ka:function(e,r,s,l){_.colorMask(!!e,!!r,!!s,!!l)},la:function(e){_.compileShader(ee[e])},ma:function(e,r,s,l,d,m,P,v){2<=it.version?_.De||!P?_.compressedTexImage2D(e,r,s,l,d,m,P,v):_.compressedTexImage2D(e,r,s,l,d,m,ot,v,P):_.compressedTexImage2D(e,r,s,l,d,m,v?ot.subarray(v,v+P):null)},na:function(e,r,s,l,d,m,P,v,y){2<=it.version?_.De||!v?_.compressedTexSubImage2D(e,r,s,l,d,m,P,v,y):_.compressedTexSubImage2D(e,r,s,l,d,m,P,ot,y,v):_.compressedTexSubImage2D(e,r,s,l,d,m,P,y?ot.subarray(y,y+v):null)},Zb:function(e,r,s,l,d){_.copyBufferSubData(e,r,s,l,d)},oa:function(e,r,s,l,d,m,P,v){_.copyTexSubImage2D(e,r,s,l,d,m,P,v)},pa:function(){var e=Oe(te),r=_.createProgram();return r.name=e,r.Ye=r.We=r.Xe=0,r.kf=1,te[e]=r,e},qa:function(e){var r=Oe(ee);return ee[r]=_.createShader(e),r},ra:function(e){_.cullFace(e)},sa:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=yi[l];d&&(_.deleteBuffer(d),d.name=0,yi[l]=null,l==_.ef&&(_.ef=0),l==_.De&&(_.De=0))}},hc:function(e,r){for(var s=0;s<e;++s){var l=$[r+4*s>>2],d=wi[l];d&&(_.deleteFramebuffer(d),d.name=0,wi[l]=null)}},ta:function(e){if(e){var r=te[e];r?(_.deleteProgram(r),r.name=0,te[e]=null):St(1281)}},ic:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Je[l];d&&(_.deleteRenderbuffer(d),d.name=0,Je[l]=null)}},Sb:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Ce[l];d&&(_.deleteSampler(d),d.name=0,Ce[l]=null)}},ua:function(e){if(e){var r=ee[e];r?(_.deleteShader(r),ee[e]=null):St(1281)}},_b:function(e){if(e){var r=_e[e];r?(_.deleteSync(r),r.name=0,_e[e]=null):St(1281)}},va:function(e,r){for(var s=0;s<e;s++){var l=$[r+4*s>>2],d=Kt[l];d&&(_.deleteTexture(d),d.name=0,Kt[l]=null)}},Ac:Vr,Dc:Vr,wa:function(e){_.depthMask(!!e)},xa:function(e){_.disable(e)},ya:function(e){_.disableVertexAttribArray(e)},za:function(e,r,s){_.drawArrays(e,r,s)},xc:function(e,r,s,l){_.drawArraysInstanced(e,r,s,l)},vc:function(e,r,s,l,d){_.pf.drawArraysInstancedBaseInstanceWEBGL(e,r,s,l,d)},tc:function(e,r){for(var s=Pi[e],l=0;l<e;l++)s[l]=$[r+4*l>>2];_.drawBuffers(s)},Aa:qr,yc:function(e,r,s,l,d){_.drawElementsInstanced(e,r,s,l,d)},wc:function(e,r,s,l,d,m,P){_.pf.drawElementsInstancedBaseVertexBaseInstanceWEBGL(e,r,s,l,d,m,P)},nc:function(e,r,s,l,d,m){qr(e,l,d,m)},Ba:function(e){_.enable(e)},Ca:function(e){_.enableVertexAttribArray(e)},Xb:function(e,r){return(e=_.fenceSync(e,r))?(r=Oe(_e),e.name=r,_e[r]=e,r):0},Da:function(){_.finish()},Ea:function(){_.flush()},jc:function(e,r,s,l){_.framebufferRenderbuffer(e,r,s,Je[l])},kc:function(e,r,s,l,d){_.framebufferTexture2D(e,r,s,Kt[l],d)},Fa:function(e){_.frontFace(e)},Ga:function(e,r){Ie(e,r,"createBuffer",yi)},lc:function(e,r){Ie(e,r,"createFramebuffer",wi)},mc:function(e,r){Ie(e,r,"createRenderbuffer",Je)},Tb:function(e,r){Ie(e,r,"createSampler",Ce)},Ha:function(e,r){Ie(e,r,"createTexture",Kt)},Bc:Yr,Ec:Yr,bc:function(e){_.generateMipmap(e)},Ia:function(e,r,s){s?$[s>>2]=_.getBufferParameter(e,r):St(1281)},Ja:function(){var e=_.getError()||bi;return bi=0,e},Ka:function(e,r){Xr(e,r,2)},cc:function(e,r,s,l){e=_.getFramebufferAttachmentParameter(e,r,s),(e instanceof WebGLRenderbuffer||e instanceof WebGLTexture)&&(e=e.name|0),$[l>>2]=e},L:function(e,r){Xr(e,r,0)},La:function(e,r,s,l){e=_.getProgramInfoLog(te[e]),e===null&&(e="(unknown error)"),r=0<r&&l?Qt(e,ot,l,r):0,s&&($[s>>2]=r)},Ma:function(e,r,s){if(s)if(e>=Ur)St(1281);else if(e=te[e],r==35716)e=_.getProgramInfoLog(e),e===null&&(e="(unknown error)"),$[s>>2]=e.length+1;else if(r==35719){if(!e.Ye)for(r=0;r<_.getProgramParameter(e,35718);++r)e.Ye=Math.max(e.Ye,_.getActiveUniform(e,r).name.length+1);$[s>>2]=e.Ye}else if(r==35722){if(!e.We)for(r=0;r<_.getProgramParameter(e,35721);++r)e.We=Math.max(e.We,_.getActiveAttrib(e,r).name.length+1);$[s>>2]=e.We}else if(r==35381){if(!e.Xe)for(r=0;r<_.getProgramParameter(e,35382);++r)e.Xe=Math.max(e.Xe,_.getActiveUniformBlockName(e,r).length+1);$[s>>2]=e.Xe}else $[s>>2]=_.getProgramParameter(e,r);else St(1281)},dc:function(e,r,s){s?$[s>>2]=_.getRenderbufferParameter(e,r):St(1281)},Na:function(e,r,s,l){e=_.getShaderInfoLog(ee[e]),e===null&&(e="(unknown error)"),r=0<r&&l?Qt(e,ot,l,r):0,s&&($[s>>2]=r)},Ob:function(e,r,s,l){e=_.getShaderPrecisionFormat(e,r),$[s>>2]=e.rangeMin,$[s+4>>2]=e.rangeMax,$[l>>2]=e.precision},Oa:function(e,r,s){s?r==35716?(e=_.getShaderInfoLog(ee[e]),e===null&&(e="(unknown error)"),$[s>>2]=e?e.length+1:0):r==35720?(e=_.getShaderSource(ee[e]),$[s>>2]=e?e.length+1:0):$[s>>2]=_.getShaderParameter(ee[e],r):St(1281)},P:function(e){var r=Wr[e];if(!r){switch(e){case 7939:r=_.getSupportedExtensions()||[],r=r.concat(r.map(function(l){return"GL_"+l})),r=Qe(r.join(" "));break;case 7936:case 7937:case 37445:case 37446:(r=_.getParameter(e))||St(1280),r=r&&Qe(r);break;case 7938:r=_.getParameter(7938),r=2<=it.version?"OpenGL ES 3.0 ("+r+")":"OpenGL ES 2.0 ("+r+")",r=Qe(r);break;case 35724:r=_.getParameter(35724);var s=r.match(/^WebGL GLSL ES ([0-9]\.[0-9][0-9]?)(?:$| .*)/);s!==null&&(s[1].length==3&&(s[1]+="0"),r="OpenGL ES GLSL ES "+s[1]+" ("+r+")"),r=Qe(r);break;default:St(1280)}Wr[e]=r}return r},jb:function(e,r){if(2>it.version)return St(1282),0;var s=$r[e];if(s)return 0>r||r>=s.length?(St(1281),0):s[r];switch(e){case 7939:return s=_.getSupportedExtensions()||[],s=s.concat(s.map(function(l){return"GL_"+l})),s=s.map(function(l){return Qe(l)}),s=$r[e]=s,0>r||r>=s.length?(St(1281),0):s[r];default:return St(1280),0}},Pa:function(e,r){if(r=r?Pe(ot,r):"",e=te[e]){var s=e,l=s.Ne,d=s.yf,m;if(!l)for(s.Ne=l={},s.xf={},m=0;m<_.getProgramParameter(s,35718);++m){var P=_.getActiveUniform(s,m),v=P.name;P=P.size;var y=Jr(v);y=0<y?v.slice(0,y):v;var A=s.kf;for(s.kf+=P,d[y]=[P,A],v=0;v<P;++v)l[A]=v,s.xf[A++]=y}if(s=e.Ne,l=0,d=r,m=Jr(r),0<m&&(l=parseInt(r.slice(m+1))>>>0,d=r.slice(0,m)),(d=e.yf[d])&&l<d[0]&&(l+=d[1],s[l]=s[l]||_.getUniformLocation(e,r)))return l}else St(1281);return-1},Pb:function(e,r,s){for(var l=Pi[r],d=0;d<r;d++)l[d]=$[s+4*d>>2];_.invalidateFramebuffer(e,l)},Qb:function(e,r,s,l,d,m,P){for(var v=Pi[r],y=0;y<r;y++)v[y]=$[s+4*y>>2];_.invalidateSubFramebuffer(e,v,l,d,m,P)},Yb:function(e){return _.isSync(_e[e])},Qa:function(e){return(e=Kt[e])?_.isTexture(e):0},Ra:function(e){_.lineWidth(e)},Sa:function(e){e=te[e],_.linkProgram(e),e.Ne=0,e.yf={}},rc:function(e,r,s,l,d,m){_.uf.multiDrawArraysInstancedBaseInstanceWEBGL(e,$,r>>2,$,s>>2,$,l>>2,wt,d>>2,m)},sc:function(e,r,s,l,d,m,P,v){_.uf.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL(e,$,r>>2,s,$,l>>2,$,d>>2,$,m>>2,wt,P>>2,v)},Ta:function(e,r){e==3317&&(Gr=r),_.pixelStorei(e,r)},uc:function(e){_.readBuffer(e)},Ua:function(e,r,s,l,d,m,P){if(2<=it.version)if(_.ef)_.readPixels(e,r,s,l,d,m,P);else{var v=Ai(m);_.readPixels(e,r,s,l,d,m,v,P>>31-Math.clz32(v.BYTES_PER_ELEMENT))}else(P=Ji(m,d,s,l,P))?_.readPixels(e,r,s,l,d,m,P):St(1280)},ec:function(e,r,s,l){_.renderbufferStorage(e,r,s,l)},ac:function(e,r,s,l,d){_.renderbufferStorageMultisample(e,r,s,l,d)},Ub:function(e,r,s){_.samplerParameterf(Ce[e],r,s)},Vb:function(e,r,s){_.samplerParameteri(Ce[e],r,s)},Wb:function(e,r,s){_.samplerParameteri(Ce[e],r,$[s>>2])},Va:function(e,r,s,l){_.scissor(e,r,s,l)},Wa:function(e,r,s,l){for(var d="",m=0;m<r;++m){var P=l?$[l+4*m>>2]:-1,v=$[s+4*m>>2];P=v?Pe(ot,v,0>P?void 0:P):"",d+=P}_.shaderSource(ee[e],d)},Xa:function(e,r,s){_.stencilFunc(e,r,s)},Ya:function(e,r,s,l){_.stencilFuncSeparate(e,r,s,l)},Za:function(e){_.stencilMask(e)},_a:function(e,r){_.stencilMaskSeparate(e,r)},$a:function(e,r,s){_.stencilOp(e,r,s)},ab:function(e,r,s,l){_.stencilOpSeparate(e,r,s,l)},bb:function(e,r,s,l,d,m,P,v,y){if(2<=it.version)if(_.De)_.texImage2D(e,r,s,l,d,m,P,v,y);else if(y){var A=Ai(v);_.texImage2D(e,r,s,l,d,m,P,v,A,y>>31-Math.clz32(A.BYTES_PER_ELEMENT))}else _.texImage2D(e,r,s,l,d,m,P,v,null);else _.texImage2D(e,r,s,l,d,m,P,v,y?Ji(v,P,l,d,y):null)},cb:function(e,r,s){_.texParameterf(e,r,s)},db:function(e,r,s){_.texParameterf(e,r,Z[s>>2])},eb:function(e,r,s){_.texParameteri(e,r,s)},fb:function(e,r,s){_.texParameteri(e,r,$[s>>2])},oc:function(e,r,s,l,d){_.texStorage2D(e,r,s,l,d)},gb:function(e,r,s,l,d,m,P,v,y){if(2<=it.version)if(_.De)_.texSubImage2D(e,r,s,l,d,m,P,v,y);else if(y){var A=Ai(v);_.texSubImage2D(e,r,s,l,d,m,P,v,A,y>>31-Math.clz32(A.BYTES_PER_ELEMENT))}else _.texSubImage2D(e,r,s,l,d,m,P,v,null);else A=null,y&&(A=Ji(v,P,d,m,y)),_.texSubImage2D(e,r,s,l,d,m,P,v,A)},hb:function(e,r){_.uniform1f(gt(e),r)},ib:function(e,r,s){if(2<=it.version)r&&_.uniform1fv(gt(e),Z,s>>2,r);else{if(288>=r)for(var l=ve[r-1],d=0;d<r;++d)l[d]=Z[s+4*d>>2];else l=Z.subarray(s>>2,s+4*r>>2);_.uniform1fv(gt(e),l)}},Zc:function(e,r){_.uniform1i(gt(e),r)},_c:function(e,r,s){if(2<=it.version)r&&_.uniform1iv(gt(e),$,s>>2,r);else{if(288>=r)for(var l=Ze[r-1],d=0;d<r;++d)l[d]=$[s+4*d>>2];else l=$.subarray(s>>2,s+4*r>>2);_.uniform1iv(gt(e),l)}},$c:function(e,r,s){_.uniform2f(gt(e),r,s)},ad:function(e,r,s){if(2<=it.version)r&&_.uniform2fv(gt(e),Z,s>>2,2*r);else{if(144>=r)for(var l=ve[2*r-1],d=0;d<2*r;d+=2)l[d]=Z[s+4*d>>2],l[d+1]=Z[s+(4*d+4)>>2];else l=Z.subarray(s>>2,s+8*r>>2);_.uniform2fv(gt(e),l)}},Yc:function(e,r,s){_.uniform2i(gt(e),r,s)},Xc:function(e,r,s){if(2<=it.version)r&&_.uniform2iv(gt(e),$,s>>2,2*r);else{if(144>=r)for(var l=Ze[2*r-1],d=0;d<2*r;d+=2)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2];else l=$.subarray(s>>2,s+8*r>>2);_.uniform2iv(gt(e),l)}},Wc:function(e,r,s,l){_.uniform3f(gt(e),r,s,l)},Vc:function(e,r,s){if(2<=it.version)r&&_.uniform3fv(gt(e),Z,s>>2,3*r);else{if(96>=r)for(var l=ve[3*r-1],d=0;d<3*r;d+=3)l[d]=Z[s+4*d>>2],l[d+1]=Z[s+(4*d+4)>>2],l[d+2]=Z[s+(4*d+8)>>2];else l=Z.subarray(s>>2,s+12*r>>2);_.uniform3fv(gt(e),l)}},Uc:function(e,r,s,l){_.uniform3i(gt(e),r,s,l)},Tc:function(e,r,s){if(2<=it.version)r&&_.uniform3iv(gt(e),$,s>>2,3*r);else{if(96>=r)for(var l=Ze[3*r-1],d=0;d<3*r;d+=3)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2],l[d+2]=$[s+(4*d+8)>>2];else l=$.subarray(s>>2,s+12*r>>2);_.uniform3iv(gt(e),l)}},Sc:function(e,r,s,l,d){_.uniform4f(gt(e),r,s,l,d)},Rc:function(e,r,s){if(2<=it.version)r&&_.uniform4fv(gt(e),Z,s>>2,4*r);else{if(72>=r){var l=ve[4*r-1],d=Z;s>>=2;for(var m=0;m<4*r;m+=4){var P=s+m;l[m]=d[P],l[m+1]=d[P+1],l[m+2]=d[P+2],l[m+3]=d[P+3]}}else l=Z.subarray(s>>2,s+16*r>>2);_.uniform4fv(gt(e),l)}},Fc:function(e,r,s,l,d){_.uniform4i(gt(e),r,s,l,d)},Gc:function(e,r,s){if(2<=it.version)r&&_.uniform4iv(gt(e),$,s>>2,4*r);else{if(72>=r)for(var l=Ze[4*r-1],d=0;d<4*r;d+=4)l[d]=$[s+4*d>>2],l[d+1]=$[s+(4*d+4)>>2],l[d+2]=$[s+(4*d+8)>>2],l[d+3]=$[s+(4*d+12)>>2];else l=$.subarray(s>>2,s+16*r>>2);_.uniform4iv(gt(e),l)}},Hc:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix2fv(gt(e),!!s,Z,l>>2,4*r);else{if(72>=r)for(var d=ve[4*r-1],m=0;m<4*r;m+=4)d[m]=Z[l+4*m>>2],d[m+1]=Z[l+(4*m+4)>>2],d[m+2]=Z[l+(4*m+8)>>2],d[m+3]=Z[l+(4*m+12)>>2];else d=Z.subarray(l>>2,l+16*r>>2);_.uniformMatrix2fv(gt(e),!!s,d)}},Ic:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix3fv(gt(e),!!s,Z,l>>2,9*r);else{if(32>=r)for(var d=ve[9*r-1],m=0;m<9*r;m+=9)d[m]=Z[l+4*m>>2],d[m+1]=Z[l+(4*m+4)>>2],d[m+2]=Z[l+(4*m+8)>>2],d[m+3]=Z[l+(4*m+12)>>2],d[m+4]=Z[l+(4*m+16)>>2],d[m+5]=Z[l+(4*m+20)>>2],d[m+6]=Z[l+(4*m+24)>>2],d[m+7]=Z[l+(4*m+28)>>2],d[m+8]=Z[l+(4*m+32)>>2];else d=Z.subarray(l>>2,l+36*r>>2);_.uniformMatrix3fv(gt(e),!!s,d)}},Jc:function(e,r,s,l){if(2<=it.version)r&&_.uniformMatrix4fv(gt(e),!!s,Z,l>>2,16*r);else{if(18>=r){var d=ve[16*r-1],m=Z;l>>=2;for(var P=0;P<16*r;P+=16){var v=l+P;d[P]=m[v],d[P+1]=m[v+1],d[P+2]=m[v+2],d[P+3]=m[v+3],d[P+4]=m[v+4],d[P+5]=m[v+5],d[P+6]=m[v+6],d[P+7]=m[v+7],d[P+8]=m[v+8],d[P+9]=m[v+9],d[P+10]=m[v+10],d[P+11]=m[v+11],d[P+12]=m[v+12],d[P+13]=m[v+13],d[P+14]=m[v+14],d[P+15]=m[v+15]}}else d=Z.subarray(l>>2,l+64*r>>2);_.uniformMatrix4fv(gt(e),!!s,d)}},Kc:function(e){e=te[e],_.useProgram(e),_.Kf=e},Lc:function(e,r){_.vertexAttrib1f(e,r)},Mc:function(e,r){_.vertexAttrib2f(e,Z[r>>2],Z[r+4>>2])},Nc:function(e,r){_.vertexAttrib3f(e,Z[r>>2],Z[r+4>>2],Z[r+8>>2])},Oc:function(e,r){_.vertexAttrib4f(e,Z[r>>2],Z[r+4>>2],Z[r+8>>2],Z[r+12>>2])},pc:function(e,r){_.vertexAttribDivisor(e,r)},qc:function(e,r,s,l,d){_.vertexAttribIPointer(e,r,s,l,d)},Pc:function(e,r,s,l,d,m){_.vertexAttribPointer(e,r,s,!!l,d,m)},Qc:function(e,r,s,l){_.viewport(e,r,s,l)},rb:function(e,r,s,l){_.waitSync(_e[e],r,(s>>>0)+4294967296*l)},j:Ms,n:Ls,k:Fs,I:zs,Lb:Bs,Y:Us,X:$s,O:ks,o:Is,x:Ns,r:Rs,v:Os,Kb:Ws,Mb:Ds,Nb:xs,tb:(e,r,s,l)=>Cs(e,r,s,l)};(function(){function e(s){if(lt=s=s.exports,li=lt.bd,gr(),Mt=lt.dd,yr.unshift(lt.cd),be--,h.monitorRunDependencies&&h.monitorRunDependencies(be),be==0&&Ge){var l=Ge;Ge=null,l()}return s}var r={a:Ts};if(be++,h.monitorRunDependencies&&h.monitorRunDependencies(be),h.instantiateWasm)try{return h.instantiateWasm(r,e)}catch(s){pe("Module.instantiateWasm callback failed with error: "+s),F(s)}return qn(r,function(s){e(s.instance)}).catch(F),{}})();var ue=h._free=e=>(ue=h._free=lt.ed)(e),Ei=h._malloc=e=>(Ei=h._malloc=lt.fd)(e),en=e=>(en=lt.gd)(e);h.__embind_initialize_bindings=()=>(h.__embind_initialize_bindings=lt.hd)();var kt=(e,r)=>(kt=lt.id)(e,r),Ot=()=>(Ot=lt.jd)(),It=e=>(It=lt.kd)(e);h.dynCall_viji=(e,r,s,l,d)=>(h.dynCall_viji=lt.ld)(e,r,s,l,d),h.dynCall_vijiii=(e,r,s,l,d,m,P)=>(h.dynCall_vijiii=lt.md)(e,r,s,l,d,m,P),h.dynCall_viiiiij=(e,r,s,l,d,m,P,v)=>(h.dynCall_viiiiij=lt.nd)(e,r,s,l,d,m,P,v),h.dynCall_jiiiijiiiii=(e,r,s,l,d,m,P,v,y,A,O,D)=>(h.dynCall_jiiiijiiiii=lt.od)(e,r,s,l,d,m,P,v,y,A,O,D),h.dynCall_viiij=(e,r,s,l,d,m)=>(h.dynCall_viiij=lt.pd)(e,r,s,l,d,m),h.dynCall_jii=(e,r,s)=>(h.dynCall_jii=lt.qd)(e,r,s),h.dynCall_vij=(e,r,s,l)=>(h.dynCall_vij=lt.rd)(e,r,s,l),h.dynCall_iiij=(e,r,s,l,d)=>(h.dynCall_iiij=lt.sd)(e,r,s,l,d),h.dynCall_iiiij=(e,r,s,l,d,m)=>(h.dynCall_iiiij=lt.td)(e,r,s,l,d,m),h.dynCall_viij=(e,r,s,l,d)=>(h.dynCall_viij=lt.ud)(e,r,s,l,d),h.dynCall_ji=(e,r)=>(h.dynCall_ji=lt.vd)(e,r),h.dynCall_iij=(e,r,s,l)=>(h.dynCall_iij=lt.wd)(e,r,s,l),h.dynCall_jiiiiii=(e,r,s,l,d,m,P)=>(h.dynCall_jiiiiii=lt.xd)(e,r,s,l,d,m,P),h.dynCall_jiiiiji=(e,r,s,l,d,m,P,v)=>(h.dynCall_jiiiiji=lt.yd)(e,r,s,l,d,m,P,v),h.dynCall_iijj=(e,r,s,l,d,m)=>(h.dynCall_iijj=lt.zd)(e,r,s,l,d,m),h.dynCall_iiiji=(e,r,s,l,d,m)=>(h.dynCall_iiiji=lt.Ad)(e,r,s,l,d,m),h.dynCall_iiji=(e,r,s,l,d)=>(h.dynCall_iiji=lt.Bd)(e,r,s,l,d),h.dynCall_iijjiii=(e,r,s,l,d,m,P,v,y)=>(h.dynCall_iijjiii=lt.Cd)(e,r,s,l,d,m,P,v,y),h.dynCall_vijjjii=(e,r,s,l,d,m,P,v,y,A)=>(h.dynCall_vijjjii=lt.Dd)(e,r,s,l,d,m,P,v,y,A),h.dynCall_jiji=(e,r,s,l,d)=>(h.dynCall_jiji=lt.Ed)(e,r,s,l,d),h.dynCall_viijii=(e,r,s,l,d,m,P)=>(h.dynCall_viijii=lt.Fd)(e,r,s,l,d,m,P),h.dynCall_iiiiij=(e,r,s,l,d,m,P)=>(h.dynCall_iiiiij=lt.Gd)(e,r,s,l,d,m,P),h.dynCall_iiiiijj=(e,r,s,l,d,m,P,v,y)=>(h.dynCall_iiiiijj=lt.Hd)(e,r,s,l,d,m,P,v,y),h.dynCall_iiiiiijj=(e,r,s,l,d,m,P,v,y,A)=>(h.dynCall_iiiiiijj=lt.Id)(e,r,s,l,d,m,P,v,y,A);function Fs(e,r,s,l){var d=Ot();try{return Mt.get(e)(r,s,l)}catch(m){if(It(d),m!==m+0)throw m;kt(1,0)}}function Ms(e,r){var s=Ot();try{return Mt.get(e)(r)}catch(l){if(It(s),l!==l+0)throw l;kt(1,0)}}function xs(e,r,s,l,d,m,P,v,y,A){var O=Ot();try{Mt.get(e)(r,s,l,d,m,P,v,y,A)}catch(D){if(It(O),D!==D+0)throw D;kt(1,0)}}function Rs(e,r,s,l){var d=Ot();try{Mt.get(e)(r,s,l)}catch(m){if(It(d),m!==m+0)throw m;kt(1,0)}}function Ns(e,r,s){var l=Ot();try{Mt.get(e)(r,s)}catch(d){if(It(l),d!==d+0)throw d;kt(1,0)}}function ks(e){var r=Ot();try{Mt.get(e)()}catch(s){if(It(r),s!==s+0)throw s;kt(1,0)}}function Os(e,r,s,l,d){var m=Ot();try{Mt.get(e)(r,s,l,d)}catch(P){if(It(m),P!==P+0)throw P;kt(1,0)}}function Is(e,r){var s=Ot();try{Mt.get(e)(r)}catch(l){if(It(s),l!==l+0)throw l;kt(1,0)}}function Ls(e,r,s){var l=Ot();try{return Mt.get(e)(r,s)}catch(d){if(It(l),d!==d+0)throw d;kt(1,0)}}function Ds(e,r,s,l,d,m,P){var v=Ot();try{Mt.get(e)(r,s,l,d,m,P)}catch(y){if(It(v),y!==y+0)throw y;kt(1,0)}}function zs(e,r,s,l,d){var m=Ot();try{return Mt.get(e)(r,s,l,d)}catch(P){if(It(m),P!==P+0)throw P;kt(1,0)}}function Bs(e,r,s,l,d,m){var P=Ot();try{return Mt.get(e)(r,s,l,d,m)}catch(v){if(It(P),v!==v+0)throw v;kt(1,0)}}function Us(e,r,s,l,d,m,P){var v=Ot();try{return Mt.get(e)(r,s,l,d,m,P)}catch(y){if(It(v),y!==y+0)throw y;kt(1,0)}}function Ws(e,r,s,l,d,m){var P=Ot();try{Mt.get(e)(r,s,l,d,m)}catch(v){if(It(P),v!==v+0)throw v;kt(1,0)}}function $s(e,r,s,l,d,m,P,v,y,A){var O=Ot();try{return Mt.get(e)(r,s,l,d,m,P,v,y,A)}catch(D){if(It(O),D!==D+0)throw D;kt(1,0)}}var Ti;Ge=function e(){Ti||rn(),Ti||(Ge=e)};function rn(){function e(){if(!Ti&&(Ti=!0,h.calledRun=!0,!Li)){if(zi(yr),C(h),h.onRuntimeInitialized&&h.onRuntimeInitialized(),h.postRun)for(typeof h.postRun=="function"&&(h.postRun=[h.postRun]);h.postRun.length;){var r=h.postRun.shift();wr.unshift(r)}zi(wr)}}if(!(0<be)){if(h.preRun)for(typeof h.preRun=="function"&&(h.preRun=[h.preRun]);h.preRun.length;)Kn();zi(vr),0<be||(h.setStatus?(h.setStatus("Running..."),setTimeout(function(){setTimeout(function(){h.setStatus("")},1),e()},1)):e())}}if(h.preInit)for(typeof h.preInit=="function"&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.pop()();return rn(),u.ready}})();g.exports=i})(Tn);var oa=Tn.exports,la=Qs(oa);class Be{static slide(t){let i=Te.linear;return typeof t.easing=="string"?i=Te.fromTypeAsString(t.easing):t.easing!==void 0&&(i=t.easing),new Dn(t.direction,t.duration,i)}static none(){return new Ln}}class Ln extends Be{constructor(){super(),this.type=de.None,this.duration=NaN,this.easing=Te.none}}class Dn extends Be{constructor(t,i,n){super(),this.type=de.Slide,this.direction=t,this.duration=i,this.easing=n}}const de={Slide:"Slide",None:"None"},fe={Up:"Up",Down:"Down",Right:"Right",Left:"Left"};class zn{constructor(t,i){this.scene=t,this.transition=i}}const Bn={type:"object",description:"Information about the user's device.",properties:{userAgent:{type:"string",description:"The user agent string returned by navigator.userAgent."},devicePixelRatio:{type:"number",description:"Ratio of physical pixels to CSS pixels."},screen:{type:"object",description:"Screen information returned by window.screen.",properties:{availHeight:{type:"number",description:"Height of screen, in pixels, excluding UI features."},availWidth:{type:"number",description:"Width of screen, in pixels, excluding UI features."},colorDepth:{type:"number",description:"Color depth of screen."},height:{type:"number",description:"Height of screen, in pixels"},width:{type:"number",description:"Width of screen, in pixels."},orientation:{type:"object",description:"Information about the device's orientation.",properties:{type:{type:"string",description:"The orientation type (ScreenOrientation.type)."},angle:{type:"number",description:"The orientation angle (ScreenOrientation.angle)."}}},pixelDepth:{type:"number",description:"Pixel depth of screen."}}},webGlRenderer:{type:"string",description:"WebGL driver vendor and renderer. Taken from WEBGL_debug_renderer_info."}}};class fr{static getRendererString(){const t=document.createElement("canvas");t.id="webgl-renderer-info-canvas",t.height=0,t.width=0,t.hidden=!0,document.body.appendChild(t);const i=t.getContext("webgl");let n="no webgl context";if(!i)return n;const u=i.getExtension("WEBGL_debug_renderer_info");return u!=null?n=String(i.getParameter(u.UNMASKED_VENDOR_WEBGL))+", "+String(i.getParameter(u.UNMASKED_RENDERER_WEBGL)):n="no debug renderer info",t.remove(),n}static dispose(){const t=document.getElementById("webgl-renderer-info-canvas");t&&t.remove()}}class Un{constructor(t,i){this.sounds={},this.game=t,this.baseUrls=i}get audioContext(){if(!this._audioContext){if(!navigator.userActivation.hasBeenActive)throw new Error("AudioContext cannot be created until user has interacted with the page");this._audioContext=new AudioContext}return this._audioContext}initializeSounds(t){return t?this.loadSounds(t):Promise.resolve()}loadSounds(t){return t.length===0?Promise.resolve():(t.forEach(i=>{let n=i.url;q.urlHasScheme(i.url)||(n=q.getUrlFromManifest(this.game,`${this.baseUrls.assets}/${i.url}`));const u={soundName:i.soundName,data:void 0,audioBuffer:void 0,url:n,status:i.lazy?zt.Deferred:zt.WillFetch};this.sounds[i.soundName]&&console.warn(`A sound named ${i.soundName} has already been loaded. It will be replaced.`),this.sounds[i.soundName]=u}),this.fetchSounds())}async fetchSounds(){const t=Object.values(this.sounds).map(i=>i.status===zt.WillFetch?(i.status=zt.Fetching,fetch(i.url).then(n=>{if(!n.ok)throw i.status=zt.Error,new Error(`cannot fetch sound ${i.soundName} at url ${i.url}: ${n.statusText}`);return n.arrayBuffer().then(u=>{i.data=u,i.status=zt.Fetched,console.log(`\u26AA sound fetched. name: ${i.soundName}, bytes: ${u.byteLength}`)})})):Promise.resolve());await Promise.all(t)}fetchDeferredSound(t){return t.status=zt.WillFetch,this.fetchSounds()}hasSoundsToDecode(){return Object.values(this.sounds).filter(t=>t.status===zt.Fetched).length>0}decodeFetchedSounds(){const i=Object.values(this.sounds).filter(n=>n.status===zt.Fetched).map(n=>this.decodeSound(n));return Promise.all(i)}async decodeSound(t){if(!t.data)throw new Error(`data is undefined for sound ${t.soundName} (url ${t.url})`);try{t.status=zt.Decoding;const i=await this.audioContext.decodeAudioData(t.data);t.audioBuffer=i,t.status=zt.Ready,console.log(`\u26AA sound decoded. name: ${t.soundName}, duration (seconds): ${i.duration}`)}catch{throw t.status=zt.Error,new Error(`error decoding sound ${t.soundName} (url: ${t.url})`)}}getSound(t){const i=this.sounds[t];if(!i)throw new Error(`getSound(): sound ${t} not found`);return i}dispose(){}getSoundNames(){return Object.keys(this.sounds)}}class ha{constructor(t){this.game=t.game,this.nodeFactory=t.nodeFactory,this.freeNodesScene=t.freeNodesScene,this.configureI18n=t.configureI18n,this.eventMaterializers=new Map([[G.NodeNew,this.materializeNodeNewEvent.bind(this)],[G.Composite,this.materializeCompositeEvent.bind(this)],[G.ScenePresent,this.materializeScenePresentEvent.bind(this)],[G.NodePropertyChange,this.materializeNodePropertyChangeEvent.bind(this)],[G.NodeAddChild,this.materializeNodeAddChildEvent.bind(this)],[G.NodeRemoveChild,this.materializeNodeRemoveChildEvent.bind(this)],[G.DomPointerDown,this.materializeDomPointerDownEvent.bind(this)],[G.BrowserImageDataReady,this.materializeBrowserImageDataReadyEvent.bind(this)],[G.I18nDataReadyEvent,this.materializeI18nDataReadyEvent.bind(this)]])}materialize(t){t.length>0&&(console.log(`Replaying ${t.length} events`),t.forEach(i=>{const n=this.eventMaterializers.get(i.type);n?n(i):console.log(`EventMaterializer unhandled event: ${i.type}`)}))}materializeCompositeEvent(t){const i=this.game.materializedNodes.find(n=>n.uuid===t.target);if(!i)console.log(`EventMaterializer: composite node of type ${t.compositeType} with uuid ${t.target} not found when handling CompositeEvent ${t.compositeEventType}`);else if(i.type===at.Composite)i.handleCompositeEvent(t);else throw new Error(`EventMaterializer: node was expected to be composite, but was of type ${i.type}`)}materializeNodeNewEvent(t){const i=this.nodeFactory.createNode(t.nodeType,t.compositeType,t.nodeOptions);i.type===at.Scene&&(i.name===X.FREE_NODES_SCENE_NAME?(this.freeNodesScene=i,this.freeNodesScene.game=this.game,this.freeNodesScene.needsInitialization=!0,this.game.freeNodesScene=this.freeNodesScene):this.game.addScene(i)),this.game.materializedNodes.push(i)}materializeNodePropertyChangeEvent(t){const i=this.game.materializedNodes.find(n=>n.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: node with uuid ${t.uuid} not found`);if(t.property in i)i[t.property]=t.value;else throw new Error(`EventMaterializer: on node ${i.name}, type ${i.type}, nodePropertyChangeEvent tried to set unknown property ${t.property} to value ${JSON.stringify(t.value)}`)}materializeNodeAddChildEvent(t){const i=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const n=this.game.materializedNodes.find(u=>u.uuid===t.childUuid);if(!n)throw new Error(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.addChild(n)}materializeNodeRemoveChildEvent(t){const i=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!i)throw new Error(`EventMaterializer: parent node with uuid ${t.uuid} not found`);const n=this.game.materializedNodes.find(u=>u.uuid===t.childUuid);if(!n)throw new Error(`EventMaterializer: child node with uuid ${t.childUuid} not found`);i.removeChild(n)}materializeDomPointerDownEvent(t){this.game.currentScene?.run(V.custom({callback:()=>{const i=new ai({circleOfRadius:16,fillColor:x.LightGray,strokeColor:x.Black,lineWidth:2,alpha:.75,position:{x:t.x,y:t.y}});this.game.currentScene?.addChild(i),i.run(V.sequence([V.group([V.fadeAlpha({duration:750,alpha:0}),V.scale({duration:750,scale:0})]),V.custom({callback:()=>{this.game.currentScene?.removeChild(i)}})]))}}))}materializeBrowserImageDataReadyEvent(t){this.game.imageManager.loadImages([{imageName:t.imageName,width:t.width,height:t.height,dataUrl:t.dataUrl,svgString:t.svgString}])}materializeI18nDataReadyEvent(t){this.configureI18n(t.localizationOptions)}materializeScenePresentEvent(t){let i=Be.none();if(t.transitionType===de.Slide){if(t.direction===void 0)throw new Error("EventMaterializer: ScenePresentEvent direction is undefined for slide transition");if(t.duration===void 0)throw new Error("EventMaterializer: ScenePresentEvent duration is undefined for slide transition");if(t.easingType===void 0)throw new Error("EventMaterializer: ScenePresentEvent easingType is undefined for slide transition");const n=this.game.materializedNodes.find(u=>u.uuid===t.uuid);if(!n)throw new Error(`EventMaterializer: Scene with uuid ${t.uuid} not found`);switch(t.direction){case fe.Left:{n.position.x=n.size.width;break}case fe.Right:{n.position.x=-n.size.width;break}case fe.Up:{n.position.y=n.size.height;break}case fe.Down:{n.position.y=-n.size.height;break}}i=Be.slide({direction:t.direction,duration:t.duration,easing:Te.fromTypeAsString(t.easingType)})}this.game.presentScene(t.uuid,i)}}class ca{constructor(t){if(this.type=si.Game,this.sessionUuid="",this.uuid=De.generate(),this.publishUuid="",this.canvasKitWasmVersion="0.39.1",this.beginTimestamp=NaN,this.beginIso8601Timestamp="",this.eventListeners=new Array,this.gameMetrics=new Array,this.stepCount=0,this.steppingNow=0,this.warmupFunctionQueue=new Array,this.warmupFinished=!1,this.plugins=[],this.staticTrialSchema={},this.eventStore=new An,this.nodeFactory=new Cn,this.materializedNodes=new Array,this.data={trials:new Array},this.trialIndex=0,this.drawnFrames=0,this.lastFpsUpdate=0,this.nextFpsUpdate=0,this.fpsRate=0,this.animationFramesRequested=0,this.limitFps=!1,this.gameStopRequested=!1,this.webGlRendererInfo="",this.canvasCssWidth=0,this.canvasCssHeight=0,this.scenes=new Array,this.freeNodesScene=new Ue({name:X.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0]}),this.incomingSceneTransitions=new Array,this.replayEventsButtonEnabled=!0,this.automaticTrialSchema={study_id:{type:["string","null"],description:"The short human-readable text ID of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},study_uuid:{type:["string","null"],format:"uuid",description:"Unique identifier of the study (protocol, experiment, or other aggregate) that contains the administration of this activity."},document_uuid:{type:"string",format:"uuid",description:"Unique identifier for this data document."},session_uuid:{type:"string",format:"uuid",description:"Unique identifier for all activities in this administration of the session. This identifier changes each time a new session starts."},activity_uuid:{type:"string",format:"uuid",description:"Unique identifier for all trials in this administration of the activity. This identifier changes each time the activity starts."},activity_id:{type:"string",description:"Human-readable identifier of the activity."},activity_publish_uuid:{type:"string",format:"uuid",description:"Persistent unique identifier of the activity. This identifier never changes. It can be used to identify the activity across different studies and sessions."},activity_version:{type:"string",description:"Version of the activity."},device_timezone:{type:"string",description:"Timezone of the device. Calculated from Intl.DateTimeFormat().resolvedOptions().timeZone."},device_timezone_offset_minutes:{type:"integer",description:"Difference in minutes between UTC and device timezone. Calculated from Date.getTimezoneOffset()."},locale:{type:["string","null"],description:"Locale of the trial. null if the activity does not support localization."}},this.snapshots=new Array,!t.id||t.id.trim()==="")throw new Error("id is required in GameOptions");if(!De.isValid(t.publishUuid)){const i=t.publishUuid?`Provided publishUuid was ${t.publishUuid}. `:"";console.warn(`Missing or invalid publishUuid in GameOptions. ${i}To generate a valid UUID, visit a site such as https://www.uuidgenerator.net/version4`)}this.options=t,this.name=t.name,this.id=t.id,this.publishUuid=t.publishUuid,this.fpsMetricReportThreshold=t.fpsMetricReportThreshold??X.FPS_METRIC_REPORT_THRESHOLD,this.maximumRecordedActivityMetrics=t.maximumRecordedActivityMetrics??X.MAXIMUM_RECORDED_ACTIVITY_METRICS,this.addLocalizationParametersToGameParameters(),this.options.locale!==void 0&&this.setParameters({locale:this.options.locale}),this.options.fallbackLocale!==void 0&&this.setParameters({fallback_locale:this.options.fallbackLocale}),this.options.missingLocalizationColor&&this.setParameters({missing_localization_color:this.options.missingLocalizationColor}),this.options.translation&&this.setParameters({translation:this.options.translation}),this.options.additionalTranslation&&this.setParameters({translation:this.options.additionalTranslation}),this.options.trialSchema||(this.options.trialSchema={}),t.moduleMetadata?this.moduleMetadata=t.moduleMetadata:this.moduleMetadata={name:"",version:"",dependencies:{}},t.moduleMetadata?.name&&t.version&&console.log(`\u26AA ${t.moduleMetadata.name} version ${t.version}`)}createFreeNodesScene(){this.freeNodesScene.game=this,this.freeNodesScene.needsInitialization=!0;const t={name:X.FREE_NODES_SCENE_NAME,backgroundColor:[255,255,255,0],uuid:this.freeNodesScene.uuid},i={type:G.NodeNew,target:this.freeNodesScene,nodeType:at.Scene,...q.createFrameUpdateTimestamps(),nodeOptions:t,sequence:m2c2Globals.eventSequence};this.eventStore.addEvent(i)}getImportedModuleBaseUrl(t,i){const n=new RegExp(`^.*${t}[^\\/]*`),u=i.match(n);if(!u||u.length===0)throw new Error(`Could not calculate imported assessment package base URL. Package name: ${t}, module URL: ${i}`);return u[0]}addLocalizationParametersToGameParameters(){this.options.parameters={...this.options.parameters,...xi.makeLocalizationParameters()}}async init(){return this.initialize()}loadCanvasKit(t){return la({locateFile:()=>t})}async resolveGameBaseUrls(t){let i,n=!1,u=`assets/${t.id}`;if(t.moduleMetadata.name)try{i=await import.meta.resolve(t.moduleMetadata.name),u=t.getImportedModuleBaseUrl(t.moduleMetadata.name,i)+"/assets",n=!0}catch{}let h=`assets/${t.id}`;try{const C=await import.meta.resolve("@m2c2kit/core");h=t.getImportedModuleBaseUrl("@m2c2kit/core",C)+"/assets"}catch{if(n)throw new Error(`the package ${t.moduleMetadata.name} has been imported from a module URL (${i}), but the @m2c2kit/core package module URL could not be determined.`)}return{assets:u,canvasKitWasm:h}}async configureI18n(t){if(this.i18n=new xi(this,t),!this.i18n)throw new Error("I18n object is undefined");await this.i18n.initialize(),this.eventStore.addEvent({type:"I18nDataReadyEvent",target:this.i18n,localizationOptions:t,...q.createFrameUpdateTimestamps()})}async waitForErudaInitialization(t=5e3){await new Promise(i=>{let n=0;const u=setInterval(()=>{m2c2Globals.erudaInitialized===!0&&(clearInterval(u),i(void 0)),n=n+100,n>t&&(console.warn(`Could not initialize eruda within ${t} milliseconds.`),clearInterval(u),i(void 0))},100)})}async initialize(){m2c2Globals.erudaRequested===!0&&await this.waitForErudaInitialization(),this.options.recordEvents===!0&&(this.eventStore.mode=ce.Record),this.createFreeNodesScene();const t=await this.resolveGameBaseUrls(this);if(this.manifest===void 0&&(this.manifest=await this.loadManifest()),this._canvasKit===void 0){const i=q.getUrlFromManifest(this,t.canvasKitWasm+`/canvaskit-${this.canvasKitWasmVersion}.wasm`);try{this.canvasKit=await this.loadCanvasKit(i)}catch{throw new Error(`game ${this.id} could not load canvaskit wasm file from ${i}`)}}if(this.isLocalizationRequested()){const i=this.getLocalizationOptionsFromGameParameters();await this.configureI18n(i)}return this.fontManager=new _n(this,t),this.imageManager=new or(this,t),this.soundManager=new Un(this,t),this.eventMaterializer=new ha({game:this,nodeFactory:this.nodeFactory,freeNodesScene:this.freeNodesScene,configureI18n:this.configureI18n.bind(this)}),Promise.all([this.fontManager.initializeFonts(this.options.fonts),this.imageManager.initializeImages(this.options.images),this.soundManager.initializeSounds(this.options.sounds)])}async loadManifest(t="__NO_M2C2KIT_MANIFEST_JSON_URL__"){if(t.includes("NO_M2C2KIT_MANIFEST_JSON_URL"))return{};let i;try{if(i=await fetch(t),!i.ok)throw new Error(`Error ${i.status} on GET manifest.json from ${t}.`)}catch{throw new Error(`Network error on GET manifest.json from ${t}.`)}try{return await i.json()}catch{throw new Error(`Error parsing manifest.json from ${t}.`)}}get fontManager(){if(!this._fontManager)throw new Error("fontManager is undefined");return this._fontManager}set fontManager(t){this._fontManager=t}get imageManager(){if(!this._imageManager)throw new Error("imageManager is undefined");return this._imageManager}set imageManager(t){this._imageManager=t}get soundManager(){if(!this._soundManager)throw new Error("soundManager is undefined");return this._soundManager}set soundManager(t){this._soundManager=t}get eventMaterializer(){if(!this._eventMaterializer)throw new Error("eventMaterializer is undefined");return this._eventMaterializer}set eventMaterializer(t){this._eventMaterializer=t}addPrefixesToKey(t){let i="";if(this.studyId&&this.studyUuid)i=this.studyId.concat(":",this.studyUuid,":");else if(this.studyId||this.studyUuid)throw new Error(`study_id and study_uuid must both be set or unset. Values are study_id: ${this.studyId}, study_uuid: ${this.studyUuid}`);return i.concat(this.id.concat(this.id,":",this.publishUuid,":",t))}storeSetItem(t,i,n=!1){const u=n?t:this.addPrefixesToKey(t);return this.dataStores[0].setItem(u,i,n?"":this.publishUuid)}storeGetItem(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].getItem(n)}storeDeleteItem(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].deleteItem(n)}storeClearItems(){return this.dataStores[0].clearItemsByActivityPublishUuid(this.publishUuid)}storeItemsKeys(t=!1){return this.dataStores[0].itemsKeysByActivityPublishUuid(t?"":this.publishUuid)}storeItemExists(t,i=!1){const n=i?t:this.addPrefixesToKey(t);return this.dataStores[0].itemExists(n)}get dataStores(){if(!this._dataStores)throw new Error("dataStores is undefined");return this._dataStores}set dataStores(t){this._dataStores=t}hasDataStores(){return this._dataStores&&this._dataStores.length>0||!1}getLocalizationOptionsFromGameParameters(){const t=this.getParameter("locale"),i=this.getParameterOrFallback("fallback_locale",void 0),n=this.getParameterOrFallback("missing_localization_color",void 0),u=this.getParameterOrFallback("translation",void 0),h=this.options.translation;return{locale:t,fallbackLocale:i,missingLocalizationColor:n,additionalTranslation:u,translation:h}}isLocalizationRequested(){const t=this.getParameterOrFallback("locale",void 0);if(t==="")throw new Error("Empty string in locale. Leave locale undefined or null to prevent localization.");return t==null&&this.options.translation?(this.setParameters({locale:this.options.translation.baseLocale}),!0):!(t==null&&this.options.translation===void 0)}setParameters(t){const{parameters:i}=this.options;Object.keys(t).forEach(n=>{if(n==="eruda"){t[n]===!0&&q.loadEruda();return}if(n==="scripts"){const u=t[n];u&&q.loadScriptUrls(u);return}!i||!(n in i)?console.warn(`game ${this.options.name} does not have a parameter named ${n}. attempt to set parameter ${n} to value ${t[n]} will be ignored`):this.options.parameters&&this.options.parameters[n]&&(this.options.parameters[n].default=t[n]),this.additionalParameters===void 0&&(this.additionalParameters={}),this.additionalParameters[n]=t[n]})}get canvasKit(){if(!this._canvasKit)throw new Error("canvaskit is undefined");return this._canvasKit}set canvasKit(t){this._canvasKit=t}addFreeNode(t){this.freeNodesScene.addChild(t)}addFreeEntity(t){this.addFreeNode(t)}removeFreeNode(t){if(typeof t=="string"){const i=this.freeNodesScene.children.filter(n=>n.name===t).find(Boolean);if(!i)throw new Error(`cannot remove free node named "${t}" because it is not currently part of the game's free nodes. `);this.freeNodesScene.removeChild(i)}else this.freeNodesScene.removeChild(t)}removeFreeEntity(t){this.removeFreeNode(t)}removeAllFreeNodes(){for(;this.freeNodesScene.children.length;)this.freeNodesScene.children.pop()}removeAllFreeEntities(){this.removeAllFreeNodes()}get freeNodes(){return this.freeNodesScene.children}get freeEntities(){return this.freeNodes}addScene(t){t.game=this,t.needsInitialization=!0,this.scenes.push(t),this.addNodeEvents(t)}addNodeEvents(t){this.eventStore.addEvents(t.nodeEvents),t.nodeEvents.length=0;for(const i of t.children)this.addNodeEvents(i)}addScenes(t){t.forEach(i=>{this.addScene(i)})}removeScene(t){if(typeof t=="object")if(this.scenes.includes(t))this.scenes=this.scenes.filter(i=>i!==t);else throw new Error(`cannot remove scene ${t} from game because the scene is not currently added to the game`);else if(this.scenes.map(i=>i.name).includes(t))this.scenes=this.scenes.filter(i=>i.name!==t);else throw new Error(`cannot remove scene named "${t}" from game because the scene is not currently added to the game`)}presentScene(t,i){let n;if(typeof t=="string"){if(n=this.scenes.filter(F=>F.name===t).find(Boolean),n===void 0&&(n=this.scenes.filter(F=>F.uuid===t).find(Boolean)),n===void 0)throw new Error(`scene ${t} not found`)}else{if(!this.scenes.some(F=>F===t))throw new Error(`scene ${t} exists, but it has not been added to the game object`);n=t}n.initialize(),n.needsInitialization=!1;const u=new zn(n,i??Be.none());this.incomingSceneTransitions.push(u),n.game.bodyBackgroundColor!==void 0?document.body.style.backgroundColor=`rgb(${n.game.bodyBackgroundColor[0]},${n.game.bodyBackgroundColor[1]},${n.game.bodyBackgroundColor[2]},${n.game.bodyBackgroundColor[3]})`:document.body.style.backgroundColor=`rgb(${n.backgroundColor[0]},${n.backgroundColor[1]},${n.backgroundColor[2]},${n.backgroundColor[3]})`;let h;i?.type===de.Slide&&(h=i.direction);const C={type:"ScenePresent",target:n,uuid:n.uuid,...q.createFrameUpdateTimestamps(),transitionType:i?.type??de.None,duration:i?.duration,direction:h,easingType:i?.easing?Te.toTypeAsString(i.easing):void 0};this.eventStore.addEvent(C)}getParameter(t){if(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))return this.options.parameters[t].default;throw new Error(`game parameter ${t} not found`)}getParameterOrFallback(t,i){return this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t)?this.options.parameters[t].default:i}hasParameter(t){return!!(this.options.parameters!==void 0&&Object.keys(this.options.parameters).includes(t))}async start(t){const i=this.options;this.setupHtmlCanvases(i.canvasId,i.width,i.height,i.stretch),this.showFps=i.showFps??!1,this.bodyBackgroundColor=i.bodyBackgroundColor,this.initData(),this.setupCanvasKitSurface(),this.setupFpsFont(),this.setupCanvasDomEventHandlers(),this.beginTimestamp=Wt.now(),this.beginIso8601Timestamp=new Date().toISOString();let n;if(t!==void 0?typeof t=="object"?n=t:n=this.scenes.filter(C=>C.name===t).find(Boolean):this.entryScene!==void 0?typeof this.entryScene=="object"?n=this.entryScene:n=this.scenes.filter(C=>C.name===this.entryScene).find(Boolean):n=this.scenes.find(Boolean),n===void 0)throw new Error("cannot start game. entry scene has not been added to the game object.");if(this.presentScene(n),this.surface===void 0)throw new Error("CanvasKit surface is undefined");this.options.timeStepping?(this.addTimeSteppingControlsToDom(),this.updateTimeSteppingOutput()):this.removeTimeSteppingControlsFromDom(),this.options.showEventStoreControls&&this.addEventControlsToDom(),this.warmupFinished=!1;const u={target:this,type:G.GameWarmupStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(u),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithPrimitives,positionOffset:.10012117}),this.warmupFunctionQueue.push({warmupFunction:this.warmupShadersWithScenes}),this.surface.requestAnimationFrame(this.loop.bind(this));const h={target:this,type:G.ActivityStart,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(h)}playEventsHandler(t){if(t?.target?.id==="replay-events"&&(this.eventStore.mode=ce.Disabled,this.scenes.forEach(i=>{this.removeScene(i)}),this.currentScene=void 0,this.eventListeners=new Array,this.freeNodesScene.removeAllChildren(),this.materializedNodes=[],this.eventStore.replay(),this.setReplayEventsButtonEnabled(!1),this.setStopReplayButtonEnabled(!0)),t?.target?.id==="stop-replay"&&(this.eventStore.clearEvents(),this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1)),t?.target?.id==="log-events"){if(this.eventStore.mode===ce.Replay){console.log(this.eventStore.serializedEventsBeforeReplay),console.log(`Total events: ${JSON.parse(this.eventStore.serializedEventsBeforeReplay).length}`);return}console.log(JSON.stringify(this.eventStore.getEvents())),console.log(`Total events: ${this.eventStore.getEvents().length}`)}}setReplayEventsButtonEnabled(t){const i=document.getElementById("replay-events");if(i){if(t){i.removeAttribute("disabled"),this.replayEventsButtonEnabled=!0;return}i.setAttribute("disabled","true"),this.replayEventsButtonEnabled=!1}}setStopReplayButtonEnabled(t){const i=document.getElementById("stop-replay");if(i){if(t){i.removeAttribute("disabled");return}i.setAttribute("disabled","true")}}addEventControlsToDom(){const t=document.getElementById("m2c2kit-event-controls-div");t&&t.remove();const i=document.getElementsByTagName("body")[0];if(i){const n=document.createElement("div");n.id="m2c2kit-event-controls-div",n.style.position="fixed",n.style.top="4px",n.style.left="4px",i.prepend(n);const u=document.createElement("button");u.id="replay-events",u.title="replay event recording",u.innerText="\u25B6\uFE0F",u.style.marginRight="4px",n.appendChild(u),u.addEventListener("click",this.playEventsHandler.bind(this));const h=document.createElement("button");h.id="stop-replay",h.title="stop event replay",h.innerText="\u23F9\uFE0F",h.style.marginRight="4px",h.disabled=!0,n.appendChild(h),h.addEventListener("click",this.playEventsHandler.bind(this));const C=document.createElement("button");C.id="log-events",C.title="log events to console",C.innerText="\u{1F4C4}",C.style.marginRight="4px",n.appendChild(C),C.addEventListener("click",this.playEventsHandler.bind(this));const F=document.createElement("span");F.title="optional: replay events only through a given sequence number. Default is to replay all events.",F.innerText="Replay through sequence: ",n.appendChild(F);const B=document.createElement("input");B.id="sequence-number",B.title="optional: replay events only through a given sequence number. Default is to replay all events.",B.style.marginRight="4px",n.appendChild(B)}}addTimeSteppingControlsToDom(){if(document.getElementById("m2c2kit-time-stepping-div"))return;const i=document.getElementsByTagName("body")[0];if(i){const n=document.createElement("div");n.id="m2c2kit-time-stepping-div",i.prepend(n);const u=document.createElement("button");u.id="1-step-advance",u.title="advance 1 step (16.667 ms)",u.innerText=">",u.style.marginRight="4px",n.appendChild(u),u.addEventListener("click",this.advanceStepsHandler.bind(this));const h=document.createElement("button");h.id="55-step-advance",h.title="advance 55 steps (916.667 ms)",h.innerText=">>",h.style.marginRight="4px",n.appendChild(h),h.addEventListener("click",this.advanceStepsHandler.bind(this));const C=document.createElement("input");C.id="time-stepping-steps-input",C.title="steps",C.style.width="40px",C.style.marginRight="4px",C.setAttribute("readonly","true"),n.appendChild(C);const F=document.createElement("input");F.id="time-stepping-now-input",F.title="milliseconds",F.style.width="80px",F.style.marginRight="4px",F.setAttribute("readonly","true"),n.appendChild(F)}}updateTimeSteppingOutput(){const t=document.getElementById("time-stepping-steps-input");t&&(t.value=this.stepCount.toString());const i=document.getElementById("time-stepping-now-input");i&&(i.value=this.steppingNow.toFixed(2))}advanceStepsHandler(t){t?.target?.id==="1-step-advance"?(this.steppingNow=this.steppingNow+16.66666666666667,this.stepCount=this.stepCount+1):t?.target?.id==="55-step-advance"&&(this.steppingNow=this.steppingNow+16.66666666666667*55,this.stepCount=this.stepCount+55),this.updateTimeSteppingOutput()}removeTimeSteppingControlsFromDom(){const t=document.getElementById("m2c2kit-time-stepping-div");t&&t.remove()}warmupShadersWithPrimitives(t,i=0){if(t.save(),i==0?t.scale(1/m2c2Globals.canvasScale,1/m2c2Globals.canvasScale):t.scale(1/m2c2Globals.canvasScale*1.13,1/m2c2Globals.canvasScale*1.13),!this.surface)throw new Error("surface is undefined");const n=this.surface.width(),u=this.surface.height(),h=Math.round(n/2)+i,C=Math.round(u/2)+i,F=i,B=i,U=Ft.makePaint(this.canvasKit,x.White,this.canvasKit.PaintStyle.Fill,!0);t.drawRect([0,0,this.surface.width(),this.surface.height()],U);const et=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Fill,!1),ct=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Fill,!0),ut=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Stroke,!1);ut.setStrokeWidth(2);const At=Ft.makePaint(this.canvasKit,x.Black,this.canvasKit.PaintStyle.Stroke,!0);At.setStrokeWidth(2),t.drawCircle(h,C,32,et),t.drawCircle(h,C,32,ct),t.drawCircle(h,C,32,ut),t.drawCircle(h,C,32,At);const yt=this.fontManager,ne=this.fontManager.getFontNames();if(ne.length>0&&yt.fonts[ne[0]].status===Xt.Ready){const Me=yt.getTypeface(ne[0]),We=new this.canvasKit.Font(Me,16*m2c2Globals.canvasScale);t.drawText("abc",h,C,et,We),t.drawText("abc",h,C,ct,We)}const Se=this.takeCurrentSceneSnapshot();t.drawImage(Se,F,B),Se.delete(),t.drawRect([F,B,16,16],et),t.drawRect([F,B,16,16],ct),t.drawRect([F,B,16,16],ut),t.drawRect([F,B,16,16],At),t.restore()}warmupShadersWithScenes(t){[...this.scenes,this.freeNodesScene].forEach(h=>{h.warmup(t)});const i=this.nodes.filter(h=>h.type===at.Sprite).map(h=>h.imageName),n=this.imageManager.images;n&&Object.keys(n).filter(C=>C!=="__outgoingSceneSnapshot").forEach(C=>{if(!i.includes(C)&&n[C].status===Yt.Ready){const F=n[C].canvaskitImage;if(!F)throw new Error(`image ${C} is undefined`);t.drawImage(F,0,0)}});const u=new this.canvasKit.Paint;if(u.setColor(this.canvasKit.Color(255,255,255,1)),!this.surface)throw new Error("surface is undefined");t.drawRect([0,0,this.surface.width(),this.surface.height()],u)}stop(){this.currentScene&&(this.currentScene._active=!1),this.gameStopRequested=!0,Wt.removeAll(),this.dispose()}dispose(){this.nodes.filter(t=>t.isDrawable).forEach(t=>t.dispose()),this.fontManager.dispose()}initData(){this.trialIndex=0,this.data={trials:new Array};const t=this.options.trialSchema??{},i=Object.entries(t);for(const[n,u]of i)if(u.type!==void 0&&!this.propertySchemaDataTypeIsValid(u.type))throw new Error(`invalid schema. variable ${n} is type ${u.type}. type must be number, string, boolean, object, or array`)}propertySchemaDataTypeIsValid(t){const i=["string","number","integer","object","array","boolean","null"];if(typeof t=="string")return i.includes(t);let n=!0;if(Array.isArray(t))t.forEach(u=>{i.includes(u)||(n=!1)});else throw new Error(`Invalid data type: ${t}`);return n}getDeviceMetadata(){const t=window.screen;return t.orientation?{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,orientation:{type:t.orientation.type,angle:t.orientation.angle},pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}:{userAgent:navigator.userAgent,devicePixelRatio:window.devicePixelRatio,screen:{availHeight:t.availHeight,availWidth:t.availWidth,colorDepth:t.colorDepth,height:t.height,pixelDepth:t.pixelDepth,width:t.width},webGlRenderer:this.webGlRendererInfo}}addTrialData(t,i){if(!this.options.trialSchema)throw new Error("no trial schema were provided in GameOptions. cannot add trial data");if(this.data.trials.length<this.trialIndex+1){const h={},C=Object.entries(this.options.trialSchema);for(const[F]of C)h[F]=null;this.data.trials.push({document_uuid:De.generate(),study_id:this.studyId??null,study_uuid:this.studyUuid??null,session_uuid:this.sessionUuid,activity_uuid:this.uuid,activity_id:this.options.id,activity_publish_uuid:this.options.publishUuid,activity_version:this.options.version,device_timezone:Intl?.DateTimeFormat()?.resolvedOptions()?.timeZone??"",device_timezone_offset_minutes:new Date().getTimezoneOffset(),locale:this.i18n?.locale??null,...h,device_metadata:this.getDeviceMetadata()})}if(!(t in this.options.trialSchema))throw new Error(`trial variable ${t} not defined in schema`);let n;Array.isArray(this.options.trialSchema[t].type)?n=this.options.trialSchema[t].type:n=[this.options.trialSchema[t].type];let u=typeof i;if(u==="object"&&Object.prototype.toString.call(i)==="[object Array]"&&(u="array"),i==null&&(u="null"),!n.includes(u)&&!(u==="number"&&Number.isInteger(i)&&n.includes("integer")))throw new Error(`type for variable ${t} (value: ${i}) is "${u}". Based on schema for this variable, expected type was "${n}"`);this.data.trials[this.trialIndex][t]=i}addTrialSchema(t){Object.keys(t).forEach(n=>{if(!this.options.trialSchema)throw new Error("trial schema is undefined");this.options.trialSchema[n]=t[n]})}addStaticTrialData(t,i){if(!this.options.trialSchema)throw new Error("trial schema is undefined");if(this.options.trialSchema[t]===void 0)throw new Error(`trial variable ${t} not defined in schema`);this.staticTrialSchema[t]=i}trialComplete(){this.data.trials[this.trialIndex]?.locale&&(this.data.trials[this.trialIndex].locale=this.i18n?.locale??null),this.data.trials[this.trialIndex]?.device_metadata&&(this.data.trials[this.trialIndex].device_metadata=this.getDeviceMetadata()),Object.keys(this.staticTrialSchema).length>0&&(this.data.trials[this.trialIndex]={...this.data.trials[this.trialIndex],...this.staticTrialSchema}),this.trialIndex++;const t={type:G.ActivityData,...q.createFrameUpdateTimestamps(),target:this,newData:this.data.trials[this.trialIndex-1],newDataSchema:this.makeNewGameDataSchema(),data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t)}makeNewGameDataSchema(){return{description:`A single trial and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Bn}}}makeGameDataSchema(){return{description:`All trials and metadata from the assessment ${this.name}.`,$comment:`Activity identifier: ${this.options.id}, version: ${this.options.version}.`,$schema:"https://json-schema.org/draft/2019-09/schema",type:"object",required:["trials"],properties:{trials:{type:"array",items:{$ref:"#/$defs/trial"},description:"All trials from the assessment."}},$defs:{trial:{type:"object",properties:{...this.automaticTrialSchema,...this.options.trialSchema,device_metadata:Bn}}}}}makeGameActivityConfiguration(t){const i=JSON.parse(JSON.stringify(t)),{locale:n,fallback_locale:u,missing_localization_color:h,translation:C,...F}=i;for(const B in F)for(const U in F[B])U=="default"&&(F[B]=F[B][U]);return F}makeGameActivityConfigurationSchema(t){const i=JSON.parse(JSON.stringify(t)),{locale:n,fallback_locale:u,missing_localization_color:h,translation:C,...F}=i;for(const B in F){if(!("type"in F[B])&&"value"in F[B]){const U=typeof F[B].default;U!=="bigint"&&U!=="function"&&U!=="symbol"&&U!=="undefined"&&(F[B].type=U)}for(const U in F[B])U=="default"&&delete F[B][U]}return{description:`activity configuration from the assessment ${this.name}`,type:"object",properties:F}}end(){const t={target:this,type:G.ActivityEnd,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}cancel(){const t={target:this,type:G.ActivityCancel,...q.createFrameUpdateTimestamps()},i={data:this.data,dataSchema:this.makeGameDataSchema(),activityConfiguration:this.makeGameActivityConfiguration(this.options.parameters??{}),activityConfigurationSchema:this.makeGameActivityConfigurationSchema(this.options.parameters??{}),activityMetrics:this.gameMetrics};this.raiseActivityEventOnListeners(t,i)}setupHtmlCanvases(t,i,n,u){m2c2Globals.canvasScale=Math.round(window.devicePixelRatio*100)/100;let h;if(t===void 0){const C=document.getElementsByTagName("canvas");let F=new Array;for(let U=0;U<C.length;U++)F.push(C[U]);if(F=F.filter(U=>!U.id.startsWith("m2c2kit-scratch-canvas")),F.length===0)throw new Error("no html canvas tag was found in the html");const B=F.filter(U=>U.id==="m2c2kit-canvas")[0];B?(h=B,F.length>1&&console.log("using canvas with id 'm2c2kit-canvas'")):(h=C[0],F.length>1&&console.log("using first canvas"))}else if(h=document.getElementById(t),h===void 0)throw new Error(`could not find canvas HTML element with id "${t}"`);if(u||window.innerWidth<i||window.innerHeight<n){const C=n/i;window.innerHeight/window.innerWidth<C?m2c2Globals.rootScale=window.innerHeight/n:m2c2Globals.rootScale=window.innerWidth/i}h.style.width=m2c2Globals.rootScale*i+"px",h.style.height=m2c2Globals.rootScale*n+"px",h.width=m2c2Globals.rootScale*i*m2c2Globals.canvasScale,h.height=m2c2Globals.rootScale*n*m2c2Globals.canvasScale,this.htmlCanvas=h,this.canvasCssWidth=i,this.canvasCssHeight=n,m2c2Globals.canvasCssWidth=i,m2c2Globals.canvasCssHeight=n}setupCanvasKitSurface(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");window.logWebGl=this.options.logWebGl,this.interceptWebGlCalls();try{this.webGlRendererInfo=fr.getRendererString()}catch{this.webGlRendererInfo="err",fr.dispose()}const t=this.canvasKit.MakeWebGLCanvasSurface(this.htmlCanvas);if(t===null)throw new Error("could not make CanvasKit surface from canvas HTML element");this.surface=t,console.log(`\u26AA CanvasKit surface is backed by ${this.surface.reportBackendTypeIsGPU()?"GPU":"CPU"}`),this.surface.getCanvas().scale(m2c2Globals.canvasScale,m2c2Globals.canvasScale)}interceptWebGlCalls(){if(!this.htmlCanvas.__proto__.m2c2ModifiedGetContext){this.htmlCanvas.__proto__.m2c2ModifiedGetContext=!0;const t=this.htmlCanvas.__proto__.getContext;this.htmlCanvas.__proto__.getContext=function(...i){window.logWebGl&&console.log(`\u{1F53C} getContext(${i.map(u=>u.toString()).join(", ")})`);const n=t.apply(this,[...i]);if(n.__proto__.compileShader&&!n.__proto__.m2c2ModifiedCompileShader){n.__proto__.m2c2ModifiedCompileShader=!0;const u=n.__proto__.compileShader;n.__proto__.compileShader=function(...h){if(window.logWebGl){const C=h[0],F=n.getShaderSource(C);console.log("\u{1F53C} compileShader():"),console.log(F)}return u.apply(this,[...h])}}return n}}}setupFpsFont(){this.fpsTextFont=new this.canvasKit.Font(null,X.FPS_DISPLAY_TEXT_FONT_SIZE*m2c2Globals.canvasScale),this.fpsTextPaint=new this.canvasKit.Paint,this.fpsTextPaint.setColor(this.canvasKit.Color(X.FPS_DISPLAY_TEXT_COLOR[0],X.FPS_DISPLAY_TEXT_COLOR[1],X.FPS_DISPLAY_TEXT_COLOR[2],X.FPS_DISPLAY_TEXT_COLOR[3])),this.fpsTextPaint.setAntiAlias(!0)}setupCanvasDomEventHandlers(){if(this.htmlCanvas===void 0)throw new Error("main html canvas is undefined");this.htmlCanvas.addEventListener("pointerdown",this.htmlCanvasPointerDownHandler.bind(this)),this.htmlCanvas.addEventListener("pointerup",this.htmlCanvasPointerUpHandler.bind(this)),this.htmlCanvas.addEventListener("pointermove",this.htmlCanvasPointerMoveHandler.bind(this)),this.htmlCanvas.addEventListener("touchstart",t=>{t.preventDefault()}),this.htmlCanvas.addEventListener("pointerleave",this.htmlCanvasPointerLeaveHandler.bind(this))}loop(t){if(!this.surface)throw new Error("surface is undefined");if(this.warmupFunctionQueue.length>0){const i=this.warmupFunctionQueue.shift();i?.warmupFunction.call(this,t,i.positionOffset),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(!this.warmupFinished){this.warmupFinished=!0;const i={target:this,type:G.GameWarmupEnd,...q.createFrameUpdateTimestamps()};this.raiseActivityEventOnListeners(i),this.surface.requestAnimationFrame(this.loop.bind(this));return}if(this.soundManager.hasSoundsToDecode()&&navigator.userActivation.hasBeenActive&&this.soundManager.decodeFetchedSounds(),this.gameStopRequested){this.surface.deleteLater();return}if(this.animationFramesRequested++,!this.limitFps||this.animationFramesRequested%Math.round(60/X.LIMITED_FPS_RATE)===0){if(this.currentScene===void 0&&this.incomingSceneTransitions.length===0&&this.eventStore.mode!==ce.Replay)throw new Error("Can not run game without a current or incoming scene");if(this.updateGameTime(),this.eventStore.mode===ce.Replay){const i=this.eventStore.dequeueEvents(Wt.now());this.eventMaterializer.materialize(i),this.eventStore.eventQueueLength===0&&!this.replayEventsButtonEnabled&&(this.setReplayEventsButtonEnabled(!0),this.setStopReplayButtonEnabled(!1))}for(this.handleIncomingSceneTransitions(this.incomingSceneTransitions),this.update(),this.draw(t);this.snapshots.length>0;)this.snapshots.shift()?.delete();this.snapshots.push(this.takeCurrentSceneSnapshot()),this.freeNodesScene.draw(t),this.pendingScreenshot&&(this.handlePendingScreenshot(this.pendingScreenshot),this.pendingScreenshot=void 0)}this.priorUpdateTime=m2c2Globals.now,this.surface.requestAnimationFrame(this.loop.bind(this))}updateGameTime(){this.options.timeStepping?m2c2Globals.now=this.steppingNow:m2c2Globals.now=performance.now(),this.priorUpdateTime?m2c2Globals.deltaTime=m2c2Globals.now-this.priorUpdateTime:m2c2Globals.deltaTime=0}handleIncomingSceneTransitions(t){if(t.length!==0&&(this.snapshots.length>0||t[0].transition.type===de.None)){const i=t.shift();if(i===void 0)throw new Error("no incoming scene transition");const n=i.scene,u=i.transition;if(u.type===de.None){this.currentScene&&(this.currentScene._active=!1),this.currentScene=n,this.currentScene._active=!0,this.raiseSceneEvent(n,"SceneSetup"),this.raiseSceneEvent(n,"SceneAppear");return}if(this.currentSceneSnapshot=this.snapshots.shift(),!this.currentSceneSnapshot)throw new Error("No snapshot available for outgoing scene");const h=this.createOutgoingScene(this.currentSceneSnapshot);h._active=!0,this.currentScene&&(this.currentScene._active=!1),this.currentScene=n,this.currentScene._active=!0,this.raiseSceneEvent(n,"SceneSetup"),this.animateSceneTransition(n,u,h)}}createOutgoingScene(t){const i=new Ue({name:X.OUTGOING_SCENE_NAME});i.size.width=this.canvasCssWidth,i.size.height=this.canvasCssHeight,this.addScene(i);const n={imageName:X.OUTGOING_SCENE_IMAGE_NAME,canvaskitImage:t,width:this.canvasCssWidth,height:this.canvasCssHeight,status:Yt.Ready,localize:!1,isFallback:!1};this.imageManager.addImage(n);const u=new oi({name:X.OUTGOING_SCENE_SPRITE_NAME,imageName:X.OUTGOING_SCENE_IMAGE_NAME,position:{x:this.canvasCssWidth/m2c2Globals.rootScale/2,y:this.canvasCssHeight/m2c2Globals.rootScale/2}});return u.scale=1/m2c2Globals.rootScale,i.addChild(u),i}async registerPlugin(t){if(t.type!==si.Game)throw new Error(`registerPlugin(): plugin ${t.id} is not a game plugin. It is a ${t.type} plugin.`);if(this.plugins.includes(t)||this.plugins.map(i=>i.id).includes(t.id))throw new Error(`registerPlugin(): plugin ${t.id} already registered.`);this.plugins.push(t),t.initialize&&await t.initialize(this)}update(){this.executeBeforeUpdatePlugins(),this.updateScenes(),this.executeAfterUpdatePlugins()}updateScenes(){this.scenes.filter(t=>t._active).forEach(t=>t.update()),this.freeNodesScene.update()}executeBeforeUpdatePlugins(){this.plugins.filter(t=>typeof t.beforeUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.beforeUpdate&&t.beforeUpdate(this,m2c2Globals.deltaTime)})}executeAfterUpdatePlugins(){this.plugins.filter(t=>typeof t.afterUpdate=="function"&&t.disabled!==!0).forEach(t=>{t.afterUpdate&&t.afterUpdate(this,m2c2Globals.deltaTime)})}draw(t){this.scenes.filter(i=>i._active).forEach(i=>i.draw(t)),this.drawnFrames++,this.calculateFps(),this.showFps&&this.drawFps(t)}calculateFps(){this.lastFpsUpdate===0?(this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+X.FPS_DISPLAY_UPDATE_INTERVAL):m2c2Globals.now>=this.nextFpsUpdate&&(this.fpsRate=this.drawnFrames/((m2c2Globals.now-this.lastFpsUpdate)/1e3),this.drawnFrames=0,this.lastFpsUpdate=m2c2Globals.now,this.nextFpsUpdate=m2c2Globals.now+X.FPS_DISPLAY_UPDATE_INTERVAL,this.gameMetrics.length<this.maximumRecordedActivityMetrics&&this.fpsRate<this.fpsMetricReportThreshold&&this.gameMetrics.push({fps:Number.parseFloat(this.fpsRate.toFixed(2)),fps_interval_ms:X.FPS_DISPLAY_UPDATE_INTERVAL,fps_report_threshold:this.fpsMetricReportThreshold,activity_type:si.Game,activity_uuid:this.uuid,iso8601_timestamp:new Date().toISOString()}))}takeCurrentSceneSnapshot(){if(this.surface===void 0)throw new Error("CanvasKit surface is undefined");return this.surface.makeImageSnapshot()}handlePendingScreenshot(t){if(!this.surface)throw new Error("no surface");let i;if(t.rect.length==4){const u=t.rect[0]*m2c2Globals.canvasScale,h=t.rect[1]*m2c2Globals.canvasScale,C=t.rect[2]*m2c2Globals.canvasScale,F=t.rect[3]*m2c2Globals.canvasScale,B=[u,h,u+C,h+F];i=this.surface.makeImageSnapshot(B)}else i=this.surface.makeImageSnapshot();const n=i.encodeToBytes();t.promiseResolve(n)}takeScreenshot(t,i,n,u){if(!this.surface)throw new Error("no canvaskit surface. unable to take screenshot.");const h=[t,i,n,u].map(C=>C?0:1).reduce((C,F)=>C+F);return new Promise((C,F)=>{switch(h){case 0:{if(!t||!i||!n||!u){F("missing values in arguments for takeScreenshot()");return}this.pendingScreenshot={rect:[t,i,n,u],promiseResolve:C};break}case 4:{this.pendingScreenshot={rect:[],promiseResolve:C};break}default:F("Exactly 0 or 4 arguments must be supplied to takeScreenshot()")}})}animateSceneTransition(t,i,n){const u=i.duration;switch(t._transitioning=!0,n._transitioning=!0,i.type){case de.Slide:{switch(i.direction){case fe.Left:t.position.x=t.size.width,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:-n.size.width,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Right:t.position.x=-t.size.width,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:n.size.width,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Up:t.position.y=t.size.height,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:0,y:-n.size.height},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;case fe.Down:t.position.y=-t.size.height,t.run(V.sequence([V.move({point:{x:0,y:0},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{t._transitioning=!1,this.raiseSceneEvent(t,"SceneAppear"),this.removeScene(X.OUTGOING_SCENE_NAME)},runDuringTransition:!0})])),n.run(V.sequence([V.move({point:{x:0,y:n.size.height},duration:u,easing:i.easing,runDuringTransition:!0}),V.custom({callback:()=>{n._active=!1,n._transitioning=!1,this.currentSceneSnapshot&&this.currentSceneSnapshot.delete()},runDuringTransition:!0})]));break;default:throw new Error("unknown transition direction")}break}default:throw new Error("unknown transition type")}}drawFps(t){t.save();const i=m2c2Globals.canvasScale;if(t.scale(1/i,1/i),!this.fpsTextFont||!this.fpsTextPaint)throw new Error("fps font or paint is undefined");t.drawText("FPS: "+this.fpsRate.toFixed(2),0,0+X.FPS_DISPLAY_TEXT_FONT_SIZE*i,this.fpsTextPaint,this.fpsTextFont),t.restore()}createEventListener(t,i,n,u){const h=this.nodes.filter(F=>F.name===i);h.length>1&&console.warn(`warning: createEventListener() found more than one node with name ${i}. Event listener will be attached to first node found. All nodes that receive tap events should be uniquely named`);const C=h.filter(F=>F.name===i).find(Boolean);if(C===void 0)throw new Error(`could not create event listener. node with name ${i} could not be found in the game node tree`);if(!Object.values(G).includes(t))throw new Error(`game ${this.id}: could not create event listener. event type ${t} is not known`);C.addEventListener(t,n,u)}get nodes(){function t(n,u){u.push(n),n.children.forEach(h=>t(h,u))}const i=new Array;return[...this.scenes,this.freeNodesScene].forEach(n=>t(n,i)),i}get entities(){return this.nodes}htmlCanvasPointerDownHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;if(!this.htmlCanvas)throw new Error("main html canvas is undefined");const n={type:"DomPointerDown",target:this.htmlCanvas,x:t.offsetX/m2c2Globals.rootScale,y:t.offsetY/m2c2Globals.rootScale,...q.createTimestamps()};this.eventStore.addEvent(n);const u={target:i,type:G.PointerDown,handled:!1,...q.createTimestamps()};this.processDomPointerDown(i,u,t),this.processDomPointerDown(this.freeNodesScene,u,t)}htmlCanvasPointerUpHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerUp,handled:!1,...q.createTimestamps()};this.processDomPointerUp(i,n,t),this.processDomPointerUp(this.freeNodesScene,n,t)}htmlCanvasPointerMoveHandler(t){t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerMove,handled:!1,...q.createTimestamps()};this.processDomPointerMove(i,n,t),this.processDomPointerMove(this.freeNodesScene,n,t)}htmlCanvasPointerLeaveHandler(t){if(!this.currentScene)return;t.preventDefault();const i=this.currentScene;if(!i||!this.sceneCanReceiveUserInteraction(i))return;const n={target:i,type:G.PointerLeave,handled:!1,...q.createTimestamps()};this.processDomPointerLeave(i,n,t),this.processDomPointerLeave(this.freeNodesScene,n,t)}processDomPointerDown(t,i,n){i.handled||(t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressed=!0,t.pressedAndWithinHitArea=!0,t.pressedInitialPointerOffset={x:n.offsetX,y:n.offsetY},this.raiseM2PointerDownEvent(t,i,n),this.raiseTapDownEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerDown(u,i,n)))}processDomPointerUp(t,i,n){if(!i.handled){if(t.dragging){t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,i,n),i.handled=!0;return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpEvent(t,i,n),this.raiseTapUpAny(t,i,n),this.raiseM2PointerUpEvent(t,i,n)):t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea==!1?(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseTapUpAny(t,i,n)):t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2PointerUpEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerUp(u,i,n))}}processDomPointerMove(t,i,n){if(!i.handled){if(t.isUserInteractionEnabled&&t.draggable&&t.pressed){let u=!1,h,C;t.dragging===!1?(t.dragging=!0,u=!0,h=n.offsetX-t.pressedInitialPointerOffset.x,C=n.offsetY-t.pressedInitialPointerOffset.y):(h=n.offsetX-t.draggingLastPointerOffset.x,C=n.offsetY-t.draggingLastPointerOffset.y),t.position.x+=h,t.position.y+=C,t.draggingLastPointerOffset={x:n.offsetX,y:n.offsetY},i.handled=!0,u?this.raiseM2DragStartEvent(t,i,n):this.raiseM2DragEvent(t,i,n);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,n)),t.isUserInteractionEnabled&&this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(this.raiseM2PointerMoveEvent(t,i,n),t.withinHitArea=!0),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerMove(u,i,n))}}processDomPointerLeave(t,i,n){if(!i.handled){if(t.dragging){const u={target:t,type:G.DragEnd,handled:!1,...q.createTimestamps()};t.dragging=!1,t.pressed=!1,t.pressedAndWithinHitArea=!1,this.raiseM2DragEndEvent(t,u,n);return}t.isUserInteractionEnabled&&t.pressed&&t.pressedAndWithinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.pressedAndWithinHitArea=!1,this.raiseTapLeaveEvent(t,i,n)),t.isUserInteractionEnabled&&t.withinHitArea&&!this.IsCanvasPointWithinNodeBounds(t,n.offsetX,n.offsetY)&&(t.withinHitArea=!1,this.raiseM2PointerLeaveEvent(t,i,n)),t.children&&t.children.filter(u=>!u.hidden).filter(u=>u.isDrawable).sort((u,h)=>h.zPosition-u.zPosition).forEach(u=>this.processDomPointerLeave(u,i,n))}}raiseM2PointerDownEvent(t,i,n){i.target=t,i.type=G.PointerDown,this.raiseEventOnListeningNodes(t,i,n)}raiseTapDownEvent(t,i,n){i.target=t,i.type=G.TapDown,this.raiseEventOnListeningNodes(t,i,n)}raiseTapLeaveEvent(t,i,n){i.target=t,i.type=G.TapLeave,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerUpEvent(t,i,n){i.target=t,i.type=G.PointerUp,this.raiseEventOnListeningNodes(t,i,n)}raiseTapUpEvent(t,i,n){i.target=t,i.type=G.TapUp,this.raiseEventOnListeningNodes(t,i,n)}raiseTapUpAny(t,i,n){i.target=t,i.type=G.TapUpAny,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerMoveEvent(t,i,n){i.target=t,i.type=G.PointerMove,this.raiseEventOnListeningNodes(t,i,n)}raiseM2PointerLeaveEvent(t,i,n){i.target=t,i.type=G.PointerLeave,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragStartEvent(t,i,n){i.target=t,i.type=G.DragStart,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragEvent(t,i,n){i.target=t,i.type=G.Drag,this.raiseEventOnListeningNodes(t,i,n)}raiseM2DragEndEvent(t,i,n){i.target=t,i.type=G.DragEnd,this.raiseEventOnListeningNodes(t,i,n)}raiseSceneEvent(t,i){const n={target:t,type:i,...q.createFrameUpdateTimestamps()};t.eventListeners.filter(u=>u.type===i).forEach(u=>u.callback(n))}calculatePointWithinNodeFromDomPointerEvent(t,i){let n=t.size.width,u=t.size.height;if(t.type===at.Shape&&t.shapeType===Ut.Circle){const et=t.circleOfRadius;if(!et)throw"circleOfRadius is undefined";n=et*2,u=et*2}let h=i.offsetX,C=i.offsetY;const F=q.calculateNodeAbsoluteBoundingBox(t);q.nodeOrAncestorHasBeenRotated(t)&&q.calculateRotationTransforms(t).forEach(ct=>{const ut=q.rotatePoint({x:h,y:C},-ct.radians,ct.center);h=ut.x,C=ut.y});const B=(h-F.xMin)/(F.xMax-F.xMin)*n,U=(C-F.yMin)/(F.yMax-F.yMin)*u;return{x:B,y:U}}onStart(t,i){this.addEventListener(G.ActivityStart,t,i)}onCancel(t,i){this.addEventListener(G.ActivityCancel,t,i)}onEnd(t,i){this.addEventListener(G.ActivityEnd,t,i)}onData(t,i){this.addEventListener(G.ActivityData,t,i)}onWarmupStart(t,i){this.addEventListener(G.GameWarmupStart,t,i)}onWarmupEnd(t,i){this.addEventListener(G.GameWarmupEnd,t,i)}addEventListener(t,i,n){const u={type:t,activityUuid:this.uuid,callback:i};n?.replaceExisting&&(this.eventListeners=this.eventListeners.filter(h=>!(h.activityUuid===u.activityUuid&&h.type===u.type))),this.eventListeners.push(u)}raiseActivityEventOnListeners(t,i){i&&(t={...t,...i}),this.eventListeners.filter(n=>n.type===t.type).forEach(n=>{n.callback(t)})}raiseEventOnListeningNodes(t,i,n){t.eventListeners.filter(u=>u.type===i.type).forEach(u=>{if(u.nodeUuid===t.uuid){switch(i.target=t,i.type){case G.PointerDown:case G.PointerMove:case G.PointerUp:case G.PointerLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,n),i.buttons=n.buttons,u.callback(i);break;case G.TapDown:case G.TapUp:case G.TapUpAny:case G.TapLeave:i.point=this.calculatePointWithinNodeFromDomPointerEvent(t,n),i.buttons=n.buttons,u.callback(i);break;case G.DragStart:case G.Drag:case G.DragEnd:i.position={x:t.position.x,y:t.position.y},i.buttons=n.buttons,u.callback(i);break}t.suppressEvents||this.eventStore.addEvent(i)}})}sceneCanReceiveUserInteraction(t){return!!(t._active&&t._transitioning===!1)}IsCanvasPointWithinNodeBounds(t,i,n){if(!t.isDrawable)throw"only drawable nodes can receive pointer events";if(t.type===at.Shape&&t.shapeType===Ut.Circle){const h=q.calculateNodeAbsoluteBoundingBox(t),C=t.circleOfRadius;if(!C)throw"circleOfRadius is undefined";const F={x:h.xMin+C*t.absoluteScale,y:h.yMin+C*t.absoluteScale};return Math.sqrt(Math.pow(i-F.x,2)+Math.pow(n-F.y,2))<=C*t.absoluteScale}if(t.size.width===0||t.size.height===0||t.type===at.TextLine&&isNaN(t.size.width))return!1;const u=q.calculateRotatedPoints(t);return t.isUserInteractionEnabled&&q.isPointInsideRectangle({x:i,y:n},u)}}function ua(){globalThis.m2c2Globals={now:performance.now(),iso8601Now:"",deltaTime:NaN,canvasScale:NaN,rootScale:1,canvasCssWidth:NaN,canvasCssHeight:NaN,m2NodeClassRegistry:{},__sequence:0,get eventSequence(){return m2c2Globals.__sequence++,m2c2Globals.__sequence-1},addedScriptUrls:[]}}ua();const Wn=class Gn{constructor(t){this.startTime=NaN,this.stopTime=NaN,this.stopped=!0,this.cumulativeElapsed=NaN,this.name=t}static now(){return window.performance.now()}static start(t){let i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)i=new Gn(t),i.cumulativeElapsed=0,this._timers.push(i);else if(i.stopped==!1)throw new Error(`can't start timer. timer with name ${t} is already started`);i.startTime=window.performance.now(),i.stopped=!1}static stop(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't stop timer. timer with name ${t} does not exist`);if(i.stopped===!0)throw new Error(`can't stop timer. timer with name ${t} is already stopped`);i.stopTime=window.performance.now(),i.cumulativeElapsed=i.cumulativeElapsed+i.stopTime-i.startTime,i.stopped=!0}static restart(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't restart timer. timer with name ${t} does not exist`);i.startTime=window.performance.now(),i.cumulativeElapsed=0,i.stopped=!1}static elapsed(t){const i=this._timers.filter(n=>n.name===t).find(Boolean);if(i===void 0)throw new Error(`can't get elapsed time. timer with name ${t} does not exist`);return i.stopped?i.cumulativeElapsed:i.cumulativeElapsed+window.performance.now()-i.startTime}static remove(t){if(this._timers.filter(n=>n.name===t).find(Boolean)===void 0)throw new Error(`can't remove timer. timer with name ${t} does not exist`);this._timers=this._timers.filter(n=>n.name!=t)}static removeAll(){this._timers=new Array}static exists(t){return this._timers.some(i=>i.name===t)}};Wn._timers=new Array;let da=Wn;class pr{static SingleFromRange(t,i){return Math.floor(Math.random()*(i-t+1))+t}static FromRangeWithoutReplacement(t,i,n){if(t>n-i+1)throw new Error(`number of requested draws (n = ${t}) is greater than number of integers in range [ ${i}, ${n}]`);const u=new Array;for(let h=0;h<t;h++){const C=pr.SingleFromRange(i,n);u.includes(C)?t++:u.push(C)}return u}static FromGridWithoutReplacement(t,i,n,u){const h=new Array,C=i*n-1,F=this.FromRangeWithoutReplacement(t,0,C);let B=0,U=NaN;for(;B<t;){const et=F[B]%n,ct=(F[B]-et)/n;if(u===void 0||u(ct,et))h.push({row:ct,column:et}),B++;else{do U=this.FromRangeWithoutReplacement(1,0,C)[0];while(F.includes(U));F[B]=U}}return h}}class fa extends re{constructor(t){super(t),this.type=at.SoundPlayer,this.isDrawable=!1,this.soundName=t.soundName}initialize(){}dispose(){}duplicate(t){throw new Error("Method not implemented.")}}class pa extends re{constructor(t){if(super(t),this.type=at.SoundRecorder,this.isDrawable=!1,this._isRecording=!1,this._isPaused=!1,this.audioChunks=[],this.timerUuid="",t?.mimeType){const i=this.getMediaRecorderSupportedAudioMimeTypes();if(i.includes(t.mimeType))this.mimeType=t.mimeType;else if(console.warn(`Unsupported MIME type in SoundRecorderOptions: ${t.mimeType}. Supported types are: ${i}.`),t.backupMimeTypes){const n=this.getSupportedBackupMimeType(t.backupMimeTypes);n&&(this.mimeType=n,console.log(`Using backup MIME type: ${n}.`))}}t?.audioTrackConstraints&&(this.audioTrackConstraints=t.audioTrackConstraints),t?.maximumDuration&&(this.maximumDuration=t.maximumDuration)}initialize(){}async start(){if(this.isRecording)throw new Error("cannot start SoundRecorder because it is already started.");const t=this.getMediaRecorderSupportedAudioMimeTypes();if(t.length===0)throw new Error("SoundRecorder found no supported MIME types for MediaRecorder.");this.mimeType||(this.mimeType=t[0],console.log(`Using MIME type: ${this.mimeType}.`));let i;try{i=await navigator.mediaDevices.getUserMedia({audio:this.audioTrackConstraints?this.audioTrackConstraints:!0})}catch{throw new Error("Error getting user media.")}if(!i)throw new Error("no stream.");const n=i.getAudioTracks();this.mediaTrackSettings=n?.map(u=>u.getSettings()),this.mediaRecorder=new MediaRecorder(i,{mimeType:this.mimeType}),this.mediaRecorder.ondataavailable=u=>{this.audioChunks.push(u.data)},this.mediaRecorder.onerror=u=>{throw new Error(`MediaRecorder error: ${u?.error?.message} ${u?.message}`)},this.mediaRecorder.start(),this.beginIso8601Timestamp=new Date().toISOString(),this.timerUuid=De.generate(),Wt.startNew(this.timerUuid),this._isRecording=!0,this._isPaused=!1}async stop(){if(!this.isRecording)throw new Error("cannot stop SoundRecorder because it has not started.");return new Promise(t=>{if(!this.mediaRecorder)throw new Error("no media recorder");this.mediaRecorder.onstop=async()=>{if(!this.mimeType)throw new Error("no mimeType");this._isRecording=!1,this._isPaused=!1;const i=new Blob(this.audioChunks,{type:this.getMimeTypeWithoutCodecs(this.mimeType)}),n=await this.blobToBase64(i);t({mimeType:this.mimeType,beginIso8601Timestamp:this.beginIso8601Timestamp??"",endIso8601Timestamp:this.endIso8601Timestamp??"",duration:Wt.elapsed(this.timerUuid),audioTrackSettings:this.mediaTrackSettings,audioBase64:n,audioBlob:i})},this.mediaRecorder.stop(),this.endIso8601Timestamp=new Date().toISOString(),this.isPaused||Wt.stop(this.timerUuid)})}pause(){if(!this.isRecording)throw new Error("cannot pause SoundRecorder because it is not started.");if(this.isPaused)throw new Error("cannot pause SoundRecorder because it is already paused.");this.mediaRecorder?.pause(),this._isPaused=!0,Wt.stop(this.timerUuid)}resume(){if(!this.isRecording)throw new Error("cannot resume SoundRecorder because it is not started.");if(!this.isPaused)throw new Error("cannot resume SoundRecorder because it is not paused.");this.mediaRecorder?.resume(),this._isPaused=!1,Wt.start(this.timerUuid)}get isRecording(){return this._isRecording}get isPaused(){return this._isPaused}update(){if(super.update(),this.isRecording&&!this.isPaused&&this.maximumDuration!==void 0&&Wt.elapsed(this.timerUuid)>this.maximumDuration){this.pause();return}}getMediaRecorderSupportedAudioMimeTypes(){const t=["audio"],i=["webm","ogg","mp3","mp4","x-matroska","3gpp","3gpp2","3gp2","quicktime","mpeg","aac","flac","x-flac","wave","wav","x-wav","x-pn-wav","not-supported"],n=["vp9","vp9.0","vp8","vp8.0","avc1","av1","h265","h.265","h264","h.264","opus","vorbis","pcm","aac","mpeg","mp4a","rtx","red","ulpfec","g722","pcmu","pcma","cn","telephone-event","not-supported"];return[...new Set(i.flatMap(u=>t.flatMap(h=>[`${h}/${u}`]))),...new Set(i.flatMap(u=>n.flatMap(h=>t.flatMap(C=>[`${C}/${u};codecs=${h}`])))),...new Set(i.flatMap(u=>n.flatMap(h=>n.flatMap(C=>t.flatMap(F=>[`${F}/${u};codecs="${h}, ${C}"`])))))].filter(u=>MediaRecorder.isTypeSupported(u))}blobToBase64(t){return new Promise((i,n)=>{const u=new FileReader;u.onloadend=()=>{const h=u.result?.toString().split(",").pop();if(h===void 0)throw new Error("base64WithoutPrefix is undefined.");i(h)},u.onerror=n,u.readAsDataURL(t)})}getMimeTypeWithoutCodecs(t){const i=t.match(/^[^;]+/);return i?i[0]:""}getSupportedBackupMimeType(t){const i=this.getMediaRecorderSupportedAudioMimeTypes();for(const n of t)if(i.includes(n))return n}dispose(){}duplicate(t){throw new Error(`Method not implemented. ${t}`)}}class ma{static create(t){return new Array}}console.log("\u26AA @m2c2kit/core version 0.3.20 (33cadc6d)");export{V as Action,si as ActivityType,Ft as CanvasKitHelpers,Vs as ColorfulMutablePath,Xs as Composite,X as Constants,Dt as ConstraintType,pn as CustomAction,Pn as Dimensions,Te as Easings,j as Equal,Js as Equals,An as EventStore,ce as EventStoreMode,wn as FadeAlphaAction,_n as FontManager,ca as Game,dn as GroupAction,xi as I18n,or as ImageManager,ki as Label,ze as LabelHorizontalAlignmentMode,bn as LayoutConstraint,da as LegacyTimer,G as M2EventType,Yt as M2ImageStatus,re as M2Node,Cn as M2NodeFactory,at as M2NodeType,zt as M2SoundStatus,q as M2c2KitHelpers,vn as MoveAction,Ni as MutablePath,Ln as NoneTransition,mn as PlayAction,pr as RandomDraws,sr as RepeatAction,fn as RepeatForeverAction,Sn as RotateAction,yn as ScaleAction,Ue as Scene,zn as SceneTransition,un as SequenceAction,ai as Shape,Ut as ShapeType,Dn as SlideTransition,Un as SoundManager,fa as SoundPlayer,pa as SoundRecorder,oi as Sprite,ma as Story,Oi as TextLine,Wt as Timer,Be as Transition,fe as TransitionDirection,de as TransitionType,De as Uuid,gn as WaitAction,x as WebColors,fr as WebGlInfo,Fe as handleInterfaceOptions};